babylon-runtime / _r

Code Less, Babylon More
https://babylon-runtime.github.io/
Apache License 2.0
8 stars 1 forks source link

Are children selectors supported? #36

Open marcusdiy opened 3 years ago

marcusdiy commented 3 years ago

Like in HTML, is there a way to use nested/recursive selector? So this _r.select("*:mesh material:ball material:blue"); so it would: 1) split query by space " " so we have 3 nested selectors 2) find all *:mesh and the return childrens 3) find all children from previus query with material:ball 4) find all children with material:blue and return

fabsharp commented 3 years ago

Hi @marcusdiy and thanks for taking the time to test our framework, it's our first public issue :).

There's no nested/recursive selector implemented so a solution would be to use the filter methods : let res = _r.select(*:mesh).filter(mesh => return mesh.material && (mesh.material.name == "blue" || mesh.material.name == "ball"))

...But _r is not usefull in this case so maybe we can do something with the attribute selector. For example with _r we can make _r.select('*:mesh [isVisible = true]) ...But it's not recursive on the attribute, so it could be a good improvement to do something like _r.select('*:mesh [material.name == blue || material.name == ball])

What do you think ?