@wave3d/core 0.2.1 → 0.2.2
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/studio/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { randomizeBackground, randomizeColor, randomizeConfig, randomizeFinish, randomizeGlobal, randomizeGradient, randomizeLights, randomizeSpine, randomizeTransform, randomizeTwist, randomizeWave } from "./randomize.js";
|
|
2
2
|
import { StudioWaveRenderer } from "./StudioWaveRenderer.js";
|
|
3
|
-
|
|
3
|
+
import { createThumbHost, prepThumbConfig, renderThumbFrame } from "./thumbnail.js";
|
|
4
|
+
export { StudioWaveRenderer, createThumbHost, prepThumbConfig, randomizeBackground, randomizeColor, randomizeConfig, randomizeFinish, randomizeGlobal, randomizeGradient, randomizeLights, randomizeSpine, randomizeTransform, randomizeTwist, randomizeWave, renderThumbFrame };
|
package/dist/studio/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { randomizeBackground, randomizeColor, randomizeConfig, randomizeFinish, randomizeGlobal, randomizeGradient, randomizeLights, randomizeSpine, randomizeTransform, randomizeTwist, randomizeWave } from "./randomize.js";
|
|
2
2
|
import { StudioWaveRenderer } from "./StudioWaveRenderer.js";
|
|
3
|
-
|
|
3
|
+
import { createThumbHost, prepThumbConfig, renderThumbFrame } from "./thumbnail.js";
|
|
4
|
+
export { StudioWaveRenderer, createThumbHost, prepThumbConfig, randomizeBackground, randomizeColor, randomizeConfig, randomizeFinish, randomizeGlobal, randomizeGradient, randomizeLights, randomizeSpine, randomizeTransform, randomizeTwist, randomizeWave, renderThumbFrame };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StudioConfig } from "../config/model.js";
|
|
2
|
+
import { WaveRenderer } from "../renderer/WaveRenderer.js";
|
|
3
|
+
|
|
4
|
+
//#region src/studio/thumbnail.d.ts
|
|
5
|
+
/** A hidden host div that is in layout (so clientWidth/Height are real) but off-screen. */
|
|
6
|
+
declare function createThumbHost(width: number, height: number): HTMLDivElement;
|
|
7
|
+
/** Mutate `cfg` for a thumbnail still: static frame, opaque, white page behind solid themes
|
|
8
|
+
* (wireframe keys its between-line colour off the dark page background, so keep it). */
|
|
9
|
+
declare function prepThumbConfig(cfg: StudioConfig): void;
|
|
10
|
+
/** Render the current config to a fresh 2D canvas (null if the WebGL canvas is missing). */
|
|
11
|
+
declare function renderThumbFrame(renderer: WaveRenderer, host: HTMLElement): HTMLCanvasElement | null;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { createThumbHost, prepThumbConfig, renderThumbFrame };
|
|
14
|
+
//# sourceMappingURL=thumbnail.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/studio/thumbnail.ts
|
|
2
|
+
/** A hidden host div that is in layout (so clientWidth/Height are real) but off-screen. */
|
|
3
|
+
function createThumbHost(width, height) {
|
|
4
|
+
const host = document.createElement("div");
|
|
5
|
+
host.style.cssText = `position:fixed;left:-10000px;top:0;width:${width}px;height:${height}px;opacity:0;pointer-events:none;`;
|
|
6
|
+
document.body.appendChild(host);
|
|
7
|
+
return host;
|
|
8
|
+
}
|
|
9
|
+
/** Mutate `cfg` for a thumbnail still: static frame, opaque, white page behind solid themes
|
|
10
|
+
* (wireframe keys its between-line colour off the dark page background, so keep it). */
|
|
11
|
+
function prepThumbConfig(cfg) {
|
|
12
|
+
cfg.paused = true;
|
|
13
|
+
cfg.transparentBackground = false;
|
|
14
|
+
if (cfg.waves[0]?.theme !== "wireframe") cfg.background = "#ffffff";
|
|
15
|
+
}
|
|
16
|
+
/** Render the current config to a fresh 2D canvas (null if the WebGL canvas is missing). */
|
|
17
|
+
function renderThumbFrame(renderer, host) {
|
|
18
|
+
renderer.resize();
|
|
19
|
+
renderer.renderOnce();
|
|
20
|
+
renderer.renderOnce();
|
|
21
|
+
const gl = host.querySelector("canvas");
|
|
22
|
+
if (!gl) return null;
|
|
23
|
+
const out = document.createElement("canvas");
|
|
24
|
+
out.width = gl.width;
|
|
25
|
+
out.height = gl.height;
|
|
26
|
+
out.getContext("2d")?.drawImage(gl, 0, 0);
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { createThumbHost, prepThumbConfig, renderThumbFrame };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=thumbnail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thumbnail.js","names":[],"sources":["../../src/studio/thumbnail.ts"],"sourcesContent":["/**\n * Offscreen thumbnail rendering: turn a config into a still frame with one hidden, reused\n * WaveRenderer. Used by the studio's preset + history thumbnails and by the wave gallery grid.\n */\nimport type { WaveRenderer } from \"../renderer/WaveRenderer\";\nimport type { StudioConfig } from \"../config/model\";\n\n/** A hidden host div that is in layout (so clientWidth/Height are real) but off-screen. */\nexport function createThumbHost(width: number, height: number): HTMLDivElement {\n const host = document.createElement(\"div\");\n host.style.cssText = `position:fixed;left:-10000px;top:0;width:${width}px;height:${height}px;opacity:0;pointer-events:none;`;\n document.body.appendChild(host);\n return host;\n}\n\n/** Mutate `cfg` for a thumbnail still: static frame, opaque, white page behind solid themes\n * (wireframe keys its between-line colour off the dark page background, so keep it). */\nexport function prepThumbConfig(cfg: StudioConfig): void {\n cfg.paused = true;\n cfg.transparentBackground = false;\n if (cfg.waves[0]?.theme !== \"wireframe\") cfg.background = \"#ffffff\";\n}\n\n/** Render the current config to a fresh 2D canvas (null if the WebGL canvas is missing). */\nexport function renderThumbFrame(\n renderer: WaveRenderer,\n host: HTMLElement,\n): HTMLCanvasElement | null {\n renderer.resize();\n renderer.renderOnce();\n renderer.renderOnce(); // 2nd pass so any shader recompile (theme/blend variant) is applied\n const gl = host.querySelector(\"canvas\");\n if (!gl) return null;\n // Copy to a 2D canvas before encoding (reliable read of the WebGL drawing buffer).\n const out = document.createElement(\"canvas\");\n out.width = gl.width;\n out.height = gl.height;\n out.getContext(\"2d\")?.drawImage(gl, 0, 0);\n return out;\n}\n"],"mappings":";;AAQA,SAAgB,gBAAgB,OAAe,QAAgC;CAC7E,MAAM,OAAO,SAAS,cAAc,KAAK;CACzC,KAAK,MAAM,UAAU,4CAA4C,MAAM,YAAY,OAAO;CAC1F,SAAS,KAAK,YAAY,IAAI;CAC9B,OAAO;AACT;;;AAIA,SAAgB,gBAAgB,KAAyB;CACvD,IAAI,SAAS;CACb,IAAI,wBAAwB;CAC5B,IAAI,IAAI,MAAM,EAAE,EAAE,UAAU,aAAa,IAAI,aAAa;AAC5D;;AAGA,SAAgB,iBACd,UACA,MAC0B;CAC1B,SAAS,OAAO;CAChB,SAAS,WAAW;CACpB,SAAS,WAAW;CACpB,MAAM,KAAK,KAAK,cAAc,QAAQ;CACtC,IAAI,CAAC,IAAI,OAAO;CAEhB,MAAM,MAAM,SAAS,cAAc,QAAQ;CAC3C,IAAI,QAAQ,GAAG;CACf,IAAI,SAAS,GAAG;CAChB,IAAI,WAAW,IAAI,CAAC,EAAE,UAAU,IAAI,GAAG,CAAC;CACxC,OAAO;AACT"}
|