Skip to main content
Version: 0.11.0

UeTransformControls

The UeTransformControls class allows objects to be transformed (moved, rotated, scaled) using a visual gizmo.
It provides an interactive way for users to manipulate 3D objects in the scene.

Constructor​

new UeTransformControls(camera, data = {})

Data parameters​

KeyTypeDefaultDescription
viewnumber0The GameMaker view index to use for projections
onDragStartfunctionundefinedCallback fired when dragging begins
onDragfunctionundefinedCallback fired every frame while dragging
onDragEndfunctionundefinedCallback fired when dragging stops
snapEnabledbooleanfalseWhether grid snapping is enabled by default
snapSizenumber10The default snapping increment

Properties​

PropertyTypeDescription
cameraUeCameraThe camera used for interaction
objectUeObject3DThe currently attached object
modestringCurrent mode: "move", "rotate", "scale"
spacestringTransformation space: "world" or "local"
sizenumberSize multiplier for the gizmo
enabledbooleanWhether the gizmo is active and visible
viewnumberThe GameMaker view index being used
draggingbooleanWhether the user is currently dragging the gizmo
hoveredAxisenumThe axis currently under the mouse (UE_GIZMO_AXIS)
selectedAxisenumThe axis currently being dragged (UE_GIZMO_AXIS)
lineWidthnumberThickness of gizmo lines in pixels (default: 3)
hitThresholdnumberPixel distance for mouse picking (default: 10)
axisLengthnumberLength of the axes in world units (default: 1.5)
snapEnabledbooleanWhether grid snapping is enabled
snapSizenumberCurrent grid snapping increment

Methods​

attach(object)

Attaches the controls to a 3D object.

detach()

Detaches the controls from the current object.

setMode(mode)

Sets the interaction mode.

  • mode: "move", "rotate", or "scale".
updateGizmo()

Updates the gizmo's internal state (matrices, position, scale). Useful for updating the gizmo's orientation without processing mouse interactions.

update()

The main update loop. Handles interaction logic (picking and dragging). Must be called in the Step event.

render()

Draws the gizmo. Must be called in the Draw GUI event.

Modes​

Move​

Allows translation along the X, Y, Z axes or the XY, XZ, YZ planes. In "local" space, axes align with the object's rotation.

Rotate​

Allows rotation around the X, Y, Z axes. Provides a screen-space rotation circle (outer ring).

Scale​

Allows scaling of the object.

  • Axes (Red, Green, Blue): Scale along specific local axes.
  • Planes: Scale along two axes simultaneously.
  • Center Cube: Uniform scaling on all axes.
    • Uniform scaling uses a visual "drag" distance logic for intuitive control.

Snapping​

UeTransformControls supports grid snapping for the Move mode (translation). When enabled, coordinates will be rounded to the nearest multiple of snapSize.

  • snapEnabled: Toggle snapping on/off.
  • snapSize: Set the increment for snapping (e.g., 10, 50, 100 world units).

In the editor, this can be toggled using the Grid Snap icon in the scene tools bar.

Callbacks​

The controls use callbacks provided in the data struct during initialization.

  • onDragStart: Fired when the user starts dragging a gizmo axis.
  • onDrag: Fired every frame while the gizmo is being dragged.
  • onDragEnd: Fired when the user releases the mouse button.

Usage Example​

// Create controls
var transformControls = new UeTransformControls(camera, {
view: 0,
onDrag: function() {
show_debug_message("Object is being transformed!");
}
});

// Attach to an object
transformControls.attach(myObject);

// Set mode
transformControls.setMode("move");

// In Step Event
transformControls.update();

// In Draw GUI Event
transformControls.render();