views:

89

answers:

1

Hey,

So I'm working on a project, and I've created a 3D scene with particles and everything how I need it.. I'm hoping to use the PV3D2.0 LensFlare class to add a lens flare to the scene. I have all the lensflare movieclips set up, and I'm using the following code to instantiate the LensFlare, but I'm getting the error

TypeError: Error #1034: Type Coercion failed: cannot convert org.papervision3d.core.effects.objects::LensFlare@34723f41 to org.papervision3d.objects.DisplayObject3D.

var light:PointLight3D
var lf:LensFlare;
var h1:MovieClip = new HaloMC();
h1.filters = [new BlurFilter(4,4,2)];
var h2:MovieClip = new HaloMC2();
h2.filters = [new BlurFilter(4,4,2)];
var h3:MovieClip = new HaloMC5();
h3.filters = [new BlurFilter(4,4,2)];
var flArray:Array = [new MainFlareMC(), new HaloMC4(), h1, new FlareMC(), h2, new FlareMC(),h3, new FlareMC() ];
light = new PointLight3D(false);
light.x = 3000;
light.z = 10000;
lf = new LensFlare(light,flArray,viewport.width,viewport.height);
scene.addChild(lf);

I found a LensFlare tutorial (which is where I got the array and movieclips from) from 2008 but it's not compatible with Great White, so I'm trying to recreate it using the new API.

A: 

According to Andy Zupko, you also need to pass a RenderLayer to the constructor. Once the LensFlare instance has a RenderLayer, it will render there, so you don't need to add it to the Scene.

A LensFlare is not a DisplayObject3D, which is why you're getting the error. You shouldn't add it to the Scene. Once you created an instance, just update using the updateFlare() method and that should be it.

pv3d lens flare

George Profenza