WindowCommand

View source

ExtendsCommand

Queues a deferred WindowRequest for a window entity.

The command stores the target entity, request kind, and request-specific payload without resolving a canvas or changing the Window component. WindowCommand#execute later looks up the canvas through Windows and applies the request. A WindowCommands builder normally creates and queues this command for the selected entity.

Examples

import { CommandQueue } from '@wimaengine/command'
import { Vector2 } from '@wimaengine/math'
import { WindowCommand, WindowRequest } from '@wimaengine/window'

world.getResource(CommandQueue).add(
  new WindowCommand(entity, WindowRequest.Resize, new Vector2(1280, 720))
)

Constructor


constructor(entity: EntityHandle, type: number, data: any)

View source

Creates a deferred window-request command.

This stores the target, operation, and payload without resolving a canvas or changing the target window. The command queue later calls WindowCommand#execute with a world to apply the request.

Parameters

NameDescriptionDefault
entity

Entity whose window receives the request.

—
type

Operation to apply when executed.

—
data

Payload required by the selected operation.

—

Properties


Methods


execute(world: World): void

View source

Applies the queued request to the target window.

This resolves the target canvas from Windows and reads the matching Window component only after a canvas is found. Without a registered canvas, this returns without applying anything.

WindowRequest.Resize is a no-op when the component dimensions already match the requested x and y. Otherwise, it writes those values to the canvas backing and CSS dimensions, reads the canvas’s bounding rectangle, and stores the rounded non-zero rectangle size—or the backing size when a rectangle dimension is zero—on both the canvas and Window. WindowRequest.Reposition assigns x to canvas.style.right and y to canvas.style.left. Pointer capture and release use data.id; fullscreen and pointer lock call the corresponding canvas APIs. An unknown request logs an error.

Parameters

NameDescriptionDefault
world

World used to resolve the target canvas and Window component.

—