In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: [PV3D] サンプル3 (3Dの視点を制御)

/**
 * Copyright Peach_man ( http://wonderfl.net/user/Peach_man )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/d6ZQ
 */

// forked from clockmaker's [PV3D] サンプル3 (3Dの視点を制御)
package {
    import flash.events.*;
    import org.papervision3d.materials.*;
    import org.papervision3d.objects.primitives.*;
    import org.papervision3d.view.*;
    
    public class Sample3 extends BasicView {
        public function Sample3():void {
            // マテリアルを作成
            var material:WireframeMaterial = new WireframeMaterial(0xFF0000);
            
            // 3Dオブジェクトを作成
            var sphere1:Sphere = new Sphere(material, 300, 10, 10);
            var sphere2:Sphere = new Sphere(material, 300, 10, 10);
            
            // 座標を設定
            sphere1.x =  500;
            sphere2.x = -500;
            
            // 3Dシーンに追加して、表示させる
            scene.addChild(sphere1);
            scene.addChild(sphere2);
            
            // レンダリングを開始
            startRendering();
            
            // エンターフレームを設定
            addEventListener(Event.ENTER_FRAME, loop);
        }
        
        // エンターフレーム
        private function loop(e:Event):void {
            // カメラの位置を変える
            var rateX:Number = mouseX / stage.stageWidth;
            var targetX:Number= -5000 * (rateX - 0.5);
            camera.x += (targetX - camera.x)*0.05;
            
            var rateY:Number = mouseY / stage.stageHeight;
            var targetY:Number=5000 * (rateY - 0.5);
            camera.y += (targetX - camera.y)*0.05; 
        }
    }
}