You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.
Looking for object aircraft whenever mouse moves on the map object. If intersection exists, returns a JS object with the object, and point of intersection
map.on('mousemove', function(e){
// scale mouse pixel position to a percentage of the screen's width and height
mouse.x = ( e.point.x / threebox.map.transform.width ) * 2 - 1;
mouse.y = - ( e.point.y / threebox.map.transform.height ) * 2 + 1;
// update the picking ray with the camera and mouse position
raycaster.ray.origin.setFromMatrixPosition( threebox.camera.projectionMatrix );
raycaster.ray.direction
.set( mouse.x, mouse.y, 0.5 )
.unproject( threebox.camera )
.sub( raycaster.ray.origin )
.normalize();
// calculate objects intersecting the picking ray
var intersects = raycaster.intersectObject(aircraft)[0];
if (!intersects) return;
var t = map.transform;
var coords = {};
['x','y','z'].forEach(function(d){
var mapTransform = t[d] ? t[d] : 0;
var adjust = t[d] ? 256 : 0;
coords[d] = (intersects.point[d] + mapTransform) * Math.pow(0.5, t.zoom) - adjust
})
console.log({object: intersects, intersection: threebox.unprojectFromWorld(coords)})
})
The text was updated successfully, but these errors were encountered:
Looking for object
aircraft
whenever mouse moves on themap
object. If intersection exists, returns a JS object with the object, and point of intersectionThe text was updated successfully, but these errors were encountered: