UNPKG

@tolokoban/tgd

Version:

ToloGameDev library for WebGL2

55 lines 2.02 kB
import { TgdPainter } from "../painter"; import { TgdTransfo, TgdTransfoOptions } from "../../math/transfo"; import { TgdInterfaceTransformablePainter } from "../../interface"; export interface TgdPainterNodeOptions { transfo: TgdTransfo | Partial<TgdTransfoOptions>; target: TgdInterfaceTransformablePainter; children: TgdPainterNode[]; logic(time: number, delay: number): void; } /** * A Node can hold others Nodes or any object providing the * TgdPainterNodeChild interface. * * Each Node is a local space for its children. * * All objects implementing `TgdInterfaceTransformable` have a `transfo` attribute * that controls its position/orientation/scale in the world coordinate system. If * you need an object's transformation to be defined in another object coordinate * system, you just have to wrap it in a `TgdPainterNode`. * * As long as a `Transformable` is hold by the `painter` attribute of a `TgdPainterNode`, * it will be controlled by the node. * That means, you should not use its `transfo` attribute because it will be * overwritten by the node. * * @example * ``` * const body = new TgdPainterNode({ * target: new TgdPainterMesh(context) * }) * const leftArm = new TgdPainterNode({ * transfo: { poition: [1, 0, 0] }, * target: new TgdPainterMesh(context) * }) * const rightArm = new TgdPainterNode({ * transfo: { poition: [-1, 0, 0] }, * target: new TgdPainterMesh(context) * }) * body.add( leftArm, rightArm ) * ``` */ export declare class TgdPainterNode extends TgdPainter { readonly transfo: TgdTransfo; target: TgdInterfaceTransformablePainter | null; private readonly parentMatrix; private readonly globalMatrix; private readonly children; private readonly logic?; constructor(options?: Partial<TgdPainterNodeOptions>); delete(): void; add(...children: TgdPainterNode[]): this; remove(...children: TgdPainterNode[]): void; paint(time: number, delay: number): void; } //# sourceMappingURL=node.d.ts.map