Skip to content

Commit

Permalink
Added support for normalized accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
lasalvavida committed Aug 30, 2016
1 parent 2471b03 commit a8afa5e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
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
26 changes: 26 additions & 0 deletions 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

0 comments on commit a8afa5e

Please sign in to comment.