想吐槽一下这个代码,看上去只是啰嗦了一些,或者把简单的实现复杂化,但是更有可能在某些情况下导致意外。 感觉ai也写不出这个代码啊 // compute a unit vector that points in the direction the camera is now
// in the xz plane from the center of the box
const direction = new THREE.Vector3()
.subVectors(camera.position, boxCenter)
.multiply(new THREE.Vector3(0, -100, 0))
.normalize();
// move the camera to a position distance units way from the center
// in whatever direction the camera was from the center already
camera.position.copy(direction.multiplyScalar(distance).add(boxCenter));
展开
评论