In my scene, I have a hierarchy of objects where one is the parent and the other is the child.
My goal is to determine a Vector3
relative to the deepest child
object that points towards a specific vector in the scene (look_point
).
var grandParent = new THREE.Object3D();
var parent = new THREE.Object3D();
var child= new THREE.Object3D();
var look_point = new THREE.Vector3();
grandParent.position.set(9,5,3);
grandParent.rotation.set(1,2,3);
parent.position.set(5,8,3);
parent.rotation.set(2,1,3);
child.position.set(2,5,3);
child.rotation.set(3,2,1);
scene.add(grandParent);
grandParent.add(parent);
parent.add(child);
var m = new THREE.LineBasicMaterial({ color: 0xFF00FF, blending: THREE.AdditiveBlending, transparent: true, opacity: 1, depthTest: false })
/// draw line in scene
var v = new THREE.Vector3().copy(child.position);
v = parent.localToWorld(v);
v = grandParent.localToWorld(v);
var g = new THREE.Geometry();
g.vertices.push(new THREE.Vector3().copy(v));
g.vertices.push(new THREE.Vector3().copy(look_point));
scene.add(new THREE.Line(g,m));
// how to get relative points to draw line with child object as a parent
var g2 = new THREE.Geometry();
g2.vertices.push(???); //// how to get Vector3 relative to child pos and rot?
g2.vertices.push(new THREE.Vector3());
child.add(new THREE.Line(g2,m));