Skip to main content

cesium 位置,旋转,高度 修改

  1. 调整模型高度

    let offsetHeight=10;
    var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
               url: '../test/tileset.json'
           }));
           viewer.scene.primitives.add(tileset);
           tileset.readyPromise.then(function(tileset) {
               var boundingSphere = tileset.boundingSphere;
               var cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
               var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
               var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, offsetHeight);
               var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
               tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
    ​
               //viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.5, -0.2, tileset.boundingSphere.radius * 1.0));
           });

注册VIP

如果已经是VIP,请直接登陆 登陆

发表回复