Pauan / rust-dominator

Zero-cost ultra-high-performance declarative DOM library using FRP signals for Rust!
MIT License
967 stars 62 forks source link

Scene Graph #22

Closed dakom closed 2 years ago

dakom commented 4 years ago

So this might be a bit early since I haven't actually tried working with Dominator yet, and I'm also not sure exactly how I'd want to build this out for practical usage, and it's not dom related... but...

On one foot, I'm wondering if I could have a tree of transforms where nodes listen to signals and upon change it causes specific properties of those nodes to cascade down.

So for example, changing a Mutable<Position> would cause that element's LocalTransform to change - and any LocalTransform change would cause that element and their children to update their WorldTransform's.

Along with the cascading changes, another gotcha is that some of them should be done in batches and a separate step. For example, perhaps the change from Position to LocalTransform is immediate, but updating all the WorldTransforms for dirty elements is once per tick.

It seems like Dominator is very related to this problem too since it's a tree and maybe does some batching too...?

dakom commented 2 years ago

Discord would probably be a better place to discuss this in more depth. Closing for now since it's not really an issue, more just a discussion point.

(yes- a scene graph could definitely build on Dominator, or more accurately on futures-signals)

Pauan commented 2 years ago

Yeah, I think a scene graph for canvas/WebGL/WebGPU should be a separate crate, which uses futures-signals. It wouldn't really be tied to dominator, it would have its own custom tree system.