Gizmos are temporary objects that are drawn in the scene for debugging or visualization purposes
They are automatically removed after a given duration and cached internally to reduce overhead.
Use the static methods of this class to draw gizmos in the scene.

Properties

enabled: boolean = true

Allow creating gizmos
If disabled then no gizmos will be added to the scene anymore

Methods

  • Draw an arrow gizmo in the scene

    Parameters

    • pt0: Vec3

      the start point of the arrow in world space

    • pt1: Vec3

      the end point of the arrow in world space

    • color: ColorRepresentation = defaultColor

      the color of the arrow

    • duration: number = 0

      the duration in seconds the arrow will be rendered. If 0 it will be rendered for one frame

    • depthTest: boolean = true

      if true the arrow will be rendered with depth test

    • wireframe: boolean = false

      if true the arrow will be rendered as wireframe

    Returns void

  • Draw a 2D circle gizmo in the scene

    Parameters

    • pt0: Vec3

      the center of the circle in world space

    • normal: Vec3

      the normal of the circle in world space

    • radius: number

      the radius of the circle in world space

    • color: ColorRepresentation = defaultColor

      the color of the circle

    • duration: number = 0

      the duration in seconds the circle will be rendered. If 0 it will be rendered for one frame

    • depthTest: boolean = true

      if true the circle will be rendered with depth test

    Returns void

  • Draw a line gizmo in the scene

    Parameters

    • pt: Vec3
    • direction: Vec3 | Vec4
    • color: ColorRepresentation = defaultColor

      the color of the line

    • duration: number = 0

      the duration in seconds the line will be rendered. If 0 it will be rendered for one frame

    • depthTest: boolean = true

      if true the line will be rendered with depth test

    • lengthFactor: number = 1

      the length of the line. Default is 1

    Returns void

  • Draw a label in the scene or attached to an object (if a parent is provided)

    Parameters

    • position: Vec3

      the position of the label in world space

    • text: string

      the text of the label

    • size: number = .05

      the size of the label in world space

    • duration: number = 0

      the duration in seconds the label will be rendered. If 0 it will be rendered for one frame

    • Optionalcolor: ColorRepresentation

      the color of the label

    • OptionalbackgroundColor: ColorRepresentation | ColorWithAlpha

      the background color of the label

    • Optionalparent: Object3D<Object3DEventMap>

      the parent object to attach the label to. If no parent is provided the label will be attached to the scene

    Returns null | LabelHandle

    a handle to the label that can be used to update the text

  • Draw a line gizmo in the scene

    Parameters

    • pt0: Vec3

      the start point of the line in world space

    • pt1: Vec3

      the end point of the line in world space

    • color: ColorRepresentation = defaultColor

      the color of the line

    • duration: number = 0

      the duration in seconds the line will be rendered. If 0 it will be rendered for one frame

    • depthTest: boolean = true

      if true the line will be rendered with depth test

    Returns void

  • Draw a ray gizmo in the scene

    Parameters

    • origin: Vec3

      the origin of the ray in world space

    • dir: Vec3

      the direction of the ray in world space

    • color: ColorRepresentation = defaultColor

      the color of the ray

    • duration: number = 0

      the duration in seconds the ray will be rendered. If 0 it will be rendered for one frame

    • depthTest: boolean = true

      if true the ray will be rendered with depth test

    Returns void

  • Draw a 3D sphere gizmo in the scene

    Parameters

    • center: Vec3

      the center of the sphere in world space

    • radius: number

      the radius of the sphere in world space

    • color: ColorRepresentation = defaultColor

      the color of the sphere

    • duration: number = 0

      the duration in seconds the sphere will be rendered. If 0 it will be rendered for one frame

    • depthTest: boolean = true

      if true the sphere will be rendered with depth test

    Returns void

  • Draw a 3D wiremesh box gizmo in the scene

    Parameters

    • center: Vec3

      the center of the box in world space

    • size: Vec3

      the size of the box in world space

    • color: ColorRepresentation = defaultColor

      the color of the box

    • duration: number = 0

      the duration in seconds the box will be rendered. If 0 it will be rendered for one frame

    • depthTest: boolean = true

      if true the box will be rendered with depth test

    Returns void

  • Draw a 3D wiremesh box gizmo in the scene

    Parameters

    • box: Box3

      the box in world space

    • color: ColorRepresentation = defaultColor

      the color of the box

    • duration: number = 0

      the duration in seconds the box will be rendered. If 0 it will be rendered for one frame

    • depthTest: boolean = true

      if true the box will be rendered with depth test

    Returns void

  • Render a wireframe mesh in the scene. The mesh will be removed after the given duration (if duration is 0 it will be rendered for one frame).
    If a mesh object is provided then the mesh's matrixWorld and geometry will be used. Otherwise, the provided matrix and geometry will be used.

    Parameters

    • options: {
          color?: ColorRepresentation | undefined;
          depthTest?: boolean;
          duration?: number;
      } & ({ mesh: Mesh } | { geometry: BufferGeometry; matrix: Matrix4 })

      the options for the wire mesh

      • Optionalcolor?: ColorRepresentation | undefined

        the color of the wire mesh

      • OptionaldepthTest?: boolean

        if true the wire mesh will be rendered with depth test

      • Optionalduration?: number

        the duration in seconds the mesh will be rendered. If 0 it will be rendered for one frame

      • { mesh: Mesh }
        • mesh: Mesh

          the mesh object to render (if it is provided the matrix and geometry will be used)

      • { geometry: BufferGeometry; matrix: Matrix4 }
        • geometry: BufferGeometry

          the geometry of the mesh to render

        • matrix: Matrix4

          the matrix of the mesh to render

    Returns void

    Gizmos.DrawWireMesh({ duration: 1, color: 0xff0000, mesh: myMesh });
    
  • Draw a 3D wiremesh sphere gizmo in the scene

    Parameters

    • center: Vec3

      the center of the sphere in world space

    • radius: number

      the radius of the sphere in world space

    • color: ColorRepresentation = defaultColor

      the color of the sphere

    • duration: number = 0

      the duration in seconds the sphere will be rendered. If 0 it will be rendered for one frame

    • depthTest: boolean = true

      if true the sphere will be rendered with depth test

    Returns void

  • Returns true if a given object is a gizmo

    Parameters

    Returns boolean

  • Set visibility of all currently rendered gizmos

    Parameters

    • visible: boolean

    Returns void