Gizmo3D

View source

Provides a labelled world resource for immediate-mode three-dimensional debug drawing.

The generic label is part of the resource’s type ID, so use the same constructor when retrieving it; different labels produce separate gizmo resources. The constructor is exposed as Gizmo3D#type for code that needs to inspect the label.

The resource owns a three-dimensional affine transform, collects vector positions and colors in Gizmo3D#buffer, and exposes Gizmo3D#settings for line settings. Use Gizmo3D#reset to restore the transform to identity. Unlike Gizmo2D, this class currently has no 3D primitive helpers; a 3D-capable integration can consume or append the public buffer. The current canvas-2D drawing path cannot render 3D geometry and clears this buffer every time it runs.

Examples

import { Gizmo3D } from '@wimaengine/gizmo'
import { typeidGeneric } from '@wimaengine/type'

class PhysicsDebug {}

function preparePhysicsDebug(world) {
  const gizmo = world.getResourceByTypeId(
    typeidGeneric(Gizmo3D, [PhysicsDebug])
  )

  gizmo.reset()
  // A 3D-capable integration can read or append gizmo.buffer here.
}

Constructor


Properties


Methods


reset(): void

View source

Resets the drawing transform to the affine identity.

The current Gizmo3D#buffer contents and Gizmo3D#settings are preserved. This method mutates the transform and returns undefined.