@thi.ng/webgl 6.9.89 → 6.9.90
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 +3 -2
- package/buffer.js +2 -2
- package/canvas.js +1 -1
- package/draw.js +2 -2
- package/package.json +18 -18
- package/shader.js +13 -13
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 211 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
|
@@ -126,7 +126,7 @@ Note: @thi.ng/api is in _most_ cases a type-only import (not used at runtime)
|
|
|
126
126
|
|
|
127
127
|
## Usage examples
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
24 projects in this repo's
|
|
130
130
|
[/examples](https://github.com/thi-ng/umbrella/tree/develop/examples)
|
|
131
131
|
directory are using this package:
|
|
132
132
|
|
|
@@ -143,6 +143,7 @@ directory are using this package:
|
|
|
143
143
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-ast-tunnel.jpg" width="240"/> | WebGL & Canvas2D textured tunnel shader | [Demo](https://demo.thi.ng/umbrella/shader-ast-tunnel/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-tunnel) |
|
|
144
144
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-graph.jpg" width="240"/> | Minimal shader graph developed during livestream #2 | [Demo](https://demo.thi.ng/umbrella/shader-graph/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-graph) |
|
|
145
145
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/soa-ecs-100k.png" width="240"/> | Entity Component System w/ 100k 3D particles | [Demo](https://demo.thi.ng/umbrella/soa-ecs/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/soa-ecs) |
|
|
146
|
+
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-cube.png" width="240"/> | 3D arcball controller to rotate the camera view of a colored cube | [Demo](https://demo.thi.ng/umbrella/webgl-arcball/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-arcball) |
|
|
146
147
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-channel-mixer.jpg" width="240"/> | rdom & WebGL-based image channel editor | [Demo](https://demo.thi.ng/umbrella/webgl-channel-mixer/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-channel-mixer) |
|
|
147
148
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-cube.png" width="240"/> | WebGL multi-colored cube mesh | [Demo](https://demo.thi.ng/umbrella/webgl-cube/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-cube) |
|
|
148
149
|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/webgl-cubemap.jpg" width="240"/> | WebGL cube maps with async texture loading | [Demo](https://demo.thi.ng/umbrella/webgl-cubemap/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/webgl-cubemap) |
|
package/buffer.js
CHANGED
|
@@ -115,7 +115,7 @@ const __initBuffer = (gl, src, type, mode) => {
|
|
|
115
115
|
};
|
|
116
116
|
const __compileAttribs = (gl, attribs, mode) => {
|
|
117
117
|
if (attribs) {
|
|
118
|
-
for (
|
|
118
|
+
for (const id in attribs) {
|
|
119
119
|
__initBuffer(gl, attribs[id], gl.ARRAY_BUFFER, mode);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -158,7 +158,7 @@ const compileVAO = (gl, spec) => {
|
|
|
158
158
|
const compileAttribPool = (gl, pool, ids, target = gl.ARRAY_BUFFER, mode = gl.STATIC_DRAW) => {
|
|
159
159
|
const buf = defBuffer(gl, pool.bytes(), target, mode, true);
|
|
160
160
|
const spec = {};
|
|
161
|
-
for (
|
|
161
|
+
for (const id of ids || Object.keys(pool.specs)) {
|
|
162
162
|
const attr = pool.specs[id];
|
|
163
163
|
spec[id] = {
|
|
164
164
|
buffer: buf,
|
package/canvas.js
CHANGED
|
@@ -44,7 +44,7 @@ const glCanvas = (opts = {}) => {
|
|
|
44
44
|
const getExtensions = (gl, ids, required = true) => {
|
|
45
45
|
const ext = {};
|
|
46
46
|
if (ids) {
|
|
47
|
-
for (
|
|
47
|
+
for (const id of ids) {
|
|
48
48
|
ext[id] = gl.getExtension(id);
|
|
49
49
|
required && !ext[id] && error(`extension ${id} not available`);
|
|
50
50
|
}
|
package/draw.js
CHANGED
|
@@ -43,7 +43,7 @@ const __drawInstanced = (gl, spec) => {
|
|
|
43
43
|
const sattribs = spec.shader.attribs;
|
|
44
44
|
const iattribs = spec.instances.attribs;
|
|
45
45
|
spec.shader.bindAttribs(iattribs);
|
|
46
|
-
for (
|
|
46
|
+
for (const id in iattribs) {
|
|
47
47
|
const attr = sattribs[id];
|
|
48
48
|
if (attr) {
|
|
49
49
|
let div = iattribs[id].divisor;
|
|
@@ -82,7 +82,7 @@ const __drawInstanced = (gl, spec) => {
|
|
|
82
82
|
spec.instances.num
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
|
-
for (
|
|
85
|
+
for (const id in iattribs) {
|
|
86
86
|
const attr = sattribs[id];
|
|
87
87
|
attr && (isGL2 ? gl.vertexAttribDivisor(attr.loc, 0) : ext.vertexAttribDivisorANGLE(attr.loc, 0));
|
|
88
88
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/webgl",
|
|
3
|
-
"version": "6.9.
|
|
3
|
+
"version": "6.9.90",
|
|
4
4
|
"description": "WebGL & GLSL abstraction layer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -43,22 +43,22 @@
|
|
|
43
43
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@thi.ng/api": "^8.12.
|
|
47
|
-
"@thi.ng/canvas": "^1.1.
|
|
48
|
-
"@thi.ng/checks": "^3.
|
|
49
|
-
"@thi.ng/equiv": "^2.1.
|
|
50
|
-
"@thi.ng/errors": "^2.5.
|
|
51
|
-
"@thi.ng/logger": "^3.2.
|
|
52
|
-
"@thi.ng/matrices": "^3.0.
|
|
53
|
-
"@thi.ng/memoize": "^4.0.
|
|
54
|
-
"@thi.ng/object-utils": "^1.3.
|
|
55
|
-
"@thi.ng/pixel": "^7.5.
|
|
56
|
-
"@thi.ng/shader-ast": "^1.1.
|
|
57
|
-
"@thi.ng/shader-ast-glsl": "^1.0.
|
|
58
|
-
"@thi.ng/shader-ast-stdlib": "^1.0.
|
|
59
|
-
"@thi.ng/transducers": "^9.6.
|
|
60
|
-
"@thi.ng/vector-pools": "^3.2.
|
|
61
|
-
"@thi.ng/vectors": "^8.6.
|
|
46
|
+
"@thi.ng/api": "^8.12.10",
|
|
47
|
+
"@thi.ng/canvas": "^1.1.3",
|
|
48
|
+
"@thi.ng/checks": "^3.8.0",
|
|
49
|
+
"@thi.ng/equiv": "^2.1.100",
|
|
50
|
+
"@thi.ng/errors": "^2.5.50",
|
|
51
|
+
"@thi.ng/logger": "^3.2.9",
|
|
52
|
+
"@thi.ng/matrices": "^3.0.30",
|
|
53
|
+
"@thi.ng/memoize": "^4.0.34",
|
|
54
|
+
"@thi.ng/object-utils": "^1.3.2",
|
|
55
|
+
"@thi.ng/pixel": "^7.5.19",
|
|
56
|
+
"@thi.ng/shader-ast": "^1.1.32",
|
|
57
|
+
"@thi.ng/shader-ast-glsl": "^1.0.51",
|
|
58
|
+
"@thi.ng/shader-ast-stdlib": "^1.0.51",
|
|
59
|
+
"@thi.ng/transducers": "^9.6.19",
|
|
60
|
+
"@thi.ng/vector-pools": "^3.2.80",
|
|
61
|
+
"@thi.ng/vectors": "^8.6.15"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"esbuild": "^0.27.0",
|
|
@@ -227,5 +227,5 @@
|
|
|
227
227
|
],
|
|
228
228
|
"year": 2014
|
|
229
229
|
},
|
|
230
|
-
"gitHead": "
|
|
230
|
+
"gitHead": "824bf9047b5a10f777c5c5b4aeecf0c750a22c75\n"
|
|
231
231
|
}
|
package/shader.js
CHANGED
|
@@ -71,7 +71,7 @@ class Shader {
|
|
|
71
71
|
}
|
|
72
72
|
unbind() {
|
|
73
73
|
let shaderAttrib;
|
|
74
|
-
for (
|
|
74
|
+
for (const id in this.attribs) {
|
|
75
75
|
if (shaderAttrib = this.attribs[id]) {
|
|
76
76
|
this.gl.disableVertexAttribArray(shaderAttrib.loc);
|
|
77
77
|
}
|
|
@@ -90,7 +90,7 @@ class Shader {
|
|
|
90
90
|
bindAttribs(specAttribs) {
|
|
91
91
|
const gl = this.gl;
|
|
92
92
|
let shaderAttrib;
|
|
93
|
-
for (
|
|
93
|
+
for (const id in specAttribs) {
|
|
94
94
|
if (shaderAttrib = this.attribs[id]) {
|
|
95
95
|
const attr = specAttribs[id];
|
|
96
96
|
attr.buffer.bind();
|
|
@@ -110,7 +110,7 @@ class Shader {
|
|
|
110
110
|
}
|
|
111
111
|
bindUniforms(specUnis = {}) {
|
|
112
112
|
const shaderUnis = this.uniforms;
|
|
113
|
-
for (
|
|
113
|
+
for (const id in specUnis) {
|
|
114
114
|
const u = shaderUnis[id];
|
|
115
115
|
if (u) {
|
|
116
116
|
let val = specUnis[id];
|
|
@@ -120,7 +120,7 @@ class Shader {
|
|
|
120
120
|
this.warnUni(id);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
for (
|
|
123
|
+
for (const id in shaderUnis) {
|
|
124
124
|
if (shaderUnis.hasOwnProperty(id) && (!specUnis || !existsAndNotNull(specUnis[id]))) {
|
|
125
125
|
const u = shaderUnis[id];
|
|
126
126
|
const val = u.defaultFn ? u.defaultFn(shaderUnis, specUnis) : u.defaultVal;
|
|
@@ -188,7 +188,7 @@ const defShader = (gl, spec, opts) => {
|
|
|
188
188
|
};
|
|
189
189
|
const __compileVars = (attribs, syntax, prefixes) => {
|
|
190
190
|
let decls = [];
|
|
191
|
-
for (
|
|
191
|
+
for (const id in attribs) {
|
|
192
192
|
if (attribs.hasOwnProperty(id)) {
|
|
193
193
|
decls.push(syntax(id, attribs[id], prefixes));
|
|
194
194
|
}
|
|
@@ -203,7 +203,7 @@ const __compileExtensionPragma = (id, behavior, version) => {
|
|
|
203
203
|
` : "";
|
|
204
204
|
};
|
|
205
205
|
const __initShaderExtensions = (gl, exts) => {
|
|
206
|
-
for (
|
|
206
|
+
for (const id in exts) {
|
|
207
207
|
const state = exts[id];
|
|
208
208
|
if (state === true || state === "require") {
|
|
209
209
|
getExtensions(gl, [id], state === "require");
|
|
@@ -213,7 +213,7 @@ const __initShaderExtensions = (gl, exts) => {
|
|
|
213
213
|
const __compilePrelude = (spec, version) => {
|
|
214
214
|
let prelude = spec.pre ? spec.replacePrelude ? spec.pre : spec.pre + "\n" + GLSL_HEADER : GLSL_HEADER;
|
|
215
215
|
if (spec.ext) {
|
|
216
|
-
for (
|
|
216
|
+
for (const id in spec.ext) {
|
|
217
217
|
prelude += __compileExtensionPragma(
|
|
218
218
|
id,
|
|
219
219
|
spec.ext[id],
|
|
@@ -224,7 +224,7 @@ const __compilePrelude = (spec, version) => {
|
|
|
224
224
|
return prelude;
|
|
225
225
|
};
|
|
226
226
|
const __compileIODecls = (decl, src, dest) => {
|
|
227
|
-
for (
|
|
227
|
+
for (const id in src) {
|
|
228
228
|
const a = src[id];
|
|
229
229
|
dest[id] = isArray(a) ? decl(a[0], id, { loc: a[1] }) : decl(a, id);
|
|
230
230
|
}
|
|
@@ -235,13 +235,13 @@ const __varyingOpts = (v) => {
|
|
|
235
235
|
return [vtype, opts];
|
|
236
236
|
};
|
|
237
237
|
const __compileVaryingDecls = (spec, decl, acc) => {
|
|
238
|
-
for (
|
|
238
|
+
for (const id in spec.varying) {
|
|
239
239
|
const [vtype, opts] = __varyingOpts(spec.varying[id]);
|
|
240
240
|
acc[id] = decl(vtype, id, opts);
|
|
241
241
|
}
|
|
242
242
|
};
|
|
243
243
|
const __compileUniformDecls = (spec, acc) => {
|
|
244
|
-
for (
|
|
244
|
+
for (const id in spec.uniforms) {
|
|
245
245
|
const u = spec.uniforms[id];
|
|
246
246
|
acc[id] = isArray(u) ? uniform(
|
|
247
247
|
u[0],
|
|
@@ -266,7 +266,7 @@ const shaderSourceFromAST = (spec, type, version, opts = {}) => {
|
|
|
266
266
|
if (version >= GLSLVersion.GLES_300) {
|
|
267
267
|
__compileIODecls(output, outs, outputs);
|
|
268
268
|
} else {
|
|
269
|
-
for (
|
|
269
|
+
for (const id in outs) {
|
|
270
270
|
const o = outs[id];
|
|
271
271
|
if (isArray(o) && o[0] === "vec4") {
|
|
272
272
|
prelude += `#define ${id} gl_FragData[${o[1]}]
|
|
@@ -342,7 +342,7 @@ ${errors}`);
|
|
|
342
342
|
};
|
|
343
343
|
const __initAttributes = (gl, prog, attribs) => {
|
|
344
344
|
const res = {};
|
|
345
|
-
for (
|
|
345
|
+
for (const id in attribs) {
|
|
346
346
|
const val = attribs[id];
|
|
347
347
|
const [type, loc] = isArray(val) ? val : [val, null];
|
|
348
348
|
const aid = id;
|
|
@@ -360,7 +360,7 @@ const __initAttributes = (gl, prog, attribs) => {
|
|
|
360
360
|
};
|
|
361
361
|
const __initUniforms = (gl, prog, uniforms = {}) => {
|
|
362
362
|
const res = {};
|
|
363
|
-
for (
|
|
363
|
+
for (const id in uniforms) {
|
|
364
364
|
const val = uniforms[id];
|
|
365
365
|
let type;
|
|
366
366
|
let t1, t2, defaultVal, defaultFn;
|