const tileset = tileSet;
// 模型外包围盒,center:模型中心点,radius:包围盒半径
let boundingSphere = tileset.boundingSphere;
// 模型中心点
let origin = boundingSphere.center;
// 获取到以模型中心为原点,Z轴垂直地表的局部坐标系,以矩阵表示,此矩阵为将局部坐标系变换到世界坐标系的变换矩阵
let localMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
// 平移向量(tx,ty,tz) 此处表示沿着x轴平移10米,y轴和z轴不变
let tempTranslation = new Cesium.Cartesian3(0, 0, -100);
// 偏移后的位置,世界坐标系中的位置,即:局部坐标中(tx,ty,tz)在世界坐标系中位置
let offset = Cesium.Matrix4.multiplyByPoint(localMatrix, tempTranslation, new Cesium.Cartesian3(0, 0, 0));
// 计算世界坐标系下平移向量
let translate = Cesium.Cartesian3.subtract(
offset,
origin,
new Cesium.Cartesian3()
);
tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translate);
网友评论