-
Notifications
You must be signed in to change notification settings - Fork 250
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
Update version #191
Conversation
@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. |
@lexaknyazev if you are able to look at this, the two files to review are:
|
specs/lib/updateVersionSpec.js
Outdated
expect(gltf.asset.profile.version).toEqual('1.0'); | ||
var animation = gltf.animations.animation; | ||
var sampler = animation.samplers.sampler; | ||
expect(sampler.input).toBe('accessor_input'); |
There was a problem hiding this comment.
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
.
specs/lib/updateVersionSpec.js
Outdated
expect(technique.states).toEqual(['TEST_STATE']); | ||
}); | ||
|
||
it('updates glTF from 1.0 to 1.1', function() { |
There was a problem hiding this comment.
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
andextensionsRequired
-
buffer.type
removal -
technique.functions.scissor
andtechnique.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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
lib/updateVersion.js
Outdated
return gltf; | ||
} | ||
|
||
function glTF_0_8_to_glTF_1_0(gltf) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
lib/updateVersion.js
Outdated
} | ||
} | ||
|
||
function glTF_1_0_to_glTF_1_1(gltf) { |
There was a problem hiding this comment.
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.
Good start, thanks @lasalvavida! |
This is updated from the discussion above. |
Great, will aim to review tomorrow morning. |
Do we handle this one from KhronosGroup/glTF#605:
I think we should strip the |
Do we handle this from KhronosGroup/glTF#605
Would be possible to know to put a parameter in This is also likely to a rare case so no need to spend too much time here. |
Is this taken into account?
|
Is this taken into account?
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. |
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' |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
lib/updateVersion.js
Outdated
if (defined(profile)) { | ||
var version = profile.version; | ||
if (defined(version)) { | ||
profile.version = version[0] + '.' + version[2]; |
There was a problem hiding this comment.
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]
?
And to be safe perhaps the check should be
if (defined(version) && (version.length > 2)) {
There was a problem hiding this comment.
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]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes!
lib/updateVersion.js
Outdated
attributes.TEXCOORD_0 = attributes[semantic]; | ||
delete attributes[semantic]; | ||
} | ||
if (semantic === 'COLOR') { |
There was a problem hiding this comment.
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.
lib/updateVersion.js
Outdated
COLOR: true, | ||
JOINT: true, | ||
WEIGHT: true, | ||
BATCHID: true |
There was a problem hiding this comment.
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).
@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? |
…ne into updateVersion
I am closing this here and will re-open as the 2.0 pull request |
@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(This is now in #223) This stage also includes tools for converting from glTF 1.0 -> 2.0.updateVersion
.butlib/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