我在三个JS中的三维地球上有几个标记。我试过这个
function onDocumentMouseDown( event ) {
event.preventDefault();
mouse.x = ( event.clientX / renderer.domElement.clientWidth ) * 2 - 1;
mouse.y = - ( event.clientY / renderer.domElement.clientHeight ) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
var intersects = raycaster.intersectObjects( objects );
console.log('outside');
if ( intersects.length > 0 ) {
console.log('inside');
intersects[0].object.callback();
}
}
document.addEventListener( 'click', onDocumentMouseDown, false );
但它总是印在“外面”。我应该将事件添加到精灵本身吗?或者到父网格?感谢。
仅供参考,callback
来自marker.callback = function() { console.log( 'HERE !!!' ); }