mrdoob/three.js — Issue #715: children updates in dynamics. 
Author: Kaustuv
Created: 2011-11-01 12:38:17+00:00
State: open

Children added post parent transformations (rotate, scale, move) do not appear in the correct coods. Seems like the matrices are not being applied to the child. (Note: existing children however work fine with correct parent transformations being applied)

Am trying to add a sphere marker(child) at the mouse-ray-intersection point on a rotated mesh (parent). The added child sphere position does not coincide with intersection point. Code below. Any suggestions/advice?

function dblClick( event ) {
event.preventDefault();
var INTERSECTED=null;
sg.models.camera.update();
var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
sg.models.projector.unprojectVector( vector, sg.models.camera );
var ray = new THREE.Ray( sg.models.camera.position, vector.subSelf( sg.models.camera.position ).normalize() );
var intersects = ray.intersectObjects( sg.models.objectList );
if ( intersects.length > 0 ) {
if ( INTERSECTED != intersects[ 0 ].object ) {
var sphere = new THREE.Mesh( new THREE.SphereGeometry( 1,10,10 ), new THREE.MeshLambertMaterial( { color: 0xfff001 } ) );
sphere.position.x=intersects[ 0 ].point.x;
sphere.position.y=intersects[ 0 ].point.y;
sphere.position.z=intersects[ 0 ].point.z;
sphere.name='SPHEREMARKER';
INTERSECTED = intersects[ 0 ].object;
INTERSECTED.add( sphere );
//sphere.matrixAutoUpdate && sphere.updateMatrix();
}
}
else {
INTERSECTED = null;
}
}