更正 Three.js 中导入的 Cesium GLTF/GLB 文件的旋转

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

我在波士顿有一组 Cesium 3D 建筑图块。这是一个示例图块:model.glb。当我使用 THREE.GLTFLoader 将此图块导入 Three.js 时,模型会相对于 XZ 平面旋转。通过反复试验,我发现我可以通过如下旋转来拉直模型:

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

我怀疑这种旋转是由于 Cesiuim 默认使用地球固定框架轴 (ITRF)。如何在 Three.js 中自动反转此旋转(相对于通过反复试验手动这样做)?

这是我手动旋转模型之前的截图:

这是我手动旋转模型后的截图:

这是与 Cesium 3D tile 关联的地理空间信息:

{
  "boundingVolume":{"sphere":[1525116.05769,-4463608.36127,4278734.88048,28.30055]},
  "geometricError":0.09375,
  "content":{"url":"L12_0000110010123.b3dm"}
}

这是我最后做的事情:

// 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;

只需将 "gltfUpAxis" 转换为 "Z" 即可。或者你可以试试"Y"。

"asset": {
    "gltfUpAxis": "Z",
    "version": "1.0"
  },