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

Detect glTF 2.0 and change forward to match Cesium's convention. #6632

Merged
merged 9 commits into from
Jun 11, 2018

Conversation

emackey
Copy link
Contributor

@emackey emackey commented May 25, 2018

I'm opening this a bit early to get Travis running on the tests, they seem to have problems. Also, feedback welcome, particularly on the approach here.

I've added a new forwardAxis setting, similar to the existing private upAxis setting, on Model.js. A change to the underlying gltf-pipeline marks models as having been upgraded from 1.0 (which includes models upgraded from 0.8 as they pass through 1.0 as an intermediate step). Models which are not marked as upgraded are presumed to be native glTF 2.0 or higher, and thus must use the new +Z forward convention. This is accomplished by adding an additional rotation, after the upAxis rotation for such models, to set the forward vector to align with what Cesium uses internally.

TODO:

@cesium-concierge
Copy link

Signed CLA is on file.

@emackey, thanks for the pull request! Maintainers, we have a signed CLA from @emackey, so you can review this at any time.

⚠️ I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to CHANGES.md and comment on this pull request so we know it was updated. For more info, see the Pull Request Guidelines.

⚠️ I noticed that a file in one of our ThirdParty folders (ThirdParty/, Source/ThirdParty/) has been added or modified. Please verify that it has a section in LICENSE.md and that its license information is up to date with this new version. Once you do, please confirm by commenting on this pull request.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

@emackey
Copy link
Contributor Author

emackey commented May 25, 2018

Fixes #6591.

@@ -53,7 +53,7 @@
viewer.scene.globe.depthTestAgainstTerrain = true;

var position = new Cesium.Cartesian3(-1371108.6511167218, -5508684.080096612, 2901825.449865087);
var heading = Cesium.Math.toRadians(90);
var heading = Cesium.Math.toRadians(180);
Copy link
Contributor Author

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.

@lilleyse
Copy link
Contributor

For glTF 2.0 in general this is probably the right thing to do.

I'm a little worried about how this affects 3D Tiles, where unlike a standalone model there isn't really a concept of a forward axis. Maybe b3dm/i3dm should always pass in Axis.X just so the content isn't rotated.

@@ -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);
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:

this._forwardAxis = defaultValue(options.forwardAxis, Axis.Z);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@emackey
Copy link
Contributor Author

emackey commented May 29, 2018

All TODOs done, this is ready. EDIT: Not yet!

Maybe b3dm/i3dm should always pass in Axis.X just so the content isn't rotated.

I think that's the right strategy. The rotation here is for the sake of Cesium's motions, like the VelocityOrientationProperty and the camera's VVLH view of a travelling object. Those are where Cesium's notion of "+X forwards" are expressed. The 3D Tiles system doesn't have that same notion and does't need this new rotation.

@emackey
Copy link
Contributor Author

emackey commented May 29, 2018

We definitely need to address 3D Tiles before this gets merged. It looks completely broken.

@emackey
Copy link
Contributor Author

emackey commented May 29, 2018

OK, I added the new constructor option to Batched3DModel3DTileContent.js, and the New York demo seems to be working again.

I believe this to be ready, but folks invested in 3D Tiles should probably do some testing of their own before merging this.

@lilleyse
Copy link
Contributor

lilleyse commented Jun 1, 2018

@emackey I'll aim to look at this closer after the release today.

@lilleyse
Copy link
Contributor

Thanks @emackey, the Sandcastle demos look good. I substituted the ground vehicle for the milk truck in Multi-part CZML, which had the wrong orientation in master but is fixed here.

I moved the breaking change to the 1.47 section to CHANGES.md.

@lilleyse lilleyse merged commit f13dc97 into master Jun 11, 2018
@lilleyse lilleyse deleted the gltf-2.0-orientation branch June 11, 2018 14:15
@lilleyse
Copy link
Contributor

@emackey what do you think about having i3dm tiles also pass in their forward axis as X, like b3dm. The issue of auto-rotated instanced models came up on the forum - https://groups.google.com/forum/#!topic/cesium-dev/w5DnTHZATRo

@emackey
Copy link
Contributor Author

emackey commented Jun 13, 2018

Yes, certainly. Sadly I'm not a 3D Tiles expert (yet) so I'm sure I just overlooked some of the constructors. Are there any others?

@lilleyse
Copy link
Contributor

That should be it. Thanks!

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