Reputation: 9169
Here I create my camera:
camera = new THREE.PerspectiveCamera(90, width / height, 0.001, 1000);
camera.position.set(0, 15, 0);
scene.add(camera);
I have this object I want to make the child of the camera
var handGeometry = new THREE.SphereGeometry(0.1, 32, 32 );
var handMaterial = new THREE.MeshBasicMaterial({color: "#eac086"});
hand = new THREE.Mesh(handGeometry, handMaterial);
hand.position.set(1, 14, camera.position.z / 2);
I then add this object as a child of the camera
camera.add(hand)
However, the scene is empty, the child does not appear. I am using OrbitControls so I want my hand
object to rotate with the camera as it is turned.
Upvotes: 1
Views: 38
Reputation: 104833
If you add a renderable object as a child of the camera, then you must add the camera to the scene graph:
scene.add( camera );
Then, set your child's position relative to the camera's position. Since the camera is always looking down its local negaitive-z axis, try
child.position.set( 0, 0, - 10 );
three.js r.73
Upvotes: 2