Gizmo2DPlugin

View source

ExtendsPlugin

Provides a labelled Gizmo2D resource for immediate-mode 2D debug drawing in an App.

The required label constructor identifies the resource. Use the same label when retrieving it from the world; different labels provide separate gizmo resources. The optional GizmoSettings instance controls line width, caps, joins, style, and dash offset. When it is omitted, the plugin creates the default settings.

When a window provides a 2D canvas, buffered line segments and strips are drawn with these settings and cleared after a successful draw. If no usable window, canvas, or 2D context is available, the buffered drawing data stays in the resource.

The app must provide CorePlugin, ReflectPlugin, ColorPlugin, MathPlugin, and WindowPlugin before this plugin. These dependencies are not installed automatically.

Examples

import { App } from '@wimaengine/app'
import { ColorPlugin } from '@wimaengine/color'
import { CorePlugin } from '@wimaengine/core'
import { Gizmo2DPlugin } from '@wimaengine/gizmo'
import { MathPlugin } from '@wimaengine/math'
import { ReflectPlugin } from '@wimaengine/reflect'
import { WindowPlugin } from '@wimaengine/window'

class DebugGizmo {}

new App()
  .registerPlugin(new ReflectPlugin())
  .registerPlugin(new CorePlugin())
  .registerPlugin(new ColorPlugin())
  .registerPlugin(new MathPlugin())
  .registerPlugin(new WindowPlugin())
  .registerPlugin(new Gizmo2DPlugin({ label: DebugGizmo }))
  .run()

Constructor


constructor<T>(param0: Gizmo2DPluginSettings<T>)

View source

Creates a 2D gizmo plugin for a labelled Gizmo2D resource.

label is required and identifies the resource. settings is optional and defaults to a new GizmoSettings; pass a shared settings instance when the app needs a specific line width, cap, join, style, or dash offset.

Type Parameters

T

Parameters

NameDescriptionDefault
param0

Generic resource label and draw settings.

—

Properties


readonlylabel: Constructor<T>

View source

Constructor used to identify the typed Gizmo2D resource and this plugin’s generic identity. Use the same constructor when retrieving the resource; different constructors provide separate gizmo resources.

readonlysettings: GizmoSettings

View source

Drawing settings used by the labelled Gizmo2D resource. They control line width, caps, joins, style, and dash offset.

Methods


register(app: App): void

View source

Installs the labelled Gizmo2D resource in the app.

The resource uses this plugin’s label and settings. When a usable 2D canvas is available, buffered line segments and strips are drawn with these settings and cleared after a successful draw. Without a usable window, canvas, or 2D context, the buffered drawing data remains available in the resource.

Parameters

NameDescriptionDefault
app

App to configure.

—

name(): TypeId

View source

Returns this plugin’s identity used by PluginRegistry.

The default implementation returns typeid(this.constructor). Override it when a plugin has multiple valid instances that need distinct identities, such as a generic plugin keyed by a configured constructor. The returned ID is checked when App#registerPlugin adds the plugin; registering a duplicate ID throws instead of replacing the existing instance.

Returns

Plugin identity used for duplicate detection and dependency lookup.