glyphcss 0.0.3 → 0.0.5
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-DVWVBIG0.d.cts → elements-ycVyIlYL.d.cts} +145 -26
- package/dist/{elements-DVWVBIG0.d.ts → elements-ycVyIlYL.d.ts} +145 -26
- package/dist/elements.cjs +5 -4
- package/dist/elements.d.cts +1 -1
- package/dist/elements.d.ts +1 -1
- package/dist/elements.js +5 -4
- package/dist/index.cjs +5 -4
- package/dist/index.d.cts +121 -6
- package/dist/index.d.ts +121 -6
- package/dist/index.js +5 -4
- package/package.json +2 -2
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
import { Vec3, Polygon, RenderMode } from '@glyphcss/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* handle with a `project()` method that maps world-space vertices to
|
|
9
|
-
* [col, row, depth] in character-cell grid space.
|
|
10
|
-
*
|
|
11
|
-
* Public names use the Glyph prefix per glyphcss naming convention.
|
|
12
|
-
* The internal camera algorithms are byte-identical to asciss's createCamera.ts.
|
|
13
|
-
*
|
|
14
|
-
* `createGlyphCamera` is the ergonomic default alias — it creates an
|
|
15
|
-
* orthographic camera, matching the voxel/iso identity of glyphcss.
|
|
4
|
+
* Default CSS-perspective distance in virtual pixels — mirrors voxcss/polycss
|
|
5
|
+
* `DEFAULT_PERSPECTIVE`. Large enough that perspective foreshortening is gentle
|
|
6
|
+
* (a normal scene only spans a few hundred px), so the on-screen result matches
|
|
7
|
+
* polycss out of the box.
|
|
16
8
|
*/
|
|
17
|
-
|
|
9
|
+
declare const DEFAULT_PERSPECTIVE = 32000;
|
|
18
10
|
interface GlyphCamera {
|
|
19
11
|
readonly kind: "perspective" | "orthographic";
|
|
20
12
|
rotX: number;
|
|
21
13
|
rotY: number;
|
|
22
|
-
/** Distance from
|
|
14
|
+
/** Distance from target along the view axis. For perspective cameras: world units. Default 0. */
|
|
23
15
|
distance: number;
|
|
24
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* CSS-perspective distance in virtual pixels (voxcss parity). When > 0, the
|
|
18
|
+
* camera projects with the browser's `P / (P − z)` CSS-perspective math.
|
|
19
|
+
* Default 0 (disabled).
|
|
20
|
+
*/
|
|
21
|
+
perspective: number;
|
|
22
|
+
/**
|
|
23
|
+
* Camera zoom — CSS scale multiplier (same semantic as voxcss).
|
|
24
|
+
* `zoom = 1` → one world unit = BASE_TILE (50) virtual pixels.
|
|
25
|
+
* Larger values zoom in; smaller zoom out. NOT a fraction of viewport.
|
|
26
|
+
*/
|
|
25
27
|
zoom: number;
|
|
26
28
|
/** Extra horizontal stretch on top of `cellAspect`. */
|
|
27
29
|
stretch: number;
|
|
30
|
+
/**
|
|
31
|
+
* Isotropic field-of-view scale applied to the projected screen offset (around
|
|
32
|
+
* the center), independent of the perspective divide. `1` = off. Use it to
|
|
33
|
+
* decouple the FOV from the grid resolution: when the grid grows (e.g. a
|
|
34
|
+
* smaller line-height adds rows), the FOV would otherwise widen — set
|
|
35
|
+
* `fovScale` proportional to the resolution change to keep it fixed. Unlike
|
|
36
|
+
* `zoom`, it does NOT alter perspective foreshortening (zoom scales `cssZ`,
|
|
37
|
+
* shifting the `P/(P−z)` divide; this only scales the post-divide offset).
|
|
38
|
+
*/
|
|
39
|
+
fovScale: number;
|
|
28
40
|
/**
|
|
29
41
|
* Camera target offset in world space — shifts the point the camera orbits around.
|
|
30
42
|
* Subtracted from world coords before projection so the mesh appears to pan without re-baking.
|
|
@@ -33,37 +45,85 @@ interface GlyphCamera {
|
|
|
33
45
|
/**
|
|
34
46
|
* Eye-at-origin projection mode. When true, the perspective camera uses a
|
|
35
47
|
* first-person formulation: `target` is treated as the eye position and
|
|
36
|
-
* vertices behind the eye (`
|
|
48
|
+
* vertices behind the eye (`rz2 >= 0`) are NaN-culled. Toggled by
|
|
37
49
|
* `createGlyphFirstPersonControls` at attach / detach time.
|
|
38
50
|
*/
|
|
39
51
|
eyeMode: boolean;
|
|
40
|
-
/**
|
|
41
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Project a world-space vector to `[col, row, depth, zbuf?]`. `depth` is the
|
|
54
|
+
* linear eye-space `cssZ` (the public contract, used by the hit layer). The
|
|
55
|
+
* optional 4th element `zbuf` is the **screen-space-linear** depth (`1/denom`)
|
|
56
|
+
* for perspective cameras — the renderer's z-buffer must use it (not `depth`)
|
|
57
|
+
* so the depth test is perspective-correct: interpolating linear `cssZ` with
|
|
58
|
+
* screen-space barycentric weights misorders overlapping triangles, which
|
|
59
|
+
* shows the wrong (farther) surface in some cells and flickers under motion.
|
|
60
|
+
* Orthographic cameras omit it (their linear `depth` is already screen-linear).
|
|
61
|
+
*/
|
|
62
|
+
project(v: Vec3, cols: number, rows: number, cellAspect: number): [number, number, number, number?];
|
|
63
|
+
/**
|
|
64
|
+
* Signed distance of a world vertex past the near plane: `> 0` is visible
|
|
65
|
+
* (in front of the near plane), `<= 0` is culled (at/behind the eye). The
|
|
66
|
+
* near plane sits at `eyeDepth = 0`, so an edge crossing the near plane is
|
|
67
|
+
* found by linear interpolation where `eyeDepth` changes sign. The renderer
|
|
68
|
+
* uses this for near-plane clipping; `eyeDepth` is affine in `v`, so the
|
|
69
|
+
* world-space crossing point interpolates linearly. Orthographic cameras
|
|
70
|
+
* return `+Infinity` (never clipped).
|
|
71
|
+
*/
|
|
72
|
+
eyeDepth(v: Vec3): number;
|
|
42
73
|
}
|
|
43
74
|
interface GlyphPerspectiveCameraOptions {
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
75
|
+
/**
|
|
76
|
+
* X rotation in **degrees** (tilt). Default 65.
|
|
77
|
+
* Matches voxcss / three.js convention.
|
|
78
|
+
*/
|
|
47
79
|
rotX?: number;
|
|
48
80
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
81
|
+
* Y rotation in **degrees** (spin). Default 45.
|
|
82
|
+
* Matches voxcss / three.js convention.
|
|
83
|
+
*/
|
|
84
|
+
rotY?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Perspective distance in world units. Larger = flatter (less foreshortening);
|
|
87
|
+
* smaller = more dramatic. Default 6.
|
|
51
88
|
*/
|
|
52
89
|
distance?: number;
|
|
53
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* CSS-perspective distance in **virtual pixels**, matching voxcss/polycss
|
|
92
|
+
* `createPolyPerspectiveCamera({ perspective })`. When > 0, the camera projects
|
|
93
|
+
* with the same `P / (P − z)` pinhole math the browser applies for CSS
|
|
94
|
+
* `perspective: Npx` — so identical camera params (rotX/rotY/target/zoom/
|
|
95
|
+
* distance/perspective) produce the same on-screen projection as polycss, and
|
|
96
|
+
* a first-person view falls out naturally (no `eyeMode` needed). Default
|
|
97
|
+
* {@link DEFAULT_PERSPECTIVE} (32000), matching voxcss. Set to 0 to disable
|
|
98
|
+
* (→ legacy orbit projection using `distance` in world units).
|
|
99
|
+
*/
|
|
100
|
+
perspective?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Camera zoom — CSS scale multiplier. Default 0.3.
|
|
103
|
+
* `zoom = 1` → BASE_TILE (50) virtual px per world unit.
|
|
104
|
+
*/
|
|
54
105
|
zoom?: number;
|
|
55
106
|
/**
|
|
56
107
|
* Extra horizontal scale on top of `cellAspect`. Use to counteract
|
|
57
108
|
* over-stretching when monospace cells are taller than wide. Default 1.0.
|
|
58
109
|
*/
|
|
59
110
|
stretch?: number;
|
|
111
|
+
/** Isotropic FOV scale on the projected offset (resolution-independent FOV). Default 1. */
|
|
112
|
+
fovScale?: number;
|
|
60
113
|
/** Center of projection in normalized grid coords. Default `[0.5, 0.5]`. */
|
|
61
114
|
center?: [number, number];
|
|
62
115
|
}
|
|
63
116
|
interface GlyphOrthographicCameraOptions {
|
|
64
|
-
|
|
117
|
+
/** X rotation in **degrees** (tilt). Default 65. */
|
|
65
118
|
rotX?: number;
|
|
119
|
+
/** Y rotation in **degrees** (spin). Default 45. */
|
|
120
|
+
rotY?: number;
|
|
121
|
+
/**
|
|
122
|
+
* Camera zoom — CSS scale multiplier. Default 0.3.
|
|
123
|
+
* `zoom = 1` → BASE_TILE (50) virtual px per world unit.
|
|
124
|
+
*/
|
|
66
125
|
zoom?: number;
|
|
126
|
+
/** Center of projection in normalized grid coords. Default `[0.5, 0.5]`. */
|
|
67
127
|
center?: [number, number];
|
|
68
128
|
}
|
|
69
129
|
/** Handle alias — same surface as `GlyphCamera`, names matched to glyphcss. */
|
|
@@ -92,12 +152,43 @@ interface GlyphAmbientLight {
|
|
|
92
152
|
/** Hex color (#rrggbb). Tints the unlit-side fill. Default white. */
|
|
93
153
|
color?: string;
|
|
94
154
|
}
|
|
155
|
+
/** Shadow configuration for the ASCII rasterizer (shadow-map technique). */
|
|
156
|
+
interface GlyphShadowOptions {
|
|
157
|
+
/** Shadow tint color. Default "#000000". */
|
|
158
|
+
color?: string;
|
|
159
|
+
/** Shadow darkness 0..1 — how much the shadowed color darkens toward `color`. Default 0.25. */
|
|
160
|
+
opacity?: number;
|
|
161
|
+
/**
|
|
162
|
+
* Depth bias added to the interpolated surface depth before comparing against
|
|
163
|
+
* the shadow map. Eliminates self-shadow acne on flat lit surfaces. Default 0.05.
|
|
164
|
+
*/
|
|
165
|
+
lift?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Maximum world-space extent for the shadow-map ortho projection.
|
|
168
|
+
* Kept for API parity with polycss. Used as the half-extent of the light-space
|
|
169
|
+
* projection volume when larger than the computed scene bounds. Default 2000.
|
|
170
|
+
*/
|
|
171
|
+
maxExtend?: number;
|
|
172
|
+
}
|
|
95
173
|
interface GlyphMeshTransform {
|
|
96
174
|
/** String identifier for the mesh — surfaced as `GlyphMeshHandle.name`. */
|
|
97
175
|
id?: string;
|
|
98
176
|
position?: Vec3;
|
|
99
177
|
scale?: number | Vec3;
|
|
100
178
|
rotation?: Vec3;
|
|
179
|
+
/** This mesh casts shadows onto receiveShadow surfaces. Default false. */
|
|
180
|
+
castShadow?: boolean;
|
|
181
|
+
/** This mesh receives (displays) shadows from castShadow meshes. Default false. */
|
|
182
|
+
receiveShadow?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Relative depth bias (0 = off). Nudges this mesh toward (positive) or away
|
|
185
|
+
* from (negative) the camera in the depth test via `pixelDepth *= 1 + depthBias`
|
|
186
|
+
* — resolving z-fighting against coplanar/coincident geometry. A CSS/DOM
|
|
187
|
+
* renderer decides coincident surfaces by stacking order for free; a
|
|
188
|
+
* projection-painted depth buffer fights, so a tiny bias (e.g. 0.002) lets a
|
|
189
|
+
* dynamic surface (a door/platform flush into a wall/floor) win cleanly.
|
|
190
|
+
*/
|
|
191
|
+
depthBias?: number;
|
|
101
192
|
}
|
|
102
193
|
|
|
103
194
|
/**
|
|
@@ -157,6 +248,32 @@ interface GlyphSceneOptions {
|
|
|
157
248
|
* Default `60`.
|
|
158
249
|
*/
|
|
159
250
|
creaseAngle?: number;
|
|
251
|
+
/**
|
|
252
|
+
* Render both faces of every polygon (no backface culling). Default `false`.
|
|
253
|
+
* Set `true` for single-sided surfaces whose winding isn't guaranteed to face
|
|
254
|
+
* the camera — e.g. BSP level geometry — so "back-wound" faces don't vanish,
|
|
255
|
+
* matching how a CSS/DOM renderer shows both sides.
|
|
256
|
+
*/
|
|
257
|
+
doubleSided?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Supersampled anti-aliasing (solid mode). `1` (default) = off; `2`/`3`
|
|
260
|
+
* rasterize at N× resolution and average down, removing the motion crawl of
|
|
261
|
+
* sub-cell-sized surfaces. Cost ~N².
|
|
262
|
+
*/
|
|
263
|
+
supersample?: number;
|
|
264
|
+
/**
|
|
265
|
+
* Global depth-test deadband (0 = exact, default). A polygon replaces a cell
|
|
266
|
+
* only when nearer by more than this relative fraction, so near-coplanar
|
|
267
|
+
* surfaces keep a stable winner instead of z-fighting per-cell as the camera
|
|
268
|
+
* moves (the tearing a CSS/DOM renderer avoids via stacking order). 0.002–0.01.
|
|
269
|
+
*/
|
|
270
|
+
depthEpsilon?: number;
|
|
271
|
+
/**
|
|
272
|
+
* Temporal anti-aliasing — exponential blend with the previous frame, weight
|
|
273
|
+
* in [0,1). `0` (default) = off. Smooths fast frame-to-frame edge crawl that
|
|
274
|
+
* supersampling can't cover, at the cost of motion ghosting.
|
|
275
|
+
*/
|
|
276
|
+
temporalBlend?: number;
|
|
160
277
|
/**
|
|
161
278
|
* Auto-size the character grid to fill the host element. When `true`, the
|
|
162
279
|
* scene measures one monospace character's pixel size from the live `<pre>`
|
|
@@ -166,6 +283,8 @@ interface GlyphSceneOptions {
|
|
|
166
283
|
* (default 80×24) is the predictable choice for tests and SSR.
|
|
167
284
|
*/
|
|
168
285
|
autoSize?: boolean;
|
|
286
|
+
/** Shadow-map configuration. `undefined` (default) = no shadows. */
|
|
287
|
+
shadow?: GlyphShadowOptions;
|
|
169
288
|
}
|
|
170
289
|
interface GlyphHotspotOptions {
|
|
171
290
|
id: string;
|
|
@@ -310,4 +429,4 @@ declare class GlyphMapControlsElement extends ELEMENT_BASE {
|
|
|
310
429
|
private _attach;
|
|
311
430
|
}
|
|
312
431
|
|
|
313
|
-
export { type GlyphSceneHandle as G, type GlyphCamera as a, type GlyphDirectionalLight as b, type GlyphAmbientLight as c,
|
|
432
|
+
export { DEFAULT_PERSPECTIVE as D, type GlyphSceneHandle as G, type GlyphCamera as a, type GlyphDirectionalLight as b, type GlyphAmbientLight as c, type GlyphShadowOptions as d, GlyphHotspotElement as e, type GlyphHotspotHandle as f, type GlyphHotspotOptions as g, GlyphMapControlsElement as h, GlyphMeshElement as i, type GlyphMeshHandle as j, type GlyphMeshTransform as k, GlyphOrbitControlsElement as l, GlyphOrthographicCameraElement as m, type GlyphOrthographicCameraHandle as n, type GlyphOrthographicCameraOptions as o, GlyphPerspectiveCameraElement as p, type GlyphPerspectiveCameraHandle as q, type GlyphPerspectiveCameraOptions as r, GlyphSceneElement as s, type GlyphSceneOptions as t, createGlyphCamera as u, createGlyphOrthographicCamera as v, createGlyphPerspectiveCamera as w, createGlyphScene as x };
|
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
import { Vec3, Polygon, RenderMode } from '@glyphcss/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* handle with a `project()` method that maps world-space vertices to
|
|
9
|
-
* [col, row, depth] in character-cell grid space.
|
|
10
|
-
*
|
|
11
|
-
* Public names use the Glyph prefix per glyphcss naming convention.
|
|
12
|
-
* The internal camera algorithms are byte-identical to asciss's createCamera.ts.
|
|
13
|
-
*
|
|
14
|
-
* `createGlyphCamera` is the ergonomic default alias — it creates an
|
|
15
|
-
* orthographic camera, matching the voxel/iso identity of glyphcss.
|
|
4
|
+
* Default CSS-perspective distance in virtual pixels — mirrors voxcss/polycss
|
|
5
|
+
* `DEFAULT_PERSPECTIVE`. Large enough that perspective foreshortening is gentle
|
|
6
|
+
* (a normal scene only spans a few hundred px), so the on-screen result matches
|
|
7
|
+
* polycss out of the box.
|
|
16
8
|
*/
|
|
17
|
-
|
|
9
|
+
declare const DEFAULT_PERSPECTIVE = 32000;
|
|
18
10
|
interface GlyphCamera {
|
|
19
11
|
readonly kind: "perspective" | "orthographic";
|
|
20
12
|
rotX: number;
|
|
21
13
|
rotY: number;
|
|
22
|
-
/** Distance from
|
|
14
|
+
/** Distance from target along the view axis. For perspective cameras: world units. Default 0. */
|
|
23
15
|
distance: number;
|
|
24
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* CSS-perspective distance in virtual pixels (voxcss parity). When > 0, the
|
|
18
|
+
* camera projects with the browser's `P / (P − z)` CSS-perspective math.
|
|
19
|
+
* Default 0 (disabled).
|
|
20
|
+
*/
|
|
21
|
+
perspective: number;
|
|
22
|
+
/**
|
|
23
|
+
* Camera zoom — CSS scale multiplier (same semantic as voxcss).
|
|
24
|
+
* `zoom = 1` → one world unit = BASE_TILE (50) virtual pixels.
|
|
25
|
+
* Larger values zoom in; smaller zoom out. NOT a fraction of viewport.
|
|
26
|
+
*/
|
|
25
27
|
zoom: number;
|
|
26
28
|
/** Extra horizontal stretch on top of `cellAspect`. */
|
|
27
29
|
stretch: number;
|
|
30
|
+
/**
|
|
31
|
+
* Isotropic field-of-view scale applied to the projected screen offset (around
|
|
32
|
+
* the center), independent of the perspective divide. `1` = off. Use it to
|
|
33
|
+
* decouple the FOV from the grid resolution: when the grid grows (e.g. a
|
|
34
|
+
* smaller line-height adds rows), the FOV would otherwise widen — set
|
|
35
|
+
* `fovScale` proportional to the resolution change to keep it fixed. Unlike
|
|
36
|
+
* `zoom`, it does NOT alter perspective foreshortening (zoom scales `cssZ`,
|
|
37
|
+
* shifting the `P/(P−z)` divide; this only scales the post-divide offset).
|
|
38
|
+
*/
|
|
39
|
+
fovScale: number;
|
|
28
40
|
/**
|
|
29
41
|
* Camera target offset in world space — shifts the point the camera orbits around.
|
|
30
42
|
* Subtracted from world coords before projection so the mesh appears to pan without re-baking.
|
|
@@ -33,37 +45,85 @@ interface GlyphCamera {
|
|
|
33
45
|
/**
|
|
34
46
|
* Eye-at-origin projection mode. When true, the perspective camera uses a
|
|
35
47
|
* first-person formulation: `target` is treated as the eye position and
|
|
36
|
-
* vertices behind the eye (`
|
|
48
|
+
* vertices behind the eye (`rz2 >= 0`) are NaN-culled. Toggled by
|
|
37
49
|
* `createGlyphFirstPersonControls` at attach / detach time.
|
|
38
50
|
*/
|
|
39
51
|
eyeMode: boolean;
|
|
40
|
-
/**
|
|
41
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Project a world-space vector to `[col, row, depth, zbuf?]`. `depth` is the
|
|
54
|
+
* linear eye-space `cssZ` (the public contract, used by the hit layer). The
|
|
55
|
+
* optional 4th element `zbuf` is the **screen-space-linear** depth (`1/denom`)
|
|
56
|
+
* for perspective cameras — the renderer's z-buffer must use it (not `depth`)
|
|
57
|
+
* so the depth test is perspective-correct: interpolating linear `cssZ` with
|
|
58
|
+
* screen-space barycentric weights misorders overlapping triangles, which
|
|
59
|
+
* shows the wrong (farther) surface in some cells and flickers under motion.
|
|
60
|
+
* Orthographic cameras omit it (their linear `depth` is already screen-linear).
|
|
61
|
+
*/
|
|
62
|
+
project(v: Vec3, cols: number, rows: number, cellAspect: number): [number, number, number, number?];
|
|
63
|
+
/**
|
|
64
|
+
* Signed distance of a world vertex past the near plane: `> 0` is visible
|
|
65
|
+
* (in front of the near plane), `<= 0` is culled (at/behind the eye). The
|
|
66
|
+
* near plane sits at `eyeDepth = 0`, so an edge crossing the near plane is
|
|
67
|
+
* found by linear interpolation where `eyeDepth` changes sign. The renderer
|
|
68
|
+
* uses this for near-plane clipping; `eyeDepth` is affine in `v`, so the
|
|
69
|
+
* world-space crossing point interpolates linearly. Orthographic cameras
|
|
70
|
+
* return `+Infinity` (never clipped).
|
|
71
|
+
*/
|
|
72
|
+
eyeDepth(v: Vec3): number;
|
|
42
73
|
}
|
|
43
74
|
interface GlyphPerspectiveCameraOptions {
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
75
|
+
/**
|
|
76
|
+
* X rotation in **degrees** (tilt). Default 65.
|
|
77
|
+
* Matches voxcss / three.js convention.
|
|
78
|
+
*/
|
|
47
79
|
rotX?: number;
|
|
48
80
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
81
|
+
* Y rotation in **degrees** (spin). Default 45.
|
|
82
|
+
* Matches voxcss / three.js convention.
|
|
83
|
+
*/
|
|
84
|
+
rotY?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Perspective distance in world units. Larger = flatter (less foreshortening);
|
|
87
|
+
* smaller = more dramatic. Default 6.
|
|
51
88
|
*/
|
|
52
89
|
distance?: number;
|
|
53
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* CSS-perspective distance in **virtual pixels**, matching voxcss/polycss
|
|
92
|
+
* `createPolyPerspectiveCamera({ perspective })`. When > 0, the camera projects
|
|
93
|
+
* with the same `P / (P − z)` pinhole math the browser applies for CSS
|
|
94
|
+
* `perspective: Npx` — so identical camera params (rotX/rotY/target/zoom/
|
|
95
|
+
* distance/perspective) produce the same on-screen projection as polycss, and
|
|
96
|
+
* a first-person view falls out naturally (no `eyeMode` needed). Default
|
|
97
|
+
* {@link DEFAULT_PERSPECTIVE} (32000), matching voxcss. Set to 0 to disable
|
|
98
|
+
* (→ legacy orbit projection using `distance` in world units).
|
|
99
|
+
*/
|
|
100
|
+
perspective?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Camera zoom — CSS scale multiplier. Default 0.3.
|
|
103
|
+
* `zoom = 1` → BASE_TILE (50) virtual px per world unit.
|
|
104
|
+
*/
|
|
54
105
|
zoom?: number;
|
|
55
106
|
/**
|
|
56
107
|
* Extra horizontal scale on top of `cellAspect`. Use to counteract
|
|
57
108
|
* over-stretching when monospace cells are taller than wide. Default 1.0.
|
|
58
109
|
*/
|
|
59
110
|
stretch?: number;
|
|
111
|
+
/** Isotropic FOV scale on the projected offset (resolution-independent FOV). Default 1. */
|
|
112
|
+
fovScale?: number;
|
|
60
113
|
/** Center of projection in normalized grid coords. Default `[0.5, 0.5]`. */
|
|
61
114
|
center?: [number, number];
|
|
62
115
|
}
|
|
63
116
|
interface GlyphOrthographicCameraOptions {
|
|
64
|
-
|
|
117
|
+
/** X rotation in **degrees** (tilt). Default 65. */
|
|
65
118
|
rotX?: number;
|
|
119
|
+
/** Y rotation in **degrees** (spin). Default 45. */
|
|
120
|
+
rotY?: number;
|
|
121
|
+
/**
|
|
122
|
+
* Camera zoom — CSS scale multiplier. Default 0.3.
|
|
123
|
+
* `zoom = 1` → BASE_TILE (50) virtual px per world unit.
|
|
124
|
+
*/
|
|
66
125
|
zoom?: number;
|
|
126
|
+
/** Center of projection in normalized grid coords. Default `[0.5, 0.5]`. */
|
|
67
127
|
center?: [number, number];
|
|
68
128
|
}
|
|
69
129
|
/** Handle alias — same surface as `GlyphCamera`, names matched to glyphcss. */
|
|
@@ -92,12 +152,43 @@ interface GlyphAmbientLight {
|
|
|
92
152
|
/** Hex color (#rrggbb). Tints the unlit-side fill. Default white. */
|
|
93
153
|
color?: string;
|
|
94
154
|
}
|
|
155
|
+
/** Shadow configuration for the ASCII rasterizer (shadow-map technique). */
|
|
156
|
+
interface GlyphShadowOptions {
|
|
157
|
+
/** Shadow tint color. Default "#000000". */
|
|
158
|
+
color?: string;
|
|
159
|
+
/** Shadow darkness 0..1 — how much the shadowed color darkens toward `color`. Default 0.25. */
|
|
160
|
+
opacity?: number;
|
|
161
|
+
/**
|
|
162
|
+
* Depth bias added to the interpolated surface depth before comparing against
|
|
163
|
+
* the shadow map. Eliminates self-shadow acne on flat lit surfaces. Default 0.05.
|
|
164
|
+
*/
|
|
165
|
+
lift?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Maximum world-space extent for the shadow-map ortho projection.
|
|
168
|
+
* Kept for API parity with polycss. Used as the half-extent of the light-space
|
|
169
|
+
* projection volume when larger than the computed scene bounds. Default 2000.
|
|
170
|
+
*/
|
|
171
|
+
maxExtend?: number;
|
|
172
|
+
}
|
|
95
173
|
interface GlyphMeshTransform {
|
|
96
174
|
/** String identifier for the mesh — surfaced as `GlyphMeshHandle.name`. */
|
|
97
175
|
id?: string;
|
|
98
176
|
position?: Vec3;
|
|
99
177
|
scale?: number | Vec3;
|
|
100
178
|
rotation?: Vec3;
|
|
179
|
+
/** This mesh casts shadows onto receiveShadow surfaces. Default false. */
|
|
180
|
+
castShadow?: boolean;
|
|
181
|
+
/** This mesh receives (displays) shadows from castShadow meshes. Default false. */
|
|
182
|
+
receiveShadow?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Relative depth bias (0 = off). Nudges this mesh toward (positive) or away
|
|
185
|
+
* from (negative) the camera in the depth test via `pixelDepth *= 1 + depthBias`
|
|
186
|
+
* — resolving z-fighting against coplanar/coincident geometry. A CSS/DOM
|
|
187
|
+
* renderer decides coincident surfaces by stacking order for free; a
|
|
188
|
+
* projection-painted depth buffer fights, so a tiny bias (e.g. 0.002) lets a
|
|
189
|
+
* dynamic surface (a door/platform flush into a wall/floor) win cleanly.
|
|
190
|
+
*/
|
|
191
|
+
depthBias?: number;
|
|
101
192
|
}
|
|
102
193
|
|
|
103
194
|
/**
|
|
@@ -157,6 +248,32 @@ interface GlyphSceneOptions {
|
|
|
157
248
|
* Default `60`.
|
|
158
249
|
*/
|
|
159
250
|
creaseAngle?: number;
|
|
251
|
+
/**
|
|
252
|
+
* Render both faces of every polygon (no backface culling). Default `false`.
|
|
253
|
+
* Set `true` for single-sided surfaces whose winding isn't guaranteed to face
|
|
254
|
+
* the camera — e.g. BSP level geometry — so "back-wound" faces don't vanish,
|
|
255
|
+
* matching how a CSS/DOM renderer shows both sides.
|
|
256
|
+
*/
|
|
257
|
+
doubleSided?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Supersampled anti-aliasing (solid mode). `1` (default) = off; `2`/`3`
|
|
260
|
+
* rasterize at N× resolution and average down, removing the motion crawl of
|
|
261
|
+
* sub-cell-sized surfaces. Cost ~N².
|
|
262
|
+
*/
|
|
263
|
+
supersample?: number;
|
|
264
|
+
/**
|
|
265
|
+
* Global depth-test deadband (0 = exact, default). A polygon replaces a cell
|
|
266
|
+
* only when nearer by more than this relative fraction, so near-coplanar
|
|
267
|
+
* surfaces keep a stable winner instead of z-fighting per-cell as the camera
|
|
268
|
+
* moves (the tearing a CSS/DOM renderer avoids via stacking order). 0.002–0.01.
|
|
269
|
+
*/
|
|
270
|
+
depthEpsilon?: number;
|
|
271
|
+
/**
|
|
272
|
+
* Temporal anti-aliasing — exponential blend with the previous frame, weight
|
|
273
|
+
* in [0,1). `0` (default) = off. Smooths fast frame-to-frame edge crawl that
|
|
274
|
+
* supersampling can't cover, at the cost of motion ghosting.
|
|
275
|
+
*/
|
|
276
|
+
temporalBlend?: number;
|
|
160
277
|
/**
|
|
161
278
|
* Auto-size the character grid to fill the host element. When `true`, the
|
|
162
279
|
* scene measures one monospace character's pixel size from the live `<pre>`
|
|
@@ -166,6 +283,8 @@ interface GlyphSceneOptions {
|
|
|
166
283
|
* (default 80×24) is the predictable choice for tests and SSR.
|
|
167
284
|
*/
|
|
168
285
|
autoSize?: boolean;
|
|
286
|
+
/** Shadow-map configuration. `undefined` (default) = no shadows. */
|
|
287
|
+
shadow?: GlyphShadowOptions;
|
|
169
288
|
}
|
|
170
289
|
interface GlyphHotspotOptions {
|
|
171
290
|
id: string;
|
|
@@ -310,4 +429,4 @@ declare class GlyphMapControlsElement extends ELEMENT_BASE {
|
|
|
310
429
|
private _attach;
|
|
311
430
|
}
|
|
312
431
|
|
|
313
|
-
export { type GlyphSceneHandle as G, type GlyphCamera as a, type GlyphDirectionalLight as b, type GlyphAmbientLight as c,
|
|
432
|
+
export { DEFAULT_PERSPECTIVE as D, type GlyphSceneHandle as G, type GlyphCamera as a, type GlyphDirectionalLight as b, type GlyphAmbientLight as c, type GlyphShadowOptions as d, GlyphHotspotElement as e, type GlyphHotspotHandle as f, type GlyphHotspotOptions as g, GlyphMapControlsElement as h, GlyphMeshElement as i, type GlyphMeshHandle as j, type GlyphMeshTransform as k, GlyphOrbitControlsElement as l, GlyphOrthographicCameraElement as m, type GlyphOrthographicCameraHandle as n, type GlyphOrthographicCameraOptions as o, GlyphPerspectiveCameraElement as p, type GlyphPerspectiveCameraHandle as q, type GlyphPerspectiveCameraOptions as r, GlyphSceneElement as s, type GlyphSceneOptions as t, createGlyphCamera as u, createGlyphOrthographicCamera as v, createGlyphPerspectiveCamera as w, createGlyphScene as x };
|