metafizzy / zdog

Flat, round, designer-friendly pseudo-3D engine for canvas & SVG

Home Page:https://zzz.dog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An alternative to group that maintains in-group rendering order

oganm opened this issue · comments

Related to #73.

Currently a way to fight z-fighting involve adding objects to a single group which means they will z-fight according to the center of mass of the group they belong to. However being in a group also controls the way things are rendered relative to the other members of the group, namely, being first in the group means the object is always rendered above the other. It would be nice to be able to combine the two behaviours, where the group members are rendered based on the center of the mass of the group compared to other elements and to each other compared to other group members. The current functionality of the group has also other uses which is why an alternative object would probably be the solution.

See this modified version of the z-fighting code from the documentation as an example.
https://codepen.io/anon/pen/rErrmp

One of the bottom balls have a different color for each side. In the grouped side, the different colored ball always appears above its peers which is not desirable in all cases.

One hacky solution with the current system I can think of would be to create invisible objects and group each dot with a different invisible object. That means the center of mass of each group can still be placed behind the large blocking object yet their relative position to each other could also be preserved.

Does updateSort: true, not do exactly this?

yes... yes it does.