forked from: Papervision3Dの基本

by Makoto_Tanaka forked from Papervision3Dの基本 (diff: 33)
♥0 | Line 32 | Modified 2010-06-10 11:30:49 | MIT License
play

ActionScript3 source code

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

// forked from Makoto_Tanaka's Papervision3Dの基本
package {
	import org.papervision3d.view.*;
	import org.papervision3d.lights.*;
	import org.papervision3d.materials.*;
	import org.papervision3d.materials.special.*;
	import org.papervision3d.materials.shadematerials.*;
	import org.papervision3d.objects.primitives.*;
	
    import flash.events.Event;
    
    [SWF(backgroundColor="#888888")]
    public class PV3DTest extends BasicView {
    		
        public function PV3DTest() {
        		
        	    var plane1:Plane = createPlane(0x88cccc);
            plane1.z = 0;
            scene.addChild(plane1);
            
            var plane2:Plane = createPlane(0xcc88cc);
            plane2.z = 300;
            plane2.x = 100;
            scene.addChild(plane2);
            
            // レンダリング開始
            startRendering();
            
            // フレームイベントの追加
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
        
        // 毎フレームの処理
        private function onEnterFrame(e:Event):void {
        		var rot:Number = (mouseX / stage.stageWidth) * 360;
        		camera.x = 1000 * Math.sin(rot * Math.PI / 180);
        		
        }
        
        private function createPlane(color_:Number):Plane {
        		// マテリアル
        		var material:ColorMaterial = new ColorMaterial(color_);
      		material.doubleSided = true;
      		
      		return new Plane(material, 400, 400);
        }
    }
}