123456789101112131415161718192021222324 |
- //skybox
- import * as THREE from 'three'
- export default class BoundingMesh extends THREE.Mesh {
- constructor(boundingBox, material, skyHeight = 50) {
- //boundingBox = boundingBox.clone().expandByScalar(0.01) //许钟文改: 稍微放大了一丢丢的,避免和其他mesh冲突闪烁。尤其在飞入飞出时,地面闪烁一下,好像是和chunk冲突。过去是和marker冲突。
- //大部分没有mesh的都是户外,所以放大些,作为天空盒背景. 另外地板因为可能破损,所以position向上提升使最低高度不变
- boundingBox = boundingBox.clone().expandByVector(new THREE.Vector3(skyHeight, skyHeight, skyHeight))
- var size = new THREE.Vector3()
- boundingBox.getSize(size)
- var geometry = new THREE.BoxGeometry(size.x, size.y, size.z)
- //geometry.boundingBox = boundingBox; //xzw delete 较早:这句加上不对。因为后面算鼠标与skybox交点时 要用到的是boundingbox加上position才是真实skybox真实位置,所以boundingbox要居中的,而不应该是整体模型所在的位置。
- geometry.computeBoundingBox() //需要重新计算对称的bounding, 在获取鼠标交点时需要。否则热点加不上
- super(geometry, material)
- var center = new THREE.Vector3()
- boundingBox.getCenter(center)
- skyHeight && (center.y += skyHeight - 0.1)
- this.position.copy(center)
- this.frustumCulled = !1
- //flag && this.add(new THREE.WireframeHelper(this))
- }
- }
|