-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not able to highlight floor of a 3D building on click of 3D floor label(three js sprite object). #10595
Comments
Hi, @gireeshbhogireddy. I'd love for this to work more easily, but at the moment, I think the answer is that the THREE.js raycaster doesn't work with the combined projection*view matrix Mapbox provides. Since Mapbox deals with tiles and scaling in a very particular way, it doesn't exactly use a single, cleanly separated projection and view matrix as is common in computer graphics. As far as THREE.js goes, this line points out that the raycaster doesn't work with a generic Camera instance: I've created a codepen which I think would function if a https://codepen.io/rsreusser/pen/XWpxWyv?editors=0010 At the moment, I think the only answer I can offer is that Mapbox's custom layer matrix output is not fully compatible with three.js's PerspectiveCamera. |
As mentioned, the issue is related to Raycaster initialization and different coordinate spaces used. I've forked @rreusser example to https://codepen.io/astojilj/pen/jOyQNLW?editors=0010 and added one more cube for raycast verification. Untitled.movI'll use raycast code to explain coordinate spaces and transformations:
Cubes are in scene coordinate system, 300 meters wide, 1000 meters apart. The direction of the ray is defined by camera position as origin and point on far plane, converted vec4(mouse.x, mouse.y, 1, 1) to scene coordinates. |
I was trying to highlight floor of a 3D building on click of floor label.
As mapbox gl does not have possibility for 3D label, I have added label with the help of three js. Able to add floor labels but not able to raise onclick event for three js sprite label.
I tried raycaster method to find the clicked label from this reference (https://threejs.org/docs/#api/en/core/Raycaster).
But it is not working properly, it is working at particular tilt of camera and also not working for every label.
How to raise click event for labels properly in every angle? . Kindly help me.
Thanks,
Gireesh
The text was updated successfully, but these errors were encountered: