Here is some code for creating a skybox that works for the viewer (in ES6):
export default class ViewerSkybox {
constructor (viewer, options) {
const faceMaterials = options.imageList.map((url) => {
return new THREE.MeshBasicMaterial({
map: THREE.ImageUtils.loadTexture(url),
side: THREE.BackSide
})
})
const skyMaterial = new THREE.MeshFaceMaterial(
faceMaterials)
const geometry = new THREE.CubeGeometry(
options.size.x,
options.size.y,
options.size.z,
1, 1, 1,
null, true)
const skybox = new THREE.Mesh(
geometry, skyMaterial)
viewer.impl.scene.add(skybox)
}
}
This is working fine on my side, as you can see in the live demo I created here.
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)].
The source of my extension using the skybox is here: Viewing.Extension.Showcase.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…