其他分享
首页 > 其他分享> > 3dtiles贴地

3dtiles贴地

作者:互联网

从网上下载的大雁塔和文庙的3dtiles。一个在天空,一个在地下。。

加载模型时设置clamptoground无效。。

    var height = 81.5;  //根据地形设置调整高度 大雁塔:-420
    tileset.readyPromise.then(function(argument) {
      //贴地显示
      var cartographic = Cesium.Cartographic.fromCartesian(tileset.boundingSphere.center);
      var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, cartographic.height);
      var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, cartographic.height + height);
      var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
      tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
    })

参考1:https://www.cnblogs.com/HandyLi/p/11113030.html

参考2:https://blog.csdn.net/caozl1132/article/details/111549414

参考3:https://www.cnblogs.com/huqi-code/p/8288239.html  https://www.jianshu.com/p/bc0c3f84226c

    //修改高度【独立方法】
    // setHeight(height) {
    //   let center = Cesium.Cartographic.fromCartesian(this.tileset.boundingSphere.center);
    //   let surface = Cesium.Cartesian3.fromRadians(center.longitude, center.latitude, center.height);
    //   let offset = Cesium.Cartesian3.fromRadians(
    //     center.longitude,
    //     center.latitude,
    //     center.height + height
    //   );
    //   let translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
    //   this.tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
    // }

 

标签:tileset,center,Cartesian3,cartographic,贴地,height,3dtiles,Cesium
来源: https://www.cnblogs.com/2008nmj/p/15675048.html