3

我正在定义一个锥体,我需要能够围绕其顶点(锥体厚度最小的点)旋转。我还找不到设置旋转发生点的方法。

var coneGeometry = new THREE.CylinderGeometry(1000, 0, width, 50, 50, false);
var cone = new THREE.Mesh(coneGeometry, material);
cone.position.x = x;
cone.position.y = y + width / 2;
cone.position.z = z;
// I want this rotation to happen around the point given by the (x, y, z) location
cone.rotation.x = dip;
4

1 回答 1

10

圆锥几何体以原点为中心。您需要做的是在创建圆锥几何体后立即平移它,使圆锥体的尖端位于原点。

coneGeometry.applyMatrix( new THREE.Matrix4().makeTranslation( 0, coneHeight/2, 0 ) );

(平移符号的变化取决于圆锥的哪一端是小端。)

现在,当您旋转圆锥体时,它将围绕尖端旋转。提示也将位于您设置的位置。

编辑:您现在可以这样做,而不是:

coneGeometry.translate( 0, coneHeight/2, 0 ); // three.js r.72
于 2012-09-24T12:07:23.707 回答