用鼠标拖动Away3D网格

时间:2014-07-31 06:58:25

标签: actionscript-3 flash mouseevent away3d

您好我想用鼠标拖动一个away3d网格,但没有运气。 正如我所看到的,我需要将mouseX和MouseY转换为3d世界坐标 然而,这是我尝试过的,它不起作用。我还需要将它放入输入框架或定时器中。 请帮助:))

PlayerHandle = new Mesh(new CubeGeometry(200, 100, 5));
_view.scene.addChild(PlayerHandle);
PlayerHandle.mouseEnabled = true;
PlayerHandle.addEventListener(MouseEvent3D.MOUSE_MOVE, HandlePlayerHandler);

public function HandlePlayerHandler(me3d:MouseEvent3D):void
{
    PlayerHandle.x = me3d.scenePosition.x;  
}

public function UpdateScene(e:Event):void
{
   _view.render();
}

1 个答案:

答案 0 :(得分:0)

Away3D内置了类,

import away3d.tools.utils.Drag3D;

e.g。

private var _drag3D:Drag3D;
private var _sphere : Sphere;

//create sphere geometry here in a function
.
.
.
_drag3D = new Drag3D(_view, ObjectContainer3D(_sphere));

private function handleEnterFrame(e:Event) : void
{
  _drag3D.updateDrag();
   _view.render();
}

请参阅此Drag3DTest Class