glyphcss 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,313 @@
1
+ import { Vec3, Polygon, RenderMode } from '@glyphcss/core';
2
+
3
+ /**
4
+ * createGlyphPerspectiveCamera / createGlyphOrthographicCamera — vanilla camera
5
+ * factories for glyphcss.
6
+ *
7
+ * These mirror the asciss camera factories and provide a `GlyphCamera`
8
+ * handle with a `project()` method that maps world-space vertices to
9
+ * [col, row, depth] in character-cell grid space.
10
+ *
11
+ * Public names use the Glyph prefix per glyphcss naming convention.
12
+ * The internal camera algorithms are byte-identical to asciss's createCamera.ts.
13
+ *
14
+ * `createGlyphCamera` is the ergonomic default alias — it creates an
15
+ * orthographic camera, matching the voxel/iso identity of glyphcss.
16
+ */
17
+
18
+ interface GlyphCamera {
19
+ readonly kind: "perspective" | "orthographic";
20
+ rotX: number;
21
+ rotY: number;
22
+ /** Distance from origin along the view axis. Only meaningful for perspective cameras. */
23
+ distance: number;
24
+ /** Camera zoom — mesh size in the viewport (fraction of `min(cols, rows)`). */
25
+ zoom: number;
26
+ /** Extra horizontal stretch on top of `cellAspect`. */
27
+ stretch: number;
28
+ /**
29
+ * Camera target offset in world space — shifts the point the camera orbits around.
30
+ * Subtracted from world coords before projection so the mesh appears to pan without re-baking.
31
+ */
32
+ target: Vec3;
33
+ /**
34
+ * Eye-at-origin projection mode. When true, the perspective camera uses a
35
+ * first-person formulation: `target` is treated as the eye position and
36
+ * vertices behind the eye (`r[2] >= 0`) are NaN-culled. Toggled by
37
+ * `createGlyphFirstPersonControls` at attach / detach time.
38
+ */
39
+ eyeMode: boolean;
40
+ /** Project a world-space vector to `[col, row, depth]`. Same projection used by the renderer and the hit layer. */
41
+ project(v: Vec3, cols: number, rows: number, cellAspect: number): [number, number, number];
42
+ }
43
+ interface GlyphPerspectiveCameraOptions {
44
+ /** Y rotation (radians). The "spin" axis. Default 0. */
45
+ rotY?: number;
46
+ /** X rotation (radians). The "tilt" axis. Default 0. */
47
+ rotX?: number;
48
+ /**
49
+ * Perspective distance. Larger = flatter (less foreshortening); smaller =
50
+ * more dramatic. Default 3.
51
+ */
52
+ distance?: number;
53
+ /** Camera zoom — mesh size in the viewport (fraction of `min(cols, rows)`). Default 0.4. */
54
+ zoom?: number;
55
+ /**
56
+ * Extra horizontal scale on top of `cellAspect`. Use to counteract
57
+ * over-stretching when monospace cells are taller than wide. Default 1.0.
58
+ */
59
+ stretch?: number;
60
+ /** Center of projection in normalized grid coords. Default `[0.5, 0.5]`. */
61
+ center?: [number, number];
62
+ }
63
+ interface GlyphOrthographicCameraOptions {
64
+ rotY?: number;
65
+ rotX?: number;
66
+ zoom?: number;
67
+ center?: [number, number];
68
+ }
69
+ /** Handle alias — same surface as `GlyphCamera`, names matched to glyphcss. */
70
+ type GlyphPerspectiveCameraHandle = GlyphCamera;
71
+ /** Handle alias — same surface as `GlyphCamera`, names matched to glyphcss. */
72
+ type GlyphOrthographicCameraHandle = GlyphCamera;
73
+ declare function createGlyphPerspectiveCamera(opts?: GlyphPerspectiveCameraOptions): GlyphPerspectiveCameraHandle;
74
+ declare function createGlyphOrthographicCamera(opts?: GlyphOrthographicCameraOptions): GlyphOrthographicCameraHandle;
75
+ /**
76
+ * Default camera alias — orthographic projection. The voxel render mode and
77
+ * iso/diagrammatic scenes are glyphcss's differentiator; ortho is the more
78
+ * representative default.
79
+ */
80
+ declare const createGlyphCamera: typeof createGlyphOrthographicCamera;
81
+
82
+ /** Directional light — single distant source for the ASCII rasterizer. */
83
+ interface GlyphDirectionalLight {
84
+ direction: Vec3;
85
+ intensity?: number;
86
+ /** Hex color (#rrggbb). Tints the lit-side per-cell output. Default white. */
87
+ color?: string;
88
+ }
89
+ /** Ambient light — uniform fill regardless of orientation. */
90
+ interface GlyphAmbientLight {
91
+ intensity?: number;
92
+ /** Hex color (#rrggbb). Tints the unlit-side fill. Default white. */
93
+ color?: string;
94
+ }
95
+ interface GlyphMeshTransform {
96
+ /** String identifier for the mesh — surfaced as `GlyphMeshHandle.name`. */
97
+ id?: string;
98
+ position?: Vec3;
99
+ scale?: number | Vec3;
100
+ rotation?: Vec3;
101
+ }
102
+
103
+ /**
104
+ * createGlyphScene — imperative scene API. The vanilla counterpart to
105
+ * `<glyph-scene>` custom element.
106
+ *
107
+ * Mirrors glyphcss's `createPolyScene` architecturally:
108
+ * - Takes a host element + scene options, returns a `GlyphSceneHandle`.
109
+ * - `handle.add(polygons, transform?)` registers a mesh and returns a
110
+ * removable `GlyphMeshHandle`.
111
+ *
112
+ * DOM: injects `<div class="glyph-scene">` containing one `<pre>` (text
113
+ * output) and one `<div class="glyph-hotspot-layer">` (positioned overlay
114
+ * for hotspot dots).
115
+ *
116
+ * Paint backend: on each render, walks all registered meshes, applies each
117
+ * mesh's transform to its polygons in memory, builds a `RasterizeContext`,
118
+ * calls `rasterize`, and sets `<pre>.innerHTML` (or `.textContent` when
119
+ * `useColors` is false).
120
+ *
121
+ * Camera changes trigger a re-rasterize; scene-root transform is NOT a CSS
122
+ * matrix3d — the ASCII output bakes the camera rotation into the projected
123
+ * text every render.
124
+ */
125
+
126
+ interface GlyphSceneOptions {
127
+ /** Render mode: "wireframe" | "solid". Default "solid". */
128
+ mode?: RenderMode;
129
+ /** Named glyph palette. Defaults to "default". */
130
+ glyphPalette?: string;
131
+ /** Whether to emit color spans. Default true. */
132
+ useColors?: boolean;
133
+ /** Grid columns. Default 80. */
134
+ cols?: number;
135
+ /** Grid rows. Default 24. */
136
+ rows?: number;
137
+ /** Character cell aspect ratio (height/width). Default 2.0. */
138
+ cellAspect?: number;
139
+ directionalLight?: GlyphDirectionalLight;
140
+ ambientLight?: GlyphAmbientLight;
141
+ camera?: GlyphCamera;
142
+ /**
143
+ * Smooth (Gouraud) shading. When `true`, per-pixel Lambert intensity is
144
+ * interpolated from per-vertex normals averaged across adjacent polygons
145
+ * within `creaseAngle`. Adjacent triangles on a curved surface render
146
+ * without visible seams along their shared edges. Default `false` — the
147
+ * faceted ASCII look is part of glyph's identity, so smooth shading is
148
+ * opt-in. Turn it on for organic / curved-surface meshes (bread, sphere,
149
+ * character models) where polygon seams hurt the silhouette.
150
+ */
151
+ smoothShading?: boolean;
152
+ /**
153
+ * Crease angle in degrees. With smooth shading on, adjacent faces whose
154
+ * normals diverge by more than this angle stay flat-shaded at their shared
155
+ * edge (preserves hard corners on otherwise smooth meshes). `0` reproduces
156
+ * flat shading regardless of `smoothShading`; `180` smooths everything.
157
+ * Default `60`.
158
+ */
159
+ creaseAngle?: number;
160
+ /**
161
+ * Auto-size the character grid to fill the host element. When `true`, the
162
+ * scene measures one monospace character's pixel size from the live `<pre>`
163
+ * (using whatever font size the host inherits via CSS), computes `cols` and
164
+ * `rows` that fit the host's `clientWidth × clientHeight`, and re-fits on
165
+ * host resize via a `ResizeObserver`. Default `false` — fixed `cols`/`rows`
166
+ * (default 80×24) is the predictable choice for tests and SSR.
167
+ */
168
+ autoSize?: boolean;
169
+ }
170
+ interface GlyphHotspotOptions {
171
+ id: string;
172
+ at: Vec3;
173
+ size?: [number, number];
174
+ }
175
+ interface GlyphHotspotHandle {
176
+ remove(): void;
177
+ /** The absolutely-positioned overlay `<div>` in the hotspot layer. */
178
+ readonly el: HTMLElement;
179
+ }
180
+ interface GlyphMeshHandle {
181
+ readonly id: number;
182
+ /** String identifier supplied via the `id` prop / transform option. */
183
+ readonly name: string | undefined;
184
+ /** The raw polygons registered with this mesh. */
185
+ readonly polygons: Polygon[];
186
+ setTransform(transform: GlyphMeshTransform): void;
187
+ dispose(): void;
188
+ }
189
+ interface GlyphSceneHandle {
190
+ /** The host element passed to `createGlyphScene`. */
191
+ readonly host: HTMLElement;
192
+ /** The `<pre>` element for reading rendered text output. */
193
+ readonly output: HTMLPreElement;
194
+ /** The camera attached to this scene (mutate then call `rerender()`). */
195
+ readonly camera: GlyphCamera;
196
+ /**
197
+ * Register a polygon list as a mesh. Optionally supply a transform.
198
+ * Returns a handle to update or dispose the mesh.
199
+ */
200
+ add(polygons: Polygon[], transform?: GlyphMeshTransform): GlyphMeshHandle;
201
+ addHotspot(opts: GlyphHotspotOptions, onClick?: () => void): GlyphHotspotHandle;
202
+ /** Force an immediate re-rasterize. Normally called automatically on add/remove/setOptions. */
203
+ rerender(): void;
204
+ setOptions(opts: Partial<GlyphSceneOptions>): void;
205
+ getOptions(): GlyphSceneOptions;
206
+ /**
207
+ * Re-measure the host's character cell (font-size, line-height) and adapt
208
+ * `cols`/`rows`/`cellAspect`. Only meaningful when `autoSize` was enabled.
209
+ * Call when something outside the scene options changes the cell size —
210
+ * e.g., the consumer overrode `pre.style.lineHeight` directly. The internal
211
+ * `ResizeObserver` already handles host-size changes automatically.
212
+ */
213
+ fit(): void;
214
+ destroy(): void;
215
+ }
216
+ declare function createGlyphScene(host: HTMLElement, opts?: GlyphSceneOptions): GlyphSceneHandle;
217
+
218
+ /**
219
+ * `<glyph-scene>` custom element.
220
+ *
221
+ * Must be placed inside a `<glyph-perspective-camera>` or
222
+ * `<glyph-orthographic-camera>` element. On `connectedCallback`, walks up
223
+ * `parentElement` until it finds a camera ancestor, then instantiates
224
+ * `createGlyphScene(this, { camera, ...options })`.
225
+ *
226
+ * Children (`<glyph-mesh>`) walk up the tree to find this element and call
227
+ * `getScene()` to register themselves.
228
+ *
229
+ * Attribute parsing mirrors `<poly-scene>` conventions.
230
+ */
231
+
232
+ declare const ELEMENT_BASE$6: typeof HTMLElement;
233
+ declare class GlyphSceneElement extends ELEMENT_BASE$6 {
234
+ static get observedAttributes(): string[];
235
+ private _scene;
236
+ getScene(): GlyphSceneHandle | null;
237
+ private _readOptions;
238
+ private _findCameraAncestor;
239
+ private _initScene;
240
+ connectedCallback(): void;
241
+ rerender(): void;
242
+ disconnectedCallback(): void;
243
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
244
+ }
245
+
246
+ declare const ELEMENT_BASE$5: typeof HTMLElement;
247
+ declare class GlyphMeshElement extends ELEMENT_BASE$5 {
248
+ static get observedAttributes(): string[];
249
+ private _handle;
250
+ private _loadToken;
251
+ getMeshHandle(): GlyphMeshHandle | null;
252
+ connectedCallback(): void;
253
+ disconnectedCallback(): void;
254
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
255
+ private _readTransform;
256
+ private _tearDown;
257
+ private _maybeLoad;
258
+ }
259
+
260
+ declare const ELEMENT_BASE$4: typeof HTMLElement;
261
+ declare class GlyphHotspotElement extends ELEMENT_BASE$4 {
262
+ static get observedAttributes(): string[];
263
+ private _handle;
264
+ connectedCallback(): void;
265
+ disconnectedCallback(): void;
266
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
267
+ private _unregister;
268
+ private _register;
269
+ }
270
+
271
+ declare const ELEMENT_BASE$3: typeof HTMLElement;
272
+ declare class GlyphPerspectiveCameraElement extends ELEMENT_BASE$3 {
273
+ static get observedAttributes(): string[];
274
+ private _camera;
275
+ getCamera(): GlyphCamera | null;
276
+ connectedCallback(): void;
277
+ disconnectedCallback(): void;
278
+ attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
279
+ }
280
+
281
+ declare const ELEMENT_BASE$2: typeof HTMLElement;
282
+ declare class GlyphOrthographicCameraElement extends ELEMENT_BASE$2 {
283
+ static get observedAttributes(): string[];
284
+ private _camera;
285
+ getCamera(): GlyphCamera | null;
286
+ connectedCallback(): void;
287
+ disconnectedCallback(): void;
288
+ attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
289
+ }
290
+
291
+ declare const ELEMENT_BASE$1: typeof HTMLElement;
292
+ declare class GlyphOrbitControlsElement extends ELEMENT_BASE$1 {
293
+ static get observedAttributes(): string[];
294
+ private _controls;
295
+ connectedCallback(): void;
296
+ disconnectedCallback(): void;
297
+ attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
298
+ private _readOptions;
299
+ private _attach;
300
+ }
301
+
302
+ declare const ELEMENT_BASE: typeof HTMLElement;
303
+ declare class GlyphMapControlsElement extends ELEMENT_BASE {
304
+ static get observedAttributes(): string[];
305
+ private _controls;
306
+ connectedCallback(): void;
307
+ disconnectedCallback(): void;
308
+ attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
309
+ private _readOptions;
310
+ private _attach;
311
+ }
312
+
313
+ export { type GlyphSceneHandle as G, type GlyphCamera as a, type GlyphDirectionalLight as b, type GlyphAmbientLight as c, GlyphHotspotElement as d, type GlyphHotspotHandle as e, type GlyphHotspotOptions as f, GlyphMapControlsElement as g, GlyphMeshElement as h, type GlyphMeshHandle as i, type GlyphMeshTransform as j, GlyphOrbitControlsElement as k, GlyphOrthographicCameraElement as l, type GlyphOrthographicCameraHandle as m, type GlyphOrthographicCameraOptions as n, GlyphPerspectiveCameraElement as o, type GlyphPerspectiveCameraHandle as p, type GlyphPerspectiveCameraOptions as q, GlyphSceneElement as r, type GlyphSceneOptions as s, createGlyphCamera as t, createGlyphOrthographicCamera as u, createGlyphPerspectiveCamera as v, createGlyphScene as w };
@@ -0,0 +1,313 @@
1
+ import { Vec3, Polygon, RenderMode } from '@glyphcss/core';
2
+
3
+ /**
4
+ * createGlyphPerspectiveCamera / createGlyphOrthographicCamera — vanilla camera
5
+ * factories for glyphcss.
6
+ *
7
+ * These mirror the asciss camera factories and provide a `GlyphCamera`
8
+ * handle with a `project()` method that maps world-space vertices to
9
+ * [col, row, depth] in character-cell grid space.
10
+ *
11
+ * Public names use the Glyph prefix per glyphcss naming convention.
12
+ * The internal camera algorithms are byte-identical to asciss's createCamera.ts.
13
+ *
14
+ * `createGlyphCamera` is the ergonomic default alias — it creates an
15
+ * orthographic camera, matching the voxel/iso identity of glyphcss.
16
+ */
17
+
18
+ interface GlyphCamera {
19
+ readonly kind: "perspective" | "orthographic";
20
+ rotX: number;
21
+ rotY: number;
22
+ /** Distance from origin along the view axis. Only meaningful for perspective cameras. */
23
+ distance: number;
24
+ /** Camera zoom — mesh size in the viewport (fraction of `min(cols, rows)`). */
25
+ zoom: number;
26
+ /** Extra horizontal stretch on top of `cellAspect`. */
27
+ stretch: number;
28
+ /**
29
+ * Camera target offset in world space — shifts the point the camera orbits around.
30
+ * Subtracted from world coords before projection so the mesh appears to pan without re-baking.
31
+ */
32
+ target: Vec3;
33
+ /**
34
+ * Eye-at-origin projection mode. When true, the perspective camera uses a
35
+ * first-person formulation: `target` is treated as the eye position and
36
+ * vertices behind the eye (`r[2] >= 0`) are NaN-culled. Toggled by
37
+ * `createGlyphFirstPersonControls` at attach / detach time.
38
+ */
39
+ eyeMode: boolean;
40
+ /** Project a world-space vector to `[col, row, depth]`. Same projection used by the renderer and the hit layer. */
41
+ project(v: Vec3, cols: number, rows: number, cellAspect: number): [number, number, number];
42
+ }
43
+ interface GlyphPerspectiveCameraOptions {
44
+ /** Y rotation (radians). The "spin" axis. Default 0. */
45
+ rotY?: number;
46
+ /** X rotation (radians). The "tilt" axis. Default 0. */
47
+ rotX?: number;
48
+ /**
49
+ * Perspective distance. Larger = flatter (less foreshortening); smaller =
50
+ * more dramatic. Default 3.
51
+ */
52
+ distance?: number;
53
+ /** Camera zoom — mesh size in the viewport (fraction of `min(cols, rows)`). Default 0.4. */
54
+ zoom?: number;
55
+ /**
56
+ * Extra horizontal scale on top of `cellAspect`. Use to counteract
57
+ * over-stretching when monospace cells are taller than wide. Default 1.0.
58
+ */
59
+ stretch?: number;
60
+ /** Center of projection in normalized grid coords. Default `[0.5, 0.5]`. */
61
+ center?: [number, number];
62
+ }
63
+ interface GlyphOrthographicCameraOptions {
64
+ rotY?: number;
65
+ rotX?: number;
66
+ zoom?: number;
67
+ center?: [number, number];
68
+ }
69
+ /** Handle alias — same surface as `GlyphCamera`, names matched to glyphcss. */
70
+ type GlyphPerspectiveCameraHandle = GlyphCamera;
71
+ /** Handle alias — same surface as `GlyphCamera`, names matched to glyphcss. */
72
+ type GlyphOrthographicCameraHandle = GlyphCamera;
73
+ declare function createGlyphPerspectiveCamera(opts?: GlyphPerspectiveCameraOptions): GlyphPerspectiveCameraHandle;
74
+ declare function createGlyphOrthographicCamera(opts?: GlyphOrthographicCameraOptions): GlyphOrthographicCameraHandle;
75
+ /**
76
+ * Default camera alias — orthographic projection. The voxel render mode and
77
+ * iso/diagrammatic scenes are glyphcss's differentiator; ortho is the more
78
+ * representative default.
79
+ */
80
+ declare const createGlyphCamera: typeof createGlyphOrthographicCamera;
81
+
82
+ /** Directional light — single distant source for the ASCII rasterizer. */
83
+ interface GlyphDirectionalLight {
84
+ direction: Vec3;
85
+ intensity?: number;
86
+ /** Hex color (#rrggbb). Tints the lit-side per-cell output. Default white. */
87
+ color?: string;
88
+ }
89
+ /** Ambient light — uniform fill regardless of orientation. */
90
+ interface GlyphAmbientLight {
91
+ intensity?: number;
92
+ /** Hex color (#rrggbb). Tints the unlit-side fill. Default white. */
93
+ color?: string;
94
+ }
95
+ interface GlyphMeshTransform {
96
+ /** String identifier for the mesh — surfaced as `GlyphMeshHandle.name`. */
97
+ id?: string;
98
+ position?: Vec3;
99
+ scale?: number | Vec3;
100
+ rotation?: Vec3;
101
+ }
102
+
103
+ /**
104
+ * createGlyphScene — imperative scene API. The vanilla counterpart to
105
+ * `<glyph-scene>` custom element.
106
+ *
107
+ * Mirrors glyphcss's `createPolyScene` architecturally:
108
+ * - Takes a host element + scene options, returns a `GlyphSceneHandle`.
109
+ * - `handle.add(polygons, transform?)` registers a mesh and returns a
110
+ * removable `GlyphMeshHandle`.
111
+ *
112
+ * DOM: injects `<div class="glyph-scene">` containing one `<pre>` (text
113
+ * output) and one `<div class="glyph-hotspot-layer">` (positioned overlay
114
+ * for hotspot dots).
115
+ *
116
+ * Paint backend: on each render, walks all registered meshes, applies each
117
+ * mesh's transform to its polygons in memory, builds a `RasterizeContext`,
118
+ * calls `rasterize`, and sets `<pre>.innerHTML` (or `.textContent` when
119
+ * `useColors` is false).
120
+ *
121
+ * Camera changes trigger a re-rasterize; scene-root transform is NOT a CSS
122
+ * matrix3d — the ASCII output bakes the camera rotation into the projected
123
+ * text every render.
124
+ */
125
+
126
+ interface GlyphSceneOptions {
127
+ /** Render mode: "wireframe" | "solid". Default "solid". */
128
+ mode?: RenderMode;
129
+ /** Named glyph palette. Defaults to "default". */
130
+ glyphPalette?: string;
131
+ /** Whether to emit color spans. Default true. */
132
+ useColors?: boolean;
133
+ /** Grid columns. Default 80. */
134
+ cols?: number;
135
+ /** Grid rows. Default 24. */
136
+ rows?: number;
137
+ /** Character cell aspect ratio (height/width). Default 2.0. */
138
+ cellAspect?: number;
139
+ directionalLight?: GlyphDirectionalLight;
140
+ ambientLight?: GlyphAmbientLight;
141
+ camera?: GlyphCamera;
142
+ /**
143
+ * Smooth (Gouraud) shading. When `true`, per-pixel Lambert intensity is
144
+ * interpolated from per-vertex normals averaged across adjacent polygons
145
+ * within `creaseAngle`. Adjacent triangles on a curved surface render
146
+ * without visible seams along their shared edges. Default `false` — the
147
+ * faceted ASCII look is part of glyph's identity, so smooth shading is
148
+ * opt-in. Turn it on for organic / curved-surface meshes (bread, sphere,
149
+ * character models) where polygon seams hurt the silhouette.
150
+ */
151
+ smoothShading?: boolean;
152
+ /**
153
+ * Crease angle in degrees. With smooth shading on, adjacent faces whose
154
+ * normals diverge by more than this angle stay flat-shaded at their shared
155
+ * edge (preserves hard corners on otherwise smooth meshes). `0` reproduces
156
+ * flat shading regardless of `smoothShading`; `180` smooths everything.
157
+ * Default `60`.
158
+ */
159
+ creaseAngle?: number;
160
+ /**
161
+ * Auto-size the character grid to fill the host element. When `true`, the
162
+ * scene measures one monospace character's pixel size from the live `<pre>`
163
+ * (using whatever font size the host inherits via CSS), computes `cols` and
164
+ * `rows` that fit the host's `clientWidth × clientHeight`, and re-fits on
165
+ * host resize via a `ResizeObserver`. Default `false` — fixed `cols`/`rows`
166
+ * (default 80×24) is the predictable choice for tests and SSR.
167
+ */
168
+ autoSize?: boolean;
169
+ }
170
+ interface GlyphHotspotOptions {
171
+ id: string;
172
+ at: Vec3;
173
+ size?: [number, number];
174
+ }
175
+ interface GlyphHotspotHandle {
176
+ remove(): void;
177
+ /** The absolutely-positioned overlay `<div>` in the hotspot layer. */
178
+ readonly el: HTMLElement;
179
+ }
180
+ interface GlyphMeshHandle {
181
+ readonly id: number;
182
+ /** String identifier supplied via the `id` prop / transform option. */
183
+ readonly name: string | undefined;
184
+ /** The raw polygons registered with this mesh. */
185
+ readonly polygons: Polygon[];
186
+ setTransform(transform: GlyphMeshTransform): void;
187
+ dispose(): void;
188
+ }
189
+ interface GlyphSceneHandle {
190
+ /** The host element passed to `createGlyphScene`. */
191
+ readonly host: HTMLElement;
192
+ /** The `<pre>` element for reading rendered text output. */
193
+ readonly output: HTMLPreElement;
194
+ /** The camera attached to this scene (mutate then call `rerender()`). */
195
+ readonly camera: GlyphCamera;
196
+ /**
197
+ * Register a polygon list as a mesh. Optionally supply a transform.
198
+ * Returns a handle to update or dispose the mesh.
199
+ */
200
+ add(polygons: Polygon[], transform?: GlyphMeshTransform): GlyphMeshHandle;
201
+ addHotspot(opts: GlyphHotspotOptions, onClick?: () => void): GlyphHotspotHandle;
202
+ /** Force an immediate re-rasterize. Normally called automatically on add/remove/setOptions. */
203
+ rerender(): void;
204
+ setOptions(opts: Partial<GlyphSceneOptions>): void;
205
+ getOptions(): GlyphSceneOptions;
206
+ /**
207
+ * Re-measure the host's character cell (font-size, line-height) and adapt
208
+ * `cols`/`rows`/`cellAspect`. Only meaningful when `autoSize` was enabled.
209
+ * Call when something outside the scene options changes the cell size —
210
+ * e.g., the consumer overrode `pre.style.lineHeight` directly. The internal
211
+ * `ResizeObserver` already handles host-size changes automatically.
212
+ */
213
+ fit(): void;
214
+ destroy(): void;
215
+ }
216
+ declare function createGlyphScene(host: HTMLElement, opts?: GlyphSceneOptions): GlyphSceneHandle;
217
+
218
+ /**
219
+ * `<glyph-scene>` custom element.
220
+ *
221
+ * Must be placed inside a `<glyph-perspective-camera>` or
222
+ * `<glyph-orthographic-camera>` element. On `connectedCallback`, walks up
223
+ * `parentElement` until it finds a camera ancestor, then instantiates
224
+ * `createGlyphScene(this, { camera, ...options })`.
225
+ *
226
+ * Children (`<glyph-mesh>`) walk up the tree to find this element and call
227
+ * `getScene()` to register themselves.
228
+ *
229
+ * Attribute parsing mirrors `<poly-scene>` conventions.
230
+ */
231
+
232
+ declare const ELEMENT_BASE$6: typeof HTMLElement;
233
+ declare class GlyphSceneElement extends ELEMENT_BASE$6 {
234
+ static get observedAttributes(): string[];
235
+ private _scene;
236
+ getScene(): GlyphSceneHandle | null;
237
+ private _readOptions;
238
+ private _findCameraAncestor;
239
+ private _initScene;
240
+ connectedCallback(): void;
241
+ rerender(): void;
242
+ disconnectedCallback(): void;
243
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
244
+ }
245
+
246
+ declare const ELEMENT_BASE$5: typeof HTMLElement;
247
+ declare class GlyphMeshElement extends ELEMENT_BASE$5 {
248
+ static get observedAttributes(): string[];
249
+ private _handle;
250
+ private _loadToken;
251
+ getMeshHandle(): GlyphMeshHandle | null;
252
+ connectedCallback(): void;
253
+ disconnectedCallback(): void;
254
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
255
+ private _readTransform;
256
+ private _tearDown;
257
+ private _maybeLoad;
258
+ }
259
+
260
+ declare const ELEMENT_BASE$4: typeof HTMLElement;
261
+ declare class GlyphHotspotElement extends ELEMENT_BASE$4 {
262
+ static get observedAttributes(): string[];
263
+ private _handle;
264
+ connectedCallback(): void;
265
+ disconnectedCallback(): void;
266
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
267
+ private _unregister;
268
+ private _register;
269
+ }
270
+
271
+ declare const ELEMENT_BASE$3: typeof HTMLElement;
272
+ declare class GlyphPerspectiveCameraElement extends ELEMENT_BASE$3 {
273
+ static get observedAttributes(): string[];
274
+ private _camera;
275
+ getCamera(): GlyphCamera | null;
276
+ connectedCallback(): void;
277
+ disconnectedCallback(): void;
278
+ attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
279
+ }
280
+
281
+ declare const ELEMENT_BASE$2: typeof HTMLElement;
282
+ declare class GlyphOrthographicCameraElement extends ELEMENT_BASE$2 {
283
+ static get observedAttributes(): string[];
284
+ private _camera;
285
+ getCamera(): GlyphCamera | null;
286
+ connectedCallback(): void;
287
+ disconnectedCallback(): void;
288
+ attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
289
+ }
290
+
291
+ declare const ELEMENT_BASE$1: typeof HTMLElement;
292
+ declare class GlyphOrbitControlsElement extends ELEMENT_BASE$1 {
293
+ static get observedAttributes(): string[];
294
+ private _controls;
295
+ connectedCallback(): void;
296
+ disconnectedCallback(): void;
297
+ attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
298
+ private _readOptions;
299
+ private _attach;
300
+ }
301
+
302
+ declare const ELEMENT_BASE: typeof HTMLElement;
303
+ declare class GlyphMapControlsElement extends ELEMENT_BASE {
304
+ static get observedAttributes(): string[];
305
+ private _controls;
306
+ connectedCallback(): void;
307
+ disconnectedCallback(): void;
308
+ attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
309
+ private _readOptions;
310
+ private _attach;
311
+ }
312
+
313
+ export { type GlyphSceneHandle as G, type GlyphCamera as a, type GlyphDirectionalLight as b, type GlyphAmbientLight as c, GlyphHotspotElement as d, type GlyphHotspotHandle as e, type GlyphHotspotOptions as f, GlyphMapControlsElement as g, GlyphMeshElement as h, type GlyphMeshHandle as i, type GlyphMeshTransform as j, GlyphOrbitControlsElement as k, GlyphOrthographicCameraElement as l, type GlyphOrthographicCameraHandle as m, type GlyphOrthographicCameraOptions as n, GlyphPerspectiveCameraElement as o, type GlyphPerspectiveCameraHandle as p, type GlyphPerspectiveCameraOptions as q, GlyphSceneElement as r, type GlyphSceneOptions as s, createGlyphCamera as t, createGlyphOrthographicCamera as u, createGlyphPerspectiveCamera as v, createGlyphScene as w };