@thi.ng/shader-ast-js 0.7.68 → 1.0.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-08-12T13:14:08Z
3
+ - **Last updated**: 2023-08-22T14:39:27Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,30 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ # [1.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/shader-ast-js@1.0.0) (2023-08-14)
13
+
14
+ #### 🛑 Breaking changes
15
+
16
+ - update renderPixels(), renderBuffer() ([5b2fe9d](https://github.com/thi-ng/umbrella/commit/5b2fe9d))
17
+ - BREAKING CHANGES: replace render functions args with options object
18
+ - add RenderPixelOpts
19
+ - update renderPixels()/renderBuffer() to support arbitrary integer pixel formats
20
+ - add/expose color conversion fns:
21
+ - rgbaBgra8888() for 32bit targets
22
+ - rgbaRgb565() for 16bit targets
23
+
24
+ #### 🚀 Features
25
+
26
+ - add vector pools for all vector ops ([31271e7](https://github.com/thi-ng/umbrella/commit/31271e7))
27
+ - add Pool class and impls for [iu]vec2/3/4
28
+ - update all vector ops to re-use memory from pools
29
+ - add CompileResult interface w/ `__reset()` and `__stats()` methods
30
+ - update targetJS() codegens
31
+
32
+ #### ♻️ Refactoring
33
+
34
+ - update/extend vector pool handling ([1c22d0c](https://github.com/thi-ng/umbrella/commit/1c22d0c))
35
+
12
36
  ### [0.7.64](https://github.com/thi-ng/umbrella/tree/@thi.ng/shader-ast-js@0.7.64) (2023-08-04)
13
37
 
14
38
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
9
9
 
10
10
  This project is part of the
11
- [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
11
+ [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo and anti-framework.
12
12
 
13
13
  - [About](#about)
14
14
  - [Unsupported features](#unsupported-features)
@@ -53,6 +53,7 @@ which altogether provide ~750 optimized vector/matrix functions.
53
53
 
54
54
  ## Related packages
55
55
 
56
+ - [@thi.ng/pixel](https://github.com/thi-ng/umbrella/tree/develop/packages/pixel) - Typedarray integer & float pixel buffers w/ customizable formats, blitting, drawing, convolution
56
57
  - [@thi.ng/shader-ast-glsl](https://github.com/thi-ng/umbrella/tree/develop/packages/shader-ast-glsl) - Customizable GLSL codegen for [@thi.ng/shader-ast](https://github.com/thi-ng/umbrella/tree/develop/packages/shader-ast)
57
58
  - [@thi.ng/shader-ast-stdlib](https://github.com/thi-ng/umbrella/tree/develop/packages/shader-ast-stdlib) - Function collection for modular GPGPU / shader programming with [@thi.ng/shader-ast](https://github.com/thi-ng/umbrella/tree/develop/packages/shader-ast)
58
59
 
@@ -76,7 +77,7 @@ For Node.js REPL:
76
77
  const shaderAstJs = await import("@thi.ng/shader-ast-js");
77
78
  ```
78
79
 
79
- Package sizes (brotli'd, pre-treeshake): ESM: 5.46 KB
80
+ Package sizes (brotli'd, pre-treeshake): ESM: 6.44 KB
80
81
 
81
82
  ## Dependencies
82
83
 
@@ -97,14 +98,15 @@ directory are using this package.
97
98
 
98
99
  A selection:
99
100
 
100
- | Screenshot | Description | Live demo | Source |
101
- |:-----------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------|:----------------------------------------------------------|:---------------------------------------------------------------------------------------|
102
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/shader-ast/shader-ast-01.jpg" width="240"/> | 2D canvas shader emulation | [Demo](https://demo.thi.ng/umbrella/shader-ast-canvas2d/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-canvas2d) |
103
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-ast-noise.jpg" width="240"/> | HOF shader procedural noise function composition | [Demo](https://demo.thi.ng/umbrella/shader-ast-noise/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-noise) |
104
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/shader-ast/shader-ast-raymarch.jpg" width="240"/> | WebGL & JS canvas2D raymarch shader cross-compilation | [Demo](https://demo.thi.ng/umbrella/shader-ast-raymarch/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-raymarch) |
105
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-ast-sdf2d.jpg" width="240"/> | WebGL & JS canvas 2D SDF | [Demo](https://demo.thi.ng/umbrella/shader-ast-sdf2d/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-sdf2d) |
106
- | <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) |
107
- | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-ast-workers.jpg" width="240"/> | Fork-join worker-based raymarch renderer (JS/CPU only) | [Demo](https://demo.thi.ng/umbrella/shader-ast-workers/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-workers) |
101
+ | Screenshot | Description | Live demo | Source |
102
+ |:-----------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------|:----------------------------------------------------------|:---------------------------------------------------------------------------------------|
103
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/ascii-raymarch.jpg" width="240"/> | ASCII art raymarching with thi.ng/shader-ast & thi.ng/text-canvas | [Demo](https://demo.thi.ng/umbrella/ascii-raymarch/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/ascii-raymarch) |
104
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/shader-ast/shader-ast-01.jpg" width="240"/> | 2D canvas shader emulation | [Demo](https://demo.thi.ng/umbrella/shader-ast-canvas2d/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-canvas2d) |
105
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-ast-noise.jpg" width="240"/> | HOF shader procedural noise function composition | [Demo](https://demo.thi.ng/umbrella/shader-ast-noise/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-noise) |
106
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/shader-ast/shader-ast-raymarch.jpg" width="240"/> | WebGL & JS canvas2D raymarch shader cross-compilation | [Demo](https://demo.thi.ng/umbrella/shader-ast-raymarch/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-raymarch) |
107
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-ast-sdf2d.jpg" width="240"/> | WebGL & JS canvas 2D SDF | [Demo](https://demo.thi.ng/umbrella/shader-ast-sdf2d/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-sdf2d) |
108
+ | <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) |
109
+ | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/shader-ast-workers.jpg" width="240"/> | Fork-join worker-based raymarch renderer (JS/CPU only) | [Demo](https://demo.thi.ng/umbrella/shader-ast-workers/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/shader-ast-workers) |
108
110
 
109
111
  ## API
110
112
 
package/api.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import type { Fn, Fn2, Fn3, Fn4, Fn5, Fn6 } from "@thi.ng/api";
1
+ import type { Fn, Fn0, Fn2, Fn3, Fn4, Fn5, Fn6, Keys } from "@thi.ng/api";
2
2
  import type { Mat } from "@thi.ng/matrices";
3
3
  import type { Term } from "@thi.ng/shader-ast";
4
4
  import type { BVec, Vec } from "@thi.ng/vectors";
5
+ import type { Pool } from "./pool.js";
5
6
  export interface JSTarget extends Fn<Term<any>, string> {
6
7
  /**
7
8
  * Compiles given AST to JavaScript, using optional `env` as backend for
@@ -31,7 +32,21 @@ export interface JSTarget extends Fn<Term<any>, string> {
31
32
  * @param tree -
32
33
  * @param env -
33
34
  */
34
- compile(tree: Term<any>, env?: JSEnv): any;
35
+ compile(tree: Term<any>, env?: JSEnv): CompileResult;
36
+ }
37
+ export interface CompileResult {
38
+ /**
39
+ * Resets all internal vector pools. Will be called automatically if
40
+ * compiled tree includes a `main()` function, otherwise **MUST** be called
41
+ * manually each time before invoking a compiled entry point function.
42
+ */
43
+ __reset: Fn0<void>;
44
+ /**
45
+ * Returns an object summarizing the number of used objects in each vector
46
+ * pool.
47
+ */
48
+ __stats: Fn0<Record<Keys<JSEnv["pools"]>, number>>;
49
+ [id: string]: any;
35
50
  }
36
51
  export interface JSBuiltinsCommon<T> {
37
52
  abs: Fn<T, T>;
@@ -218,6 +233,17 @@ export interface JSEnv {
218
233
  samplerCube: JSBuiltinsSampler;
219
234
  sampler2DShadow: JSBuiltinsSampler;
220
235
  samplerCubeShadow: JSBuiltinsSampler;
236
+ pools: {
237
+ vec2: Pool;
238
+ vec3: Pool;
239
+ vec4: Pool;
240
+ ivec2: Pool;
241
+ ivec3: Pool;
242
+ ivec4: Pool;
243
+ uvec2: Pool;
244
+ uvec3: Pool;
245
+ uvec4: Pool;
246
+ };
221
247
  }
222
248
  export interface JSTargetOpts {
223
249
  /**
package/env/ivec2.js CHANGED
@@ -10,28 +10,30 @@ import { lshiftI2 } from "@thi.ng/vectors/lshift";
10
10
  import { mulI2, mulNI2 } from "@thi.ng/vectors/muli";
11
11
  import { rshiftI2 } from "@thi.ng/vectors/rshift";
12
12
  import { subI2, subNI2 } from "@thi.ng/vectors/subi";
13
+ import { POOL_IVEC2 } from "../pool.js";
13
14
  import { VEC2 } from "./vec2.js";
15
+ const { next, uniform } = POOL_IVEC2;
14
16
  export const IVEC2 = {
15
- ...VEC2,
16
- add: (a, b) => addI2([], a, b),
17
- addvn: (a, b) => addNI2([], a, b),
18
- addnv: (a, b) => addNI2([], b, a),
19
- div: (a, b) => divI2([], a, b),
20
- divvn: (a, b) => divNI2([], a, b),
21
- divnv: (a, b) => divI2(null, [a, a], b),
22
- modi: (a, b) => fmod2([], a, b),
23
- modivn: (a, b) => fmodN2([], a, b),
24
- modinv: (a, b) => fmod2(null, [a, a], b),
25
- mul: (a, b) => mulI2([], a, b),
26
- mulvn: (a, b) => mulNI2([], a, b),
27
- mulnv: (a, b) => mulNI2([], b, a),
28
- sub: (a, b) => subI2([], a, b),
29
- subvn: (a, b) => subNI2([], a, b),
30
- subnv: (a, b) => subI2(null, [a, a], b),
31
- bitand: (a, b) => bitAndI2([], a, b),
32
- lshift: (a, b) => lshiftI2([], a, b),
33
- bitnot1: (a) => bitNotI2([], a),
34
- bitor: (a, b) => bitOrI2([], a, b),
35
- rshift: (a, b) => rshiftI2([], a, b),
36
- bitxor: (a, b) => bitXorI2([], a, b),
17
+ ...VEC2(POOL_IVEC2),
18
+ add: (a, b) => addI2(next(), a, b),
19
+ addvn: (a, b) => addNI2(next(), a, b),
20
+ addnv: (a, b) => addNI2(next(), b, a),
21
+ div: (a, b) => divI2(next(), a, b),
22
+ divvn: (a, b) => divNI2(next(), a, b),
23
+ divnv: (a, b) => divI2(null, uniform(a), b),
24
+ modi: (a, b) => fmod2(next(), a, b),
25
+ modivn: (a, b) => fmodN2(next(), a, b),
26
+ modinv: (a, b) => fmod2(null, uniform(a), b),
27
+ mul: (a, b) => mulI2(next(), a, b),
28
+ mulvn: (a, b) => mulNI2(next(), a, b),
29
+ mulnv: (a, b) => mulNI2(next(), b, a),
30
+ sub: (a, b) => subI2(next(), a, b),
31
+ subvn: (a, b) => subNI2(next(), a, b),
32
+ subnv: (a, b) => subI2(null, uniform(a), b),
33
+ bitand: (a, b) => bitAndI2(next(), a, b),
34
+ lshift: (a, b) => lshiftI2(next(), a, b),
35
+ bitnot1: (a) => bitNotI2(next(), a),
36
+ bitor: (a, b) => bitOrI2(next(), a, b),
37
+ rshift: (a, b) => rshiftI2(next(), a, b),
38
+ bitxor: (a, b) => bitXorI2(next(), a, b),
37
39
  };
package/env/ivec3.js CHANGED
@@ -10,28 +10,30 @@ import { lshiftI3 } from "@thi.ng/vectors/lshift";
10
10
  import { mulI3, mulNI3 } from "@thi.ng/vectors/muli";
11
11
  import { rshiftI3 } from "@thi.ng/vectors/rshift";
12
12
  import { subI3, subNI3 } from "@thi.ng/vectors/subi";
13
+ import { POOL_IVEC3 } from "../pool.js";
13
14
  import { VEC3 } from "./vec3.js";
15
+ const { next, uniform } = POOL_IVEC3;
14
16
  export const IVEC3 = {
15
- ...VEC3,
16
- add: (a, b) => addI3([], a, b),
17
- addvn: (a, b) => addNI3([], a, b),
18
- addnv: (a, b) => addNI3([], b, a),
19
- div: (a, b) => divI3([], a, b),
20
- divvn: (a, b) => divNI3([], a, b),
21
- divnv: (a, b) => divI3(null, [a, a, a], b),
22
- modi: (a, b) => fmod3([], a, b),
23
- modivn: (a, b) => fmodN3([], a, b),
24
- modinv: (a, b) => fmod3(null, [a, a, a], b),
25
- mul: (a, b) => mulI3([], a, b),
26
- mulvn: (a, b) => mulNI3([], a, b),
27
- mulnv: (a, b) => mulNI3([], b, a),
28
- sub: (a, b) => subI3([], a, b),
29
- subvn: (a, b) => subNI3([], a, b),
30
- subnv: (a, b) => subI3(null, [a, a, a], b),
31
- bitand: (a, b) => bitAndI3([], a, b),
32
- lshift: (a, b) => lshiftI3([], a, b),
33
- bitnot1: (a) => bitNotI3([], a),
34
- bitor: (a, b) => bitOrI3([], a, b),
35
- rshift: (a, b) => rshiftI3([], a, b),
36
- bitxor: (a, b) => bitXorI3([], a, b),
17
+ ...VEC3(POOL_IVEC3),
18
+ add: (a, b) => addI3(next(), a, b),
19
+ addvn: (a, b) => addNI3(next(), a, b),
20
+ addnv: (a, b) => addNI3(next(), b, a),
21
+ div: (a, b) => divI3(next(), a, b),
22
+ divvn: (a, b) => divNI3(next(), a, b),
23
+ divnv: (a, b) => divI3(null, uniform(a), b),
24
+ modi: (a, b) => fmod3(next(), a, b),
25
+ modivn: (a, b) => fmodN3(next(), a, b),
26
+ modinv: (a, b) => fmod3(null, uniform(a), b),
27
+ mul: (a, b) => mulI3(next(), a, b),
28
+ mulvn: (a, b) => mulNI3(next(), a, b),
29
+ mulnv: (a, b) => mulNI3(next(), b, a),
30
+ sub: (a, b) => subI3(next(), a, b),
31
+ subvn: (a, b) => subNI3(next(), a, b),
32
+ subnv: (a, b) => subI3(null, uniform(a), b),
33
+ bitand: (a, b) => bitAndI3(next(), a, b),
34
+ lshift: (a, b) => lshiftI3(next(), a, b),
35
+ bitnot1: (a) => bitNotI3(next(), a),
36
+ bitor: (a, b) => bitOrI3(next(), a, b),
37
+ rshift: (a, b) => rshiftI3(next(), a, b),
38
+ bitxor: (a, b) => bitXorI3(next(), a, b),
37
39
  };
package/env/ivec4.js CHANGED
@@ -10,28 +10,30 @@ import { lshiftI4 } from "@thi.ng/vectors/lshift";
10
10
  import { mulI4, mulNI4 } from "@thi.ng/vectors/muli";
11
11
  import { rshiftI4 } from "@thi.ng/vectors/rshift";
12
12
  import { subI4, subNI4 } from "@thi.ng/vectors/subi";
13
+ import { POOL_IVEC4 } from "../pool.js";
13
14
  import { VEC4 } from "./vec4.js";
15
+ const { next, uniform } = POOL_IVEC4;
14
16
  export const IVEC4 = {
15
- ...VEC4,
16
- add: (a, b) => addI4([], a, b),
17
- addvn: (a, b) => addNI4([], a, b),
18
- addnv: (a, b) => addNI4([], b, a),
19
- div: (a, b) => divI4([], a, b),
20
- divvn: (a, b) => divNI4([], a, b),
21
- divnv: (a, b) => divI4(null, [a, a, a, a], b),
22
- modi: (a, b) => fmod4([], a, b),
23
- modivn: (a, b) => fmodN4([], a, b),
24
- modinv: (a, b) => fmod4(null, [a, a, a, a], b),
25
- mul: (a, b) => mulI4([], a, b),
26
- mulvn: (a, b) => mulNI4([], a, b),
27
- mulnv: (a, b) => mulNI4([], b, a),
28
- sub: (a, b) => subI4([], a, b),
29
- subvn: (a, b) => subNI4([], a, b),
30
- subnv: (a, b) => subI4(null, [a, a, a, a], b),
31
- bitand: (a, b) => bitAndI4([], a, b),
32
- lshift: (a, b) => lshiftI4([], a, b),
33
- bitnot1: (a) => bitNotI4([], a),
34
- bitor: (a, b) => bitOrI4([], a, b),
35
- rshift: (a, b) => rshiftI4([], a, b),
36
- bitxor: (a, b) => bitXorI4([], a, b),
17
+ ...VEC4(POOL_IVEC4),
18
+ add: (a, b) => addI4(next(), a, b),
19
+ addvn: (a, b) => addNI4(next(), a, b),
20
+ addnv: (a, b) => addNI4(next(), b, a),
21
+ div: (a, b) => divI4(next(), a, b),
22
+ divvn: (a, b) => divNI4(next(), a, b),
23
+ divnv: (a, b) => divI4(null, uniform(a), b),
24
+ modi: (a, b) => fmod4(next(), a, b),
25
+ modivn: (a, b) => fmodN4(next(), a, b),
26
+ modinv: (a, b) => fmod4(null, uniform(a), b),
27
+ mul: (a, b) => mulI4(next(), a, b),
28
+ mulvn: (a, b) => mulNI4(next(), a, b),
29
+ mulnv: (a, b) => mulNI4(next(), b, a),
30
+ sub: (a, b) => subI4(next(), a, b),
31
+ subvn: (a, b) => subNI4(next(), a, b),
32
+ subnv: (a, b) => subI4(null, uniform(a), b),
33
+ bitand: (a, b) => bitAndI4(next(), a, b),
34
+ lshift: (a, b) => lshiftI4(next(), a, b),
35
+ bitnot1: (a) => bitNotI4(next(), a),
36
+ bitor: (a, b) => bitOrI4(next(), a, b),
37
+ rshift: (a, b) => rshiftI4(next(), a, b),
38
+ bitxor: (a, b) => bitXorI4(next(), a, b),
37
39
  };
package/env/mat2.js CHANGED
@@ -10,24 +10,26 @@ import { mulVM22 } from "@thi.ng/matrices/mulvm";
10
10
  import { sub22 } from "@thi.ng/matrices/sub";
11
11
  import { subN22 } from "@thi.ng/matrices/subn";
12
12
  import { neg } from "@thi.ng/vectors/neg";
13
+ import { POOL_VEC4 } from "../pool.js";
14
+ const { next, uniform } = POOL_VEC4;
13
15
  export const MAT2 = {
14
- add: (a, b) => add22([], a, b),
15
- addnv: (a, b) => addN22([], b, a),
16
- addvn: (a, b) => addN22([], a, b),
17
- dec: (a) => subN22([], a, 1),
18
- div: (a, b) => div22([], a, b),
19
- divnv: (a, b) => div22(null, [a, a, a, a], b),
20
- divvn: (a, b) => divN22([], a, b),
16
+ add: (a, b) => add22(next(), a, b),
17
+ addnv: (a, b) => addN22(next(), b, a),
18
+ addvn: (a, b) => addN22(next(), a, b),
19
+ dec: (a) => subN22(next(), a, 1),
20
+ div: (a, b) => div22(next(), a, b),
21
+ divnv: (a, b) => div22(null, uniform(a), b),
22
+ divvn: (a, b) => divN22(next(), a, b),
21
23
  idx: (a, b) => [a[b * 2], a[b * 2 + 1]],
22
- inc: (a) => addN22([], a, 1),
23
- mul: (a, b) => mul22([], a, b),
24
- mulm: (a, b) => mulM22([], a, b),
25
- mulmv: (a, b) => mulV22([], a, b),
26
- mulnv: (a, b) => mulN22([], b, a),
27
- mulvm: (a, b) => mulVM22([], a, b),
28
- mulvn: (a, b) => mulN22([], a, b),
29
- sub: (a, b) => sub22([], a, b),
30
- sub1: (a) => neg([], a),
31
- subnv: (a, b) => sub22(null, [a, a, a, a], b),
32
- subvn: (a, b) => subN22([], a, b),
24
+ inc: (a) => addN22(next(), a, 1),
25
+ mul: (a, b) => mul22(next(), a, b),
26
+ mulm: (a, b) => mulM22(next(), a, b),
27
+ mulmv: (a, b) => mulV22(next(), a, b),
28
+ mulnv: (a, b) => mulN22(next(), b, a),
29
+ mulvm: (a, b) => mulVM22(next(), a, b),
30
+ mulvn: (a, b) => mulN22(next(), a, b),
31
+ sub: (a, b) => sub22(next(), a, b),
32
+ sub1: (a) => neg(next(), a),
33
+ subnv: (a, b) => sub22(null, uniform(a), b),
34
+ subvn: (a, b) => subN22(next(), a, b),
33
35
  };
package/env/uvec2.js CHANGED
@@ -10,28 +10,30 @@ import { lshiftU2 } from "@thi.ng/vectors/lshift";
10
10
  import { mulNU2, mulU2 } from "@thi.ng/vectors/muli";
11
11
  import { rshiftU2 } from "@thi.ng/vectors/rshift";
12
12
  import { subNU2, subU2 } from "@thi.ng/vectors/subi";
13
+ import { POOL_UVEC2 } from "../pool.js";
13
14
  import { VEC2 } from "./vec2.js";
15
+ const { next, uniform } = POOL_UVEC2;
14
16
  export const UVEC2 = {
15
- ...VEC2,
16
- add: (a, b) => addU2([], a, b),
17
- addvn: (a, b) => addNU2([], a, b),
18
- addnv: (a, b) => addNU2([], b, a),
19
- div: (a, b) => divU2([], a, b),
20
- divvn: (a, b) => divNU2([], a, b),
21
- divnv: (a, b) => divU2(null, [a, a], b),
22
- modi: (a, b) => fmod2([], a, b),
23
- modivn: (a, b) => fmodN2([], a, b),
24
- modinv: (a, b) => fmod2(null, [a, a], b),
25
- mul: (a, b) => mulU2([], a, b),
26
- mulvn: (a, b) => mulNU2([], a, b),
27
- mulnv: (a, b) => mulNU2([], b, a),
28
- sub: (a, b) => subU2([], a, b),
29
- subvn: (a, b) => subNU2([], a, b),
30
- subnv: (a, b) => subU2(null, [a, a], b),
31
- bitand: (a, b) => bitAndU2([], a, b),
32
- lshift: (a, b) => lshiftU2([], a, b),
33
- bitnot1: (a) => bitNotU2([], a),
34
- bitor: (a, b) => bitOrU2([], a, b),
35
- rshift: (a, b) => rshiftU2([], a, b),
36
- bitxor: (a, b) => bitXorU2([], a, b),
17
+ ...VEC2(POOL_UVEC2),
18
+ add: (a, b) => addU2(next(), a, b),
19
+ addvn: (a, b) => addNU2(next(), a, b),
20
+ addnv: (a, b) => addNU2(next(), b, a),
21
+ div: (a, b) => divU2(next(), a, b),
22
+ divvn: (a, b) => divNU2(next(), a, b),
23
+ divnv: (a, b) => divU2(null, uniform(a), b),
24
+ modi: (a, b) => fmod2(next(), a, b),
25
+ modivn: (a, b) => fmodN2(next(), a, b),
26
+ modinv: (a, b) => fmod2(null, uniform(a), b),
27
+ mul: (a, b) => mulU2(next(), a, b),
28
+ mulvn: (a, b) => mulNU2(next(), a, b),
29
+ mulnv: (a, b) => mulNU2(next(), b, a),
30
+ sub: (a, b) => subU2(next(), a, b),
31
+ subvn: (a, b) => subNU2(next(), a, b),
32
+ subnv: (a, b) => subU2(null, uniform(a), b),
33
+ bitand: (a, b) => bitAndU2(next(), a, b),
34
+ lshift: (a, b) => lshiftU2(next(), a, b),
35
+ bitnot1: (a) => bitNotU2(next(), a),
36
+ bitor: (a, b) => bitOrU2(next(), a, b),
37
+ rshift: (a, b) => rshiftU2(next(), a, b),
38
+ bitxor: (a, b) => bitXorU2(next(), a, b),
37
39
  };
package/env/uvec3.js CHANGED
@@ -10,28 +10,30 @@ import { lshiftU3 } from "@thi.ng/vectors/lshift";
10
10
  import { mulNU3, mulU3 } from "@thi.ng/vectors/muli";
11
11
  import { rshiftU3 } from "@thi.ng/vectors/rshift";
12
12
  import { subNU3, subU3 } from "@thi.ng/vectors/subi";
13
+ import { POOL_UVEC3 } from "../pool.js";
13
14
  import { VEC3 } from "./vec3.js";
15
+ const { next, uniform } = POOL_UVEC3;
14
16
  export const UVEC3 = {
15
- ...VEC3,
16
- add: (a, b) => addU3([], a, b),
17
- addvn: (a, b) => addNU3([], a, b),
18
- addnv: (a, b) => addNU3([], b, a),
19
- div: (a, b) => divU3([], a, b),
20
- divvn: (a, b) => divNU3([], a, b),
21
- divnv: (a, b) => divU3(null, [a, a, a], b),
22
- modi: (a, b) => fmod3([], a, b),
23
- modivn: (a, b) => fmodN3([], a, b),
24
- modinv: (a, b) => fmod3(null, [a, a, a], b),
25
- mul: (a, b) => mulU3([], a, b),
26
- mulvn: (a, b) => mulNU3([], a, b),
27
- mulnv: (a, b) => mulNU3([], b, a),
28
- sub: (a, b) => subU3([], a, b),
29
- subvn: (a, b) => subNU3([], a, b),
30
- subnv: (a, b) => subU3(null, [a, a, a], b),
31
- bitand: (a, b) => bitAndU3([], a, b),
32
- lshift: (a, b) => lshiftU3([], a, b),
33
- bitnot1: (a) => bitNotU3([], a),
34
- bitor: (a, b) => bitOrU3([], a, b),
35
- rshift: (a, b) => rshiftU3([], a, b),
36
- bitxor: (a, b) => bitXorU3([], a, b),
17
+ ...VEC3(POOL_UVEC3),
18
+ add: (a, b) => addU3(next(), a, b),
19
+ addvn: (a, b) => addNU3(next(), a, b),
20
+ addnv: (a, b) => addNU3(next(), b, a),
21
+ div: (a, b) => divU3(next(), a, b),
22
+ divvn: (a, b) => divNU3(next(), a, b),
23
+ divnv: (a, b) => divU3(null, uniform(a), b),
24
+ modi: (a, b) => fmod3(next(), a, b),
25
+ modivn: (a, b) => fmodN3(next(), a, b),
26
+ modinv: (a, b) => fmod3(null, uniform(a), b),
27
+ mul: (a, b) => mulU3(next(), a, b),
28
+ mulvn: (a, b) => mulNU3(next(), a, b),
29
+ mulnv: (a, b) => mulNU3(next(), b, a),
30
+ sub: (a, b) => subU3(next(), a, b),
31
+ subvn: (a, b) => subNU3(next(), a, b),
32
+ subnv: (a, b) => subU3(null, uniform(a), b),
33
+ bitand: (a, b) => bitAndU3(next(), a, b),
34
+ lshift: (a, b) => lshiftU3(next(), a, b),
35
+ bitnot1: (a) => bitNotU3(next(), a),
36
+ bitor: (a, b) => bitOrU3(next(), a, b),
37
+ rshift: (a, b) => rshiftU3(next(), a, b),
38
+ bitxor: (a, b) => bitXorU3(next(), a, b),
37
39
  };
package/env/uvec4.js CHANGED
@@ -10,28 +10,30 @@ import { lshiftU4 } from "@thi.ng/vectors/lshift";
10
10
  import { mulNU4, mulU4 } from "@thi.ng/vectors/muli";
11
11
  import { rshiftU4 } from "@thi.ng/vectors/rshift";
12
12
  import { subNU4, subU4 } from "@thi.ng/vectors/subi";
13
+ import { POOL_UVEC4 } from "../pool.js";
13
14
  import { VEC4 } from "./vec4.js";
15
+ const { next, uniform } = POOL_UVEC4;
14
16
  export const UVEC4 = {
15
- ...VEC4,
16
- add: (a, b) => addU4([], a, b),
17
- addvn: (a, b) => addNU4([], a, b),
18
- addnv: (a, b) => addNU4([], b, a),
19
- div: (a, b) => divU4([], a, b),
20
- divvn: (a, b) => divNU4([], a, b),
21
- divnv: (a, b) => divU4(null, [a, a, a, a], b),
22
- modi: (a, b) => fmod4([], a, b),
23
- modivn: (a, b) => fmodN4([], a, b),
24
- modinv: (a, b) => fmod4(null, [a, a, a, a], b),
25
- mul: (a, b) => mulU4([], a, b),
26
- mulvn: (a, b) => mulNU4([], a, b),
27
- mulnv: (a, b) => mulNU4([], b, a),
28
- sub: (a, b) => subU4([], a, b),
29
- subvn: (a, b) => subNU4([], a, b),
30
- subnv: (a, b) => subU4(null, [a, a, a, a], b),
31
- bitand: (a, b) => bitAndU4([], a, b),
32
- lshift: (a, b) => lshiftU4([], a, b),
33
- bitnot1: (a) => bitNotU4([], a),
34
- bitor: (a, b) => bitOrU4([], a, b),
35
- rshift: (a, b) => rshiftU4([], a, b),
36
- bitxor: (a, b) => bitXorU4([], a, b),
17
+ ...VEC4(POOL_UVEC4),
18
+ add: (a, b) => addU4(next(), a, b),
19
+ addvn: (a, b) => addNU4(next(), a, b),
20
+ addnv: (a, b) => addNU4(next(), b, a),
21
+ div: (a, b) => divU4(next(), a, b),
22
+ divvn: (a, b) => divNU4(next(), a, b),
23
+ divnv: (a, b) => divU4(null, uniform(a), b),
24
+ modi: (a, b) => fmod4(next(), a, b),
25
+ modivn: (a, b) => fmodN4(next(), a, b),
26
+ modinv: (a, b) => fmod4(null, uniform(a), b),
27
+ mul: (a, b) => mulU4(next(), a, b),
28
+ mulvn: (a, b) => mulNU4(next(), a, b),
29
+ mulnv: (a, b) => mulNU4(next(), b, a),
30
+ sub: (a, b) => subU4(next(), a, b),
31
+ subvn: (a, b) => subNU4(next(), a, b),
32
+ subnv: (a, b) => subU4(null, uniform(a), b),
33
+ bitand: (a, b) => bitAndU4(next(), a, b),
34
+ lshift: (a, b) => lshiftU4(next(), a, b),
35
+ bitnot1: (a) => bitNotU4(next(), a),
36
+ bitor: (a, b) => bitOrU4(next(), a, b),
37
+ rshift: (a, b) => rshiftU4(next(), a, b),
38
+ bitxor: (a, b) => bitXorU4(next(), a, b),
37
39
  };
package/env/vec2.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { JSBuiltinsVec } from "../api.js";
2
- export declare const VEC2: JSBuiltinsVec;
2
+ import { Pool } from "../pool.js";
3
+ export declare const VEC2: ({ next, uniform }: Pool) => JSBuiltinsVec;
3
4
  //# sourceMappingURL=vec2.d.ts.map