Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Three.js 如何设置箭头形状的轴点_Three.js - Fatal编程技术网

Three.js 如何设置箭头形状的轴点

Three.js 如何设置箭头形状的轴点,three.js,Three.js,我正在使用three.js创建此箭头形状: let planeShape = new THREE.Shape() planeShape.moveTo(0, 0) planeShape.lineTo(3, 1) planeShape.lineTo(0, 2) planeShape.lineTo(1, 1) planeShape.lineTo(0, 0) var geometry = new THREE.ShapeGeometry( planeShape ) // Appropriate rota

我正在使用three.js创建此箭头形状:

let planeShape = new THREE.Shape()
planeShape.moveTo(0, 0)
planeShape.lineTo(3, 1)
planeShape.lineTo(0, 2)
planeShape.lineTo(1, 1)
planeShape.lineTo(0, 0)

var geometry = new THREE.ShapeGeometry( planeShape )
// Appropriate rotation or translation should take place here
var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } )
var mesh = new THREE.Mesh( geometry, planeMaterial )
scene.add( mesh )
我希望能够使用mesh.lookAt(位置),以便箭头的尖端指向指定的位置。然而,我没有能够设置一个合适的支点。我想我遇到了问题,因为我在2D中创建箭头形状的点,但最终导致3D对象失去了原点的轨迹


下面是我想要完成的一个示例:

var geometry=new THREE.shapegegeometry(planeShape)
add之后

geometry.translate(0, -1, 0); // center with x-axis
geometry.rotateY(-Math.PI * 0.5); // align with z-axis to use with lookAt()

var geometry=new THREE.shapegegeometry(planeShape)
add之后

geometry.translate(0, -1, 0); // center with x-axis
geometry.rotateY(-Math.PI * 0.5); // align with z-axis to use with lookAt()