1

I'll like to attach my object on my camera or camera target.

I try with crosshair.parent = camera; and this but doesn't work:

//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 )

Any suggestions?

Bruno Peres
  • 15,845
  • 5
  • 53
  • 89
Noodle09
  • 11
  • 4
  • try using pointer lock controls: https://github.com/mrdoob/three.js/blob/master/examples/js/controls/PointerLockControls.js – Rishi May 14 '17 at 14:04
  • how doest it works ? i add the script but nothing change. – Noodle09 May 14 '17 at 14:18
  • `var controls = new THREE.PointerLockControls(camera); scene.add(controls.getObject()); controls.enabled = true;` – Rishi May 14 '17 at 14:19
  • it returns: THREE.PointerLockControls is not a constructor – Noodle09 May 14 '17 at 14:21
  • You need to add the library first: https://github.com/mrdoob/three.js/blob/master/examples/js/controls/PointerLockControls.js – Rishi May 14 '17 at 14:22
  • i did it. but it returns this error. i've find this exemple: https://github.com/mrdoob/three.js/blob/master/examples/webvr_cubes.html so i had line 73 to 82.. and again nothing – Noodle09 May 14 '17 at 14:24
  • @Noodle09 see http://stackoverflow.com/questions/31831425/static-object-in-scene-three-js/31835326#31835326 – WestLangley May 14 '17 at 14:57
  • thx it's works fine ! – Noodle09 May 15 '17 at 09:26

0 Answers0