首页 / 浏览问题 / 三维GIS / 问题详情
iclien3d for cesium 替换天空盒失败
YE1
8EXP 2024年03月18日

按照官网示例添加的天空盒,加载失败,天空变为纯黑色,控制台没有错误提示

 const qingtianSkyBox=new Cesium.SkyBox({
     nearGround:true,
     sources:{
       positiveX:'../assets/天空盒素材/Right.png',
       negativeX:'../assets/天空盒素材/Left.png',
       positiveY:'../assets/天空盒素材/Front.png',
       negativeY:'../assets/天空盒素材/Back.png',
       positiveZ:'../assets/天空盒素材/Up.png',
      negativeZ:'../assets/天空盒素材/Down.png',
      
    }
   })
       const defaultSkyBox=viewer.scene.skyBox
       const currentSkyBox=qingtianSkyBox
       scene.skyBox=currentSkyBox
       scene.postRender.addEventListener(function() {
                  var cameraHeight = scene.camera.positionCartographic.height;
                  var toggleHeight = 23e4;
                  if(cameraHeight < toggleHeight && Cesium.defined(currentSkyBox)) {
                     scene.skyBox = currentSkyBox;
                     scene.skyAtmosphere.show = false;
                    }  else {
                       scene.skyBox = defaultSkyBox;
                       scene.skyAtmosphere.show = true;
                     }
                });

...