Sleepless

Object Gizmo

Call Options

Last updated on

Pass a table as the second argument of useGizmo to override config.lua for that edit only. Omitted keys keep the config value.

A number is shorthand for distanceLimit:

exports.object_gizmo:useGizmo(entity, 2.5)
exports.object_gizmo:useGizmo(entity, {
    camera = 'orbit',
    pivot = 'center',
    enableScale = true,
    distanceLimit = 4.0,
})

Editor

OptionTypeDescription
camera'gameplay' | 'orbit'Camera for this edit.
mode'translate' | 'rotate' | 'scale'Starting mode.
space'world' | 'local'relative is accepted and treated as local.
pivot'origin' | 'center'Where the handles sit. The returned position is always the entity origin.
enableScalebooleanAllow scale mode on this call.
enableRotatebooleanAllow rotate mode. Default true.
enableTranslatebooleanAllow translate mode. Default true.
gizmoSizenumberHandle size.
axes{ x, y, z }GTA axes. z = false hides the vertical handle. Missing axes stay visible.

Orbit

orbit is merged over Config.orbit. Set only the fields this call should change.

exports.object_gizmo:useGizmo(entity, {
    camera = 'orbit',
    orbit = {
        minRadius = 2.0,
        maxRadius = 8.0,
        zoomStep = 0.5,
    },
})
FieldTypeDescription
minRadiusnumberClosest orbit distance, in metres.
maxRadiusnumberFarthest orbit distance, in metres.
zoomStepnumberScroll step, in metres.
sensitivitynumberDrag sensitivity.
blendnumberCamera blend, in milliseconds.

Bounds

bounds keeps the entity origin inside a volume. The check is that zone's contains, so a rotated box and a poly thickness behave the same as they do elsewhere in ox_lib.

Pass a zone you already created:

local room = lib.zones.box({
    coords = vec3(100.0, 200.0, 30.0),
    size = vec3(4.0, 4.0, 3.0),
    rotation = 45,
})

exports.object_gizmo:useGizmo(entity, {
    bounds = room,
})

Or pass a definition. It uses the same fields as lib.zones.box, lib.zones.sphere, or lib.zones.poly, plus type. The temporary zone is removed when the gizmo closes. A zone you created yourself is left in place.

exports.object_gizmo:useGizmo(entity, {
    bounds = {
        type = 'sphere',
        coords = GetEntityCoords(entity),
        radius = 3.0,
        debug = true,
    },
})
exports.object_gizmo:useGizmo(entity, {
    bounds = {
        type = 'poly',
        points = {
            vec3(100.0, 200.0, 30.0),
            vec3(104.0, 200.0, 30.0),
            vec3(104.0, 204.0, 30.0),
            vec3(100.0, 204.0, 30.0),
        },
        thickness = 4.0,
    },
})

debug = true on a definition draws the zone for the edit.

If the entity starts outside the zone, and the zone center is inside, the entity is pulled to the edge when the gizmo opens. Dragging past the edge stops on it. The prompt shows the limit. distanceLimit still applies, and the entity has to satisfy both.

Bounds constrain the entity origin, which is the position you get back. With pivot = 'center', the handles can stop before the zone edge by the distance from the origin to the model center.

Distance

OptionTypeDescription
distanceLimitnumberMax metres from origin. 0 or omitting it disables the limit.
originvector3Point the distance is measured from. Default is the entity position when the gizmo opens.

Highlight And Physics

OptionTypeDescription
outlinebooleanDraw the outline. Default true. Peds fade instead.
outlineColor{ r, g, b, a }Outline colour for this call.
outlineShadernumber0 hard edge, 1 softer edge.
pedAlphanumberPed alpha while editing.
freezeEntitybooleanFreeze the entity, then restore the previous freeze state.
freezePlayerbooleanFreeze the player ped.
disableCollisionbooleanDisable entity collision for the edit, then turn it back on.
playerCanMovebooleanAllow the player to walk while the gizmo is open.
requestControlbooleanRequest network control of a networked entity.

Controls And HUD

OptionTypeDescription
enableCancelbooleanEsc cancels and can restore the entity.
restoreOnCancelbooleanPut the entity back when the edit is cancelled. Default true.
snapToGroundbooleanShow ground snap.
enableSnapTogglebooleanShow the snap toggle.
snapbooleanStart with snap on. Matches Config.snapEnabled.
translationSnapnumberMetres while snap is on.
rotationSnapnumberDegrees while snap is on.
scaleSnapnumberScale step while snap is on.
enableCopybooleanShow the copy control.
promptsbooleanUse sleepless_prompts for this call when it is started. false forces text UI.
promptPositionstringPrompt slot for this call.
promptLayout'row' | 'column'Prompt layout for this call.
textUiPositionstringText UI position for this call.
showCoordsbooleanPrint position and rotation in the text UI.

onChange

Called while the entity is moving. confirmed is false until the player finishes. Errors in the callback are caught and do not close the gizmo.

exports.object_gizmo:useGizmo(entity, {
    onChange = function(update)
        print(update.position)
    end,
})

On this page