glyphcss 0.0.1
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.
- package/LICENSE +21 -0
- package/dist/elements-Bb37NHHO.d.cts +269 -0
- package/dist/elements-Bb37NHHO.d.ts +269 -0
- package/dist/elements.cjs +41 -0
- package/dist/elements.d.cts +2 -0
- package/dist/elements.d.ts +2 -0
- package/dist/elements.js +41 -0
- package/dist/index.cjs +41 -0
- package/dist/index.d.cts +177 -0
- package/dist/index.d.ts +177 -0
- package/dist/index.js +41 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Layoutit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { Vec3, Vec2, RenderMode } from '@glyphcss/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* createGlyphcssPerspectiveCamera / createGlyphcssOrthographicCamera /
|
|
5
|
+
* createGlyphcssFirstPersonCamera — vanilla camera factories for glyphcss.
|
|
6
|
+
*
|
|
7
|
+
* These mirror the asciss camera factories and provide a `GlyphcssCamera`
|
|
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 are Glyphcss-prefixed to mirror polycss's naming convention.
|
|
12
|
+
* The internal camera algorithms are byte-identical to asciss's createCamera.ts.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface GlyphcssCamera {
|
|
16
|
+
readonly kind: "perspective" | "orthographic" | "firstPerson";
|
|
17
|
+
rotX: number;
|
|
18
|
+
rotY: number;
|
|
19
|
+
/** Distance from origin along the view axis. Only meaningful for perspective cameras. */
|
|
20
|
+
distance: number;
|
|
21
|
+
/** Mesh size in the viewport (fraction of `min(cols, rows)`). */
|
|
22
|
+
scale: number;
|
|
23
|
+
/** Extra horizontal stretch on top of `cellAspect`. */
|
|
24
|
+
stretch: number;
|
|
25
|
+
/**
|
|
26
|
+
* Camera target offset in world space — shifts the point the camera orbits around.
|
|
27
|
+
* Subtracted from world coords before projection so the mesh appears to pan without re-baking.
|
|
28
|
+
*/
|
|
29
|
+
target: Vec3;
|
|
30
|
+
/** Project a world-space vector to `[col, row, depth]`. Same projection used by the renderer and the hit layer. */
|
|
31
|
+
project(v: Vec3, cols: number, rows: number, cellAspect: number): [number, number, number];
|
|
32
|
+
}
|
|
33
|
+
interface GlyphcssPerspectiveCameraOptions {
|
|
34
|
+
/** Y rotation (radians). The "spin" axis. Default 0. */
|
|
35
|
+
rotY?: number;
|
|
36
|
+
/** X rotation (radians). The "tilt" axis. Default 0. */
|
|
37
|
+
rotX?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Perspective distance. Larger = flatter (less foreshortening); smaller =
|
|
40
|
+
* more dramatic. Default 3.
|
|
41
|
+
*/
|
|
42
|
+
distance?: number;
|
|
43
|
+
/** Size of the mesh in the viewport (fraction of `min(cols, rows)`). Default 0.4. */
|
|
44
|
+
scale?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Extra horizontal scale on top of `cellAspect`. Use to counteract
|
|
47
|
+
* over-stretching when monospace cells are taller than wide. Default 1.0.
|
|
48
|
+
*/
|
|
49
|
+
stretch?: number;
|
|
50
|
+
/** Center of projection in normalized grid coords. Default `[0.5, 0.5]`. */
|
|
51
|
+
center?: [number, number];
|
|
52
|
+
}
|
|
53
|
+
interface GlyphcssOrthographicCameraOptions {
|
|
54
|
+
rotY?: number;
|
|
55
|
+
rotX?: number;
|
|
56
|
+
zoom?: number;
|
|
57
|
+
center?: [number, number];
|
|
58
|
+
}
|
|
59
|
+
interface GlyphcssFirstPersonCameraOptions {
|
|
60
|
+
rotY?: number;
|
|
61
|
+
rotX?: number;
|
|
62
|
+
/** Focal length in world units. Smaller = wider FOV. */
|
|
63
|
+
focal?: number;
|
|
64
|
+
/** Eye position in world space. Used as the projection origin. */
|
|
65
|
+
origin?: Vec3;
|
|
66
|
+
center?: [number, number];
|
|
67
|
+
}
|
|
68
|
+
/** Handle alias — same surface as `GlyphcssCamera`, names matched to polycss. */
|
|
69
|
+
type GlyphcssPerspectiveCameraHandle = GlyphcssCamera;
|
|
70
|
+
/** Handle alias — same surface as `GlyphcssCamera`, names matched to polycss. */
|
|
71
|
+
type GlyphcssOrthographicCameraHandle = GlyphcssCamera;
|
|
72
|
+
/** Handle alias — same surface as `GlyphcssCamera`, names matched to polycss. */
|
|
73
|
+
type GlyphcssFirstPersonCameraHandle = GlyphcssCamera;
|
|
74
|
+
declare function createGlyphcssPerspectiveCamera(opts?: GlyphcssPerspectiveCameraOptions): GlyphcssPerspectiveCameraHandle;
|
|
75
|
+
declare function createGlyphcssOrthographicCamera(opts?: GlyphcssOrthographicCameraOptions): GlyphcssOrthographicCameraHandle;
|
|
76
|
+
/**
|
|
77
|
+
* First-person camera. Projection origin = eye (`target`). Vertices
|
|
78
|
+
* behind the eye (`r[2] >= 0`) are NaN-culled.
|
|
79
|
+
*/
|
|
80
|
+
declare function createGlyphcssFirstPersonCamera(opts?: GlyphcssFirstPersonCameraOptions): GlyphcssFirstPersonCameraHandle;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Triangle type for the glyphcss rasterizer. Unlike polycss-core's TextureTriangle,
|
|
84
|
+
* `uvs` is optional — the ASCII rasterizer never samples UV texture coordinates.
|
|
85
|
+
*/
|
|
86
|
+
interface GlyphcssTriangle {
|
|
87
|
+
vertices: [Vec3, Vec3, Vec3];
|
|
88
|
+
uvs?: [Vec2, Vec2, Vec2];
|
|
89
|
+
color?: string;
|
|
90
|
+
}
|
|
91
|
+
/** Directional light — single distant source for the ASCII rasterizer. */
|
|
92
|
+
interface GlyphcssDirectionalLight {
|
|
93
|
+
direction: Vec3;
|
|
94
|
+
intensity?: number;
|
|
95
|
+
/** Hex color (#rrggbb). Tints the lit-side per-cell output. Default white. */
|
|
96
|
+
color?: string;
|
|
97
|
+
}
|
|
98
|
+
/** Ambient light — uniform fill regardless of orientation. */
|
|
99
|
+
interface GlyphcssAmbientLight {
|
|
100
|
+
intensity?: number;
|
|
101
|
+
/** Hex color (#rrggbb). Tints the unlit-side fill. Default white. */
|
|
102
|
+
color?: string;
|
|
103
|
+
}
|
|
104
|
+
interface GlyphcssMeshTransform {
|
|
105
|
+
position?: Vec3;
|
|
106
|
+
scale?: number | Vec3;
|
|
107
|
+
rotation?: Vec3;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* createGlyphcssScene — imperative scene API. The vanilla counterpart to
|
|
112
|
+
* `<glyphcss-scene>` custom element.
|
|
113
|
+
*
|
|
114
|
+
* Mirrors polycss's `createPolyScene` architecturally:
|
|
115
|
+
* - Takes a host element + scene options, returns a `GlyphcssSceneHandle`.
|
|
116
|
+
* - `handle.add(triangles, transform?)` registers a mesh and returns a
|
|
117
|
+
* removable `GlyphcssMeshHandle`.
|
|
118
|
+
*
|
|
119
|
+
* DOM: injects `<div class="glyphcss-scene">` containing one `<pre>` (text
|
|
120
|
+
* output) and one `<div class="glyphcss-hotspot-layer">` (positioned overlay
|
|
121
|
+
* for hotspot dots).
|
|
122
|
+
*
|
|
123
|
+
* Paint backend: on each render, walks all registered meshes, applies each
|
|
124
|
+
* mesh's transform to its triangles in memory, builds a `RasterizeContext`,
|
|
125
|
+
* calls `rasterize`, and sets `<pre>.innerHTML` (or `.textContent` when
|
|
126
|
+
* `useColors` is false).
|
|
127
|
+
*
|
|
128
|
+
* Camera changes trigger a re-rasterize; scene-root transform is NOT a CSS
|
|
129
|
+
* matrix3d — the ASCII output bakes the camera rotation into the projected
|
|
130
|
+
* text every render.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
interface GlyphcssSceneOptions {
|
|
134
|
+
/** Render mode: "wireframe" | "solid". Default "solid". */
|
|
135
|
+
mode?: RenderMode;
|
|
136
|
+
/** Named glyph palette. Defaults to "default". */
|
|
137
|
+
glyphPalette?: string;
|
|
138
|
+
/** Whether to emit color spans. Default true. */
|
|
139
|
+
useColors?: boolean;
|
|
140
|
+
/** Grid columns. Default 80. */
|
|
141
|
+
cols?: number;
|
|
142
|
+
/** Grid rows. Default 24. */
|
|
143
|
+
rows?: number;
|
|
144
|
+
/** Character cell aspect ratio (height/width). Default 2.0. */
|
|
145
|
+
cellAspect?: number;
|
|
146
|
+
directionalLight?: GlyphcssDirectionalLight;
|
|
147
|
+
ambientLight?: GlyphcssAmbientLight;
|
|
148
|
+
camera?: GlyphcssCamera;
|
|
149
|
+
}
|
|
150
|
+
interface GlyphcssHotspotOptions {
|
|
151
|
+
id: string;
|
|
152
|
+
at: Vec3;
|
|
153
|
+
size?: [number, number];
|
|
154
|
+
}
|
|
155
|
+
interface GlyphcssHotspotHandle {
|
|
156
|
+
remove(): void;
|
|
157
|
+
}
|
|
158
|
+
interface GlyphcssMeshHandle {
|
|
159
|
+
readonly id: number;
|
|
160
|
+
/** The raw triangles registered with this mesh. */
|
|
161
|
+
readonly triangles: GlyphcssTriangle[];
|
|
162
|
+
setTransform(transform: GlyphcssMeshTransform): void;
|
|
163
|
+
dispose(): void;
|
|
164
|
+
}
|
|
165
|
+
interface GlyphcssSceneHandle {
|
|
166
|
+
/** The host element passed to `createGlyphcssScene`. */
|
|
167
|
+
readonly host: HTMLElement;
|
|
168
|
+
/** The `<pre>` element for reading rendered text output. */
|
|
169
|
+
readonly output: HTMLPreElement;
|
|
170
|
+
/** The camera attached to this scene (mutate then call `rerender()`). */
|
|
171
|
+
readonly camera: GlyphcssCamera;
|
|
172
|
+
/**
|
|
173
|
+
* Register a triangle list as a mesh. Optionally supply a transform.
|
|
174
|
+
* Returns a handle to update or dispose the mesh.
|
|
175
|
+
*/
|
|
176
|
+
add(triangles: GlyphcssTriangle[], transform?: GlyphcssMeshTransform): GlyphcssMeshHandle;
|
|
177
|
+
addHotspot(opts: GlyphcssHotspotOptions, onClick?: () => void): GlyphcssHotspotHandle;
|
|
178
|
+
/** Force an immediate re-rasterize. Normally called automatically on add/remove/setOptions. */
|
|
179
|
+
rerender(): void;
|
|
180
|
+
setOptions(opts: Partial<GlyphcssSceneOptions>): void;
|
|
181
|
+
getOptions(): GlyphcssSceneOptions;
|
|
182
|
+
destroy(): void;
|
|
183
|
+
}
|
|
184
|
+
declare function createGlyphcssScene(host: HTMLElement, opts?: GlyphcssSceneOptions): GlyphcssSceneHandle;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* `<glyphcss-scene>` custom element. Vanilla counterpart to React's future GlyphcssScene.
|
|
188
|
+
*
|
|
189
|
+
* On `connectedCallback`, instantiates `createGlyphcssScene(this, options)`.
|
|
190
|
+
* Children (`<glyphcss-mesh>`) walk up the tree to find this element and call
|
|
191
|
+
* `getScene()` to register themselves.
|
|
192
|
+
*
|
|
193
|
+
* Attribute parsing mirrors `<poly-scene>` conventions.
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
declare const ELEMENT_BASE$6: typeof HTMLElement;
|
|
197
|
+
declare class GlyphcssSceneElement extends ELEMENT_BASE$6 {
|
|
198
|
+
static get observedAttributes(): string[];
|
|
199
|
+
private _scene;
|
|
200
|
+
getScene(): GlyphcssSceneHandle | null;
|
|
201
|
+
private _readOptions;
|
|
202
|
+
connectedCallback(): void;
|
|
203
|
+
disconnectedCallback(): void;
|
|
204
|
+
attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare const ELEMENT_BASE$5: typeof HTMLElement;
|
|
208
|
+
declare class GlyphcssMeshElement extends ELEMENT_BASE$5 {
|
|
209
|
+
static get observedAttributes(): string[];
|
|
210
|
+
private _handle;
|
|
211
|
+
private _loadToken;
|
|
212
|
+
getMeshHandle(): GlyphcssMeshHandle | null;
|
|
213
|
+
connectedCallback(): void;
|
|
214
|
+
disconnectedCallback(): void;
|
|
215
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
216
|
+
private _readTransform;
|
|
217
|
+
private _tearDown;
|
|
218
|
+
private _maybeLoad;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare const ELEMENT_BASE$4: typeof HTMLElement;
|
|
222
|
+
declare class GlyphcssHotspotElement extends ELEMENT_BASE$4 {
|
|
223
|
+
static get observedAttributes(): string[];
|
|
224
|
+
private _handle;
|
|
225
|
+
connectedCallback(): void;
|
|
226
|
+
disconnectedCallback(): void;
|
|
227
|
+
attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
|
|
228
|
+
private _register;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
declare const ELEMENT_BASE$3: typeof HTMLElement;
|
|
232
|
+
declare class GlyphcssPerspectiveCameraElement extends ELEMENT_BASE$3 {
|
|
233
|
+
static get observedAttributes(): string[];
|
|
234
|
+
connectedCallback(): void;
|
|
235
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
236
|
+
private _apply;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
declare const ELEMENT_BASE$2: typeof HTMLElement;
|
|
240
|
+
declare class GlyphcssOrthographicCameraElement extends ELEMENT_BASE$2 {
|
|
241
|
+
static get observedAttributes(): string[];
|
|
242
|
+
connectedCallback(): void;
|
|
243
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
244
|
+
private _apply;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
declare const ELEMENT_BASE$1: typeof HTMLElement;
|
|
248
|
+
declare class GlyphcssOrbitControlsElement extends ELEMENT_BASE$1 {
|
|
249
|
+
static get observedAttributes(): string[];
|
|
250
|
+
private _controls;
|
|
251
|
+
connectedCallback(): void;
|
|
252
|
+
disconnectedCallback(): void;
|
|
253
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
254
|
+
private _readOptions;
|
|
255
|
+
private _attach;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
declare const ELEMENT_BASE: typeof HTMLElement;
|
|
259
|
+
declare class GlyphcssMapControlsElement extends ELEMENT_BASE {
|
|
260
|
+
static get observedAttributes(): string[];
|
|
261
|
+
private _controls;
|
|
262
|
+
connectedCallback(): void;
|
|
263
|
+
disconnectedCallback(): void;
|
|
264
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
265
|
+
private _readOptions;
|
|
266
|
+
private _attach;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export { type GlyphcssSceneHandle as G, type GlyphcssCamera as a, type GlyphcssTriangle as b, type GlyphcssDirectionalLight as c, type GlyphcssAmbientLight as d, type GlyphcssFirstPersonCameraHandle as e, type GlyphcssFirstPersonCameraOptions as f, GlyphcssHotspotElement as g, type GlyphcssHotspotHandle as h, type GlyphcssHotspotOptions as i, GlyphcssMapControlsElement as j, GlyphcssMeshElement as k, type GlyphcssMeshHandle as l, type GlyphcssMeshTransform as m, GlyphcssOrbitControlsElement as n, GlyphcssOrthographicCameraElement as o, type GlyphcssOrthographicCameraHandle as p, type GlyphcssOrthographicCameraOptions as q, GlyphcssPerspectiveCameraElement as r, type GlyphcssPerspectiveCameraHandle as s, type GlyphcssPerspectiveCameraOptions as t, GlyphcssSceneElement as u, type GlyphcssSceneOptions as v, createGlyphcssFirstPersonCamera as w, createGlyphcssOrthographicCamera as x, createGlyphcssPerspectiveCamera as y, createGlyphcssScene as z };
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { Vec3, Vec2, RenderMode } from '@glyphcss/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* createGlyphcssPerspectiveCamera / createGlyphcssOrthographicCamera /
|
|
5
|
+
* createGlyphcssFirstPersonCamera — vanilla camera factories for glyphcss.
|
|
6
|
+
*
|
|
7
|
+
* These mirror the asciss camera factories and provide a `GlyphcssCamera`
|
|
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 are Glyphcss-prefixed to mirror polycss's naming convention.
|
|
12
|
+
* The internal camera algorithms are byte-identical to asciss's createCamera.ts.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface GlyphcssCamera {
|
|
16
|
+
readonly kind: "perspective" | "orthographic" | "firstPerson";
|
|
17
|
+
rotX: number;
|
|
18
|
+
rotY: number;
|
|
19
|
+
/** Distance from origin along the view axis. Only meaningful for perspective cameras. */
|
|
20
|
+
distance: number;
|
|
21
|
+
/** Mesh size in the viewport (fraction of `min(cols, rows)`). */
|
|
22
|
+
scale: number;
|
|
23
|
+
/** Extra horizontal stretch on top of `cellAspect`. */
|
|
24
|
+
stretch: number;
|
|
25
|
+
/**
|
|
26
|
+
* Camera target offset in world space — shifts the point the camera orbits around.
|
|
27
|
+
* Subtracted from world coords before projection so the mesh appears to pan without re-baking.
|
|
28
|
+
*/
|
|
29
|
+
target: Vec3;
|
|
30
|
+
/** Project a world-space vector to `[col, row, depth]`. Same projection used by the renderer and the hit layer. */
|
|
31
|
+
project(v: Vec3, cols: number, rows: number, cellAspect: number): [number, number, number];
|
|
32
|
+
}
|
|
33
|
+
interface GlyphcssPerspectiveCameraOptions {
|
|
34
|
+
/** Y rotation (radians). The "spin" axis. Default 0. */
|
|
35
|
+
rotY?: number;
|
|
36
|
+
/** X rotation (radians). The "tilt" axis. Default 0. */
|
|
37
|
+
rotX?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Perspective distance. Larger = flatter (less foreshortening); smaller =
|
|
40
|
+
* more dramatic. Default 3.
|
|
41
|
+
*/
|
|
42
|
+
distance?: number;
|
|
43
|
+
/** Size of the mesh in the viewport (fraction of `min(cols, rows)`). Default 0.4. */
|
|
44
|
+
scale?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Extra horizontal scale on top of `cellAspect`. Use to counteract
|
|
47
|
+
* over-stretching when monospace cells are taller than wide. Default 1.0.
|
|
48
|
+
*/
|
|
49
|
+
stretch?: number;
|
|
50
|
+
/** Center of projection in normalized grid coords. Default `[0.5, 0.5]`. */
|
|
51
|
+
center?: [number, number];
|
|
52
|
+
}
|
|
53
|
+
interface GlyphcssOrthographicCameraOptions {
|
|
54
|
+
rotY?: number;
|
|
55
|
+
rotX?: number;
|
|
56
|
+
zoom?: number;
|
|
57
|
+
center?: [number, number];
|
|
58
|
+
}
|
|
59
|
+
interface GlyphcssFirstPersonCameraOptions {
|
|
60
|
+
rotY?: number;
|
|
61
|
+
rotX?: number;
|
|
62
|
+
/** Focal length in world units. Smaller = wider FOV. */
|
|
63
|
+
focal?: number;
|
|
64
|
+
/** Eye position in world space. Used as the projection origin. */
|
|
65
|
+
origin?: Vec3;
|
|
66
|
+
center?: [number, number];
|
|
67
|
+
}
|
|
68
|
+
/** Handle alias — same surface as `GlyphcssCamera`, names matched to polycss. */
|
|
69
|
+
type GlyphcssPerspectiveCameraHandle = GlyphcssCamera;
|
|
70
|
+
/** Handle alias — same surface as `GlyphcssCamera`, names matched to polycss. */
|
|
71
|
+
type GlyphcssOrthographicCameraHandle = GlyphcssCamera;
|
|
72
|
+
/** Handle alias — same surface as `GlyphcssCamera`, names matched to polycss. */
|
|
73
|
+
type GlyphcssFirstPersonCameraHandle = GlyphcssCamera;
|
|
74
|
+
declare function createGlyphcssPerspectiveCamera(opts?: GlyphcssPerspectiveCameraOptions): GlyphcssPerspectiveCameraHandle;
|
|
75
|
+
declare function createGlyphcssOrthographicCamera(opts?: GlyphcssOrthographicCameraOptions): GlyphcssOrthographicCameraHandle;
|
|
76
|
+
/**
|
|
77
|
+
* First-person camera. Projection origin = eye (`target`). Vertices
|
|
78
|
+
* behind the eye (`r[2] >= 0`) are NaN-culled.
|
|
79
|
+
*/
|
|
80
|
+
declare function createGlyphcssFirstPersonCamera(opts?: GlyphcssFirstPersonCameraOptions): GlyphcssFirstPersonCameraHandle;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Triangle type for the glyphcss rasterizer. Unlike polycss-core's TextureTriangle,
|
|
84
|
+
* `uvs` is optional — the ASCII rasterizer never samples UV texture coordinates.
|
|
85
|
+
*/
|
|
86
|
+
interface GlyphcssTriangle {
|
|
87
|
+
vertices: [Vec3, Vec3, Vec3];
|
|
88
|
+
uvs?: [Vec2, Vec2, Vec2];
|
|
89
|
+
color?: string;
|
|
90
|
+
}
|
|
91
|
+
/** Directional light — single distant source for the ASCII rasterizer. */
|
|
92
|
+
interface GlyphcssDirectionalLight {
|
|
93
|
+
direction: Vec3;
|
|
94
|
+
intensity?: number;
|
|
95
|
+
/** Hex color (#rrggbb). Tints the lit-side per-cell output. Default white. */
|
|
96
|
+
color?: string;
|
|
97
|
+
}
|
|
98
|
+
/** Ambient light — uniform fill regardless of orientation. */
|
|
99
|
+
interface GlyphcssAmbientLight {
|
|
100
|
+
intensity?: number;
|
|
101
|
+
/** Hex color (#rrggbb). Tints the unlit-side fill. Default white. */
|
|
102
|
+
color?: string;
|
|
103
|
+
}
|
|
104
|
+
interface GlyphcssMeshTransform {
|
|
105
|
+
position?: Vec3;
|
|
106
|
+
scale?: number | Vec3;
|
|
107
|
+
rotation?: Vec3;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* createGlyphcssScene — imperative scene API. The vanilla counterpart to
|
|
112
|
+
* `<glyphcss-scene>` custom element.
|
|
113
|
+
*
|
|
114
|
+
* Mirrors polycss's `createPolyScene` architecturally:
|
|
115
|
+
* - Takes a host element + scene options, returns a `GlyphcssSceneHandle`.
|
|
116
|
+
* - `handle.add(triangles, transform?)` registers a mesh and returns a
|
|
117
|
+
* removable `GlyphcssMeshHandle`.
|
|
118
|
+
*
|
|
119
|
+
* DOM: injects `<div class="glyphcss-scene">` containing one `<pre>` (text
|
|
120
|
+
* output) and one `<div class="glyphcss-hotspot-layer">` (positioned overlay
|
|
121
|
+
* for hotspot dots).
|
|
122
|
+
*
|
|
123
|
+
* Paint backend: on each render, walks all registered meshes, applies each
|
|
124
|
+
* mesh's transform to its triangles in memory, builds a `RasterizeContext`,
|
|
125
|
+
* calls `rasterize`, and sets `<pre>.innerHTML` (or `.textContent` when
|
|
126
|
+
* `useColors` is false).
|
|
127
|
+
*
|
|
128
|
+
* Camera changes trigger a re-rasterize; scene-root transform is NOT a CSS
|
|
129
|
+
* matrix3d — the ASCII output bakes the camera rotation into the projected
|
|
130
|
+
* text every render.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
interface GlyphcssSceneOptions {
|
|
134
|
+
/** Render mode: "wireframe" | "solid". Default "solid". */
|
|
135
|
+
mode?: RenderMode;
|
|
136
|
+
/** Named glyph palette. Defaults to "default". */
|
|
137
|
+
glyphPalette?: string;
|
|
138
|
+
/** Whether to emit color spans. Default true. */
|
|
139
|
+
useColors?: boolean;
|
|
140
|
+
/** Grid columns. Default 80. */
|
|
141
|
+
cols?: number;
|
|
142
|
+
/** Grid rows. Default 24. */
|
|
143
|
+
rows?: number;
|
|
144
|
+
/** Character cell aspect ratio (height/width). Default 2.0. */
|
|
145
|
+
cellAspect?: number;
|
|
146
|
+
directionalLight?: GlyphcssDirectionalLight;
|
|
147
|
+
ambientLight?: GlyphcssAmbientLight;
|
|
148
|
+
camera?: GlyphcssCamera;
|
|
149
|
+
}
|
|
150
|
+
interface GlyphcssHotspotOptions {
|
|
151
|
+
id: string;
|
|
152
|
+
at: Vec3;
|
|
153
|
+
size?: [number, number];
|
|
154
|
+
}
|
|
155
|
+
interface GlyphcssHotspotHandle {
|
|
156
|
+
remove(): void;
|
|
157
|
+
}
|
|
158
|
+
interface GlyphcssMeshHandle {
|
|
159
|
+
readonly id: number;
|
|
160
|
+
/** The raw triangles registered with this mesh. */
|
|
161
|
+
readonly triangles: GlyphcssTriangle[];
|
|
162
|
+
setTransform(transform: GlyphcssMeshTransform): void;
|
|
163
|
+
dispose(): void;
|
|
164
|
+
}
|
|
165
|
+
interface GlyphcssSceneHandle {
|
|
166
|
+
/** The host element passed to `createGlyphcssScene`. */
|
|
167
|
+
readonly host: HTMLElement;
|
|
168
|
+
/** The `<pre>` element for reading rendered text output. */
|
|
169
|
+
readonly output: HTMLPreElement;
|
|
170
|
+
/** The camera attached to this scene (mutate then call `rerender()`). */
|
|
171
|
+
readonly camera: GlyphcssCamera;
|
|
172
|
+
/**
|
|
173
|
+
* Register a triangle list as a mesh. Optionally supply a transform.
|
|
174
|
+
* Returns a handle to update or dispose the mesh.
|
|
175
|
+
*/
|
|
176
|
+
add(triangles: GlyphcssTriangle[], transform?: GlyphcssMeshTransform): GlyphcssMeshHandle;
|
|
177
|
+
addHotspot(opts: GlyphcssHotspotOptions, onClick?: () => void): GlyphcssHotspotHandle;
|
|
178
|
+
/** Force an immediate re-rasterize. Normally called automatically on add/remove/setOptions. */
|
|
179
|
+
rerender(): void;
|
|
180
|
+
setOptions(opts: Partial<GlyphcssSceneOptions>): void;
|
|
181
|
+
getOptions(): GlyphcssSceneOptions;
|
|
182
|
+
destroy(): void;
|
|
183
|
+
}
|
|
184
|
+
declare function createGlyphcssScene(host: HTMLElement, opts?: GlyphcssSceneOptions): GlyphcssSceneHandle;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* `<glyphcss-scene>` custom element. Vanilla counterpart to React's future GlyphcssScene.
|
|
188
|
+
*
|
|
189
|
+
* On `connectedCallback`, instantiates `createGlyphcssScene(this, options)`.
|
|
190
|
+
* Children (`<glyphcss-mesh>`) walk up the tree to find this element and call
|
|
191
|
+
* `getScene()` to register themselves.
|
|
192
|
+
*
|
|
193
|
+
* Attribute parsing mirrors `<poly-scene>` conventions.
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
declare const ELEMENT_BASE$6: typeof HTMLElement;
|
|
197
|
+
declare class GlyphcssSceneElement extends ELEMENT_BASE$6 {
|
|
198
|
+
static get observedAttributes(): string[];
|
|
199
|
+
private _scene;
|
|
200
|
+
getScene(): GlyphcssSceneHandle | null;
|
|
201
|
+
private _readOptions;
|
|
202
|
+
connectedCallback(): void;
|
|
203
|
+
disconnectedCallback(): void;
|
|
204
|
+
attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
declare const ELEMENT_BASE$5: typeof HTMLElement;
|
|
208
|
+
declare class GlyphcssMeshElement extends ELEMENT_BASE$5 {
|
|
209
|
+
static get observedAttributes(): string[];
|
|
210
|
+
private _handle;
|
|
211
|
+
private _loadToken;
|
|
212
|
+
getMeshHandle(): GlyphcssMeshHandle | null;
|
|
213
|
+
connectedCallback(): void;
|
|
214
|
+
disconnectedCallback(): void;
|
|
215
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
216
|
+
private _readTransform;
|
|
217
|
+
private _tearDown;
|
|
218
|
+
private _maybeLoad;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
declare const ELEMENT_BASE$4: typeof HTMLElement;
|
|
222
|
+
declare class GlyphcssHotspotElement extends ELEMENT_BASE$4 {
|
|
223
|
+
static get observedAttributes(): string[];
|
|
224
|
+
private _handle;
|
|
225
|
+
connectedCallback(): void;
|
|
226
|
+
disconnectedCallback(): void;
|
|
227
|
+
attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
|
|
228
|
+
private _register;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
declare const ELEMENT_BASE$3: typeof HTMLElement;
|
|
232
|
+
declare class GlyphcssPerspectiveCameraElement extends ELEMENT_BASE$3 {
|
|
233
|
+
static get observedAttributes(): string[];
|
|
234
|
+
connectedCallback(): void;
|
|
235
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
236
|
+
private _apply;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
declare const ELEMENT_BASE$2: typeof HTMLElement;
|
|
240
|
+
declare class GlyphcssOrthographicCameraElement extends ELEMENT_BASE$2 {
|
|
241
|
+
static get observedAttributes(): string[];
|
|
242
|
+
connectedCallback(): void;
|
|
243
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
244
|
+
private _apply;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
declare const ELEMENT_BASE$1: typeof HTMLElement;
|
|
248
|
+
declare class GlyphcssOrbitControlsElement extends ELEMENT_BASE$1 {
|
|
249
|
+
static get observedAttributes(): string[];
|
|
250
|
+
private _controls;
|
|
251
|
+
connectedCallback(): void;
|
|
252
|
+
disconnectedCallback(): void;
|
|
253
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
254
|
+
private _readOptions;
|
|
255
|
+
private _attach;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
declare const ELEMENT_BASE: typeof HTMLElement;
|
|
259
|
+
declare class GlyphcssMapControlsElement extends ELEMENT_BASE {
|
|
260
|
+
static get observedAttributes(): string[];
|
|
261
|
+
private _controls;
|
|
262
|
+
connectedCallback(): void;
|
|
263
|
+
disconnectedCallback(): void;
|
|
264
|
+
attributeChangedCallback(_name: string, old: string | null, next: string | null): void;
|
|
265
|
+
private _readOptions;
|
|
266
|
+
private _attach;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export { type GlyphcssSceneHandle as G, type GlyphcssCamera as a, type GlyphcssTriangle as b, type GlyphcssDirectionalLight as c, type GlyphcssAmbientLight as d, type GlyphcssFirstPersonCameraHandle as e, type GlyphcssFirstPersonCameraOptions as f, GlyphcssHotspotElement as g, type GlyphcssHotspotHandle as h, type GlyphcssHotspotOptions as i, GlyphcssMapControlsElement as j, GlyphcssMeshElement as k, type GlyphcssMeshHandle as l, type GlyphcssMeshTransform as m, GlyphcssOrbitControlsElement as n, GlyphcssOrthographicCameraElement as o, type GlyphcssOrthographicCameraHandle as p, type GlyphcssOrthographicCameraOptions as q, GlyphcssPerspectiveCameraElement as r, type GlyphcssPerspectiveCameraHandle as s, type GlyphcssPerspectiveCameraOptions as t, GlyphcssSceneElement as u, type GlyphcssSceneOptions as v, createGlyphcssFirstPersonCamera as w, createGlyphcssOrthographicCamera as x, createGlyphcssPerspectiveCamera as y, createGlyphcssScene as z };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";var B=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Re=Object.prototype.hasOwnProperty;var Ie=(n,t)=>{for(var e in t)B(n,e,{get:t[e],enumerable:!0})},ke=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Oe(t))!Re.call(n,s)&&s!==e&&B(n,s,{get:()=>t[s],enumerable:!(r=Pe(t,s))||r.enumerable});return n};var Ye=n=>ke(B({},"__esModule",{value:!0}),n);var yt={};Ie(yt,{GlyphcssHotspotElement:()=>I,GlyphcssMapControlsElement:()=>z,GlyphcssMeshElement:()=>R,GlyphcssOrbitControlsElement:()=>X,GlyphcssOrthographicCameraElement:()=>F,GlyphcssPerspectiveCameraElement:()=>Y,GlyphcssSceneElement:()=>O});module.exports=Ye(yt);function oe(n,t,e){let r=Math.cos(t),s=Math.sin(t),c=r*n[1]-s*n[0],i=s*n[1]+r*n[0],o=n[2],a=Math.cos(e),l=Math.sin(e),f=a*i-l*o,m=l*i+a*o;return[c,f,m]}function V(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:n.distance??3,scale:n.scale??.4,stretch:n.stretch??1,target:[0,0,0]},[e,r]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(s){t.rotX=s},get rotY(){return t.rotY},set rotY(s){t.rotY=s},get distance(){return t.distance},set distance(s){t.distance=s},get scale(){return t.scale},set scale(s){t.scale=s},get stretch(){return t.stretch},set stretch(s){t.stretch=s},get target(){return t.target},set target(s){t.target=s},project(s,c,i,o){let a=[s[0]-t.target[0],s[1]-t.target[1],s[2]-t.target[2]],l=oe(a,t.rotY,t.rotX),f=30,m=1.5,E=l[2]*f,g=.001,h=1-E/t.distance;if(h<g)return[NaN,NaN,l[2]];let G=1/h,M=Math.min(c,i)*t.scale*m*G,_=c*e+l[0]*M*o*t.stretch,d=i*r+l[1]*M;return[_,d,l[2]]}}}function le(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:0,scale:n.zoom??.4,stretch:1,target:[0,0,0]},[e,r]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(s){t.rotX=s},get rotY(){return t.rotY},set rotY(s){t.rotY=s},get distance(){return t.distance},set distance(s){t.distance=s},get scale(){return t.scale},set scale(s){t.scale=s},get stretch(){return t.stretch},set stretch(s){t.stretch=s},get target(){return t.target},set target(s){t.target=s},project(s,c,i,o){let a=[s[0]-t.target[0],s[1]-t.target[1],s[2]-t.target[2]],l=oe(a,t.rotY,t.rotX),m=Math.min(c,i)*t.scale*1.5,E=c*e+l[0]*m*o*t.stretch,g=i*r+l[1]*m;return[E,g,l[2]]}}}var ce=require("@glyphcss/core"),Fe={direction:[.5,.7,.5],intensity:1},Xe={intensity:.4};function ae(n){let t=n.triangles??[],e=n.mode??(t.length?"solid":"wireframe"),r=n.wireframe??(e==="wireframe"?(0,ce.trianglesToFeatureEdges)(t):[]);return{camera:n.camera,grid:n.grid,triangles:t,wireframe:r,mode:e,directionalLight:n.directionalLight??Fe,ambientLight:n.ambientLight??Xe,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0}}var Et=" .:-=+*#%@".split(""),Gt=" .:-=+*#%@".split(""),j={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},Mt=j.default;function W(n){return j[n]??j.default}function ue(n){let{camera:t,grid:e,wireframe:r,triangles:s,mode:c,directionalLight:i,ambientLight:o}=n,{cols:a,rows:l,cellAspect:f}=e;if(c==="solid")return ze(n,a,l,f);let m=W(n.glyphPalette),E=new Uint8Array(a*l),g=n.useColors?new Array(a*l).fill(null):null;for(let h of r){let G=t.project(h.from,a,l,f),M=t.project(h.to,a,l,f);G[0]!==G[0]||M[0]!==M[0]||De(E,g,G[0]|0,G[1]|0,M[0]|0,M[1]|0,h.weight??2,h.color??null,a,l)}return Be(E,g,a,l,m)}function ze(n,t,e,r){let{camera:s,triangles:c,directionalLight:i,ambientLight:o}=n,a=W(n.glyphPalette).solid,l=new Array(t*e).fill(" "),f=n.useColors,m=f?new Array(t*e).fill(null):null,E=new Float64Array(t*e).fill(-1/0),g=i.direction,h=Math.hypot(g[0],g[1],g[2])||1,G=g[0]/h,M=g[1]/h,_=g[2]/h,d=i.intensity??1,b=o.intensity??.4,v=U(i.color??"#ffffff"),L=U(o.color??"#ffffff");for(let y of c){let[u,C,A]=y.vertices,T=s.project(u,t,e,r),p=s.project(C,t,e,r),x=s.project(A,t,e,r);if(T[0]!==T[0]||p[0]!==p[0]||x[0]!==x[0])continue;let S=C[0]-u[0],w=C[1]-u[1],H=C[2]-u[2],Q=A[0]-u[0],ee=A[1]-u[1],te=A[2]-u[2],ne=w*te-H*ee,se=H*Q-S*te,re=S*ee-w*Q,Ee=Math.hypot(ne,se,re)||1,Ge=(ne*G+se*M+re*_)/Ee,N=Math.max(0,Ge)*d,Me=Math.min(1,Math.max(0,b+N)),xe=Math.min(a.length-1,Me*(a.length-1)|0),Le=a[xe],ie=null;if(f){let D=y.color?U(y.color):[255,255,255],Ae=b*L[0]/255+N*v[0]/255,Te=b*L[1]/255+N*v[1]/255,_e=b*L[2]/255+N*v[2]/255,Se=Math.min(255,D[0]*Ae),He=Math.min(255,D[1]*Te),we=Math.min(255,D[2]*_e);ie=`#${$(Se)}${$(He)}${$(we)}`}let Ce=(T[2]+p[2]+x[2])/3;Ne(T[0],T[1],p[0],p[1],x[0],x[1],Ce,Le,ie,l,m,E,t,e)}return Ve(l,m,t,e)}function Ne(n,t,e,r,s,c,i,o,a,l,f,m,E,g){let h=n,G=t,M=e,_=r,d=s,b=c;if(_<G){let y=h;h=M,M=y,y=G,G=_,_=y}if(b<G){let y=h;h=d,d=y,y=G,G=b,b=y}if(b<_){let y=M;M=d,d=y,y=_,_=b,b=y}let v=Math.max(0,Math.ceil(G)),L=Math.min(g-1,Math.floor(b));if(!(v>L))for(let y=v;y<=L;y++){let u=(y-G)/(b-G||1),C=h+(d-h)*u,A;if(y<_){let x=(y-G)/(_-G||1);A=h+(M-h)*x}else{let x=(y-_)/(b-_||1);A=M+(d-M)*x}let T=Math.max(0,Math.ceil(Math.min(C,A))),p=Math.min(E-1,Math.floor(Math.max(C,A)));for(let x=T;x<=p;x++){let S=y*E+x;i>m[S]&&(m[S]=i,l[S]=o,f&&(f[S]=a))}}}function Ve(n,t,e,r){let s=[],c=null,i="",o=()=>{i&&(c!==null?s.push(`<span style="color:${c}">${i}</span>`):s.push(i),i="")};for(let a=0;a<r;a++){for(let l=0;l<e;l++){let f=a*e+l,m=n[f],E=t&&m!==" "?t[f]??null:null;E!==c&&(o(),c=E),i+=m}o(),c=null,a<r-1&&s.push(`
|
|
2
|
+
`)}return s.join("")}function De(n,t,e,r,s,c,i,o,a,l){let f=Math.abs(s-e),m=-Math.abs(c-r),E=e<s?1:-1,g=r<c?1:-1,h=f+m;for(;;){if(e>=0&&e<a&&r>=0&&r<l){let M=r*a+e;n[M]<i&&(n[M]=i,t&&(t[M]=o))}if(e===s&&r===c)break;let G=2*h;G>=m&&(h+=m,e+=E),G<=f&&(h+=f,r+=g)}}function Be(n,t,e,r,s){let c=[],i=null,o="",a=()=>{o&&(i!==null?c.push(`<span style="color:${i}">${o}</span>`):c.push(o),o="")};for(let l=0;l<r;l++){for(let f=0;f<e;f++){let m=l*e+f,E=n[m],g,h;E===0?(g=" ",h=null):(g=E===1?s.thin[Math.random()*s.thin.length|0]:E===2?s.normal[Math.random()*s.normal.length|0]:s.core[Math.random()*s.core.length|0],h=t?t[m]??null:null),h!==i&&(a(),i=h),o+=g}a(),i=null,l<r-1&&c.push(`
|
|
3
|
+
`)}return c.join("")}function U(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),r=parseInt(t[1]+t[1],16),s=parseInt(t[2]+t[2],16);return[e||0,r||0,s||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16);return[e||0,r||0,s||0]}return[255,255,255]}function $(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var pe="glyphcss-styles";function de(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(pe))return;let e=t.createElement("style");e.id=pe,e.textContent=je,t.head.appendChild(e)}var je=`
|
|
4
|
+
/* \u2500\u2500 Glyphcss scene container \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
5
|
+
|
|
6
|
+
.glyphcss-scene {
|
|
7
|
+
position: relative;
|
|
8
|
+
display: block;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
line-height: 1;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* \u2500\u2500 ASCII output <pre> \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
14
|
+
|
|
15
|
+
.glyphcss-scene .glyphcss-output {
|
|
16
|
+
display: block;
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding: 0;
|
|
19
|
+
font-family: monospace;
|
|
20
|
+
font-size: inherit;
|
|
21
|
+
line-height: 1;
|
|
22
|
+
white-space: pre;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
user-select: none;
|
|
25
|
+
-webkit-user-select: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* \u2500\u2500 Hotspot overlay \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
29
|
+
|
|
30
|
+
.glyphcss-scene .glyphcss-hotspot-layer {
|
|
31
|
+
position: absolute;
|
|
32
|
+
inset: 0;
|
|
33
|
+
pointer-events: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.glyphcss-scene .glyphcss-hotspot {
|
|
37
|
+
position: absolute;
|
|
38
|
+
pointer-events: all;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
`;function he(n,t,e,r,s){return n.map(c=>{let[i,o,a]=t.project(c.at,e,r,s),l=a>-3&&i>=0&&i<e&&o>=0&&o<r;return{id:c.id,col:i,row:o,depth:a,visible:l}})}var We=1;function Ue(n,t){let{position:e,scale:r,rotation:s}=t;if(!e&&!r&&!s)return n;let[c,i,o]=e??[0,0,0],a=1,l=1,f=1;r!==void 0&&(typeof r=="number"?a=l=f=r:[a,l,f]=r);let[m,E,g]=s??[0,0,0],h=Math.cos(m),G=Math.sin(m),M=Math.cos(E),_=Math.sin(E),d=Math.cos(g),b=Math.sin(g);function v(L){let y=L[0]*a,u=L[1]*l,C=L[2]*f,A=d*y-b*u,T=b*y+d*u,p=C;return y=M*A+_*p,u=T,C=-_*A+M*p,A=y,T=h*u-G*C,p=G*u+h*C,[A+c,T+i,p+o]}return n.map(L=>({...L,vertices:[v(L.vertices[0]),v(L.vertices[1]),v(L.vertices[2])]}))}function me(n,t={}){de(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[.5,.7,.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??V()},r=n.ownerDocument.createElement("div");r.className="glyphcss-scene";let s=n.ownerDocument.createElement("pre");s.className="glyphcss-output";let c=n.ownerDocument.createElement("div");c.className="glyphcss-hotspot-layer",r.appendChild(s),r.appendChild(c),n.appendChild(r);let i=new Map,o=[],a=!1;function l(){a||(a=!0,Promise.resolve().then(()=>{a=!1,f()}))}function f(){let d=[];for(let L of i.values()){let y=Ue(L.triangles,L.transform);for(let u of y)d.push(u)}let b=ae({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},triangles:d,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors}),v=ue(b);e.useColors?s.innerHTML=v:s.textContent=v,m()}function m(){let{cols:d,rows:b,cellAspect:v,camera:L}=e,y=he(o.map(T=>T.hotspot),L,d,b,v),u=s.getBoundingClientRect(),C=d>0?u.width/d:8,A=b>0?u.height/b:16;for(let T=0;T<o.length;T++){let{el:p}=o[T],x=y[T];x.visible?(p.style.display="",p.style.left=`${x.col*C}px`,p.style.top=`${x.row*A}px`,p.style.zIndex=String(Math.round(x.depth*1e3))):p.style.display="none"}}function E(d,b={}){let v=We++;return i.set(v,{id:v,triangles:d,transform:b}),l(),{get id(){return v},get triangles(){return d},setTransform(L){let y=i.get(v);y&&(y.transform=L,l())},dispose(){i.delete(v),l()}}}function g(d,b){let v=n.ownerDocument.createElement("div");v.className="glyphcss-hotspot",v.setAttribute("data-hotspot-id",d.id);let[L,y]=d.size??[1,1];v.style.position="absolute",v.style.width=`${L}ch`,v.style.height=`${y*e.cellAspect}ch`,b&&v.addEventListener("click",b),c.appendChild(v);let u={hotspot:{id:d.id,at:d.at,size:d.size},el:v,onClick:b};return o.push(u),l(),{remove(){let C=o.indexOf(u);C>=0&&o.splice(C,1),b&&v.removeEventListener("click",b),c.removeChild(v),l()}}}function h(){f()}function G(d){d.mode!==void 0&&(e.mode=d.mode),d.glyphPalette!==void 0&&(e.glyphPalette=d.glyphPalette),d.useColors!==void 0&&(e.useColors=d.useColors),d.cols!==void 0&&(e.cols=d.cols),d.rows!==void 0&&(e.rows=d.rows),d.cellAspect!==void 0&&(e.cellAspect=d.cellAspect),d.directionalLight!==void 0&&(e.directionalLight=d.directionalLight),d.ambientLight!==void 0&&(e.ambientLight=d.ambientLight),d.camera!==void 0&&(e.camera=d.camera),l()}function M(){return{...e}}function _(){i.clear(),n.contains(r)&&n.removeChild(r)}return l(),{get host(){return n},get output(){return s},get camera(){return e.camera},add:E,addHotspot:g,rerender:h,setOptions:G,getOptions:M,destroy:_}}var $e=typeof HTMLElement<"u"?HTMLElement:class{},qe=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity"];function P(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Ze(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function Ke(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var O=class extends $e{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...qe]}getScene(){return this._scene}_readOptions(){let e={},r=Ze(this.getAttribute("mode"));r!==void 0&&(e.mode=r);let s=this.getAttribute("glyph-palette");s&&(e.glyphPalette=s);let c=Ke(this.getAttribute("use-colors"));c!==void 0&&(e.useColors=c);let i=P(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let o=P(this.getAttribute("rows"));o!==void 0&&(e.rows=o);let a=P(this.getAttribute("cell-aspect"));a!==void 0&&(e.cellAspect=a);let l=P(this.getAttribute("directional-intensity"));l!==void 0&&(e.directionalLight={direction:[.5,.7,.5],intensity:l});let f=P(this.getAttribute("ambient-intensity"));return f!==void 0&&(e.ambientLight={intensity:f}),e}connectedCallback(){this._scene||(this._scene=me(this,this._readOptions()),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1})))}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,r,s){r!==s&&this._scene&&this._scene.setOptions(this._readOptions())}};var fe=require("@glyphcss/core"),Je=typeof HTMLElement<"u"?HTMLElement:class{},Qe=["src","position","scale","rotation"];function q(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function et(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return q(n)}}function tt(n){return n.closest("glyphcss-scene")??null}function nt(n){let t=[[0,0],[0,0],[0,0]],e=[];for(let r of n){let s=r.vertices;if(!(s.length<3))for(let c=1;c<s.length-1;c++)e.push({vertices:[s[0],s[c],s[c+1]],uvs:t,...r.color?{color:r.color}:{}})}return e}var R=class extends Je{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Qe]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,r,s){if(r!==s){if(e==="src"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:q(this.getAttribute("position")),scale:et(this.getAttribute("scale")),rotation:q(this.getAttribute("rotation"))}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src");if(!e)return;let r=tt(this);if(!r)return;let s=++this._loadToken,c;try{c=await(0,fe.loadMesh)(e)}catch(a){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:a,bubbles:!0}));return}if(s!==this._loadToken){try{c.dispose()}catch{}return}let i=r.getScene();if(!i){try{c.dispose()}catch{}return}let o=nt(c.polygons);this._handle=i.add(o,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{triangles:o},bubbles:!0}))}};var st=typeof HTMLElement<"u"?HTMLElement:class{};function rt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function it(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function ot(n){return n.closest("glyphcss-scene")??null}var I=class extends st{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&(this._handle.remove(),this._handle=null)}attributeChangedCallback(e,r,s){r!==s&&(this._handle&&(this._handle.remove(),this._handle=null),this._register())}_register(){let e=rt(this.getAttribute("at"));if(!e)return;let s=ot(this)?.getScene();if(!s)return;let c=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),i=it(this.getAttribute("size"));this._handle=s.addHotspot({id:c,at:e,size:i},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:c},bubbles:!0})))}};var lt=typeof HTMLElement<"u"?HTMLElement:class{};function k(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ct(n){return n.closest("glyphcss-scene")??null}var Y=class extends lt{static get observedAttributes(){return["rot-x","rot-y","distance","scale","stretch"]}connectedCallback(){this._apply()}attributeChangedCallback(t,e,r){e!==r&&this._apply()}_apply(){let e=ct(this)?.getScene();if(!e)return;let r=V({rotX:k(this.getAttribute("rot-x")),rotY:k(this.getAttribute("rot-y")),distance:k(this.getAttribute("distance")),scale:k(this.getAttribute("scale")),stretch:k(this.getAttribute("stretch"))});e.setOptions({camera:r})}};var at=typeof HTMLElement<"u"?HTMLElement:class{};function Z(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ut(n){return n.closest("glyphcss-scene")??null}var F=class extends at{static get observedAttributes(){return["rot-x","rot-y","zoom"]}connectedCallback(){this._apply()}attributeChangedCallback(t,e,r){e!==r&&this._apply()}_apply(){let e=ut(this)?.getScene();if(!e)return;let r=le({rotX:Z(this.getAttribute("rot-x")),rotY:Z(this.getAttribute("rot-y")),zoom:Z(this.getAttribute("zoom"))});e.setOptions({camera:r})}};function ge(n,t={}){let e=n.host,r=t.drag??!0,s=t.wheel??!0,c=ye(t.invert),i=t.animate??!1,o=!1,a=!1,l=null,f=null,m=null,E={x:0,y:0},g=n.camera;function h(u){if(!(!r||o)&&m===null&&u.isPrimary!==!1){u.preventDefault(),m=u.pointerId,E={x:u.clientX,y:u.clientY},e.style.cursor="grabbing";try{u.target.setPointerCapture(u.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(a=!0)}}function G(u){if(m===null||u.pointerId!==m||!r||o)return;u.preventDefault();let C=u.clientX-E.x,A=u.clientY-E.y;E={x:u.clientX,y:u.clientY};let T=c,x=1/4*Math.PI/180;g.rotY=g.rotY-C*x*T,g.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,g.rotX+A*x*T)),n.rerender()}function M(u){if(m===u.pointerId){m=null,e.style.cursor=r&&!o?"grab":"";try{u.target.releasePointerCapture(u.pointerId)}catch{}i&&(a=!1)}}function _(u){if(!s||o)return;u.preventDefault();let C=u.deltaY*.001;g.scale=Math.max(.05,Math.min(10,g.scale*(1-C))),n.rerender()}function d(u){if(!(o||!i)){if(!a){let C=f!==null?Math.min(u-f,50):16.67,A=typeof i=="object"&&i.speed?i.speed:.3,T=typeof i=="object"&&i.axis?i.axis:"y",p=A*(Math.PI/180)*(C/16.67);T==="y"?g.rotY=g.rotY+p:g.rotX=g.rotX+p,n.rerender()}f=u,l=requestAnimationFrame(d)}}function b(){l===null&&typeof requestAnimationFrame<"u"&&i&&(l=requestAnimationFrame(d))}function v(){l!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l),l=null),f=null}function L(){e.addEventListener("pointerdown",h),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("wheel",_,{passive:!1}),e.style.cursor=r?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",h),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("wheel",_),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return L(),b(),{update(u){let C=!!i;r=u.drag??r,s=u.wheel??s,c=ye(u.invert),i=u.animate??i,!o&&m===null&&(e.style.cursor=r?"grab":"");let A=!!i;C&&!A?v():!C&&A&&b()},pause(){o||(o=!0,y(),v(),m=null,a=!1)},resume(){o&&(o=!1,L(),b())},destroy(){o||y(),v(),o=!0}}}function ye(n){return n===void 0||n===!1?1:n===!0?-1:n}var pt=typeof HTMLElement<"u"?HTMLElement:class{};function dt(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function K(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function ht(n){return n.closest("glyphcss-scene")??null}var X=class extends pt{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,r,s){r!==s&&this._controls?.update(this._readOptions())}_readOptions(){let e=K(this.getAttribute("drag")),r=K(this.getAttribute("wheel")),s=K(this.getAttribute("invert")),c=dt(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...r!==void 0?{wheel:r}:{},...s!==void 0?{invert:s}:{},...c!==void 0?{animate:{speed:c,axis:i}}:{}}}_attach(){if(this._controls)return;let e=ht(this);if(!e)return;let r=e.getScene();if(!r){let s=()=>{e.removeEventListener("glyphcss:scene-ready",s),this._attach()};e.addEventListener("glyphcss:scene-ready",s);return}this._controls=ge(r,this._readOptions())}};function ve(n,t={}){let e=n.host,r=t.drag??!0,s=t.wheel??!0,c=be(t.invert),i=t.animate??!1,o=!1,a=!1,l=null,f=null,m=null,E={x:0,y:0},g=!1,h=n.camera,G=1/4*Math.PI/180,M=.02;function _(p){if(!(!r||o)&&m===null&&p.isPrimary!==!1){p.preventDefault(),m=p.pointerId,E={x:p.clientX,y:p.clientY},g=p.button===2,e.style.cursor="grabbing";try{p.target.setPointerCapture(p.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(a=!0)}}function d(p){if(m===null||p.pointerId!==m||!r||o)return;p.preventDefault();let x=p.clientX-E.x,S=p.clientY-E.y;E={x:p.clientX,y:p.clientY};let w=c;if(g||p.shiftKey)h.rotY=h.rotY-x*G*w,h.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,h.rotX+S*G*w));else{let H=h.target;h.target=[H[0]-x*M/h.scale,H[1]-S*M/h.scale,H[2]]}n.rerender()}function b(p){if(m===p.pointerId){m=null,g=!1,e.style.cursor=r&&!o?"grab":"";try{p.target.releasePointerCapture(p.pointerId)}catch{}i&&(a=!1)}}function v(p){p.preventDefault()}function L(p){if(!s||o)return;p.preventDefault();let x=p.deltaY*.001;h.scale=Math.max(.05,Math.min(10,h.scale*(1-x))),n.rerender()}function y(p){if(!(o||!i)){if(!a){let x=f!==null?Math.min(p-f,50):16.67,S=typeof i=="object"&&i.speed?i.speed:.3,w=typeof i=="object"&&i.axis?i.axis:"y",H=S*(Math.PI/180)*(x/16.67);w==="y"?h.rotY=h.rotY+H:h.rotX=h.rotX+H,n.rerender()}f=p,l=requestAnimationFrame(y)}}function u(){l===null&&typeof requestAnimationFrame<"u"&&i&&(l=requestAnimationFrame(y))}function C(){l!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l),l=null),f=null}function A(){e.addEventListener("pointerdown",_),e.addEventListener("pointermove",d),e.addEventListener("pointerup",b),e.addEventListener("pointercancel",b),e.addEventListener("contextmenu",v),e.addEventListener("wheel",L,{passive:!1}),e.style.cursor=r?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function T(){e.removeEventListener("pointerdown",_),e.removeEventListener("pointermove",d),e.removeEventListener("pointerup",b),e.removeEventListener("pointercancel",b),e.removeEventListener("contextmenu",v),e.removeEventListener("wheel",L),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),u(),{update(p){let x=!!i;r=p.drag??r,s=p.wheel??s,c=be(p.invert),i=p.animate??i,!o&&m===null&&(e.style.cursor=r?"grab":"");let S=!!i;x&&!S?C():!x&&S&&u()},pause(){o||(o=!0,T(),C(),m=null,a=!1)},resume(){o&&(o=!1,A(),u())},destroy(){o||T(),C(),o=!0}}}function be(n){return n===void 0||n===!1?1:n===!0?-1:n}var mt=typeof HTMLElement<"u"?HTMLElement:class{};function J(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function ft(n){return n.closest("glyphcss-scene")??null}var z=class extends mt{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,r,s){r!==s&&this._controls?.update(this._readOptions())}_readOptions(){let e=J(this.getAttribute("drag")),r=J(this.getAttribute("wheel")),s=J(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...r!==void 0?{wheel:r}:{},...s!==void 0?{invert:s}:{}}}_attach(){if(this._controls)return;let e=ft(this);if(!e)return;let r=e.getScene();if(!r){let s=()=>{e.removeEventListener("glyphcss:scene-ready",s),this._attach()};e.addEventListener("glyphcss:scene-ready",s);return}this._controls=ve(r,this._readOptions())}};typeof customElements<"u"&&(customElements.get("glyphcss-scene")||customElements.define("glyphcss-scene",O),customElements.get("glyphcss-mesh")||customElements.define("glyphcss-mesh",R),customElements.get("glyphcss-hotspot")||customElements.define("glyphcss-hotspot",I),customElements.get("glyphcss-perspective-camera")||customElements.define("glyphcss-perspective-camera",Y),customElements.get("glyphcss-orthographic-camera")||customElements.define("glyphcss-orthographic-camera",F),customElements.get("glyphcss-orbit-controls")||customElements.define("glyphcss-orbit-controls",X),customElements.get("glyphcss-map-controls")||customElements.define("glyphcss-map-controls",z));0&&(module.exports={GlyphcssHotspotElement,GlyphcssMapControlsElement,GlyphcssMeshElement,GlyphcssOrbitControlsElement,GlyphcssOrthographicCameraElement,GlyphcssPerspectiveCameraElement,GlyphcssSceneElement});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { g as GlyphcssHotspotElement, j as GlyphcssMapControlsElement, k as GlyphcssMeshElement, n as GlyphcssOrbitControlsElement, o as GlyphcssOrthographicCameraElement, r as GlyphcssPerspectiveCameraElement, u as GlyphcssSceneElement } from './elements-Bb37NHHO.cjs';
|
|
2
|
+
import '@glyphcss/core';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { g as GlyphcssHotspotElement, j as GlyphcssMapControlsElement, k as GlyphcssMeshElement, n as GlyphcssOrbitControlsElement, o as GlyphcssOrthographicCameraElement, r as GlyphcssPerspectiveCameraElement, u as GlyphcssSceneElement } from './elements-Bb37NHHO.js';
|
|
2
|
+
import '@glyphcss/core';
|