-
Notifications
You must be signed in to change notification settings - Fork 169
Description
Description 📝
Hi, first of all thank you for all your work on this amazing project!
Usecase: I am developing an XR-App. I have to raycast not only from a screen (Desktop or in Augmented Reality on mobile) but also from a Headset plus controller. However, SimpleRaycaster.castRay()
only takes a 2d-pointer as a position parameter while in 3D space a 3D origin plus a 3D direction is required to create a ray.
Edit: Since custom ThreeJS raycasters are not supported in 3.1, it became impossible to perform a raycast in a 3D environment (i.e. when in AR or VR on mobile or headset ).
Suggested solution 💡
Even though it has not worked for me as expected in the past, the most straightforward solution seems to be a re-implementation of the function SimpleRaycaster.castRayFromVector()
.
Up until this commit, the method existed. Now it is commented out.
Trying to fully understand the way the raycasting works internally, I got lost a couple of files in between connection handlers and multithreading controllers. So I'm unfortunately not confident I can provide more concrete feedback on how to re-implement SimpleRaycaster.castRayFromVector()
.
Alternative ⛕
Back in 2.4 we used to be able to work around this by utilizing the three.js Raycaster with something like this:
const raycaster = components.get(OBC.Raycasters).get(world).three;
raycaster.set(touchOrigin, directionFromCamera);
const intersects = raycaster.intersectObjects(scene.children, true);
However, this thread states that the new fragments won't work with three.js raycaster anymore since geometry buffers are dropped after GPU upload.
And indeed, when upgrading to 3.1, the raycaster.intersectObjects()
will throw errors like this for many objects (and also prevents copying/stringifying them):
TypeError: can't access property 0, this.array is undefined
(This happens irrespective of whether the model is loaded from a .ifc
or .frag
file.)
I have tried working around this by manually reconstructing the dropped meshes for later raycast use - as described in the thread mentioned above. But on first glance it seems like this either requires duplicate meshes for items or more involved replacement of all item's meshes (upon raycast, I still want to infer the item from the mesh and associated ifc-properties).
Additional context ☝️
Maybe I am missing something but for now I will be switching back to 2.4 in order to use the threejs raycast. (EDIT: docs for previous versions are here: https://thatopen.github.io/engine_past-docs/3.0.x/Tutorials/Components/Core/Raycasters)
Thank you all for your time and effort!
Validations ✅
- Read the docs.
- Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.