UNPKG

@tolokoban/tgd

Version:

ToloGameDev library for WebGL2

68 lines 2.48 kB
import { TgdPainter } from "../painter"; import { TgdTransfo, TgdTransfoOptions } from "../../math/transfo"; import { TgdInterfaceTransformablePainter } from "../../interface"; export interface TgdPainterNodeOptions { name?: string; transfo: TgdTransfo | Partial<TgdTransfoOptions>; children: TgdPainterNodeChild[]; /** * Do we call the `paint()` method of the targets? * Default to `true`. */ paintTheTargets?: boolean; logic(this: TgdPainterNode, time: number, delay: number): void; } export type TgdPainterNodeChild = TgdPainterNode | TgdInterfaceTransformablePainter; /** * 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; logic?: ((time: number, delay: number) => void) | undefined; private readonly parentMatrix; /** * globalMatrix = parentMatrix * transfo */ private readonly globalMatrix; private readonly nodes; private readonly targets; private readonly paintTheTargets; constructor(options?: Partial<TgdPainterNodeOptions>); delete(): void; add(...children: TgdPainterNodeChild[]): this; remove(...children: TgdPainterNodeChild[]): this; getNodes(): TgdPainterNode[]; getTargets(): TgdInterfaceTransformablePainter[]; paint(time: number, delay: number): void; debug(caption?: string): void; } //# sourceMappingURL=node.d.ts.map