-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
I'm doing a hit event over the 3D-Object. About the THREE.js documentation, it says to use Raycaster following the next code. But there are problems with de pitch of maps.
this._canvas.addEventListener('click', this.onCanvasClick);
this._camera = new THREE.PerspectiveCamera(
this._mapView.map.transform.fov,
this._mapView.map.transform.width / this._mapView.map.transform.height,
0.1,
//1000
1e21
);
this._camera.matrixAutoUpdate = false
this._raycaster = new THREE.Raycaster();
this._mouse = new THREE.Vector2( 1, 1 );
onCanvasClick(event) {
event.preventDefault();
this._mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
this._mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
this._raycaster.setFromCamera(this._mouse, this._camera);
const intersects = this._raycaster.intersectObjects(this._world.children, true);
if (intersects.length > 0) {
const intersectedObject = intersects[0].object;
console.log('Object!', intersectedObject);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels