Editor Tool Utilities – Gizmo
Utility module for managing the editor axis gizmo (translate/rotate) for spline-editing tools. Handles drag callbacks, undo/redo integration, and local/world alignment switching.
Utility module for managing the editor axis gizmo (translate/rotate) for spline-editing tools. Handles drag callbacks, undo/redo integration, and local/world alignment switching.
Public API
| Function | Signature | Description |
|---|---|---|
M.handleGizmo | (isRotEnabled, selectedSplineIdx, selectedNodeIdx, splinesIn, isConformToTerrain, isRigid, deepCopyFn, undoFn, redoFn) | Main gizmo handler: sets up transform, draws gizmo, handles drag begin/end/during, locks axes as needed |
Code Examples
local gizmo = require('editor/toolUtilities/gizmo')
-- Handle the gizmo for the selected spline node
-- isRotEnabled: allow rotation around the tangent axis
-- isConformToTerrain: lock Z translation when conforming to terrain
-- isRigid: translate all nodes together (rigid body mode)
gizmo.handleGizmo(
true, -- rotation enabled
selectedSplineIdx, -- index of selected spline in array
selectedNodeIdx, -- index of selected node
splines, -- array of spline tables
true, -- conform to terrain (lock Z)
false, -- not rigid (individual node drag)
deepCopySpline, -- function to deep copy a spline
undoCallback, -- undo callback
redoCallback -- redo callback
)
-- The gizmo automatically:
-- 1. Computes local transform from node position and tangent
-- 2. Locks rotation to tangent-only (Y axis) when rotation is enabled
-- 3. Locks Z translation when conforming to terrain
-- 4. Commits undo/redo actions on drag end
-- 5. Forces local alignment for rotation, world for translation
-- Rigid translation mode moves ALL nodes by the same delta
gizmo.handleGizmo(false, sIdx, nIdx, splines, false, true, copyFn, undoFn, redoFn)
-- Rotation mode: adjusts spline normals (banking/twist)
-- The gizmo extracts the up vector from the rotation quaternion
-- and writes it back to spline.nmls[nodeIdx]See Also
- Tool Utilities - Fit Polyline - Related reference
- Editor Tool Utilities – Geometry - Related reference
- Editor Tool Utilities – Material Selection Manager - Related reference
- World Editor Guide - Guide
Editor Tool Utilities – Geometry
Comprehensive geometry utility library for spline-editing tools. Provides Catmull-Rom interpolation, Frenet frame computation, mouse-hit detection, vector math, polygon operations, and spline manipula
Editor Tool Utilities – Material Selection Manager
Utility for selecting materials with image thumbnails and a search bar. Used across road/decal tools to pick terrain or decal materials.