【发布时间】:2014-01-07 15:29:41
【问题描述】:
我是 Three.js 的新手,我想为我的场景创建一个飞行相机。
我已经看到 THREE.Geometry 具有 .computeBoundingSphere() 方法和 .boundingSphere 属性,它为我提供了该对象边界球的中心和半径。
假设我的场景中只有一个网格,我可以通过 scene.children[0].computeBoundingSphere 获得它
想法是使用.boundingSphere.center 设置myCamera.lookAt 并使用.boundingSphere.center 和.boundingSphere.radius 与我的视角的Math.sin/cos 来设置myCamera 位置。
问题 1:这是继续进行的最佳方式还是 Three.js 是否为该范围提供了任何特殊的类或帮助器?
问题 2:如果我的场景包含多个网格并且我想要一个全局场景 boundingSphere,该怎么办?我是否已经手动遍历所有scene.children(跳过相机、灯光等)并以数学方式创建单个网格的 boundingSphere 的“boundingSphere”,还是有更聪明的方法来做到这一点?是否可以添加一个“根”虚拟对象,其中包含我所有的场景网格,并作为所有子 boundingSpheres 的结果来获取它的 boundingSphere?
【问题讨论】:
标签: javascript three.js