HitTestWorldMesh Alternative in Connected Lens
Hello!
I'm currently trying to merge the True Size Object template with the Connected lens template. One issue that the connected lens template has is that hitTestWorldMesh is disabled from DeviceTracking API.
To my understanding, the True Size Object template depends on the hitTestWorldMesh feature in order to place the object in the world. I was wondering if anyone has any thoughts on alternatives I can use in order to get past this restriction?
For context, the piece of code I'm currently looking at is trying to raycast where I'm clicking and returning the position that intersects with the world mesh.
Thank you so much!
Answers
-
One possible solution to this issue could be to use a different method for raycasting and intersecting with the world mesh in your Snap Lens. Instead of using the hitTestWorldMesh function, you could try using the hitTest function provided by the Scene Tracking API.
The hitTest function allows you to specify a ray to cast and a set of objects to intersect with, and it returns a list of intersection points. You can use this function to raycast from the device's camera and intersect with the objects in your scene, similar to the way hitTestWorldMesh works.
Here's an example of how you could use the hitTest function in your Snap Lens:
// Create a ray to cast from the device's camera const ray = Device.createRayFromCamera(Camera.main); // Set up a list of objects to intersect with const objects = [object1, object2, ...]; // Perform the hit test and get a list of intersection points const hits = Scene.hitTest(ray, objects); // Process the intersection points as needed for (let hit of hits) { // Do something with the hit point }
0