google-ar / three.ar.js

A helper three.js library for building AR web experiences that run in WebARonARKit and WebARonARCore
https://developers.google.com/ar/develop/web/getting-started
Apache License 2.0
2.91k stars 365 forks source link

Creating custom planes #94

Closed cosmo-naut closed 6 years ago

cosmo-naut commented 6 years ago

How much support does ARCore and by extension three.ar,js have for managing custom planes? For example, can I extend the length or manually size a plane detected?

I understand that having the webAR wrapper does limit the access available to a developer, however I was wondering if there are any pathways to directly manage a plane.

Furthermore, this may be more of an ARCore question, but I understand that plane detection only currently supports convex 2d planes, is this correct? Thank you

jsantell commented 6 years ago

How much support does ARCore and by extension three.ar,js have for managing custom planes? For example, can I extend the length or manually size a plane detected? I understand that having the webAR wrapper does limit the access available to a developer, however I was wondering if there are any pathways to directly manage a plane.

The planes exposed are directly from the scene understanding capabilities of ARCore/ARKit -- you can extend these in your own code and do whatever you'd like with them (double the size of all planes, make all planes very large or "infinite", make assumptions about areas between planes if they're on the same Z plane, etc.), but the API focused on providing as much information as possible from the platform's scene understanding and to be building blocks or primitives for any experience, so the API will not support altering these planes in anyway. However you can use these building blocks to manipulate planes however you'd like.

Furthermore, this may be more of an ARCore question, but I understand that plane detection only currently supports convex 2d planes, is this correct? Thank you

Correct, ARCore supports 2D convex planes, and ARKit supports 2D rectangular planes.

Hope this helps! :smile:

cosmo-naut commented 6 years ago

Is there a specific object that manages these planes that I should investigate extending? I'm not entirely sure where I'd begin

I've answered my own question. For the curious: src/ARPlanes.js handles the plane related events given to us by ARCore. three.ar.js also has an ARPlanes class that is a duplicate of ARPlanes.js, I imagine it would do the same job. I am unclear whether I need to instantiate an ARPlanes object in my code to access it, or if there is an object already doing that behind the scenes

jsantell commented 6 years ago

src/ARPlanes.js is used by the ARDebug utility for visualizing planes, although not exposed as it's rather opinionated and everyone will want to use planes differently. The docs show how to listen to planes via the VRDisplay and from there can be manipulated. The surfaces demo uses the ARDebug plane visualization if you'd like to see where planes are, but I imagine it would be difficult editing and manipulating these in a way that's different from the true scene understanding.