-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
With this tool, I can normally listen for mouse events for the model.
But i don't know how to judge a click on a blank scene .
const pointer = new THREE.Vector2();
document.addEventListener( 'pointermove', onPointerMove );
function onPointerMove( event:any ) {
pointer.x = ( event.clientX / window.innerWidth ) * 2 - 1;
pointer.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
}
const nDiv:any = contain3DEl.current;
nDiv.addEventListener('click', ()=>{
const raycaster = new THREE.Raycaster();
raycaster.setFromCamera( pointer, camera );
const intersects = raycaster.intersectObjects( modelNodeList );
if ( intersects.length <= 0 ) {
setSelectedModelObject(null);
props.onModelNodeSelected('');
PubSub.publish('menu_item_cancel_selected', '');
}
})
like intersects<=0 effect
Metadata
Metadata
Assignees
Labels
No labels