Heya
Im doing a website for a client, stumbled upon a sought of problem in my code.
The website so far has flower petals floating from the top of the stage, with like perlin and bend as3mod modifier to it to give it that nice floating feel (and smooth rotation). The only thing is that whenever the plane rotates to like 0 where all you see is like a slither my whole computer system stops for about 5 seconds and then goes back to floating. Now i know this is not my computer because i viewed http://www.verbatim.jp/senshuken/ which is a high intensity papervision site and my computer runs that fine, so obviously ive made a **** up in my code!! Excuse the french!
here is my code
these are a few lines in the timeline to load and implement the class:
[COLOR=“silver”]//-------------------------[/COLOR]
import PetalClass;
var wind:Number = Math.random();
[COLOR=“Silver”]//PetalClass(plane width, plane height, x, y, z, velocity, wind)[/COLOR]
var rosePetal:PetalClass = new PetalClass(258, 300, 0, 500, 500, 1, wind);
var material:RosePetal = new RosePetal();
rosePetal.createSides(material);
addChild(rosePetal);
PS. the RosePetal is an item in the library!
And here is the class file:
[COLOR=“silver”]//-------------------------[/COLOR]
package
{
import flash.display.;
import flash.events.;
import com.as3dmod.IModifier;
import com.as3dmod.ModifierStack;
import com.as3dmod.modifiers.Bend;
import com.as3dmod.modifiers.Perlin;
import com.as3dmod.plugins.pv3d.LibraryPv3d;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.objects.special.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.lights.*;
import org.papervision3d.render.*;
import org.papervision3d.view.*;
import org.papervision3d.events.*;
import org.papervision3d.core.utils.*;
import org.papervision3d.core.animation.*;
import org.papervision3d.core.math.Number3D;
import org.papervision3d.core.utils.virtualmouse.VirtualMouse;// papervision
public class PetalClass extends MovieClip
{
private var render:BasicRenderEngine = new BasicRenderEngine();
private var scene:Scene3D = new Scene3D();
private var camera:Camera3D = new Camera3D();
private var viewport:Viewport3D = new Viewport3D(0,0,true,true);
public var motherPlane:Plane;
public var plane:Plane;
public var planeWidth:Number;
public var planeHieght:Number;
public var planeXPos:Number;
public var planeYPos:Number;
public var planeZPos:Number;
public var vy:Number;
public var wind:Number
public var modStack:ModifierStack;
public var perlin:Perlin;
public var bend:Bend;
public var mm1:MovieMaterial;
public var mm2:MovieMaterial;
public function PetalClass(planeW:Number, planeH:Number, planeX:Number, planeY:Number, planeZ:Number, velocity:Number, xWind:Number)
{
planeWidth = planeW;
planeHieght = planeH;
vy = velocity;
wind = xWind;
planeXPos = planeX;
planeYPos = planeY;
planeZPos = planeZ;
addEventListener(Event.ENTER_FRAME, processFrame);
addChild(viewport);
camera.focus = 10;
camera.zoom = 100;
motherPlane = new Plane(null, planeWidth, planeHieght, 5, 5);
motherPlane.material.lineColor = 0x000000;
motherPlane.material.oneSide = true;
motherPlane.material.lineAlpha = 0;
scene.addChild(motherPlane);
motherPlane.x = planeX;
motherPlane.y = planeY;
motherPlane.z = planeZ;
}
public function processFrame(e:Event):void
{
render.renderScene(scene,camera,viewport);
plane.x -= wind;
plane.y -= vy;
plane.z -= wind/2;
plane.pitch(0.5);
plane.roll(0.5);
if(plane.y <= -1200)
{
plane.x = planeXPos;
plane.y = 200;
plane.z = planeZPos;
}
modStack.apply();
}
public function createSides(front:MovieClip)
{
mm1 = new MovieMaterial(front, true);
mm1.interactive = false;
mm1.animated = false;
mm1.smooth = true;
mm1.oneSide = false;
plane = new Plane(mm1, planeWidth,planeHieght, 1, 4);
motherPlane.addChild(plane);
modStack = new ModifierStack(new LibraryPv3d, plane);
bend = new Bend(0.5, 0.5);
bend.force = Math.random() + 0.5;
perlin = new Perlin(1);
perlin.setFalloff(2, 0);
modStack.addModifier(bend);
modStack.addModifier(perlin);
}
}
}
i would be greatly appreciated if you experts could give some insight or label the stuff i did wrong (its highly possible!!)