glyphcss 0.0.6 → 0.0.7
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/dist/elements.cjs +5 -5
- package/dist/elements.d.cts +14 -1
- package/dist/elements.d.ts +14 -1
- package/dist/elements.js +5 -5
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +91 -23
- package/dist/index.d.ts +91 -23
- package/dist/index.js +5 -5
- package/package.json +2 -2
- /package/dist/{elements-ycVyIlYL.d.cts → GlyphMapControlsElement-ycVyIlYL.d.cts} +0 -0
- /package/dist/{elements-ycVyIlYL.d.ts → GlyphMapControlsElement-ycVyIlYL.d.ts} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,45 @@
|
|
|
1
|
-
import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight, d as GlyphShadowOptions } from './
|
|
2
|
-
export { D as DEFAULT_PERSPECTIVE, e as GlyphHotspotElement, f as GlyphHotspotHandle, g as GlyphHotspotOptions, h as GlyphMapControlsElement, i as GlyphMeshElement, j as GlyphMeshHandle, k as GlyphMeshTransform, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, n as GlyphOrthographicCameraHandle, o as GlyphOrthographicCameraOptions, p as GlyphPerspectiveCameraElement, q as GlyphPerspectiveCameraHandle, r as GlyphPerspectiveCameraOptions, s as GlyphSceneElement, t as GlyphSceneOptions, u as createGlyphCamera, v as createGlyphOrthographicCamera, w as createGlyphPerspectiveCamera, x as createGlyphScene } from './
|
|
3
|
-
import { Hotspot, HotspotCell, GridSize, Polygon, WireframeEdge, RenderMode, TextureSampler, CharRamp } from '@glyphcss/core';
|
|
1
|
+
import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight, d as GlyphShadowOptions } from './GlyphMapControlsElement-ycVyIlYL.cjs';
|
|
2
|
+
export { D as DEFAULT_PERSPECTIVE, e as GlyphHotspotElement, f as GlyphHotspotHandle, g as GlyphHotspotOptions, h as GlyphMapControlsElement, i as GlyphMeshElement, j as GlyphMeshHandle, k as GlyphMeshTransform, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, n as GlyphOrthographicCameraHandle, o as GlyphOrthographicCameraOptions, p as GlyphPerspectiveCameraElement, q as GlyphPerspectiveCameraHandle, r as GlyphPerspectiveCameraOptions, s as GlyphSceneElement, t as GlyphSceneOptions, u as createGlyphCamera, v as createGlyphOrthographicCamera, w as createGlyphPerspectiveCamera, x as createGlyphScene } from './GlyphMapControlsElement-ycVyIlYL.cjs';
|
|
3
|
+
import { Vec3, Hotspot, HotspotCell, GridSize, Polygon, WireframeEdge, RenderMode, TextureSampler, CharRamp } from '@glyphcss/core';
|
|
4
4
|
export * from '@glyphcss/core';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Shared controls event surface — mirrors voxcss `controls/common.ts`'s event
|
|
8
|
+
* pieces (the camera snapshot + `change`/`start`/`end` listener registry). The
|
|
9
|
+
* wheel/anim/options helpers are inlined per-control in glyphcss, so only the
|
|
10
|
+
* event types + registry live here. Used by orbit / map / first-person controls.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface GlyphControlsCamera {
|
|
14
|
+
rotX: number;
|
|
15
|
+
rotY: number;
|
|
16
|
+
zoom: number;
|
|
17
|
+
target: Vec3;
|
|
18
|
+
distance: number;
|
|
19
|
+
}
|
|
20
|
+
interface GlyphControlsChangeEvent {
|
|
21
|
+
type: "change";
|
|
22
|
+
camera: GlyphControlsCamera;
|
|
23
|
+
}
|
|
24
|
+
interface GlyphControlsInteractionEvent {
|
|
25
|
+
type: "start" | "end";
|
|
26
|
+
camera: GlyphControlsCamera;
|
|
27
|
+
}
|
|
28
|
+
type GlyphControlsEvent = GlyphControlsChangeEvent | GlyphControlsInteractionEvent;
|
|
29
|
+
type GlyphControlsListener<E extends GlyphControlsEvent = GlyphControlsEvent> = (event: E) => void;
|
|
30
|
+
/** Methods every control handle exposes for `change`/`start`/`end` subscription. */
|
|
31
|
+
interface GlyphControlsEventTarget {
|
|
32
|
+
addEventListener<T extends GlyphControlsEvent["type"]>(type: T, listener: GlyphControlsListener<Extract<GlyphControlsEvent, {
|
|
33
|
+
type: T;
|
|
34
|
+
}>>): void;
|
|
35
|
+
removeEventListener<T extends GlyphControlsEvent["type"]>(type: T, listener: GlyphControlsListener<Extract<GlyphControlsEvent, {
|
|
36
|
+
type: T;
|
|
37
|
+
}>>): void;
|
|
38
|
+
hasEventListener<T extends GlyphControlsEvent["type"]>(type: T, listener: GlyphControlsListener<Extract<GlyphControlsEvent, {
|
|
39
|
+
type: T;
|
|
40
|
+
}>>): boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
6
43
|
/**
|
|
7
44
|
* createGlyphOrbitControls — orbit-mode camera input for a GlyphScene.
|
|
8
45
|
*
|
|
@@ -35,7 +72,7 @@ interface GlyphOrbitControlsOptions {
|
|
|
35
72
|
pauseOnInteraction?: boolean;
|
|
36
73
|
};
|
|
37
74
|
}
|
|
38
|
-
interface GlyphOrbitControlsHandle {
|
|
75
|
+
interface GlyphOrbitControlsHandle extends GlyphControlsEventTarget {
|
|
39
76
|
update(opts: GlyphOrbitControlsOptions): void;
|
|
40
77
|
pause(): void;
|
|
41
78
|
resume(): void;
|
|
@@ -65,7 +102,7 @@ interface GlyphMapControlsOptions {
|
|
|
65
102
|
pauseOnInteraction?: boolean;
|
|
66
103
|
};
|
|
67
104
|
}
|
|
68
|
-
interface GlyphMapControlsHandle {
|
|
105
|
+
interface GlyphMapControlsHandle extends GlyphControlsEventTarget {
|
|
69
106
|
update(opts: GlyphMapControlsOptions): void;
|
|
70
107
|
pause(): void;
|
|
71
108
|
resume(): void;
|
|
@@ -76,31 +113,62 @@ declare function createGlyphMapControls(scene: GlyphSceneHandle, options?: Glyph
|
|
|
76
113
|
/**
|
|
77
114
|
* createGlyphFirstPersonControls — first-person camera input for a GlyphScene.
|
|
78
115
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* detach, restores `eyeMode = false`.
|
|
83
|
-
*
|
|
84
|
-
* Mouse-drag looks around (rotX/rotY). WASD or arrow keys move forward/backward/strafe.
|
|
116
|
+
* Mouselook on pointer-lock, WASD/arrow planar move in the yaw-aligned XY
|
|
117
|
+
* plane, Space jump (parametric arc, no collision), Ctrl crouch. Each input
|
|
118
|
+
* axis is independently toggleable.
|
|
85
119
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
120
|
+
* Requires a perspective camera; sets `camera.eyeMode = true` on attach (the
|
|
121
|
+
* camera projects from `target` along rotX/rotY) and restores it on detach.
|
|
122
|
+
* rotX/rotY are in DEGREES (three.js / voxcss convention).
|
|
89
123
|
*/
|
|
90
124
|
|
|
91
125
|
interface GlyphFirstPersonControlsOptions {
|
|
92
|
-
|
|
93
|
-
|
|
126
|
+
/** Master switch. When `false`, all sub-controls are inert. Default: `true`. */
|
|
127
|
+
enabled?: boolean;
|
|
128
|
+
/** Pointer-lock mouselook (rotX = pitch, rotY = yaw). Default: `true`. */
|
|
129
|
+
lookEnabled?: boolean;
|
|
130
|
+
/** WASD / arrow-key planar movement on world XY. Default: `true`. */
|
|
131
|
+
moveEnabled?: boolean;
|
|
132
|
+
/** Space-bar parametric jump arc on world Z. Default: `true`. */
|
|
133
|
+
jumpEnabled?: boolean;
|
|
134
|
+
/** Ctrl crouch (lowers eye height while held). Default: `true`. */
|
|
135
|
+
crouchEnabled?: boolean;
|
|
136
|
+
/** Mouselook sensitivity in degrees per pixel. Default: `0.15`. */
|
|
137
|
+
lookSensitivity?: number;
|
|
138
|
+
/** Invert vertical mouselook. Default: `false`. */
|
|
139
|
+
invertY?: boolean;
|
|
140
|
+
/** Movement speed in world units per second. Default: `5`. */
|
|
94
141
|
moveSpeed?: number;
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
142
|
+
/** Initial vertical velocity for a jump, world units per second. Default: `7`. */
|
|
143
|
+
jumpVelocity?: number;
|
|
144
|
+
/** Gravity acceleration in world units per second squared. Default: `18`. */
|
|
145
|
+
gravity?: number;
|
|
146
|
+
/** Standing eye height above the ground plane (target.z). Default: `1.7`. */
|
|
147
|
+
eyeHeight?: number;
|
|
148
|
+
/** Eye height while crouching. Default: `1`. */
|
|
149
|
+
crouchHeight?: number;
|
|
150
|
+
/** World Z of the ground plane the player walks on. Default: `0`. */
|
|
151
|
+
groundZ?: number;
|
|
152
|
+
/** Min pitch (rotX) angle. Default: `5`. */
|
|
153
|
+
minPitch?: number;
|
|
154
|
+
/** Max pitch (rotX) angle. Default: `175`. */
|
|
155
|
+
maxPitch?: number;
|
|
98
156
|
}
|
|
99
|
-
interface GlyphFirstPersonControlsHandle {
|
|
100
|
-
update(
|
|
101
|
-
pause(): void;
|
|
157
|
+
interface GlyphFirstPersonControlsHandle extends GlyphControlsEventTarget {
|
|
158
|
+
update(partial: GlyphFirstPersonControlsOptions): void;
|
|
102
159
|
resume(): void;
|
|
160
|
+
pause(): void;
|
|
103
161
|
destroy(): void;
|
|
162
|
+
/** Request pointer-lock now. Call from a user gesture (click). */
|
|
163
|
+
lock(): void;
|
|
164
|
+
/** Release pointer-lock. */
|
|
165
|
+
unlock(): void;
|
|
166
|
+
/** Whether pointer-lock is currently held. */
|
|
167
|
+
isLocked(): boolean;
|
|
168
|
+
/** The camera's WORLD position (the eye). Mutated via WASD / jump / crouch. */
|
|
169
|
+
getOrigin(): [number, number, number];
|
|
170
|
+
/** Teleport the camera eye to a world position (e.g. spawn at a chosen spot). */
|
|
171
|
+
setOrigin(origin: [number, number, number]): void;
|
|
104
172
|
}
|
|
105
173
|
declare function createGlyphFirstPersonControls(scene: GlyphSceneHandle, options?: GlyphFirstPersonControlsOptions): GlyphFirstPersonControlsHandle;
|
|
106
174
|
|
|
@@ -367,4 +435,4 @@ declare function getWireframeGlyphs(name: string): WireframeGlyphTiers;
|
|
|
367
435
|
|
|
368
436
|
declare function injectGlyphBaseStyles(doc?: Document): void;
|
|
369
437
|
|
|
370
|
-
export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, GlyphShadowOptions, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };
|
|
438
|
+
export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, type GlyphControlsCamera, type GlyphControlsChangeEvent, type GlyphControlsEvent, type GlyphControlsEventTarget, type GlyphControlsInteractionEvent, type GlyphControlsListener, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, GlyphShadowOptions, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,45 @@
|
|
|
1
|
-
import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight, d as GlyphShadowOptions } from './
|
|
2
|
-
export { D as DEFAULT_PERSPECTIVE, e as GlyphHotspotElement, f as GlyphHotspotHandle, g as GlyphHotspotOptions, h as GlyphMapControlsElement, i as GlyphMeshElement, j as GlyphMeshHandle, k as GlyphMeshTransform, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, n as GlyphOrthographicCameraHandle, o as GlyphOrthographicCameraOptions, p as GlyphPerspectiveCameraElement, q as GlyphPerspectiveCameraHandle, r as GlyphPerspectiveCameraOptions, s as GlyphSceneElement, t as GlyphSceneOptions, u as createGlyphCamera, v as createGlyphOrthographicCamera, w as createGlyphPerspectiveCamera, x as createGlyphScene } from './
|
|
3
|
-
import { Hotspot, HotspotCell, GridSize, Polygon, WireframeEdge, RenderMode, TextureSampler, CharRamp } from '@glyphcss/core';
|
|
1
|
+
import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight, d as GlyphShadowOptions } from './GlyphMapControlsElement-ycVyIlYL.js';
|
|
2
|
+
export { D as DEFAULT_PERSPECTIVE, e as GlyphHotspotElement, f as GlyphHotspotHandle, g as GlyphHotspotOptions, h as GlyphMapControlsElement, i as GlyphMeshElement, j as GlyphMeshHandle, k as GlyphMeshTransform, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, n as GlyphOrthographicCameraHandle, o as GlyphOrthographicCameraOptions, p as GlyphPerspectiveCameraElement, q as GlyphPerspectiveCameraHandle, r as GlyphPerspectiveCameraOptions, s as GlyphSceneElement, t as GlyphSceneOptions, u as createGlyphCamera, v as createGlyphOrthographicCamera, w as createGlyphPerspectiveCamera, x as createGlyphScene } from './GlyphMapControlsElement-ycVyIlYL.js';
|
|
3
|
+
import { Vec3, Hotspot, HotspotCell, GridSize, Polygon, WireframeEdge, RenderMode, TextureSampler, CharRamp } from '@glyphcss/core';
|
|
4
4
|
export * from '@glyphcss/core';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Shared controls event surface — mirrors voxcss `controls/common.ts`'s event
|
|
8
|
+
* pieces (the camera snapshot + `change`/`start`/`end` listener registry). The
|
|
9
|
+
* wheel/anim/options helpers are inlined per-control in glyphcss, so only the
|
|
10
|
+
* event types + registry live here. Used by orbit / map / first-person controls.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface GlyphControlsCamera {
|
|
14
|
+
rotX: number;
|
|
15
|
+
rotY: number;
|
|
16
|
+
zoom: number;
|
|
17
|
+
target: Vec3;
|
|
18
|
+
distance: number;
|
|
19
|
+
}
|
|
20
|
+
interface GlyphControlsChangeEvent {
|
|
21
|
+
type: "change";
|
|
22
|
+
camera: GlyphControlsCamera;
|
|
23
|
+
}
|
|
24
|
+
interface GlyphControlsInteractionEvent {
|
|
25
|
+
type: "start" | "end";
|
|
26
|
+
camera: GlyphControlsCamera;
|
|
27
|
+
}
|
|
28
|
+
type GlyphControlsEvent = GlyphControlsChangeEvent | GlyphControlsInteractionEvent;
|
|
29
|
+
type GlyphControlsListener<E extends GlyphControlsEvent = GlyphControlsEvent> = (event: E) => void;
|
|
30
|
+
/** Methods every control handle exposes for `change`/`start`/`end` subscription. */
|
|
31
|
+
interface GlyphControlsEventTarget {
|
|
32
|
+
addEventListener<T extends GlyphControlsEvent["type"]>(type: T, listener: GlyphControlsListener<Extract<GlyphControlsEvent, {
|
|
33
|
+
type: T;
|
|
34
|
+
}>>): void;
|
|
35
|
+
removeEventListener<T extends GlyphControlsEvent["type"]>(type: T, listener: GlyphControlsListener<Extract<GlyphControlsEvent, {
|
|
36
|
+
type: T;
|
|
37
|
+
}>>): void;
|
|
38
|
+
hasEventListener<T extends GlyphControlsEvent["type"]>(type: T, listener: GlyphControlsListener<Extract<GlyphControlsEvent, {
|
|
39
|
+
type: T;
|
|
40
|
+
}>>): boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
6
43
|
/**
|
|
7
44
|
* createGlyphOrbitControls — orbit-mode camera input for a GlyphScene.
|
|
8
45
|
*
|
|
@@ -35,7 +72,7 @@ interface GlyphOrbitControlsOptions {
|
|
|
35
72
|
pauseOnInteraction?: boolean;
|
|
36
73
|
};
|
|
37
74
|
}
|
|
38
|
-
interface GlyphOrbitControlsHandle {
|
|
75
|
+
interface GlyphOrbitControlsHandle extends GlyphControlsEventTarget {
|
|
39
76
|
update(opts: GlyphOrbitControlsOptions): void;
|
|
40
77
|
pause(): void;
|
|
41
78
|
resume(): void;
|
|
@@ -65,7 +102,7 @@ interface GlyphMapControlsOptions {
|
|
|
65
102
|
pauseOnInteraction?: boolean;
|
|
66
103
|
};
|
|
67
104
|
}
|
|
68
|
-
interface GlyphMapControlsHandle {
|
|
105
|
+
interface GlyphMapControlsHandle extends GlyphControlsEventTarget {
|
|
69
106
|
update(opts: GlyphMapControlsOptions): void;
|
|
70
107
|
pause(): void;
|
|
71
108
|
resume(): void;
|
|
@@ -76,31 +113,62 @@ declare function createGlyphMapControls(scene: GlyphSceneHandle, options?: Glyph
|
|
|
76
113
|
/**
|
|
77
114
|
* createGlyphFirstPersonControls — first-person camera input for a GlyphScene.
|
|
78
115
|
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* detach, restores `eyeMode = false`.
|
|
83
|
-
*
|
|
84
|
-
* Mouse-drag looks around (rotX/rotY). WASD or arrow keys move forward/backward/strafe.
|
|
116
|
+
* Mouselook on pointer-lock, WASD/arrow planar move in the yaw-aligned XY
|
|
117
|
+
* plane, Space jump (parametric arc, no collision), Ctrl crouch. Each input
|
|
118
|
+
* axis is independently toggleable.
|
|
85
119
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
120
|
+
* Requires a perspective camera; sets `camera.eyeMode = true` on attach (the
|
|
121
|
+
* camera projects from `target` along rotX/rotY) and restores it on detach.
|
|
122
|
+
* rotX/rotY are in DEGREES (three.js / voxcss convention).
|
|
89
123
|
*/
|
|
90
124
|
|
|
91
125
|
interface GlyphFirstPersonControlsOptions {
|
|
92
|
-
|
|
93
|
-
|
|
126
|
+
/** Master switch. When `false`, all sub-controls are inert. Default: `true`. */
|
|
127
|
+
enabled?: boolean;
|
|
128
|
+
/** Pointer-lock mouselook (rotX = pitch, rotY = yaw). Default: `true`. */
|
|
129
|
+
lookEnabled?: boolean;
|
|
130
|
+
/** WASD / arrow-key planar movement on world XY. Default: `true`. */
|
|
131
|
+
moveEnabled?: boolean;
|
|
132
|
+
/** Space-bar parametric jump arc on world Z. Default: `true`. */
|
|
133
|
+
jumpEnabled?: boolean;
|
|
134
|
+
/** Ctrl crouch (lowers eye height while held). Default: `true`. */
|
|
135
|
+
crouchEnabled?: boolean;
|
|
136
|
+
/** Mouselook sensitivity in degrees per pixel. Default: `0.15`. */
|
|
137
|
+
lookSensitivity?: number;
|
|
138
|
+
/** Invert vertical mouselook. Default: `false`. */
|
|
139
|
+
invertY?: boolean;
|
|
140
|
+
/** Movement speed in world units per second. Default: `5`. */
|
|
94
141
|
moveSpeed?: number;
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
142
|
+
/** Initial vertical velocity for a jump, world units per second. Default: `7`. */
|
|
143
|
+
jumpVelocity?: number;
|
|
144
|
+
/** Gravity acceleration in world units per second squared. Default: `18`. */
|
|
145
|
+
gravity?: number;
|
|
146
|
+
/** Standing eye height above the ground plane (target.z). Default: `1.7`. */
|
|
147
|
+
eyeHeight?: number;
|
|
148
|
+
/** Eye height while crouching. Default: `1`. */
|
|
149
|
+
crouchHeight?: number;
|
|
150
|
+
/** World Z of the ground plane the player walks on. Default: `0`. */
|
|
151
|
+
groundZ?: number;
|
|
152
|
+
/** Min pitch (rotX) angle. Default: `5`. */
|
|
153
|
+
minPitch?: number;
|
|
154
|
+
/** Max pitch (rotX) angle. Default: `175`. */
|
|
155
|
+
maxPitch?: number;
|
|
98
156
|
}
|
|
99
|
-
interface GlyphFirstPersonControlsHandle {
|
|
100
|
-
update(
|
|
101
|
-
pause(): void;
|
|
157
|
+
interface GlyphFirstPersonControlsHandle extends GlyphControlsEventTarget {
|
|
158
|
+
update(partial: GlyphFirstPersonControlsOptions): void;
|
|
102
159
|
resume(): void;
|
|
160
|
+
pause(): void;
|
|
103
161
|
destroy(): void;
|
|
162
|
+
/** Request pointer-lock now. Call from a user gesture (click). */
|
|
163
|
+
lock(): void;
|
|
164
|
+
/** Release pointer-lock. */
|
|
165
|
+
unlock(): void;
|
|
166
|
+
/** Whether pointer-lock is currently held. */
|
|
167
|
+
isLocked(): boolean;
|
|
168
|
+
/** The camera's WORLD position (the eye). Mutated via WASD / jump / crouch. */
|
|
169
|
+
getOrigin(): [number, number, number];
|
|
170
|
+
/** Teleport the camera eye to a world position (e.g. spawn at a chosen spot). */
|
|
171
|
+
setOrigin(origin: [number, number, number]): void;
|
|
104
172
|
}
|
|
105
173
|
declare function createGlyphFirstPersonControls(scene: GlyphSceneHandle, options?: GlyphFirstPersonControlsOptions): GlyphFirstPersonControlsHandle;
|
|
106
174
|
|
|
@@ -367,4 +435,4 @@ declare function getWireframeGlyphs(name: string): WireframeGlyphTiers;
|
|
|
367
435
|
|
|
368
436
|
declare function injectGlyphBaseStyles(doc?: Document): void;
|
|
369
437
|
|
|
370
|
-
export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, GlyphShadowOptions, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };
|
|
438
|
+
export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, type GlyphControlsCamera, type GlyphControlsChangeEvent, type GlyphControlsEvent, type GlyphControlsEventTarget, type GlyphControlsInteractionEvent, type GlyphControlsListener, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, GlyphShadowOptions, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{buildTextureSamplers as wn}from"@glyphcss/core";var zt=Math.PI/180,Ht=.01,Ft=32e3,Zt=Ht*1.01;function ct(n,t,e){let o=n[1],r=n[0],i=n[2],l=e*zt,s=Math.cos(l),c=Math.sin(l),u=o*s-r*c,p=o*c+r*s,d=i,h=t*zt,m=Math.cos(h),f=Math.sin(h),v=p*m-d*f,C=p*f+d*m;return[u,v,C]}function Pe(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??Ft,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let i=ct([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),l=.001*1.01;if(t.eyeMode)return-i[2]-l;if(t.perspective>0){let s=i[2]*t.zoom*50-t.distance;return t.perspective-s-t.perspective*Zt}return t.distance-i[2]-l},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=ct(p,t.rotX,t.rotY);if(t.eyeMode){if(d[2]>=-.001)return[NaN,NaN,d[2],NaN];let b=t.focal/-d[2],S=d[0]*b*t.zoom*50,P=d[1]*b*t.zoom*50,y=i*e+S/u*t.stretch,E=l*o+P/50;return[y,E,d[2],-1/d[2]]}if(t.perspective>0){let M=t.perspective,b=d[0]*t.zoom*50,S=d[1]*t.zoom*50,P=d[2]*t.zoom*50-t.distance,y=M-P,E=M*Ht;if(y<E)return[NaN,NaN,P,NaN];let A=M/y,L=i*e+b*A/u*t.stretch*t.fovScale,a=l*o+S*A/50*t.fovScale;return[L,a,P,1/y]}let h=.001,m=t.distance-d[2];if(m<h)return[NaN,NaN,d[2],NaN];let f=t.distance/m,v=d[0]*f*t.zoom*50,C=d[1]*f*t.zoom*50,T=i*e+v/u*t.stretch*t.fovScale,G=l*o+C/50*t.fovScale;return[T,G,d[2],1/m]}}}function qe(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,i,l,s){let u=50/s,p=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],d=ct(p,t.rotX,t.rotY),h=d[0]*t.zoom*50,m=d[1]*t.zoom*50,f=i*e+h/u*t.fovScale,v=l*o+m/50*t.fovScale;return[f,v,d[2]]}}}var Jt=qe;var Qt={direction:[-.5,-.7,-.5],intensity:1},en={intensity:.4};function tn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let i=0;i<r.length;i++){let l=r[i],s=r[(i+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${s[0]},${s[1]},${s[2]}`,p=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(p))continue;t.add(p);let d={from:l,to:s,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function ut(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?tn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??Qt,ambientLight:n.ambientLight??en,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}import{sampleTexel as sn,polygonTexture as ln}from"@glyphcss/core";var nn=" .:-=+*#%@".split(""),rn=" .:-=+*#%@".split(""),Ue={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("")}},on=Ue.default;function Ke(n){return Ue[n]??Ue.default}function Ze(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:i,rows:l,cellAspect:s}=e;if(r==="solid"){let d=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return an(n,i,l,s,d)}let c=Ke(n.glyphPalette),u=new Uint8Array(i*l),p=n.useColors?new Array(i*l).fill(null):null;for(let d of o){let h=t.project(d.from,i,l,s),m=t.project(d.to,i,l,s);h[0]!==h[0]||m[0]!==m[0]||gn(u,p,h[0]|0,h[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,i,l)}return bn(u,p,i,l,c)}function an(n,t,e,o,r){let i=t*r,l=e*r,{camera:s,polygons:c,directionalLight:u,ambientLight:p,smoothShading:d,creaseAngle:h,doubleSided:m,castShadowFlags:f,receiveShadowFlags:v}=n,C=n.depthBiases,T=n.depthEpsilon??0,G=r>1?{zoom:s.zoom,eyeDepth:R=>s.eyeDepth(R),project:(R,V,X,D)=>{let x=s.project(R,V,X,D);return[V*.5+(x[0]-V*.5)*r,X*.5+(x[1]-X*.5)*r,x[2],x[3]]}}:s,M=Ke(n.glyphPalette).solid,b=M.length-1,S=new Array(i*l).fill(" "),P=n.useColors,y=P?new Array(i*l).fill(null):null,E=new Float64Array(i*l).fill(-1/0),A=n.temporalBlend>0&&!!n.temporalHistory,L=A?new Float32Array(i*l*3).fill(NaN):null,a=u.direction,w=Math.hypot(a[0],a[1],a[2])||1,g=a[0]/w,_=a[1]/w,H=a[2]/w,F=u.intensity??1,z=p.intensity??.4,W=ze(u.color??"#ffffff"),B=ze(p.color??"#ffffff"),j=d&&h>0?mn(c,h):null,k=new Map,re=n.textureSamplers??null,N=n.shadow,q=N!=null&&f.length>0?hn(c,f,g,_,H):null,oe=N?.opacity??.25,K=N?.lift??.05,Z=N?.color??"#000000",ie=q?ze(Z):[0,0,0],I=globalThis.__glyphPerfDetail,Ye=I?performance.now():0,ye=[],J=n.shadeCache??null,Q=-1,ve=(R,V,X,D)=>{if(q===null||!D)return null;let x=q,O=Ie(R,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax),ee=Ie(V,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax),de=Ie(X,x.right[0],x.right[1],x.right[2],x.up[0],x.up[1],x.up[2],x.dir[0],x.dir[1],x.dir[2],x.uMin,x.uMax,x.vMin,x.vMax);return{map:x,luA:O[0],lvA:O[1],ldA:O[2],luB:ee[0],lvB:ee[1],ldB:ee[2],luC:de[0],lvC:de[1],ldC:de[2],lift:K,opacity:oe,shadowColorRgb:ie,shadowColorHex:Z,litCache:k}};for(let R=0;R<c.length;R++){let V=c[R],X=V.vertices;if(X.length<3)continue;let D=V.uvs,x=null;if(re!==null&&D&&D.length>=X.length){let O=ln(V);O&&(x=re.get(O)??null)}for(let O=0;O<X.length;O++)ye[O]=G.project(X[O],i,l,o);for(let O=1;O<X.length-1;O++){Q++;let ee=0,de=O,Ee=O+1,se=X[ee],pe=X[de],we=X[Ee],ae=ye[ee],ge=ye[de],xe=ye[Ee],et=(ae[0]!==ae[0]?1:0)+(ge[0]!==ge[0]?1:0)+(xe[0]!==xe[0]?1:0);if(et===3||et===0&&!m&&(ge[0]-ae[0])*(xe[1]-ae[1])-(ge[1]-ae[1])*(xe[0]-ae[0])>0)continue;let Ge,Le,Te,Be=null;if(J!==null&&J.iA[Q]!==void 0)Ge=J.iA[Q],Le=J.iB[Q],Te=J.iC[Q],Be=J.lit[Q];else{let $=pe[0]-se[0],he=pe[1]-se[1],Ae=pe[2]-se[2],me=we[0]-se[0],Xe=we[1]-se[1],$e=we[2]-se[2],We=he*$e-Ae*Xe,ke=Ae*me-$*$e,U=$*Xe-he*me,Y=Math.hypot(We,ke,U)||1,te=We/Y,fe=ke/Y,le=U/Y,ce,_e,tt,nt,rt,ot,it,st,lt;if(j){let Ne=j[R],Ce=Ne[ee],Oe=Ne[de],De=Ne[Ee];ce=Ce[0],_e=Ce[1],tt=Ce[2],nt=Oe[0],rt=Oe[1],ot=Oe[2],it=De[0],st=De[1],lt=De[2]}else ce=nt=it=te,_e=rt=st=fe,tt=ot=lt=le;let Lt=ce*g+_e*_+tt*H,Tt=nt*g+rt*_+ot*H,_t=it*g+st*_+lt*H,Yt=m?Math.abs(Lt):Math.max(0,-Lt),Vt=m?Math.abs(Tt):Math.max(0,-Tt),Xt=m?Math.abs(_t):Math.max(0,-_t);if(Ge=Math.min(1,z+Yt*F),Le=Math.min(1,z+Vt*F),Te=Math.min(1,z+Xt*F),P){let Ne=(Ge+Le+Te)/3,Ce=Math.max(0,Ne-z),Oe=V.color??"#ffffff",De=Ce*255|0,Pt=`${Oe}:${De}`,je=k.get(Pt);if(je===void 0){let at=ze(Oe),$t=z*B[0]/255+Ce*W[0]/255,Wt=z*B[1]/255+Ce*W[1]/255,jt=z*B[2]/255+Ce*W[2]/255,qt=Math.min(255,at[0]*$t),Ut=Math.min(255,at[1]*Wt),Kt=Math.min(255,at[2]*jt);je=`#${ne(qt)}${ne(Ut)}${ne(Kt)}`,k.set(Pt,je)}Be=je}J!==null&&(J.iA[Q]=Ge,J.iB[Q]=Le,J.iC[Q]=Te,J.lit[Q]=Be)}let Mt=v[R]??!1,Fe=1+(C?.[R]??0),Gt=null;if(x!==null&&D){let $=D[ee],he=D[de],Ae=D[Ee],me=Math.max(0,(Ge+Le+Te)/3-z);Gt={sampler:x,ua:$[0],va:$[1],ub:he[0],vb:he[1],uc:Ae[0],vc:Ae[1],tintR:z*B[0]/255+me*W[0]/255,tintG:z*B[1]/255+me*W[1]/255,tintB:z*B[2]/255+me*W[2]/255}}if(et===0)Ot(ae[0],ae[1],(ae[3]??ae[2])*Fe,Ge,ge[0],ge[1],(ge[3]??ge[2])*Fe,Le,xe[0],xe[1],(xe[3]??xe[2])*Fe,Te,M,b,Be,S,y,E,i,l,ve(se,pe,we,Mt),m,se,pe,we,L,T,Gt);else{let $=[],he=[],Ae=[se,pe,we],me=[Ge,Le,Te],Xe=G.eyeDepth(se),$e=G.eyeDepth(pe),We=G.eyeDepth(we),ke=[Xe,$e,We];for(let U=0;U<3;U++){let Y=(U+1)%3,te=ke[U],fe=ke[Y];if(te>0&&($.push(Ae[U]),he.push(me[U])),te>0!=fe>0){let le=te/(te-fe),ce=Ae[U],_e=Ae[Y];$.push([ce[0]+le*(_e[0]-ce[0]),ce[1]+le*(_e[1]-ce[1]),ce[2]+le*(_e[2]-ce[2])]),he.push(me[U]+le*(me[Y]-me[U]))}}if($.length>=3){let U=$.map(Y=>G.project(Y,i,l,o));for(let Y=1;Y<$.length-1;Y++){let te=U[0],fe=U[Y],le=U[Y+1],ce=(fe[0]-te[0])*(le[1]-te[1])-(fe[1]-te[1])*(le[0]-te[0]);!m&&ce>0||Ot(te[0],te[1],(te[3]??te[2])*Fe,he[0],fe[0],fe[1],(fe[3]??fe[2])*Fe,he[Y],le[0],le[1],(le[3]??le[2])*Fe,he[Y+1],M,b,Be,S,y,E,i,l,ve($[0],$[Y],$[Y+1],Mt),m,$[0],$[Y],$[Y+1],L,T,null)}}}}}I&&(I.loop??(I.loop=[])).push(performance.now()-Ye);let Ct=I?performance.now():0,He=S,Se=y,Ve=L;if(r>1){let R=un(S,y,E,L,t,e,r,M);He=R.glyphBuf,Se=R.colorBuf,Ve=R.worldPos}A&&cn(He,Se,Ve,t,e,o,M,n.temporalBlend,n.temporalHistory,s);let Qe=fn(He,Se,t,e);return I&&(I.string??(I.string=[])).push(performance.now()-Ct),Qe}function cn(n,t,e,o,r,i,l,s,c,u){let p=o*r,d=l.length-1,h=new Map;for(let M=0;M<l.length;M++)h.set(l[M],M);let m=c.cam;(c.cols!==o||c.rows!==r||c.idx.length!==p)&&(c.cols=o,c.rows=r,c.idx=new Float32Array(p),c.r=new Float32Array(p),c.g=new Float32Array(p),c.b=new Float32Array(p),m=null);let f=null;if(m){let M=Pe({rotX:m.rotX,rotY:m.rotY,distance:m.distance,perspective:m.perspective,zoom:m.zoom,stretch:m.stretch});M.target=m.target,f=b=>M.project(b,o,r,i)}let v=new Float32Array(p),C=new Float32Array(p),T=new Float32Array(p),G=new Float32Array(p);for(let M=0;M<r;M++)for(let b=0;b<o;b++){let S=M*o+b,P=h.get(n[S])??0,y=0,E=0,A=0,L=t?t[S]:null;if(L){let N=ze(L);y=N[0],E=N[1],A=N[2]}let a=0,w=0,g=0,_=0,H=0,F=e[S*3];if(f&&F===F){let N=f([F,e[S*3+1],e[S*3+2]]),q=Math.round(N[0]),oe=Math.round(N[1]);if(N[0]===N[0]&&q>=0&&q<o&&oe>=0&&oe<r){let K=oe*o+q;w=c.idx[K],g=c.r[K],_=c.g[K],H=c.b[K],a=s}}let z=1-a,W=z*P+a*w,B=z*y+a*g,j=z*E+a*_,k=z*A+a*H;v[S]=W,C[S]=B,T[S]=j,G[S]=k;let re=Math.round(W);re<0?re=0:re>d&&(re=d),n[S]=l[re],t&&(t[S]=re===0?null:`#${ne(B)}${ne(j)}${ne(k)}`)}c.idx=v,c.r=C,c.g=T,c.b=G,c.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function un(n,t,e,o,r,i,l,s){let c=new Map;for(let v=0;v<s.length;v++)c.set(s[v],v);let u=s.length-1,p=r*l,d=new Array(r*i).fill(" "),h=t?new Array(r*i).fill(null):null,m=o?new Float32Array(r*i*3).fill(NaN):null,f=1/(l*l);for(let v=0;v<i;v++)for(let C=0;C<r;C++){let T=0,G=0,M=0,b=0,S=0,P=0,y=0,E=0;for(let a=0;a<l;a++){let w=(v*l+a)*p+C*l;for(let g=0;g<l;g++){let _=w+g;if(e[_]!==-1/0){if(T+=c.get(n[_])??0,G++,h){let H=t[_];if(H){let F=ze(H);M+=F[0],b+=F[1],S+=F[2]}}m&&(P+=o[_*3],y+=o[_*3+1],E+=o[_*3+2])}}}let A=v*r+C;if(G===0)continue;let L=Math.round(T*f);L<0?L=0:L>u&&(L=u),d[A]=s[L],h&&(h[A]=`#${ne(M/G)}${ne(b/G)}${ne(S/G)}`),m&&(m[A*3]=P/G,m[A*3+1]=y/G,m[A*3+2]=E/G)}return{glyphBuf:d,colorBuf:h,worldPos:m}}var dn=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Ie(n,t,e,o,r,i,l,s,c,u,p,d,h,m){let f=t*n[0]+e*n[1]+o*n[2],v=r*n[0]+i*n[1]+l*n[2],C=-(s*n[0]+c*n[1]+u*n[2]),T=(f-p)/(d-p)*(be-1),G=(v-h)/(m-h)*(be-1);return[T,G,C]}function pn(n,t,e,o){let r=t[0],i=t[1],l=t[2],s=e[0],c=e[1],u=e[2],p=o[0],d=o[1],h=o[2],m=(s-r)*(d-i)-(c-i)*(p-r);if(m===0)return;let f=1/m,v=r<s?r:s;p<v&&(v=p);let C=r>s?r:s;p>C&&(C=p);let T=i<c?i:c;d<T&&(T=d);let G=i>c?i:c;d>G&&(G=d);let M=Math.max(0,Math.ceil(v)),b=Math.min(be-1,Math.floor(C)),S=Math.max(0,Math.ceil(T)),P=Math.min(be-1,Math.floor(G));if(M>b||S>P)return;let y=m>0;for(let E=S;E<=P;E++)for(let A=M;A<=b;A++){let L=A,a=E,w=(s-L)*(d-a)-(c-a)*(p-L),g=(p-L)*(i-a)-(d-a)*(r-L),_=(r-L)*(c-a)-(i-a)*(s-L);if(y?w<0||g<0||_<0:w>0||g>0||_>0)continue;let H=(w*l+g*u+_*h)*f,F=E*be+A;H>n[F]&&(n[F]=H)}}function hn(n,t,e,o,r){let i,l,s;Math.abs(e)<.9?(i=0,l=r,s=-o):(i=-r,l=0,s=e);let c=Math.hypot(i,l,s);i/=c,l/=c,s/=c;let u=l*r-s*o,p=s*e-i*r,d=i*o-l*e,h=1/0,m=-1/0,f=1/0,v=-1/0,C=!1;for(let b=0;b<n.length;b++)if(t[b]){C=!0;for(let S of n[b].vertices){let P=i*S[0]+l*S[1]+s*S[2],y=u*S[0]+p*S[1]+d*S[2];P<h&&(h=P),P>m&&(m=P),y<f&&(f=y),y>v&&(v=y)}}if(!C)return null;let T=(m-h)*.05+.01,G=(v-f)*.05+.01;h-=T,m+=T,f-=G,v+=G;let M=new Float64Array(be*be).fill(-1/0);for(let b=0;b<n.length;b++){if(!t[b])continue;let S=n[b].vertices;if(!(S.length<3))for(let P=1;P<S.length-1;P++){let y=S[0],E=S[P],A=S[P+1],L=Ie(y,i,l,s,u,p,d,e,o,r,h,m,f,v),a=Ie(E,i,l,s,u,p,d,e,o,r,h,m,f,v),w=Ie(A,i,l,s,u,p,d,e,o,r,h,m,f,v);pn(M,L,a,w)}}return{buf:M,right:[i,l,s],up:[u,p,d],dir:[e,o,r],uMin:h,uMax:m,vMin:f,vMax:v}}function Ot(n,t,e,o,r,i,l,s,c,u,p,d,h,m,f,v,C,T,G,M,b,S,P,y,E,A,L,a){let w=(r-n)*(u-t)-(i-t)*(c-n);if(w===0||!S&&w>0)return;let g=1/w,_=w>0,H=n<r?n:r;c<H&&(H=c);let F=n>r?n:r;c>F&&(F=c);let z=t<i?t:i;u<z&&(z=u);let W=t>i?t:i;u>W&&(W=u);let B=Math.max(0,Math.ceil(H)),j=Math.min(G-1,Math.floor(F)),k=Math.max(0,Math.ceil(z)),re=Math.min(M-1,Math.floor(W));if(!(B>j||k>re))for(let N=k;N<=re;N++){let q=N;for(let oe=B;oe<=j;oe++){let K=oe,Z=(r-K)*(u-q)-(i-q)*(c-K),ie=(c-K)*(t-q)-(u-q)*(n-K),I=(n-K)*(i-q)-(t-q)*(r-K);if(_?Z<0||ie<0||I<0:Z>0||ie>0||I>0)continue;let Ye=(Z*e+ie*l+I*p)*g,ye=N*G+oe,J=T[ye];if(Ye>(J>0?J*(1-L):J)){if(T[ye]=Ye,A!==null){let V=ye*3;A[V]=(Z*P[0]+ie*y[0]+I*E[0])*g,A[V+1]=(Z*P[1]+ie*y[1]+I*E[1])*g,A[V+2]=(Z*P[2]+ie*y[2]+I*E[2])*g}let Q=(Z*o+ie*s+I*d)*g,ve=f;if(a!==null){let V=(Z*a.ua+ie*a.ub+I*a.uc)*g,X=(Z*a.va+ie*a.vb+I*a.vc)*g,D=sn(a.sampler,V,X);if(D!==null&&D.a>8){let x=D.r*a.tintR|0;x>255&&(x=255);let O=D.g*a.tintG|0;O>255&&(O=255);let ee=D.b*a.tintB|0;ee>255&&(ee=255),ve=`#${ne(x)}${ne(O)}${ne(ee)}`,Q*=(.299*D.r+.587*D.g+.114*D.b)/255}}let He=(Q<0?0:Q>1?1:Q)*m,Se=He|0,Ve=He-Se,Qe=dn[(N&3)*4+(oe&3)],R=Ve>Qe&&Se<m?Se+1:Se;if(R>m&&(R=m),b!==null){let V=(Z*b.luA+ie*b.luB+I*b.luC)*g,X=(Z*b.lvA+ie*b.lvB+I*b.lvC)*g,D=(Z*b.ldA+ie*b.ldB+I*b.ldC)*g,x=V|0,O=X|0;if(x>=0&&x<be&&O>=0&&O<be){let ee=b.map.buf[O*be+x];if(ee>-1/0&&D+b.lift<ee&&(R=Math.max(0,R-Math.round(b.opacity*m)),ve!==null)){let de=`shadow:${ve}:${R}`,Ee=b.litCache.get(de);if(Ee===void 0){let se=ze(ve),pe=b.shadowColorRgb,we=Math.round(se[0]*(1-b.opacity)+pe[0]*b.opacity),ae=Math.round(se[1]*(1-b.opacity)+pe[1]*b.opacity),ge=Math.round(se[2]*(1-b.opacity)+pe[2]*b.opacity);Ee=`#${ne(we)}${ne(ae)}${ne(ge)}`,b.litCache.set(de,Ee)}ve=Ee}}}v[ye]=h[R],C&&(C[ye]=ve)}}}}function mn(n,t){let e=n.length,o=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices;if(c.length<3){o[s]=[0,0,0];continue}let u=c[0],p=c[1],d=c[2],h=p[0]-u[0],m=p[1]-u[1],f=p[2]-u[2],v=d[0]-u[0],C=d[1]-u[1],T=d[2]-u[2],G=m*T-f*C,M=f*v-h*T,b=h*C-m*v,S=Math.hypot(G,M,b)||1;o[s]=[G/S,M/S,b/S]}let r=new Map;for(let s=0;s<e;s++){let c=n[s].vertices;for(let u=0;u<c.length;u++){let p=c[u],d=`${p[0]},${p[1]},${p[2]}`,h=r.get(d);h||(h=[],r.set(d,h)),(h.length===0||h[h.length-1]!==s)&&h.push(s)}}let i=Math.cos(t*Math.PI/180),l=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices,u=o[s],p=new Array(c.length);for(let d=0;d<c.length;d++){let h=c[d],m=r.get(`${h[0]},${h[1]},${h[2]}`),f=0,v=0,C=0;for(let G=0;G<m.length;G++){let M=m[G],b=o[M];u[0]*b[0]+u[1]*b[1]+u[2]*b[2]>=i&&(f+=b[0],v+=b[1],C+=b[2])}let T=Math.hypot(f,v,C)||1;p[d]=[f/T,v/T,C/T]}l[s]=p}return l}function fn(n,t,e,o){let r=[],i=null,l="",s=()=>{l&&(i!==null?r.push(`<span style="color:${i}">${l}</span>`):r.push(l),l="")};for(let c=0;c<o;c++){for(let u=0;u<e;u++){let p=c*e+u,d=n[p],h=t&&d!==" "?t[p]??null:null;h!==i&&(s(),i=h),l+=d}s(),i=null,c<o-1&&r.push(`
|
|
2
|
-
`)}return r.join("")}function
|
|
3
|
-
`)}return
|
|
1
|
+
import{buildTextureSamplers as _n}from"@glyphcss/core";var It=Math.PI/180,Ft=.01,Rt=32e3,ln=Ft*1.01;function dt(n,t,e){let o=n[1],r=n[0],s=n[2],i=e*It,l=Math.cos(i),a=Math.sin(i),u=o*l-r*a,m=o*a+r*l,c=s,d=t*It,h=Math.cos(d),f=Math.sin(d),b=m*h-c*f,C=m*f+c*h;return[u,b,C]}function Pe(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,perspective:n.perspective??Rt,zoom:n.zoom??.65,stretch:n.stretch??1,fovScale:n.fovScale??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return t.perspective},set perspective(r){t.perspective=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},eyeDepth(r){let s=dt([r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],t.rotX,t.rotY),i=.001*1.01;if(t.eyeMode)return-s[2]-i;if(t.perspective>0){let l=s[2]*t.zoom*50-t.distance;return t.perspective-l-t.perspective*ln}return t.distance-s[2]-i},project(r,s,i,l){let u=50/l,m=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=dt(m,t.rotX,t.rotY);if(t.eyeMode){if(c[2]>=-.001)return[NaN,NaN,c[2],NaN];let y=t.focal/-c[2],G=c[0]*y*t.zoom*50,k=c[1]*y*t.zoom*50,O=s*e+G/u*t.stretch,I=i*o+k/50;return[O,I,c[2],-1/c[2]]}if(t.perspective>0){let w=t.perspective,y=c[0]*t.zoom*50,G=c[1]*t.zoom*50,k=c[2]*t.zoom*50-t.distance,O=w-k,I=w*Ft;if(O<I)return[NaN,NaN,k,NaN];let M=w/O,H=s*e+y*M/u*t.stretch*t.fovScale,p=i*o+G*M/50*t.fovScale;return[H,p,k,1/O]}let d=.001,h=t.distance-c[2];if(h<d)return[NaN,NaN,c[2],NaN];let f=t.distance/h,b=c[0]*f*t.zoom*50,C=c[1]*f*t.zoom*50,P=s*e+b/u*t.stretch*t.fovScale,T=i*o+C/50*t.fovScale;return[P,T,c[2],1/h]}}}function Ze(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,fovScale:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get perspective(){return 0},set perspective(r){},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get fovScale(){return t.fovScale},set fovScale(r){t.fovScale=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},eyeDepth(r){return Number.POSITIVE_INFINITY},project(r,s,i,l){let u=50/l,m=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=dt(m,t.rotX,t.rotY),d=c[0]*t.zoom*50,h=c[1]*t.zoom*50,f=s*e+d/u*t.fovScale,b=i*o+h/50*t.fovScale;return[f,b,c[2]]}}}var an=Ze;var cn={direction:[-.5,-.7,-.5],intensity:1},un={intensity:.4};function pn(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let s=0;s<r.length;s++){let i=r[s],l=r[(s+1)%r.length],a=`${i[0]},${i[1]},${i[2]}`,u=`${l[0]},${l[1]},${l[2]}`,m=a<u?`${a}|${u}`:`${u}|${a}`;if(t.has(m))continue;t.add(m);let c={from:i,to:l,weight:2};o.color&&(c.color=o.color),e.push(c)}}return e}function ht(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?pn(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??cn,ambientLight:n.ambientLight??un,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,doubleSided:n.doubleSided??!1,supersample:n.supersample??1,temporalBlend:n.temporalBlend??0,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[],...n.depthBiases?{depthBiases:n.depthBiases}:{},...n.depthEpsilon?{depthEpsilon:n.depthEpsilon}:{}}}import{sampleTexel as fn,polygonTexture as yn}from"@glyphcss/core";var dn=" .:-=+*#%@".split(""),hn=" .:-=+*#%@".split(""),Je={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("")}},mn=Je.default;function Qe(n){return Je[n]??Je.default}function et(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:s,rows:i,cellAspect:l}=e;if(r==="solid"){let c=n.supersample&&n.supersample>1?Math.floor(n.supersample):1;return gn(n,s,i,l,c)}let a=Qe(n.glyphPalette),u=new Uint8Array(s*i),m=n.useColors?new Array(s*i).fill(null):null;for(let c of o){let d=t.project(c.from,s,i,l),h=t.project(c.to,s,i,l);d[0]!==d[0]||h[0]!==h[0]||wn(u,m,d[0]|0,d[1]|0,h[0]|0,h[1]|0,c.weight??2,c.color??null,s,i)}return Mn(u,m,s,i,a)}function gn(n,t,e,o,r){let s=t*r,i=e*r,{camera:l,polygons:a,directionalLight:u,ambientLight:m,smoothShading:c,creaseAngle:d,doubleSided:h,castShadowFlags:f,receiveShadowFlags:b}=n,C=n.depthBiases,P=n.depthEpsilon??0,T=r>1?{zoom:l.zoom,eyeDepth:j=>l.eyeDepth(j),project:(j,J,Q,q)=>{let A=l.project(j,J,Q,q);return[J*.5+(A[0]-J*.5)*r,Q*.5+(A[1]-Q*.5)*r,A[2],A[3]]}}:l,w=Qe(n.glyphPalette).solid,y=w.length-1,G=new Array(s*i).fill(" "),k=n.useColors,O=k?new Array(s*i).fill(null):null,I=new Float64Array(s*i).fill(-1/0),M=n.temporalBlend>0&&!!n.temporalHistory,H=M?new Float32Array(s*i*3).fill(NaN):null,p=u.direction,S=Math.hypot(p[0],p[1],p[2])||1,g=p[0]/S,_=p[1]/S,E=p[2]/S,z=u.intensity??1,L=m.intensity??.4,x=He(u.color??"#ffffff"),v=He(m.color??"#ffffff"),F=c&&d>0?Sn(a,d):null,R=new Map,B=n.textureSamplers??null,Y=n.shadow,N=Y!=null&&f.length>0?Gn(a,f,g,_,E):null,W=Y?.opacity??.25,$=Y?.lift??.05,D=Y?.color??"#000000",te=N?He(D):[0,0,0],V=globalThis.__glyphPerfDetail,ze=V?performance.now():0,ae=[],K=n.shadeCache??null,Z=-1,ve=(j,J,Q,q)=>{if(N===null||!q)return null;let A=N,X=Fe(j,A.right[0],A.right[1],A.right[2],A.up[0],A.up[1],A.up[2],A.dir[0],A.dir[1],A.dir[2],A.uMin,A.uMax,A.vMin,A.vMax),re=Fe(J,A.right[0],A.right[1],A.right[2],A.up[0],A.up[1],A.up[2],A.dir[0],A.dir[1],A.dir[2],A.uMin,A.uMax,A.vMin,A.vMax),de=Fe(Q,A.right[0],A.right[1],A.right[2],A.up[0],A.up[1],A.up[2],A.dir[0],A.dir[1],A.dir[2],A.uMin,A.uMax,A.vMin,A.vMax);return{map:A,luA:X[0],lvA:X[1],ldA:X[2],luB:re[0],lvB:re[1],ldB:re[2],luC:de[0],lvC:de[1],ldC:de[2],lift:$,opacity:W,shadowColorRgb:te,shadowColorHex:D,litCache:R}};for(let j=0;j<a.length;j++){let J=a[j],Q=J.vertices;if(Q.length<3)continue;let q=J.uvs,A=null;if(B!==null&&q&&q.length>=Q.length){let X=yn(J);X&&(A=B.get(X)??null)}for(let X=0;X<Q.length;X++)ae[X]=T.project(Q[X],s,i,o);for(let X=1;X<Q.length-1;X++){Z++;let re=0,de=X,Ee=X+1,se=Q[re],he=Q[de],Ce=Q[Ee],ce=ae[re],ge=ae[de],xe=ae[Ee],rt=(ce[0]!==ce[0]?1:0)+(ge[0]!==ge[0]?1:0)+(xe[0]!==xe[0]?1:0);if(rt===3||rt===0&&!h&&(ge[0]-ce[0])*(xe[1]-ce[1])-(ge[1]-ce[1])*(xe[0]-ce[0])>0)continue;let Me,Le,Te,De=null;if(K!==null&&K.iA[Z]!==void 0)Me=K.iA[Z],Le=K.iB[Z],Te=K.iC[Z],De=K.lit[Z];else{let ee=he[0]-se[0],me=he[1]-se[1],Ge=he[2]-se[2],fe=Ce[0]-se[0],We=Ce[1]-se[1],qe=Ce[2]-se[2],Ue=me*qe-Ge*We,Ve=Ge*fe-ee*qe,ne=ee*We-me*fe,U=Math.hypot(Ue,Ve,ne)||1,oe=Ue/U,ye=Ve/U,le=ne/U,ue,_e,ot,it,st,lt,at,ct,ut;if(F){let Xe=F[j],Ae=Xe[re],Ie=Xe[de],je=Xe[Ee];ue=Ae[0],_e=Ae[1],ot=Ae[2],it=Ie[0],st=Ie[1],lt=Ie[2],at=je[0],ct=je[1],ut=je[2]}else ue=it=at=oe,_e=st=ct=ye,ot=lt=ut=le;let Ht=ue*g+_e*_+ot*E,zt=it*g+st*_+lt*E,Ot=at*g+ct*_+ut*E,Zt=h?Math.abs(Ht):Math.max(0,-Ht),Jt=h?Math.abs(zt):Math.max(0,-zt),Qt=h?Math.abs(Ot):Math.max(0,-Ot);if(Me=Math.min(1,L+Zt*z),Le=Math.min(1,L+Jt*z),Te=Math.min(1,L+Qt*z),k){let Xe=(Me+Le+Te)/3,Ae=Math.max(0,Xe-L),Ie=J.color??"#ffffff",je=Ae*255|0,kt=`${Ie}:${je}`,Ke=R.get(kt);if(Ke===void 0){let pt=He(Ie),en=L*v[0]/255+Ae*x[0]/255,tn=L*v[1]/255+Ae*x[1]/255,nn=L*v[2]/255+Ae*x[2]/255,rn=Math.min(255,pt[0]*en),on=Math.min(255,pt[1]*tn),sn=Math.min(255,pt[2]*nn);Ke=`#${ie(rn)}${ie(on)}${ie(sn)}`,R.set(kt,Ke)}De=Ke}K!==null&&(K.iA[Z]=Me,K.iB[Z]=Le,K.iC[Z]=Te,K.lit[Z]=De)}let _t=b[j]??!1,ke=1+(C?.[j]??0),Pt=null;if(A!==null&&q){let ee=q[re],me=q[de],Ge=q[Ee],fe=Math.max(0,(Me+Le+Te)/3-L);Pt={sampler:A,ua:ee[0],va:ee[1],ub:me[0],vb:me[1],uc:Ge[0],vc:Ge[1],tintR:L*v[0]/255+fe*x[0]/255,tintG:L*v[1]/255+fe*x[1]/255,tintB:L*v[2]/255+fe*x[2]/255}}if(rt===0)Bt(ce[0],ce[1],(ce[3]??ce[2])*ke,Me,ge[0],ge[1],(ge[3]??ge[2])*ke,Le,xe[0],xe[1],(xe[3]??xe[2])*ke,Te,w,y,De,G,O,I,s,i,ve(se,he,Ce,_t),h,se,he,Ce,H,P,Pt);else{let ee=[],me=[],Ge=[se,he,Ce],fe=[Me,Le,Te],We=T.eyeDepth(se),qe=T.eyeDepth(he),Ue=T.eyeDepth(Ce),Ve=[We,qe,Ue];for(let ne=0;ne<3;ne++){let U=(ne+1)%3,oe=Ve[ne],ye=Ve[U];if(oe>0&&(ee.push(Ge[ne]),me.push(fe[ne])),oe>0!=ye>0){let le=oe/(oe-ye),ue=Ge[ne],_e=Ge[U];ee.push([ue[0]+le*(_e[0]-ue[0]),ue[1]+le*(_e[1]-ue[1]),ue[2]+le*(_e[2]-ue[2])]),me.push(fe[ne]+le*(fe[U]-fe[ne]))}}if(ee.length>=3){let ne=ee.map(U=>T.project(U,s,i,o));for(let U=1;U<ee.length-1;U++){let oe=ne[0],ye=ne[U],le=ne[U+1],ue=(ye[0]-oe[0])*(le[1]-oe[1])-(ye[1]-oe[1])*(le[0]-oe[0]);!h&&ue>0||Bt(oe[0],oe[1],(oe[3]??oe[2])*ke,me[0],ye[0],ye[1],(ye[3]??ye[2])*ke,me[U],le[0],le[1],(le[3]??le[2])*ke,me[U+1],w,y,De,G,O,I,s,i,ve(ee[0],ee[U],ee[U+1],_t),h,ee[0],ee[U],ee[U+1],H,P,null)}}}}}V&&(V.loop??(V.loop=[])).push(performance.now()-ze);let Tt=V?performance.now():0,Oe=G,Se=O,$e=H;if(r>1){let j=vn(G,O,I,H,t,e,r,w);Oe=j.glyphBuf,Se=j.colorBuf,$e=j.worldPos}M&&bn(Oe,Se,$e,t,e,o,w,n.temporalBlend,n.temporalHistory,l);let nt=xn(Oe,Se,t,e);return V&&(V.string??(V.string=[])).push(performance.now()-Tt),nt}function bn(n,t,e,o,r,s,i,l,a,u){let m=o*r,c=i.length-1,d=new Map;for(let w=0;w<i.length;w++)d.set(i[w],w);let h=a.cam;(a.cols!==o||a.rows!==r||a.idx.length!==m)&&(a.cols=o,a.rows=r,a.idx=new Float32Array(m),a.r=new Float32Array(m),a.g=new Float32Array(m),a.b=new Float32Array(m),h=null);let f=null;if(h){let w=Pe({rotX:h.rotX,rotY:h.rotY,distance:h.distance,perspective:h.perspective,zoom:h.zoom,stretch:h.stretch});w.target=h.target,f=y=>w.project(y,o,r,s)}let b=new Float32Array(m),C=new Float32Array(m),P=new Float32Array(m),T=new Float32Array(m);for(let w=0;w<r;w++)for(let y=0;y<o;y++){let G=w*o+y,k=d.get(n[G])??0,O=0,I=0,M=0,H=t?t[G]:null;if(H){let Y=He(H);O=Y[0],I=Y[1],M=Y[2]}let p=0,S=0,g=0,_=0,E=0,z=e[G*3];if(f&&z===z){let Y=f([z,e[G*3+1],e[G*3+2]]),N=Math.round(Y[0]),W=Math.round(Y[1]);if(Y[0]===Y[0]&&N>=0&&N<o&&W>=0&&W<r){let $=W*o+N;S=a.idx[$],g=a.r[$],_=a.g[$],E=a.b[$],p=l}}let L=1-p,x=L*k+p*S,v=L*O+p*g,F=L*I+p*_,R=L*M+p*E;b[G]=x,C[G]=v,P[G]=F,T[G]=R;let B=Math.round(x);B<0?B=0:B>c&&(B=c),n[G]=i[B],t&&(t[G]=B===0?null:`#${ie(v)}${ie(F)}${ie(R)}`)}a.idx=b,a.r=C,a.g=P,a.b=T,a.cam={rotX:u.rotX,rotY:u.rotY,target:[u.target[0],u.target[1],u.target[2]],zoom:u.zoom,perspective:u.perspective,distance:u.distance,stretch:u.stretch}}function vn(n,t,e,o,r,s,i,l){let a=new Map;for(let b=0;b<l.length;b++)a.set(l[b],b);let u=l.length-1,m=r*i,c=new Array(r*s).fill(" "),d=t?new Array(r*s).fill(null):null,h=o?new Float32Array(r*s*3).fill(NaN):null,f=1/(i*i);for(let b=0;b<s;b++)for(let C=0;C<r;C++){let P=0,T=0,w=0,y=0,G=0,k=0,O=0,I=0;for(let p=0;p<i;p++){let S=(b*i+p)*m+C*i;for(let g=0;g<i;g++){let _=S+g;if(e[_]!==-1/0){if(P+=a.get(n[_])??0,T++,d){let E=t[_];if(E){let z=He(E);w+=z[0],y+=z[1],G+=z[2]}}h&&(k+=o[_*3],O+=o[_*3+1],I+=o[_*3+2])}}}let M=b*r+C;if(T===0)continue;let H=Math.round(P*f);H<0?H=0:H>u&&(H=u),c[M]=l[H],d&&(d[M]=`#${ie(w/T)}${ie(y/T)}${ie(G/T)}`),h&&(h[M*3]=k/T,h[M*3+1]=O/T,h[M*3+2]=I/T)}return{glyphBuf:c,colorBuf:d,worldPos:h}}var En=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),be=256;function Fe(n,t,e,o,r,s,i,l,a,u,m,c,d,h){let f=t*n[0]+e*n[1]+o*n[2],b=r*n[0]+s*n[1]+i*n[2],C=-(l*n[0]+a*n[1]+u*n[2]),P=(f-m)/(c-m)*(be-1),T=(b-d)/(h-d)*(be-1);return[P,T,C]}function Cn(n,t,e,o){let r=t[0],s=t[1],i=t[2],l=e[0],a=e[1],u=e[2],m=o[0],c=o[1],d=o[2],h=(l-r)*(c-s)-(a-s)*(m-r);if(h===0)return;let f=1/h,b=r<l?r:l;m<b&&(b=m);let C=r>l?r:l;m>C&&(C=m);let P=s<a?s:a;c<P&&(P=c);let T=s>a?s:a;c>T&&(T=c);let w=Math.max(0,Math.ceil(b)),y=Math.min(be-1,Math.floor(C)),G=Math.max(0,Math.ceil(P)),k=Math.min(be-1,Math.floor(T));if(w>y||G>k)return;let O=h>0;for(let I=G;I<=k;I++)for(let M=w;M<=y;M++){let H=M,p=I,S=(l-H)*(c-p)-(a-p)*(m-H),g=(m-H)*(s-p)-(c-p)*(r-H),_=(r-H)*(a-p)-(s-p)*(l-H);if(O?S<0||g<0||_<0:S>0||g>0||_>0)continue;let E=(S*i+g*u+_*d)*f,z=I*be+M;E>n[z]&&(n[z]=E)}}function Gn(n,t,e,o,r){let s,i,l;Math.abs(e)<.9?(s=0,i=r,l=-o):(s=-r,i=0,l=e);let a=Math.hypot(s,i,l);s/=a,i/=a,l/=a;let u=i*r-l*o,m=l*e-s*r,c=s*o-i*e,d=1/0,h=-1/0,f=1/0,b=-1/0,C=!1;for(let y=0;y<n.length;y++)if(t[y]){C=!0;for(let G of n[y].vertices){let k=s*G[0]+i*G[1]+l*G[2],O=u*G[0]+m*G[1]+c*G[2];k<d&&(d=k),k>h&&(h=k),O<f&&(f=O),O>b&&(b=O)}}if(!C)return null;let P=(h-d)*.05+.01,T=(b-f)*.05+.01;d-=P,h+=P,f-=T,b+=T;let w=new Float64Array(be*be).fill(-1/0);for(let y=0;y<n.length;y++){if(!t[y])continue;let G=n[y].vertices;if(!(G.length<3))for(let k=1;k<G.length-1;k++){let O=G[0],I=G[k],M=G[k+1],H=Fe(O,s,i,l,u,m,c,e,o,r,d,h,f,b),p=Fe(I,s,i,l,u,m,c,e,o,r,d,h,f,b),S=Fe(M,s,i,l,u,m,c,e,o,r,d,h,f,b);Cn(w,H,p,S)}}return{buf:w,right:[s,i,l],up:[u,m,c],dir:[e,o,r],uMin:d,uMax:h,vMin:f,vMax:b}}function Bt(n,t,e,o,r,s,i,l,a,u,m,c,d,h,f,b,C,P,T,w,y,G,k,O,I,M,H,p){let S=(r-n)*(u-t)-(s-t)*(a-n);if(S===0||!G&&S>0)return;let g=1/S,_=S>0,E=n<r?n:r;a<E&&(E=a);let z=n>r?n:r;a>z&&(z=a);let L=t<s?t:s;u<L&&(L=u);let x=t>s?t:s;u>x&&(x=u);let v=Math.max(0,Math.ceil(E)),F=Math.min(T-1,Math.floor(z)),R=Math.max(0,Math.ceil(L)),B=Math.min(w-1,Math.floor(x));if(!(v>F||R>B))for(let Y=R;Y<=B;Y++){let N=Y;for(let W=v;W<=F;W++){let $=W,D=(r-$)*(u-N)-(s-N)*(a-$),te=(a-$)*(t-N)-(u-N)*(n-$),V=(n-$)*(s-N)-(t-N)*(r-$);if(_?D<0||te<0||V<0:D>0||te>0||V>0)continue;let ze=(D*e+te*i+V*m)*g,ae=Y*T+W,K=P[ae];if(ze>(K>0?K*(1-H):K)){if(P[ae]=ze,M!==null){let J=ae*3;M[J]=(D*k[0]+te*O[0]+V*I[0])*g,M[J+1]=(D*k[1]+te*O[1]+V*I[1])*g,M[J+2]=(D*k[2]+te*O[2]+V*I[2])*g}let Z=(D*o+te*l+V*c)*g,ve=f;if(p!==null){let J=(D*p.ua+te*p.ub+V*p.uc)*g,Q=(D*p.va+te*p.vb+V*p.vc)*g,q=fn(p.sampler,J,Q);if(q!==null&&q.a>8){let A=q.r*p.tintR|0;A>255&&(A=255);let X=q.g*p.tintG|0;X>255&&(X=255);let re=q.b*p.tintB|0;re>255&&(re=255),ve=`#${ie(A)}${ie(X)}${ie(re)}`,Z*=(.299*q.r+.587*q.g+.114*q.b)/255}}let Oe=(Z<0?0:Z>1?1:Z)*h,Se=Oe|0,$e=Oe-Se,nt=En[(Y&3)*4+(W&3)],j=$e>nt&&Se<h?Se+1:Se;if(j>h&&(j=h),y!==null){let J=(D*y.luA+te*y.luB+V*y.luC)*g,Q=(D*y.lvA+te*y.lvB+V*y.lvC)*g,q=(D*y.ldA+te*y.ldB+V*y.ldC)*g,A=J|0,X=Q|0;if(A>=0&&A<be&&X>=0&&X<be){let re=y.map.buf[X*be+A];if(re>-1/0&&q+y.lift<re&&(j=Math.max(0,j-Math.round(y.opacity*h)),ve!==null)){let de=`shadow:${ve}:${j}`,Ee=y.litCache.get(de);if(Ee===void 0){let se=He(ve),he=y.shadowColorRgb,Ce=Math.round(se[0]*(1-y.opacity)+he[0]*y.opacity),ce=Math.round(se[1]*(1-y.opacity)+he[1]*y.opacity),ge=Math.round(se[2]*(1-y.opacity)+he[2]*y.opacity);Ee=`#${ie(Ce)}${ie(ce)}${ie(ge)}`,y.litCache.set(de,Ee)}ve=Ee}}}b[ae]=d[j],C&&(C[ae]=ve)}}}}function Sn(n,t){let e=n.length,o=new Array(e);for(let l=0;l<e;l++){let a=n[l].vertices;if(a.length<3){o[l]=[0,0,0];continue}let u=a[0],m=a[1],c=a[2],d=m[0]-u[0],h=m[1]-u[1],f=m[2]-u[2],b=c[0]-u[0],C=c[1]-u[1],P=c[2]-u[2],T=h*P-f*C,w=f*b-d*P,y=d*C-h*b,G=Math.hypot(T,w,y)||1;o[l]=[T/G,w/G,y/G]}let r=new Map;for(let l=0;l<e;l++){let a=n[l].vertices;for(let u=0;u<a.length;u++){let m=a[u],c=`${m[0]},${m[1]},${m[2]}`,d=r.get(c);d||(d=[],r.set(c,d)),(d.length===0||d[d.length-1]!==l)&&d.push(l)}}let s=Math.cos(t*Math.PI/180),i=new Array(e);for(let l=0;l<e;l++){let a=n[l].vertices,u=o[l],m=new Array(a.length);for(let c=0;c<a.length;c++){let d=a[c],h=r.get(`${d[0]},${d[1]},${d[2]}`),f=0,b=0,C=0;for(let T=0;T<h.length;T++){let w=h[T],y=o[w];u[0]*y[0]+u[1]*y[1]+u[2]*y[2]>=s&&(f+=y[0],b+=y[1],C+=y[2])}let P=Math.hypot(f,b,C)||1;m[c]=[f/P,b/P,C/P]}i[l]=m}return i}function xn(n,t,e,o){let r=[],s=null,i="",l=()=>{i&&(s!==null?r.push(`<span style="color:${s}">${i}</span>`):r.push(i),i="")};for(let a=0;a<o;a++){for(let u=0;u<e;u++){let m=a*e+u,c=n[m],d=t&&c!==" "?t[m]??null:null;d!==s&&(l(),s=d),i+=c}l(),s=null,a<o-1&&r.push(`
|
|
2
|
+
`)}return r.join("")}function An(n,t,e="y"){let{camera:o}=n,r=e==="y"?o.rotY:o.rotX,s=new Array(t);for(let i=0;i<t;i++){let l=r+i/t*Math.PI*2;e==="y"?o.rotY=l:o.rotX=l,s[i]=et(n)}return e==="y"?o.rotY=r:o.rotX=r,s}function wn(n,t,e,o,r,s,i,l,a,u){let m=Math.abs(r-e),c=-Math.abs(s-o),d=e<r?1:-1,h=o<s?1:-1,f=m+c;for(;;){if(e>=0&&e<a&&o>=0&&o<u){let C=o*a+e;n[C]<i&&(n[C]=i,t&&(t[C]=l))}if(e===r&&o===s)break;let b=2*f;b>=c&&(f+=c,e+=d),b<=m&&(f+=m,o+=h)}}function Mn(n,t,e,o,r){let s=[],i=null,l="",a=()=>{l&&(i!==null?s.push(`<span style="color:${i}">${l}</span>`):s.push(l),l="")};for(let u=0;u<o;u++){for(let m=0;m<e;m++){let c=u*e+m,d=n[c],h,f;d===0?(h=" ",f=null):(h=d===1?r.thin[Math.random()*r.thin.length|0]:d===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],f=t?t[c]??null:null),f!==i&&(a(),i=f),l+=h}a(),i=null,u<o-1&&s.push(`
|
|
3
|
+
`)}return s.join("")}var Yt=new Map;function He(n){let t=Yt.get(n);if(t!==void 0)return t;let e=Ln(n);return Yt.set(n,e),e}function Ln(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,o||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function ie(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Nt="glyph-styles";function mt(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Nt))return;let e=t.createElement("style");e.id=Nt,e.textContent=Tn,t.head.appendChild(e)}var Tn=`
|
|
4
4
|
/* \u2500\u2500 React / Vue host wrapper \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 */
|
|
5
5
|
|
|
6
6
|
.glyph-host {
|
|
@@ -59,5 +59,5 @@ import{buildTextureSamplers as wn}from"@glyphcss/core";var zt=Math.PI/180,Ht=.01
|
|
|
59
59
|
the content from the 3D vertex being labelled. */
|
|
60
60
|
transform: translate(-50%, -50%);
|
|
61
61
|
}
|
|
62
|
-
`;function
|
|
63
|
-
`),w.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(w);let g=w.getBoundingClientRect();return w.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function E(){let a=n.clientWidth,w=n.clientHeight;if(!a||!w)return;let g=y(),_=Math.max(20,Math.floor(a/g.w)),H=Math.max(8,Math.floor(w/g.h)),F=g.h/g.w,z=!1;e.cols!==_&&(e.cols=_,z=!0),e.rows!==H&&(e.rows=H,z=!0),Math.abs(e.cellAspect-F)>.01&&(e.cellAspect=F,z=!0),z&&v()}let A=null;e.autoSize&&typeof ResizeObserver<"u"&&(A=new ResizeObserver(()=>E()),A.observe(n),E());function L(){A&&(A.disconnect(),A=null),l.clear(),n.contains(o)&&n.removeChild(o)}return v(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:G,addHotspot:M,rerender:b,setOptions:S,getOptions:P,fit:E,destroy:L}}function mt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=Bt(t.invert),l=t.clampPitch??!0,s=t.animate??!1,c=!1,u=!1,p=null,d=null,h=null,m={x:0,y:0},f=n.camera;function v(E){if(!(!o||c)&&h===null&&E.isPrimary!==!1){E.preventDefault(),h=E.pointerId,m={x:E.clientX,y:E.clientY},e.style.cursor="grabbing";try{E.target.setPointerCapture(E.pointerId)}catch{}s&&s.pauseOnInteraction!==!1&&(u=!0)}}function C(E){if(h===null||E.pointerId!==h||!o||c)return;E.preventDefault();let A=E.clientX-m.x,L=E.clientY-m.y;m={x:E.clientX,y:E.clientY};let a=i,w=1/4;f.rotY=f.rotY-A*w*a;let g=f.rotX-L*w*a;f.rotX=l?Math.max(-90,Math.min(90,g)):g,n.rerender()}function T(E){if(h===E.pointerId){h=null,e.style.cursor=o&&!c?"grab":"";try{E.target.releasePointerCapture(E.pointerId)}catch{}s&&(u=!1)}}function G(E){if(!r||c)return;E.preventDefault();let A=E.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-A))),n.rerender()}function M(E){if(!(c||!s)){if(!u){let A=d!==null?Math.min(E-d,50):16.67,L=typeof s=="object"&&s.speed?s.speed:.3,a=typeof s=="object"&&s.axis?s.axis:"y",w=L*(A/16.67);a==="y"?f.rotY=f.rotY+w:f.rotX=f.rotX+w,n.rerender()}d=E,p=requestAnimationFrame(M)}}function b(){p===null&&typeof requestAnimationFrame<"u"&&s&&(p=requestAnimationFrame(M))}function S(){p!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(p),p=null),d=null}function P(){e.addEventListener("pointerdown",v),e.addEventListener("pointermove",C),e.addEventListener("pointerup",T),e.addEventListener("pointercancel",T),e.addEventListener("wheel",G,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",v),e.removeEventListener("pointermove",C),e.removeEventListener("pointerup",T),e.removeEventListener("pointercancel",T),e.removeEventListener("wheel",G),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return P(),b(),{update(E){let A=!!s;o=E.drag??o,r=E.wheel??r,i=Bt(E.invert),E.clampPitch!==void 0&&(l=E.clampPitch),s=E.animate??s,!c&&h===null&&(e.style.cursor=o?"grab":"");let L=!!s;A&&!L?S():!A&&L&&b()},pause(){c||(c=!0,y(),S(),h=null,u=!1)},resume(){c&&(c=!1,P(),b())},destroy(){c||y(),S(),c=!0}}}function Bt(n){return n===void 0||n===!1?1:n===!0?-1:n}function ft(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,i=kt(t.invert),l=t.animate??!1,s=!1,c=!1,u=null,p=null,d=null,h={x:0,y:0},m=!1,f=n.camera,v=1/4,C=.02;function T(a){if(!(!o||s)&&d===null&&a.isPrimary!==!1){a.preventDefault(),d=a.pointerId,h={x:a.clientX,y:a.clientY},m=a.button===2,e.style.cursor="grabbing";try{a.target.setPointerCapture(a.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function G(a){if(d===null||a.pointerId!==d||!o||s)return;a.preventDefault();let w=a.clientX-h.x,g=a.clientY-h.y;h={x:a.clientX,y:a.clientY};let _=i;if(m||a.shiftKey)f.rotY=f.rotY-w*v*_,f.rotX=Math.max(-90,Math.min(90,f.rotX+g*v*_));else{let H=f.target;f.target=[H[0]-w*C/f.zoom,H[1]-g*C/f.zoom,H[2]]}n.rerender()}function M(a){if(d===a.pointerId){d=null,m=!1,e.style.cursor=o&&!s?"grab":"";try{a.target.releasePointerCapture(a.pointerId)}catch{}l&&(c=!1)}}function b(a){a.preventDefault()}function S(a){if(!r||s)return;a.preventDefault();let w=a.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-w))),n.rerender()}function P(a){if(!(s||!l)){if(!c){let w=p!==null?Math.min(a-p,50):16.67,g=typeof l=="object"&&l.speed?l.speed:.3,_=typeof l=="object"&&l.axis?l.axis:"y",H=g*(w/16.67);_==="y"?f.rotY=f.rotY+H:f.rotX=f.rotX+H,n.rerender()}p=a,u=requestAnimationFrame(P)}}function y(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(P))}function E(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),p=null}function A(){e.addEventListener("pointerdown",T),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",b),e.addEventListener("wheel",S,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function L(){e.removeEventListener("pointerdown",T),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",b),e.removeEventListener("wheel",S),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),y(),{update(a){let w=!!l;o=a.drag??o,r=a.wheel??r,i=kt(a.invert),l=a.animate??l,!s&&d===null&&(e.style.cursor=o?"grab":"");let g=!!l;w&&!g?E():!w&&g&&y()},pause(){s||(s=!0,L(),E(),d=null,c=!1)},resume(){s&&(s=!1,A(),y())},destroy(){s||L(),E(),s=!0}}}function kt(n){return n===void 0||n===!1?1:n===!0?-1:n}function xn(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");n.camera.eyeMode=!0;let e=n.host,o=t.drag??!0,r=t.keyboard??!0,i=t.moveSpeed??.05,l=t.lookSpeed??.15,s=Nt(t.invert),c=!1,u=null,p={x:0,y:0},d=new Set,h=null,m=n.camera;function f(y){if(!(!o||c)&&u===null){y.preventDefault(),u=y.pointerId,p={x:y.clientX,y:y.clientY};try{y.target.setPointerCapture(y.pointerId)}catch{}}}function v(y){if(u===null||y.pointerId!==u||!o||c)return;y.preventDefault();let E=y.clientX-p.x,A=y.clientY-p.y;p={x:y.clientX,y:y.clientY},m.rotY=m.rotY-E*l*s,m.rotX=Math.max(-90,Math.min(90,m.rotX+A*l*s)),n.rerender()}function C(y){if(u===y.pointerId){u=null;try{y.target.releasePointerCapture(y.pointerId)}catch{}}}function T(y){r&&!c&&d.add(y.key.toLowerCase())}function G(y){d.delete(y.key.toLowerCase())}function M(){if(c||!r||d.size===0)return;let y=m.target,E=m.rotY*Math.PI/180,A=Math.cos(E),L=Math.sin(E),a=!1;(d.has("w")||d.has("arrowup"))&&(m.target=[y[0]-L*i,y[1]-A*i,y[2]],a=!0),(d.has("s")||d.has("arrowdown"))&&(m.target=[y[0]+L*i,y[1]+A*i,y[2]],a=!0),(d.has("a")||d.has("arrowleft"))&&(m.target=[y[0]-A*i,y[1]+L*i,y[2]],a=!0),(d.has("d")||d.has("arrowright"))&&(m.target=[y[0]+A*i,y[1]-L*i,y[2]],a=!0),a&&n.rerender()}function b(){c||(M(),h=requestAnimationFrame(b))}function S(){e.addEventListener("pointerdown",f),e.addEventListener("pointermove",v),e.addEventListener("pointerup",C),e.addEventListener("pointercancel",C),r&&(e.ownerDocument?.addEventListener("keydown",T),e.ownerDocument?.addEventListener("keyup",G)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(h=requestAnimationFrame(b))}function P(){e.removeEventListener("pointerdown",f),e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",C),e.removeEventListener("pointercancel",C),e.ownerDocument?.removeEventListener("keydown",T),e.ownerDocument?.removeEventListener("keyup",G),e.style.touchAction="",e.style.userSelect="",h!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(h),h=null),d.clear(),n.camera.eyeMode=!1}return S(),{update(y){o=y.drag??o,r=y.keyboard??r,i=y.moveSpeed??i,l=y.lookSpeed??l,s=Nt(y.invert)},pause(){c||(c=!0,P(),u=null)},resume(){c&&(c=!1,S())},destroy(){c||P(),c=!0}}}function Nt(n){return n===void 0||n===!1?1:n===!0?-1:n}function Cn(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function Dt(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function Mn(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let i of r)if(Dt(i,t,e))return i;return null}var Gn=typeof HTMLElement<"u"?HTMLElement:class{},Ln=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function Me(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Tn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function _n(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var yt=class extends Gn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Ln]}getScene(){return this._scene}_readOptions(){let e={},o=Tn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let i=_n(this.getAttribute("use-colors"));i!==void 0&&(e.useColors=i);let l=Me(this.getAttribute("cols"));l!==void 0&&(e.cols=l);let s=Me(this.getAttribute("rows"));s!==void 0&&(e.rows=s);let c=Me(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=Me(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let p=Me(this.getAttribute("ambient-intensity"));if(p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let d={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},h=this.getAttribute("shadow-color");h&&(d.color=h);let m=Me(this.getAttribute("shadow-opacity"));m!==void 0&&(d.opacity=m);let f=Me(this.getAttribute("shadow-lift"));f!==void 0&&(d.lift=f);let v=Me(this.getAttribute("shadow-max-extend"));v!==void 0&&(d.maxExtend=v),e.shadow=d}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=ht(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as Pn,resolveGeometry as zn,recenterPolygons as Hn}from"@glyphcss/core";var Fn=typeof HTMLElement<"u"?HTMLElement:class{},On=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function gt(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 In(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return gt(n)}}function Rn(n){return n.closest("glyph-scene")??null}var bt=class extends Fn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...On]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:gt(this.getAttribute("position")),scale:In(this.getAttribute("scale")),rotation:gt(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Rn(this);if(r){if(!r.getScene()){let i=()=>{r.removeEventListener("glyphcss:scene-ready",i),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",i);return}if(e){let i=++this._loadToken,l;try{l=await Pn(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(i!==this._loadToken){try{l.dispose()}catch{}return}let s=r.getScene();if(!s){try{l.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?Hn(l.polygons):l.polygons;this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let i=r.getScene();if(!i)return;let l=this.getAttribute("size"),s=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=zn(o,{size:Number.isFinite(s)?s:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=i.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var Bn=typeof HTMLElement<"u"?HTMLElement:class{};function kn(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 Nn(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 Dn(n){return n.closest("glyph-scene")??null}var vt=class extends Bn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=kn(this.getAttribute("at"));if(!e)return;let o=Dn(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let i=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=Nn(this.getAttribute("size"));this._handle=r.addHotspot({id:i,at:e,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:i},bubbles:!0})));let s=this._handle.el;for(;this.firstChild;)s.appendChild(this.firstChild)}};var Yn=typeof HTMLElement<"u"?HTMLElement:class{};function ue(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Et=class extends Yn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Pe({rotX:ue(this.getAttribute("rot-x")),rotY:ue(this.getAttribute("rot-y")),distance:ue(this.getAttribute("distance")),perspective:ue(this.getAttribute("perspective")),zoom:ue(this.getAttribute("zoom")),stretch:ue(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=ue(this.getAttribute("rot-x")),s=ue(this.getAttribute("rot-y")),c=ue(this.getAttribute("distance")),u=ue(this.getAttribute("perspective")),p=ue(this.getAttribute("zoom")),d=ue(this.getAttribute("stretch")),h=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,h=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,h=!0),c!==void 0&&i.distance!==c&&(i.distance=c,h=!0),u!==void 0&&i.perspective!==u&&(i.perspective=u,h=!0),p!==void 0&&i.zoom!==p&&(i.zoom=p,h=!0),d!==void 0&&i.stretch!==d&&(i.stretch=d,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var Vn=typeof HTMLElement<"u"?HTMLElement:class{};function Re(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var wt=class extends Vn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=qe({rotX:Re(this.getAttribute("rot-x")),rotY:Re(this.getAttribute("rot-y")),zoom:Re(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let i=this._camera;if(!i)return;let l=Re(this.getAttribute("rot-x")),s=Re(this.getAttribute("rot-y")),c=Re(this.getAttribute("zoom")),u=!1;l!==void 0&&i.rotX!==l&&(i.rotX=l,u=!0),s!==void 0&&i.rotY!==s&&(i.rotY=s,u=!0),c!==void 0&&i.zoom!==c&&(i.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};var Xn=typeof HTMLElement<"u"?HTMLElement:class{};function $n(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Je(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Wn(n){return n.closest("glyph-scene")??null}var At=class extends Xn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Je(this.getAttribute("drag")),o=Je(this.getAttribute("wheel")),r=Je(this.getAttribute("invert")),i=Je(this.getAttribute("clamp-pitch")),l=$n(this.getAttribute("animate-speed")),s=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...i!==void 0?{clampPitch:i}:{},...l!==void 0?{animate:{speed:l,axis:s}}:{}}}_attach(){if(this._controls)return;let e=Wn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=mt(o,this._readOptions())}};var jn=typeof HTMLElement<"u"?HTMLElement:class{};function St(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function qn(n){return n.closest("glyph-scene")??null}var xt=class extends jn{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,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=St(this.getAttribute("drag")),o=St(this.getAttribute("wheel")),r=St(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=qn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=ft(o,this._readOptions())}};export*from"@glyphcss/core";export{Ft as DEFAULT_PERSPECTIVE,nn as DEFAULT_RAMP,vt as GlyphHotspotElement,xt as GlyphMapControlsElement,bt as GlyphMeshElement,At as GlyphOrbitControlsElement,wt as GlyphOrthographicCameraElement,Et as GlyphPerspectiveCameraElement,yt as GlyphSceneElement,rn as SOLID_RAMP,on as WIREFRAME_GLYPHS,Ue as WIREFRAME_PALETTES,yn as bakeFrames,ut as buildRasterizeContext,Jt as createGlyphCamera,xn as createGlyphFirstPersonControls,ft as createGlyphMapControls,mt as createGlyphOrbitControls,qe as createGlyphOrthographicCamera,Pe as createGlyphPerspectiveCamera,ht as createGlyphScene,Cn as findGlyphMeshHandle,Mn as findMeshUnderPoint,Ke as getWireframeGlyphs,dt as injectGlyphBaseStyles,Dt as pointInMeshElement,pt as projectHotspots,Ze as rasterize};
|
|
62
|
+
`;function ft(n,t,e,o,r){return n.map(s=>{let[i,l,a]=t.project(s.at,e,o,r),u=a>-3&&i>=0&&i<e&&l>=0&&l<o;return{id:s.id,col:i,row:l,depth:a,visible:u}})}var Pn=1;function Hn(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[s,i,l]=e??[0,0,0],a=1,u=1,m=1;o!==void 0&&(typeof o=="number"?a=u=m=o:[a,u,m]=o);let c=Math.PI/180,[d,h,f]=r??[0,0,0],b=d*c,C=h*c,P=f*c,T=Math.cos(b),w=Math.sin(b),y=Math.cos(C),G=Math.sin(C),k=Math.cos(P),O=Math.sin(P);function I(M){let H=M[0]*a,p=M[1]*u,S=M[2]*m,g=k*H-O*p,_=O*H+k*p,E=S;return H=y*g+G*E,p=_,S=-G*g+y*E,g=H,_=T*p-w*S,E=w*p+T*S,[g+s,_+i,E+l]}return n.map(M=>({...M,vertices:M.vertices.map(I)}))}function yt(n,t={}){mt(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??Pe(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,doubleSided:t.doubleSided??!1,supersample:t.supersample??1,depthEpsilon:t.depthEpsilon??0,temporalBlend:t.temporalBlend??0,autoSize:t.autoSize??!1,shadow:t.shadow},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let s=n.ownerDocument.createElement("div");s.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(s),n.appendChild(o);let i=new Map,l=[],a=!1,u={iA:[],iB:[],iC:[],lit:[]},m={idx:new Float32Array(0),r:new Float32Array(0),g:new Float32Array(0),b:new Float32Array(0),cols:0,rows:0,cam:null};function c(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}let d=null,h=0;function f(){let p=[];for(let g of i.values())for(let _ of g.polygons)(_.texture||_.material?.texture)&&p.push(_);if(p.length===0){d&&(d=null,b());return}let S=++h;_n(p).then(g=>{S===h&&(d=g.size>0?g:null,b())})}function b(){a||(a=!0,Promise.resolve().then(()=>{a=!1,C()}))}function C(){let p=[],S=[],g=[],_=[],E=!1;for(let R of i.values()){let B=Hn(R.polygons,R.transform),Y=R.transform.castShadow??!1,N=R.transform.receiveShadow??!1,W=R.transform.depthBias??0;W!==0&&(E=!0);for(let $ of B)p.push($),S.push(Y),g.push(N),_.push(W)}let z=ht({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:p,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,doubleSided:e.doubleSided,supersample:e.supersample,depthEpsilon:e.depthEpsilon,temporalBlend:e.temporalBlend,shadow:e.shadow,castShadowFlags:S,receiveShadowFlags:g,depthBiases:E?_:void 0});z.shadeCache=u,z.textureSamplers=d,z.temporalHistory=m;let L=globalThis.__glyphPerf,x=L?performance.now():0,v=et(z),F=L?performance.now():0;if(e.useColors?r.innerHTML=v:r.textContent=v,L){let R=performance.now();(L.raster??(L.raster=[])).push(F-x),(L.dom??(L.dom=[])).push(R-F),(L.polys??(L.polys=[])).push(p.length)}P()}function P(){let{cols:p,rows:S,cellAspect:g,camera:_}=e,E=ft(l.map(v=>v.hotspot),_,p,S,g),z=r.getBoundingClientRect(),L=p>0?z.width/p:8,x=S>0?z.height/S:16;for(let v=0;v<l.length;v++){let{el:F}=l[v],R=E[v];R.visible?(F.style.display="",F.style.left=`${(R.col+.5)*L}px`,F.style.top=`${(R.row+.5)*x}px`,F.style.zIndex=String(Math.round(R.depth*1e3))):F.style.display="none"}}function T(p,S={}){let g=Pn++;return i.set(g,{id:g,polygons:p,transform:S}),c(),f(),b(),{get id(){return g},get name(){return i.get(g)?.transform.id},get polygons(){return p},setTransform(_){let E=i.get(g);E&&(E.transform=_,c(),b())},dispose(){i.delete(g),c(),f(),b()}}}function w(p,S){let g=n.ownerDocument.createElement("div");g.className="glyph-hotspot",g.setAttribute("data-hotspot-id",p.id);let[_,E]=p.size??[1,1];g.style.position="absolute",g.style.width=`${_}ch`,g.style.height=`${E*e.cellAspect}ch`,S&&g.addEventListener("click",S),s.appendChild(g);let z={hotspot:{id:p.id,at:p.at,size:p.size},el:g,onClick:S};return l.push(z),b(),{get el(){return g},remove(){let L=l.indexOf(z);L>=0&&l.splice(L,1),S&&g.removeEventListener("click",S),s.removeChild(g),b()}}}function y(){C()}function G(p){p.mode!==void 0&&(e.mode=p.mode),p.glyphPalette!==void 0&&(e.glyphPalette=p.glyphPalette),p.useColors!==void 0&&(e.useColors=p.useColors),p.cols!==void 0&&(e.cols=p.cols),p.rows!==void 0&&(e.rows=p.rows),p.cellAspect!==void 0&&(e.cellAspect=p.cellAspect),p.directionalLight!==void 0&&(e.directionalLight=p.directionalLight),p.ambientLight!==void 0&&(e.ambientLight=p.ambientLight),p.camera!==void 0&&(e.camera=p.camera),p.smoothShading!==void 0&&(e.smoothShading=p.smoothShading),p.creaseAngle!==void 0&&(e.creaseAngle=p.creaseAngle),"shadow"in p&&(e.shadow=p.shadow),p.autoSize!==void 0&&(e.autoSize=p.autoSize,e.autoSize&&!M&&typeof ResizeObserver<"u"?(M=new ResizeObserver(()=>I()),M.observe(n),I()):!e.autoSize&&M&&(M.disconnect(),M=null)),(p.mode!==void 0||p.useColors!==void 0||p.directionalLight!==void 0||p.ambientLight!==void 0||p.smoothShading!==void 0||p.creaseAngle!==void 0||p.glyphPalette!==void 0)&&c(),b()}function k(){return{...e}}function O(){let S=n.ownerDocument.createElement("span");S.textContent=Array(20).fill("M").join(`
|
|
63
|
+
`),S.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(S);let g=S.getBoundingClientRect();return S.remove(),{w:g.width||8,h:g.height?g.height/20:16}}function I(){let p=n.clientWidth,S=n.clientHeight;if(!p||!S)return;let g=O(),_=Math.max(20,Math.floor(p/g.w)),E=Math.max(8,Math.floor(S/g.h)),z=g.h/g.w,L=!1;e.cols!==_&&(e.cols=_,L=!0),e.rows!==E&&(e.rows=E,L=!0),Math.abs(e.cellAspect-z)>.01&&(e.cellAspect=z,L=!0),L&&b()}let M=null;e.autoSize&&typeof ResizeObserver<"u"&&(M=new ResizeObserver(()=>I()),M.observe(n),I());function H(){M&&(M.disconnect(),M=null),i.clear(),n.contains(o)&&n.removeChild(o)}return b(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:T,addHotspot:w,rerender:y,setOptions:G,getOptions:k,fit:I,destroy:H}}function Re(){let n=[],t=[],e=[];function o(i){return i==="change"?n:i==="start"?t:e}function r(i){if(n.length===0)return;let l={type:"change",camera:i()};for(let a of n.slice())try{a(l)}catch(u){console.error("[glyphcss] controls 'change' listener threw:",u)}}function s(i,l){let a=i==="start"?t:e;if(a.length===0)return;let u={type:i,camera:l()};for(let m of a.slice())try{m(u)}catch(c){console.error(`[glyphcss] controls '${i}' listener threw:`,c)}}return{changeListeners:n,startListeners:t,endListeners:e,listenerArray:o,emitChange:r,emitInteraction:s}}function Be(n){return()=>{let t=n.camera,e=t.target??[0,0,0];return{rotX:t.rotX??0,rotY:t.rotY??0,zoom:t.zoom??1,target:[e[0],e[1],e[2]],distance:t.distance??0}}}function Ye(n){return{addEventListener(t,e){let o=n.listenerArray(t);o.includes(e)||o.push(e)},removeEventListener(t,e){let o=n.listenerArray(t),r=o.indexOf(e);r>=0&&o.splice(r,1)},hasEventListener(t,e){return n.listenerArray(t).includes(e)}}}function gt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=Dt(t.invert),i=t.clampPitch??!0,l=t.animate??!1,a=!1,u=!1,m=null,c=null,d=null,h={x:0,y:0},f=n.camera,b=Re(),C=Be(n),{emitChange:P,emitInteraction:T}=b,w=!1,y=null;function G(E){if(!(!o||a)&&d===null&&E.isPrimary!==!1){E.preventDefault(),d=E.pointerId,h={x:E.clientX,y:E.clientY},e.style.cursor="grabbing";try{E.target.setPointerCapture(E.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(u=!0),T("start",C)}}function k(E){if(d===null||E.pointerId!==d||!o||a)return;E.preventDefault();let z=E.clientX-h.x,L=E.clientY-h.y;h={x:E.clientX,y:E.clientY};let x=s,v=1/4;f.rotY=f.rotY-z*v*x;let F=f.rotX-L*v*x;f.rotX=i?Math.max(-90,Math.min(90,F)):F,n.rerender(),P(C)}function O(E){if(d===E.pointerId){d=null,e.style.cursor=o&&!a?"grab":"";try{E.target.releasePointerCapture(E.pointerId)}catch{}l&&(u=!1),T("end",C)}}function I(E){if(!r||a)return;E.preventDefault();let z=E.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-z))),n.rerender(),w||(w=!0,T("start",C)),P(C),y!==null&&clearTimeout(y),y=setTimeout(()=>{y=null,w=!1,T("end",C)},150)}function M(E){if(!(a||!l)){if(!u){let z=c!==null?Math.min(E-c,50):16.67,L=typeof l=="object"&&l.speed?l.speed:.3,x=typeof l=="object"&&l.axis?l.axis:"y",v=L*(z/16.67);x==="y"?f.rotY=f.rotY+v:f.rotX=f.rotX+v,n.rerender(),P(C)}c=E,m=requestAnimationFrame(M)}}function H(){m===null&&typeof requestAnimationFrame<"u"&&l&&(m=requestAnimationFrame(M))}function p(){m!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(m),m=null),c=null}function S(){e.addEventListener("pointerdown",G),e.addEventListener("pointermove",k),e.addEventListener("pointerup",O),e.addEventListener("pointercancel",O),e.addEventListener("wheel",I,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function g(){e.removeEventListener("pointerdown",G),e.removeEventListener("pointermove",k),e.removeEventListener("pointerup",O),e.removeEventListener("pointercancel",O),e.removeEventListener("wheel",I),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}function _(){y!==null&&(clearTimeout(y),y=null),w=!1}return S(),H(),{...Ye(b),update(E){let z=!!l;o=E.drag??o,r=E.wheel??r,s=Dt(E.invert),E.clampPitch!==void 0&&(i=E.clampPitch),l=E.animate??l,!a&&d===null&&(e.style.cursor=o?"grab":"");let L=!!l;z&&!L?p():!z&&L&&H()},pause(){a||(a=!0,g(),p(),_(),d=null,u=!1)},resume(){a&&(a=!1,S(),H())},destroy(){a||g(),p(),_(),a=!0}}}function Dt(n){return n===void 0||n===!1?1:n===!0?-1:n}function bt(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=Vt(t.invert),i=t.animate??!1,l=!1,a=!1,u=null,m=null,c=null,d={x:0,y:0},h=!1,f=n.camera,b=Re(),C=Be(n),{emitChange:P,emitInteraction:T}=b,w=!1,y=null,G=1/4,k=.02;function O(x){if(!(!o||l)&&c===null&&x.isPrimary!==!1){x.preventDefault(),c=x.pointerId,d={x:x.clientX,y:x.clientY},h=x.button===2,e.style.cursor="grabbing";try{x.target.setPointerCapture(x.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(a=!0),T("start",C)}}function I(x){if(c===null||x.pointerId!==c||!o||l)return;x.preventDefault();let v=x.clientX-d.x,F=x.clientY-d.y;d={x:x.clientX,y:x.clientY};let R=s;if(h||x.shiftKey)f.rotY=f.rotY-v*G*R,f.rotX=Math.max(-90,Math.min(90,f.rotX+F*G*R));else{let B=f.target;f.target=[B[0]-v*k/f.zoom,B[1]-F*k/f.zoom,B[2]]}n.rerender(),P(C)}function M(x){if(c===x.pointerId){c=null,h=!1,e.style.cursor=o&&!l?"grab":"";try{x.target.releasePointerCapture(x.pointerId)}catch{}i&&(a=!1),T("end",C)}}function H(x){x.preventDefault()}function p(x){if(!r||l)return;x.preventDefault();let v=x.deltaY*.001;f.zoom=Math.max(.1,Math.min(500,f.zoom*(1-v))),n.rerender(),w||(w=!0,T("start",C)),P(C),y!==null&&clearTimeout(y),y=setTimeout(()=>{y=null,w=!1,T("end",C)},150)}function S(x){if(!(l||!i)){if(!a){let v=m!==null?Math.min(x-m,50):16.67,F=typeof i=="object"&&i.speed?i.speed:.3,R=typeof i=="object"&&i.axis?i.axis:"y",B=F*(v/16.67);R==="y"?f.rotY=f.rotY+B:f.rotX=f.rotX+B,n.rerender(),P(C)}m=x,u=requestAnimationFrame(S)}}function g(){u===null&&typeof requestAnimationFrame<"u"&&i&&(u=requestAnimationFrame(S))}function _(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),m=null}function E(){e.addEventListener("pointerdown",O),e.addEventListener("pointermove",I),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",H),e.addEventListener("wheel",p,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function z(){e.removeEventListener("pointerdown",O),e.removeEventListener("pointermove",I),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",H),e.removeEventListener("wheel",p),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}function L(){y!==null&&(clearTimeout(y),y=null),w=!1}return E(),g(),{...Ye(b),update(x){let v=!!i;o=x.drag??o,r=x.wheel??r,s=Vt(x.invert),i=x.animate??i,!l&&c===null&&(e.style.cursor=o?"grab":"");let F=!!i;v&&!F?_():!v&&F&&g()},pause(){l||(l=!0,z(),_(),L(),c=null,a=!1)},resume(){l&&(l=!1,E(),g())},destroy(){l||z(),_(),L(),l=!0}}}function Vt(n){return n===void 0||n===!1?1:n===!0?-1:n}var zn={enabled:!0,lookEnabled:!0,moveEnabled:!0,jumpEnabled:!0,crouchEnabled:!0,lookSensitivity:.15,invertY:!1,moveSpeed:5,jumpVelocity:7,gravity:18,eyeHeight:1.7,crouchHeight:1,groundZ:0,minPitch:5,maxPitch:175};function Xt(n,t){return{enabled:t.enabled??n.enabled,lookEnabled:t.lookEnabled??n.lookEnabled,moveEnabled:t.moveEnabled??n.moveEnabled,jumpEnabled:t.jumpEnabled??n.jumpEnabled,crouchEnabled:t.crouchEnabled??n.crouchEnabled,lookSensitivity:t.lookSensitivity??n.lookSensitivity,invertY:t.invertY??n.invertY,moveSpeed:t.moveSpeed??n.moveSpeed,jumpVelocity:t.jumpVelocity??n.jumpVelocity,gravity:t.gravity??n.gravity,eyeHeight:t.eyeHeight??n.eyeHeight,crouchHeight:t.crouchHeight??n.crouchHeight,groundZ:t.groundZ??n.groundZ,minPitch:t.minPitch??n.minPitch,maxPitch:t.maxPitch??n.maxPitch}}var jt=new Set(["KeyW","ArrowUp"]),$t=new Set(["KeyS","ArrowDown"]),Wt=new Set(["KeyA","ArrowLeft"]),qt=new Set(["KeyD","ArrowRight"]),Ut=new Set(["Space"]),vt=new Set(["ControlLeft","ControlRight"]);function On(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");let e=Xt(zn,t),o=n.camera,r=n.host,s=r.ownerDocument??document,i=s.defaultView??globalThis,l=Re(),a=Be(n),{emitChange:u,emitInteraction:m}=l,c=new Set,d=!1,h=!1,f=0,b=0,C=[0,0,e.groundZ+e.eyeHeight];function P(){o.target=[C[0],C[1],C[2]],n.rerender(),u(a)}function T(){let v=o.target??[0,0,0];C=[v[0],v[1],e.groundZ+e.eyeHeight],P()}let w=()=>{if(!(!e.enabled||!e.lookEnabled||h||d))try{r.requestPointerLock()}catch{}},y=()=>{let v=s.pointerLockElement===r;v!==d&&(d=v,m(v?"start":"end",a))},G=v=>{if(!d||!e.enabled||!e.lookEnabled||h)return;let F=v.movementX??0,R=v.movementY??0;if(F===0&&R===0)return;let B=e.lookSensitivity,Y=e.invertY?-1:1;o.rotY=((o.rotY-F*B)%360+360)%360;let N=o.rotX-R*B*Y;N<e.minPitch?N=e.minPitch:N>e.maxPitch&&(N=e.maxPitch),o.rotX=N,P()},k=v=>jt.has(v)||$t.has(v)||Wt.has(v)||qt.has(v)||Ut.has(v)||vt.has(v),O=v=>{if(!(!e.enabled||h)&&k(v.code)&&!(!d&&!e.moveEnabled)){if(Ut.has(v.code)){if(!e.jumpEnabled)return;v.preventDefault(),!c.has(v.code)&&f===0&&b===0&&(f=e.jumpVelocity),c.add(v.code);return}vt.has(v.code)&&!e.crouchEnabled||!e.moveEnabled&&!vt.has(v.code)||(v.preventDefault(),c.add(v.code))}},I=v=>{k(v.code)&&c.delete(v.code)},M=()=>{c.clear()},H=null,p=0,S=.05,g=v=>{if(H===null||h)return;let F=Math.min(S,p?(v-p)/1e3:.0167);if(p=v,e.enabled){let R=!1;if(e.moveEnabled){let W=0,$=0;for(let D of c)jt.has(D)?W+=1:$t.has(D)?W-=1:qt.has(D)?$+=1:Wt.has(D)&&($-=1);if(W!==0||$!==0){let D=o.rotY*Math.PI/180,te=-Math.cos(D),V=-Math.sin(D),ze=-Math.sin(D),ae=Math.cos(D),K=Math.hypot(W,$)||1,Z=e.moveSpeed*F;C[0]+=(te*W+ze*$)/K*Z,C[1]+=(V*W+ae*$)/K*Z,R=!0}}let Y=e.crouchEnabled&&(c.has("ControlLeft")||c.has("ControlRight"))?e.crouchHeight:e.eyeHeight;e.jumpEnabled&&(f!==0||b>0)?(f-=e.gravity*F,b+=f*F,b<=0&&(b=0,f=0)):e.jumpEnabled||(b=0,f=0);let N=e.groundZ+Y+b;Math.abs(C[2]-N)>1e-4&&(C[2]=N,R=!0),R&&P()}H=i.requestAnimationFrame(g)};function _(){H!==null||h||(p=0,typeof i.requestAnimationFrame<"u"&&(H=i.requestAnimationFrame(g)))}function E(){H!==null&&(i.cancelAnimationFrame(H),H=null)}function z(){o.eyeMode=!0,r.addEventListener("click",w),s.addEventListener("pointerlockchange",y),s.addEventListener("mousemove",G),i.addEventListener("keydown",O),i.addEventListener("keyup",I),i.addEventListener("blur",M),r.style.cursor=e.lookEnabled?"crosshair":"",r.style.touchAction="none"}function L(){if(r.removeEventListener("click",w),s.removeEventListener("pointerlockchange",y),s.removeEventListener("mousemove",G),i.removeEventListener("keydown",O),i.removeEventListener("keyup",I),i.removeEventListener("blur",M),r.style.cursor="",r.style.touchAction="",c.clear(),d)try{s.exitPointerLock()}catch{}o.eyeMode=!1}T(),z(),_();function x(v){let F=e.eyeHeight,R=e.groundZ;e=Xt(e,v),h||(r.style.cursor=e.lookEnabled?"crosshair":""),(e.eyeHeight!==F||e.groundZ!==R)&&(C[2]=e.groundZ+e.eyeHeight,P())}return{...Ye(l),update:x,resume(){h&&(h=!1,z(),_())},pause(){h||(h=!0,L(),E())},destroy(){h||(L(),E()),h=!0},lock(){if(!(!e.enabled||!e.lookEnabled||h))try{r.requestPointerLock()}catch{}},unlock(){if(d)try{s.exitPointerLock()}catch{}},isLocked(){return d},getOrigin(){return[C[0],C[1],C[2]]},setOrigin(v){C=[v[0],v[1],v[2]],P()}}}function kn(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function Kt(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function In(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let s of r)if(Kt(s,t,e))return s;return null}var Fn=typeof HTMLElement<"u"?HTMLElement:class{},Rn=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function we(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Bn(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function Yn(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Et=class extends Fn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Rn]}getScene(){return this._scene}_readOptions(){let e={},o=Bn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let s=Yn(this.getAttribute("use-colors"));s!==void 0&&(e.useColors=s);let i=we(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let l=we(this.getAttribute("rows"));l!==void 0&&(e.rows=l);let a=we(this.getAttribute("cell-aspect"));a!==void 0&&(e.cellAspect=a);let u=we(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let m=we(this.getAttribute("ambient-intensity"));if(m!==void 0&&(e.ambientLight={intensity:m}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let c={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},d=this.getAttribute("shadow-color");d&&(c.color=d);let h=we(this.getAttribute("shadow-opacity"));h!==void 0&&(c.opacity=h);let f=we(this.getAttribute("shadow-lift"));f!==void 0&&(c.lift=f);let b=we(this.getAttribute("shadow-max-extend"));b!==void 0&&(c.maxExtend=b),e.shadow=c}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=yt(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as Nn,resolveGeometry as Dn,recenterPolygons as Vn}from"@glyphcss/core";var Xn=typeof HTMLElement<"u"?HTMLElement:class{},jn=["src","geometry","size","color","position","scale","rotation","auto-center","cast-shadow","receive-shadow"];function Ct(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 $n(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Ct(n)}}function Wn(n){return n.closest("glyph-scene")??null}var Gt=class extends Xn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...jn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:Ct(this.getAttribute("position")),scale:$n(this.getAttribute("scale")),rotation:Ct(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Wn(this);if(r){if(!r.getScene()){let s=()=>{r.removeEventListener("glyphcss:scene-ready",s),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",s);return}if(e){let s=++this._loadToken,i;try{i=await Nn(e)}catch(m){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:m,bubbles:!0}));return}if(s!==this._loadToken){try{i.dispose()}catch{}return}let l=r.getScene();if(!l){try{i.dispose()}catch{}return}let u=this.hasAttribute("auto-center")?Vn(i.polygons):i.polygons;this._handle=l.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(o){let s=r.getScene();if(!s)return;let i=this.getAttribute("size"),l=i!==null?parseFloat(i):1,a=this.getAttribute("color")??void 0,u;try{u=Dn(o,{size:Number.isFinite(l)?l:1,color:a})}catch(m){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:m,bubbles:!0}));return}this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var qn=typeof HTMLElement<"u"?HTMLElement:class{};function Un(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 Kn(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 Zn(n){return n.closest("glyph-scene")??null}var St=class extends qn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=Un(this.getAttribute("at"));if(!e)return;let o=Zn(this);if(!o)return;if(!o.getScene()){let a=()=>{o.removeEventListener("glyphcss:scene-ready",a),this._register()};o.addEventListener("glyphcss:scene-ready",a);return}let r=o.getScene();if(!r)return;let s=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),i=Kn(this.getAttribute("size"));this._handle=r.addHotspot({id:s,at:e,size:i},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:s},bubbles:!0})));let l=this._handle.el;for(;this.firstChild;)l.appendChild(this.firstChild)}};var Jn=typeof HTMLElement<"u"?HTMLElement:class{};function pe(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var xt=class extends Jn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","perspective","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Pe({rotX:pe(this.getAttribute("rot-x")),rotY:pe(this.getAttribute("rot-y")),distance:pe(this.getAttribute("distance")),perspective:pe(this.getAttribute("perspective")),zoom:pe(this.getAttribute("zoom")),stretch:pe(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let i=pe(this.getAttribute("rot-x")),l=pe(this.getAttribute("rot-y")),a=pe(this.getAttribute("distance")),u=pe(this.getAttribute("perspective")),m=pe(this.getAttribute("zoom")),c=pe(this.getAttribute("stretch")),d=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,d=!0),l!==void 0&&s.rotY!==l&&(s.rotY=l,d=!0),a!==void 0&&s.distance!==a&&(s.distance=a,d=!0),u!==void 0&&s.perspective!==u&&(s.perspective=u,d=!0),m!==void 0&&s.zoom!==m&&(s.zoom=m,d=!0),c!==void 0&&s.stretch!==c&&(s.stretch=c,d=!0),d&&this.querySelector("glyph-scene")?.rerender?.()}};var Qn=typeof HTMLElement<"u"?HTMLElement:class{};function Ne(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var At=class extends Qn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ze({rotX:Ne(this.getAttribute("rot-x")),rotY:Ne(this.getAttribute("rot-y")),zoom:Ne(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let i=Ne(this.getAttribute("rot-x")),l=Ne(this.getAttribute("rot-y")),a=Ne(this.getAttribute("zoom")),u=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,u=!0),l!==void 0&&s.rotY!==l&&(s.rotY=l,u=!0),a!==void 0&&s.zoom!==a&&(s.zoom=a,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};var er=typeof HTMLElement<"u"?HTMLElement:class{};function tr(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function tt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function nr(n){return n.closest("glyph-scene")??null}var wt=class extends er{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=tt(this.getAttribute("drag")),o=tt(this.getAttribute("wheel")),r=tt(this.getAttribute("invert")),s=tt(this.getAttribute("clamp-pitch")),i=tr(this.getAttribute("animate-speed")),l=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...s!==void 0?{clampPitch:s}:{},...i!==void 0?{animate:{speed:i,axis:l}}:{}}}_attach(){if(this._controls)return;let e=nr(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=gt(o,this._readOptions())}};var rr=typeof HTMLElement<"u"?HTMLElement:class{};function Mt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function or(n){return n.closest("glyph-scene")??null}var Lt=class extends rr{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,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Mt(this.getAttribute("drag")),o=Mt(this.getAttribute("wheel")),r=Mt(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=or(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=bt(o,this._readOptions())}};export*from"@glyphcss/core";export{Rt as DEFAULT_PERSPECTIVE,dn as DEFAULT_RAMP,St as GlyphHotspotElement,Lt as GlyphMapControlsElement,Gt as GlyphMeshElement,wt as GlyphOrbitControlsElement,At as GlyphOrthographicCameraElement,xt as GlyphPerspectiveCameraElement,Et as GlyphSceneElement,hn as SOLID_RAMP,mn as WIREFRAME_GLYPHS,Je as WIREFRAME_PALETTES,An as bakeFrames,ht as buildRasterizeContext,an as createGlyphCamera,On as createGlyphFirstPersonControls,bt as createGlyphMapControls,gt as createGlyphOrbitControls,Ze as createGlyphOrthographicCamera,Pe as createGlyphPerspectiveCamera,yt as createGlyphScene,kn as findGlyphMeshHandle,In as findMeshUnderPoint,Qe as getWireframeGlyphs,mt as injectGlyphBaseStyles,Kt as pointInMeshElement,ft as projectHotspots,et as rasterize};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glyphcss",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Glyphcss — ASCII paint backend with glyphcss's scene-composition API. Renders 3D meshes as ASCII art in a <pre> element.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@glyphcss/core": "^0.0.
|
|
36
|
+
"@glyphcss/core": "^0.0.7"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"tsup": "^8.0.1",
|
|
File without changes
|
|
File without changes
|