对于新版本模型旋转直接就飞了,原因是旋转中心不对,cesium包的旋转中心是地球中心,想要解决这个问题,可以先把模型平移到球心,然后旋转,再平移回来
也可以按照上面方式取巧,上面代码没有贴完整不好意思,xyz是位置,这个位置自己选择就是旋转的中心点,RotateX,RotateY,RotateZ是xyz坐标平移什么的
up3dtilesMaxtrix() {
tileset.readyPromise.then(function(argument) {
let x = "298.29725",
y = "145.03273",
z = "0";
let RotateX = 0,
RotateY = 10,
RotateZ = -94;
//旋转
let mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(RotateX));
let my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(RotateY));
let mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(RotateZ));
let rotationX = Cesium.Matrix4.fromRotationTranslation(mx);
let rotationY = Cesium.Matrix4.fromRotationTranslation(my);
let rotationZ = Cesium.Matrix4.fromRotationTranslation(mz);
//平移
let position = Cesium.Cartesian3.fromDegrees(x, y, z);
let m = Cesium.Transforms.eastNorthUpToFixedFrame(position);
// 缩放
let scale = Cesium.Matrix4.fromUniformScale(3);
//旋转、平移、缩放矩阵相乘
Cesium.Matrix4.multiply(m, rotationX, m);
Cesium.Matrix4.multiply(m, rotationY, m);
Cesium.Matrix4.multiply(m, rotationZ, m);
Cesium.Matrix4.multiply(m, scale, m);
//赋值给tileset
tileset._root.transform = m;
viewer.zoomTo(tileset);
});
},
已解决