away3d/away3d-core-fp11 — Issue #194: Objects sharing the same material cause Error when disposed
Author: flyon
Created: 2011-12-09 16:36:30+00:00
State: open

http://away3d.com/forum/viewthread/1538/#5085

var colorMaterial:ColorMaterial = new ColorMaterial(0xff00ff);
var container:ObjectContainer3D = new ObjectContainer3D();
var sphere:Sphere = new Sphere(colorMaterial);
var sphere2:Sphere = new Sphere(colorMaterial);
container.addChild(sphere);
container.addChild(sphere2);
_view.scene.addChild(container);
container.dispose(true);

when the container starts disposing the seccond sphere, the material of the seccond sphere is already disposed, which causes an error:

RangeError: Error #1125: The index -1 is out of range 1.
at away3d.materials::MaterialLibrary/unregisterMaterial()[D:\1. WEBDESIGN\Projects\DaVine\lib\away3d\materials\MaterialLibrary.as:107]
at away3d.materials::MaterialBase/dispose()[D:\1. WEBDESIGN\Projects\DaVine\lib\away3d\materials\MaterialBase.as:165]
at away3d.entities::Mesh/dispose()[D:\1. WEBDESIGN\Projects\DaVine\lib\away3d\entities\Mesh.as:166]
at away3d.containers::ObjectContainer3D/dispose()[D:\1. WEBDESIGN\Projects\DaVine\lib\away3d\containers\ObjectContainer3D.as:618]
at BugTest()[D:\1. WEBDESIGN\Projects\DaVine\src\BugTest.as:29]