将对象附加到相机three.js

时间:2017-05-14 13:50:11

标签: javascript three.js

我想将物体贴在相机或相机目标上。

我尝试使用crosshair.parent = camera;,但这不起作用:



//Crosshair
var crosshair = new THREE.Mesh( new THREE.PlaneGeometry( 5, 5 ), mat_crosshair );
			// place it in the center
var crosshairPercentX = 50;
var crosshairPercentY = 50;
var crosshairPositionX = (crosshairPercentX / 100) * 2 - 1;
var crosshairPositionY = (crosshairPercentY / 100) * 2 - 1;

crosshair.position.x = crosshairPositionX * camera.aspect;
crosshair.position.y = crosshairPositionY;

crosshair.position.z = -0.3;
crosshair.rotation.y = 1.6;

camera.add( crosshair );
scene.add ( crosshair )




有什么建议吗?

0 个答案:

没有答案