DesignWebKit

Dragging in 3D: The Right Way

Here you can find some new functions that make dragging in 3D possible. More over, they are more elegant and have much greater use than simply for dragging, so make good use of them! The main function, which is essential to being able drag in 3D – is CameraObject3D.unproject: it unprojects coordinates. It takes 2D screen coordinates, and gives you back a vector in world space. In lay terms – this basically shoots a ray from the camera, through where the mouse is, into 3D space. You can then do whatever you want knowing where that ray is. The author used it in his demo to find where the ray hits a plane supposed to be dragging on. When you find the intersection of the unprojected ray with the plane – move the object there. It’s really that easy. And all this is built into Papervision3D for you. Great post from Andy Zupko’s collection of Papervision tuts.