Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3980

Update scene graph via state

$
0
0

I'm toying around with the idea of rendering out via react or some other "view-from-state" methodology. Whatever it is - in this scenario, state is managed via logic before it gets pushed to the view and state is 100% pure simple plain object data.

Is there a good way to work with this and pixi?

e.g. imagine I end up with objects like this (just illustrative, I haven't cracked the exact format yet):

state: { 
  background: bgTexture, 
  spriteLayers: [
    [{texture: personTexture, x:1,y:2,scale:1}, {texture: enemyTexture, x: 100,y: 100, scale: .5}],
    [{texture: tree, x:50,y:50,scale:1}, {textureFrames: clouds, x: 75,y: 75, scale: 1, frame: 10}]
  ]
}

It wouldn't be a 1:1 mapping to pixi, and I'd be throwing in other non-pixi metadata (e.g. physics info like velocity), but it should be able to translate directly into a representation via pixi

Each tick the entire object would be updated and re-passed to the renderer.

I'm not sure if I'll actually build anything with this right now, but I'd love to hear some approaches - even if just for putting in the back of my mind.

A naive approach might be to completely wipe the Stage and just re addChild everything from scratch every frame... but I guess that's wildly less efficient than just moving objects that have changed, etc.

I guess I'm looking for a sort of vDom implementation for PIXI type of thing...

Thanks!


Viewing all articles
Browse latest Browse all 3980

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>