ivan.popelyshev Posted March 27, 2016 Share Posted March 27, 2016 https://github.com/pixijs/pixi.js/pull/2414 I made a very scary PR for pixiv4, stil work in progress. It takes care of multiple things: No need to calculate matrices for objects every tick: only when they position/scale or something else was changed Same with bounds Same with interaction Sprite size doesnt change scale Camera projection doesnt change transforms. Object transform wont be re-calculated if camera was scrolled or rotated. DisplayObject can have pre-calculated local bounds that will be used to speed up interaction process. Things that I'm preparing right now: Z-indices, displayorder for camera. culling based on bounds for camera 3d transforms. See that gif at https://www.kickstarter.com/projects/chimeraco/lux-a-survival-mmorpg-pc-mac-xb1-ps4 ? Its pixi-flip. new version of pixi-spine that will use all that stuff. I need people who understand WTF is I am doing and who can tell me what can go wrong with it, because that's one of the most sofisticated things that I've made in my life. Quote Link to comment Share on other sites More sharing options...
GBear Posted March 28, 2016 Share Posted March 28, 2016 sounds great... there looks performance up... can i ask this meaning? Quote Same with bounds Same with interaction Sprite size doesnt change scale and is this option? Quote Z-indices, displayorder for camera. z-indices looks great but is this better than sorting children? is this automatic culling objects(containers) by camera? Quote culling based on bounds for camera thx~~ ps> can i ask pixi.spi Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 28, 2016 Author Share Posted March 28, 2016 And first demo for camera: http://ivanpopelyshev.github.io/examples/index.html?s=camera&f=mirror.js&title=Mirror How many bunnies do you see there? Quote Link to comment Share on other sites More sharing options...
Nazariglez Posted March 28, 2016 Share Posted March 28, 2016 19 minutes ago, ivan.popelyshev said: And first demo for camera: http://ivanpopelyshev.github.io/examples/index.html?s=camera&f=mirror.js&title=Mirror How many bunnies do you see there? Awesome, this feature will be really useful for multiplayer games! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 28, 2016 Author Share Posted March 28, 2016 Just now, Nazariglez said: Awesome, this feature will be really useful for multiplayer games! When I'll add z-index, it will be possible to sort ALL bunnies by some parameter, even if they are only projections or belong to different containers Quote Link to comment Share on other sites More sharing options...
fire7side Posted March 29, 2016 Share Posted March 29, 2016 Very cool. This will be something to keep watching. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 29, 2016 Author Share Posted March 29, 2016 Interaction works too - try to click on mirrored bunnies Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 29, 2016 Author Share Posted March 29, 2016 Z-order and z-index are here! http://ivanpopelyshev.github.io/examples/index.html?s=camera&f=zorder.js&title=Z-order Quote Link to comment Share on other sites More sharing options...
GBear Posted March 30, 2016 Share Posted March 30, 2016 Quote Z-order and z-index are here! http://ivanpopelyshev.github.io/examples/index.html?s=camera&f=zorder.js&title=Z-order hi @ivan.popelyshevlooks great... z-order is controlled by camera... is this more powerful than container's children controlling? which one is more optimized between sort children manually and camera-zindex controlling? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 30, 2016 Author Share Posted March 30, 2016 Camera z-index is much better: All objects inside camera, except those who are INSIDE filters or masks are sorted. Objects that are not renderable (culled) are ignored. There are no changes of "children" AT ALL. Camera forms _displayList array, that will be used by render() method. You can assign different z-index to parent and child, its useful for making shadows of objects. First they sorted by z-index, but if you specify function that assigns dynamic z-order (like sprite.zOrder = -sprite.position.y), it will be taken into account too. If both z-index and z-order are the same for two elements, that often happens if child is inheriting parent z-index, update order will be used. I'll implement special optimization for sort function later, but I dont think we'll need them right now. Quote Link to comment Share on other sites More sharing options...
fire7side Posted March 30, 2016 Share Posted March 30, 2016 Is the onZOrder automatically called during render, I didn't see it called anywhere? Why both zOrder and zIndex? They seem like the same thing. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 30, 2016 Author Share Posted March 30, 2016 I just thought about common uses of Z coordinate and came up with solution that covers them. zIndex is like layer in web-page. In most cases there will be only a few z-indices and I'll be able to optimize it. zOrder is for arranging sprites by their distance from camera, like in actual 2d/3d scene. onZOrder is called after updateTransform() of camera for every renderable element in that camera: https://github.com/ivanpopelyshev/pixi.js/blob/dev-v4.0.0-geom/src/core/display/Camera2d.js#L329 camera.onZOrder = function(obj) { if (obj.zIndex == 1) { //THATS MY UI! preserve natural order! I wonder why did I add it in camera container anyway... } else if (obj.zIndex == 0) { //my precious sprites. some of them are in containers, and camera might be rotated, so I take it directly from the matrix obj.zOrder = -obj.projectionMatrix2d.ty; } }; Quote Link to comment Share on other sites More sharing options...
d13 Posted April 2, 2016 Share Posted April 2, 2016 On March 27, 2016 at 4:16 PM, ivan.popelyshev said: I need people who understand WTF is I am doing and who can tell me what can go wrong with it, because that's one of the most sofisticated things that I've made in my life. Oh dear! Quote Link to comment Share on other sites More sharing options...
manelis Posted April 5, 2016 Share Posted April 5, 2016 This is not something that will come with the 4.0 version, right? Quote No need to calculate matrices for objects every tick: only when they position/scale or something else was changed Same with bounds Same with interaction Sprite size doesnt change scale Camera projection doesnt change transforms. Object transform wont be re-calculated if camera was scrolled or rotated. DisplayObject can have pre-calculated local bounds that will be used to speed up interaction process. This will likely give a huge performance boost in my use case Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 5, 2016 Author Share Posted April 5, 2016 @manelis You can build it from https://github.com/ivanpopelyshev/pixi.js/tree/dev-4.1.0 , and there are two examples on it already: http://pixijs.github.io/examples/index.html?s=camera&f=zorder.js&title=%5Bv4.1%5D+Z-order&v=dev-4.1.0 Quote Link to comment Share on other sites More sharing options...
manelis Posted April 5, 2016 Share Posted April 5, 2016 thank you but I will probably wait for a stable release. Quote Link to comment Share on other sites More sharing options...
klim Posted September 21, 2016 Share Posted September 21, 2016 Greetings Ivan, Is this still an active branch of pixijs? Thanks, klim Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 21, 2016 Author Share Posted September 21, 2016 @klim now Its a fork, third iteration, and it is used in production of some projects. Fourth will be done soon. https://gameofbombs.github.io/pixi-bin/ https://gameofbombs.github.io/pixi.js/ https://gameofbombs.github.io/pixi-bin/index.html?s=flip&f=cards.js&title=Cards As for Z-index, https://github.com/pixijs/pixi-display works just fine for latest pixi-v4, and its actually faster than the one in "scary pull request" and "gameofbombs pixi" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.