-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Detect glTF 2.0 and change forward to match Cesium's convention. #6632
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
676aaf1
Detect glTF 2.0 and change forward to match Cesium's convention.
emackey 2569796
Fix name of option.
emackey 30d95f1
Fix tests
emackey 3e4e579
Merge remote-tracking branch 'origin/master' into gltf-2.0-orientation
emackey 897c01c
Add new tests for forwardAxis.
emackey 8a58c11
CHANGES.md
emackey 9809e31
Add option to suppress autodetect of forward axis.
emackey 97a9d03
Merge branch 'master' into gltf-2.0-orientation
lilleyse 56f94d9
Moved breaking change to 1.47 section
lilleyse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,24 @@ | |
"children": [ | ||
3, | ||
1 | ||
], | ||
"matrix": [ | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
-1, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
1 | ||
] | ||
}, | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -579,6 +579,7 @@ define([ | |
this._ignoreCommands = defaultValue(options.ignoreCommands, false); | ||
this._requestType = options.requestType; | ||
this._upAxis = defaultValue(options.upAxis, Axis.Y); | ||
this._forwardAxis = defaultValue(options.upAxis, Axis.Z); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
|
||
/** | ||
* @private | ||
|
@@ -973,6 +974,25 @@ define([ | |
} | ||
}, | ||
|
||
/** | ||
* Gets the model's forward axis. | ||
* By default, glTF 2.0 models are z-forward according to the glTF spec, however older | ||
* glTF (1.0, 0.8) models used x-forward. Note that only Axis.X and Axis.Z are supported. | ||
* | ||
* @memberof Model.prototype | ||
* | ||
* @type {Number} | ||
* @default Axis.Z | ||
* @readonly | ||
* | ||
* @private | ||
*/ | ||
forwardAxis : { | ||
get : function() { | ||
return this._forwardAxis; | ||
} | ||
}, | ||
|
||
/** | ||
* Gets the model's triangle count. | ||
* | ||
|
@@ -1361,6 +1381,10 @@ define([ | |
} else if (model._upAxis === Axis.X) { | ||
BoundingSphere.transformWithoutScale(boundingSphere, Axis.X_UP_TO_Z_UP, boundingSphere); | ||
} | ||
if (model._forwardAxis === Axis.Z) { | ||
// glTF 2.0 has a Z-forward convention that must be adapted here to X-forward. | ||
BoundingSphere.transformWithoutScale(boundingSphere, Axis.Z_UP_TO_X_UP, boundingSphere); | ||
} | ||
return boundingSphere; | ||
} | ||
|
||
|
@@ -4303,6 +4327,10 @@ define([ | |
}; | ||
frameState.brdfLutGenerator.update(frameState); | ||
updateVersion(this.gltf); | ||
if (defined(this.gltf.asset) && defined(this.gltf.asset.extras) && | ||
this.gltf.asset.extras.gltf_pipeline_upgrade_10to20) { | ||
this._forwardAxis = Axis.X; | ||
} | ||
ModelUtility.checkSupportedExtensions(this.extensionsRequired); | ||
addPipelineExtras(this.gltf); | ||
addDefaults(this.gltf); | ||
|
@@ -4437,6 +4465,10 @@ define([ | |
} else if (this._upAxis === Axis.X) { | ||
Matrix4.multiplyTransformation(computedModelMatrix, Axis.X_UP_TO_Z_UP, computedModelMatrix); | ||
} | ||
if (this._forwardAxis === Axis.Z) { | ||
// glTF 2.0 has a Z-forward convention that must be adapted here to X-forward. | ||
Matrix4.multiplyTransformation(computedModelMatrix, Axis.Z_UP_TO_X_UP, computedModelMatrix); | ||
} | ||
} | ||
|
||
// Update modelMatrix throughout the graph as needed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,13 @@ | |
1 | ||
], | ||
"matrix": [ | ||
1, | ||
0, | ||
0, | ||
1, | ||
0, | ||
1, | ||
0, | ||
0, | ||
-1, | ||
0, | ||
0, | ||
1, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,24 @@ | |
"children": [ | ||
3, | ||
1 | ||
], | ||
"matrix": [ | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
1, | ||
0, | ||
0, | ||
-1, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
1 | ||
] | ||
}, | ||
{ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Point of trivia, this change actually puts the heading back to what is was prior to #6592, which is not a coincidence. The model was updated to the correct glTF 2.0 orientation in that PR, but Cesium wasn't yet handling the 2.0 orientations correctly, so this was a workaround that is now being removed.