0
我也正与此代码解决方案旋转对象:Threejs - 围绕中心
var collisionGroup = new THREE.Group();
scene.add(collisionGroup);
(function() {
var geometry = new THREE.CircleGeometry(20, 32);
var material = new THREE.MeshBasicMaterial({ color: 0xffff00 });
var collisionCircle = new THREE.Mesh(geometry, material);
collisionCircle.position.z = -180;
collisionGroup.add(collisionCircle);
})();
function animate(timestamp) {
// apply camera rotation
var rotObjectMatrix = new THREE.Matrix4();
rotObjectMatrix.makeRotationFromQuaternion(camera.quaternion);
collisionGroup.rotation.setFromRotationMatrix(rotObjectMatrix);
// Update VR headset position and apply to camera.
controls.update();
// Render the scene through the manager.
manager.render(scene, camera, timestamp);
requestAnimationFrame(animate);
}
但我想知道是否有可能实现这一目标而无需为每个对象创建组我想旋转(会有其中许多人)。 这些对象的位置基于相机旋转amd,这就是为什么我使用了makeRotationFromQuaternion和rotation.setFromRotationMatrix。
也许有更容易的解决方案,然后存储相机四元数。
诀窍是修改几何图形并预先偏移每个顶点的位置。我有一段时间没有使用Three.js,所以我不能轻易给你一个直接的例子。但你可以检查文档(查找“位置”部分)http://threejs.org/docs/#Reference/Core/BufferGeometry –
其实我的错误这可能是正确的链接http://threejs.org/docs /#Reference/Core/Geometry,你会在寻找'translate'。 –