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

Update version -> 2.0 (#271) #272

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1406b32
Update version -> 2.0 (#271)
Apr 28, 2017
06a0954
Added pbrToMaterialsCommon
lasalvavida Apr 28, 2017
d373dc2
Moved out getJointCountForMaterials as a separate function and added
lasalvavida Apr 28, 2017
c43c6d8
Infer missing bufferView targets
lasalvavida Apr 28, 2017
119d008
Add option to break from object iterator
May 3, 2017
8c909e8
Style tweaks
lilleyse May 3, 2017
5b04132
Mistake from previous commit
lilleyse May 3, 2017
9891c39
Added some unit tests for ForEach iterator
May 15, 2017
3d107c2
Merge pull request #275 from AnalyticalGraphicsInc/2.0-bufferView-tar…
lilleyse May 18, 2017
d9842a0
Added spec for getJointCountForMaterials and some cleanup
lasalvavida Jun 9, 2017
5c722f9
Clean up jsHint
lasalvavida Jun 9, 2017
d7d9391
fit -> it
lasalvavida Jun 9, 2017
8f83cc2
Fix failing test
lasalvavida Jun 9, 2017
4308188
Merge pull request #274 from AnalyticalGraphicsInc/2.0-pbr
lilleyse Jun 9, 2017
715ebc2
Added processPbrMetallicRoughness
moneimne Jul 11, 2017
40a7600
Updated processPbrMetallicRoughness per PR comments and fixed bug tha…
moneimne Jul 13, 2017
7785d21
Split glsl type and webGL conversions into separate files
moneimne Jul 13, 2017
6c9cc69
Added default byteOffset to accessors
moneimne Jul 14, 2017
8f7cf87
Added default byteOffset to bufferViews
moneimne Jul 14, 2017
357aaa7
Took uninterleaveAndPackBuffers from master and upgraded to 2.0
moneimne Jul 14, 2017
401691d
Fixed jsHint issues and removeUnusedProperties tests
moneimne Jul 17, 2017
58ca4b6
Fixed removeUnusedVertices tests by changing according to master
moneimne Jul 20, 2017
81b8b32
Fixed quantizeAttributes tests by changing according to master
moneimne Jul 20, 2017
ff7af4a
Fixed mergeDuplicateVertices tests by changing according to master
moneimne Jul 20, 2017
abcc18a
Fixed generateTangentsBitangents test to account for tangent and bita…
moneimne Jul 20, 2017
e2097f9
Updated gulpfile and added skinning upgrade to 2.0
moneimne Jul 21, 2017
ccdf46b
Keep extensions as object instead of array
moneimne Jul 21, 2017
a67e5e7
Should not change materials to arrays for 1.0
moneimne Jul 21, 2017
cae4279
Only try to switch jointNames over if defined
moneimne Jul 21, 2017
8a444f7
Updated tests to support changes to diffuse texture changes
moneimne Jul 21, 2017
59f4478
Updated per changes in Cesium
moneimne Jul 25, 2017
f24ef8a
Another update per Cesium changes
moneimne Jul 26, 2017
b10c842
Removed print statement
moneimne Jul 26, 2017
1ae7781
Updated per Cesium cmpt tiles fix
moneimne Jul 26, 2017
bacada9
Emulate the Earth with a set of gradients.
emackey Jul 27, 2017
4350ab8
Merge pull request #1 from emackey/pbr-earth-reflections
moneimne Jul 28, 2017
bf83211
Updated per changes to Cesium for gltf-2.0 PR
moneimne Aug 7, 2017
bdbcdc9
Removed a couple files from cesium-combine gul task
lilleyse Aug 7, 2017
6965cf0
Merge pull request #301 from moneimne/processPbrMetallicRoughness
lilleyse Aug 7, 2017
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: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Change Log
* Change Cesium `Geometry`'s and `VertexFormat`'s `binormal` attribute to bitangent.
* Fixed a bug in `combinePrimitives` where combining primitives can overflow uint16 for the resulting indices. [#230](https://github.com/AnalyticalGraphicsInc/gltf-pipeline/issues/230)
* Made `generateNormals` stage optional and added `smoothNormals` option for generating smooth normals if the model does not have normals. [#240](https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/240)
* `updateVersion` stage for upgrades the glTF version of an asset from `1.0` to `2.0`. [#223](https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/223)
* All pipeline stages now operate on glTF `2.0` assets.

### 0.1.0-alpha10 - 2017-01-10
* Added `tangentsBitangents` generation option
Expand Down
31 changes: 22 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,17 @@ function amdify(source, subDependencyMapping) {
paths.push(requireMapping[variable]);
}
}
var definePathsHeader = '\'' + paths.join('\',\n \'') + '\'';
var defineVariablesHeader = variables.join(',\n ');
var defineHeader = '/*global define*/\n' +
'define([\n' +
' ' + definePathsHeader + '\n' +
' ], function(\n' +
' ' + defineVariablesHeader + ') {\n ';
'define([], function() {\n ';
if (paths.length > 0) {
var definePathsHeader = '\'' + paths.join('\',\n \'') + '\'';
var defineVariablesHeader = variables.join(',\n ');
defineHeader = '/*global define*/\n' +
'define([\n' +
' ' + definePathsHeader + '\n' +
' ], function(\n' +
' ' + defineVariablesHeader + ') {\n ';
}
var defineFooter = '\n});\n';
if (defined(returnValue)) {
defineFooter = '\n return ' + returnValue + ';' + defineFooter;
Expand Down Expand Up @@ -273,17 +277,26 @@ gulp.task('build-cesium', function () {
var outputDir = 'dist/cesium';
var files = [
'addDefaults.js',
'addExtensionsRequired.js',
'addExtensionsUsed.js',
'addPipelineExtras.js',
'addToArray.js',
'byteLengthForComponentType.js',
'findAccessorMinMax.js',
'ForEach.js',
'getAccessorByteStride.js',
'getStatistics.js',
'getUniqueId.js',
'getJointCountForMaterials.js',
'glslTypeToWebGLConstant.js',
'numberOfComponentsForType.js',
'parseBinaryGltf.js',
'processModelMaterialsCommon.js',
'techniqueParameterForSemantic.js'
'processPbrMetallicRoughness.js',
'removePipelineExtras.js',
'removeExtensionsRequired.js',
'removeExtensionsUsed.js',
'techniqueParameterForSemantic.js',
'updateVersion.js',
'webGLConstantToGlslType.js'
];
var subDependencyMapping = {
cesium : {
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
AccessorReader : require('./lib/AccessorReader'),
addCesiumRTC : require('./lib/addCesiumRTC'),
addDefaults : require('./lib/addDefaults'),
addExtensionsRequired : require('./lib/addExtensionsRequired'),
addExtensionsUsed : require('./lib/addExtensionsUsed'),
addPipelineExtras : require('./lib/addPipelineExtras'),
bakeAmbientOcclusion : require('./lib/bakeAmbientOcclusion'),
Expand Down Expand Up @@ -41,6 +42,7 @@ module.exports = {
removeUnusedVertices : require('./lib/removeUnusedVertices'),
triangleAxisAlignedBoundingBoxOverlap : require('./lib/triangleAxisAlignedBoundingBoxOverlap'),
uninterleaveAndPackBuffers : require('./lib/uninterleaveAndPackBuffers'),
updateVersion : require('./lib/updateVersion'),
writeAccessor : require('./lib/writeAccessor'),
writeBinaryGltf : require('./lib/writeBinaryGltf'),
writeBufferComponent : require('./lib/writeBufferComponent'),
Expand Down
10 changes: 6 additions & 4 deletions lib/AccessorReader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict';
var Cesium = require('cesium');
var defaultValue = Cesium.defaultValue;

var byteLengthForComponentType = require('./byteLengthForComponentType');
var getAccessorByteStride = require('./getAccessorByteStride');
var numberOfComponentsForType = require('./numberOfComponentsForType');
var readBufferComponent = require('./readBufferComponent');
var writeBufferComponent = require('./writeBufferComponent');

var defaultValue = Cesium.defaultValue;
var defined = Cesium.defined;

module.exports = AccessorReader;

/**
Expand All @@ -32,8 +33,9 @@ function AccessorReader(gltf, accessor) {
var buffer = buffers[bufferId];

this.accessor = accessor;
this.bufferView = bufferView;
this.byteOffset = accessor.byteOffset + bufferView.byteOffset;
this.byteStride = getAccessorByteStride(accessor);
this.byteStride = getAccessorByteStride(gltf, accessor);
this.componentType = accessor.componentType;
this.numberOfComponents = numberOfComponentsForType(accessor.type);
this.count = accessor.count;
Expand Down Expand Up @@ -85,7 +87,7 @@ AccessorReader.prototype.write = function(data, componentType, dataOffset) {
dataOffset = defaultValue(dataOffset, 0);
var componentByteLength = byteLengthForComponentType(componentType);
var byteStride = this.byteStride;
if (this.accessor.byteStride === 0 && componentType !== this.componentType) {
if ((!defined(this.bufferView.byteStride) || this.bufferView.byteStride === 0) && componentType !== this.componentType) {
byteStride = byteLengthForComponentType(componentType) * this.numberOfComponents;
}
for (var i = 0; i < this.numberOfComponents; i++) {
Expand Down
214 changes: 214 additions & 0 deletions lib/ForEach.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
'use strict';
var Cesium = require('cesium');

var defined = Cesium.defined;

module.exports = ForEach;

/**
* Contains traversal functions for processing elements of the glTF hierarchy.
* @constructor
*/
function ForEach() {}

ForEach.object = function(arrayOfObjects, handler) {
if (defined(arrayOfObjects)) {
for (var i = 0; i < arrayOfObjects.length; i++) {
var object = arrayOfObjects[i];
var returnValue = handler(object, i);
if (typeof returnValue === 'number') {
i += returnValue;
}
else if (returnValue) {
break;
}
}
}
};

ForEach.topLevel = function(gltf, name, handler) {
var arrayOfObjects = gltf[name];
ForEach.object(arrayOfObjects, handler);
};

ForEach.accessor = function(gltf, handler) {
ForEach.topLevel(gltf, 'accessors', handler);
};

ForEach.accessorWithSemantic = function(gltf, semantic, handler) {
ForEach.mesh(gltf, function(mesh) {
ForEach.meshPrimitive(mesh, function(primitive) {
ForEach.meshPrimitiveAttribute(primitive, function(accessorId, attributeSemantic) {
if (attributeSemantic.indexOf(semantic) === 0) {
handler(accessorId, attributeSemantic, primitive);
}
});
});
});
};

ForEach.animation = function(gltf, handler) {
ForEach.topLevel(gltf, 'animations', handler);
};

ForEach.animationSampler = function(animation, handler) {
var samplers = animation.samplers;
if (defined(samplers)) {
ForEach.object(samplers, handler);
}
};

ForEach.buffer = function(gltf, handler) {
ForEach.topLevel(gltf, 'buffers', handler);
};

ForEach.bufferView = function(gltf, handler) {
ForEach.topLevel(gltf, 'bufferViews', handler);
};

ForEach.camera = function(gltf, handler) {
ForEach.topLevel(gltf, 'cameras', handler);
};

ForEach.image = function(gltf, handler) {
ForEach.topLevel(gltf, 'images', handler);
};

ForEach.material = function(gltf, handler) {
ForEach.topLevel(gltf, 'materials', handler);
};

ForEach.materialValue = function(material, handler) {
var values = material.values;
if (defined(values)) {
for (var name in values) {
if (values.hasOwnProperty(name)) {
handler(values[name], name);
}
}
}
};

ForEach.mesh = function(gltf, handler) {
ForEach.topLevel(gltf, 'meshes', handler);
};

ForEach.meshPrimitive = function(mesh, handler) {
var primitives = mesh.primitives;
if (defined(primitives)) {
var primitivesLength = primitives.length;
for (var i = 0; i < primitivesLength; i++) {
var primitive = primitives[i];
handler(primitive, i);
}
}
};

ForEach.meshPrimitiveAttribute = function(primitive, handler) {
var attributes = primitive.attributes;
if (defined(attributes)) {
for (var semantic in attributes) {
if (attributes.hasOwnProperty(semantic)) {
handler(attributes[semantic], semantic);
}
}
}
};

ForEach.meshPrimitiveTargetAttribute = function(primitive, handler) {
var targets = primitive.targets;
if (defined(targets)) {
for (var targetId in targets) {
if (targets.hasOwnProperty(targetId)) {
var target = targets[targetId];
for (var attributeId in target) {
if (target.hasOwnProperty(attributeId) && attributeId !== 'extras') {
handler(target[attributeId], attributeId);
}
}
}
}
}
};

ForEach.node = function(gltf, handler) {
ForEach.topLevel(gltf, 'nodes', handler);
};

ForEach.nodeInTree = function(gltf, nodeIds, handler) {
var nodes = gltf.nodes;
if (defined(nodes)) {
for (var i = 0; i < nodeIds.length; i++) {
var nodeId = nodeIds[i];
var node = nodes[nodeId];
if (defined(node)) {
handler(node, nodeId);
var children = node.children;
if (defined(children)) {
ForEach.nodeInTree(gltf, children, handler);
}
}
}
}
};

ForEach.nodeInScene = function(gltf, scene, handler) {
var sceneNodeIds = scene.nodes;
if (defined(sceneNodeIds)) {
ForEach.nodeInTree(gltf, sceneNodeIds, handler);
}
};

ForEach.program = function(gltf, handler) {
ForEach.topLevel(gltf, 'programs', handler);
};

ForEach.sampler = function(gltf, handler) {
ForEach.topLevel(gltf, 'samplers', handler);
};

ForEach.scene = function(gltf, handler) {
ForEach.topLevel(gltf, 'scenes', handler);
};

ForEach.shader = function(gltf, handler) {
ForEach.topLevel(gltf, 'shaders', handler);
};

ForEach.skin = function(gltf, handler) {
ForEach.topLevel(gltf, 'skins', handler);
};

ForEach.techniqueAttribute = function(technique, handler) {
var attributes = technique.attributes;
if (defined(attributes)) {
for (var semantic in attributes) {
if (attributes.hasOwnProperty(semantic)) {
if (handler(attributes[semantic], semantic)) {
break;
}
}
}
}
};

ForEach.techniqueParameter = function(technique, handler) {
var parameters = technique.parameters;
if (defined(parameters)) {
for (var parameterName in parameters) {
if (parameters.hasOwnProperty(parameterName)) {
if (handler(parameters[parameterName], parameterName)) {
break;
}
}
}
}
};

ForEach.technique = function(gltf, handler) {
ForEach.topLevel(gltf, 'techniques', handler);
};

ForEach.texture = function(gltf, handler) {
ForEach.topLevel(gltf, 'textures', handler);
};
Loading