Skip to content

Commit

Permalink
Update version -> 2.0 (#271)
Browse files Browse the repository at this point in the history
* Added updateVersion stage as well as some refactoring

* Split out into multiple functions

* Cleaned up a few failing tests

* Added new upgrades to specs

* Application specific parameters are prefixed with underscores

* Migrated changes back from cesium

* Changed 1.1 to 2.0

* Lots of 1.0->2.0 changes in pipeline stages

* Tweaks from model generation

* Generate default material

* Add updateVersion to buildForCesium

* Select default scene

* A few more small changes

* Add removePipelineExtras to cesium build

* kmc fixes

* Build global cesium include

* Update

* Update CHANGES.md

* Added two more update functions

* Update CHANGES.md

* Strip version numbers when guessing if invalid

* WIP Array-based Traversal

* More WIP changes

* Removed combineMeshes -> nodes only have a singular mesh now

* Operator -> operate

* combineNodes, removeUnused and dagToTree traversal changes

* More WIP

* Bulk WIP changes for traversal

* Fixed a few more failing tests

* Removed findUsedIds

* WIP, switching workspaces

* WIP, pretty much just AO left

* Fixed a few more tests

* All tests pass

* Removed riggedSimpleUnoptimized

* Delete generateTangentsBitangents models

* Don't look for slots in array, just append

* Small fixes from testing

* More fixes

* A few test fixes and byteStride -> bufferView

* A few more test fixes

* Missed a function

* Removed vestigial byteStride references

* Some fixes from cesium changes

* Fixed cesium dependency list

* Fixed some plurality issues

* Add KHR_technique_webgl extensions if there are techniques
  • Loading branch information
Rob Taglang committed Apr 28, 2017
1 parent ce48e5f commit 1406b32
Show file tree
Hide file tree
Showing 123 changed files with 7,883 additions and 8,831 deletions.
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
26 changes: 18 additions & 8 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,23 @@ 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',
'numberOfComponentsForType.js',
'parseBinaryGltf.js',
'processModelMaterialsCommon.js',
'techniqueParameterForSemantic.js'
'removePipelineExtras.js',
'removeExtensionsRequired.js',
'removeExtensionsUsed.js',
'techniqueParameterForSemantic.js',
'updateVersion.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
195 changes: 195 additions & 0 deletions lib/ForEach.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
'use strict';
var Cesium = require('cesium');

var defaultValue = Cesium.defaultValue;
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 offset = defaultValue(handler(object, i), 0);
i += offset;
}
}
};

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.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

0 comments on commit 1406b32

Please sign in to comment.