I ran into some significant trouble trying to use layers in an Away3DLite project. I have a Collada model containing a dozen or so objects, all of them u/v unwrapped into one of two bitmap materials. When attempting to assign the objects to individual layers, the faces seemed to get assigned to different layer sprites in an unpredictable manner, regardless of what layer it was assigned to.
After some poking around I eventually realized that the layers are associated by material in BasicRenderer.sortFaces(), which was causing the faces to get distributed among layers seemingly at random. This can be illustrated by altering the ExLayer example so that all the planes share a single material. In this case, they will all be assigned to the same layer, regardless of the individual layer property of the plane. So my first question: Is this intended behavior? If so, it may be worth documenting the association more clearly, or possibly making layer a property of material instead of Object3D. If not, there are a couple of potential fixes I tried out. One option is to alter the render so that sortFaces() monitors for layer as well as material changes when iterating through the faces, which seems to work ok for the most part. Another potential fix is to wrap the layer property in a method that clones the current material when updated, which seems to fix the issue as well. Is there a better or more obvious fix that I am overlooking? -Ken
