Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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
Javascript 镜头后的线条_Javascript_Html_Canvas_Three.js_Html5 Canvas - Fatal编程技术网

Javascript 镜头后的线条

Javascript 镜头后的线条,javascript,html,canvas,three.js,html5-canvas,Javascript,Html,Canvas,Three.js,Html5 Canvas,如何在摄影机视图后面画一条线?请参见图中的示例: (红线是我要生成的,蓝点是相机。) 我有这段代码生成这条线,我还有鼠标移动: var material = new THREE.LineBasicMaterial({ color: 0xff0000, linewidth: 5 }); var geometry = new THREE.Geometry(); geometry.vertices.push( new THREE.Vector3( 0, 5, 0 ),

如何在摄影机视图后面画一条线?请参见图中的示例:

(红线是我要生成的,蓝点是相机。)

我有这段代码生成这条线,我还有鼠标移动:

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 );
快速解决方案:

scene.add(camera);
camera.add(line);
line.position.z = -1.0; // put the line in front of the camera
将线作为子对象添加到摄影机将使其跟随其移动

看一看