Skip to content

Commit

Permalink
Fix Cesium's breaking changes: +X and +Z faces (gltf_version=[0.8|1.0])
Browse files Browse the repository at this point in the history
  • Loading branch information
Son-HNguyen committed Jan 2, 2019
1 parent efad89d commit c598f94
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions js/CitydbKmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1599,15 +1599,21 @@
rollValue = 0;
}

// by default in glTF 2.0 +Z faces forward, while earlier version of Cesium uses +X
// https://github.com/AnalyticalGraphicsInc/cesium/pull/6632
headingValue = headingValue + 90;

var heading = Cesium.Math.toRadians(headingValue);
var pitch = Cesium.Math.toRadians(tiltValue);
var roll = Cesium.Math.toRadians(rollValue);

// Backward compatible....
var gltfVersion = CitydbUtil.parse_query_string('gltf_version', window.location.href);
if (gltfVersion == '0.8') {
var heading = Cesium.Math.toRadians(headingValue - 180);
var pitch = Cesium.Math.toRadians(180);
heading = Cesium.Math.toRadians(headingValue - 180);
pitch = Cesium.Math.toRadians(180);
} else if (gltfVersion == '1.0') {
heading = Cesium.Math.toRadians(headingValue - 90);
}

var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
Expand Down

1 comment on commit c598f94

@Son-HNguyen
Copy link
Member Author

Choose a reason for hiding this comment

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

Version 2.0 shall now be the default glTF version. For earlier versions, i.e. 0.8 and 1.0, a string parameter gltf_version=0.8 or gltf_version=1.0 must be given in the client URL.

This commit addresses the breaking changes in Cesium regarding the up/forward axis in glTF version 2.0 starting from Cesium 1.46/1.47.

Please sign in to comment.