Description:
Drag is an open source project showing the mathematics behind dragging an object in a 3D environment. When
holding your cursor on an axis from the cube entity, the following happens:
- A vector Vinit is created with the direction from the camera to the intersection from the raycast
from the
camera to the cursor.
- From this vector, a plane is created using, as a normal, one of the two vectors normal to the one being
dragged. If you choose to drag the vector right, the vector used as a normal for the plane
will either be top or front. The vector which has the lowest angle with
Vinit is chosen. It ensures that the plane will morelikely face the camera.
- The scene displays a plane with the color of the normal vector. The plane is used as a surface to
interesect with the raycast from the camera to your cursor when moving your cursor around. The result of
the intersection is a yellow sphere, following your cursor within the plane.
- The final step is to project the intersection on the dragged axis and change the position according to
the distance from the initial dragged. The result of the projection is a sphere of the color of the
dragged axis.
Todo:
- Rotation of the cube.
- Dragging along a plane.
- Dragging from the root.