Correcting rotation of imported Cesium GLTF/GLB file in Three.js

I have a Cesium 3D tile set of buildings in Boston. Here is a sample tile: When I import this tile into Three.js using THREE.GLTFLoader, the model is rotated relative to the XZ plane. Through trial and error, I have found that I can straighten the model out by rotating it as follows:

model.rotation.x = -Math.PI / 4;
model.rotation.z = Math.PI / 10;

I suspect this rotation is due to Cesiuim using Earth-fixed frame axes (ITRF) by default. How can I reverse this rotation automatically in Three.js (versus manually doing so via trial and error)?

Here is a screenshot of the model before I manually rotate it:

Here is a screenshot of the model after I manually rotate it:

Here is the geospatial information associated with the Cesium 3D tile:


Hi Randy,

Cesium 3D Tiles have a different coordinate reference system than glTF. Take a look at the Coordinate System section of the 3D Tiles Specification for the details and the necessary transformations.

Thanks for your help. Here is what I ended up doing:

// Get the tile's cartesian center.
var cartesian = new Cesium.Cartesian3(1525116.05769, -4463608.36127, 4278734.88048);

// Get the tile's cartographic center.
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);

// Rotate the model.
model.rotation.x = -cartographic.latitude;
model.rotation.z = cartographic.longitude + Math.PI / 2;

Thanks for the update, glad it’s solved!

thanks for your topic,I meet the same problem.
double p = fun.XYZtoBL(rtc_center.X, rtc_center.Y, rtc_center.Z);

//count the rotation way in your value

double angleX = -p[1] / 180 * Math.PI;

double angleZ = p[0] / 180 * Math.PI +Math.PI / 2;

Vector3 t = new Vector3(v1, v2, v3);

//rotation the coordinate

Matrix4 m4 = Matrix4.RotateFromEuler(angleX, 0, angleZ);

Vector3 t2 = m4 * t;

//translate the corrdinate by the cesium_rtc

t2.X += rtc_center.X;

t2.Y += rtc_center.Y;

t2.Z += rtc_center.Z;

//the ans geted not in the correct location

double ans = fun.XYZtoBL(t2.X, t2.Y, t2.Z);

there is the screenshot,the lable whit number shoud on the terrain if the answer is coordinate location is in china,is there some change should be apply to the rotation value?

thank you for tour replay!

在 2018年6月20日星期三 UTC+8上午1:04:06,randy…@primitive.us写道:

This might be a slightly different problem. It’s also a bit hard to tell what the issue is without a bit more context.

Can you open a new topic with a bit more context and perhaps a running Sandcastle example of your code?