Ah thanks for the reply.
I did think of your approach as well, but it's more work ;(  (and the
problem is actually a fundamental problem apparently)
So I guess we should have a large particle pool from which particle
spawners take their particles and place them back in the pool when
done.

And now that I've seen you post here, perhaps you could take a look at
the skybox issue I mentioned earlier, it might be a bug within Away3D:
http://groups.google.com/group/away3d-dev/browse_thread/thread/4336c92f0e7d5553/70950aee6dfe396f?lnk=gst&q=skybox+issue#70950aee6dfe396f

On 11 mei, 13:33, DerSchmale <[email protected]> wrote:
> Hey,
>
> It seems the actual geometry of the Plane is never disposed, which
> prevents the buffers from being cleaned up. In any case, your current
> approach will be sub-optimal. I would consider rewriting it to recycle
> the Geometry object (in this case, do NOT dispose it), since it'll be
> the same for every object. So in effect, create a Plane once
> (statically, for example), have the particles simply extend Mesh
> rather than Plane, and pass a reference to the geometry to the Mesh's
> super constructor. Be sure to also recycle the material object if
> possible. It will be faster and much more memory-friendly.
> Further optimisations can be done by not creating and destroying
> SmokeParticle objects, but reset "destroyed" ones as newly spawned
> particles.
>
> Hope that helps,
> David
>
> On Apr 11, 7:56 pm, Josh Beckwith <[email protected]> wrote:
>
> > Game:http://positlabs.com/files/code/drive/
>
> > I'm making a driving game of sorts. I made a dust effect that spawns a
> > textured plane on enterframe 25% of the time. This plane grows for
> > some time, and then it's removed from the scene.
>
> > I made sure to limit the number of planes being displayed to 25.
>
> > The game crashes after some time due to running out of resources for
> > vertices or something like that. I don't think the planes are being
> > disposed of properly.
>
> > Here's the class:
>
> > package {
> >         import away3d.primitives.Plane;
> >         import flash.events.TimerEvent;
> >         import flash.geom.Vector3D;
> >         import flash.utils.Timer;
>
> >         public class SmokeParticle extends Plane {
>
> >                 public static var globalCount : int;
> >                 public static var collection : Vector.<SmokeParticle> = new
> > Vector.<SmokeParticle>(26, false);
>
> >                 private var fadetimer : Timer = new Timer(100);
>
> >                 public function SmokeParticle(pos : Vector3D, rotY : 
> > Number) {
> >                         super(Materials.SMOKE_MAT, 128, 128);
>
> >                         if(globalCount > 25) {
> >                                 destroy(collection[0]);
> >                         }
>
> >                         position = pos;
> >                         rotationY = rotY + Math.random()*31 - 15;
>
> >                         Drive.view.scene.addChild(this);
> >                         collection.push(this);
> >                         globalCount++;
>
> >                         fadetimer.addEventListener(TimerEvent.TIMER, fade);
> >                         fadetimer.start();
>
> >                 }
>
> >                 private function fade(e : TimerEvent) : void {
> >                         scaleX += .3;
> >                         scaleY += .3;
>
> >                         if (fadetimer.currentCount == 15)destroy(this);
> >                 }
>
> >                 private function destroy(target : SmokeParticle) : void {
> >                         if(target != null){
> >                                 collection.shift();
> >                                 target.dispose(false);
> >                                 Drive.view.scene.removeChild(target);
> >                                 
> > target.fadetimer.removeEventListener(TimerEvent.TIMER, fade);
> >                                 target.fadetimer.stop();
> >                                 globalCount--;
> >                         }
> >                 }
> >         }
>
> > }
>
> > And here's the error I get:
> > Exception fault: Error: Error #3691: Resource limit for this resource
> > type exceeded.
> >         at flash.display3D::Context3D/createVertexBuffer()
> >         at away3d.core.base::SubGeometry/getVertexNormalBuffer()[C:\Users
> > \Beeker\workspace\Drive\src\away3d\core\base\SubGeometry.as:192]
> >         at away3d.core.base::SubMesh/getVertexNormalBuffer()[C:\Users\Beeker
> > \workspace\Drive\src\away3d\core\base\SubMesh.as:130]
> >         at 
> > away3d.materials.passes::DefaultScreenPass/render()[C:\Users\Beeker
> > \workspace\Drive\src\away3d\materials\passes\DefaultScreenPass.as:377]
> >         at away3d.materials::MaterialBase/renderPass()[C:\Users\Beeker
> > \workspace\Drive\src\away3d\materials\MaterialBase.as:308]
> >         at away3d.core.render::DefaultRenderer/drawRenderables()[C:\Users
> > \Beeker\workspace\Drive\src\away3d\core\render\DefaultRenderer.as:184]
> >         at away3d.core.render::DefaultRenderer/draw()[C:\Users\Beeker
> > \workspace\Drive\src\away3d\core\render\DefaultRenderer.as:109]
> >         at away3d.core.render::RendererBase/executeRender()[C:\Users\Beeker
> > \workspace\Drive\src\away3d\core\render\RendererBase.as:308]
> >         at 
> > away3d.core.render::DefaultRenderer/executeRender()[C:\Users\Beeker
> > \workspace\Drive\src\away3d\core\render\DefaultRenderer.as:88]
> >         at 
> > away3d.core.render::RendererBase/render()[C:\Users\Beeker\workspace
> > \Drive\src\away3d\core\render\RendererBase.as:289]
> >         at away3d.core.render::DefaultRenderer/render()[C:\Users\Beeker
> > \workspace\Drive\src\away3d\core\render\DefaultRenderer.as:79]
> >         at 
> > away3d.containers::View3D/render()[C:\Users\Beeker\workspace\Drive
> > \src\away3d\containers\View3D.as:254]
> >         at 
> > Drive/onEnterFrame()[C:\Users\Beeker\workspace\Drive\src\Drive.as:
> > 262]

Reply via email to