lume icon indicating copy to clipboard operation
lume copied to clipboard

consolidate "selector ref" functionality into a re-usable class or function, make it search downwards not just upwards

Open trusktr opened this issue 1 year ago • 0 comments

Some elements such as TextureProjector, ClipPlane, and SpotLight support referencing or being referenced via attributes that specify a CSS selector. For example,

<lume-clip-plane id="clipPlane1"></lume-clip-plane>
<lume-clip-plane class="clipPlane2"></lume-clip-plane>

<lume-mesh ... has="clip-planes" clip-planes="#clipPlane1, .clipPlane2"></lume-mesh>

This works across shadow roots, but currently upwards shadow trees only. It does not search into sibling shadow trees or downwards. For example the lume-mesh in the example will not be able to reference any lume-clip-planes in a shadow tree that is sibling to the shadow tree it is in or any tree below itself or the siblings', which may be limiting. Let's make it search all reachable roots of the given element, not just in upwards shadow trees.

The implementation of this is currently repeated in a similar way in several classes:

  • ClipPlanesBehavior
  • SpotLight
  • ProjectedMaterialBehavior which is has an improved version of the last two
  • and we're working on more

As we add more elements with references to other elements, we want to stop duplicating the logic.

trusktr avatar Apr 30 '24 00:04 trusktr