aframevr / aframe

:a: Web framework for building virtual reality experiences.
https://aframe.io/
MIT License
16.73k stars 3.99k forks source link

Raycaster component to react on attribute updates #2712

Closed eng1neer closed 7 years ago

eng1neer commented 7 years ago

I have a use case where an object is switching from selectable to a non-selectable state. I do this by changing the class name from 'screen selectable' to just 'screen' (raycaster is set up with '.selectable' selector).

It appears that the raycaster component does not react to class name changes, it only detects a change when an element is added or removed from DOM.

ngokevin commented 7 years ago

This was filed a couple days ago. Closed with solution at https://github.com/aframevr/aframe/issues/2708

eng1neer commented 7 years ago

@ngokevin I just think that this is not a corner or a rare case - changing a class name of an element so that it triggers (or does not trigger) a selector match. Why not do an extended check in the raycaster component (maybe just reacting on "class" attribute changes)? Is it a performance consideration?

ngokevin commented 7 years ago

It's expensive. Better to call the refresh method on demand rather than hacking in mutation observers and running selector refreshes 90 times per second.

ngokevin commented 7 years ago

If you really want to do it, you can create a component that force refreshes the raycaster on your desired interval.