MozillaReality / mred

INACTIVE - Mixed Reality Editor
27 stars 6 forks source link

change the way hit testing is done: delegate to each object #55

Closed blairmacintyre closed 2 months ago

blairmacintyre commented 5 years ago

Doing one hit test at the root isn't any more efficient then calling hit test per child (since that is what it does).

We should add a "hittest" method to each object, and instead of calling rayCast's hit test on the scene, we should call hit test on each node in the scene. For the text object (see #54 ) this will just use that object's method (but might also eventually trigger dom events!)

This would also include having a "hitTest" method on a script, which we should pass the information in so that the simple implementation is just a single call. But, if a script creates three.js objects, as @anselm is thinking about, it will need to be able to respond to hits.

Each node can return more than one hit, but have each of them tagged with "itself". Then, it can sort out what it means when/if it gets the click back.

You can see how I do this in my geo glitch at https://glitch.com/~webxr-geo-street

blairmacintyre commented 5 years ago

Note: we only need to do hit testing on “thing” (leaf?) nodes, not groups, and thus would call the scripts on those nodes

And it think we can skip scripts first. Just change hit test to call a hit test method on each tangible / hit table object.