Search code examples
javascripthtmlaframe

Aframe select by component


Is there a way to select all entities with a particular component attached?

I was trying document.querySelectorAll(".shadow"); and various other combinations to no avail.


Solution

  • I believe you're looking for a attribute selector - which allows grabbing HTML nodes by their attributes. a-frame components are pretty much custom made HTML attributes - you're setting them using setAttribute() :)

    In your case it would be document.querySelectorAll("[shadow]")

    Check it out in this fiddle.