Home > Archives > 2007-12-05

2007-12-05

テスト

  • 2007-12-05 (水)
  • blog
  • hatena button
  • hatena count
  • save this page del.icio.us

ソースを載せるテスト

/**
* ...
* @author JC
* @version 0.1
*/

package  {

    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.Plane;
    //import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.scenes.MovieScene3D;
    import flash.events.MouseEvent;
    import caurina.transitions.Tweener;

    public class Test3D extends Sprite {

        private var container: Sprite;
        private var scene: MovieScene3D;
        private var camera: Camera3D;
        private var world: DisplayObject3D;

        private var p: Plane;
        private var edgeSize: int = 200;
        private var seg: int = 8;
        private var valX: int = 0;
        private var valY: int = 0;
        private var isClick: Boolean;

        public function Test3D() {
            addEventListener( Event.ADDED, init);
        }
        private function init(e: Event): void {
            this.isClick = false;
            removeEventListener( Event.ADDED, init);
            stage.quality = "HIGH";
            stage.scaleMode = "noScale";

            this.container = addChild(new Sprite()) as Sprite;
            this.container.x = stage.stageWidth / 2;
            this.container.y = stage.stageHeight / 2;

            this.scene = new MovieScene3D(this.container);
            this.camera = new Camera3D();
            this.camera.z = - this.edgeSize / 3;
            this.camera.x = this.edgeSize / 2;
            this.camera.y = this.edgeSize / 2;

            this.world = this.scene.addChild(new DisplayObject3D("world"));
            this.p = this.world.addChild(
                new Plane(
                    new ColorMaterial( 0xCC3300 , 2, {doubleSided: true}),
                    this.edgeSize, this.edgeSize,
                    this.seg, this.seg
                )
            ) as Plane;
            //this.scene.renderCamera(this.camera);
            this.container.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
            addEventListener(Event.ENTER_FRAME, doEnterFrame);
        }

        private function onClick(e: MouseEvent): void {
            if (this.isClick) {
                Tweener.addTween( this.container, {
                    scaleX: 1,
                    scaleY: 1,
                    time: 1,
                    transition: "easeOutElastic"
                });
            } else {
                Tweener.addTween( this.container, {
                    scaleX: 3,
                    scaleY: 3,
                    time: 1,
                    transition: "easeOutElastic"
                });
            }
            this.isClick = !this.isClick;
        }

        private function doEnterFrame(e: Event): void {
            this.valX += this.container.mouseX / 50;
            this.valY += this.container.mouseY / 50;
            this.world.rotationY = this.valX;
            this.world.rotationX = this.valY;
            this.scene.renderCamera(this.camera);
        }

    }

}

どうだしょ。

Home > Archives > 2007-12-05

Search
Feeds
Meta

Return to page top