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 #191

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
a5f1ad8
Added updateVersion stage as well as some refactoring
lasalvavida Dec 5, 2016
74c6635
Merge branch 'master' of https://github.com/AnalyticalGraphicsInc/glt…
lasalvavida Dec 5, 2016
b4ff281
Split out into multiple functions
lasalvavida Dec 14, 2016
96160e5
Merge branch 'master' of https://github.com/AnalyticalGraphicsInc/glt…
lasalvavida Dec 14, 2016
318d2b8
Cleaned up a few failing tests
lasalvavida Dec 14, 2016
77cd995
Added new upgrades to specs
lasalvavida Dec 14, 2016
6478c98
Application specific parameters are prefixed with underscores
lasalvavida Dec 14, 2016
1ef43e3
Merge branch 'master' of github.com:AnalyticalGraphicsInc/gltf-pipeli…
Jan 17, 2017
cf697a9
Merge branch 'updateVersion' of github.com:AnalyticalGraphicsInc/gltf…
Jan 17, 2017
a6db842
Migrated changes back from cesium
Jan 17, 2017
439f0fa
Merge branch 'master' of github.com:AnalyticalGraphicsInc/gltf-pipeli…
Jan 25, 2017
611d148
Merge branch 'cleanup-add-defaults' of github.com:AnalyticalGraphicsI…
Jan 25, 2017
e882790
Changed 1.1 to 2.0
Jan 25, 2017
d2cb44c
Merge branch 'master' of github.com:AnalyticalGraphicsInc/gltf-pipeli…
Jan 25, 2017
e88fd50
Lots of 1.0->2.0 changes in pipeline stages
Jan 25, 2017
f2557af
Tweaks from model generation
Jan 26, 2017
3d35c21
Generate default material
Jan 26, 2017
7f8ad7c
Add updateVersion to buildForCesium
Jan 26, 2017
ed61ae7
Select default scene
Jan 26, 2017
7ee3137
A few more small changes
Jan 26, 2017
7b63d22
Add removePipelineExtras to cesium build
Jan 26, 2017
a76c503
kmc fixes
Jan 26, 2017
d8337e1
Build global cesium include
Jan 26, 2017
9bb2d3c
Update
Jan 26, 2017
01b3140
Update CHANGES.md
Jan 26, 2017
3bc06ba
Added two more update functions
Jan 26, 2017
6d58407
Update CHANGES.md
pjcozzi Jan 26, 2017
0d6e895
Strip version numbers when guessing if invalid
Jan 27, 2017
99c98e2
Merge branch 'updateVersion' of github.com:AnalyticalGraphicsInc/gltf…
Jan 27, 2017
843a480
WIP Array-based Traversal
Feb 14, 2017
9f4b12b
More WIP changes
Feb 14, 2017
dee1009
Removed combineMeshes -> nodes only have a singular mesh now
Feb 14, 2017
c9f79c4
Merge branch 'master' of github.com:AnalyticalGraphicsInc/gltf-pipeli…
Feb 15, 2017
2ac3bfd
Operator -> operate
Feb 15, 2017
2ec8545
combineNodes, removeUnused and dagToTree traversal changes
Feb 15, 2017
29e21f2
More WIP
Feb 15, 2017
9ad94f3
Bulk WIP changes for traversal
lasalvavida Feb 17, 2017
f952bc0
Merge branch 'master' of https://github.com/AnalyticalGraphicsInc/glt…
lasalvavida Mar 3, 2017
4c884d5
Fixed a few more failing tests
lasalvavida Mar 3, 2017
13aa73d
Removed findUsedIds
lasalvavida Mar 10, 2017
b5d8002
WIP, switching workspaces
lasalvavida Mar 20, 2017
6427738
WIP, pretty much just AO left
Mar 21, 2017
af0a51a
Fixed a few more tests
Mar 21, 2017
a4a0331
All tests pass
Mar 21, 2017
94ee8e5
Removed riggedSimpleUnoptimized
Mar 21, 2017
d75085e
Delete generateTangentsBitangents models
Mar 21, 2017
37b97c0
Merge branch 'master' of github.com:AnalyticalGraphicsInc/gltf-pipeli…
Mar 21, 2017
9fc99cc
Don't look for slots in array, just append
Mar 21, 2017
d172439
Small fixes from testing
Mar 21, 2017
d4ccb41
More fixes
Mar 21, 2017
edee467
A few test fixes and byteStride -> bufferView
Mar 21, 2017
2e7519e
A few more test fixes
Mar 21, 2017
684c272
Missed a function
Mar 21, 2017
d426433
Removed vestigial byteStride references
Mar 21, 2017
a35e5f7
Some fixes from cesium changes
Mar 22, 2017
7492f57
Fixed cesium dependency list
Mar 22, 2017
ab6daee
Fixed some plurality issues
Apr 2, 2017
34d1c67
Add KHR_technique_webgl extensions if there are techniques
Apr 2, 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 @@ -2,8 +2,10 @@ Change Log
==========

### Next Release

* `modelMaterialsCommon` renamed to `processModelMaterialsCommon`.
* Added `generateModelMaterialsCommon` and command line `kmc` flags for generating models with the `KHR_materials_common` extension.
* Added `updateVersion` stage for transitioning assets between glTF version and migrated any glTF 0.8 code out of `addDefaults`

### 0.1.0-alpha6 - 2016-11-18

Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
RemoveUnusedProperties : require('./lib/RemoveUnusedProperties'),
removeUnusedVertices : require('./lib/removeUnusedVertices'),
uninterleaveAndPackBuffers : require('./lib/uninterleaveAndPackBuffers'),
updateVersion : require('./lib/updateVersion'),
writeAccessor : require('./lib/writeAccessor'),
writeBinaryGltf : require('./lib/writeBinaryGltf'),
writeBufferComponent : require('./lib/writeBufferComponent'),
Expand Down
4 changes: 4 additions & 0 deletions lib/Pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var removeDuplicatePrimitives = require('./removeDuplicatePrimitives');
var removeNormals = require('./removeNormals');
var removePipelineExtras = require('./removePipelineExtras');
var quantizeAttributes = require('./quantizeAttributes');
var updateVersion = require('./updateVersion');
var writeGltf = require('./writeGltf');
var writeBinaryGltf = require('./writeBinaryGltf');
var writeSource = require('./writeSource');
Expand Down Expand Up @@ -84,6 +85,9 @@ Pipeline.processJSONWithExtras = function(gltfWithExtras, options) {
if (options.removeNormals) {
removeNormals(gltfWithExtras);
}
updateVersion(gltfWithExtras, {
targetVersion: '1.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 1.1?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is this dependent on updating the rest of the pipeline stages to use 1.1? This could be a separate branch, but probably needs to go into master at the same time so we are able to optimize sample models and gltf-pipeline can process models that it outputs.

Copy link
Contributor Author

@lasalvavida lasalvavida Dec 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, this is set to 1.0 intentionally since I don't think we want to be generating 1.1 from master by default just yet. Though now that I think about it, a command line flag for 1.1 may be a better solution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. The other option is to keep the 1.1 changes on this branch, but I agree it would be better to get this into master.

});
addDefaults(gltfWithExtras, options);
RemoveUnusedProperties.removeAll(gltfWithExtras);
generateNormals(gltfWithExtras, options);
Expand Down
83 changes: 3 additions & 80 deletions lib/addDefaults.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
'use strict';
var Cesium = require('cesium');

var Cartesian3 = Cesium.Cartesian3;
var defaultValue = Cesium.defaultValue;
var defined = Cesium.defined;
var Quaternion = Cesium.Quaternion;
var WebGLConstants = Cesium.WebGLConstants;

var addExtensionsUsed = require('./addExtensionsUsed');
var findAccessorMinMax = require('./findAccessorMinMax');
var processModelMaterialsCommon = require('./processModelMaterialsCommon');

module.exports = addDefaults;
Expand All @@ -23,11 +20,6 @@ function accessorDefaults(gltf) {
if (accessors.hasOwnProperty(name)) {
var accessor = accessors[name];
accessor.byteStride = defaultValue(accessor.byteStride, 0);
if (!defined(accessor.min) || !defined(accessor.max)) {
var minMax = findAccessorMinMax(gltf, accessor);
accessor.min = defaultValue(accessor.min, minMax.min);
accessor.max = defaultValue(accessor.max, minMax.max);
}
}
}
}
Expand Down Expand Up @@ -71,25 +63,13 @@ function assetDefaults(gltf) {
gltf.asset = {};
}
var asset = gltf.asset;

// Backwards compatibility for glTF 0.8. profile was a string.
if (!defined(asset.profile) || (typeof asset.profile === 'string')) {
if (!defined(asset.profile)) {
asset.profile = {};
}
var profile = asset.profile;

asset.premultipliedAlpha = defaultValue(asset.premultipliedAlpha, false);
profile.api = defaultValue(profile.api, 'WebGL');
profile.version = defaultValue(profile.version, '1.0.2');

// glTF 0.8 backward compatibility
if (defined(gltf.version)) {
asset.version = defaultValue(asset.version, gltf.version);
delete gltf.version;
}
if (typeof asset.version === 'number') {
asset.version = asset.version.toFixed(1).toString();
}
profile.version = defaultValue(profile.version, '1.0');
}

function bufferDefaults(gltf) {
Expand Down Expand Up @@ -201,15 +181,6 @@ function materialDefaults(gltf, options) {
for (var name in materials) {
if (materials.hasOwnProperty(name)) {
var material = materials[name];
var instanceTechnique = material.instanceTechnique;
if (defined(instanceTechnique)) {
// glTF 0.8 backward compatibility
material.technique = instanceTechnique.technique;
material.values = instanceTechnique.values;

delete material.instanceTechnique;
}

if (!defined(material.technique)) {
if (!defined(material.extensions) || Object.keys(material.extensions).length === 0) {
guessExtensionTechnique(gltf, material, options);
Expand Down Expand Up @@ -269,7 +240,6 @@ function meshDefaults(gltf) {
for (var name in meshes) {
if (meshes.hasOwnProperty(name)) {
var mesh = meshes[name];

if (!defined(mesh.primitives)) {
mesh.primitives = [];
}
Expand All @@ -278,14 +248,11 @@ function meshDefaults(gltf) {
var length = primitives.length;
for (var i = 0; i < length; ++i) {
var primitive = primitives[i];

if (!defined(primitive.attributes)) {
primitive.attributes = {};
}
primitive.mode = defaultValue(primitive.mode, WebGLConstants.TRIANGLES);

// Backwards compatibility for glTF 0.8. primitive was renamed to mode.
var defaultMode = defaultValue(primitive.primitive, WebGLConstants.TRIANGLES);
primitive.mode = defaultValue(primitive.mode, defaultMode);
}
}
}
Expand All @@ -296,10 +263,6 @@ function nodeDefaults(gltf) {
gltf.nodes = {};
}
var nodes = gltf.nodes;
var hasAxisAngle = (parseFloat(gltf.asset.version) < 1.0);

var axis = new Cartesian3();
var quat = new Quaternion();
for (var name in nodes) {
if (nodes.hasOwnProperty(name)) {
var node = nodes[name];
Expand All @@ -308,14 +271,6 @@ function nodeDefaults(gltf) {
node.children = [];
}

if (hasAxisAngle && defined(node.rotation)) {
// glTF 0.8 backward compatibility
var rotation = node.rotation;
Cartesian3.fromArray(rotation, 0, axis);
Quaternion.fromAxisAngle(axis, rotation[3], quat);
node.rotation = [quat.x, quat.y, quat.z, quat.w];
}

if (!defined(node.matrix)) {
// Add default identity matrix if there is no matrix property and no TRS properties
if (!defined(node.translation) && !defined(node.rotation) && !defined(node.scale)) {
Expand All @@ -339,14 +294,6 @@ function nodeDefaults(gltf) {
}
}
}

var instanceSkin = node.instanceSkin;
if (defined(instanceSkin)) {
node.skeletons = instanceSkin.skeletons;
node.skin = instanceSkin.skin;
node.meshes = instanceSkin.meshes;
delete node.instanceSkin;
}
}
}
}
Expand Down Expand Up @@ -459,25 +406,6 @@ function techniqueDefaults(gltf, options) {
parameters.diffuse.semantic = '_3DTILESDIFFUSE';
}

var passes = technique.passes;
if (defined(passes)) {
// glTF 0.8 backward compatibility
var passName = defaultValue(technique.pass, 'defaultPass');
if (passes.hasOwnProperty(passName)) {
var pass = passes[passName];
var instanceProgram = pass.instanceProgram;

technique.attributes = defaultValue(technique.attributes, instanceProgram.attributes);
technique.program = defaultValue(technique.program, instanceProgram.program);
technique.uniforms = defaultValue(technique.uniforms, instanceProgram.uniforms);

technique.states = defaultValue(technique.states, pass.states);
}

technique.passes = undefined;
technique.pass = undefined;
}

if (!defined(technique.attributes)) {
technique.attributes = {};
}
Expand Down Expand Up @@ -527,11 +455,6 @@ function textureDefaults(gltf) {
*/
function addDefaults(gltf, options) {
options = defaultValue(options, {});

if (defined(gltf.allExtensions)) {
gltf.extensionsUsed = gltf.allExtensions;
gltf.allExtensions = undefined;
}
gltf.extensionsUsed = defaultValue(gltf.extensionsUsed, []);

accessorDefaults(gltf);
Expand Down
55 changes: 12 additions & 43 deletions lib/getUniqueId.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,18 @@ module.exports = getUniqueId;
* @returns {String} A unique id beginning with prefix.
*/
function getUniqueId(gltf, prefix) {
var prefixMatches = {};

// Check top level objects with ids for instances of the prefix
checkForPrefix(gltf.nodes, prefixMatches, prefix);
checkForPrefix(gltf.skins, prefixMatches, prefix);
checkForPrefix(gltf.cameras, prefixMatches, prefix);
checkForPrefix(gltf.meshes, prefixMatches, prefix);
checkForPrefix(gltf.accessors, prefixMatches, prefix);
checkForPrefix(gltf.materials, prefixMatches, prefix);
checkForPrefix(gltf.bufferViews, prefixMatches, prefix);
checkForPrefix(gltf.techniques, prefixMatches, prefix);
checkForPrefix(gltf.textures, prefixMatches, prefix);
checkForPrefix(gltf.buffers, prefixMatches, prefix);
checkForPrefix(gltf.programs, prefixMatches, prefix);
checkForPrefix(gltf.images, prefixMatches, prefix);
checkForPrefix(gltf.samplers, prefixMatches, prefix);
checkForPrefix(gltf.shaders, prefixMatches, prefix);

// Generate a new ID based on the prefix and any occurrences of the prefix throughout the json
// Case where the prefix is already unique
if (!prefixMatches[prefix]) {
return prefix;
}

// Impossible for prefixMatches to contain all strings of form 'prefix_X', 0 <= X < count, and 'prefix'
var prefixMatchCount = Object.keys(prefixMatches).length;
for (var i = 0; i < prefixMatchCount; i++) {
var newID = prefix + '_' + i;
if (!prefixMatches[newID]) {
return newID;
}
}
}

function checkForPrefix(topLevelObject, prefixMatches, prefix) {
if (defined(topLevelObject)) {
var objectIds = Object.keys(topLevelObject);
var objectIdCount = objectIds.length;
for (var j = 0; j < objectIdCount; j++) {
var idString = objectIds[j];
if (idString.startsWith(prefix)) {
prefixMatches[idString] = true;
var id = prefix;
var appendIndex = 0;
for (var topLevelGroupId in gltf) {
if (gltf.hasOwnProperty(topLevelGroupId)) {
var topLevelGroup = gltf[topLevelGroupId];
var match = topLevelGroup[id];
while (defined(match)) {
id = prefix + '_' + appendIndex;
match = topLevelGroup[id];
appendIndex++;
}
}
}
}
return id;
}
10 changes: 6 additions & 4 deletions lib/loadGltfUris.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ module.exports = loadGltfUris;
* glTF must be initialized for the pipeline.
*
* @param {Object} gltf A javascript object containing a glTF asset.
* @param {Object} options Options for loading uris.
* @param {String} options.basePath The path to look in when loading external files.
* @param {Object} [options] Options for loading uris.
* @param {String} [options.basePath] The path to look in when loading external files.
* @returns {Promise} A promise that resolves to the glTF asset when all uris are loaded.
*
* @see addPipelineExtras
*/
function loadGltfUris(gltf, options) {
options = defaultValue(options, {});
var basePath = options.basePath;
var basePath = defaultValue(options.basePath, '');
var loadURIs = [
loadURI(gltf, basePath, 'buffers'),
loadURI(gltf, basePath, 'images'),
Expand All @@ -53,7 +53,9 @@ function loadURI(gltf, basePath, name) {
var object = objects[id];
var uri = object.uri;
object.extras = defaultValue(object.extras, {});
object.extras._pipeline = defaultValue(object.extras._pipeline, {});
object.extras._pipeline = defaultValue(object.extras._pipeline, {
deleteExtras: true
});
//Load the uri into the extras object based on the uri type
if (isDataUri(uri)) {
if (!defined(object.extras._pipeline.source)) {
Expand Down
Loading