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:DAEオブジェクトを読んでミル

PaperVision3DのDAEクラスでオブジェクトを読んでみるテスト。
モデルが重めでごめんなさい。
ロードが完了するまで少しまってね。
// forked from noenoe's PV3D:DAEオブジェクトを読んでミル
// PaperVision3DのDAEクラスでオブジェクトを読んでみるテスト。
// モデルが重めでごめんなさい。
// ロードが完了するまで少しまってね。

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import org.papervision3d.objects.parsers.DAE;
	import org.papervision3d.view.BasicView;

	public class Flipper_for_wonderfl extends Sprite
	{
		public var view:BasicView = new BasicView(465,465);
		public var dae:DAE = new DAE();
		
		public function Flipper_for_wonderfl()
		{
			this.addChild(view);
			
			dae.load("http://labs.logosware.com/flash/yamada/flipper3d/flipper_export.dae");
			view.scene.addChild(dae);
			
			stage.addEventListener(Event.ENTER_FRAME, _enterFrameHandle);
			
			stage.addEventListener(MouseEvent.MOUSE_DOWN, _onStageMouseDown);
		 	stage.addEventListener(MouseEvent.MOUSE_UP, _onStageMouseUp);
		 	stage.addEventListener(MouseEvent.MOUSE_WHEEL, _onMouseWheel);
		}
		
		//レンダリング
		private function _enterFrameHandle(e:Event):void{
			dae.rotationY += 5;
			view.startRendering();
		}
		 
		 private  var _startMouseX:Number = 0;
		 private  var _startRotationY:Number = 0;
		 
		 private  var _startMouseY:Number = 0;
		 private  var _startCameraY:Number = 0;
		 
		 //Stage上でのマウスダウン
		 private function _onStageMouseDown(e:MouseEvent):void{
		 	_startMouseX = this.mouseX;
		 	_startRotationY = dae.rotationY;
		 	
		 	_startMouseY = this.mouseY;
		 	_startCameraY = view.camera.y;
		 	
		 	this.stage.addEventListener(MouseEvent.MOUSE_MOVE, _onStageMouseMove);
		 }
		 
		 //Stage上でのマウスアップ
		 private function _onStageMouseUp(e:MouseEvent):void{
		 	this.stage.removeEventListener(MouseEvent.MOUSE_MOVE, _onStageMouseMove);
		 }
		 
		 //視点移動中のマウスムーブ
		 private function _onStageMouseMove(e:MouseEvent):void{
		 	var xValue:Number;
		 	var yValue:Number;
		 	var zValue:Number;

		 	xValue = _startMouseX - this.mouseX;
		 	yValue = (_startMouseY - this.mouseY)*10;
		 		
			dae.rotationY = _startRotationY + xValue;
			view.camera.y = _startCameraY - yValue;
		 }
		 
		 //ホイール回したとき
		 private function _onMouseWheel(e:MouseEvent):void{
		 	view.camera.z += e.delta*40;
		 }
	}
}