@ascii-fx/three 0.9.0 → 0.10.0
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/README.md +8 -4
- package/dist/asciiPass.d.ts +19 -4
- package/dist/index.js +43 -8
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -12,28 +12,32 @@ import { AsciiPass } from '@ascii-fx/three'
|
|
|
12
12
|
|
|
13
13
|
const renderer = new THREE.WebGPURenderer()
|
|
14
14
|
const pass = new AsciiPass({ renderer, profile, columns: 160 })
|
|
15
|
+
await pass.init() // compiles the pipelines, and initializes the renderer if you haven't
|
|
15
16
|
|
|
16
17
|
renderer.setAnimationLoop(() => pass.render(scene, camera))
|
|
17
18
|
```
|
|
18
19
|
|
|
20
|
+
`pass.render()` replaces `renderer.render()`. The scene goes through three's own output pass first, so the renderer's `toneMapping`, `outputColorSpace` and antialiasing all apply and the glyphs are matched against the picture the canvas would have shown. The render target follows the renderer's drawing buffer, so `renderer.setSize()` on a window resize is all a resize takes; pass `width`/`height`, or call `pass.setSize()`, to pin it instead.
|
|
21
|
+
|
|
19
22
|
## Why WebGPURenderer only
|
|
20
23
|
|
|
21
24
|
The pass runs the matcher **on Three's own `GPUDevice`** — the scene's render target is matched and composited in place, with no readback. That's what keeps it cheap enough to run every frame.
|
|
22
25
|
|
|
23
|
-
A WebGL renderer can't do that. Matching a WebGL-rendered scene exactly would mean pulling every frame back to the CPU, matching there, and pushing the result up again — a GPU→CPU→GPU round trip per frame, which is slow enough to defeat the point. Rather than ship a "supported" path that's quietly 20× slower, this package requires `THREE.WebGPURenderer`
|
|
26
|
+
A WebGL renderer can't do that. Matching a WebGL-rendered scene exactly would mean pulling every frame back to the CPU, matching there, and pushing the result up again — a GPU→CPU→GPU round trip per frame, which is slow enough to defeat the point. Rather than ship a "supported" path that's quietly 20× slower, this package requires `THREE.WebGPURenderer` and says so. It reaches the renderer's `GPUDevice` through `renderer.backend`, which three does not document; the test suite runs against r187.
|
|
24
27
|
|
|
25
28
|
If you're on WebGL and want ASCII, render your scene to a canvas and feed that canvas to [`@ascii-fx/gpu`](../gpu) as a source — you'll pay the readback, but explicitly.
|
|
26
29
|
|
|
27
30
|
## Glyphs as geometry
|
|
28
31
|
|
|
29
|
-
`AsciiGlyphs` is the other direction: an instanced mesh of glyph quads you can place in the scene
|
|
32
|
+
`AsciiGlyphs` is the other direction: an instanced mesh of glyph quads you can place in the scene and move with the camera, rather than a full-frame post effect. It displays a frame you matched elsewhere — `matchFrame()` from `@ascii-fx/core`, or a renderer's `captureFrame()` — and is unlit: each glyph is drawn in its frame colours.
|
|
30
33
|
|
|
31
34
|
```ts
|
|
35
|
+
import { matchFrame } from '@ascii-fx/core'
|
|
32
36
|
import { AsciiGlyphs } from '@ascii-fx/three'
|
|
33
37
|
|
|
34
38
|
const glyphs = new AsciiGlyphs({ profile, columns: 120, rows: 40 })
|
|
35
|
-
scene.add(glyphs)
|
|
36
|
-
glyphs.
|
|
39
|
+
scene.add(glyphs.mesh)
|
|
40
|
+
glyphs.updateFromFrame(matchFrame(image, { profile, columns: 120, rows: 40, color: 'full' }))
|
|
37
41
|
```
|
|
38
42
|
|
|
39
43
|
One draw call for the whole grid.
|
package/dist/asciiPass.d.ts
CHANGED
|
@@ -6,7 +6,11 @@ import type { AsciiPointer, FitMode, InteractionOptions, PostOptions, StreamMatc
|
|
|
6
6
|
export interface AsciiPassOptions extends StreamMatchOptions {
|
|
7
7
|
profile: AsciiProfile;
|
|
8
8
|
renderer: WebGPURenderer;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Render-target resolution. Left out, it is the renderer's drawing buffer size and follows
|
|
11
|
+
* it, so `renderer.setSize()` on a window resize is all a resize takes. Given here, or
|
|
12
|
+
* through `setSize()`, it stays where it was put.
|
|
13
|
+
*/
|
|
10
14
|
width?: number;
|
|
11
15
|
height?: number;
|
|
12
16
|
fit?: FitMode;
|
|
@@ -27,8 +31,12 @@ type ViewOptions = {
|
|
|
27
31
|
* scene → render target → exact structural-v1 compute on Three's own
|
|
28
32
|
* GPUDevice → one-draw atlas composite straight to the canvas.
|
|
29
33
|
*
|
|
30
|
-
* The
|
|
31
|
-
*
|
|
34
|
+
* The scene is matched as it would have been displayed. The render target is set as the
|
|
35
|
+
* renderer's *output* target, so three runs its own output pass into it — the renderer's
|
|
36
|
+
* `toneMapping` and `outputColorSpace`, and its antialiasing — and what is matched is the
|
|
37
|
+
* picture the canvas would have shown. A three release without output targets renders
|
|
38
|
+
* straight into the target instead: linear light, no tone mapping, sRGB-encoded here before
|
|
39
|
+
* matching (§28). Usage:
|
|
32
40
|
*
|
|
33
41
|
* ```ts
|
|
34
42
|
* const pass = new AsciiPass({ profile, renderer, columns: 160 })
|
|
@@ -53,16 +61,23 @@ export declare class AsciiPass {
|
|
|
53
61
|
private velY;
|
|
54
62
|
private readonly t0;
|
|
55
63
|
private readonly drawSize;
|
|
64
|
+
/** Whether the render target follows the renderer's drawing buffer (no explicit size). */
|
|
65
|
+
private autoSize;
|
|
56
66
|
private engine?;
|
|
57
67
|
private stream?;
|
|
58
68
|
private device?;
|
|
59
69
|
private disposed;
|
|
60
70
|
constructor(options: AsciiPassOptions);
|
|
61
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Compile pipelines on the renderer's device. Call once, and await it before the first
|
|
73
|
+
* `render()`. Initializes the renderer too if nothing has yet — three hands back the same
|
|
74
|
+
* promise to every caller, so an `await renderer.init()` of your own is harmless.
|
|
75
|
+
*/
|
|
62
76
|
init(): Promise<void>;
|
|
63
77
|
/** Update matcher/composite options (spec §2: `ascii.set({...})`). */
|
|
64
78
|
set(options: Partial<StreamMatchOptions & ViewOptions>): void;
|
|
65
79
|
setInteraction(interaction: InteractionOptions | null): void;
|
|
80
|
+
/** Pin the render-target resolution. After this it no longer follows the drawing buffer. */
|
|
66
81
|
setSize(width: number, height: number): void;
|
|
67
82
|
grid(): {
|
|
68
83
|
columns: number;
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ function getCanvasContext(renderer) {
|
|
|
17
17
|
const context = backendOf(renderer)?.context;
|
|
18
18
|
if (!context) {
|
|
19
19
|
throw new Error(
|
|
20
|
-
"Could not access the WebGPU canvas context via renderer.backend (
|
|
20
|
+
"Could not access the WebGPU canvas context via renderer.backend (tested against three r187)."
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
return context;
|
|
@@ -27,7 +27,7 @@ function getGpuTexture(renderer, texture2) {
|
|
|
27
27
|
const gpuTexture = data?.texture;
|
|
28
28
|
if (!gpuTexture) {
|
|
29
29
|
throw new Error(
|
|
30
|
-
"Could not access the render target GPU texture via renderer.backend \u2014 render to the target once first (
|
|
30
|
+
"Could not access the render target GPU texture via renderer.backend \u2014 render to the target once first (tested against three r187)."
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
return gpuTexture;
|
|
@@ -51,6 +51,8 @@ var AsciiPass = class {
|
|
|
51
51
|
velY = 0;
|
|
52
52
|
t0 = performance.now();
|
|
53
53
|
drawSize = new Vector2();
|
|
54
|
+
/** Whether the render target follows the renderer's drawing buffer (no explicit size). */
|
|
55
|
+
autoSize;
|
|
54
56
|
engine;
|
|
55
57
|
stream;
|
|
56
58
|
device;
|
|
@@ -76,6 +78,7 @@ var AsciiPass = class {
|
|
|
76
78
|
this.palette = palette ?? null;
|
|
77
79
|
this.post = post ?? null;
|
|
78
80
|
this.interaction = interaction ?? null;
|
|
81
|
+
this.autoSize = width === void 0 && height === void 0;
|
|
79
82
|
const size = renderer.getDrawingBufferSize(this.drawSize);
|
|
80
83
|
this.renderTarget = new RenderTarget(
|
|
81
84
|
width ?? Math.max(1, size.x),
|
|
@@ -92,10 +95,16 @@ var AsciiPass = class {
|
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
}
|
|
95
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Compile pipelines on the renderer's device. Call once, and await it before the first
|
|
100
|
+
* `render()`. Initializes the renderer too if nothing has yet — three hands back the same
|
|
101
|
+
* promise to every caller, so an `await renderer.init()` of your own is harmless.
|
|
102
|
+
*/
|
|
96
103
|
async init() {
|
|
97
104
|
if (this.disposed) throw new Error("AsciiPass.init() called after dispose().");
|
|
98
105
|
if (this.stream) return;
|
|
106
|
+
await this.rendererRef.init();
|
|
107
|
+
if (this.disposed) return;
|
|
99
108
|
const device = getDevice(this.rendererRef);
|
|
100
109
|
const engine = await AsciiEngine.create(device, this.profile);
|
|
101
110
|
if (this.disposed) {
|
|
@@ -129,7 +138,9 @@ var AsciiPass = class {
|
|
|
129
138
|
setInteraction(interaction) {
|
|
130
139
|
this.interaction = interaction;
|
|
131
140
|
}
|
|
141
|
+
/** Pin the render-target resolution. After this it no longer follows the drawing buffer. */
|
|
132
142
|
setSize(width, height) {
|
|
143
|
+
this.autoSize = false;
|
|
133
144
|
this.renderTarget.setSize(width, height);
|
|
134
145
|
}
|
|
135
146
|
grid() {
|
|
@@ -145,20 +156,44 @@ var AsciiPass = class {
|
|
|
145
156
|
);
|
|
146
157
|
}
|
|
147
158
|
const renderer = this.rendererRef;
|
|
159
|
+
const size = renderer.getDrawingBufferSize(this.drawSize);
|
|
160
|
+
if (this.autoSize) {
|
|
161
|
+
const w = Math.max(1, size.x);
|
|
162
|
+
const h = Math.max(1, size.y);
|
|
163
|
+
if (this.renderTarget.width !== w || this.renderTarget.height !== h) {
|
|
164
|
+
this.renderTarget.setSize(w, h);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const output = renderer;
|
|
168
|
+
const viaOutputPass = typeof output.setOutputRenderTarget === "function" && typeof output.getOutputRenderTarget === "function";
|
|
148
169
|
const prev = renderer.getRenderTarget();
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
170
|
+
if (viaOutputPass) {
|
|
171
|
+
const prevOutput = output.getOutputRenderTarget();
|
|
172
|
+
renderer.setRenderTarget(null);
|
|
173
|
+
output.setOutputRenderTarget(this.renderTarget);
|
|
174
|
+
try {
|
|
175
|
+
renderer.render(scene, camera);
|
|
176
|
+
} finally {
|
|
177
|
+
output.setOutputRenderTarget(prevOutput);
|
|
178
|
+
renderer.setRenderTarget(prev);
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
renderer.setRenderTarget(this.renderTarget);
|
|
182
|
+
renderer.render(scene, camera);
|
|
183
|
+
renderer.setRenderTarget(prev);
|
|
184
|
+
}
|
|
152
185
|
const srcTexture = getGpuTexture(renderer, this.renderTarget.texture);
|
|
153
186
|
stream.configure(srcTexture, this.renderTarget.width, this.renderTarget.height, {
|
|
154
|
-
|
|
187
|
+
// The output pass has already encoded; a plain render target is still linear.
|
|
188
|
+
srgbEncode: !viaOutputPass,
|
|
155
189
|
alpha: "ignore",
|
|
190
|
+
// A motion-driven interaction needs the field computed, as the gpu renderer arranges.
|
|
191
|
+
motion: this.interaction?.source === "motion" ? this.interaction.motion ?? {} : void 0,
|
|
156
192
|
...this.matchOpts
|
|
157
193
|
});
|
|
158
194
|
const cenc = this.device.createCommandEncoder();
|
|
159
195
|
stream.encodeMatch(cenc);
|
|
160
196
|
this.device.queue.submit([cenc.finish()]);
|
|
161
|
-
const size = renderer.getDrawingBufferSize(this.drawSize);
|
|
162
197
|
stream.syncView({
|
|
163
198
|
width: size.x,
|
|
164
199
|
height: size.y,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/asciiPass.ts","../src/internals.ts","../src/asciiGlyphs.ts"],"sourcesContent":["import { RenderTarget, Vector2 } from 'three'\nimport type { Camera, Object3D } from 'three'\nimport type { WebGPURenderer } from 'three/webgpu'\nimport type { AsciiFrame, AsciiProfile, PaletteOptions } from '@ascii-fx/core'\nimport { AsciiEngine, AsciiStream } from '@ascii-fx/gpu/webgpu'\nimport type {\n AsciiPointer,\n FitMode,\n InteractionOptions,\n PostOptions,\n StreamMatchOptions,\n} from '@ascii-fx/gpu'\nimport { getCanvasContext, getDevice, getGpuTexture } from './internals.js'\n\nexport interface AsciiPassOptions extends StreamMatchOptions {\n profile: AsciiProfile\n renderer: WebGPURenderer\n /** Render-target resolution; defaults to the renderer's drawing buffer size. */\n width?: number\n height?: number\n fit?: FitMode\n clearColor?: readonly [number, number, number, number]\n interaction?: InteractionOptions | null\n /** palette-v1 colour snap between matching and the composite; see AsciiRendererOptions. */\n palette?: PaletteOptions | null\n post?: PostOptions | null\n}\n\ntype ViewOptions = {\n fit: FitMode\n clearColor: readonly [number, number, number, number]\n palette: PaletteOptions | null\n post: PostOptions | null\n}\n\n/**\n * Fullscreen ASCII postprocessing for THREE.WebGPURenderer (spec §30):\n * scene → render target → exact structural-v1 compute on Three's own\n * GPUDevice → one-draw atlas composite straight to the canvas.\n *\n * The render target holds linear-light values, so the source is sRGB-encoded\n * before matching (§28). Usage:\n *\n * ```ts\n * const pass = new AsciiPass({ profile, renderer, columns: 160 })\n * await pass.init()\n * pass.render(scene, camera) // instead of renderer.render(...)\n * ```\n */\nexport class AsciiPass {\n readonly renderTarget: RenderTarget\n readonly pointer: AsciiPointer\n\n private readonly rendererRef: WebGPURenderer\n private readonly profile: AsciiProfile\n private matchOpts: StreamMatchOptions\n private fit: FitMode | undefined\n private clearColor: readonly [number, number, number, number] | undefined\n private palette: PaletteOptions | null\n private post: PostOptions | null\n private interaction: InteractionOptions | null\n private pointerX = 0.5\n private pointerY = 0.5\n private velX = 0\n private velY = 0\n private readonly t0 = performance.now()\n private readonly drawSize = new Vector2()\n\n private engine?: AsciiEngine\n private stream?: AsciiStream\n private device?: GPUDevice\n private disposed = false\n\n constructor(options: AsciiPassOptions) {\n const {\n profile,\n renderer,\n width,\n height,\n fit,\n clearColor,\n interaction,\n palette,\n post,\n ...match\n } = options\n this.profile = profile\n this.rendererRef = renderer\n this.matchOpts = match\n this.fit = fit\n this.clearColor = clearColor\n this.palette = palette ?? null\n this.post = post ?? null\n this.interaction = interaction ?? null\n const size = renderer.getDrawingBufferSize(this.drawSize)\n this.renderTarget = new RenderTarget(\n width ?? Math.max(1, size.x),\n height ?? Math.max(1, size.y),\n )\n this.pointer = {\n set: (x: number, y: number) => {\n this.pointerX = x\n this.pointerY = y\n },\n setVelocity: (x: number, y: number) => {\n this.velX = x\n this.velY = y\n },\n }\n }\n\n /** Compile pipelines on the renderer's device. Call once after renderer.init(). */\n async init(): Promise<void> {\n if (this.disposed) throw new Error('AsciiPass.init() called after dispose().')\n if (this.stream) return\n const device = getDevice(this.rendererRef)\n const engine = await AsciiEngine.create(device, this.profile)\n if (this.disposed) {\n engine.destroy()\n return\n }\n try {\n const stream = await engine.createStream(navigator.gpu.getPreferredCanvasFormat())\n if (this.disposed) {\n stream.destroy()\n engine.destroy()\n return\n }\n this.device = device\n this.engine = engine\n this.stream = stream\n } catch (error) {\n engine.destroy()\n throw error\n }\n }\n\n /** Update matcher/composite options (spec §2: `ascii.set({...})`). */\n set(options: Partial<StreamMatchOptions & ViewOptions>): void {\n const { fit, clearColor, palette, post, ...match } = options\n if (fit !== undefined) this.fit = fit\n if (clearColor !== undefined) this.clearColor = clearColor\n if (palette !== undefined) this.palette = palette\n if (post !== undefined) this.post = post\n this.matchOpts = { ...this.matchOpts, ...match }\n }\n\n setInteraction(interaction: InteractionOptions | null): void {\n this.interaction = interaction\n }\n\n setSize(width: number, height: number): void {\n this.renderTarget.setSize(width, height)\n }\n\n grid(): { columns: number; rows: number } | null {\n return this.stream?.grid() ?? null\n }\n\n /** Render the scene through the ASCII pipeline to the canvas. */\n render(scene: Object3D, camera: Camera): void {\n if (this.disposed) return\n const stream = this.stream\n if (!stream || !this.device) {\n throw new Error(\n 'AsciiPass.render() called before init() — `await pass.init()` after creating the pass.',\n )\n }\n const renderer = this.rendererRef\n\n const prev = renderer.getRenderTarget()\n renderer.setRenderTarget(this.renderTarget)\n renderer.render(scene, camera)\n renderer.setRenderTarget(prev)\n\n const srcTexture = getGpuTexture(renderer, this.renderTarget.texture)\n stream.configure(srcTexture, this.renderTarget.width, this.renderTarget.height, {\n srgbEncode: true,\n alpha: 'ignore',\n ...this.matchOpts,\n })\n\n const cenc = this.device.createCommandEncoder()\n stream.encodeMatch(cenc)\n this.device.queue.submit([cenc.finish()])\n\n const size = renderer.getDrawingBufferSize(this.drawSize)\n stream.syncView({\n width: size.x,\n height: size.y,\n fit: this.fit,\n clearColor: this.clearColor,\n palette: this.palette,\n post: this.post,\n })\n stream.syncFx(\n {\n interaction: this.interaction,\n pointerX: this.pointerX * size.x,\n pointerY: this.pointerY * size.y,\n velX: this.velX,\n velY: this.velY,\n time: (performance.now() - this.t0) / 1000,\n },\n size.x,\n size.y,\n )\n const enc = this.device.createCommandEncoder()\n stream.encodeComposite(enc, getCanvasContext(renderer).getCurrentTexture().createView())\n this.device.queue.submit([enc.finish()])\n }\n\n /** Explicit readback of the matched frame (spec §33). */\n async captureFrame(): Promise<AsciiFrame> {\n if (!this.stream)\n throw new Error('AsciiPass.captureFrame() requires init() and at least one render().')\n return this.stream.captureFrame()\n }\n\n dispose(): void {\n if (this.disposed) return\n this.disposed = true\n this.renderTarget.dispose()\n this.stream?.destroy()\n this.engine?.destroy() // engine resources only — the device belongs to Three\n }\n}\n","// Access to WebGPURenderer backend internals. Three does not yet expose the\n// GPUDevice / canvas context / texture handles publicly; these accessors are\n// the supported-in-practice interop points, verified against r170–r185.\nimport type { Texture } from 'three'\nimport type { WebGPURenderer } from 'three/webgpu'\n\ninterface BackendLike {\n device?: GPUDevice\n context?: GPUCanvasContext\n get?: (object: unknown) => { texture?: GPUTexture } | undefined\n}\n\nconst backendOf = (renderer: WebGPURenderer): BackendLike | undefined =>\n (renderer as unknown as { backend?: BackendLike }).backend\n\nexport function getDevice(renderer: WebGPURenderer): GPUDevice {\n const device = backendOf(renderer)?.device\n if (!device) {\n throw new Error(\n 'AsciiPass requires an initialized THREE.WebGPURenderer — `await renderer.init()` first. ' +\n 'WebGL renderers are unsupported: exact matching would require per-frame GPU→CPU readback (spec §30).',\n )\n }\n return device\n}\n\nexport function getCanvasContext(renderer: WebGPURenderer): GPUCanvasContext {\n const context = backendOf(renderer)?.context\n if (!context) {\n throw new Error(\n 'Could not access the WebGPU canvas context via renderer.backend (supported: three r170–r185).',\n )\n }\n return context\n}\n\nexport function getGpuTexture(renderer: WebGPURenderer, texture: Texture): GPUTexture {\n const data = backendOf(renderer)?.get?.(texture)\n const gpuTexture = data?.texture\n if (!gpuTexture) {\n throw new Error(\n 'Could not access the render target GPU texture via renderer.backend — render to the target once first ' +\n '(supported: three r170–r185).',\n )\n }\n return gpuTexture\n}\n","import {\n DataTexture,\n InstancedBufferAttribute,\n InstancedMesh,\n LinearFilter,\n LinearMipmapLinearFilter,\n Matrix4,\n PlaneGeometry,\n RedFormat,\n UnsignedByteType,\n} from 'three'\nimport { MeshBasicNodeMaterial } from 'three/webgpu'\nimport { add, attribute, div, float, floor, mix, mod, mul, texture, uv, vec2 } from 'three/tsl'\nimport type { AsciiFrame, AsciiProfile } from '@ascii-fx/core'\nimport { FLAG_TRANSPARENT, blankGlyphId, unpackB, unpackG, unpackR } from '@ascii-fx/core'\n\nexport interface AsciiGlyphsOptions {\n profile: AsciiProfile\n columns: number\n rows: number\n /** World-space cell height. Default 1. */\n cellSize?: number\n}\n\n/**\n * Instanced 3D glyph renderer (spec §8 'instances', §30): one plane instance\n * per cell, glyph/colors as instanced attributes, atlas sampled via TSL.\n * Instance transforms live in the standard instanceMatrix so effects can\n * animate them (GPU-side via node materials, or CPU-side via setMatrixAt).\n *\n * v1 data path: populate from a captured AsciiFrame (`updateFromFrame`).\n * A zero-readback bridge from the GPU cell buffer is a planned optimization.\n */\nexport class AsciiGlyphs {\n readonly mesh: InstancedMesh\n readonly material: MeshBasicNodeMaterial\n readonly columns: number\n readonly rows: number\n\n private readonly aGlyph: InstancedBufferAttribute\n private readonly aFg: InstancedBufferAttribute\n private readonly aBg: InstancedBufferAttribute\n private readonly aVisible: InstancedBufferAttribute\n private readonly aUseBackground: InstancedBufferAttribute\n private readonly atlasTexture: DataTexture\n private readonly profileFingerprint: string\n private readonly glyphCount: number\n private readonly blankGlyph: number\n\n constructor(options: AsciiGlyphsOptions) {\n const { profile, columns, rows } = options\n const cellSize = options.cellSize ?? 1\n this.columns = columns\n this.rows = rows\n this.profileFingerprint = profile.fingerprint\n this.glyphCount = profile.glyphCount\n this.blankGlyph = blankGlyphId(profile)\n const { atlas } = profile\n const aspect = atlas.cellWidth / atlas.cellHeight\n const count = columns * rows\n\n const geometry = new PlaneGeometry(cellSize * aspect, cellSize)\n this.aGlyph = new InstancedBufferAttribute(new Float32Array(count), 1)\n this.aFg = new InstancedBufferAttribute(new Float32Array(count * 3).fill(1), 3)\n this.aBg = new InstancedBufferAttribute(new Float32Array(count * 3), 3)\n this.aVisible = new InstancedBufferAttribute(new Float32Array(count).fill(1), 1)\n this.aUseBackground = new InstancedBufferAttribute(new Float32Array(count).fill(1), 1)\n geometry.setAttribute('aGlyph', this.aGlyph)\n geometry.setAttribute('aFg', this.aFg)\n geometry.setAttribute('aBg', this.aBg)\n geometry.setAttribute('aVisible', this.aVisible)\n geometry.setAttribute('aUseBackground', this.aUseBackground)\n\n this.atlasTexture = new DataTexture(\n atlas.data as Uint8Array<ArrayBuffer>,\n atlas.width,\n atlas.height,\n RedFormat,\n UnsignedByteType,\n )\n this.atlasTexture.flipY = false\n this.atlasTexture.magFilter = LinearFilter\n this.atlasTexture.minFilter = LinearMipmapLinearFilter\n this.atlasTexture.generateMipmaps = true\n this.atlasTexture.needsUpdate = true\n\n this.material = new MeshBasicNodeMaterial()\n // @types/three cannot yet type composed TSL node graphs; the runtime API\n // is stable, so the graph is built through a single contained cast.\n /* eslint-disable @typescript-eslint/no-explicit-any */\n const n = {\n add,\n attribute,\n div,\n float,\n floor,\n mix,\n mod,\n mul,\n texture,\n uv,\n vec2,\n } as unknown as Record<\n | 'add'\n | 'attribute'\n | 'div'\n | 'float'\n | 'floor'\n | 'mix'\n | 'mod'\n | 'mul'\n | 'texture'\n | 'uv'\n | 'vec2',\n (...args: any[]) => any\n >\n /* eslint-enable @typescript-eslint/no-explicit-any */\n const id = n.attribute('aGlyph')\n const col = n.mod(id, n.float(atlas.columns))\n const row = n.floor(n.div(id, n.float(atlas.columns)))\n const tile = n.vec2(\n n.add(n.mul(col, n.float(atlas.pitchWidth)), n.float(atlas.padding)),\n n.add(n.mul(row, n.float(atlas.pitchHeight)), n.float(atlas.padding)),\n )\n // PlaneGeometry uv has v=0 at the bottom; the atlas is y-down: flip v.\n const guv = n.add(n.mul(n.uv(), n.vec2(1, -1)), n.vec2(0, 1))\n const texel = n.add(tile, n.mul(guv, n.vec2(atlas.cellWidth, atlas.cellHeight)))\n const auv = n.div(texel, n.vec2(atlas.width, atlas.height))\n const alpha = n.texture(this.atlasTexture, auv).r\n const foreground = n.attribute('aFg')\n const useBackground = n.attribute('aUseBackground')\n const cellColor = n.mix(n.attribute('aBg'), foreground, alpha)\n this.material.colorNode = n.mix(foreground, cellColor, useBackground)\n this.material.opacityNode = n.mul(\n n.attribute('aVisible'),\n n.mix(alpha, n.float(1), useBackground),\n )\n this.material.transparent = true\n this.material.depthWrite = false\n\n this.mesh = new InstancedMesh(geometry, this.material, count)\n this.mesh.frustumCulled = false\n const m = new Matrix4()\n const cw = cellSize * aspect\n for (let cy = 0; cy < rows; cy++) {\n for (let cx = 0; cx < columns; cx++) {\n m.makeTranslation((cx - (columns - 1) / 2) * cw, ((rows - 1) / 2 - cy) * cellSize, 0)\n this.mesh.setMatrixAt(cy * columns + cx, m)\n }\n }\n this.mesh.instanceMatrix.needsUpdate = true\n }\n\n /** Load glyph ids and colors from a matched frame (same grid dimensions). */\n updateFromFrame(frame: AsciiFrame): void {\n if (frame.profile.fingerprint !== this.profileFingerprint) {\n throw new Error(\n `Frame profile \"${frame.profile.id}\" (${frame.profile.fingerprint.slice(0, 12)}…) does not match ` +\n `AsciiGlyphs profile (${this.profileFingerprint.slice(0, 12)}…).`,\n )\n }\n if (frame.columns !== this.columns || frame.rows !== this.rows) {\n throw new Error(\n `Frame grid ${frame.columns}×${frame.rows} does not match AsciiGlyphs grid ${this.columns}×${this.rows}.`,\n )\n }\n const n = this.columns * this.rows\n const g = this.aGlyph.array as Float32Array\n const fg = this.aFg.array as Float32Array\n const bg = this.aBg.array as Float32Array\n const visible = this.aVisible.array as Float32Array\n const useBackground = this.aUseBackground.array as Float32Array\n for (let i = 0; i < n; i++) {\n const transparent = (frame.flags[i] & FLAG_TRANSPARENT) !== 0\n const glyphId = frame.glyphIds[i]\n if (glyphId >= this.glyphCount) {\n throw new Error(\n `Frame cell ${i} references glyph ${glyphId}, but the profile has ${this.glyphCount} glyphs.`,\n )\n }\n g[i] = transparent ? this.blankGlyph : glyphId\n visible[i] = transparent ? 0 : 1\n useBackground[i] = frame.colorMode === 'foreground' ? 0 : 1\n const fgc = frame.foreground?.[i]\n const bgc = frame.background?.[i]\n fg[i * 3] = fgc !== undefined ? unpackR(fgc) / 255 : 1\n fg[i * 3 + 1] = fgc !== undefined ? unpackG(fgc) / 255 : 1\n fg[i * 3 + 2] = fgc !== undefined ? unpackB(fgc) / 255 : 1\n bg[i * 3] = bgc !== undefined ? unpackR(bgc) / 255 : 0\n bg[i * 3 + 1] = bgc !== undefined ? unpackG(bgc) / 255 : 0\n bg[i * 3 + 2] = bgc !== undefined ? unpackB(bgc) / 255 : 0\n }\n this.aGlyph.needsUpdate = true\n this.aFg.needsUpdate = true\n this.aBg.needsUpdate = true\n this.aVisible.needsUpdate = true\n this.aUseBackground.needsUpdate = true\n }\n\n dispose(): void {\n // The mesh's own dispose releases its instanced attributes (instanceMatrix et al.);\n // without it their GPU buffers wait on backend WeakMap GC.\n this.mesh.dispose()\n this.mesh.geometry.dispose()\n this.material.dispose()\n this.atlasTexture.dispose()\n }\n}\n"],"mappings":";AAAA,SAAS,cAAc,eAAe;AAItC,SAAS,mBAAgC;;;ACQzC,IAAM,YAAY,CAAC,aAChB,SAAkD;AAE9C,SAAS,UAAU,UAAqC;AAC7D,QAAM,SAAS,UAAU,QAAQ,GAAG;AACpC,MA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AAChC,SAAG,IAAI,CAAC,IAAI,QAAQ,SAAY,QAAQ,GAAG,IAAI,MAAM;AACrD,SAAG,IAAI,IAAI,CAAC,IAAI,QAAQ,SAAY,QAAQ,GAAG,IAAI,MAAM;AACzD,SAAG,IAAI,IAAI,CAAC,IAAI,QAAQ,SAAY,QAAQ,GAAG,IAAI,MAAM;AACzD,SAAG,IAAI,CAAC,IAAI,QAAQ,SAAY,QAAQ,GAAG,IAAI,MAAM;AACrD,SAAG,IAAI,IAAI,CAAC,IAAI,QAAQ,SAAY,QAAQ,GAAG,IAAI,MAAM;AACzD,SAAG,IAAI,IAAI,CAAC,IAAI,QAAQ,SAAY,QAAQ,GAAG,IAAI,MAAM;AAAA,IAC3D;AACA,SAAK,OAAO,cAAc;AAC1B,SAAK,IAAI,cAAc;AACvB,SAAK,IAAI,cAAc;AACvB,SAAK,SAAS,cAAc;AAC5B,SAAK,eAAe,cAAc;AAAA,EACpC;AAAA,EAEA,UAAgB;AAGd,SAAK,KAAK,QAAQ;AAClB,SAAK,KAAK,SAAS,QAAQ;AAC3B,SAAK,SAAS,QAAQ;AACtB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;","names":["texture"]}
|
|
1
|
+
{"version":3,"sources":["../src/asciiPass.ts","../src/internals.ts","../src/asciiGlyphs.ts"],"sourcesContent":["import { RenderTarget, Vector2 } from 'three'\nimport type { Camera, Object3D } from 'three'\nimport type { WebGPURenderer } from 'three/webgpu'\nimport type { AsciiFrame, AsciiProfile, PaletteOptions } from '@ascii-fx/core'\nimport { AsciiEngine, AsciiStream } from '@ascii-fx/gpu/webgpu'\nimport type {\n AsciiPointer,\n FitMode,\n InteractionOptions,\n PostOptions,\n StreamMatchOptions,\n} from '@ascii-fx/gpu'\nimport { getCanvasContext, getDevice, getGpuTexture } from './internals.js'\n\nexport interface AsciiPassOptions extends StreamMatchOptions {\n profile: AsciiProfile\n renderer: WebGPURenderer\n /**\n * Render-target resolution. Left out, it is the renderer's drawing buffer size and follows\n * it, so `renderer.setSize()` on a window resize is all a resize takes. Given here, or\n * through `setSize()`, it stays where it was put.\n */\n width?: number\n height?: number\n fit?: FitMode\n clearColor?: readonly [number, number, number, number]\n interaction?: InteractionOptions | null\n /** palette-v1 colour snap between matching and the composite; see AsciiRendererOptions. */\n palette?: PaletteOptions | null\n post?: PostOptions | null\n}\n\ntype ViewOptions = {\n fit: FitMode\n clearColor: readonly [number, number, number, number]\n palette: PaletteOptions | null\n post: PostOptions | null\n}\n\n/** The output-target half of Renderer, which older three releases do not have. */\ninterface OutputTargetRenderer {\n setOutputRenderTarget?: (target: RenderTarget | null) => void\n getOutputRenderTarget?: () => RenderTarget | null\n}\n\n/**\n * Fullscreen ASCII postprocessing for THREE.WebGPURenderer (spec §30):\n * scene → render target → exact structural-v1 compute on Three's own\n * GPUDevice → one-draw atlas composite straight to the canvas.\n *\n * The scene is matched as it would have been displayed. The render target is set as the\n * renderer's *output* target, so three runs its own output pass into it — the renderer's\n * `toneMapping` and `outputColorSpace`, and its antialiasing — and what is matched is the\n * picture the canvas would have shown. A three release without output targets renders\n * straight into the target instead: linear light, no tone mapping, sRGB-encoded here before\n * matching (§28). Usage:\n *\n * ```ts\n * const pass = new AsciiPass({ profile, renderer, columns: 160 })\n * await pass.init()\n * pass.render(scene, camera) // instead of renderer.render(...)\n * ```\n */\nexport class AsciiPass {\n readonly renderTarget: RenderTarget\n readonly pointer: AsciiPointer\n\n private readonly rendererRef: WebGPURenderer\n private readonly profile: AsciiProfile\n private matchOpts: StreamMatchOptions\n private fit: FitMode | undefined\n private clearColor: readonly [number, number, number, number] | undefined\n private palette: PaletteOptions | null\n private post: PostOptions | null\n private interaction: InteractionOptions | null\n private pointerX = 0.5\n private pointerY = 0.5\n private velX = 0\n private velY = 0\n private readonly t0 = performance.now()\n private readonly drawSize = new Vector2()\n /** Whether the render target follows the renderer's drawing buffer (no explicit size). */\n private autoSize: boolean\n\n private engine?: AsciiEngine\n private stream?: AsciiStream\n private device?: GPUDevice\n private disposed = false\n\n constructor(options: AsciiPassOptions) {\n const {\n profile,\n renderer,\n width,\n height,\n fit,\n clearColor,\n interaction,\n palette,\n post,\n ...match\n } = options\n this.profile = profile\n this.rendererRef = renderer\n this.matchOpts = match\n this.fit = fit\n this.clearColor = clearColor\n this.palette = palette ?? null\n this.post = post ?? null\n this.interaction = interaction ?? null\n this.autoSize = width === undefined && height === undefined\n const size = renderer.getDrawingBufferSize(this.drawSize)\n this.renderTarget = new RenderTarget(\n width ?? Math.max(1, size.x),\n height ?? Math.max(1, size.y),\n )\n this.pointer = {\n set: (x: number, y: number) => {\n this.pointerX = x\n this.pointerY = y\n },\n setVelocity: (x: number, y: number) => {\n this.velX = x\n this.velY = y\n },\n }\n }\n\n /**\n * Compile pipelines on the renderer's device. Call once, and await it before the first\n * `render()`. Initializes the renderer too if nothing has yet — three hands back the same\n * promise to every caller, so an `await renderer.init()` of your own is harmless.\n */\n async init(): Promise<void> {\n if (this.disposed) throw new Error('AsciiPass.init() called after dispose().')\n if (this.stream) return\n await this.rendererRef.init()\n if (this.disposed) return\n const device = getDevice(this.rendererRef)\n const engine = await AsciiEngine.create(device, this.profile)\n if (this.disposed) {\n engine.destroy()\n return\n }\n try {\n const stream = await engine.createStream(navigator.gpu.getPreferredCanvasFormat())\n if (this.disposed) {\n stream.destroy()\n engine.destroy()\n return\n }\n this.device = device\n this.engine = engine\n this.stream = stream\n } catch (error) {\n engine.destroy()\n throw error\n }\n }\n\n /** Update matcher/composite options (spec §2: `ascii.set({...})`). */\n set(options: Partial<StreamMatchOptions & ViewOptions>): void {\n const { fit, clearColor, palette, post, ...match } = options\n if (fit !== undefined) this.fit = fit\n if (clearColor !== undefined) this.clearColor = clearColor\n if (palette !== undefined) this.palette = palette\n if (post !== undefined) this.post = post\n this.matchOpts = { ...this.matchOpts, ...match }\n }\n\n setInteraction(interaction: InteractionOptions | null): void {\n this.interaction = interaction\n }\n\n /** Pin the render-target resolution. After this it no longer follows the drawing buffer. */\n setSize(width: number, height: number): void {\n this.autoSize = false\n this.renderTarget.setSize(width, height)\n }\n\n grid(): { columns: number; rows: number } | null {\n return this.stream?.grid() ?? null\n }\n\n /** Render the scene through the ASCII pipeline to the canvas. */\n render(scene: Object3D, camera: Camera): void {\n if (this.disposed) return\n const stream = this.stream\n if (!stream || !this.device) {\n throw new Error(\n 'AsciiPass.render() called before init() — `await pass.init()` after creating the pass.',\n )\n }\n const renderer = this.rendererRef\n\n const size = renderer.getDrawingBufferSize(this.drawSize)\n if (this.autoSize) {\n const w = Math.max(1, size.x)\n const h = Math.max(1, size.y)\n if (this.renderTarget.width !== w || this.renderTarget.height !== h) {\n this.renderTarget.setSize(w, h)\n }\n }\n\n const output = renderer as unknown as OutputTargetRenderer\n const viaOutputPass =\n typeof output.setOutputRenderTarget === 'function' &&\n typeof output.getOutputRenderTarget === 'function'\n const prev = renderer.getRenderTarget()\n if (viaOutputPass) {\n // As the output target, with no render target set: the renderer treats this exactly\n // like the canvas, so its tone mapping and colour-space conversion both run.\n const prevOutput = output.getOutputRenderTarget!()\n renderer.setRenderTarget(null)\n output.setOutputRenderTarget!(this.renderTarget)\n try {\n renderer.render(scene, camera)\n } finally {\n output.setOutputRenderTarget!(prevOutput)\n renderer.setRenderTarget(prev)\n }\n } else {\n renderer.setRenderTarget(this.renderTarget)\n renderer.render(scene, camera)\n renderer.setRenderTarget(prev)\n }\n\n const srcTexture = getGpuTexture(renderer, this.renderTarget.texture)\n stream.configure(srcTexture, this.renderTarget.width, this.renderTarget.height, {\n // The output pass has already encoded; a plain render target is still linear.\n srgbEncode: !viaOutputPass,\n alpha: 'ignore',\n // A motion-driven interaction needs the field computed, as the gpu renderer arranges.\n motion: this.interaction?.source === 'motion' ? (this.interaction.motion ?? {}) : undefined,\n ...this.matchOpts,\n })\n\n const cenc = this.device.createCommandEncoder()\n stream.encodeMatch(cenc)\n this.device.queue.submit([cenc.finish()])\n\n stream.syncView({\n width: size.x,\n height: size.y,\n fit: this.fit,\n clearColor: this.clearColor,\n palette: this.palette,\n post: this.post,\n })\n stream.syncFx(\n {\n interaction: this.interaction,\n pointerX: this.pointerX * size.x,\n pointerY: this.pointerY * size.y,\n velX: this.velX,\n velY: this.velY,\n time: (performance.now() - this.t0) / 1000,\n },\n size.x,\n size.y,\n )\n const enc = this.device.createCommandEncoder()\n stream.encodeComposite(enc, getCanvasContext(renderer).getCurrentTexture().createView())\n this.device.queue.submit([enc.finish()])\n }\n\n /** Explicit readback of the matched frame (spec §33). */\n async captureFrame(): Promise<AsciiFrame> {\n if (!this.stream)\n throw new Error('AsciiPass.captureFrame() requires init() and at least one render().')\n return this.stream.captureFrame()\n }\n\n dispose(): void {\n if (this.disposed) return\n this.disposed = true\n this.renderTarget.dispose()\n this.stream?.destroy()\n this.engine?.destroy() // engine resources only — the device belongs to Three\n }\n}\n","// Access to WebGPURenderer backend internals. Three does not yet expose the\n// GPUDevice / canvas context / texture handles publicly; these accessors are\n// the supported-in-practice interop points. The test suite runs against the\n// three version pinned in this package's devDependencies (r187); the peer range\n// reaches back to r170, where the same three properties exist.\nimport type { Texture } from 'three'\nimport type { WebGPURenderer } from 'three/webgpu'\n\ninterface BackendLike {\n device?: GPUDevice\n context?: GPUCanvasContext\n get?: (object: unknown) => { texture?: GPUTexture } | undefined\n}\n\nconst backendOf = (renderer: WebGPURenderer): BackendLike | undefined =>\n (renderer as unknown as { backend?: BackendLike }).backend\n\nexport function getDevice(renderer: WebGPURenderer): GPUDevice {\n const device = backendOf(renderer)?.device\n if (!device) {\n throw new Error(\n 'AsciiPass requires an initialized THREE.WebGPURenderer — `await renderer.init()` first. ' +\n 'WebGL renderers are unsupported: exact matching would require per-frame GPU→CPU readback (spec §30).',\n )\n }\n return device\n}\n\nexport function getCanvasContext(renderer: WebGPURenderer): GPUCanvasContext {\n const context = backendOf(renderer)?.context\n if (!context) {\n throw new Error(\n 'Could not access the WebGPU canvas context via renderer.backend (tested against three r187).',\n )\n }\n return context\n}\n\nexport function getGpuTexture(renderer: WebGPURenderer, texture: Texture): GPUTexture {\n const data = backendOf(renderer)?.get?.(texture)\n const gpuTexture = data?.texture\n if (!gpuTexture) {\n throw new Error(\n 'Could not access the render target GPU texture via renderer.backend — render to the target once first ' +\n '(tested against three r187).',\n )\n }\n return gpuTexture\n}\n","import {\n DataTexture,\n InstancedBufferAttribute,\n InstancedMesh,\n LinearFilter,\n LinearMipmapLinearFilter,\n Matrix4,\n PlaneGeometry,\n RedFormat,\n UnsignedByteType,\n} from 'three'\nimport { MeshBasicNodeMaterial } from 'three/webgpu'\nimport { add, attribute, div, float, floor, mix, mod, mul, texture, uv, vec2 } from 'three/tsl'\nimport type { AsciiFrame, AsciiProfile } from '@ascii-fx/core'\nimport { FLAG_TRANSPARENT, blankGlyphId, unpackB, unpackG, unpackR } from '@ascii-fx/core'\n\nexport interface AsciiGlyphsOptions {\n profile: AsciiProfile\n columns: number\n rows: number\n /** World-space cell height. Default 1. */\n cellSize?: number\n}\n\n/**\n * Instanced 3D glyph renderer (spec §8 'instances', §30): one plane instance\n * per cell, glyph/colors as instanced attributes, atlas sampled via TSL.\n * Instance transforms live in the standard instanceMatrix so effects can\n * animate them (GPU-side via node materials, or CPU-side via setMatrixAt).\n *\n * v1 data path: populate from a captured AsciiFrame (`updateFromFrame`).\n * A zero-readback bridge from the GPU cell buffer is a planned optimization.\n */\nexport class AsciiGlyphs {\n readonly mesh: InstancedMesh\n readonly material: MeshBasicNodeMaterial\n readonly columns: number\n readonly rows: number\n\n private readonly aGlyph: InstancedBufferAttribute\n private readonly aFg: InstancedBufferAttribute\n private readonly aBg: InstancedBufferAttribute\n private readonly aVisible: InstancedBufferAttribute\n private readonly aUseBackground: InstancedBufferAttribute\n private readonly atlasTexture: DataTexture\n private readonly profileFingerprint: string\n private readonly glyphCount: number\n private readonly blankGlyph: number\n\n constructor(options: AsciiGlyphsOptions) {\n const { profile, columns, rows } = options\n const cellSize = options.cellSize ?? 1\n this.columns = columns\n this.rows = rows\n this.profileFingerprint = profile.fingerprint\n this.glyphCount = profile.glyphCount\n this.blankGlyph = blankGlyphId(profile)\n const { atlas } = profile\n const aspect = atlas.cellWidth / atlas.cellHeight\n const count = columns * rows\n\n const geometry = new PlaneGeometry(cellSize * aspect, cellSize)\n this.aGlyph = new InstancedBufferAttribute(new Float32Array(count), 1)\n this.aFg = new InstancedBufferAttribute(new Float32Array(count * 3).fill(1), 3)\n this.aBg = new InstancedBufferAttribute(new Float32Array(count * 3), 3)\n this.aVisible = new InstancedBufferAttribute(new Float32Array(count).fill(1), 1)\n this.aUseBackground = new InstancedBufferAttribute(new Float32Array(count).fill(1), 1)\n geometry.setAttribute('aGlyph', this.aGlyph)\n geometry.setAttribute('aFg', this.aFg)\n geometry.setAttribute('aBg', this.aBg)\n geometry.setAttribute('aVisible', this.aVisible)\n geometry.setAttribute('aUseBackground', this.aUseBackground)\n\n this.atlasTexture = new DataTexture(\n atlas.data as Uint8Array<ArrayBuffer>,\n atlas.width,\n atlas.height,\n RedFormat,\n UnsignedByteType,\n )\n this.atlasTexture.flipY = false\n this.atlasTexture.magFilter = LinearFilter\n this.atlasTexture.minFilter = LinearMipmapLinearFilter\n this.atlasTexture.generateMipmaps = true\n this.atlasTexture.needsUpdate = true\n\n this.material = new MeshBasicNodeMaterial()\n // @types/three cannot yet type composed TSL node graphs; the runtime API\n // is stable, so the graph is built through a single contained cast.\n /* eslint-disable @typescript-eslint/no-explicit-any */\n const n = {\n add,\n attribute,\n div,\n float,\n floor,\n mix,\n mod,\n mul,\n texture,\n uv,\n vec2,\n } as unknown as Record<\n | 'add'\n | 'attribute'\n | 'div'\n | 'float'\n | 'floor'\n | 'mix'\n | 'mod'\n | 'mul'\n | 'texture'\n | 'uv'\n | 'vec2',\n (...args: any[]) => any\n >\n /* eslint-enable @typescript-eslint/no-explicit-any */\n const id = n.attribute('aGlyph')\n const col = n.mod(id, n.float(atlas.columns))\n const row = n.floor(n.div(id, n.float(atlas.columns)))\n const tile = n.vec2(\n n.add(n.mul(col, n.float(atlas.pitchWidth)), n.float(atlas.padding)),\n n.add(n.mul(row, n.float(atlas.pitchHeight)), n.float(atlas.padding)),\n )\n // PlaneGeometry uv has v=0 at the bottom; the atlas is y-down: flip v.\n const guv = n.add(n.mul(n.uv(), n.vec2(1, -1)), n.vec2(0, 1))\n const texel = n.add(tile, n.mul(guv, n.vec2(atlas.cellWidth, atlas.cellHeight)))\n const auv = n.div(texel, n.vec2(atlas.width, atlas.height))\n const alpha = n.texture(this.atlasTexture, auv).r\n const foreground = n.attribute('aFg')\n const useBackground = n.attribute('aUseBackground')\n const cellColor = n.mix(n.attribute('aBg'), foreground, alpha)\n this.material.colorNode = n.mix(foreground, cellColor, useBackground)\n this.material.opacityNode = n.mul(\n n.attribute('aVisible'),\n n.mix(alpha, n.float(1), useBackground),\n )\n this.material.transparent = true\n this.material.depthWrite = false\n\n this.mesh = new InstancedMesh(geometry, this.material, count)\n this.mesh.frustumCulled = false\n const m = new Matrix4()\n const cw = cellSize * aspect\n for (let cy = 0; cy < rows; cy++) {\n for (let cx = 0; cx < columns; cx++) {\n m.makeTranslation((cx - (columns - 1) / 2) * cw, ((rows - 1) / 2 - cy) * cellSize, 0)\n this.mesh.setMatrixAt(cy * columns + cx, m)\n }\n }\n this.mesh.instanceMatrix.needsUpdate = true\n }\n\n /** Load glyph ids and colors from a matched frame (same grid dimensions). */\n updateFromFrame(frame: AsciiFrame): void {\n if (frame.profile.fingerprint !== this.profileFingerprint) {\n throw new Error(\n `Frame profile \"${frame.profile.id}\" (${frame.profile.fingerprint.slice(0, 12)}…) does not match ` +\n `AsciiGlyphs profile (${this.profileFingerprint.slice(0, 12)}…).`,\n )\n }\n if (frame.columns !== this.columns || frame.rows !== this.rows) {\n throw new Error(\n `Frame grid ${frame.columns}×${frame.rows} does not match AsciiGlyphs grid ${this.columns}×${this.rows}.`,\n )\n }\n const n = this.columns * this.rows\n const g = this.aGlyph.array as Float32Array\n const fg = this.aFg.array as Float32Array\n const bg = this.aBg.array as Float32Array\n const visible = this.aVisible.array as Float32Array\n const useBackground = this.aUseBackground.array as Float32Array\n for (let i = 0; i < n; i++) {\n const transparent = (frame.flags[i] & FLAG_TRANSPARENT) !== 0\n const glyphId = frame.glyphIds[i]\n if (glyphId >= this.glyphCount) {\n throw new Error(\n `Frame cell ${i} references glyph ${glyphId}, but the profile has ${this.glyphCount} glyphs.`,\n )\n }\n g[i] = transparent ? this.blankGlyph : glyphId\n visible[i] = transparent ? 0 : 1\n useBackground[i] = frame.colorMode === 'foreground' ? 0 : 1\n const fgc = frame.foreground?.[i]\n const bgc = frame.background?.[i]\n fg[i * 3] = fgc !== undefined ? unpackR(fgc) / 255 : 1\n fg[i * 3 + 1] = fgc !== undefined ? unpackG(fgc) / 255 : 1\n fg[i * 3 + 2] = fgc !== undefined ? unpackB(fgc) / 255 : 1\n bg[i * 3] = bgc !== undefined ? unpackR(bgc) / 255 : 0\n bg[i * 3 + 1] = bgc !== undefined ? unpackG(bgc) / 255 : 0\n bg[i * 3 + 2] = bgc !== undefined ? unpackB(bgc) / 255 : 0\n }\n this.aGlyph.needsUpdate = true\n this.aFg.needsUpdate = true\n this.aBg.needsUpdate = true\n this.aVisible.needsUpdate = true\n this.aUseBackground.needsUpdate = true\n }\n\n dispose(): void {\n // The mesh's own dispose releases its instanced attributes (instanceMatrix et al.);\n // without it their GPU buffers wait on backend WeakMap GC.\n this.mesh.dispose()\n this.mesh.geometry.dispose()\n this.material.dispose()\n this.atlasTexture.dispose()\n }\n}\n"],"mappings":";AAAA,SAAS,cAAc,eAAe;AAItC,SAAS,mBAAgC;;;ACUzC,IAAM,YAAY,CAAC,aAChB,SAAkD;AAE9C,SAAS,UAAU,UAAqC;AAC7D,QAAM,SAAS,UAAU,QAAQ,GAAG;AACpC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,iBAAiB,UAA4C;AAC3E,QAAM,UAAU,UAAU,QAAQ,GAAG;AACrC,MAAI,CAA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SAAK,eAAe,cAAc;AAAA,EACpC;AAAA,EAEA,UAAgB;AAGd,SAAK,KAAK,QAAQ;AAClB,SAAK,KAAK,SAAS,QAAQ;AAC3B,SAAK,SAAS,QAAQ;AACtB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;","names":["texture"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ascii-fx/three",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Three.js adapter for ASCII FX: AsciiPass postprocessing for WebGPURenderer and an instanced AsciiGlyphs renderer.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ascii",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ascii-fx/core": "0.
|
|
41
|
-
"@ascii-fx/gpu": "0.
|
|
40
|
+
"@ascii-fx/core": "0.10.0",
|
|
41
|
+
"@ascii-fx/gpu": "0.10.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/three": "0.
|
|
44
|
+
"@types/three": "0.187.0",
|
|
45
45
|
"@webgpu/types": "^0.1.74",
|
|
46
|
-
"three": "0.
|
|
47
|
-
"tsup": "^
|
|
46
|
+
"three": "0.187.0",
|
|
47
|
+
"tsup": "^9.0.0",
|
|
48
48
|
"typescript": "^7.0.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|