Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glTF 1.0.1 Adds support for normalized vertex arrays and a test #4247

Merged
merged 3 commits into from
Aug 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ define([
vertexBuffer : rendererBuffers[a.bufferView],
componentsPerAttribute : getBinaryAccessor(a).componentsPerAttribute,
componentDatatype : a.componentType,
normalize : false,
normalize : defaultValue(a.normalized, false),
offsetInBytes : a.byteOffset,
strideInBytes : a.byteStride
});
Expand Down
110 changes: 55 additions & 55 deletions Specs/Data/Models/Box-Color/Box-Color.gltf
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
{
"accessors": {
"accessor_21": {
"bufferView": "bufferView_29",
"bufferView": "bufferView_1",
"byteOffset": 0,
"byteStride": 0,
"componentType": 5123,
"count": 36,
"type": "SCALAR"
"type": "SCALAR",
"min": [
0
],
"max": [
23
]
},
"accessor_23": {
"bufferView": "bufferView_30",
"bufferView": "bufferView_0",
"byteOffset": 0,
"byteStride": 12,
"byteStride": 0,
"componentType": 5126,
"count": 24,
"max": [
Expand All @@ -27,22 +33,41 @@
"type": "VEC3"
},
"accessor_27": {
"bufferView": "bufferView_30",
"byteOffset": 288,
"byteStride": 12,
"componentType": 5126,
"bufferView": "bufferView_0",
"byteOffset": 576,
"byteStride": 0,
"componentType": 5121,
"count": 24,
"max": [
1,
1,
1
255,
255,
255
],
"min": [
0,
0,
0
],
"type": "VEC3"
"type": "VEC3",
"normalized": true
},
"accessor_normal_generated": {
"bufferView": "bufferView_0",
"byteOffset": 288,
"byteStride": 0,
"componentType": 5126,
"count": 24,
"type": "VEC3",
"min": [
-1,
-1,
-1
],
"max": [
1,
1,
1
]
}
},
"animations": {},
Expand All @@ -56,24 +81,24 @@
"version": "1.0"
},
"bufferViews": {
"bufferView_29": {
"buffer": "Box",
"byteLength": 72,
"bufferView_0": {
"buffer": "buffer_0",
"byteLength": 648,
"byteOffset": 0,
"target": 34963
},
"bufferView_30": {
"buffer": "Box",
"byteLength": 576,
"byteOffset": 72,
"target": 34962
},
"bufferView_1": {
"buffer": "buffer_0",
"byteLength": 72,
"byteOffset": 648,
"target": 34963
}
},
"buffers": {
"Box": {
"byteLength": 648,
"buffer_0": {
"type": "arraybuffer",
"uri": "data:application/octet-stream;base64,AAABAAIAAwACAAEABAAFAAYABwAGAAUACAAJAAoACwAKAAkADAANAA4ADwAOAA0AEAARABIAEwASABEAFAAVABYAFwAWABUAAAAAvwAAAL8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAL8AAAA/AAAAPwAAAL8AAAC/AAAAvwAAAL8AAAC/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAPwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAPwAAAD8AAAC/AACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAD8AAAAAAACAPwAAAD8AAAAAAACAPwAAAD8AAAAAAACAPwAAAD8AAAAAAACAPwAAgD8AAAAAAACAPwAAgD8AAAAAAACAPwAAgD8AAAAAAACAPwAAgD8AAAAAAAAAAAAAgD8AAAAAAA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AD/SgCBSgCBSgCBSgCBAAABAAIAAwACAAEABAAFAAYABwAGAAUACAAJAAoACwAKAAkADAANAA4ADwAOAA0AEAARABIAEwASABEAFAAVABYAFwAWABUA"
}
},
"materials": {
Expand All @@ -100,54 +125,29 @@
}
},
"nodes": {
"Geometry-mesh002Node": {
"rootNode": {
"children": [],
"matrix": [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
],
"meshes": [
"Geometry-mesh002"
],
"name": "Mesh"
},
"node_1": {
"children": [
"Geometry-mesh002Node"
],
"matrix": [
1,
0,
0,
0,
0,
1,
0,
-1,
0,
0,
1,
0,
1,
0,
0,
0,
0,
1
],
"name": "Y_UP_Transform"
]
}
},
"programs": {
Expand All @@ -164,7 +164,7 @@
"scenes": {
"defaultScene": {
"nodes": [
"node_1"
"rootNode"
]
}
},
Expand Down Expand Up @@ -230,4 +230,4 @@
},
"samplers": {},
"textures": {}
}
}
28 changes: 27 additions & 1 deletion Specs/Scene/ModelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,32 @@ defineSuite([
});
});

it('loads a glTF with WEB3D_quantized_attributes and accessor.normalized', function() {
return loadModel(boxQuantizedUrl).then(function(m) {
verifyRender(m);
var gltf = m.gltf;
var accessors = gltf.accessors;
var normalAccessor = accessors.accessor_25;
var positionAccessor = accessors.accessor_23;
normalAccessor.normalized = true;
positionAccessor.normalized = true;
var decodeMatrixArray = normalAccessor.extensions.WEB3D_quantized_attributes.decodeMatrix;
var decodeMatrix = new Matrix4();
Matrix4.unpack(decodeMatrixArray, 0, decodeMatrix);
Matrix4.multiplyByUniformScale(decodeMatrix, 65535.0, decodeMatrix);
Matrix4.pack(decodeMatrix, decodeMatrixArray);
decodeMatrixArray = positionAccessor.extensions.WEB3D_quantized_attributes.decodeMatrix;
Matrix4.unpack(decodeMatrixArray, 0, decodeMatrix);
Matrix4.multiplyByUniformScale(decodeMatrix, 65535.0, decodeMatrix);
Matrix4.pack(decodeMatrix, decodeMatrixArray);
primitives.remove(m);
return loadModelJson(gltf, {}).then(function(m) {
verifyRender(m);
primitives.remove(m);
});
});
});

it('loads a glTF with WEB3D_quantized_attributes POSITION and NORMAL where primitives with different accessors use the same shader', function() {
return loadModel(milkTruckQuantizedUrl).then(function(m) {
verifyRender(m);
Expand Down Expand Up @@ -1651,7 +1677,7 @@ defineSuite([
}
}

it('loads a gltf with color attributes', function() {
it('loads a gltf with normalized color attributes', function() {
return loadModel(boxColorUrl).then(function(m) {
expect(m.ready).toBe(true);
expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
Expand Down