Select Page

UPDATE 29/09/09: This technique is possibly no longer valid with the latest version of Papervision3D.


Dragging in Papervision example

Here is a small example I put together quickly today to demonstrate how to drag in 3D using Papervision and the InteractiveUtils.getMapCoordAtPointDO3D function.
Since my last post on this in December last year, the Papervision getMapCoordAtPointDO3D method returned object’s x and y values seemed to have changed by a factor of 36.

UPDATE 29/09/09: This technique is possibly no longer valid with the latest version of Papervision3D.

private function _updateDrag(e:Event):void 
{
    // get the update position on the plane
    var obj:Object = InteractiveUtils.getMapCoordAtPointDO3D(_selectedPlane, 
                                        _selectedPlane.container.mouseX, 
                                        _selectedPlane.container.mouseY)
    // move the dragged plane to the new postion with the offset                
    _selectedPlane.x = _selectedPlane.x + obj.x * 36 - _drag_X_offset;
    _selectedPlane.y = _selectedPlane.y - obj.y * 36  + _drag_Y_offset;
}

Click here to see it in action.

The source files can be downloaded here.