Cesium加载3dtiles并调整位置

效果展示

Cesium加载3dtiles并调整位置

代码

  1. 平移模型核心代码
   const _tx=tx?tx:0;
   const _ty=ty?ty:0;
   const _tz=tz?tz:0;
   const tempTranslation = new Cesium.Cartesian3(_tx, _ty, _tz);
   const offset =Cesium.Matrix4.multiplyByPoint(m, tempTranslation, new Cesium.Cartesian3(0,0,0));
   const translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
   tileSet.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
  1. 旋转及缩放模型核心代码
if(rx){
     const mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(rx));
     const rotate= Cesium.Matrix4.fromRotationTranslation(mx);
     Cesium.Matrix4.multiply(m, rotate, m);
   }
  
   if(ry){
     const my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(ry));
     const rotate= Cesium.Matrix4.fromRotationTranslation(my);
     Cesium.Matrix4.multiply(m, rotate, m);
   }
  
   if(rz){
     const mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(rz));
     const rotate= Cesium.Matrix4.fromRotationTranslation(mz);
     Cesium.Matrix4.multiply(m, rotate, m);
   }
  
   if(scale){
     const _scale = Cesium.Matrix4.fromUniformScale(scale);
     Cesium.Matrix4.multiply(m, _scale, m);
   }
 
   tileSet._root.transform = m;

完整代码示例

请参考在线示例

上一篇:【图像去雨】DCSFN: Deep Cross-scale Fusion Network for Single Image RainRemoval


下一篇:状态提升&共享state