I've been working on a scene with orbitControls in threejs (r84) and I'm trying to incorporate a mouse event for raycasting. Although the function itself works, I'm having trouble getting both events to work simultaneously. It seems like I can only have one active at a time.
Within my init function, I currently have:
controls = new THREE.OrbitControls( cameraB1, rendererB1.domElement );
controls.addEventListener( 'change', render );
controls.enableZoom = true;
controls.enableRotate= false;
controls.addEventListener('mousedown',myOnMouseDownFunction ,false);
controls.update();
And here is the function that needs to be called:
function myOnMouseDownFunction( evt ) {
evt.preventDefault();
var array = getMousePosition( contB1, evt.clientX, evt.clientY );
onClickPosition.fromArray( array );
var intersects = getIntersects( onClickPosition, sceneB1.children );
if ( intersects.length > 0 && intersects[ 0 ].uv ) {
var uv = intersects[ 0 ].uv;
console.log(uv);
}
console.log("I am being called");
}
At this point, it feels like I have to choose between orbiting or executing my function. Is there a way to make them both work together seamlessly? Any help would be greatly appreciated.