@tolokoban/tgd
Version:
ToloGameDev library for WebGL2
69 lines • 2.6 kB
TypeScript
import { TgdInterfaceTransformable, type TgdInterfaceTransformablePainter } from "../../interface";
import { TgdTransfo, type TgdTransfoOptions } from "../../math/transfo";
import { type TgdDebugPainterHierarchy, TgdPainter } from "../painter";
import { TgdPainterGroup } from "../group";
import { TgdPainterFunction } from "../../types/painter";
export interface TgdPainterNodeOptions {
name?: string;
transfo: TgdTransfo | Partial<TgdTransfoOptions>;
children: (TgdPainter | TgdPainterFunction)[];
/**
* Do we call the `paint()` method of the targets?
* Default to `true`.
*/
paintTheTargets?: boolean;
logic(this: TgdPainterNode, time: number, delta: 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 TgdPainterGroup {
readonly transfo: TgdTransfo;
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(...painters: (TgdPainter | TgdPainterFunction | TgdInterfaceTransformable)[]): this;
remove(...painters: TgdPainter[]): this;
getNodes(): TgdPainterNode[];
getTargets(): TgdInterfaceTransformablePainter[];
paint(time: number, delta: number): void;
debug(caption?: string): void;
get hierarchy(): TgdDebugPainterHierarchy;
}
//# sourceMappingURL=node.d.ts.map