はちゅね マウスでうごくじょ
モデリング:ズサさん
参考サイト:http://blog.r3c7.net/?p=121
感謝
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.StageQuality;//ステージ設定
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.view.BasicView;
public class Main extends BasicView
{
public var view:BasicView = new BasicView(465,465);
public var dae:DAE = new DAE();
public function Main()
{
stage.quality = StageQuality.HIGH;//ステージ設定
dae.load("http://www.zacc.sakura.ne.jp/wonderfl/negimiku.dae");
dae.rotationY = 180;
scene.addChild(dae);
startRendering();//レンダリング
camera.z = 50;
//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 += 2;}
private var _startMouseX:Number = 0;
private var _startRotationY:Number = 0;
private var _startMouseY:Number = 0;
private var _startCameraY:Number = 0;
private function _onStageMouseDown(e:MouseEvent):void{//Stage上でのマウスダウン
_startMouseX = this.mouseX;
_startRotationY = dae.rotationY;
_startMouseY = this.mouseY;
_startCameraY = camera.y;
this.stage.addEventListener(MouseEvent.MOUSE_MOVE, _onStageMouseMove);
}
private function _onStageMouseUp(e:MouseEvent):void{//Stage上でのマウスアップ
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;
camera.y = _startCameraY - yValue;
}
private function _onMouseWheel(e:MouseEvent):void{//ホイール回したとき
camera.z += e.delta*20;
}
}
}