EditorNode3DGizmo
Gizmo for editing Node3D
objects.
class EditorNode3DGizmo
Gizmo that is used for providing custom visualization and editing (handles and subgizmos) for Node3D
objects. Can be overridden to create custom gizmos, but for simple gizmos creating a EditorNode3DGizmoPlugin
is usually recommended.
Superclasses
class Node3DGizmo
Abstract class to expose editor gizmos for
Node3D
.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
func addCollisionSegments(PackedVector3Array
) Adds the specified
segments
to the gizmo’s collision shape for picking. Call this method during_redraw
.func addCollisionTriangles(TriangleMesh?
) Adds collision triangles to the gizmo for picking. A
TriangleMesh
can be generated from a regularMesh
too. Call this method during_redraw
.func addHandles(PackedVector3Array, material: Material?, ids: PackedInt32Array, billboard: Bool, secondary: Bool
) Adds a list of handles (points) which can be used to edit the properties of the gizmo’s
Node3D
. Theids
argument can be used to specify a custom identifier for each handle, if an empty array is passed, the ids will be assigned automatically from thehandles
argument order.func addLines(PackedVector3Array, material: Material?, billboard: Bool, modulate: Color
) Adds lines to the gizmo (as sets of 2 points), with a given material. The lines are used for visualizing the gizmo. Call this method during
_redraw
.func addMesh(Mesh?, material: Material?, transform: Transform3D, skeleton: SkinReference?
) Adds a mesh to the gizmo with the specified
material
, localtransform
andskeleton
. Call this method during_redraw
.func addUnscaledBillboard(material: Material?, defaultScale: Double, modulate: Color
) Adds an unscaled billboard for visualization and selection. Call this method during
_redraw
.func clear(
) Removes everything in the gizmo including meshes, collisions and handles.
func getNode3d(
) -> Node3D? Returns the
Node3D
node associated with this gizmo.func getPlugin(
) -> EditorNode3DGizmoPlugin? Returns the
EditorNode3DGizmoPlugin
that owns this gizmo. It’s useful to retrieve materials usinggetMaterial(name:gizmo:)
.func getSubgizmoSelection(
) -> PackedInt32Array Returns a list of the currently selected subgizmos. Can be used to highlight selected elements during
_redraw
.func isSubgizmoSelected(id: Int32
) -> Bool Returns
true
if the given subgizmo is currently selected. Can be used to highlight selected elements during_redraw
.func setHidden(Bool
) Sets the gizmo’s hidden state. If
true
, the gizmo will be hidden. Iffalse
, it will be shown.func setNode3d(node: Node?
) Sets the reference
Node3D
node for the gizmo.node
must inherit fromNode3D
.
Show implementation details (11)
Hide implementation details
func _commitHandle(id: Int32, secondary: Bool, restore: Variant, cancel: Bool
) Override this method to commit a handle being edited (handles must have been previously added by
addHandles(_:material:ids:billboard:secondary:)
). This usually means creating anUndoRedo
action for the change, using the current handle value as “do” and therestore
argument as “undo”.func _commitSubgizmos(ids: PackedInt32Array, restores: VariantCollection<Transform3D>, cancel: Bool
) Override this method to commit a group of subgizmos being edited (see
_subgizmosIntersectRay(camera:point:)
and_subgizmosIntersectFrustum(camera:frustum:)
). This usually means creating anUndoRedo
action for the change, using the current transforms as “do” and therestores
transforms as “undo”.func _getHandleName(id: Int32, secondary: Bool
) -> String Override this method to return the name of an edited handle (handles must have been previously added by
addHandles(_:material:ids:billboard:secondary:)
). Handles can be named for reference to the user when editing.func _getHandleValue(id: Int32, secondary: Bool
) -> Variant Override this method to return the current value of a handle. This value will be requested at the start of an edit and used as the
restore
argument in_commitHandle(id:secondary:restore:cancel:)
.func _getSubgizmoTransform(id: Int32
) -> Transform3D Override this method to return the current transform of a subgizmo. This transform will be requested at the start of an edit and used as the
restore
argument in_commitSubgizmos(ids:restores:cancel:)
.func _isHandleHighlighted(id: Int32, secondary: Bool
) -> Bool Override this method to return
true
whenever the given handle should be highlighted in the editor.func _redraw(
) Override this method to add all the gizmo elements whenever a gizmo update is requested. It’s common to call
clear
at the beginning of this method and then add visual elements depending on the node’s properties.func _setHandle(id: Int32, secondary: Bool, camera: Camera3D?, point: Vector2
) Override this method to update the node properties when the user drags a gizmo handle (previously added with
addHandles(_:material:ids:billboard:secondary:)
). The providedpoint
is the mouse position in screen coordinates and thecamera
can be used to convert it to raycasts.func _setSubgizmoTransform(id: Int32, transform: Transform3D
) Override this method to update the node properties during subgizmo editing (see
_subgizmosIntersectRay(camera:point:)
and_subgizmosIntersectFrustum(camera:frustum:)
). Thetransform
is given in theNode3D
’s local coordinate system.func _subgizmosIntersectFrustum(camera: Camera3D?, frustum: VariantCollection<Plane>
) -> PackedInt32Array Override this method to allow selecting subgizmos using mouse drag box selection. Given a
camera
and afrustum
, this method should return which subgizmos are contained within the frustum. Thefrustum
argument consists of an array with all thePlane
s that make up the selection frustum. The returned value should contain a list of unique subgizmo identifiers, which can have any non-negative value and will be used in other virtual methods like_getSubgizmoTransform(id:)
or_commitSubgizmos(ids:restores:cancel:)
.func _subgizmosIntersectRay(camera: Camera3D?, point: Vector2
) -> Int32 Override this method to allow selecting subgizmos using mouse clicks. Given a
camera
and apoint
in screen coordinates, this method should return which subgizmo should be selected. The returned value should be a unique subgizmo identifier, which can have any non-negative value and will be used in other virtual methods like_getSubgizmoTransform(id:)
or_commitSubgizmos(ids:restores:cancel:)
.