Erain 3D
-->

Why is there a z-sorting issue

As a Flash engine, Sandy3D has some limitations. To obtain a good ratio between performance and rendering quality, we have done some choices.

Our Z-sorting approach is one of these choices. We currently use a mean algorithm. We also propose to use an object based sorting or a polygon based one. Both have their pros and cons:

Object based sorting pros:

Object based sorting cons:

The polygon based approach has the opposite pros and cons.

Each object/polygon computes its transformed Z value mean, and we sort the objects/polygons that way.

As a consequence, large objects/polygons do not have a very representative mean value, and they are very often source of sorting issue in Sandy3D.

How to solve a depth sorting issue

First thing to do

First if you have objects closed to each others, set their properties useSingleContainer to false. For these objects, the sorting algorithm will be polygon based, hence more accurate.

myObject.useSingleContainer = false;

Yes ok, but some problems remain

More generally, the simplest way to solve this, is to make polygons smaller, basically doable increasing the polygon count. Augment the quality, and you'll reduce the sorting artifact.

When using custom models, the effort shall be done at modelisation time.

And there's no way to force a depth or something?

Yes, Sandy3D offers that possibiliy. You can force the depth of an object.
But before using this feature, be sure to not have a free camera. The forced depth is efficient when the camera does not move in more than 2 dimensions.

This feature is convenient to make a long floor, for example, when you know that the camera will never go beneath:

myFloor.enableForcedDepth = true;
myFloor.forcedDepth = 9999999999999;