typegpu 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/LICENSE.md +1 -1
  2. package/chunk-2CMWQRQC.cjs +2 -0
  3. package/chunk-2CMWQRQC.cjs.map +1 -0
  4. package/chunk-2ZAQFPSX.js +1266 -0
  5. package/chunk-2ZAQFPSX.js.map +1 -0
  6. package/chunk-35UVS2JJ.cjs +591 -0
  7. package/chunk-35UVS2JJ.cjs.map +1 -0
  8. package/chunk-A2QB4MSZ.js +4 -0
  9. package/{chunk-47YH5LQ7.cjs.map → chunk-A2QB4MSZ.js.map} +1 -1
  10. package/chunk-CMYXKKUP.cjs +1266 -0
  11. package/chunk-CMYXKKUP.cjs.map +1 -0
  12. package/chunk-DDEF2Y4S.js +591 -0
  13. package/chunk-DDEF2Y4S.js.map +1 -0
  14. package/chunk-KYBPSQX5.js +2 -0
  15. package/chunk-KYBPSQX5.js.map +1 -0
  16. package/chunk-VRYGOFCW.cjs +4 -0
  17. package/chunk-VRYGOFCW.cjs.map +1 -0
  18. package/data/index.cjs +192 -1
  19. package/data/index.d.cts +2 -2
  20. package/data/index.d.ts +2 -2
  21. package/data/index.js +192 -1
  22. package/{index-CopjPGJg.d.cts → index-CuzbyKXg.d.cts} +5 -3
  23. package/{index-BM7ZTN7E.d.ts → index-FHKuURMs.d.ts} +5 -3
  24. package/index.cjs +4269 -14
  25. package/index.cjs.map +1 -1
  26. package/index.d.cts +80 -11
  27. package/index.d.ts +80 -11
  28. package/index.js +4269 -14
  29. package/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/std/index.cjs +490 -1
  32. package/std/index.cjs.map +1 -1
  33. package/std/index.d.cts +1 -1
  34. package/std/index.d.ts +1 -1
  35. package/std/index.js +490 -1
  36. package/std/index.js.map +1 -1
  37. package/{vector-BSez01sn.d.cts → vector-CDD2FV2v.d.cts} +19 -3
  38. package/{vector-BSez01sn.d.ts → vector-CDD2FV2v.d.ts} +19 -3
  39. package/chunk-47YH5LQ7.cjs +0 -4
  40. package/chunk-BGPVBIFN.js +0 -4
  41. package/chunk-BGPVBIFN.js.map +0 -1
  42. package/chunk-MCUGRE3S.js +0 -2
  43. package/chunk-MCUGRE3S.js.map +0 -1
  44. package/chunk-OHFPIYFY.cjs +0 -2
  45. package/chunk-OHFPIYFY.cjs.map +0 -1
package/std/index.js CHANGED
@@ -1,2 +1,491 @@
1
- import{l as x,m as y,n as i,o as h,p as u,q as l,r as w,s as v,t as r,u as a,v as g,w as f,x as M}from"../chunk-BGPVBIFN.js";var o=e=>Math.sqrt(e.x**2+e.y**2),z=e=>Math.sqrt(e.x**2+e.y**2+e.z**2),m=e=>Math.sqrt(e.x**2+e.y**2+e.z**2+e.w**2),T=(e,s)=>e.x*s.x+e.y*s.y,d=(e,s)=>e.x*s.x+e.y*s.y+e.z*s.z,p=(e,s)=>e.x*s.x+e.y*s.y+e.z*s.z+e.w*s.w,n=(e,s,t)=>Math.min(Math.max(s,e),t),c={abs:{vec2f:e=>y(Math.abs(e.x),Math.abs(e.y)),vec2h:e=>i(Math.abs(e.x),Math.abs(e.y)),vec2i:e=>h(Math.abs(e.x),Math.abs(e.y)),vec2u:e=>u(Math.abs(e.x),Math.abs(e.y)),vec3f:e=>l(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z)),vec3h:e=>w(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z)),vec3i:e=>v(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z)),vec3u:e=>r(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z)),vec4f:e=>a(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z),Math.abs(e.w)),vec4h:e=>g(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z),Math.abs(e.w)),vec4i:e=>f(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z),Math.abs(e.w)),vec4u:e=>M(Math.abs(e.x),Math.abs(e.y),Math.abs(e.z),Math.abs(e.w))},ceil:{vec2f:e=>y(Math.ceil(e.x),Math.ceil(e.y)),vec2h:e=>i(Math.ceil(e.x),Math.ceil(e.y)),vec2i:e=>h(Math.ceil(e.x),Math.ceil(e.y)),vec2u:e=>u(Math.ceil(e.x),Math.ceil(e.y)),vec3f:e=>l(Math.ceil(e.x),Math.ceil(e.y),Math.ceil(e.z)),vec3h:e=>w(Math.ceil(e.x),Math.ceil(e.y),Math.ceil(e.z)),vec3i:e=>v(Math.ceil(e.x),Math.ceil(e.y),Math.ceil(e.z)),vec3u:e=>r(Math.ceil(e.x),Math.ceil(e.y),Math.ceil(e.z)),vec4f:e=>a(Math.ceil(e.x),Math.ceil(e.y),Math.ceil(e.z),Math.ceil(e.w)),vec4h:e=>g(Math.ceil(e.x),Math.ceil(e.y),Math.ceil(e.z),Math.ceil(e.w)),vec4i:e=>f(Math.ceil(e.x),Math.ceil(e.y),Math.ceil(e.z),Math.ceil(e.w)),vec4u:e=>M(Math.ceil(e.x),Math.ceil(e.y),Math.ceil(e.z),Math.ceil(e.w))},clamp:{vec2f:(e,s,t)=>y(n(e.x,s.x,t.x),n(e.y,s.y,t.y)),vec2h:(e,s,t)=>i(n(e.x,s.x,t.x),n(e.y,s.y,t.y)),vec2i:(e,s,t)=>h(n(e.x,s.x,t.x),n(e.y,s.y,t.y)),vec2u:(e,s,t)=>u(n(e.x,s.x,t.x),n(e.y,s.y,t.y)),vec3f:(e,s,t)=>l(n(e.x,s.x,t.x),n(e.y,s.y,t.y),n(e.z,s.z,t.z)),vec3h:(e,s,t)=>w(n(e.x,s.x,t.x),n(e.y,s.y,t.y),n(e.z,s.z,t.z)),vec3i:(e,s,t)=>v(n(e.x,s.x,t.x),n(e.y,s.y,t.y),n(e.z,s.z,t.z)),vec3u:(e,s,t)=>r(n(e.x,s.x,t.x),n(e.y,s.y,t.y),n(e.z,s.z,t.z)),vec4f:(e,s,t)=>a(n(e.x,s.x,t.x),n(e.y,s.y,t.y),n(e.z,s.z,t.z),n(e.w,s.w,t.w)),vec4h:(e,s,t)=>g(n(e.x,s.x,t.x),n(e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)},dot:{vec2f:T,vec2h:T,vec2i:T,vec2u:T,vec3f:d,vec3h:d,vec3i:d,vec3u:d,vec4f:p,vec4h:p,vec4i:p,vec4u:p},normalize:{vec2f:e=>{let s=o(e);return y(e.x/s,e.y/s)},vec2h:e=>{let s=o(e);return i(e.x/s,e.y/s)},vec2i:e=>{let s=o(e);return h(e.x/s,e.y/s)},vec2u:e=>{let s=o(e);return u(e.x/s,e.y/s)},vec3f:e=>{let s=z(e);return l(e.x/s,e.y/s,e.z/s)},vec3h:e=>{let s=z(e);return w(e.x/s,e.y/s,e.z/s)},vec3i:e=>{let s=z(e);return v(e.x/s,e.y/s,e.z/s)},vec3u:e=>{let s=z(e);return r(e.x/s,e.y/s,e.z/s)},vec4f:e=>{let s=m(e);return a(e.x/s,e.y/s,e.z/s,e.w/s)},vec4h:e=>{let s=m(e);return g(e.x/s,e.y/s,e.z/s,e.w/s)},vec4i:e=>{let s=m(e);return f(e.x/s,e.y/s,e.z/s,e.w/s)},vec4u:e=>{let s=m(e);return M(e.x/s,e.y/s,e.z/s,e.w/s)}},cross:{vec3f:(e,s)=>l(e.y*s.z-e.z*s.y,e.z*s.x-e.x*s.z,e.x*s.y-e.y*s.x),vec3h:(e,s)=>w(e.y*s.z-e.z*s.y,e.z*s.x-e.x*s.z,e.x*s.y-e.y*s.x),vec3i:(e,s)=>v(e.y*s.z-e.z*s.y,e.z*s.x-e.x*s.z,e.x*s.y-e.y*s.x),vec3u:(e,s)=>r(e.y*s.z-e.z*s.y,e.z*s.x-e.x*s.z,e.x*s.y-e.y*s.x)},floor:{vec2f:e=>y(Math.floor(e.x),Math.floor(e.y)),vec2h:e=>i(Math.floor(e.x),Math.floor(e.y)),vec2i:e=>h(Math.floor(e.x),Math.floor(e.y)),vec2u:e=>u(Math.floor(e.x),Math.floor(e.y)),vec3f:e=>l(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z)),vec3h:e=>w(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z)),vec3i:e=>v(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z)),vec3u:e=>r(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z)),vec4f:e=>a(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z),Math.floor(e.w)),vec4h:e=>g(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z),Math.floor(e.w)),vec4i:e=>f(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z),Math.floor(e.w)),vec4u:e=>M(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z),Math.floor(e.w))},max:{vec2f:(e,s)=>y(Math.max(e.x,s.x),Math.max(e.y,s.y)),vec2h:(e,s)=>i(Math.max(e.x,s.x),Math.max(e.y,s.y)),vec2i:(e,s)=>h(Math.max(e.x,s.x),Math.max(e.y,s.y)),vec2u:(e,s)=>u(Math.max(e.x,s.x),Math.max(e.y,s.y)),vec3f:(e,s)=>l(Math.max(e.x,s.x),Math.max(e.y,s.y),Math.max(e.z,s.z)),vec3h:(e,s)=>w(Math.max(e.x,s.x),Math.max(e.y,s.y),Math.max(e.z,s.z)),vec3i:(e,s)=>v(Math.max(e.x,s.x),Math.max(e.y,s.y),Math.max(e.z,s.z)),vec3u:(e,s)=>r(Math.max(e.x,s.x),Math.max(e.y,s.y),Math.max(e.z,s.z)),vec4f:(e,s)=>a(Math.max(e.x,s.x),Math.max(e.y,s.y),Math.max(e.z,s.z),Math.max(e.w,s.w)),vec4h:(e,s)=>g(Math.max(e.x,s.x),Math.max(e.y,s.y),Math.max(e.z,s.z),Math.max(e.w,s.w)),vec4i:(e,s)=>f(Math.max(e.x,s.x),Math.max(e.y,s.y),Math.max(e.z,s.z),Math.max(e.w,s.w)),vec4u:(e,s)=>M(Math.max(e.x,s.x),Math.max(e.y,s.y),Math.max(e.z,s.z),Math.max(e.w,s.w))},min:{vec2f:(e,s)=>y(Math.min(e.x,s.x),Math.min(e.y,s.y)),vec2h:(e,s)=>i(Math.min(e.x,s.x),Math.min(e.y,s.y)),vec2i:(e,s)=>h(Math.min(e.x,s.x),Math.min(e.y,s.y)),vec2u:(e,s)=>u(Math.min(e.x,s.x),Math.min(e.y,s.y)),vec3f:(e,s)=>l(Math.min(e.x,s.x),Math.min(e.y,s.y),Math.min(e.z,s.z)),vec3h:(e,s)=>w(Math.min(e.x,s.x),Math.min(e.y,s.y),Math.min(e.z,s.z)),vec3i:(e,s)=>v(Math.min(e.x,s.x),Math.min(e.y,s.y),Math.min(e.z,s.z)),vec3u:(e,s)=>r(Math.min(e.x,s.x),Math.min(e.y,s.y),Math.min(e.z,s.z)),vec4f:(e,s)=>a(Math.min(e.x,s.x),Math.min(e.y,s.y),Math.min(e.z,s.z),Math.min(e.w,s.w)),vec4h:(e,s)=>g(Math.min(e.x,s.x),Math.min(e.y,s.y),Math.min(e.z,s.z),Math.min(e.w,s.w)),vec4i:(e,s)=>f(Math.min(e.x,s.x),Math.min(e.y,s.y),Math.min(e.z,s.z),Math.min(e.w,s.w)),vec4u:(e,s)=>M(Math.min(e.x,s.x),Math.min(e.y,s.y),Math.min(e.z,s.z),Math.min(e.w,s.w))}};function k(e,s){return x()?`(${e} + ${s})`:c.add[e.kind](e,s)}function B(e,s){return x()?`(${e} - ${s})`:c.sub[e.kind](e,s)}function V(e,s){return x()?`(${e} * ${s})`:typeof e=="number"?c.mulSxV[s.kind](e,s):c.mulVxV[s.kind](e,s)}function $(e){return x()?`abs(${e})`:typeof e=="number"?Math.abs(e):c.abs[e.kind](e)}function K(e){return x()?`ceil(${e})`:typeof e=="number"?Math.ceil(e):c.ceil[e.kind](e)}function R(e,s,t){return x()?`clamp(${e}, ${s}, ${t})`:typeof e=="number"?Math.min(Math.max(s,e),t):c.clamp[e.kind](e,s,t)}function q(e){return x()?`cos(${e})`:Math.cos(e)}function O(e,s){return x()?`cross(${e}, ${s})`:c.cross[e.kind](e,s)}function S(e,s){return x()?`dot(${e}, ${s})`:c.dot[e.kind](e,s)}function G(e){return x()?`normalize(${e})`:c.normalize[e.kind](e)}function P(e){return x()?`floor(${e})`:typeof e=="number"?Math.floor(e):c.floor[e.kind](e)}function U(e){return x()?`fract(${e})`:e-Math.floor(e)}function j(e){return x()?`length(${e})`:typeof e=="number"?Math.abs(e):c.length[e.kind](e)}function A(e,s){return x()?`max(${e}, ${s})`:typeof e=="number"?Math.max(e,s):c.max[e.kind](e,s)}function C(e,s){return x()?`min(${e}, ${s})`:typeof e=="number"?Math.min(e,s):c.min[e.kind](e,s)}function D(e){return x()?`sin(${e})`:Math.sin(e)}export{$ as abs,k as add,K as ceil,R as clamp,q as cos,O as cross,S as dot,P as floor,U as fract,j as length,A as max,C as min,V as mul,G as normalize,D as sin,B as sub};
1
+ import {
2
+ inGPUMode,
3
+ vec2f,
4
+ vec2h,
5
+ vec2i,
6
+ vec2u,
7
+ vec3f,
8
+ vec3h,
9
+ vec3i,
10
+ vec3u,
11
+ vec4f,
12
+ vec4h,
13
+ vec4i,
14
+ vec4u
15
+ } from "../chunk-DDEF2Y4S.js";
16
+
17
+ // src/data/vectorOps.ts
18
+ var lengthVec2 = (v) => Math.sqrt(v.x ** 2 + v.y ** 2);
19
+ var lengthVec3 = (v) => Math.sqrt(v.x ** 2 + v.y ** 2 + v.z ** 2);
20
+ var lengthVec4 = (v) => Math.sqrt(v.x ** 2 + v.y ** 2 + v.z ** 2 + v.w ** 2);
21
+ var dotVec2 = (lhs, rhs) => lhs.x * rhs.x + lhs.y * rhs.y;
22
+ var dotVec3 = (lhs, rhs) => lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z;
23
+ var dotVec4 = (lhs, rhs) => lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z + lhs.w * rhs.w;
24
+ var clamp = (value, low, high) => Math.min(Math.max(low, value), high);
25
+ var VectorOps = {
26
+ abs: {
27
+ vec2f: (v) => vec2f(Math.abs(v.x), Math.abs(v.y)),
28
+ vec2h: (v) => vec2h(Math.abs(v.x), Math.abs(v.y)),
29
+ vec2i: (v) => vec2i(Math.abs(v.x), Math.abs(v.y)),
30
+ vec2u: (v) => vec2u(Math.abs(v.x), Math.abs(v.y)),
31
+ vec3f: (v) => vec3f(Math.abs(v.x), Math.abs(v.y), Math.abs(v.z)),
32
+ vec3h: (v) => vec3h(Math.abs(v.x), Math.abs(v.y), Math.abs(v.z)),
33
+ vec3i: (v) => vec3i(Math.abs(v.x), Math.abs(v.y), Math.abs(v.z)),
34
+ vec3u: (v) => vec3u(Math.abs(v.x), Math.abs(v.y), Math.abs(v.z)),
35
+ vec4f: (v) => vec4f(Math.abs(v.x), Math.abs(v.y), Math.abs(v.z), Math.abs(v.w)),
36
+ vec4h: (v) => vec4h(Math.abs(v.x), Math.abs(v.y), Math.abs(v.z), Math.abs(v.w)),
37
+ vec4i: (v) => vec4i(Math.abs(v.x), Math.abs(v.y), Math.abs(v.z), Math.abs(v.w)),
38
+ vec4u: (v) => vec4u(Math.abs(v.x), Math.abs(v.y), Math.abs(v.z), Math.abs(v.w))
39
+ },
40
+ ceil: {
41
+ vec2f: (v) => vec2f(Math.ceil(v.x), Math.ceil(v.y)),
42
+ vec2h: (v) => vec2h(Math.ceil(v.x), Math.ceil(v.y)),
43
+ vec2i: (v) => vec2i(Math.ceil(v.x), Math.ceil(v.y)),
44
+ vec2u: (v) => vec2u(Math.ceil(v.x), Math.ceil(v.y)),
45
+ vec3f: (v) => vec3f(Math.ceil(v.x), Math.ceil(v.y), Math.ceil(v.z)),
46
+ vec3h: (v) => vec3h(Math.ceil(v.x), Math.ceil(v.y), Math.ceil(v.z)),
47
+ vec3i: (v) => vec3i(Math.ceil(v.x), Math.ceil(v.y), Math.ceil(v.z)),
48
+ vec3u: (v) => vec3u(Math.ceil(v.x), Math.ceil(v.y), Math.ceil(v.z)),
49
+ vec4f: (v) => vec4f(Math.ceil(v.x), Math.ceil(v.y), Math.ceil(v.z), Math.ceil(v.w)),
50
+ vec4h: (v) => vec4h(Math.ceil(v.x), Math.ceil(v.y), Math.ceil(v.z), Math.ceil(v.w)),
51
+ vec4i: (v) => vec4i(Math.ceil(v.x), Math.ceil(v.y), Math.ceil(v.z), Math.ceil(v.w)),
52
+ vec4u: (v) => vec4u(Math.ceil(v.x), Math.ceil(v.y), Math.ceil(v.z), Math.ceil(v.w))
53
+ },
54
+ clamp: {
55
+ vec2f: (v, low, high) => vec2f(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
56
+ vec2h: (v, low, high) => vec2h(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
57
+ vec2i: (v, low, high) => vec2i(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
58
+ vec2u: (v, low, high) => vec2u(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
59
+ vec3f: (v, low, high) => vec3f(
60
+ clamp(v.x, low.x, high.x),
61
+ clamp(v.y, low.y, high.y),
62
+ clamp(v.z, low.z, high.z)
63
+ ),
64
+ vec3h: (v, low, high) => vec3h(
65
+ clamp(v.x, low.x, high.x),
66
+ clamp(v.y, low.y, high.y),
67
+ clamp(v.z, low.z, high.z)
68
+ ),
69
+ vec3i: (v, low, high) => vec3i(
70
+ clamp(v.x, low.x, high.x),
71
+ clamp(v.y, low.y, high.y),
72
+ clamp(v.z, low.z, high.z)
73
+ ),
74
+ vec3u: (v, low, high) => vec3u(
75
+ clamp(v.x, low.x, high.x),
76
+ clamp(v.y, low.y, high.y),
77
+ clamp(v.z, low.z, high.z)
78
+ ),
79
+ vec4f: (v, low, high) => vec4f(
80
+ clamp(v.x, low.x, high.x),
81
+ clamp(v.y, low.y, high.y),
82
+ clamp(v.z, low.z, high.z),
83
+ clamp(v.w, low.w, high.w)
84
+ ),
85
+ vec4h: (v, low, high) => vec4h(
86
+ clamp(v.x, low.x, high.x),
87
+ clamp(v.y, low.y, high.y),
88
+ clamp(v.z, low.z, high.z),
89
+ clamp(v.w, low.w, high.w)
90
+ ),
91
+ vec4i: (v, low, high) => vec4i(
92
+ clamp(v.x, low.x, high.x),
93
+ clamp(v.y, low.y, high.y),
94
+ clamp(v.z, low.z, high.z),
95
+ clamp(v.w, low.w, high.w)
96
+ ),
97
+ vec4u: (v, low, high) => vec4u(
98
+ clamp(v.x, low.x, high.x),
99
+ clamp(v.y, low.y, high.y),
100
+ clamp(v.z, low.z, high.z),
101
+ clamp(v.w, low.w, high.w)
102
+ )
103
+ },
104
+ length: {
105
+ vec2f: lengthVec2,
106
+ vec2h: lengthVec2,
107
+ vec2i: lengthVec2,
108
+ vec2u: lengthVec2,
109
+ vec3f: lengthVec3,
110
+ vec3h: lengthVec3,
111
+ vec3i: lengthVec3,
112
+ vec3u: lengthVec3,
113
+ vec4f: lengthVec4,
114
+ vec4h: lengthVec4,
115
+ vec4i: lengthVec4,
116
+ vec4u: lengthVec4
117
+ },
118
+ add: {
119
+ vec2f: (a, b) => vec2f(a.x + b.x, a.y + b.y),
120
+ vec2h: (a, b) => vec2h(a.x + b.x, a.y + b.y),
121
+ vec2i: (a, b) => vec2i(a.x + b.x, a.y + b.y),
122
+ vec2u: (a, b) => vec2u(a.x + b.x, a.y + b.y),
123
+ vec3f: (a, b) => vec3f(a.x + b.x, a.y + b.y, a.z + b.z),
124
+ vec3h: (a, b) => vec3h(a.x + b.x, a.y + b.y, a.z + b.z),
125
+ vec3i: (a, b) => vec3i(a.x + b.x, a.y + b.y, a.z + b.z),
126
+ vec3u: (a, b) => vec3u(a.x + b.x, a.y + b.y, a.z + b.z),
127
+ vec4f: (a, b) => vec4f(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w),
128
+ vec4h: (a, b) => vec4h(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w),
129
+ vec4i: (a, b) => vec4i(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w),
130
+ vec4u: (a, b) => vec4u(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w)
131
+ },
132
+ sub: {
133
+ vec2f: (a, b) => vec2f(a.x - b.x, a.y - b.y),
134
+ vec2h: (a, b) => vec2h(a.x - b.x, a.y - b.y),
135
+ vec2i: (a, b) => vec2i(a.x - b.x, a.y - b.y),
136
+ vec2u: (a, b) => vec2u(a.x - b.x, a.y - b.y),
137
+ vec3f: (a, b) => vec3f(a.x - b.x, a.y - b.y, a.z - b.z),
138
+ vec3h: (a, b) => vec3h(a.x - b.x, a.y - b.y, a.z - b.z),
139
+ vec3i: (a, b) => vec3i(a.x - b.x, a.y - b.y, a.z - b.z),
140
+ vec3u: (a, b) => vec3u(a.x - b.x, a.y - b.y, a.z - b.z),
141
+ vec4f: (a, b) => vec4f(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w),
142
+ vec4h: (a, b) => vec4h(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w),
143
+ vec4i: (a, b) => vec4i(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w),
144
+ vec4u: (a, b) => vec4u(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w)
145
+ },
146
+ mulSxV: {
147
+ vec2f: (s, v) => vec2f(s * v.x, s * v.y),
148
+ vec2h: (s, v) => vec2h(s * v.x, s * v.y),
149
+ vec2i: (s, v) => vec2i(s * v.x, s * v.y),
150
+ vec2u: (s, v) => vec2u(s * v.x, s * v.y),
151
+ vec3f: (s, v) => vec3f(s * v.x, s * v.y, s * v.z),
152
+ vec3h: (s, v) => vec3h(s * v.x, s * v.y, s * v.z),
153
+ vec3i: (s, v) => vec3i(s * v.x, s * v.y, s * v.z),
154
+ vec3u: (s, v) => vec3u(s * v.x, s * v.y, s * v.z),
155
+ vec4f: (s, v) => vec4f(s * v.x, s * v.y, s * v.z, s * v.w),
156
+ vec4h: (s, v) => vec4h(s * v.x, s * v.y, s * v.z, s * v.w),
157
+ vec4i: (s, v) => vec4i(s * v.x, s * v.y, s * v.z, s * v.w),
158
+ vec4u: (s, v) => vec4u(s * v.x, s * v.y, s * v.z, s * v.w)
159
+ },
160
+ mulVxV: {
161
+ vec2f: (a, b) => vec2f(a.x * b.x, a.y * b.y),
162
+ vec2h: (a, b) => vec2h(a.x * b.x, a.y * b.y),
163
+ vec2i: (a, b) => vec2i(a.x * b.x, a.y * b.y),
164
+ vec2u: (a, b) => vec2u(a.x * b.x, a.y * b.y),
165
+ vec3f: (a, b) => vec3f(a.x * b.x, a.y * b.y, a.z * b.z),
166
+ vec3h: (a, b) => vec3h(a.x * b.x, a.y * b.y, a.z * b.z),
167
+ vec3i: (a, b) => vec3i(a.x * b.x, a.y * b.y, a.z * b.z),
168
+ vec3u: (a, b) => vec3u(a.x * b.x, a.y * b.y, a.z * b.z),
169
+ vec4f: (a, b) => vec4f(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w),
170
+ vec4h: (a, b) => vec4h(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w),
171
+ vec4i: (a, b) => vec4i(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w),
172
+ vec4u: (a, b) => vec4u(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w)
173
+ },
174
+ dot: {
175
+ vec2f: dotVec2,
176
+ vec2h: dotVec2,
177
+ vec2i: dotVec2,
178
+ vec2u: dotVec2,
179
+ vec3f: dotVec3,
180
+ vec3h: dotVec3,
181
+ vec3i: dotVec3,
182
+ vec3u: dotVec3,
183
+ vec4f: dotVec4,
184
+ vec4h: dotVec4,
185
+ vec4i: dotVec4,
186
+ vec4u: dotVec4
187
+ },
188
+ normalize: {
189
+ vec2f: (v) => {
190
+ const len = lengthVec2(v);
191
+ return vec2f(v.x / len, v.y / len);
192
+ },
193
+ vec2h: (v) => {
194
+ const len = lengthVec2(v);
195
+ return vec2h(v.x / len, v.y / len);
196
+ },
197
+ vec2i: (v) => {
198
+ const len = lengthVec2(v);
199
+ return vec2i(v.x / len, v.y / len);
200
+ },
201
+ vec2u: (v) => {
202
+ const len = lengthVec2(v);
203
+ return vec2u(v.x / len, v.y / len);
204
+ },
205
+ vec3f: (v) => {
206
+ const len = lengthVec3(v);
207
+ return vec3f(v.x / len, v.y / len, v.z / len);
208
+ },
209
+ vec3h: (v) => {
210
+ const len = lengthVec3(v);
211
+ return vec3h(v.x / len, v.y / len, v.z / len);
212
+ },
213
+ vec3i: (v) => {
214
+ const len = lengthVec3(v);
215
+ return vec3i(v.x / len, v.y / len, v.z / len);
216
+ },
217
+ vec3u: (v) => {
218
+ const len = lengthVec3(v);
219
+ return vec3u(v.x / len, v.y / len, v.z / len);
220
+ },
221
+ vec4f: (v) => {
222
+ const len = lengthVec4(v);
223
+ return vec4f(v.x / len, v.y / len, v.z / len, v.w / len);
224
+ },
225
+ vec4h: (v) => {
226
+ const len = lengthVec4(v);
227
+ return vec4h(v.x / len, v.y / len, v.z / len, v.w / len);
228
+ },
229
+ vec4i: (v) => {
230
+ const len = lengthVec4(v);
231
+ return vec4i(v.x / len, v.y / len, v.z / len, v.w / len);
232
+ },
233
+ vec4u: (v) => {
234
+ const len = lengthVec4(v);
235
+ return vec4u(v.x / len, v.y / len, v.z / len, v.w / len);
236
+ }
237
+ },
238
+ cross: {
239
+ vec3f: (a, b) => {
240
+ return vec3f(
241
+ a.y * b.z - a.z * b.y,
242
+ a.z * b.x - a.x * b.z,
243
+ a.x * b.y - a.y * b.x
244
+ );
245
+ },
246
+ vec3h: (a, b) => {
247
+ return vec3h(
248
+ a.y * b.z - a.z * b.y,
249
+ a.z * b.x - a.x * b.z,
250
+ a.x * b.y - a.y * b.x
251
+ );
252
+ },
253
+ vec3i: (a, b) => {
254
+ return vec3i(
255
+ a.y * b.z - a.z * b.y,
256
+ a.z * b.x - a.x * b.z,
257
+ a.x * b.y - a.y * b.x
258
+ );
259
+ },
260
+ vec3u: (a, b) => {
261
+ return vec3u(
262
+ a.y * b.z - a.z * b.y,
263
+ a.z * b.x - a.x * b.z,
264
+ a.x * b.y - a.y * b.x
265
+ );
266
+ }
267
+ },
268
+ floor: {
269
+ vec2f: (v) => vec2f(Math.floor(v.x), Math.floor(v.y)),
270
+ vec2h: (v) => vec2h(Math.floor(v.x), Math.floor(v.y)),
271
+ vec2i: (v) => vec2i(Math.floor(v.x), Math.floor(v.y)),
272
+ vec2u: (v) => vec2u(Math.floor(v.x), Math.floor(v.y)),
273
+ vec3f: (v) => vec3f(Math.floor(v.x), Math.floor(v.y), Math.floor(v.z)),
274
+ vec3h: (v) => vec3h(Math.floor(v.x), Math.floor(v.y), Math.floor(v.z)),
275
+ vec3i: (v) => vec3i(Math.floor(v.x), Math.floor(v.y), Math.floor(v.z)),
276
+ vec3u: (v) => vec3u(Math.floor(v.x), Math.floor(v.y), Math.floor(v.z)),
277
+ vec4f: (v) => vec4f(Math.floor(v.x), Math.floor(v.y), Math.floor(v.z), Math.floor(v.w)),
278
+ vec4h: (v) => vec4h(Math.floor(v.x), Math.floor(v.y), Math.floor(v.z), Math.floor(v.w)),
279
+ vec4i: (v) => vec4i(Math.floor(v.x), Math.floor(v.y), Math.floor(v.z), Math.floor(v.w)),
280
+ vec4u: (v) => vec4u(Math.floor(v.x), Math.floor(v.y), Math.floor(v.z), Math.floor(v.w))
281
+ },
282
+ max: {
283
+ vec2f: (a, b) => vec2f(Math.max(a.x, b.x), Math.max(a.y, b.y)),
284
+ vec2h: (a, b) => vec2h(Math.max(a.x, b.x), Math.max(a.y, b.y)),
285
+ vec2i: (a, b) => vec2i(Math.max(a.x, b.x), Math.max(a.y, b.y)),
286
+ vec2u: (a, b) => vec2u(Math.max(a.x, b.x), Math.max(a.y, b.y)),
287
+ vec3f: (a, b) => vec3f(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z)),
288
+ vec3h: (a, b) => vec3h(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z)),
289
+ vec3i: (a, b) => vec3i(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z)),
290
+ vec3u: (a, b) => vec3u(Math.max(a.x, b.x), Math.max(a.y, b.y), Math.max(a.z, b.z)),
291
+ vec4f: (a, b) => vec4f(
292
+ Math.max(a.x, b.x),
293
+ Math.max(a.y, b.y),
294
+ Math.max(a.z, b.z),
295
+ Math.max(a.w, b.w)
296
+ ),
297
+ vec4h: (a, b) => vec4h(
298
+ Math.max(a.x, b.x),
299
+ Math.max(a.y, b.y),
300
+ Math.max(a.z, b.z),
301
+ Math.max(a.w, b.w)
302
+ ),
303
+ vec4i: (a, b) => vec4i(
304
+ Math.max(a.x, b.x),
305
+ Math.max(a.y, b.y),
306
+ Math.max(a.z, b.z),
307
+ Math.max(a.w, b.w)
308
+ ),
309
+ vec4u: (a, b) => vec4u(
310
+ Math.max(a.x, b.x),
311
+ Math.max(a.y, b.y),
312
+ Math.max(a.z, b.z),
313
+ Math.max(a.w, b.w)
314
+ )
315
+ },
316
+ min: {
317
+ vec2f: (a, b) => vec2f(Math.min(a.x, b.x), Math.min(a.y, b.y)),
318
+ vec2h: (a, b) => vec2h(Math.min(a.x, b.x), Math.min(a.y, b.y)),
319
+ vec2i: (a, b) => vec2i(Math.min(a.x, b.x), Math.min(a.y, b.y)),
320
+ vec2u: (a, b) => vec2u(Math.min(a.x, b.x), Math.min(a.y, b.y)),
321
+ vec3f: (a, b) => vec3f(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z)),
322
+ vec3h: (a, b) => vec3h(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z)),
323
+ vec3i: (a, b) => vec3i(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z)),
324
+ vec3u: (a, b) => vec3u(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z)),
325
+ vec4f: (a, b) => vec4f(
326
+ Math.min(a.x, b.x),
327
+ Math.min(a.y, b.y),
328
+ Math.min(a.z, b.z),
329
+ Math.min(a.w, b.w)
330
+ ),
331
+ vec4h: (a, b) => vec4h(
332
+ Math.min(a.x, b.x),
333
+ Math.min(a.y, b.y),
334
+ Math.min(a.z, b.z),
335
+ Math.min(a.w, b.w)
336
+ ),
337
+ vec4i: (a, b) => vec4i(
338
+ Math.min(a.x, b.x),
339
+ Math.min(a.y, b.y),
340
+ Math.min(a.z, b.z),
341
+ Math.min(a.w, b.w)
342
+ ),
343
+ vec4u: (a, b) => vec4u(
344
+ Math.min(a.x, b.x),
345
+ Math.min(a.y, b.y),
346
+ Math.min(a.z, b.z),
347
+ Math.min(a.w, b.w)
348
+ )
349
+ }
350
+ };
351
+
352
+ // src/std/numeric.ts
353
+ function add(lhs, rhs) {
354
+ if (inGPUMode()) {
355
+ return `(${lhs} + ${rhs})`;
356
+ }
357
+ return VectorOps.add[lhs.kind](lhs, rhs);
358
+ }
359
+ function sub(lhs, rhs) {
360
+ if (inGPUMode()) {
361
+ return `(${lhs} - ${rhs})`;
362
+ }
363
+ return VectorOps.sub[lhs.kind](lhs, rhs);
364
+ }
365
+ function mul(s, v) {
366
+ if (inGPUMode()) {
367
+ return `(${s} * ${v})`;
368
+ }
369
+ if (typeof s === "number") {
370
+ return VectorOps.mulSxV[v.kind](s, v);
371
+ }
372
+ return VectorOps.mulVxV[v.kind](s, v);
373
+ }
374
+ function abs(value) {
375
+ if (inGPUMode()) {
376
+ return `abs(${value})`;
377
+ }
378
+ if (typeof value === "number") {
379
+ return Math.abs(value);
380
+ }
381
+ return VectorOps.abs[value.kind](value);
382
+ }
383
+ function ceil(value) {
384
+ if (inGPUMode()) {
385
+ return `ceil(${value})`;
386
+ }
387
+ if (typeof value === "number") {
388
+ return Math.ceil(value);
389
+ }
390
+ return VectorOps.ceil[value.kind](value);
391
+ }
392
+ function clamp2(value, low, high) {
393
+ if (inGPUMode()) {
394
+ return `clamp(${value}, ${low}, ${high})`;
395
+ }
396
+ if (typeof value === "number") {
397
+ return Math.min(Math.max(low, value), high);
398
+ }
399
+ return VectorOps.clamp[value.kind](value, low, high);
400
+ }
401
+ function cos(radians) {
402
+ if (inGPUMode()) {
403
+ return `cos(${radians})`;
404
+ }
405
+ return Math.cos(radians);
406
+ }
407
+ function cross(a, b) {
408
+ if (inGPUMode()) {
409
+ return `cross(${a}, ${b})`;
410
+ }
411
+ return VectorOps.cross[a.kind](a, b);
412
+ }
413
+ function dot(lhs, rhs) {
414
+ if (inGPUMode()) {
415
+ return `dot(${lhs}, ${rhs})`;
416
+ }
417
+ return VectorOps.dot[lhs.kind](lhs, rhs);
418
+ }
419
+ function normalize(v) {
420
+ if (inGPUMode()) {
421
+ return `normalize(${v})`;
422
+ }
423
+ return VectorOps.normalize[v.kind](v);
424
+ }
425
+ function floor(value) {
426
+ if (inGPUMode()) {
427
+ return `floor(${value})`;
428
+ }
429
+ if (typeof value === "number") {
430
+ return Math.floor(value);
431
+ }
432
+ return VectorOps.floor[value.kind](value);
433
+ }
434
+ function fract(a) {
435
+ if (inGPUMode()) {
436
+ return `fract(${a})`;
437
+ }
438
+ return a - Math.floor(a);
439
+ }
440
+ function length(value) {
441
+ if (inGPUMode()) {
442
+ return `length(${value})`;
443
+ }
444
+ if (typeof value === "number") {
445
+ return Math.abs(value);
446
+ }
447
+ return VectorOps.length[value.kind](value);
448
+ }
449
+ function max(a, b) {
450
+ if (inGPUMode()) {
451
+ return `max(${a}, ${b})`;
452
+ }
453
+ if (typeof a === "number") {
454
+ return Math.max(a, b);
455
+ }
456
+ return VectorOps.max[a.kind](a, b);
457
+ }
458
+ function min(a, b) {
459
+ if (inGPUMode()) {
460
+ return `min(${a}, ${b})`;
461
+ }
462
+ if (typeof a === "number") {
463
+ return Math.min(a, b);
464
+ }
465
+ return VectorOps.min[a.kind](a, b);
466
+ }
467
+ function sin(radians) {
468
+ if (inGPUMode()) {
469
+ return `sin(${radians})`;
470
+ }
471
+ return Math.sin(radians);
472
+ }
473
+ export {
474
+ abs,
475
+ add,
476
+ ceil,
477
+ clamp2 as clamp,
478
+ cos,
479
+ cross,
480
+ dot,
481
+ floor,
482
+ fract,
483
+ length,
484
+ max,
485
+ min,
486
+ mul,
487
+ normalize,
488
+ sin,
489
+ sub
490
+ };
2
491
  //# sourceMappingURL=index.js.map