@babylonjs/lite-gl 1.20.0 → 1.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -19
- package/context.js +2 -0
- package/context.js.map +1 -1
- package/depth-stencil.d.ts +1 -2
- package/depth-stencil.js +2 -2
- package/depth-stencil.js.map +1 -1
- package/dynamic-texture.d.ts +18 -18
- package/dynamic-texture.js +28 -24
- package/dynamic-texture.js.map +1 -1
- package/effect-ready.d.ts +1 -3
- package/effect-ready.js +3 -3
- package/effect-ready.js.map +1 -1
- package/effect-renderer.d.ts +39 -12
- package/effect-renderer.js +47 -17
- package/effect-renderer.js.map +1 -1
- package/effect.d.ts +25 -21
- package/effect.js +69 -51
- package/effect.js.map +1 -1
- package/gpu-frame-time.d.ts +49 -0
- package/gpu-frame-time.js +130 -0
- package/gpu-frame-time.js.map +1 -0
- package/html-texture.d.ts +24 -34
- package/html-texture.js +34 -55
- package/html-texture.js.map +1 -1
- package/index.d.ts +9 -8
- package/index.js +9 -6
- package/index.js.map +1 -1
- package/mesh.d.ts +8 -14
- package/mesh.js +23 -19
- package/mesh.js.map +1 -1
- package/package.json +3 -3
- package/render-loop.d.ts +14 -0
- package/render-loop.js +23 -0
- package/render-loop.js.map +1 -1
- package/render-target.d.ts +109 -39
- package/render-target.js +136 -58
- package/render-target.js.map +1 -1
- package/sprites.d.ts +8 -2
- package/sprites.js +17 -13
- package/sprites.js.map +1 -1
- package/state.d.ts +1 -1
- package/state.js.map +1 -1
- package/text/_gpu/text-effect.js +5 -5
- package/text/_gpu/text-effect.js.map +1 -1
- package/text/_gpu/text-instances.js +4 -4
- package/text/_gpu/text-instances.js.map +1 -1
- package/text/_gpu/text-textures.js +5 -3
- package/text/_gpu/text-textures.js.map +1 -1
- package/text/glyph-storage.js +3 -3
- package/text/glyph-storage.js.map +1 -1
- package/text/text-data.js +2 -2
- package/text/text-data.js.map +1 -1
- package/text/text-renderer.js +11 -11
- package/text/text-renderer.js.map +1 -1
- package/texture-3d.d.ts +10 -7
- package/texture-3d.js +27 -12
- package/texture-3d.js.map +1 -1
- package/texture-source.d.ts +3 -4
- package/texture-source.js +5 -5
- package/texture-source.js.map +1 -1
- package/texture.d.ts +195 -31
- package/texture.js +215 -35
- package/texture.js.map +1 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the GPU frame-time counter for `engine` (Babylon
|
|
3
|
+
* `engine.getGPUFrameTimeCounter()`), creating it on first use. The counter is
|
|
4
|
+
* only fed while `captureGPUFrameTime(engine, true)` is active and the
|
|
5
|
+
* `EXT_disjoint_timer_query_webgl2` extension is available; otherwise `count`
|
|
6
|
+
* stays at 0. Values are in nanoseconds.
|
|
7
|
+
*/
|
|
8
|
+
export function getGPUFrameTimeCounter(engine) {
|
|
9
|
+
let counter = engine._gpuFrameTime;
|
|
10
|
+
if (counter === undefined) {
|
|
11
|
+
counter = { current: 0, average: 0, lastSecAverage: 0, min: 0, max: 0, total: 0, count: 0, _lastSecTotal: 0, _lastSecCount: 0, _lastSecTime: 0 };
|
|
12
|
+
engine._gpuFrameTime = counter;
|
|
13
|
+
}
|
|
14
|
+
return counter;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Enables or disables GPU frame-time measurement (Babylon
|
|
18
|
+
* `engine.captureGPUFrameTime(value)`). While enabled, each frame delimited by
|
|
19
|
+
* `beginFrame` / `endFrame` — which `runRenderLoop` calls automatically — is
|
|
20
|
+
* wrapped in a `TIME_ELAPSED_EXT` timer query. Results arrive asynchronously a
|
|
21
|
+
* few frames later and feed `getGPUFrameTimeCounter(engine)`. Only one query is
|
|
22
|
+
* in flight at a time, so not every frame is sampled.
|
|
23
|
+
*
|
|
24
|
+
* Silently does nothing useful when `EXT_disjoint_timer_query_webgl2` is
|
|
25
|
+
* unavailable (common outside desktop Chrome, and often disabled for privacy).
|
|
26
|
+
* Samples overlapping a disjoint GPU event are discarded. Survives context
|
|
27
|
+
* loss: the in-flight query is dropped and measurement resumes after restore.
|
|
28
|
+
*
|
|
29
|
+
* @param engine - The lite-gl engine.
|
|
30
|
+
* @param enabled - `true` to start measuring, `false` to stop and release the pending query.
|
|
31
|
+
*/
|
|
32
|
+
export function captureGPUFrameTime(engine, enabled) {
|
|
33
|
+
const hooks = engine._frameHooks;
|
|
34
|
+
if (!enabled) {
|
|
35
|
+
if (hooks !== undefined) {
|
|
36
|
+
hooks._dispose();
|
|
37
|
+
engine._frameHooks = undefined;
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (hooks !== undefined || engine._disposed) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const gl = engine.gl;
|
|
45
|
+
const counter = getGPUFrameTimeCounter(engine);
|
|
46
|
+
// `undefined` = not queried yet (or invalidated by context loss); `null` = unsupported.
|
|
47
|
+
let ext;
|
|
48
|
+
let query = null;
|
|
49
|
+
let ended = false;
|
|
50
|
+
// Query handles and extension objects die with the context.
|
|
51
|
+
const onLost = () => {
|
|
52
|
+
query = null;
|
|
53
|
+
ext = undefined;
|
|
54
|
+
};
|
|
55
|
+
engine._onLost.push(onLost);
|
|
56
|
+
engine._frameHooks = {
|
|
57
|
+
_begin: () => {
|
|
58
|
+
if (query !== null || engine._isLost || engine._disposed) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (ext === undefined) {
|
|
62
|
+
ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
63
|
+
}
|
|
64
|
+
if (ext === null) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
query = gl.createQuery();
|
|
68
|
+
if (query !== null) {
|
|
69
|
+
gl.beginQuery(ext.TIME_ELAPSED_EXT, query);
|
|
70
|
+
ended = false;
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
_end: () => {
|
|
74
|
+
if (query === null || ext === null || ext === undefined || engine._isLost || engine._disposed) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!ended) {
|
|
78
|
+
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
79
|
+
ended = true;
|
|
80
|
+
}
|
|
81
|
+
if (!gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// Reading GPU_DISJOINT_EXT also clears it; a disjoint result is unreliable.
|
|
85
|
+
if (!gl.getParameter(ext.GPU_DISJOINT_EXT)) {
|
|
86
|
+
addSample(counter, gl.getQueryParameter(query, gl.QUERY_RESULT));
|
|
87
|
+
}
|
|
88
|
+
gl.deleteQuery(query);
|
|
89
|
+
query = null;
|
|
90
|
+
},
|
|
91
|
+
_dispose: () => {
|
|
92
|
+
const i = engine._onLost.indexOf(onLost);
|
|
93
|
+
if (i !== -1) {
|
|
94
|
+
engine._onLost.splice(i, 1);
|
|
95
|
+
}
|
|
96
|
+
if (query !== null && !engine._isLost) {
|
|
97
|
+
if (!ended && ext) {
|
|
98
|
+
gl.endQuery(ext.TIME_ELAPSED_EXT);
|
|
99
|
+
}
|
|
100
|
+
gl.deleteQuery(query);
|
|
101
|
+
}
|
|
102
|
+
query = null;
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Babylon `PerfCounter.fetchNewFrame()` + `addCount(value, true)`. */
|
|
107
|
+
function addSample(counter, value) {
|
|
108
|
+
counter.count++;
|
|
109
|
+
counter.current = value;
|
|
110
|
+
counter.total += value;
|
|
111
|
+
if (counter.count === 1) {
|
|
112
|
+
counter.min = value;
|
|
113
|
+
counter.max = value;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
counter.min = Math.min(counter.min, value);
|
|
117
|
+
counter.max = Math.max(counter.max, value);
|
|
118
|
+
}
|
|
119
|
+
counter.average = counter.total / counter.count;
|
|
120
|
+
counter._lastSecTotal += value;
|
|
121
|
+
counter._lastSecCount++;
|
|
122
|
+
const now = performance.now();
|
|
123
|
+
if (now - counter._lastSecTime > 1000) {
|
|
124
|
+
counter.lastSecAverage = counter._lastSecTotal / counter._lastSecCount;
|
|
125
|
+
counter._lastSecTime = now;
|
|
126
|
+
counter._lastSecTotal = 0;
|
|
127
|
+
counter._lastSecCount = 0;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=gpu-frame-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-frame-time.js","sourceRoot":"","sources":["../src/gpu-frame-time.ts"],"names":[],"mappings":"AAsCA;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAuB;IAC1D,IAAI,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC;IACnC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;QACjJ,MAAM,CAAC,aAAa,GAAG,OAAO,CAAC;IACnC,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAuB,EAAE,OAAgB;IACzE,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC;IACjC,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,KAAK,CAAC,QAAQ,EAAE,CAAC;YACjB,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC;QACnC,CAAC;QACD,OAAO;IACX,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,CAA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ACxB,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACvB,IAAI,OAAO,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;QACpB,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC;IACxB,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAChD,OAAO,CAAC,aAAa,IAAI,KAAK,CAAC;IAC/B,OAAO,CAAC,aAAa,EAAE,CAAC;IACxB,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAC9B,IAAI,GAAG,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,EAAE,CAAC;QACpC,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QACvE,OAAO,CAAC,YAAY,GAAG,GAAG,CAAC;QAC3B,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC;QAC1B,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC;IAC9B,CAAC;AACL,CAAC","sourcesContent":["import type { GLEngineContext } from \"./context.js\";\n\n/**\n * Running statistics over a stream of samples — the data subset of Babylon's\n * `PerfCounter`. For the GPU frame-time counter every value is in\n * **nanoseconds** (as in Babylon); divide by `1e6` for milliseconds.\n *\n * All fields are read-only for callers; the owning feature updates them.\n */\nexport interface GLPerfCounter {\n /** Most recent sample. */\n current: number;\n /** Mean of every sample since the counter was created. */\n average: number;\n /** Mean of the samples gathered during the last completed ~1 second window. */\n lastSecAverage: number;\n /** Smallest sample seen (0 until the first sample). */\n min: number;\n /** Largest sample seen (0 until the first sample). */\n max: number;\n /** Sum of every sample. */\n total: number;\n /** Number of samples. */\n count: number;\n /** @internal */\n _lastSecTotal: number;\n /** @internal */\n _lastSecCount: number;\n /** @internal */\n _lastSecTime: number;\n}\n\n/** Subset of `EXT_disjoint_timer_query_webgl2` used here. */\ninterface GLTimerQueryExtension {\n TIME_ELAPSED_EXT: number;\n GPU_DISJOINT_EXT: number;\n}\n\n/**\n * Returns the GPU frame-time counter for `engine` (Babylon\n * `engine.getGPUFrameTimeCounter()`), creating it on first use. The counter is\n * only fed while `captureGPUFrameTime(engine, true)` is active and the\n * `EXT_disjoint_timer_query_webgl2` extension is available; otherwise `count`\n * stays at 0. Values are in nanoseconds.\n */\nexport function getGPUFrameTimeCounter(engine: GLEngineContext): GLPerfCounter {\n let counter = engine._gpuFrameTime;\n if (counter === undefined) {\n counter = { current: 0, average: 0, lastSecAverage: 0, min: 0, max: 0, total: 0, count: 0, _lastSecTotal: 0, _lastSecCount: 0, _lastSecTime: 0 };\n engine._gpuFrameTime = counter;\n }\n return counter;\n}\n\n/**\n * Enables or disables GPU frame-time measurement (Babylon\n * `engine.captureGPUFrameTime(value)`). While enabled, each frame delimited by\n * `beginFrame` / `endFrame` — which `runRenderLoop` calls automatically — is\n * wrapped in a `TIME_ELAPSED_EXT` timer query. Results arrive asynchronously a\n * few frames later and feed `getGPUFrameTimeCounter(engine)`. Only one query is\n * in flight at a time, so not every frame is sampled.\n *\n * Silently does nothing useful when `EXT_disjoint_timer_query_webgl2` is\n * unavailable (common outside desktop Chrome, and often disabled for privacy).\n * Samples overlapping a disjoint GPU event are discarded. Survives context\n * loss: the in-flight query is dropped and measurement resumes after restore.\n *\n * @param engine - The lite-gl engine.\n * @param enabled - `true` to start measuring, `false` to stop and release the pending query.\n */\nexport function captureGPUFrameTime(engine: GLEngineContext, enabled: boolean): void {\n const hooks = engine._frameHooks;\n if (!enabled) {\n if (hooks !== undefined) {\n hooks._dispose();\n engine._frameHooks = undefined;\n }\n return;\n }\n if (hooks !== undefined || engine._disposed) {\n return;\n }\n const gl = engine.gl;\n const counter = getGPUFrameTimeCounter(engine);\n // `undefined` = not queried yet (or invalidated by context loss); `null` = unsupported.\n let ext: GLTimerQueryExtension | null | undefined;\n let query: WebGLQuery | null = null;\n let ended = false;\n // Query handles and extension objects die with the context.\n const onLost = (): void => {\n query = null;\n ext = undefined;\n };\n engine._onLost.push(onLost);\n engine._frameHooks = {\n _begin: () => {\n if (query !== null || engine._isLost || engine._disposed) {\n return;\n }\n if (ext === undefined) {\n ext = gl.getExtension(\"EXT_disjoint_timer_query_webgl2\") as GLTimerQueryExtension | null;\n }\n if (ext === null) {\n return;\n }\n query = gl.createQuery();\n if (query !== null) {\n gl.beginQuery(ext.TIME_ELAPSED_EXT, query);\n ended = false;\n }\n },\n _end: () => {\n if (query === null || ext === null || ext === undefined || engine._isLost || engine._disposed) {\n return;\n }\n if (!ended) {\n gl.endQuery(ext.TIME_ELAPSED_EXT);\n ended = true;\n }\n if (!gl.getQueryParameter(query, gl.QUERY_RESULT_AVAILABLE)) {\n return;\n }\n // Reading GPU_DISJOINT_EXT also clears it; a disjoint result is unreliable.\n if (!gl.getParameter(ext.GPU_DISJOINT_EXT)) {\n addSample(counter, gl.getQueryParameter(query, gl.QUERY_RESULT) as number);\n }\n gl.deleteQuery(query);\n query = null;\n },\n _dispose: () => {\n const i = engine._onLost.indexOf(onLost);\n if (i !== -1) {\n engine._onLost.splice(i, 1);\n }\n if (query !== null && !engine._isLost) {\n if (!ended && ext) {\n gl.endQuery(ext.TIME_ELAPSED_EXT);\n }\n gl.deleteQuery(query);\n }\n query = null;\n },\n };\n}\n\n/** Babylon `PerfCounter.fetchNewFrame()` + `addCount(value, true)`. */\nfunction addSample(counter: GLPerfCounter, value: number): void {\n counter.count++;\n counter.current = value;\n counter.total += value;\n if (counter.count === 1) {\n counter.min = value;\n counter.max = value;\n } else {\n counter.min = Math.min(counter.min, value);\n counter.max = Math.max(counter.max, value);\n }\n counter.average = counter.total / counter.count;\n counter._lastSecTotal += value;\n counter._lastSecCount++;\n const now = performance.now();\n if (now - counter._lastSecTime > 1000) {\n counter.lastSecAverage = counter._lastSecTotal / counter._lastSecCount;\n counter._lastSecTime = now;\n counter._lastSecTotal = 0;\n counter._lastSecCount = 0;\n }\n}\n"]}
|
package/html-texture.d.ts
CHANGED
|
@@ -6,40 +6,30 @@
|
|
|
6
6
|
* NeonBrush's `InputGlow`) tree-shake it out.
|
|
7
7
|
*/
|
|
8
8
|
import type { GLEngineContext } from "./context.js";
|
|
9
|
-
import { type GLTexture, type GLTextureOptions } from "./texture.js";
|
|
10
|
-
/** High-level sampling presets, mirroring Babylon's `Texture.*_SAMPLINGMODE`
|
|
11
|
-
* numeric constants. Each resolves to GL min/mag filters (and mip generation
|
|
12
|
-
* for `TRILINEAR`). */
|
|
13
|
-
export declare const GLSamplingMode: {
|
|
14
|
-
/** Nearest min + mag, no mipmaps. (`Texture.NEAREST_SAMPLINGMODE`) */
|
|
15
|
-
readonly NEAREST: 1;
|
|
16
|
-
/** Linear min + mag, no mipmaps. (`Texture.BILINEAR_SAMPLINGMODE`) */
|
|
17
|
-
readonly BILINEAR: 2;
|
|
18
|
-
/** Linear mag + linear-mipmap-linear min, mipmaps generated.
|
|
19
|
-
* (`Texture.TRILINEAR_SAMPLINGMODE`) */
|
|
20
|
-
readonly TRILINEAR: 3;
|
|
21
|
-
};
|
|
22
|
-
/** One of the {@link GLSamplingMode} preset values (`1`, `2` or `3`). */
|
|
23
|
-
export type GLSamplingMode = (typeof GLSamplingMode)[keyof typeof GLSamplingMode];
|
|
24
|
-
/** Options for `createHtmlElementTexture` — the base texture options plus
|
|
25
|
-
* HTML-source-specific settings. */
|
|
26
|
-
export interface GLHtmlElementTextureOptions extends GLTextureOptions {
|
|
27
|
-
/** High-level sampling preset. When set, derives `minFilter`/`magFilter`
|
|
28
|
-
* (and `generateMipMaps` for `TRILINEAR`). Explicit `minFilter` /
|
|
29
|
-
* `magFilter` / `generateMipMaps` options still take precedence. Omit for
|
|
30
|
-
* the GL defaults (linear min + mag, no mipmaps). */
|
|
31
|
-
samplingMode?: GLSamplingMode;
|
|
32
|
-
/** Build a full mip chain after each upload. Independent of the core
|
|
33
|
-
* texture options (this factory's mip behavior is sampling-mode-driven):
|
|
34
|
-
* defaults to `true` only when `samplingMode` is `TRILINEAR`, otherwise
|
|
35
|
-
* `false`. */
|
|
36
|
-
generateMipMaps?: boolean;
|
|
37
|
-
}
|
|
9
|
+
import { type GLTexture, type GLTextureOptions, type GLTextureUpdateOptions } from "./texture.js";
|
|
38
10
|
/** Create a texture backed by an `<canvas>` / `<img>` / `<video>` element.
|
|
39
11
|
* The initial upload is performed immediately; call `updateHtmlElementTexture`
|
|
40
|
-
* to re-upload after the source has changed.
|
|
41
|
-
|
|
42
|
-
|
|
12
|
+
* to re-upload after the source has changed.
|
|
13
|
+
*
|
|
14
|
+
* @param engine - The engine to create GL resources on.
|
|
15
|
+
* @param element - The source element.
|
|
16
|
+
* @param options - The shared {@link GLTextureOptions} (including `invertY`
|
|
17
|
+
* and `premultiplyAlpha`), applied on creation, on every
|
|
18
|
+
* `updateHtmlElementTexture` that omits them and on `webglcontextrestored`.
|
|
19
|
+
* For Babylon-style presets spread `getSamplingModeFilters(...)`; for mipmaps
|
|
20
|
+
* call `generateTextureMipMaps` once and every later update rebuilds the chain.
|
|
21
|
+
* @returns The new {@link GLTexture}. */
|
|
22
|
+
export declare function createHtmlElementTexture(engine: GLEngineContext, element: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement, options?: GLTextureOptions): GLTexture;
|
|
23
|
+
/** Re-upload the texture from its source element — the counterpart of
|
|
24
|
+
* Babylon's `HtmlElementTexture.update(invertY)`. Only valid for textures
|
|
43
25
|
* created by {@link createHtmlElementTexture}. No-op when the context is
|
|
44
|
-
* lost/disposed or the texture is disposed.
|
|
45
|
-
|
|
26
|
+
* lost/disposed or the texture is disposed.
|
|
27
|
+
*
|
|
28
|
+
* `invertY` is always the raw `UNPACK_FLIP_Y_WEBGL` value. Babylon flips
|
|
29
|
+
* video elements with `!invertY`, so port `videoTexture.update(invertY)` as
|
|
30
|
+
* `{ invertY: !invertY }` (canvas / image calls map directly).
|
|
31
|
+
*
|
|
32
|
+
* @param tex - A texture created by {@link createHtmlElementTexture}.
|
|
33
|
+
* @param options - Per-update `invertY` / `premultiplyAlpha`; each defaults to
|
|
34
|
+
* the texture's creation value. Retained for `webglcontextrestored` replay. */
|
|
35
|
+
export declare function updateHtmlElementTexture(tex: GLTexture, options?: GLTextureUpdateOptions): void;
|
package/html-texture.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { bindTextureForUpload, setBoundTextureParams, setUnpackState } from "./texture.js";
|
|
2
|
-
/** High-level sampling presets, mirroring Babylon's `Texture.*_SAMPLINGMODE`
|
|
3
|
-
* numeric constants. Each resolves to GL min/mag filters (and mip generation
|
|
4
|
-
* for `TRILINEAR`). */
|
|
5
|
-
export const GLSamplingMode = {
|
|
6
|
-
/** Nearest min + mag, no mipmaps. (`Texture.NEAREST_SAMPLINGMODE`) */
|
|
7
|
-
NEAREST: 1,
|
|
8
|
-
/** Linear min + mag, no mipmaps. (`Texture.BILINEAR_SAMPLINGMODE`) */
|
|
9
|
-
BILINEAR: 2,
|
|
10
|
-
/** Linear mag + linear-mipmap-linear min, mipmaps generated.
|
|
11
|
-
* (`Texture.TRILINEAR_SAMPLINGMODE`) */
|
|
12
|
-
TRILINEAR: 3,
|
|
13
|
-
};
|
|
1
|
+
import { bindTextureForUpload, setTexImageSourceSize, setBoundTextureParams, setUnpackState, } from "./texture.js";
|
|
14
2
|
/** Create a texture backed by an `<canvas>` / `<img>` / `<video>` element.
|
|
15
3
|
* The initial upload is performed immediately; call `updateHtmlElementTexture`
|
|
16
|
-
* to re-upload after the source has changed.
|
|
4
|
+
* to re-upload after the source has changed.
|
|
5
|
+
*
|
|
6
|
+
* @param engine - The engine to create GL resources on.
|
|
7
|
+
* @param element - The source element.
|
|
8
|
+
* @param options - The shared {@link GLTextureOptions} (including `invertY`
|
|
9
|
+
* and `premultiplyAlpha`), applied on creation, on every
|
|
10
|
+
* `updateHtmlElementTexture` that omits them and on `webglcontextrestored`.
|
|
11
|
+
* For Babylon-style presets spread `getSamplingModeFilters(...)`; for mipmaps
|
|
12
|
+
* call `generateTextureMipMaps` once and every later update rebuilds the chain.
|
|
13
|
+
* @returns The new {@link GLTexture}. */
|
|
17
14
|
export function createHtmlElementTexture(engine, element, options) {
|
|
18
15
|
const gl = engine.gl;
|
|
19
16
|
const handle = gl.createTexture();
|
|
@@ -21,44 +18,29 @@ export function createHtmlElementTexture(engine, element, options) {
|
|
|
21
18
|
throw new Error("lite-gl: gl.createTexture returned null");
|
|
22
19
|
}
|
|
23
20
|
const opts = options ?? {};
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const magFilter = opts.magFilter ?? samplingMagFilter(gl, sm);
|
|
21
|
+
const minFilter = opts.minFilter ?? gl.LINEAR;
|
|
22
|
+
const magFilter = opts.magFilter ?? gl.LINEAR;
|
|
27
23
|
const wrapS = opts.wrapS ?? gl.CLAMP_TO_EDGE;
|
|
28
24
|
const wrapT = opts.wrapT ?? gl.CLAMP_TO_EDGE;
|
|
29
25
|
const invertY = opts.invertY ?? false;
|
|
30
|
-
const
|
|
31
|
-
const sizeOf = () => {
|
|
32
|
-
if (element instanceof HTMLVideoElement) {
|
|
33
|
-
return [element.videoWidth || 1, element.videoHeight || 1];
|
|
34
|
-
}
|
|
35
|
-
if (element instanceof HTMLImageElement) {
|
|
36
|
-
return [element.naturalWidth || 1, element.naturalHeight || 1];
|
|
37
|
-
}
|
|
38
|
-
return [element.width || 1, element.height || 1];
|
|
39
|
-
};
|
|
26
|
+
const premultiplyAlpha = opts.premultiplyAlpha ?? false;
|
|
40
27
|
const upload = (target) => {
|
|
41
28
|
const g = target.gl;
|
|
42
|
-
setUnpackState(target, invertY,
|
|
29
|
+
setUnpackState(target, tex._invertY ?? invertY, tex._premultiplyAlpha ?? premultiplyAlpha);
|
|
43
30
|
bindTextureForUpload(target, tex.handle);
|
|
44
31
|
g.texImage2D(g.TEXTURE_2D, 0, g.RGBA8, g.RGBA, g.UNSIGNED_BYTE, element);
|
|
45
|
-
|
|
46
|
-
tex.width = w;
|
|
47
|
-
tex.height = h;
|
|
48
|
-
if (generateMipMaps) {
|
|
49
|
-
g.generateMipmap(g.TEXTURE_2D);
|
|
50
|
-
}
|
|
32
|
+
setTexImageSourceSize(tex, element);
|
|
51
33
|
};
|
|
52
34
|
const initializeParameters = (target) => {
|
|
53
35
|
setBoundTextureParams(target.gl, minFilter, magFilter, wrapS, wrapT);
|
|
54
36
|
};
|
|
55
|
-
const [w0, h0] = sizeOf();
|
|
56
37
|
const tex = {
|
|
57
38
|
handle,
|
|
58
39
|
target: gl.TEXTURE_2D,
|
|
59
|
-
width:
|
|
60
|
-
height:
|
|
40
|
+
width: 1,
|
|
41
|
+
height: 1,
|
|
61
42
|
isReady: true,
|
|
43
|
+
_engine: engine,
|
|
62
44
|
_disposed: false,
|
|
63
45
|
_refCount: 1,
|
|
64
46
|
_upload: upload,
|
|
@@ -70,28 +52,25 @@ export function createHtmlElementTexture(engine, element, options) {
|
|
|
70
52
|
engine._textures.add(tex);
|
|
71
53
|
return tex;
|
|
72
54
|
}
|
|
73
|
-
/** Re-upload the texture from its source element
|
|
55
|
+
/** Re-upload the texture from its source element — the counterpart of
|
|
56
|
+
* Babylon's `HtmlElementTexture.update(invertY)`. Only valid for textures
|
|
74
57
|
* created by {@link createHtmlElementTexture}. No-op when the context is
|
|
75
|
-
* lost/disposed or the texture is disposed.
|
|
76
|
-
|
|
58
|
+
* lost/disposed or the texture is disposed.
|
|
59
|
+
*
|
|
60
|
+
* `invertY` is always the raw `UNPACK_FLIP_Y_WEBGL` value. Babylon flips
|
|
61
|
+
* video elements with `!invertY`, so port `videoTexture.update(invertY)` as
|
|
62
|
+
* `{ invertY: !invertY }` (canvas / image calls map directly).
|
|
63
|
+
*
|
|
64
|
+
* @param tex - A texture created by {@link createHtmlElementTexture}.
|
|
65
|
+
* @param options - Per-update `invertY` / `premultiplyAlpha`; each defaults to
|
|
66
|
+
* the texture's creation value. Retained for `webglcontextrestored` replay. */
|
|
67
|
+
export function updateHtmlElementTexture(tex, options) {
|
|
68
|
+
const engine = tex._engine;
|
|
77
69
|
if (engine._isLost || engine._disposed || tex._disposed) {
|
|
78
70
|
return;
|
|
79
71
|
}
|
|
72
|
+
tex._invertY = options?.invertY;
|
|
73
|
+
tex._premultiplyAlpha = options?.premultiplyAlpha;
|
|
80
74
|
tex._upload(engine);
|
|
81
75
|
}
|
|
82
|
-
/* ──────────────────────────── internal helpers ──────────────────────────── */
|
|
83
|
-
/** Resolve a sampling preset to a GL min filter. Defaults to `gl.LINEAR`. */
|
|
84
|
-
function samplingMinFilter(gl, mode) {
|
|
85
|
-
if (mode === GLSamplingMode.NEAREST) {
|
|
86
|
-
return gl.NEAREST;
|
|
87
|
-
}
|
|
88
|
-
if (mode === GLSamplingMode.TRILINEAR) {
|
|
89
|
-
return gl.LINEAR_MIPMAP_LINEAR;
|
|
90
|
-
}
|
|
91
|
-
return gl.LINEAR;
|
|
92
|
-
}
|
|
93
|
-
/** Resolve a sampling preset to a GL mag filter. Defaults to `gl.LINEAR`. */
|
|
94
|
-
function samplingMagFilter(gl, mode) {
|
|
95
|
-
return mode === GLSamplingMode.NEAREST ? gl.NEAREST : gl.LINEAR;
|
|
96
|
-
}
|
|
97
76
|
//# sourceMappingURL=html-texture.js.map
|
package/html-texture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-texture.js","sourceRoot":"","sources":["../src/html-texture.ts"],"names":[],"mappings":"AAQA,OAAO,
|
|
1
|
+
{"version":3,"file":"html-texture.js","sourceRoot":"","sources":["../src/html-texture.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,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AAC;QACzE,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC;IAEF,MAAM,oBAAoB,GAAG,CAAC,MAAuB,EAAQ,EAAE;QAC3D,qBAAqB,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC,CAAC;IAEF,MAAM,GAAG,GAAc;QACnB,MAAM;QACN,MAAM,EAAE,EAAE,CAAC,UAAU;QACrB,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,qBAAqB,EAAE,oBAAoB;QAC3C,SAAS,EAAE,IAAI;KAClB,CAAC;IACF,MAAM,CAAC,MAAM,CAAC,CAAC;IACf,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;;;;;;iFAWiF;AACjF,MAAM,UAAU,wBAAwB,CAAC,GAAc,EAAE,OAAgC;IACrF,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;IAC3B,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,SAAS,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QACtD,OAAO;IACX,CAAC;IACD,GAAG,CAAC,QAAQ,GAAG,OAAO,EAAE,OAAO,CAAC;IAChC,GAAG,CAAC,iBAAiB,GAAG,OAAO,EAAE,gBAAgB,CAAC;IAClD,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACxB,CAAC","sourcesContent":["/**\n * HTML element textures.\n *\n * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is\n * `sideEffects: false`, so consumers that don't need it (everything except\n * NeonBrush's `InputGlow`) tree-shake it out.\n */\nimport type { GLEngineContext } from \"./context.js\";\nimport {\n bindTextureForUpload,\n setTexImageSourceSize,\n setBoundTextureParams,\n setUnpackState,\n type GLTexture,\n type GLTextureOptions,\n type GLTextureUpdateOptions,\n} from \"./texture.js\";\n\n/** Create a texture backed by an `<canvas>` / `<img>` / `<video>` element.\n * The initial upload is performed immediately; call `updateHtmlElementTexture`\n * to re-upload after the source has changed.\n *\n * @param engine - The engine to create GL resources on.\n * @param element - The source element.\n * @param options - The shared {@link GLTextureOptions} (including `invertY`\n * and `premultiplyAlpha`), applied on creation, on every\n * `updateHtmlElementTexture` that omits them and on `webglcontextrestored`.\n * For Babylon-style presets spread `getSamplingModeFilters(...)`; for mipmaps\n * call `generateTextureMipMaps` once and every later update rebuilds the chain.\n * @returns The new {@link GLTexture}. */\nexport function createHtmlElementTexture(engine: GLEngineContext, element: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement, options?: GLTextureOptions): GLTexture {\n const gl = engine.gl;\n const handle = gl.createTexture();\n if (handle === null) {\n throw new Error(\"lite-gl: gl.createTexture returned null\");\n }\n const opts = options ?? {};\n const minFilter = opts.minFilter ?? gl.LINEAR;\n const magFilter = opts.magFilter ?? gl.LINEAR;\n const wrapS = opts.wrapS ?? gl.CLAMP_TO_EDGE;\n const wrapT = opts.wrapT ?? gl.CLAMP_TO_EDGE;\n const invertY = opts.invertY ?? false;\n const premultiplyAlpha = opts.premultiplyAlpha ?? false;\n\n const upload = (target: GLEngineContext): void => {\n const g = target.gl;\n setUnpackState(target, tex._invertY ?? invertY, tex._premultiplyAlpha ?? premultiplyAlpha);\n bindTextureForUpload(target, tex.handle);\n g.texImage2D(g.TEXTURE_2D, 0, g.RGBA8, g.RGBA, g.UNSIGNED_BYTE, element);\n setTexImageSourceSize(tex, element);\n };\n\n const initializeParameters = (target: GLEngineContext): void => {\n setBoundTextureParams(target.gl, minFilter, magFilter, wrapS, wrapT);\n };\n\n const tex: GLTexture = {\n handle,\n target: gl.TEXTURE_2D,\n width: 1,\n height: 1,\n isReady: true,\n _engine: engine,\n _disposed: false,\n _refCount: 1,\n _upload: upload,\n _initializeParameters: initializeParameters,\n _wasReady: true,\n };\n upload(engine);\n initializeParameters(engine);\n engine._textures.add(tex);\n return tex;\n}\n\n/** Re-upload the texture from its source element — the counterpart of\n * Babylon's `HtmlElementTexture.update(invertY)`. Only valid for textures\n * created by {@link createHtmlElementTexture}. No-op when the context is\n * lost/disposed or the texture is disposed.\n *\n * `invertY` is always the raw `UNPACK_FLIP_Y_WEBGL` value. Babylon flips\n * video elements with `!invertY`, so port `videoTexture.update(invertY)` as\n * `{ invertY: !invertY }` (canvas / image calls map directly).\n *\n * @param tex - A texture created by {@link createHtmlElementTexture}.\n * @param options - Per-update `invertY` / `premultiplyAlpha`; each defaults to\n * the texture's creation value. Retained for `webglcontextrestored` replay. */\nexport function updateHtmlElementTexture(tex: GLTexture, options?: GLTextureUpdateOptions): void {\n const engine = tex._engine;\n if (engine._isLost || engine._disposed || tex._disposed) {\n return;\n }\n tex._invertY = options?.invertY;\n tex._premultiplyAlpha = options?.premultiplyAlpha;\n tex._upload(engine);\n}\n"]}
|
package/index.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
export { createGLEngine, disposeGLEngine, resizeGLEngine, setGLEngineSize, wipeGLStateCache, getRenderWidth, getRenderHeight, getHardwareScalingLevel, setHardwareScalingLevel, getRenderingCanvas, onContextLost, offContextLost, onContextRestored, offContextRestored, } from "./context.js";
|
|
2
2
|
export type { GLEngineOptions, GLEngineCaps, GLEngineContext } from "./context.js";
|
|
3
3
|
export { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from "./alpha-to-coverage.js";
|
|
4
|
-
export { runRenderLoop, stopRenderLoop } from "./render-loop.js";
|
|
4
|
+
export { runRenderLoop, stopRenderLoop, beginFrame, endFrame } from "./render-loop.js";
|
|
5
|
+
export { captureGPUFrameTime, getGPUFrameTimeCounter } from "./gpu-frame-time.js";
|
|
6
|
+
export type { GLPerfCounter } from "./gpu-frame-time.js";
|
|
5
7
|
export { createEffect, useEffect, isEffectReady, getEffectCompilationError, executeWhenCompiled, disposeEffect, setEffectFloat, setEffectFloat2, setEffectFloat3, setEffectFloat4, setEffectColor3, setEffectColor4, setEffectVector2, setEffectDirectColor4, setEffectInt, setEffectTexture, setEffectMatrix, setEffectMatrix3x3, setEffectFloatArray, setEffectFloatArray4, setEffectIntArray, } from "./effect.js";
|
|
6
8
|
export type { GLEffectOptions, GLEffect } from "./effect.js";
|
|
7
9
|
export { waitForEffect } from "./effect-ready.js";
|
|
8
10
|
export type { GLEffectWaitOptions } from "./effect-ready.js";
|
|
9
11
|
export { createEffectWrapper, applyEffectWrapper, drawEffect, setViewport, disposeEffectWrapper } from "./effect-renderer.js";
|
|
10
12
|
export type { GLEffectWrapperOptions, GLEffectWrapper, GLViewport } from "./effect-renderer.js";
|
|
11
|
-
export { createRawTexture, createFloatTexture, generateTextureMipMaps, loadTexture2D, bindTexture, disposeTexture, updateRawTexture, updateTextureSamplingMode, updateTextureWrapMode, createTextureFromHandle, } from "./texture.js";
|
|
12
|
-
export type { GLTextureOptions, GLFloatTextureOptions, GLTexture } from "./texture.js";
|
|
13
|
+
export { createRawTexture, createFloatTexture, generateTextureMipMaps, loadTexture2D, bindTexture, unbindTexture, disposeTexture, updateRawTexture, updateTextureSamplingMode, updateTextureSamplingPreset, updateTextureWrapMode, createTextureFromHandle, getSamplingModeFilters, isTextureReady, GLSamplingMode, } from "./texture.js";
|
|
14
|
+
export type { GLTextureOptions, GLTextureUpdateOptions, GLRawTextureOptions, GLFloatTextureOptions, GLTexture, GLSamplingFilters } from "./texture.js";
|
|
13
15
|
export { createTextureFromSource } from "./texture-source.js";
|
|
14
16
|
export type { GLTextureSourceOptions } from "./texture-source.js";
|
|
15
|
-
export { createTexture3DFromPixels, bindTexture3D, setEffectTexture3D, generateTexture3DMipMaps, updateTexture3DSamplingMode, updateTexture3DWrapMode, disposeTexture3D, } from "./texture-3d.js";
|
|
17
|
+
export { createTexture3DFromPixels, bindTexture3D, unbindTexture3D, setEffectTexture3D, generateTexture3DMipMaps, updateTexture3DSamplingMode, updateTexture3DWrapMode, disposeTexture3D, } from "./texture-3d.js";
|
|
16
18
|
export type { GLPixelsTexture3DOptions, GLTexture3D } from "./texture-3d.js";
|
|
17
19
|
export { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource } from "./dynamic-texture.js";
|
|
18
|
-
export { createRenderTarget, createFloatRenderTarget, bindRenderTarget, generateRenderTargetMipMaps, resizeRenderTarget, readRenderTargetPixels, disposeRenderTarget, } from "./render-target.js";
|
|
19
|
-
export type { GLRenderTarget, GLRenderTargetOptions, GLFloatRenderTargetOptions } from "./render-target.js";
|
|
20
|
+
export { createRenderTarget, createFloatRenderTarget, bindRenderTarget, restoreDefaultFramebuffer, generateRenderTargetMipMaps, resizeRenderTarget, readRenderTargetPixels, readRenderTargetPixelsToBuffer, disposeRenderTarget, } from "./render-target.js";
|
|
21
|
+
export type { GLRenderTarget, GLRenderTargetOptions, GLFloatRenderTargetOptions, GLReadPixelsRegionOptions, GLReadPixelsOptions, GLReadPixelsToBufferOptions, } from "./render-target.js";
|
|
20
22
|
export { createVertexBuffer, updateVertexBuffer, createIndexBuffer, disposeBuffer, bindIndexBuffer, bindAttributes, unbindInstanceAttributes, drawIndexed, createMeshVao, bindMeshVao, drawMesh, disposeMeshVao, } from "./mesh.js";
|
|
21
23
|
export type { GLVertexBuffer, GLIndexBuffer, GLAttributeDescriptor, GLMeshVertexBuffer, GLMeshVao } from "./mesh.js";
|
|
22
24
|
export { GLBlendMode, GLBlendEquation, setBlendMode, setBlendState, disableBlend } from "./blend.js";
|
|
@@ -26,8 +28,7 @@ export type { GLDepthState, GLStencilState, GLStencilOpState, GLClearOptions } f
|
|
|
26
28
|
export { setScissor, disableScissor } from "./scissor.js";
|
|
27
29
|
export { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeSpriteRenderer } from "./sprites.js";
|
|
28
30
|
export type { GLSprite, GLSpriteColor, GLSpriteRendererOptions, GLSpriteRenderer } from "./sprites.js";
|
|
29
|
-
export { createHtmlElementTexture, updateHtmlElementTexture
|
|
30
|
-
export type { GLHtmlElementTextureOptions } from "./html-texture.js";
|
|
31
|
+
export { createHtmlElementTexture, updateHtmlElementTexture } from "./html-texture.js";
|
|
31
32
|
export type { GLFont } from "./text/font.js";
|
|
32
33
|
export { loadFont, createFontFromBuffer } from "./text/font.js";
|
|
33
34
|
export { extractGlyphCurves, cubicToQuadratics } from "./text/glyph-extraction.js";
|
package/index.js
CHANGED
|
@@ -15,20 +15,24 @@ export { createGLEngine, disposeGLEngine, resizeGLEngine, setGLEngineSize, wipeG
|
|
|
15
15
|
// ─── Alpha-to-coverage (optional) ───────────────────────────────────
|
|
16
16
|
export { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from "./alpha-to-coverage.js";
|
|
17
17
|
// ─── Render loop ─────────────────────────────────────────────────────
|
|
18
|
-
export { runRenderLoop, stopRenderLoop } from "./render-loop.js";
|
|
18
|
+
export { runRenderLoop, stopRenderLoop, beginFrame, endFrame } from "./render-loop.js";
|
|
19
|
+
// ─── GPU frame timing (optional) ────────────────────────────────────
|
|
20
|
+
export { captureGPUFrameTime, getGPUFrameTimeCounter } from "./gpu-frame-time.js";
|
|
19
21
|
// ─── Effects ─────────────────────────────────────────────────────────
|
|
20
22
|
export { createEffect, useEffect, isEffectReady, getEffectCompilationError, executeWhenCompiled, disposeEffect, setEffectFloat, setEffectFloat2, setEffectFloat3, setEffectFloat4, setEffectColor3, setEffectColor4, setEffectVector2, setEffectDirectColor4, setEffectInt, setEffectTexture, setEffectMatrix, setEffectMatrix3x3, setEffectFloatArray, setEffectFloatArray4, setEffectIntArray, } from "./effect.js";
|
|
21
23
|
export { waitForEffect } from "./effect-ready.js";
|
|
22
24
|
// ─── Effect renderer (fullscreen quad) ───────────────────────────────
|
|
23
25
|
export { createEffectWrapper, applyEffectWrapper, drawEffect, setViewport, disposeEffectWrapper } from "./effect-renderer.js";
|
|
24
26
|
// ─── Textures ────────────────────────────────────────────────────────
|
|
25
|
-
export { createRawTexture, createFloatTexture, generateTextureMipMaps, loadTexture2D, bindTexture, disposeTexture, updateRawTexture, updateTextureSamplingMode, updateTextureWrapMode, createTextureFromHandle,
|
|
27
|
+
export { createRawTexture, createFloatTexture, generateTextureMipMaps, loadTexture2D, bindTexture, unbindTexture, disposeTexture, updateRawTexture, updateTextureSamplingMode, updateTextureSamplingPreset, updateTextureWrapMode, createTextureFromHandle, getSamplingModeFilters, isTextureReady,
|
|
28
|
+
// GLSamplingMode is a const + same-name type; one value re-export carries both.
|
|
29
|
+
GLSamplingMode, } from "./texture.js";
|
|
26
30
|
export { createTextureFromSource } from "./texture-source.js";
|
|
27
|
-
export { createTexture3DFromPixels, bindTexture3D, setEffectTexture3D, generateTexture3DMipMaps, updateTexture3DSamplingMode, updateTexture3DWrapMode, disposeTexture3D, } from "./texture-3d.js";
|
|
31
|
+
export { createTexture3DFromPixels, bindTexture3D, unbindTexture3D, setEffectTexture3D, generateTexture3DMipMaps, updateTexture3DSamplingMode, updateTexture3DWrapMode, disposeTexture3D, } from "./texture-3d.js";
|
|
28
32
|
// ─── Dynamic textures ────────────────────────────────────────────────
|
|
29
33
|
export { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource } from "./dynamic-texture.js";
|
|
30
34
|
// ─── Render targets ──────────────────────────────────────────────────
|
|
31
|
-
export { createRenderTarget, createFloatRenderTarget, bindRenderTarget, generateRenderTargetMipMaps, resizeRenderTarget, readRenderTargetPixels, disposeRenderTarget, } from "./render-target.js";
|
|
35
|
+
export { createRenderTarget, createFloatRenderTarget, bindRenderTarget, restoreDefaultFramebuffer, generateRenderTargetMipMaps, resizeRenderTarget, readRenderTargetPixels, readRenderTargetPixelsToBuffer, disposeRenderTarget, } from "./render-target.js";
|
|
32
36
|
// ─── Meshes / buffers / instancing ───────────────────────────────────
|
|
33
37
|
export { createVertexBuffer, updateVertexBuffer, createIndexBuffer, disposeBuffer, bindIndexBuffer, bindAttributes, unbindInstanceAttributes, drawIndexed, createMeshVao, bindMeshVao, drawMesh, disposeMeshVao, } from "./mesh.js";
|
|
34
38
|
// ─── Blend modes ─────────────────────────────────────────────────────
|
|
@@ -42,8 +46,7 @@ export { setScissor, disableScissor } from "./scissor.js";
|
|
|
42
46
|
// ─── Sprites ─────────────────────────────────────────────────────────
|
|
43
47
|
export { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeSpriteRenderer } from "./sprites.js";
|
|
44
48
|
// ─── HTML-element textures ───────────────────────────────────────────
|
|
45
|
-
|
|
46
|
-
export { createHtmlElementTexture, updateHtmlElementTexture, GLSamplingMode } from "./html-texture.js";
|
|
49
|
+
export { createHtmlElementTexture, updateHtmlElementTexture } from "./html-texture.js";
|
|
47
50
|
export { loadFont, createFontFromBuffer } from "./text/font.js";
|
|
48
51
|
export { extractGlyphCurves, cubicToQuadratics } from "./text/glyph-extraction.js";
|
|
49
52
|
export { createGlyphStorage, updateGlyphStorage, disposeGlyphStorage } from "./text/glyph-storage.js";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,gFAAgF;AAChF,EAAE;AACF,iFAAiF;AACjF,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,+DAA+D;AAC/D,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,wCAAwC;AAExC,wEAAwE;AACxE,OAAO,EACH,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,cAAc,CAAC;AAGtB,uEAAuE;AACvE,OAAO,EAAE,k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UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["// @babylonjs/lite-gl — Public API\n// Function-based, tree-shakeable WebGL2 micro-engine. Import only what you use.\n//\n// Convention (mirrors @babylonjs/lite): the public API is re-exported EXPLICITLY\n// by name — never `export *`. This keeps the public surface intentional and\n// reviewable, lets `export type` mark type-only re-exports (required under\n// `isolatedModules`), and keeps internal helpers (e.g. `bindTextureRaw`,\n// `bindTextureForUpload`) out of consumers' bundles + `.d.ts`.\n//\n// The package is `sideEffects: false` and no module has top-level side effects,\n// so a consumer that imports only the symbols it needs tree-shakes everything\n// else (sprites, html-texture, …) away.\n\n// ─── Engine / context ────────────────────────────────────────────────\nexport {\n createGLEngine,\n disposeGLEngine,\n resizeGLEngine,\n setGLEngineSize,\n wipeGLStateCache,\n getRenderWidth,\n getRenderHeight,\n getHardwareScalingLevel,\n setHardwareScalingLevel,\n getRenderingCanvas,\n onContextLost,\n offContextLost,\n onContextRestored,\n offContextRestored,\n} from \"./context.js\";\nexport type { GLEngineOptions, GLEngineCaps, GLEngineContext } from \"./context.js\";\n\n// ─── Alpha-to-coverage (optional) ───────────────────────────────────\nexport { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from \"./alpha-to-coverage.js\";\n\n// ─── Render loop ─────────────────────────────────────────────────────\nexport { runRenderLoop, stopRenderLoop } from \"./render-loop.js\";\n\n// ─── Effects ─────────────────────────────────────────────────────────\nexport {\n createEffect,\n useEffect,\n isEffectReady,\n getEffectCompilationError,\n executeWhenCompiled,\n disposeEffect,\n setEffectFloat,\n setEffectFloat2,\n setEffectFloat3,\n setEffectFloat4,\n setEffectColor3,\n setEffectColor4,\n setEffectVector2,\n setEffectDirectColor4,\n setEffectInt,\n setEffectTexture,\n setEffectMatrix,\n setEffectMatrix3x3,\n setEffectFloatArray,\n setEffectFloatArray4,\n setEffectIntArray,\n} from \"./effect.js\";\nexport type { GLEffectOptions, GLEffect } from \"./effect.js\";\nexport { waitForEffect } from \"./effect-ready.js\";\nexport type { GLEffectWaitOptions } from \"./effect-ready.js\";\n\n// ─── Effect renderer (fullscreen quad) ───────────────────────────────\nexport { createEffectWrapper, applyEffectWrapper, drawEffect, setViewport, disposeEffectWrapper } from \"./effect-renderer.js\";\nexport type { GLEffectWrapperOptions, GLEffectWrapper, GLViewport } from \"./effect-renderer.js\";\n\n// ─── Textures ────────────────────────────────────────────────────────\nexport {\n createRawTexture,\n createFloatTexture,\n generateTextureMipMaps,\n loadTexture2D,\n bindTexture,\n disposeTexture,\n updateRawTexture,\n updateTextureSamplingMode,\n updateTextureWrapMode,\n createTextureFromHandle,\n} from \"./texture.js\";\nexport type { GLTextureOptions, GLFloatTextureOptions, GLTexture } from \"./texture.js\";\nexport { createTextureFromSource } from \"./texture-source.js\";\nexport type { GLTextureSourceOptions } from \"./texture-source.js\";\nexport {\n createTexture3DFromPixels,\n bindTexture3D,\n setEffectTexture3D,\n generateTexture3DMipMaps,\n updateTexture3DSamplingMode,\n updateTexture3DWrapMode,\n disposeTexture3D,\n} from \"./texture-3d.js\";\nexport type { GLPixelsTexture3DOptions, GLTexture3D } from \"./texture-3d.js\";\n\n// ─── Dynamic textures ────────────────────────────────────────────────\nexport { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource } from \"./dynamic-texture.js\";\n\n// ─── Render targets ──────────────────────────────────────────────────\nexport {\n createRenderTarget,\n createFloatRenderTarget,\n bindRenderTarget,\n generateRenderTargetMipMaps,\n resizeRenderTarget,\n readRenderTargetPixels,\n disposeRenderTarget,\n} from \"./render-target.js\";\nexport type { GLRenderTarget, GLRenderTargetOptions, GLFloatRenderTargetOptions } from \"./render-target.js\";\n\n// ─── Meshes / buffers / instancing ───────────────────────────────────\nexport {\n createVertexBuffer,\n updateVertexBuffer,\n createIndexBuffer,\n disposeBuffer,\n bindIndexBuffer,\n bindAttributes,\n unbindInstanceAttributes,\n drawIndexed,\n createMeshVao,\n bindMeshVao,\n drawMesh,\n disposeMeshVao,\n} from \"./mesh.js\";\nexport type { GLVertexBuffer, GLIndexBuffer, GLAttributeDescriptor, GLMeshVertexBuffer, GLMeshVao } from \"./mesh.js\";\n\n// ─── Blend modes ─────────────────────────────────────────────────────\n// GLBlendMode / GLBlendEquation are const + same-name type; one value\n// re-export carries both.\nexport { GLBlendMode, GLBlendEquation, setBlendMode, setBlendState, disableBlend } from \"./blend.js\";\nexport type { GLBlendState } from \"./blend.js\";\n\n// ─── Depth / stencil / color-mask / clear ────────────────────────────\nexport { setDepthState, setCullState, setStencilState, setStencilOpSeparate, setColorMask, clearEngine, generateRenderTargetStencil } from \"./depth-stencil.js\";\nexport type { GLDepthState, GLStencilState, GLStencilOpState, GLClearOptions } from \"./depth-stencil.js\";\n\n// ─── Scissor ─────────────────────────────────────────────────────────\nexport { setScissor, disableScissor } from \"./scissor.js\";\n\n// ─── Sprites ─────────────────────────────────────────────────────────\nexport { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeSpriteRenderer } from \"./sprites.js\";\nexport type { GLSprite, GLSpriteColor, GLSpriteRendererOptions, GLSpriteRenderer } from \"./sprites.js\";\n\n// ─── HTML-element textures ───────────────────────────────────────────\n// GLSamplingMode is a const + same-name type; one value re-export carries both.\nexport { createHtmlElementTexture, updateHtmlElementTexture, GLSamplingMode } from \"./html-texture.js\";\nexport type { GLHtmlElementTextureOptions } from \"./html-texture.js\";\n\n// ─── Text (analytic Slug coverage) ───────────────────────────────────\nexport type { GLFont } from \"./text/font.js\";\nexport { loadFont, createFontFromBuffer } from \"./text/font.js\";\nexport { extractGlyphCurves, cubicToQuadratics } from \"./text/glyph-extraction.js\";\nexport type { GLTextLayoutOptions } from \"./text/layout.js\";\nexport type { GLGlyphStorage, GLCurveSetId, GLQuadCurve, GLGlyphBounds, GLGlyphCurves } from \"./text/glyph-storage.js\";\nexport { createGlyphStorage, updateGlyphStorage, disposeGlyphStorage } from \"./text/glyph-storage.js\";\nexport type { GLTextData, GLPlacedGlyph, GLGlyphRun, GLTextDataUpdate } from \"./text/text-data.js\";\nexport { createTextData, updateTextData, disposeTextData } from \"./text/text-data.js\";\nexport type { GLDefaultTextData } from \"./text/default-text-data.js\";\nexport { createDefaultTextData, updateDefaultTextData, disposeDefaultTextData } from \"./text/default-text-data.js\";\nexport type { GLTextLayer, GLTextLayerOptions, GLTextRenderer, GLTextRendererOptions } from \"./text/text-renderer.js\";\nexport {\n createTextLayer,\n setTextLayerPosition,\n createTextRenderer,\n renderText,\n isTextRendererReady,\n addTextRendererLayer,\n removeTextRendererLayer,\n registerTextRenderer,\n unregisterTextRenderer,\n disposeTextRenderer,\n} from \"./text/text-renderer.js\";\nexport { setFontWeightOffset } from \"./text/set-font-weight-offset.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,gFAAgF;AAChF,EAAE;AACF,iFAAiF;AACjF,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,+DAA+D;AAC/D,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,wCAAwC;AAExC,wEAAwE;AACxE,OAAO,EACH,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,cAAc,CAAC;AAGtB,uEAAuE;AACvE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEvG,wEAAwE;AACxE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvF,uEAA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,EACpB,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["// @babylonjs/lite-gl — Public API\n// Function-based, tree-shakeable WebGL2 micro-engine. Import only what you use.\n//\n// Convention (mirrors @babylonjs/lite): the public API is re-exported EXPLICITLY\n// by name — never `export *`. This keeps the public surface intentional and\n// reviewable, lets `export type` mark type-only re-exports (required under\n// `isolatedModules`), and keeps internal helpers (e.g. `bindTextureRaw`,\n// `bindTextureForUpload`) out of consumers' bundles + `.d.ts`.\n//\n// The package is `sideEffects: false` and no module has top-level side effects,\n// so a consumer that imports only the symbols it needs tree-shakes everything\n// else (sprites, html-texture, …) away.\n\n// ─── Engine / context ────────────────────────────────────────────────\nexport {\n createGLEngine,\n disposeGLEngine,\n resizeGLEngine,\n setGLEngineSize,\n wipeGLStateCache,\n getRenderWidth,\n getRenderHeight,\n getHardwareScalingLevel,\n setHardwareScalingLevel,\n getRenderingCanvas,\n onContextLost,\n offContextLost,\n onContextRestored,\n offContextRestored,\n} from \"./context.js\";\nexport type { GLEngineOptions, GLEngineCaps, GLEngineContext } from \"./context.js\";\n\n// ─── Alpha-to-coverage (optional) ───────────────────────────────────\nexport { getAlphaToCoverage, getCurrentSampleCount, setAlphaToCoverage } from \"./alpha-to-coverage.js\";\n\n// ─── Render loop ─────────────────────────────────────────────────────\nexport { runRenderLoop, stopRenderLoop, beginFrame, endFrame } from \"./render-loop.js\";\n\n// ─── GPU frame timing (optional) ────────────────────────────────────\nexport { captureGPUFrameTime, getGPUFrameTimeCounter } from \"./gpu-frame-time.js\";\nexport type { GLPerfCounter } from \"./gpu-frame-time.js\";\n\n// ─── Effects ─────────────────────────────────────────────────────────\nexport {\n createEffect,\n useEffect,\n isEffectReady,\n getEffectCompilationError,\n executeWhenCompiled,\n disposeEffect,\n setEffectFloat,\n setEffectFloat2,\n setEffectFloat3,\n setEffectFloat4,\n setEffectColor3,\n setEffectColor4,\n setEffectVector2,\n setEffectDirectColor4,\n setEffectInt,\n setEffectTexture,\n setEffectMatrix,\n setEffectMatrix3x3,\n setEffectFloatArray,\n setEffectFloatArray4,\n setEffectIntArray,\n} from \"./effect.js\";\nexport type { GLEffectOptions, GLEffect } from \"./effect.js\";\nexport { waitForEffect } from \"./effect-ready.js\";\nexport type { GLEffectWaitOptions } from \"./effect-ready.js\";\n\n// ─── Effect renderer (fullscreen quad) ───────────────────────────────\nexport { createEffectWrapper, applyEffectWrapper, drawEffect, setViewport, disposeEffectWrapper } from \"./effect-renderer.js\";\nexport type { GLEffectWrapperOptions, GLEffectWrapper, GLViewport } from \"./effect-renderer.js\";\n\n// ─── Textures ────────────────────────────────────────────────────────\nexport {\n createRawTexture,\n createFloatTexture,\n generateTextureMipMaps,\n loadTexture2D,\n bindTexture,\n unbindTexture,\n disposeTexture,\n updateRawTexture,\n updateTextureSamplingMode,\n updateTextureSamplingPreset,\n updateTextureWrapMode,\n createTextureFromHandle,\n getSamplingModeFilters,\n isTextureReady,\n // GLSamplingMode is a const + same-name type; one value re-export carries both.\n GLSamplingMode,\n} from \"./texture.js\";\nexport type { GLTextureOptions, GLTextureUpdateOptions, GLRawTextureOptions, GLFloatTextureOptions, GLTexture, GLSamplingFilters } from \"./texture.js\";\nexport { createTextureFromSource } from \"./texture-source.js\";\nexport type { GLTextureSourceOptions } from \"./texture-source.js\";\nexport {\n createTexture3DFromPixels,\n bindTexture3D,\n unbindTexture3D,\n setEffectTexture3D,\n generateTexture3DMipMaps,\n updateTexture3DSamplingMode,\n updateTexture3DWrapMode,\n disposeTexture3D,\n} from \"./texture-3d.js\";\nexport type { GLPixelsTexture3DOptions, GLTexture3D } from \"./texture-3d.js\";\n\n// ─── Dynamic textures ────────────────────────────────────────────────\nexport { createDynamicTexture, updateDynamicTexture, clearDynamicTextureSource } from \"./dynamic-texture.js\";\n\n// ─── Render targets ──────────────────────────────────────────────────\nexport {\n createRenderTarget,\n createFloatRenderTarget,\n bindRenderTarget,\n restoreDefaultFramebuffer,\n generateRenderTargetMipMaps,\n resizeRenderTarget,\n readRenderTargetPixels,\n readRenderTargetPixelsToBuffer,\n disposeRenderTarget,\n} from \"./render-target.js\";\nexport type {\n GLRenderTarget,\n GLRenderTargetOptions,\n GLFloatRenderTargetOptions,\n GLReadPixelsRegionOptions,\n GLReadPixelsOptions,\n GLReadPixelsToBufferOptions,\n} from \"./render-target.js\";\n\n// ─── Meshes / buffers / instancing ───────────────────────────────────\nexport {\n createVertexBuffer,\n updateVertexBuffer,\n createIndexBuffer,\n disposeBuffer,\n bindIndexBuffer,\n bindAttributes,\n unbindInstanceAttributes,\n drawIndexed,\n createMeshVao,\n bindMeshVao,\n drawMesh,\n disposeMeshVao,\n} from \"./mesh.js\";\nexport type { GLVertexBuffer, GLIndexBuffer, GLAttributeDescriptor, GLMeshVertexBuffer, GLMeshVao } from \"./mesh.js\";\n\n// ─── Blend modes ─────────────────────────────────────────────────────\n// GLBlendMode / GLBlendEquation are const + same-name type; one value\n// re-export carries both.\nexport { GLBlendMode, GLBlendEquation, setBlendMode, setBlendState, disableBlend } from \"./blend.js\";\nexport type { GLBlendState } from \"./blend.js\";\n\n// ─── Depth / stencil / color-mask / clear ────────────────────────────\nexport { setDepthState, setCullState, setStencilState, setStencilOpSeparate, setColorMask, clearEngine, generateRenderTargetStencil } from \"./depth-stencil.js\";\nexport type { GLDepthState, GLStencilState, GLStencilOpState, GLClearOptions } from \"./depth-stencil.js\";\n\n// ─── Scissor ─────────────────────────────────────────────────────────\nexport { setScissor, disableScissor } from \"./scissor.js\";\n\n// ─── Sprites ─────────────────────────────────────────────────────────\nexport { createSpriteRenderer, renderSprites, setSpriteRendererTexture, disposeSpriteRenderer } from \"./sprites.js\";\nexport type { GLSprite, GLSpriteColor, GLSpriteRendererOptions, GLSpriteRenderer } from \"./sprites.js\";\n\n// ─── HTML-element textures ───────────────────────────────────────────\nexport { createHtmlElementTexture, updateHtmlElementTexture } from \"./html-texture.js\";\n\n// ─── Text (analytic Slug coverage) ───────────────────────────────────\nexport type { GLFont } from \"./text/font.js\";\nexport { loadFont, createFontFromBuffer } from \"./text/font.js\";\nexport { extractGlyphCurves, cubicToQuadratics } from \"./text/glyph-extraction.js\";\nexport type { GLTextLayoutOptions } from \"./text/layout.js\";\nexport type { GLGlyphStorage, GLCurveSetId, GLQuadCurve, GLGlyphBounds, GLGlyphCurves } from \"./text/glyph-storage.js\";\nexport { createGlyphStorage, updateGlyphStorage, disposeGlyphStorage } from \"./text/glyph-storage.js\";\nexport type { GLTextData, GLPlacedGlyph, GLGlyphRun, GLTextDataUpdate } from \"./text/text-data.js\";\nexport { createTextData, updateTextData, disposeTextData } from \"./text/text-data.js\";\nexport type { GLDefaultTextData } from \"./text/default-text-data.js\";\nexport { createDefaultTextData, updateDefaultTextData, disposeDefaultTextData } from \"./text/default-text-data.js\";\nexport type { GLTextLayer, GLTextLayerOptions, GLTextRenderer, GLTextRendererOptions } from \"./text/text-renderer.js\";\nexport {\n createTextLayer,\n setTextLayerPosition,\n createTextRenderer,\n renderText,\n isTextRendererReady,\n addTextRendererLayer,\n removeTextRendererLayer,\n registerTextRenderer,\n unregisterTextRenderer,\n disposeTextRenderer,\n} from \"./text/text-renderer.js\";\nexport { setFontWeightOffset } from \"./text/set-font-weight-offset.js\";\n"]}
|