Lets a TransformControls move a bound mesh: while the gizmo drags
bound.object, its pose is sent to scene.drag(bound.mesh), and the drag
is ended (one undo step) when the gizmo lets go. Returns a function that
detaches it (ending a drag in progress first).
Pose and placement: bound.object.matrix is the scene mesh's
matrix4 = placement · translate(origin), so with placement (R, t) the
object's quaternion is R and its position is R · origin + t. A pose is
therefore sent as { rotation: quaternion, translation: position − R · origin },
all in f64. The origin (fixed for the mesh) comes from the placement and
matrix at the start of each drag: origin = Rᵀ (m − t), with m the
matrix's translation column.
Placements are rigid: TransformControls' scale mode has no effect (the
object's scale is kept at 1). The object must be a direct child of an
untransformed parent (its matrix is a world matrix), as for bindMesh;
a transformed ancestor is detected and warned about once.
The object's position, quaternion and scale are kept in step with its
matrix (TransformControls reads them when a drag starts), so call this
after bindMesh and before the gizmo grabs the object. While the gizmo
drags, the object's matrix follows the gizmo, not the change stream (the
scene lags by up to a frame); once the drag ends, the final placement is
applied. When the drag is ended by the scene instead (undo() while
dragging, for example), the object follows the scene again and the rest
of the gesture is ignored. When the mesh is removed, the drag ends
(no step is left open) and the attachment goes idle. A gesture that
cannot start a drag (another drag is active) is ignored with a warning.
Lets a TransformControls move a bound mesh: while the gizmo drags
bound.object, its pose is sent toscene.drag(bound.mesh), and the drag is ended (one undo step) when the gizmo lets go. Returns a function that detaches it (ending a drag in progress first).Pose and placement:
bound.object.matrixis the scene mesh'smatrix4 = placement · translate(origin), so with placement(R, t)the object's quaternion isRand its position isR · origin + t. A pose is therefore sent as{ rotation: quaternion, translation: position − R · origin }, all in f64. The origin (fixed for the mesh) comes from the placement and matrix at the start of each drag:origin = Rᵀ (m − t), withmthe matrix's translation column.Placements are rigid: TransformControls' scale mode has no effect (the object's scale is kept at 1). The object must be a direct child of an untransformed parent (its matrix is a world matrix), as for
bindMesh; a transformed ancestor is detected and warned about once.The object's
position,quaternionandscaleare kept in step with its matrix (TransformControls reads them when a drag starts), so call this afterbindMeshand before the gizmo grabs the object. While the gizmo drags, the object's matrix follows the gizmo, not the change stream (the scene lags by up to a frame); once the drag ends, the final placement is applied. When the drag is ended by the scene instead (undo()while dragging, for example), the object follows the scene again and the rest of the gesture is ignored. When the mesh is removed, the drag ends (no step is left open) and the attachment goes idle. A gesture that cannot start a drag (another drag is active) is ignored with a warning.