import { Color, Sprite, ColorRepresentation } from 'three/webgpu'; import { DIVEComponent } from '../../engine/component/Component.ts'; import { DIVENode } from '../../engine/node/Node.ts'; /** * A camera facing text label on a node. * * The text is rasterized to a canvas and applied to a sprite, so the label always * faces the camera while keeping a constant height in world units. `textHeight` * is that height, and the width follows from the rasterized aspect ratio. * * Where the label sits is the node's business, as with every component: position * the node, not the sprite. What belongs here is what the label *is* -- its text, * its height and its colour. * * Takes the owner's layer, so a caller decides what the label counts as by setting * it on the node before attaching. Layers gate only the object they are set on, so * the mask has to reach the sprite itself, which is what this does. * * @module */ export declare class SpriteTextComponent extends DIVEComponent { readonly isSpriteTextComponent: true; private _text; private _textHeight; private _color; private _canvas; private _texture; private _sprite; constructor(); /** The sprite the label is drawn on. */ get sprite(): Sprite; /** The text currently drawn. */ get text(): string; /** The label's height in world units. */ get textHeight(): number; /** The colour the text is rasterized in. */ get color(): Color; /** * @param text - What to write. */ setText(text: string): this; /** * @param textHeight - The label's height in world units. */ setTextHeight(textHeight: number): this; /** * @param color - The colour to rasterize the text in. */ setColor(color: ColorRepresentation): this; protected onAttach(owner: DIVENode): void; copy(source: this): this; dispose(): void; /** * Rasterizes the text to the canvas and scales the sprite to the resulting * aspect ratio, so the label's height matches its text height in world units. */ private _draw; }