如何在摄像机视图后面创建一条线?请参见图片中的示例:
(红线是我想要生成的,蓝点是相机。)
我有这个生成线的代码,我也有鼠标移动:
var material = new THREE.LineBasicMaterial({
color: 0xff0000,
linewidth: 5
});
var geometry = new THREE.Geometry();
geometry.vertices.push(
new THREE.Vector3( 0, 5, 0 ),
new THREE.Vector3( 5, 0, 0 )
);
var LINHATARGET = new THREE.Line( geometry, material );
LINHATARGET.position.x = 1;
LINHATARGET.position.y = 0;
LINHATARGET.position.z = 0;
scene.add( LINHATARGET );
答案 0 :(得分:0)
快速解决方案:
scene.add(camera);
camera.add(line);
line.position.z = -1.0; // put the line in front of the camera
将作为孩子的线条添加到相机中将使其跟随其移动。
看看this fiddle。