Add modelUpAxis
and modelForwardAxis
to tileset constructor
#10439
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.
This PR adds two constructor options to allow the user more control over the orientation of glTF models in a tileset.
A common difficulty when making 3D Tiles for use in CesiumJS is determining which way to orient the data. CesiumJS makes some assumptions when loading glTF files (+y up because of the glTF specification). Though CesiumJS assumes individual models follow the glTF spec and have +z forward. Meanwhile, 3D Tiles often use earth-centered, earth-fixed (ECEF) coordinates, and +x is (perhaps arbitrarily) chosen as "forward".
Depending on the above, CesiumJS automatically applies rotations to bring the data into ECEF coordinates. This works nicely if the data is in glTF's coordinate space. However, if the positions are in a +z up coordinate system (e.g. a local east-north-up (ENU) coordinate system)), an extra matrix rotation must be baked into the data to cancel out the automatic correction. This is non-obvious and redundant.
This PR adds
modelUpAxis
andmodelForwardAxis
that let the user describe the coordinate system used by the glTF models.Example use cases:
modelUpAxis: Axis.Z
modelForwardAxis: Axis.X
-- This may sound counterintuitive, but CesiumJS chooses +x forward. The model matrix (next step) will position and orient the coordinate system for a particular ENU frame.modelMatrix: Transforms.eastNorthUpToFixedFrame(...)
to position the tileset as desiredmodelUpAxis: Axis.Y
modelForwardAxis: Axis.X
(CesiumJS convention)modelUpAxis: Axis.Y
modelForwardAxis: Axis.Z
Example ENU sandcastle -- Red = East, Green = North, Blue = Up