Fork me on GitHub
Not signed in (Sign In)

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

    • CommentAuthoregatuz
    • CommentTimeDec 4th 2010 edited
     
    RotateVelocity based on y axis or x axis doesn't work. only work if use z axis.

    package
    {
    import com.greensock.TweenMax;
    import com.greensock.events.TweenEvent;

    import flash.display.Bitmap;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Vector3D;

    import id.web.ega.Kotakan;

    import org.flintparticles.common.particles.Particle;
    import org.flintparticles.threeD.actions.Rotate;
    import org.flintparticles.threeD.emitters.Emitter3D;
    import org.flintparticles.threeD.initializers.RotateVelocity;
    import org.flintparticles.threeD.particles.Particle3D;
    import org.flintparticles.threeD.particles.Particle3DUtils;
    import org.flintparticles.threeD.renderers.DisplayObjectRenderer;

    /**
    *
    * @author ega
    *
    */
    public class Main extends Sprite
    {
    private var rotationVelocity:RotateVelocity;

    private var tw:TweenMax;

    private var particle:Particle3D;

    private var imageParticles:Vector.;

    private var renderer:DisplayObjectRenderer;

    private var emitter:Emitter3D;

    private var kotakan:Kotakan;

    /**
    * Constructor.
    *
    */
    public function Main()
    {
    kotakan = new Kotakan;
    emitter = new Emitter3D;
    renderer = new DisplayObjectRenderer;

    rotationVelocity = new RotateVelocity(Vector3D.Z_AXIS, Math.PI / 2);

    emitter.addInitializer(rotationVelocity);

    emitter.addAction(new Rotate);

    renderer.camera.dolly(-400);

    renderer.addEmitter(emitter);

    addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    }

    private function onAddedToStage(e:Event):void
    {
    removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);

    kotakan.addEventListener(Event.COMPLETE, onFotoComplete);

    addChildren();
    }

    private function onFotoComplete(e:Event):void
    {
    kotakan.removeEventListener(Event.COMPLETE, onFotoComplete);

    imageParticles = Particle3DUtils.createRectangleParticlesFromBitmapData((kotakan.content as Bitmap).bitmapData, 10, emitter.particleFactory);

    emitter.addExistingParticles(imageParticles, true);

    draw('start');
    }

    private function onTwComplete(e:TweenEvent):void
    {
    emitter.stop();
    }

    private function onTwStart(e:TweenEvent):void
    {
    emitter.start();
    }

    protected function addChildren():void
    {
    addChild(renderer);

    draw();
    }

    public function draw(args:String='null'):void
    {
    switch(args)
    {
    case 'particle':
    tw = new TweenMax(particle.rotation, 5, {y: 180});
    tw.addEventListener(TweenEvent.START, onTwStart);
    tw.addEventListener(TweenEvent.COMPLETE, onTwComplete);
    case 'start' :
    emitter.start();
    }
    }
    }
    }
    • CommentAuthorRichard
    • CommentTimeDec 16th 2010
     
    In Flint, the particles are treated as billboards - they always face the camera. This is a simplification for performance purposes. I'm debating whether to change this in a future version. The upshot is that to see the rotation in the Y axis you need to move the camera to a position that is not perpendicular to that axis.

    e.g.
    renderer.camera.position = new Point3D( 0, 200, -300 );
    renderer.camera.target = new Point3D( 0, 0, 0 );


    Meanwhile, if you need full 3D perspective, you should use the Away3D renderer and use full 3D objects. (N.B. If you use Away3D sprites you again won't see the rotation.)