@babylonjs/lite-gl 0.1.0 → 0.2.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 +10 -34
- package/apply-states.d.ts +1 -0
- package/apply-states.js +30 -0
- package/apply-states.js.map +1 -0
- package/blend.d.ts +123 -0
- package/blend.js +194 -0
- package/blend.js.map +1 -0
- package/context.d.ts +130 -0
- package/context.js +354 -0
- package/context.js.map +1 -0
- package/depth-stencil.d.ts +155 -231
- package/depth-stencil.js +399 -262
- package/depth-stencil.js.map +1 -1
- package/dynamic-texture.d.ts +59 -149
- package/dynamic-texture.js +123 -69
- package/dynamic-texture.js.map +1 -1
- package/effect-renderer.d.ts +65 -0
- package/effect-renderer.js +132 -0
- package/effect-renderer.js.map +1 -0
- package/effect.d.ts +142 -0
- package/effect.js +465 -0
- package/effect.js.map +1 -0
- package/html-texture.d.ts +44 -143
- package/html-texture.js +87 -81
- package/html-texture.js.map +1 -1
- package/index.d.ts +23 -1482
- package/index.js +42 -263
- package/index.js.map +1 -1
- package/mesh.d.ts +210 -307
- package/mesh.js +436 -311
- package/mesh.js.map +1 -1
- package/package.json +5 -29
- package/render-loop.d.ts +8 -0
- package/render-loop.js +62 -0
- package/render-loop.js.map +1 -0
- package/render-target.d.ts +233 -290
- package/render-target.js +534 -335
- package/render-target.js.map +1 -1
- package/scissor.d.ts +30 -72
- package/scissor.js +47 -33
- package/scissor.js.map +1 -1
- package/shader.d.ts +22 -0
- package/shader.js +65 -0
- package/shader.js.map +1 -0
- package/sprites.d.ts +182 -263
- package/sprites.js +426 -10
- package/sprites.js.map +1 -1
- package/state.d.ts +126 -0
- package/state.js +153 -0
- package/state.js.map +1 -0
- package/texture.d.ts +142 -0
- package/texture.js +433 -0
- package/texture.js.map +1 -0
- package/effect-BxxwfB_O.js +0 -737
- package/effect-BxxwfB_O.js.map +0 -1
- package/sprites--1oyVtJ3.js +0 -437
- package/sprites--1oyVtJ3.js.map +0 -1
- package/state--j_ncWIi.js +0 -155
- package/state--j_ncWIi.js.map +0 -1
- package/texture-DaMd1gGm.js +0 -329
- package/texture-DaMd1gGm.js.map +0 -1
package/depth-stencil.d.ts
CHANGED
|
@@ -1,231 +1,155 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
depth
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
/** Op when the stencil test passes but depth fails (`gl.stencilOp` arg 2). */
|
|
157
|
-
opZFail?: GLenum;
|
|
158
|
-
/** Op when both stencil and depth pass (`gl.stencilOp` arg 3). */
|
|
159
|
-
opZPass?: GLenum;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Pure-state texture handle. The `handle` field is MUTABLE so the same logical
|
|
164
|
-
* texture survives a `webglcontextrestored` event — every consumer keeps the
|
|
165
|
-
* same `GLTexture` reference; only the internal `WebGLTexture` is swapped.
|
|
166
|
-
*
|
|
167
|
-
* `loadTexture2D` also uses the same handle for the 1×1 placeholder upload AND
|
|
168
|
-
* the final image upload — so a `bindTexture(engine, unit, tex)` made before the
|
|
169
|
-
* image has decoded remains valid once the image arrives.
|
|
170
|
-
*/
|
|
171
|
-
declare interface GLTexture_2 {
|
|
172
|
-
/** The live `WebGLTexture`. MUTABLE — swapped for a fresh handle on
|
|
173
|
-
* `webglcontextrestored` while consumers keep the same `GLTexture` reference. */
|
|
174
|
-
handle: WebGLTexture;
|
|
175
|
-
/** GL texture target (always `gl.TEXTURE_2D` for this package). */
|
|
176
|
-
readonly target: GLenum;
|
|
177
|
-
/** Texture width in texels. Updated once an async upload resolves. */
|
|
178
|
-
width: number;
|
|
179
|
-
/** Texture height in texels. Updated once an async upload resolves. */
|
|
180
|
-
height: number;
|
|
181
|
-
/** True when the texture is safe to sample with final content (placeholders
|
|
182
|
-
* read as not-ready until their image/upload completes). */
|
|
183
|
-
isReady: boolean;
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Buffer the color write mask into the DESIRED state — the lite-gl equivalent of
|
|
187
|
-
* Babylon's `setColorWrite` (which passes the same flag to all four channels).
|
|
188
|
-
* Flushed to GL (`gl.colorMask`) by `applyGLStates` before the next draw /
|
|
189
|
-
* clear.
|
|
190
|
-
*
|
|
191
|
-
* @param engine - The engine.
|
|
192
|
-
* @param r - Write red.
|
|
193
|
-
* @param g - Write green.
|
|
194
|
-
* @param b - Write blue.
|
|
195
|
-
* @param a - Write alpha.
|
|
196
|
-
*/
|
|
197
|
-
export declare function setColorMask(engine: GLEngineContext, r: boolean, g: boolean, b: boolean, a: boolean): void;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Enable/disable face culling and (optionally) set the cull face — the lite-gl
|
|
201
|
-
* equivalent of `engine.depthCullingState.cull` + `cullFace`.
|
|
202
|
-
*
|
|
203
|
-
* @param engine - The engine.
|
|
204
|
-
* @param enabled - Enable (`true`) or disable (`false`) `gl.CULL_FACE`.
|
|
205
|
-
* @param face - Optional cull face (`gl.BACK` / `gl.FRONT` / `gl.FRONT_AND_BACK`).
|
|
206
|
-
*/
|
|
207
|
-
export declare function setCullState(engine: GLEngineContext, enabled: boolean, face?: GLenum): void;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Buffer depth-buffer state (test enable, write mask, comparison function) into
|
|
211
|
-
* the DESIRED state — the lite-gl equivalent of mutating Babylon's
|
|
212
|
-
* `engine.depthCullingState.{depthTest,depthMask,depthFunc}`. Flushed to GL by
|
|
213
|
-
* `applyGLStates` before the next draw / clear; omitted fields are untouched.
|
|
214
|
-
*
|
|
215
|
-
* @param engine - The engine.
|
|
216
|
-
* @param state - The depth fields to change. Omitted fields are untouched.
|
|
217
|
-
*/
|
|
218
|
-
export declare function setDepthState(engine: GLEngineContext, state: GLDepthState): void;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Buffer stencil state (test enable, write mask, comparison func triple, op
|
|
222
|
-
* triple) into the DESIRED state — the lite-gl equivalent of mutating Babylon's
|
|
223
|
-
* `engine.stencilState.*`. Flushed by `applyGLStates` before the next draw /
|
|
224
|
-
* clear; omitted fields are untouched (merge-from-desired).
|
|
225
|
-
*
|
|
226
|
-
* @param engine - The engine.
|
|
227
|
-
* @param state - The stencil fields to change. Omitted fields are untouched.
|
|
228
|
-
*/
|
|
229
|
-
export declare function setStencilState(engine: GLEngineContext, state: GLStencilState): void;
|
|
230
|
-
|
|
231
|
-
export { }
|
|
1
|
+
/**
|
|
2
|
+
* Depth, stencil, color-mask and clear state — the lite-gl counterpart of
|
|
3
|
+
* Babylon's `_depthCullingState` / `_stencilState` / `setColorWrite` / `clear`.
|
|
4
|
+
*
|
|
5
|
+
* Like Babylon, these setters are DEFERRED: they buffer the requested values
|
|
6
|
+
* into the DESIRED (`d*`) mirror fields of `GLState` and raise `statesDirty`,
|
|
7
|
+
* issuing NO `gl.*` calls themselves. `applyGLStates` (apply-states.ts) flushes
|
|
8
|
+
* the diff to GL right before each draw (and before `clearEngine`'s `gl.clear`,
|
|
9
|
+
* since a clear respects the current write masks). Every field is reconciled
|
|
10
|
+
* independently, so a flush that changes only one sub-state (e.g. just the
|
|
11
|
+
* stencil op triple) issues only that GL call. Omitted setter fields leave the
|
|
12
|
+
* corresponding desired value untouched (merge-from-desired).
|
|
13
|
+
*
|
|
14
|
+
* All setters are no-ops on a lost/disposed context.
|
|
15
|
+
*
|
|
16
|
+
* This module also hosts {@link generateRenderTargetStencil} — the tree-shakeable
|
|
17
|
+
* opt-in that gives a `/render-target` {@link GLRenderTarget} a stencil (or packed
|
|
18
|
+
* depth+stencil) attachment. Keeping the STENCIL_INDEX8 / DEPTH24_STENCIL8
|
|
19
|
+
* renderbuffer code here (rather than in the render-target core) means a consumer
|
|
20
|
+
* that only needs a depth buffer never ships it. The one-way type import below
|
|
21
|
+
* (`depth-stencil` importing `render-target`) introduces NO cycle: render-target
|
|
22
|
+
* must not import this module.
|
|
23
|
+
*/
|
|
24
|
+
import type { GLEngineContext } from "./context.js";
|
|
25
|
+
import type { GLRenderTarget } from "./render-target.js";
|
|
26
|
+
/** Depth-buffer configuration for {@link setDepthState}. Omitted fields are
|
|
27
|
+
* left unchanged. */
|
|
28
|
+
export interface GLDepthState {
|
|
29
|
+
/** Enable/disable the depth test (`gl.enable/disable(DEPTH_TEST)`). */
|
|
30
|
+
test?: boolean;
|
|
31
|
+
/** Enable/disable depth writes (`gl.depthMask`). */
|
|
32
|
+
write?: boolean;
|
|
33
|
+
/** Depth comparison function (`gl.depthFunc`), e.g. `gl.LESS`. */
|
|
34
|
+
func?: GLenum;
|
|
35
|
+
}
|
|
36
|
+
/** Stencil configuration for {@link setStencilState}. Omitted fields are left
|
|
37
|
+
* unchanged. The `func`/`ref`/`funcMask` triple and the
|
|
38
|
+
* `opFail`/`opZFail`/`opZPass` triple are each applied as a unit (any member
|
|
39
|
+
* present re-issues that GL call, merging the unspecified members from cache). */
|
|
40
|
+
export interface GLStencilState {
|
|
41
|
+
/** Enable/disable the stencil test (`gl.enable/disable(STENCIL_TEST)`). */
|
|
42
|
+
test?: boolean;
|
|
43
|
+
/** Stencil write mask (`gl.stencilMask`). */
|
|
44
|
+
mask?: number;
|
|
45
|
+
/** Comparison function (`gl.stencilFunc` arg 1), e.g. `gl.ALWAYS`. */
|
|
46
|
+
func?: GLenum;
|
|
47
|
+
/** Reference value (`gl.stencilFunc` arg 2). */
|
|
48
|
+
ref?: number;
|
|
49
|
+
/** Comparison mask (`gl.stencilFunc` arg 3). */
|
|
50
|
+
funcMask?: number;
|
|
51
|
+
/** Op when the stencil test fails (`gl.stencilOp` arg 1). */
|
|
52
|
+
opFail?: GLenum;
|
|
53
|
+
/** Op when the stencil test passes but depth fails (`gl.stencilOp` arg 2). */
|
|
54
|
+
opZFail?: GLenum;
|
|
55
|
+
/** Op when both stencil and depth pass (`gl.stencilOp` arg 3). */
|
|
56
|
+
opZPass?: GLenum;
|
|
57
|
+
}
|
|
58
|
+
/** Options for {@link clearEngine}. */
|
|
59
|
+
export interface GLClearOptions {
|
|
60
|
+
/** When set, clears the color buffer to this RGBA color (alpha default 1). */
|
|
61
|
+
color?: {
|
|
62
|
+
r: number;
|
|
63
|
+
g: number;
|
|
64
|
+
b: number;
|
|
65
|
+
a?: number;
|
|
66
|
+
};
|
|
67
|
+
/** Clear the depth buffer (respects the current depth write mask). */
|
|
68
|
+
depth?: boolean;
|
|
69
|
+
/** Clear the stencil buffer (respects the current stencil write mask). */
|
|
70
|
+
stencil?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Buffer depth-buffer state (test enable, write mask, comparison function) into
|
|
74
|
+
* the DESIRED state — the lite-gl equivalent of mutating Babylon's
|
|
75
|
+
* `engine.depthCullingState.{depthTest,depthMask,depthFunc}`. Flushed to GL by
|
|
76
|
+
* `applyGLStates` before the next draw / clear; omitted fields are untouched.
|
|
77
|
+
*
|
|
78
|
+
* @param engine - The engine.
|
|
79
|
+
* @param state - The depth fields to change. Omitted fields are untouched.
|
|
80
|
+
*/
|
|
81
|
+
export declare function setDepthState(engine: GLEngineContext, state: GLDepthState): void;
|
|
82
|
+
/**
|
|
83
|
+
* Enable/disable face culling and (optionally) set the cull face — the lite-gl
|
|
84
|
+
* equivalent of `engine.depthCullingState.cull` + `cullFace`.
|
|
85
|
+
*
|
|
86
|
+
* @param engine - The engine.
|
|
87
|
+
* @param enabled - Enable (`true`) or disable (`false`) `gl.CULL_FACE`.
|
|
88
|
+
* @param face - Optional cull face (`gl.BACK` / `gl.FRONT` / `gl.FRONT_AND_BACK`).
|
|
89
|
+
*/
|
|
90
|
+
export declare function setCullState(engine: GLEngineContext, enabled: boolean, face?: GLenum): void;
|
|
91
|
+
/**
|
|
92
|
+
* Buffer stencil state (test enable, write mask, comparison func triple, op
|
|
93
|
+
* triple) into the DESIRED state — the lite-gl equivalent of mutating Babylon's
|
|
94
|
+
* `engine.stencilState.*`. Flushed by `applyGLStates` before the next draw /
|
|
95
|
+
* clear; omitted fields are untouched (merge-from-desired).
|
|
96
|
+
*
|
|
97
|
+
* @param engine - The engine.
|
|
98
|
+
* @param state - The stencil fields to change. Omitted fields are untouched.
|
|
99
|
+
*/
|
|
100
|
+
export declare function setStencilState(engine: GLEngineContext, state: GLStencilState): void;
|
|
101
|
+
/**
|
|
102
|
+
* Buffer the color write mask into the DESIRED state — the lite-gl equivalent of
|
|
103
|
+
* Babylon's `setColorWrite` (which passes the same flag to all four channels).
|
|
104
|
+
* Flushed to GL (`gl.colorMask`) by `applyGLStates` before the next draw /
|
|
105
|
+
* clear.
|
|
106
|
+
*
|
|
107
|
+
* @param engine - The engine.
|
|
108
|
+
* @param r - Write red.
|
|
109
|
+
* @param g - Write green.
|
|
110
|
+
* @param b - Write blue.
|
|
111
|
+
* @param a - Write alpha.
|
|
112
|
+
*/
|
|
113
|
+
export declare function setColorMask(engine: GLEngineContext, r: boolean, g: boolean, b: boolean, a: boolean): void;
|
|
114
|
+
/**
|
|
115
|
+
* Clear the currently-bound framebuffer's color / depth / stencil buffers — the
|
|
116
|
+
* lite-gl equivalent of Babylon's `clear(color, backBuffer, depth, stencil)`.
|
|
117
|
+
* Depth/stencil clears respect the current write masks (set them first via
|
|
118
|
+
* {@link setDepthState} / {@link setStencilState}). No-op when nothing is
|
|
119
|
+
* requested or the context is lost/disposed.
|
|
120
|
+
*
|
|
121
|
+
* @param engine - The engine.
|
|
122
|
+
* @param options - Which buffers to clear (and the color value).
|
|
123
|
+
*/
|
|
124
|
+
export declare function clearEngine(engine: GLEngineContext, options: GLClearOptions): void;
|
|
125
|
+
/**
|
|
126
|
+
* Opt-in: give a `/render-target` {@link GLRenderTarget} a stencil attachment,
|
|
127
|
+
* replacing the core's depth-only `DEPTH_COMPONENT16` renderbuffer with either a
|
|
128
|
+
* packed **`DEPTH24_STENCIL8`** buffer (default — depth *and* stencil) or a
|
|
129
|
+
* stencil-only **`STENCIL_INDEX8`** buffer.
|
|
130
|
+
*
|
|
131
|
+
* Stencil is intentionally NOT a {@link createRenderTarget} option: keeping this
|
|
132
|
+
* helper in the depth-stencil module means the stencil/packed renderbuffer
|
|
133
|
+
* code tree-shakes out of every bundle that only needs a color (and optional
|
|
134
|
+
* depth) target.
|
|
135
|
+
*
|
|
136
|
+
* The attachment is **restore-correct**: it is rebuilt automatically — at the new
|
|
137
|
+
* size on {@link resizeRenderTarget}, and into the fresh framebuffer after a
|
|
138
|
+
* `webglcontextrestored` event — so the stencil survives for the life of the
|
|
139
|
+
* target, and {@link disposeRenderTarget} releases it along with the target.
|
|
140
|
+
*
|
|
141
|
+
* No-op on a lost/disposed context or a disposed target.
|
|
142
|
+
*
|
|
143
|
+
* @param engine - The engine that owns `rt`.
|
|
144
|
+
* @param rt - The render target to attach the stencil buffer to.
|
|
145
|
+
* @param options - `depth` (default `true`): when `true` the attachment is a
|
|
146
|
+
* packed depth+stencil buffer (`DEPTH24_STENCIL8` on `DEPTH_STENCIL_ATTACHMENT`)
|
|
147
|
+
* — the common case, and the correct choice when the target was created with
|
|
148
|
+
* `generateDepthBuffer: true`. When `false` the attachment is stencil-only
|
|
149
|
+
* (`STENCIL_INDEX8` on `STENCIL_ATTACHMENT`).
|
|
150
|
+
* @throws If a renderbuffer handle could not be allocated or the framebuffer is
|
|
151
|
+
* incomplete after attaching.
|
|
152
|
+
*/
|
|
153
|
+
export declare function generateRenderTargetStencil(engine: GLEngineContext, rt: GLRenderTarget, options?: {
|
|
154
|
+
depth?: boolean;
|
|
155
|
+
}): void;
|