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

Update version #191

wants to merge 58 commits into from

Conversation

lasalvavida
Copy link
Contributor

@lasalvavida lasalvavida commented Dec 5, 2016

@lilleyse and @pjcozzi could you look at this when you get a chance? This refactors any glTF 0.8 ->1.0 from gltfDefaults out into a global stage called updateVersion. (This is now in #223) This stage also includes tools for converting from glTF 1.0 -> 2.0.
but lib/Pipeline.js still targets 1.0 by default. This will be changed once glTF 1.1 is fully released.

See KhronosGroup/glTF#605 for the full list of changes from glTF 1.0 -> 1.1

@lexaknyazev, if you have time I'd appreciate your input here as well.


TODO

  • Test new stage with all glTF sample models

@lasalvavida lasalvavida mentioned this pull request Dec 5, 2016
2 tasks
@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 6, 2016

@lasalvavida have you tested this with all the sample models?

@lasalvavida
Copy link
Contributor Author

@lasalvavida have you tested this with all the sample models?

Not yet.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 6, 2016

@lasalvavida have you tested this with all the sample models?
Not yet.

Added to the tasklist at the top of this PR. Please add any other items there needed before we should merge this. Updating the entire pipeline to 1.1 can be a separate PR if you prefer.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 6, 2016

@lexaknyazev if you are able to look at this, the two files to review are:

expect(gltf.asset.profile.version).toEqual('1.0');
var animation = gltf.animations.animation;
var sampler = animation.samplers.sampler;
expect(sampler.input).toBe('accessor_input');
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and below, should this just be toEqual.

expect(technique.states).toEqual(['TEST_STATE']);
});

it('updates glTF from 1.0 to 1.1', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this also test:

  • glExtensionsUsed and extensionsRequired
  • buffer.type removal
  • technique.functions.scissor and technique.states.enable = 3089 removal
  • Adds all properties that were formerly not required, e.g., asset, buffer.byteLength, bufferView.byteLength, etc.
  • technique.states.functions.blendColor / technique.states.functions.depthRange parameter changes.

In general, can you look at each bullet in KhronosGroup/glTF#605 and confirm that it is handled? There are others that I did not mention above.

There are some cases where an exact update won't be possible, and we may have to make a breaking change (to the model itself) and provide a log to the user. For example, we may have to prepend an underscore to an application-specific parameter semantic or change camera.perspective.yfov = 0.0 to camera.perspective.yfov = 1.0. In practice, most of these edge cases will not come up.

It is likely cleaner to break this into multiple tests for some of these edge cases.

Copy link
Contributor Author

@lasalvavida lasalvavida Dec 6, 2016

Choose a reason for hiding this comment

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

glExtensionsUsed and extensionsRequired

Those properties have no analogue in older versions of glTF; they are just new properties. I can't take a glTF1.0 extensionsUsed and make it extensionsRequired because we don't know which ones were just used vs. required. As such, I don't think there is any safe updating that can be done here.

buffer.type removal

Thank you, I did miss that one

technique.functions.scissor and technique.states.enable = 3089 removal

Agreed, I will add this.

Adds all properties that were formerly not required, e.g., asset, buffer.byteLength, bufferView.byteLength, etc.

I'll do byteLength, but adding the asset if it doesn't exist is handled by addDefaults.

technique.states.functions.blendColor / technique.states.functions.depthRange parameter changes.

I think this is in the same realm as camera.perspective properties. If someone has a property that is set to an invalid value, I don't think that it is safe to just change the value to a valid one. Even though it was never explicitly forbidden in 1.0, those restrictions were still imposed by WebGL. I can maybe log a warning or something, but I don't think we can change the value.

Copy link
Contributor Author

@lasalvavida lasalvavida Dec 6, 2016

Choose a reason for hiding this comment

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

Actually adding asset if it is not defined is a bit more complex. That being said, I think the existing behavior is the correct approach. If a glTF 0.8 without asset defined is updated, but it has gltf.version, the asset property will be added. However, for any other this will throw an exception, because if asset isn't defined, then asset.version isn't defined, and there is no safe way to determine the version of the glTF, and what changes need to be made.

If it's undefined, we could assume 1.0. I'm just concerned that this could cause some strange behavior down the line somewhere.

Copy link
Contributor

@pjcozzi pjcozzi Dec 6, 2016

Choose a reason for hiding this comment

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

I can't take a glTF1.0 extensionsUsed and make it extensionsRequired because we don't know which ones were just used vs. required

I think we do know which were required; it is the extensions that are now required, which I suppose is all of the current extensions.

Copy link
Contributor

Choose a reason for hiding this comment

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

technique.states.functions.blendColor / technique.states.functions.depthRange parameter changes.

I think this is in the same realm as camera.perspective properties.

It's a tough call, but the 1.0 -> 1.1 stage should output a valid 1.1 model so I would be fine with clamping the value and providing a warning log. There's an OK chance that is what the user wants; otherwise, the user would have to edit the model afterward 100% of the time.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's undefined, we could assume 1.0. I'm just concerned that this could cause some strange behavior down the line somewhere.

Probably OK. In practice, I suspect virtually 0% of users use 0.8, and post 1.0, asset is required.

return gltf;
}

function glTF_0_8_to_glTF_1_0(gltf) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Even for private functions, we don't put underscore in names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have a suggested alternative? I was having a hard time making it still readable without underscores.

Copy link
Contributor

Choose a reason for hiding this comment

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

ha. I had a few then I deleted them. I dunno:

  • glTF08To10
  • glTF08ToglTF10

}
}

function glTF_1_0_to_glTF_1_1(gltf) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider breaking this function up into several smaller ones. Basically each comment could call a separate function.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 6, 2016

Good start, thanks @lasalvavida!

@lasalvavida
Copy link
Contributor Author

This is updated from the discussion above.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 15, 2016

Great, will aim to review tomorrow morning.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 16, 2016

Do we handle this one from KhronosGroup/glTF#605:

Attribute parameters can't have a value defined in the technique or parameter, #563 (comment).

I think we should strip the value and warn in this case.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 16, 2016

Do we handle this from KhronosGroup/glTF#605

Properties in technique.parameters must be defined in technique.uniforms or technique.attributes,
#563 (comment).

Would be possible to know to put a parameter in uniforms or attributes? I suspect this would be painful, and perhaps we could just warn that the parameter is missing from uniforms or attributes. I don't want to overlap too much with the glTF Validator, but case could be OK.

This is also likely to a rare case so no need to spend too much time here.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 16, 2016

Is this taken into account?

technique.parameter.count can only be defined when the semantic is JOINTMATRIX or an application-specific semantic is used. It can never be defined for attribute parameters; only uniforms, d2f6945

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 16, 2016

Is this taken into account?

technique.parameter.semantic is required when the parameter is an attribute, 28e113d

In practice, it is likely to be rare so no need to over invest here.

We could either (1) warning or (2) make a best attempt to map attribute names to semantics and still warn.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 16, 2016

I reviewed KhronosGroup/glTF#605 and that is all my comments about how this maps to the 1.1 spec. Please keep an eye on 1.1 issues in the glTF repo for any last-minute updates.

I'll also take a quick look at this code now.

lib/Pipeline.js Outdated
@@ -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.

if (defined(profile)) {
var version = profile.version;
if (defined(version)) {
profile.version = version[0] + '.' + version[2];
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't version[2] be version[1]?

KhronosGroup/glTF#701

And to be safe perhaps the check should be

if (defined(version) && (version.length > 2)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is correct as is, but a length check is a good idea.

0 1 2 3 4
1 . 0 . 3

and we want 1.0, so version[0] + '.' + version[2].

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes!

attributes.TEXCOORD_0 = attributes[semantic];
delete attributes[semantic];
}
if (semantic === 'COLOR') {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor, but } else if (semantic === 'COLOR') { would be slightly better style.

COLOR: true,
JOINT: true,
WEIGHT: true,
BATCHID: true
Copy link
Contributor

Choose a reason for hiding this comment

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

BATCHID is part of 3D Tiles, not glTF, so the 3D Tiles spec will need to name this _BATCHID (please update the spec if it isn't already), and then we can have backwards compatibility loading in Cesium with a warning (also please open PR if this isn't done).

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 16, 2016

@lasalvavida just those comments. What is your plan from here?

Perhaps get this fully into shape, but then do not merge until we have the samples converted and Cesium loader so that we know the full stack works together?

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.5%) to 92.321% when pulling 9fc99cc on updateVersion into bf401ef on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.8%) to 92.049% when pulling 684c272 on updateVersion into bf401ef on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.8%) to 92.03% when pulling d426433 on updateVersion into bf401ef on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.8%) to 92.03% when pulling d426433 on updateVersion into bf401ef on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.9%) to 91.944% when pulling 34d1c67 on updateVersion into bf401ef on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.9%) to 91.952% when pulling 34d1c67 on updateVersion into bf401ef on master.

@lasalvavida
Copy link
Contributor Author

I am closing this here and will re-open as the 2.0 pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants