我已经在我的threejs应用程序中创建了一些盒子几何形状,并且我已经使用下面的代码成功地从一个圆柱体中心绘制到另一个圆柱体的中心:
function cylinderMesh(pointX, pointY, material) {
var direction = new THREE.Vector3().subVectors(pointY, pointX);
var orientation = new THREE.Matrix4();
orientation.lookAt(pointX, pointY, new THREE.Object3D().up);
orientation.multiply(new THREE.Matrix4(1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0, 0,
0, 0, 0, 1));
var edgeGeometry = new THREE.CylinderGeometry(2, 2, direction.length(), 8, 1);
var edge = new THREE.Mesh(edgeGeometry, material);
edge.applyMatrix(orientation);
edge.position.x = (pointY.x + pointX.x) / 2;
edge.position.y = (pointY.y + pointX.y) / 2;
edge.position.z = (pointY.z + pointX.z) / 2;
return edge;
}
scene.add(cylinderMesh(vertex1, vertex2, globalMaterial));
我的问题是:如果它们移动时如何保持圆柱体“连接”到我提供的两个顶点?
我不想使用THREE.Line
,因为我无法控制线条的宽度,而且我注意到如果相机距离太近,裁剪会出现奇怪的问题。
有什么想法吗?