怎么给forge的做一个天空盒

想要给forge的外面去添加一个天空盒,把场景弄的更好看,怎么去实现,试过three.js成功了但是forge好像做了改动,先是报错THREE.CubeTextureLoader is not a constructor这是因为forge所用的three.js版本的问题吗? 然后新建一个盒子但是出现了新的问题,视角好像被切掉了一样。截图和代码如下:
图片描述

var materialArr=[];
var directions = ["aa_RT","aa_LF","aa_UP","aa_DN","aa_FR","aa_BK"] ;
for (var i = 0; i < 6; i++){

materialArray.push( new THREE.MeshBasicMaterial({
  map: THREE.ImageUtils.loadTexture( "lib/img/aa/"+ directions[i] + ".jpg" ),
  side: THREE.BackSide
}));

}
var skyBoxGeom = new THREE.CubeGeometry(80,80,80);
var skyBoxMaterial = new THREE.MeshFaceMaterial(materialArr);
var skyBox = new THREE.Mesh(skyBoxGeom,skyBoxMaterial);
viewer.impl.scene.add(skyBox);

阅读 5.3k
3 个回答

在stackoverflow上看到了大神给的解决方法,大致意思是要加载另一个范围更大的模型,这样剪裁面就会自动更新。大神的原话我翻译不好就直接粘原话了,如下:

One thing you need to take care about is that the viewer uses near/far clipping planes which are created based on the loaded model bounding box. Your skybox is probably much bigger than the model, so one workaround is to load a second model with a much bigger extents, so the scene clipping planes are updated automatically. The second model only contains tiny cubes placed at the desired extents, for example [(-500, -500, -500), (500, 500, 500)].

krdkP.png
详情请查看https://stackoverflow.com/que...,同时也给出了扩展地址https://github.com/Autodesk-F...
因forge github文件地址修改现已经修正文件地址

经调试后,这看起来是因为 Renderer 的背景不是透明的,Renderer 的背景预设是有颜色的,所以造成 Skybox 部份的内容内被 Renderer 的背景颜色覆盖了,以目前 Viewer 公开的资料、介面和我的经验看来,这没办法修改 Renderer 的设置。您可以尝试透过写英文信到 forge.help@autodesk.com 求救,问看看有没有解法。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏