typegpu 0.11.8 → 0.12.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.
Files changed (362) hide show
  1. package/builtin.d.ts +51 -53
  2. package/builtin.js +30 -34
  3. package/common/fullScreenTriangle.d.ts +2 -10
  4. package/common/fullScreenTriangle.js +20 -28
  5. package/common/index.d.ts +2 -9
  6. package/common/index.js +3 -12
  7. package/common/writeSoA.d.ts +11 -12
  8. package/common/writeSoA.js +88 -76
  9. package/core/buffer/buffer.d.ts +79 -62
  10. package/core/buffer/buffer.js +279 -205
  11. package/core/buffer/bufferBinding.d.ts +71 -0
  12. package/core/buffer/bufferBinding.js +154 -0
  13. package/core/buffer/bufferUsage.d.ts +14 -45
  14. package/core/buffer/bufferUsage.js +1 -171
  15. package/core/buffer/laidOutBuffer.d.ts +25 -0
  16. package/core/buffer/laidOutBuffer.js +55 -0
  17. package/core/commandEncoder/attachments.d.ts +125 -0
  18. package/core/commandEncoder/attachments.js +29 -0
  19. package/core/commandEncoder/commandEncoder.d.ts +53 -0
  20. package/core/commandEncoder/commandEncoder.js +56 -0
  21. package/core/commandEncoder/computePass.d.ts +58 -0
  22. package/core/commandEncoder/computePass.js +63 -0
  23. package/core/commandEncoder/renderPass.d.ts +121 -0
  24. package/core/commandEncoder/renderPass.js +196 -0
  25. package/core/constant/tgpuConstant.d.ts +26 -26
  26. package/core/constant/tgpuConstant.js +76 -65
  27. package/core/declare/tgpuDeclare.d.ts +3 -6
  28. package/core/declare/tgpuDeclare.js +37 -38
  29. package/core/function/autoIO.d.ts +61 -33
  30. package/core/function/autoIO.js +68 -73
  31. package/core/function/comptime.d.ts +11 -13
  32. package/core/function/comptime.js +60 -52
  33. package/core/function/createCallableSchema.d.ts +16 -0
  34. package/core/function/createCallableSchema.js +50 -40
  35. package/core/function/dualImpl.d.ts +44 -0
  36. package/core/function/dualImpl.js +71 -50
  37. package/core/function/entryInputRouter.d.ts +26 -0
  38. package/core/function/entryInputRouter.js +31 -33
  39. package/core/function/extractArgs.d.ts +38 -0
  40. package/core/function/extractArgs.js +202 -200
  41. package/core/function/fnCore.d.ts +44 -0
  42. package/core/function/fnCore.js +148 -92
  43. package/core/function/fnTypes.d.ts +31 -29
  44. package/core/function/fnTypes.js +1 -0
  45. package/core/function/ioSchema.d.ts +12 -10
  46. package/core/function/ioSchema.js +65 -47
  47. package/core/function/shelllessImpl.d.ts +9 -12
  48. package/core/function/shelllessImpl.js +18 -20
  49. package/core/function/templateUtils.d.ts +2 -0
  50. package/core/function/templateUtils.js +9 -8
  51. package/core/function/tgpuComputeFn.d.ts +26 -28
  52. package/core/function/tgpuComputeFn.js +47 -48
  53. package/core/function/tgpuFn.d.ts +34 -37
  54. package/core/function/tgpuFn.js +179 -153
  55. package/core/function/tgpuFragmentFn.d.ts +52 -53
  56. package/core/function/tgpuFragmentFn.js +63 -56
  57. package/core/function/tgpuVertexFn.d.ts +36 -39
  58. package/core/function/tgpuVertexFn.js +56 -53
  59. package/core/pipeline/computePipeline.d.ts +141 -53
  60. package/core/pipeline/computePipeline.js +291 -225
  61. package/core/pipeline/connectAttachmentToShader.d.ts +4 -0
  62. package/core/pipeline/connectAttachmentToShader.js +25 -22
  63. package/core/pipeline/connectTargetsToShader.d.ts +3 -0
  64. package/core/pipeline/connectTargetsToShader.js +29 -27
  65. package/core/pipeline/drawState.d.ts +52 -0
  66. package/core/pipeline/drawState.js +225 -0
  67. package/core/pipeline/limitsOverflow.d.ts +2 -0
  68. package/core/pipeline/limitsOverflow.js +13 -10
  69. package/core/pipeline/performanceTracker.d.ts +14 -0
  70. package/core/pipeline/performanceTracker.js +34 -0
  71. package/core/pipeline/pipelineUtils.d.ts +18 -0
  72. package/core/pipeline/pipelineUtils.js +54 -25
  73. package/core/pipeline/priors.d.ts +1 -0
  74. package/core/pipeline/priors.js +12 -0
  75. package/core/pipeline/renderPipeline.d.ts +246 -261
  76. package/core/pipeline/renderPipeline.js +487 -480
  77. package/core/pipeline/timeable.d.ts +28 -18
  78. package/core/pipeline/timeable.js +90 -52
  79. package/core/pipeline/typeGuards.d.ts +17 -0
  80. package/core/pipeline/typeGuards.js +52 -22
  81. package/core/querySet/querySet.d.ts +26 -21
  82. package/core/querySet/querySet.js +127 -103
  83. package/core/rawCodeSnippet/tgpuRawCodeSnippet.d.ts +13 -18
  84. package/core/rawCodeSnippet/tgpuRawCodeSnippet.js +90 -93
  85. package/core/resolve/externals.d.ts +25 -7
  86. package/core/resolve/externals.js +79 -62
  87. package/core/resolve/namespace.d.ts +22 -25
  88. package/core/resolve/namespace.js +16 -21
  89. package/core/resolve/resolvableString.d.ts +7 -0
  90. package/core/resolve/resolvableString.js +13 -0
  91. package/core/resolve/resolveData.d.ts +10 -0
  92. package/core/resolve/resolveData.js +162 -121
  93. package/core/resolve/stitch.d.ts +8 -0
  94. package/core/resolve/stitch.js +23 -21
  95. package/core/resolve/tgpuResolve.d.ts +55 -53
  96. package/core/resolve/tgpuResolve.js +106 -55
  97. package/core/root/configurableImpl.d.ts +10 -0
  98. package/core/root/configurableImpl.js +17 -19
  99. package/core/root/init.d.ts +76 -38
  100. package/core/root/init.js +346 -454
  101. package/core/root/rootTypes.d.ts +461 -627
  102. package/core/root/rootTypes.js +1 -0
  103. package/core/sampler/sampler.d.ts +50 -31
  104. package/core/sampler/sampler.js +120 -113
  105. package/core/simulate/tgpuSimulate.d.ts +9 -12
  106. package/core/simulate/tgpuSimulate.js +68 -71
  107. package/core/slot/accessor.d.ts +36 -13
  108. package/core/slot/accessor.js +138 -91
  109. package/core/slot/internalSlots.d.ts +2 -0
  110. package/core/slot/internalSlots.js +1 -6
  111. package/core/slot/lazy.d.ts +2 -6
  112. package/core/slot/lazy.js +71 -39
  113. package/core/slot/slot.d.ts +2 -6
  114. package/core/slot/slot.js +45 -38
  115. package/core/slot/slotTypes.d.ts +78 -80
  116. package/core/slot/slotTypes.js +11 -16
  117. package/core/texture/externalTexture.d.ts +20 -11
  118. package/core/texture/externalTexture.js +46 -46
  119. package/core/texture/texture.d.ts +152 -97
  120. package/core/texture/texture.js +407 -314
  121. package/core/texture/textureFormats.d.ts +42 -23
  122. package/core/texture/textureFormats.js +104 -75
  123. package/core/texture/textureProps.d.ts +7 -10
  124. package/core/texture/textureProps.js +1 -0
  125. package/core/texture/textureUtils.d.ts +8 -0
  126. package/core/texture/textureUtils.js +185 -179
  127. package/core/texture/usageExtension.d.ts +21 -18
  128. package/core/texture/usageExtension.js +13 -17
  129. package/core/unroll/tgpuUnroll.d.ts +20 -19
  130. package/core/unroll/tgpuUnroll.js +82 -91
  131. package/core/valueProxyUtils.d.ts +3 -0
  132. package/core/valueProxyUtils.js +52 -41
  133. package/core/variable/tgpuVariable.d.ts +26 -27
  134. package/core/variable/tgpuVariable.js +93 -96
  135. package/core/vertexLayout/connectAttributesToShader.d.ts +9 -0
  136. package/core/vertexLayout/connectAttributesToShader.js +61 -56
  137. package/core/vertexLayout/vertexAttribute.d.ts +21 -17
  138. package/core/vertexLayout/vertexAttribute.js +1 -0
  139. package/core/vertexLayout/vertexLayout.d.ts +24 -18
  140. package/core/vertexLayout/vertexLayout.js +130 -99
  141. package/core/whitespaces.d.ts +2 -0
  142. package/core/whitespaces.js +16 -0
  143. package/data/alignIO.d.ts +7 -0
  144. package/data/alignIO.js +13 -13
  145. package/data/alignmentOf.d.ts +5 -8
  146. package/data/alignmentOf.js +90 -75
  147. package/data/array.d.ts +6 -9
  148. package/data/array.js +48 -40
  149. package/data/atomic.d.ts +2 -7
  150. package/data/atomic.js +26 -23
  151. package/data/attributes.d.ts +19 -21
  152. package/data/attributes.js +192 -132
  153. package/data/autoStruct.d.ts +36 -3
  154. package/data/autoStruct.js +84 -81
  155. package/data/compiledIO.d.ts +5 -0
  156. package/data/compiledIO.js +231 -214
  157. package/data/dataIO.d.ts +13 -11
  158. package/data/dataIO.js +643 -589
  159. package/data/dataTypes.d.ts +83 -65
  160. package/data/dataTypes.js +66 -68
  161. package/data/deepEqual.d.ts +2 -7
  162. package/data/deepEqual.js +80 -55
  163. package/data/disarray.d.ts +6 -10
  164. package/data/disarray.js +52 -46
  165. package/data/float16Conversion.d.ts +4 -0
  166. package/data/float16Conversion.js +7 -0
  167. package/data/getLongestContiguousPrefix.d.ts +4 -8
  168. package/data/getLongestContiguousPrefix.js +6 -11
  169. package/data/index.d.ts +30 -31
  170. package/data/index.js +39 -172
  171. package/data/instanceToSchema.d.ts +24 -27
  172. package/data/instanceToSchema.js +1 -0
  173. package/data/isContiguous.d.ts +4 -8
  174. package/data/isContiguous.js +6 -11
  175. package/data/matrix.d.ts +21 -21
  176. package/data/matrix.js +513 -505
  177. package/data/numberOps.d.ts +6 -0
  178. package/data/numberOps.js +26 -20
  179. package/data/numeric.d.ts +21 -12
  180. package/data/numeric.js +287 -192
  181. package/data/offsetUtils.d.ts +9 -13
  182. package/data/offsetUtils.js +204 -144
  183. package/data/offsets.d.ts +8 -0
  184. package/data/offsets.js +33 -33
  185. package/data/partialIO.d.ts +13 -8
  186. package/data/partialIO.js +124 -113
  187. package/data/ptr.d.ts +12 -12
  188. package/data/ptr.js +42 -44
  189. package/data/ref.d.ts +40 -27
  190. package/data/ref.js +125 -95
  191. package/data/sampler.d.ts +99 -101
  192. package/data/sampler.js +17 -21
  193. package/data/schemaCallWrapper.d.ts +19 -0
  194. package/data/schemaCallWrapper.js +31 -26
  195. package/data/schemaMemoryLayout.d.ts +8 -0
  196. package/data/schemaMemoryLayout.js +213 -185
  197. package/data/sizeOf.d.ts +4 -8
  198. package/data/sizeOf.js +6 -11
  199. package/data/snippet.d.ts +96 -20
  200. package/data/snippet.js +75 -86
  201. package/data/struct.d.ts +4 -7
  202. package/data/struct.js +51 -39
  203. package/data/texture.d.ts +253 -250
  204. package/data/texture.js +238 -200
  205. package/data/unstruct.d.ts +2 -7
  206. package/data/unstruct.js +43 -37
  207. package/data/vector.d.ts +33 -21
  208. package/data/vector.js +234 -221
  209. package/data/vectorImpl.d.ts +231 -0
  210. package/data/vectorImpl.js +563 -515
  211. package/data/vectorOps.d.ts +63 -0
  212. package/data/vectorOps.js +642 -630
  213. package/data/vertexFormatData.d.ts +181 -184
  214. package/data/vertexFormatData.js +104 -106
  215. package/data/wgslTypes.d.ts +665 -600
  216. package/data/wgslTypes.js +220 -198
  217. package/errors.d.ts +50 -24
  218. package/errors.js +146 -120
  219. package/execMode.d.ts +16 -0
  220. package/execMode.js +47 -40
  221. package/extension.d.ts +13 -8
  222. package/extension.js +10 -16
  223. package/getGPUValue.d.ts +1 -0
  224. package/getGPUValue.js +2 -7
  225. package/index.d.ts +28 -68
  226. package/index.js +8 -28
  227. package/indexNamedExports.d.ts +69 -42
  228. package/indexNamedExports.js +25 -0
  229. package/internal.d.ts +16 -0
  230. package/internal.js +12 -0
  231. package/mathUtils.d.ts +5 -0
  232. package/mathUtils.js +7 -11
  233. package/memo.d.ts +11 -0
  234. package/memo.js +20 -22
  235. package/minify.d.ts +5 -0
  236. package/minify.js +93 -0
  237. package/nameUtils.d.ts +29 -0
  238. package/nameUtils.js +428 -398
  239. package/package.json +9 -3
  240. package/resolutionCtx.d.ts +162 -22
  241. package/resolutionCtx.js +911 -624
  242. package/serial/registry.d.ts +15 -0
  243. package/serial/registry.js +106 -0
  244. package/serial/restore.d.ts +49 -0
  245. package/serial/restore.js +68 -0
  246. package/serial/schema.d.ts +58 -0
  247. package/serial/schema.js +209 -0
  248. package/serial/types.d.ts +5 -0
  249. package/serial/types.js +1 -0
  250. package/shared/env.d.ts +9 -0
  251. package/shared/env.js +9 -12
  252. package/shared/generators.d.ts +4 -0
  253. package/shared/generators.js +10 -12
  254. package/shared/meta.d.ts +29 -14
  255. package/shared/meta.js +71 -55
  256. package/shared/normalizeMetadata.d.ts +32 -27
  257. package/shared/normalizeMetadata.js +23 -36
  258. package/shared/repr.d.ts +73 -55
  259. package/shared/repr.js +1 -0
  260. package/shared/soul.d.ts +17 -0
  261. package/shared/soul.js +1 -0
  262. package/shared/stringify.d.ts +2 -0
  263. package/shared/stringify.js +29 -20
  264. package/shared/symbols.d.ts +26 -20
  265. package/shared/symbols.js +79 -79
  266. package/shared/tseynit.d.ts +2 -0
  267. package/shared/tseynit.js +160 -75
  268. package/shared/utilityTypes.d.ts +30 -14
  269. package/shared/utilityTypes.js +2 -6
  270. package/shared/vertexFormat.d.ts +41 -43
  271. package/shared/vertexFormat.js +59 -62
  272. package/std/array.d.ts +2 -7
  273. package/std/array.js +18 -23
  274. package/std/atomic.d.ts +14 -18
  275. package/std/atomic.js +96 -95
  276. package/std/bitcast.d.ts +193 -10
  277. package/std/bitcast.js +309 -39
  278. package/std/boolean.d.ts +19 -33
  279. package/std/boolean.js +296 -288
  280. package/std/copy.d.ts +2 -7
  281. package/std/copy.js +27 -24
  282. package/std/derivative.d.ts +11 -15
  283. package/std/derivative.js +56 -79
  284. package/std/discard.d.ts +1 -6
  285. package/std/discard.js +7 -14
  286. package/std/environment.d.ts +19 -14
  287. package/std/environment.js +71 -51
  288. package/std/extensions.d.ts +2 -8
  289. package/std/extensions.js +10 -11
  290. package/std/index.d.ts +20 -24
  291. package/std/index.js +32 -187
  292. package/std/matrix.d.ts +6 -12
  293. package/std/matrix.js +60 -69
  294. package/std/numeric.d.ts +143 -146
  295. package/std/numeric.js +858 -749
  296. package/std/operators.d.ts +19 -27
  297. package/std/operators.js +227 -193
  298. package/std/packing.d.ts +5 -11
  299. package/std/packing.js +67 -75
  300. package/std/range.d.ts +6 -11
  301. package/std/range.js +48 -36
  302. package/std/subgroup.d.ts +33 -37
  303. package/std/subgroup.js +180 -217
  304. package/std/texture.d.ts +70 -38
  305. package/std/texture.js +176 -172
  306. package/taskQueue.d.ts +6 -0
  307. package/taskQueue.js +30 -0
  308. package/tgpu.d.ts +16 -0
  309. package/tgpu.js +17 -44
  310. package/tgpuBindGroupLayout.d.ts +132 -152
  311. package/tgpuBindGroupLayout.js +346 -268
  312. package/tgpuLogger.d.ts +34 -0
  313. package/tgpuLogger.js +63 -0
  314. package/tgpuUnstable.d.ts +16 -22
  315. package/tgpuUnstable.js +13 -35
  316. package/tgsl/accessIndex.d.ts +2 -0
  317. package/tgsl/accessIndex.js +76 -33
  318. package/tgsl/accessProp.d.ts +2 -0
  319. package/tgsl/accessProp.js +142 -100
  320. package/tgsl/accessStructProp.d.ts +5 -0
  321. package/tgsl/accessStructProp.js +18 -0
  322. package/tgsl/consoleLog/deserializers.d.ts +13 -0
  323. package/tgsl/consoleLog/deserializers.js +119 -103
  324. package/tgsl/consoleLog/logGenerator.d.ts +21 -0
  325. package/tgsl/consoleLog/logGenerator.js +85 -80
  326. package/tgsl/consoleLog/serializers.d.ts +21 -0
  327. package/tgsl/consoleLog/serializers.js +119 -100
  328. package/tgsl/consoleLog/types.d.ts +40 -39
  329. package/tgsl/consoleLog/types.js +1 -0
  330. package/tgsl/conversion.d.ts +33 -0
  331. package/tgsl/conversion.js +272 -193
  332. package/tgsl/forOfUtils.d.ts +15 -0
  333. package/tgsl/forOfUtils.js +85 -70
  334. package/tgsl/generationHelpers.d.ts +22 -39
  335. package/tgsl/generationHelpers.js +85 -58
  336. package/tgsl/infixDispatch.d.ts +70 -0
  337. package/tgsl/infixDispatch.js +48 -46
  338. package/tgsl/jsPolyfills.d.ts +16 -19
  339. package/tgsl/jsPolyfills.js +44 -42
  340. package/tgsl/makeDereferenceable.d.ts +48 -0
  341. package/tgsl/makeDereferenceable.js +86 -0
  342. package/tgsl/makeResolvable.d.ts +22 -0
  343. package/tgsl/makeResolvable.js +33 -0
  344. package/tgsl/shaderGenerator.d.ts +77 -17
  345. package/tgsl/shaderGenerator.js +1 -0
  346. package/tgsl/shellless.d.ts +6 -9
  347. package/tgsl/shellless.js +73 -43
  348. package/tgsl/wgslGenerator.d.ts +66 -59
  349. package/tgsl/wgslGenerator.js +1344 -747
  350. package/types.d.ts +287 -221
  351. package/types.js +61 -44
  352. package/unwrapper.d.ts +31 -26
  353. package/unwrapper.js +1 -0
  354. package/wgslExtensions.d.ts +3 -5
  355. package/wgslExtensions.js +12 -16
  356. package/_virtual/rolldown_runtime.js +0 -13
  357. package/core/buffer/bufferShorthand.d.ts +0 -50
  358. package/core/buffer/bufferShorthand.js +0 -55
  359. package/core/pipeline/applyPipelineState.js +0 -37
  360. package/package.js +0 -5
  361. package/tgsl/shaderGenerator_members.d.ts +0 -33
  362. package/tgsl/shaderGenerator_members.js +0 -12
package/data/vectorOps.js CHANGED
@@ -1,23 +1,21 @@
1
- import { vec2b as vec2b$1, vec2f as vec2f$1, vec2h as vec2h$1, vec2i as vec2i$1, vec2u as vec2u$1, vec3b as vec3b$1, vec3f as vec3f$1, vec3h as vec3h$1, vec3i as vec3i$1, vec3u as vec3u$1, vec4b as vec4b$1, vec4f as vec4f$1, vec4h as vec4h$1, vec4i as vec4i$1, vec4u as vec4u$1 } from "./vector.js";
2
1
  import { mat2x2f, mat3x3f, mat4x4f } from "./matrix.js";
3
- import { bitcastU32toF32Impl, bitcastU32toI32Impl, clamp, divInteger, smoothstepScalar } from "./numberOps.js";
4
-
5
- //#region src/data/vectorOps.ts
6
- const vec2b = vec2b$1;
7
- const vec2f = vec2f$1;
8
- const vec2h = vec2h$1;
9
- const vec2i = vec2i$1;
10
- const vec2u = vec2u$1;
11
- const vec3b = vec3b$1;
12
- const vec3f = vec3f$1;
13
- const vec3h = vec3h$1;
14
- const vec3i = vec3i$1;
15
- const vec3u = vec3u$1;
16
- const vec4b = vec4b$1;
17
- const vec4f = vec4f$1;
18
- const vec4h = vec4h$1;
19
- const vec4i = vec4i$1;
20
- const vec4u = vec4u$1;
2
+ import { bitcastF32toU32Impl, bitcastU32toF32Impl, bitcastU32toI32Impl, clamp, divInteger, smoothstepScalar, } from "./numberOps.js";
3
+ import * as vectorConstructors from "./vector.js";
4
+ const vec2b = vectorConstructors.vec2b;
5
+ const vec2f = vectorConstructors.vec2f;
6
+ const vec2h = vectorConstructors.vec2h;
7
+ const vec2i = vectorConstructors.vec2i;
8
+ const vec2u = vectorConstructors.vec2u;
9
+ const vec3b = vectorConstructors.vec3b;
10
+ const vec3f = vectorConstructors.vec3f;
11
+ const vec3h = vectorConstructors.vec3h;
12
+ const vec3i = vectorConstructors.vec3i;
13
+ const vec3u = vectorConstructors.vec3u;
14
+ const vec4b = vectorConstructors.vec4b;
15
+ const vec4f = vectorConstructors.vec4f;
16
+ const vec4h = vectorConstructors.vec4h;
17
+ const vec4i = vectorConstructors.vec4i;
18
+ const vec4u = vectorConstructors.vec4u;
21
19
  const lengthVec2 = (v) => Math.sqrt(v.x ** 2 + v.y ** 2);
22
20
  const lengthVec3 = (v) => Math.sqrt(v.x ** 2 + v.y ** 2 + v.z ** 2);
23
21
  const lengthVec4 = (v) => Math.sqrt(v.x ** 2 + v.y ** 2 + v.z ** 2 + v.w ** 2);
@@ -37,16 +35,16 @@ const unary4h = (op) => (a) => vec4h(op(a.x), op(a.y), op(a.z), op(a.w));
37
35
  const unary4i = (op) => (a) => vec4i(op(a.x), op(a.y), op(a.z), op(a.w));
38
36
  const unary4u = (op) => (a) => vec4u(op(a.x), op(a.y), op(a.z), op(a.w));
39
37
  const unary2x2f = (op) => (a) => {
40
- const a_ = a.columns;
41
- return mat2x2f(unary2f(op)(a_[0]), unary2f(op)(a_[1]));
38
+ const a_ = a.columns;
39
+ return mat2x2f(unary2f(op)(a_[0]), unary2f(op)(a_[1]));
42
40
  };
43
41
  const unary3x3f = (op) => (a) => {
44
- const a_ = a.columns;
45
- return mat3x3f(unary3f(op)(a_[0]), unary3f(op)(a_[1]), unary3f(op)(a_[2]));
42
+ const a_ = a.columns;
43
+ return mat3x3f(unary3f(op)(a_[0]), unary3f(op)(a_[1]), unary3f(op)(a_[2]));
46
44
  };
47
45
  const unary4x4f = (op) => (a) => {
48
- const a_ = a.columns;
49
- return mat4x4f(unary4f(op)(a_[0]), unary4f(op)(a_[1]), unary4f(op)(a_[2]), unary4f(op)(a_[3]));
46
+ const a_ = a.columns;
47
+ return mat4x4f(unary4f(op)(a_[0]), unary4f(op)(a_[1]), unary4f(op)(a_[2]), unary4f(op)(a_[3]));
50
48
  };
51
49
  const binaryComponentWise2f = (op) => (a, b) => vec2f(op(a.x, b.x), op(a.y, b.y));
52
50
  const binaryComponentWise2h = (op) => (a, b) => vec2h(op(a.x, b.x), op(a.y, b.y));
@@ -64,19 +62,19 @@ const binaryComponentWise2i2u = (op) => (a, b) => vec2i(op(a.x, b.x), op(a.y, b.
64
62
  const binaryComponentWise3i3u = (op) => (a, b) => vec3i(op(a.x, b.x), op(a.y, b.y), op(a.z, b.z));
65
63
  const binaryComponentWise4i4u = (op) => (a, b) => vec4i(op(a.x, b.x), op(a.y, b.y), op(a.z, b.z), op(a.w, b.w));
66
64
  const binaryComponentWise2x2f = (op) => (a, b) => {
67
- const a_ = a.columns;
68
- const b_ = b.columns;
69
- return mat2x2f(binaryComponentWise2f(op)(a_[0], b_[0]), binaryComponentWise2f(op)(a_[1], b_[1]));
65
+ const a_ = a.columns;
66
+ const b_ = b.columns;
67
+ return mat2x2f(binaryComponentWise2f(op)(a_[0], b_[0]), binaryComponentWise2f(op)(a_[1], b_[1]));
70
68
  };
71
69
  const binaryComponentWise3x3f = (op) => (a, b) => {
72
- const a_ = a.columns;
73
- const b_ = b.columns;
74
- return mat3x3f(binaryComponentWise3f(op)(a_[0], b_[0]), binaryComponentWise3f(op)(a_[1], b_[1]), binaryComponentWise3f(op)(a_[2], b_[2]));
70
+ const a_ = a.columns;
71
+ const b_ = b.columns;
72
+ return mat3x3f(binaryComponentWise3f(op)(a_[0], b_[0]), binaryComponentWise3f(op)(a_[1], b_[1]), binaryComponentWise3f(op)(a_[2], b_[2]));
75
73
  };
76
74
  const binaryComponentWise4x4f = (op) => (a, b) => {
77
- const a_ = a.columns;
78
- const b_ = b.columns;
79
- return mat4x4f(binaryComponentWise4f(op)(a_[0], b_[0]), binaryComponentWise4f(op)(a_[1], b_[1]), binaryComponentWise4f(op)(a_[2], b_[2]), binaryComponentWise4f(op)(a_[3], b_[3]));
75
+ const a_ = a.columns;
76
+ const b_ = b.columns;
77
+ return mat4x4f(binaryComponentWise4f(op)(a_[0], b_[0]), binaryComponentWise4f(op)(a_[1], b_[1]), binaryComponentWise4f(op)(a_[2], b_[2]), binaryComponentWise4f(op)(a_[3], b_[3]));
80
78
  };
81
79
  const ternaryComponentWise2f = (op) => (a, b, c) => vec2f(op(a.x, b.x, c.x), op(a.y, b.y, c.y));
82
80
  const ternaryComponentWise2h = (op) => (a, b, c) => vec2h(op(a.x, b.x, c.x), op(a.y, b.y, c.y));
@@ -84,600 +82,614 @@ const ternaryComponentWise3f = (op) => (a, b, c) => vec3f(op(a.x, b.x, c.x), op(
84
82
  const ternaryComponentWise3h = (op) => (a, b, c) => vec3h(op(a.x, b.x, c.x), op(a.y, b.y, c.y), op(a.z, b.z, c.z));
85
83
  const ternaryComponentWise4f = (op) => (a, b, c) => vec4f(op(a.x, b.x, c.x), op(a.y, b.y, c.y), op(a.z, b.z, c.z), op(a.w, b.w, c.w));
86
84
  const ternaryComponentWise4h = (op) => (a, b, c) => vec4h(op(a.x, b.x, c.x), op(a.y, b.y, c.y), op(a.z, b.z, c.z), op(a.w, b.w, c.w));
87
- const VectorOps = {
88
- eq: {
89
- vec2f: (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
90
- vec2h: (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
91
- vec2i: (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
92
- vec2u: (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
93
- "vec2<bool>": (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
94
- vec3f: (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
95
- vec3h: (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
96
- vec3i: (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
97
- vec3u: (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
98
- "vec3<bool>": (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
99
- vec4f: (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w),
100
- vec4h: (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w),
101
- vec4i: (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w),
102
- vec4u: (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w),
103
- "vec4<bool>": (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w)
104
- },
105
- lt: {
106
- vec2f: (e1, e2) => vec2b(e1.x < e2.x, e1.y < e2.y),
107
- vec2h: (e1, e2) => vec2b(e1.x < e2.x, e1.y < e2.y),
108
- vec2i: (e1, e2) => vec2b(e1.x < e2.x, e1.y < e2.y),
109
- vec2u: (e1, e2) => vec2b(e1.x < e2.x, e1.y < e2.y),
110
- vec3f: (e1, e2) => vec3b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z),
111
- vec3h: (e1, e2) => vec3b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z),
112
- vec3i: (e1, e2) => vec3b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z),
113
- vec3u: (e1, e2) => vec3b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z),
114
- vec4f: (e1, e2) => vec4b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z, e1.w < e2.w),
115
- vec4h: (e1, e2) => vec4b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z, e1.w < e2.w),
116
- vec4i: (e1, e2) => vec4b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z, e1.w < e2.w),
117
- vec4u: (e1, e2) => vec4b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z, e1.w < e2.w)
118
- },
119
- or: {
120
- "vec2<bool>": (e1, e2) => vec2b(e1.x || e2.x, e1.y || e2.y),
121
- "vec3<bool>": (e1, e2) => vec3b(e1.x || e2.x, e1.y || e2.y, e1.z || e2.z),
122
- "vec4<bool>": (e1, e2) => vec4b(e1.x || e2.x, e1.y || e2.y, e1.z || e2.z, e1.w || e2.w)
123
- },
124
- all: {
125
- "vec2<bool>": (e) => e.x && e.y,
126
- "vec3<bool>": (e) => e.x && e.y && e.z,
127
- "vec4<bool>": (e) => e.x && e.y && e.z && e.w
128
- },
129
- abs: {
130
- vec2f: unary2f(Math.abs),
131
- vec2h: unary2h(Math.abs),
132
- vec2i: unary2i(Math.abs),
133
- vec2u: unary2u(Math.abs),
134
- vec3f: unary3f(Math.abs),
135
- vec3h: unary3h(Math.abs),
136
- vec3i: unary3i(Math.abs),
137
- vec3u: unary3u(Math.abs),
138
- vec4f: unary4f(Math.abs),
139
- vec4h: unary4h(Math.abs),
140
- vec4i: unary4i(Math.abs),
141
- vec4u: unary4u(Math.abs)
142
- },
143
- atan2: {
144
- vec2f: binaryComponentWise2f(Math.atan2),
145
- vec2h: binaryComponentWise2h(Math.atan2),
146
- vec3f: binaryComponentWise3f(Math.atan2),
147
- vec3h: binaryComponentWise3h(Math.atan2),
148
- vec4f: binaryComponentWise4f(Math.atan2),
149
- vec4h: binaryComponentWise4h(Math.atan2)
150
- },
151
- acos: {
152
- vec2f: unary2f(Math.acos),
153
- vec2h: unary2h(Math.acos),
154
- vec2i: unary2i(Math.acos),
155
- vec2u: unary2u(Math.acos),
156
- vec3f: unary3f(Math.acos),
157
- vec3h: unary3h(Math.acos),
158
- vec3i: unary3i(Math.acos),
159
- vec3u: unary3u(Math.acos),
160
- vec4f: unary4f(Math.acos),
161
- vec4h: unary4h(Math.acos),
162
- vec4i: unary4i(Math.acos),
163
- vec4u: unary4u(Math.acos)
164
- },
165
- acosh: {
166
- vec2f: unary2f(Math.acosh),
167
- vec2h: unary2h(Math.acosh),
168
- vec3f: unary3f(Math.acosh),
169
- vec3h: unary3h(Math.acosh),
170
- vec4f: unary4f(Math.acosh),
171
- vec4h: unary4h(Math.acosh)
172
- },
173
- asin: {
174
- vec2f: unary2f(Math.asin),
175
- vec2h: unary2h(Math.asin),
176
- vec3f: unary3f(Math.asin),
177
- vec3h: unary3h(Math.asin),
178
- vec4f: unary4f(Math.asin),
179
- vec4h: unary4h(Math.asin)
180
- },
181
- asinh: {
182
- vec2f: unary2f(Math.asinh),
183
- vec2h: unary2h(Math.asinh),
184
- vec3f: unary3f(Math.asinh),
185
- vec3h: unary3h(Math.asinh),
186
- vec4f: unary4f(Math.asinh),
187
- vec4h: unary4h(Math.asinh)
188
- },
189
- atan: {
190
- vec2f: unary2f(Math.atan),
191
- vec2h: unary2h(Math.atan),
192
- vec3f: unary3f(Math.atan),
193
- vec3h: unary3h(Math.atan),
194
- vec4f: unary4f(Math.atan),
195
- vec4h: unary4h(Math.atan)
196
- },
197
- atanh: {
198
- vec2f: unary2f(Math.atanh),
199
- vec2h: unary2h(Math.atanh),
200
- vec3f: unary3f(Math.atanh),
201
- vec3h: unary3h(Math.atanh),
202
- vec4f: unary4f(Math.atanh),
203
- vec4h: unary4h(Math.atanh)
204
- },
205
- ceil: {
206
- vec2f: unary2f(Math.ceil),
207
- vec2h: unary2h(Math.ceil),
208
- vec3f: unary3f(Math.ceil),
209
- vec3h: unary3h(Math.ceil),
210
- vec4f: unary4f(Math.ceil),
211
- vec4h: unary4h(Math.ceil)
212
- },
213
- clamp: {
214
- vec2f: (v, low, high) => vec2f(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
215
- vec2h: (v, low, high) => vec2h(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
216
- vec2i: (v, low, high) => vec2i(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
217
- vec2u: (v, low, high) => vec2u(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
218
- vec3f: (v, low, high) => vec3f(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z)),
219
- vec3h: (v, low, high) => vec3h(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z)),
220
- vec3i: (v, low, high) => vec3i(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z)),
221
- vec3u: (v, low, high) => vec3u(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z)),
222
- vec4f: (v, low, high) => vec4f(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z), clamp(v.w, low.w, high.w)),
223
- vec4h: (v, low, high) => vec4h(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z), clamp(v.w, low.w, high.w)),
224
- vec4i: (v, low, high) => vec4i(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z), clamp(v.w, low.w, high.w)),
225
- vec4u: (v, low, high) => vec4u(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z), clamp(v.w, low.w, high.w))
226
- },
227
- length: {
228
- vec2f: lengthVec2,
229
- vec2h: lengthVec2,
230
- vec3f: lengthVec3,
231
- vec3h: lengthVec3,
232
- vec4f: lengthVec4,
233
- vec4h: lengthVec4
234
- },
235
- add: {
236
- vec2f: binaryComponentWise2f((a, b) => a + b),
237
- vec2h: binaryComponentWise2h((a, b) => a + b),
238
- vec2i: binaryComponentWise2i((a, b) => a + b),
239
- vec2u: binaryComponentWise2u((a, b) => a + b),
240
- vec3f: binaryComponentWise3f((a, b) => a + b),
241
- vec3h: binaryComponentWise3h((a, b) => a + b),
242
- vec3i: binaryComponentWise3i((a, b) => a + b),
243
- vec3u: binaryComponentWise3u((a, b) => a + b),
244
- vec4f: binaryComponentWise4f((a, b) => a + b),
245
- vec4h: binaryComponentWise4h((a, b) => a + b),
246
- vec4i: binaryComponentWise4i((a, b) => a + b),
247
- vec4u: binaryComponentWise4u((a, b) => a + b),
248
- mat2x2f: binaryComponentWise2x2f((a, b) => a + b),
249
- mat3x3f: binaryComponentWise3x3f((a, b) => a + b),
250
- mat4x4f: binaryComponentWise4x4f((a, b) => a + b)
251
- },
252
- smoothstep: {
253
- vec2f: ternaryComponentWise2f(smoothstepScalar),
254
- vec2h: ternaryComponentWise2h(smoothstepScalar),
255
- vec3f: ternaryComponentWise3f(smoothstepScalar),
256
- vec3h: ternaryComponentWise3h(smoothstepScalar),
257
- vec4f: ternaryComponentWise4f(smoothstepScalar),
258
- vec4h: ternaryComponentWise4h(smoothstepScalar)
259
- },
260
- addMixed: {
261
- vec2f: (a, b) => unary2f((e) => e + b)(a),
262
- vec2h: (a, b) => unary2h((e) => e + b)(a),
263
- vec2i: (a, b) => unary2i((e) => e + b)(a),
264
- vec2u: (a, b) => unary2u((e) => e + b)(a),
265
- vec3f: (a, b) => unary3f((e) => e + b)(a),
266
- vec3h: (a, b) => unary3h((e) => e + b)(a),
267
- vec3i: (a, b) => unary3i((e) => e + b)(a),
268
- vec3u: (a, b) => unary3u((e) => e + b)(a),
269
- vec4f: (a, b) => unary4f((e) => e + b)(a),
270
- vec4h: (a, b) => unary4h((e) => e + b)(a),
271
- vec4i: (a, b) => unary4i((e) => e + b)(a),
272
- vec4u: (a, b) => unary4u((e) => e + b)(a),
273
- mat2x2f: (a, b) => unary2x2f((e) => e + b)(a),
274
- mat3x3f: (a, b) => unary3x3f((e) => e + b)(a),
275
- mat4x4f: (a, b) => unary4x4f((e) => e + b)(a)
276
- },
277
- mulSxV: {
278
- vec2f: (s, v) => unary2f((e) => s * e)(v),
279
- vec2h: (s, v) => unary2h((e) => s * e)(v),
280
- vec2i: (s, v) => unary2i((e) => s * e)(v),
281
- vec2u: (s, v) => unary2u((e) => s * e)(v),
282
- vec3f: (s, v) => unary3f((e) => s * e)(v),
283
- vec3h: (s, v) => unary3h((e) => s * e)(v),
284
- vec3i: (s, v) => unary3i((e) => s * e)(v),
285
- vec3u: (s, v) => unary3u((e) => s * e)(v),
286
- vec4f: (s, v) => unary4f((e) => s * e)(v),
287
- vec4h: (s, v) => unary4h((e) => s * e)(v),
288
- vec4i: (s, v) => unary4i((e) => s * e)(v),
289
- vec4u: (s, v) => unary4u((e) => s * e)(v),
290
- mat2x2f: (s, m) => unary2x2f((e) => s * e)(m),
291
- mat3x3f: (s, m) => unary3x3f((e) => s * e)(m),
292
- mat4x4f: (s, m) => unary4x4f((e) => s * e)(m)
293
- },
294
- mulVxV: {
295
- vec2f: binaryComponentWise2f((a, b) => a * b),
296
- vec2h: binaryComponentWise2h((a, b) => a * b),
297
- vec2i: binaryComponentWise2i((a, b) => a * b),
298
- vec2u: binaryComponentWise2u((a, b) => a * b),
299
- vec3f: binaryComponentWise3f((a, b) => a * b),
300
- vec3h: binaryComponentWise3h((a, b) => a * b),
301
- vec3i: binaryComponentWise3i((a, b) => a * b),
302
- vec3u: binaryComponentWise3u((a, b) => a * b),
303
- vec4f: binaryComponentWise4f((a, b) => a * b),
304
- vec4h: binaryComponentWise4h((a, b) => a * b),
305
- vec4i: binaryComponentWise4i((a, b) => a * b),
306
- vec4u: binaryComponentWise4u((a, b) => a * b),
307
- mat2x2f: (a, b) => {
308
- const a_ = a.columns;
309
- const b_ = b.columns;
310
- return mat2x2f(a_[0].x * b_[0].x + a_[1].x * b_[0].y, a_[0].y * b_[0].x + a_[1].y * b_[0].y, a_[0].x * b_[1].x + a_[1].x * b_[1].y, a_[0].y * b_[1].x + a_[1].y * b_[1].y);
311
- },
312
- mat3x3f: (a, b) => {
313
- const a_ = a.columns;
314
- const b_ = b.columns;
315
- return mat3x3f(a_[0].x * b_[0].x + a_[1].x * b_[0].y + a_[2].x * b_[0].z, a_[0].y * b_[0].x + a_[1].y * b_[0].y + a_[2].y * b_[0].z, a_[0].z * b_[0].x + a_[1].z * b_[0].y + a_[2].z * b_[0].z, a_[0].x * b_[1].x + a_[1].x * b_[1].y + a_[2].x * b_[1].z, a_[0].y * b_[1].x + a_[1].y * b_[1].y + a_[2].y * b_[1].z, a_[0].z * b_[1].x + a_[1].z * b_[1].y + a_[2].z * b_[1].z, a_[0].x * b_[2].x + a_[1].x * b_[2].y + a_[2].x * b_[2].z, a_[0].y * b_[2].x + a_[1].y * b_[2].y + a_[2].y * b_[2].z, a_[0].z * b_[2].x + a_[1].z * b_[2].y + a_[2].z * b_[2].z);
316
- },
317
- mat4x4f: (a, b) => {
318
- const a_ = a.columns;
319
- const b_ = b.columns;
320
- return mat4x4f(a_[0].x * b_[0].x + a_[1].x * b_[0].y + a_[2].x * b_[0].z + a_[3].x * b_[0].w, a_[0].y * b_[0].x + a_[1].y * b_[0].y + a_[2].y * b_[0].z + a_[3].y * b_[0].w, a_[0].z * b_[0].x + a_[1].z * b_[0].y + a_[2].z * b_[0].z + a_[3].z * b_[0].w, a_[0].w * b_[0].x + a_[1].w * b_[0].y + a_[2].w * b_[0].z + a_[3].w * b_[0].w, a_[0].x * b_[1].x + a_[1].x * b_[1].y + a_[2].x * b_[1].z + a_[3].x * b_[1].w, a_[0].y * b_[1].x + a_[1].y * b_[1].y + a_[2].y * b_[1].z + a_[3].y * b_[1].w, a_[0].z * b_[1].x + a_[1].z * b_[1].y + a_[2].z * b_[1].z + a_[3].z * b_[1].w, a_[0].w * b_[1].x + a_[1].w * b_[1].y + a_[2].w * b_[1].z + a_[3].w * b_[1].w, a_[0].x * b_[2].x + a_[1].x * b_[2].y + a_[2].x * b_[2].z + a_[3].x * b_[2].w, a_[0].y * b_[2].x + a_[1].y * b_[2].y + a_[2].y * b_[2].z + a_[3].y * b_[2].w, a_[0].z * b_[2].x + a_[1].z * b_[2].y + a_[2].z * b_[2].z + a_[3].z * b_[2].w, a_[0].w * b_[2].x + a_[1].w * b_[2].y + a_[2].w * b_[2].z + a_[3].w * b_[2].w, a_[0].x * b_[3].x + a_[1].x * b_[3].y + a_[2].x * b_[3].z + a_[3].x * b_[3].w, a_[0].y * b_[3].x + a_[1].y * b_[3].y + a_[2].y * b_[3].z + a_[3].y * b_[3].w, a_[0].z * b_[3].x + a_[1].z * b_[3].y + a_[2].z * b_[3].z + a_[3].z * b_[3].w, a_[0].w * b_[3].x + a_[1].w * b_[3].y + a_[2].w * b_[3].z + a_[3].w * b_[3].w);
321
- }
322
- },
323
- mulMxV: {
324
- mat2x2f: (m, v) => {
325
- const m_ = m.columns;
326
- return vec2f(m_[0].x * v.x + m_[1].x * v.y, m_[0].y * v.x + m_[1].y * v.y);
327
- },
328
- mat3x3f: (m, v) => {
329
- const m_ = m.columns;
330
- return vec3f(m_[0].x * v.x + m_[1].x * v.y + m_[2].x * v.z, m_[0].y * v.x + m_[1].y * v.y + m_[2].y * v.z, m_[0].z * v.x + m_[1].z * v.y + m_[2].z * v.z);
331
- },
332
- mat4x4f: (m, v) => {
333
- const m_ = m.columns;
334
- return vec4f(m_[0].x * v.x + m_[1].x * v.y + m_[2].x * v.z + m_[3].x * v.w, m_[0].y * v.x + m_[1].y * v.y + m_[2].y * v.z + m_[3].y * v.w, m_[0].z * v.x + m_[1].z * v.y + m_[2].z * v.z + m_[3].z * v.w, m_[0].w * v.x + m_[1].w * v.y + m_[2].w * v.z + m_[3].w * v.w);
335
- }
336
- },
337
- mulVxM: {
338
- mat2x2f: (v, m) => {
339
- const m_ = m.columns;
340
- return vec2f(v.x * m_[0].x + v.y * m_[0].y, v.x * m_[1].x + v.y * m_[1].y);
341
- },
342
- mat3x3f: (v, m) => {
343
- const m_ = m.columns;
344
- return vec3f(v.x * m_[0].x + v.y * m_[0].y + v.z * m_[0].z, v.x * m_[1].x + v.y * m_[1].y + v.z * m_[1].z, v.x * m_[2].x + v.y * m_[2].y + v.z * m_[2].z);
345
- },
346
- mat4x4f: (v, m) => {
347
- const m_ = m.columns;
348
- return vec4f(v.x * m_[0].x + v.y * m_[0].y + v.z * m_[0].z + v.w * m_[0].w, v.x * m_[1].x + v.y * m_[1].y + v.z * m_[1].z + v.w * m_[1].w, v.x * m_[2].x + v.y * m_[2].y + v.z * m_[2].z + v.w * m_[2].w, v.x * m_[3].x + v.y * m_[3].y + v.z * m_[3].z + v.w * m_[3].w);
349
- }
350
- },
351
- div: {
352
- vec2f: binaryComponentWise2f((a, b) => a / b),
353
- vec2h: binaryComponentWise2h((a, b) => a / b),
354
- vec2i: binaryComponentWise2i(divInteger),
355
- vec2u: binaryComponentWise2u(divInteger),
356
- vec3f: binaryComponentWise3f((a, b) => a / b),
357
- vec3h: binaryComponentWise3h((a, b) => a / b),
358
- vec3i: binaryComponentWise3i(divInteger),
359
- vec3u: binaryComponentWise3u(divInteger),
360
- vec4f: binaryComponentWise4f((a, b) => a / b),
361
- vec4h: binaryComponentWise4h((a, b) => a / b),
362
- vec4i: binaryComponentWise4i(divInteger),
363
- vec4u: binaryComponentWise4u(divInteger)
364
- },
365
- dot: {
366
- vec2f: dotVec2,
367
- vec2h: dotVec2,
368
- vec2i: dotVec2,
369
- vec2u: dotVec2,
370
- vec3f: dotVec3,
371
- vec3h: dotVec3,
372
- vec3i: dotVec3,
373
- vec3u: dotVec3,
374
- vec4f: dotVec4,
375
- vec4h: dotVec4,
376
- vec4i: dotVec4,
377
- vec4u: dotVec4
378
- },
379
- normalize: {
380
- vec2f: (v) => {
381
- const len = lengthVec2(v);
382
- return vec2f(v.x / len, v.y / len);
383
- },
384
- vec2h: (v) => {
385
- const len = lengthVec2(v);
386
- return vec2h(v.x / len, v.y / len);
387
- },
388
- vec2i: (v) => {
389
- const len = lengthVec2(v);
390
- return vec2i(v.x / len, v.y / len);
391
- },
392
- vec2u: (v) => {
393
- const len = lengthVec2(v);
394
- return vec2u(v.x / len, v.y / len);
395
- },
396
- vec3f: (v) => {
397
- const len = lengthVec3(v);
398
- return vec3f(v.x / len, v.y / len, v.z / len);
399
- },
400
- vec3h: (v) => {
401
- const len = lengthVec3(v);
402
- return vec3h(v.x / len, v.y / len, v.z / len);
403
- },
404
- vec3i: (v) => {
405
- const len = lengthVec3(v);
406
- return vec3i(v.x / len, v.y / len, v.z / len);
407
- },
408
- vec3u: (v) => {
409
- const len = lengthVec3(v);
410
- return vec3u(v.x / len, v.y / len, v.z / len);
411
- },
412
- vec4f: (v) => {
413
- const len = lengthVec4(v);
414
- return vec4f(v.x / len, v.y / len, v.z / len, v.w / len);
415
- },
416
- vec4h: (v) => {
417
- const len = lengthVec4(v);
418
- return vec4h(v.x / len, v.y / len, v.z / len, v.w / len);
419
- },
420
- vec4i: (v) => {
421
- const len = lengthVec4(v);
422
- return vec4i(v.x / len, v.y / len, v.z / len, v.w / len);
423
- },
424
- vec4u: (v) => {
425
- const len = lengthVec4(v);
426
- return vec4u(v.x / len, v.y / len, v.z / len, v.w / len);
427
- }
428
- },
429
- cross: {
430
- vec3f: (a, b) => {
431
- return vec3f(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
432
- },
433
- vec3h: (a, b) => {
434
- return vec3h(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
435
- }
436
- },
437
- mod: {
438
- vec2f: binaryComponentWise2f((a, b) => a % b),
439
- vec2h: binaryComponentWise2h((a, b) => a % b),
440
- vec2i: binaryComponentWise2i((a, b) => a % b),
441
- vec2u: binaryComponentWise2u((a, b) => a % b),
442
- vec3f: binaryComponentWise3f((a, b) => a % b),
443
- vec3h: binaryComponentWise3h((a, b) => a % b),
444
- vec3i: binaryComponentWise3i((a, b) => a % b),
445
- vec3u: binaryComponentWise3u((a, b) => a % b),
446
- vec4f: binaryComponentWise4f((a, b) => a % b),
447
- vec4h: binaryComponentWise4h((a, b) => a % b),
448
- vec4i: binaryComponentWise4i((a, b) => a % b),
449
- vec4u: binaryComponentWise4u((a, b) => a % b)
450
- },
451
- floor: {
452
- vec2f: unary2f(Math.floor),
453
- vec2h: unary2h(Math.floor),
454
- vec3f: unary3f(Math.floor),
455
- vec3h: unary3h(Math.floor),
456
- vec4f: unary4f(Math.floor),
457
- vec4h: unary4h(Math.floor)
458
- },
459
- max: {
460
- vec2f: binaryComponentWise2f(Math.max),
461
- vec2h: binaryComponentWise2h(Math.max),
462
- vec2i: binaryComponentWise2i(Math.max),
463
- vec2u: binaryComponentWise2u(Math.max),
464
- vec3f: binaryComponentWise3f(Math.max),
465
- vec3h: binaryComponentWise3h(Math.max),
466
- vec3i: binaryComponentWise3i(Math.max),
467
- vec3u: binaryComponentWise3u(Math.max),
468
- vec4f: binaryComponentWise4f(Math.max),
469
- vec4h: binaryComponentWise4h(Math.max),
470
- vec4i: binaryComponentWise4i(Math.max),
471
- vec4u: binaryComponentWise4u(Math.max)
472
- },
473
- min: {
474
- vec2f: binaryComponentWise2f(Math.min),
475
- vec2h: binaryComponentWise2h(Math.min),
476
- vec2i: binaryComponentWise2i(Math.min),
477
- vec2u: binaryComponentWise2u(Math.min),
478
- vec3f: binaryComponentWise3f(Math.min),
479
- vec3h: binaryComponentWise3h(Math.min),
480
- vec3i: binaryComponentWise3i(Math.min),
481
- vec3u: binaryComponentWise3u(Math.min),
482
- vec4f: binaryComponentWise4f(Math.min),
483
- vec4h: binaryComponentWise4h(Math.min),
484
- vec4i: binaryComponentWise4i(Math.min),
485
- vec4u: binaryComponentWise4u(Math.min)
486
- },
487
- pow: {
488
- vec2f: (base, exponent) => vec2f(base.x ** exponent.x, base.y ** exponent.y),
489
- vec2h: (base, exponent) => vec2h(base.x ** exponent.x, base.y ** exponent.y),
490
- vec3f: (base, exponent) => vec3f(base.x ** exponent.x, base.y ** exponent.y, base.z ** exponent.z),
491
- vec3h: (base, exponent) => vec3h(base.x ** exponent.x, base.y ** exponent.y, base.z ** exponent.z),
492
- vec4f: (base, exponent) => vec4f(base.x ** exponent.x, base.y ** exponent.y, base.z ** exponent.z, base.w ** exponent.w),
493
- vec4h: (base, exponent) => vec4h(base.x ** exponent.x, base.y ** exponent.y, base.z ** exponent.z, base.w ** exponent.w)
494
- },
495
- sign: {
496
- vec2f: unary2f(Math.sign),
497
- vec2h: unary2h(Math.sign),
498
- vec2i: unary2i(Math.sign),
499
- vec3f: unary3f(Math.sign),
500
- vec3h: unary3h(Math.sign),
501
- vec3i: unary3i(Math.sign),
502
- vec4f: unary4f(Math.sign),
503
- vec4h: unary4h(Math.sign),
504
- vec4i: unary4i(Math.sign)
505
- },
506
- sqrt: {
507
- vec2f: unary2f(Math.sqrt),
508
- vec2h: unary2h(Math.sqrt),
509
- vec3f: unary3f(Math.sqrt),
510
- vec3h: unary3h(Math.sqrt),
511
- vec4f: unary4f(Math.sqrt),
512
- vec4h: unary4h(Math.sqrt)
513
- },
514
- mix: {
515
- vec2f: (e1, e2, e3) => {
516
- if (typeof e3 === "number") return vec2f(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3);
517
- return vec2f(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y);
518
- },
519
- vec2h: (e1, e2, e3) => {
520
- if (typeof e3 === "number") return vec2h(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3);
521
- return vec2h(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y);
522
- },
523
- vec3f: (e1, e2, e3) => {
524
- if (typeof e3 === "number") return vec3f(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3, e1.z * (1 - e3) + e2.z * e3);
525
- return vec3f(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y, e1.z * (1 - e3.z) + e2.z * e3.z);
526
- },
527
- vec3h: (e1, e2, e3) => {
528
- if (typeof e3 === "number") return vec3h(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3, e1.z * (1 - e3) + e2.z * e3);
529
- return vec3h(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y, e1.z * (1 - e3.z) + e2.z * e3.z);
530
- },
531
- vec4f: (e1, e2, e3) => {
532
- if (typeof e3 === "number") return vec4f(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3, e1.z * (1 - e3) + e2.z * e3, e1.w * (1 - e3) + e2.w * e3);
533
- return vec4f(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y, e1.z * (1 - e3.z) + e2.z * e3.z, e1.w * (1 - e3.w) + e2.w * e3.w);
534
- },
535
- vec4h: (e1, e2, e3) => {
536
- if (typeof e3 === "number") return vec4h(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3, e1.z * (1 - e3) + e2.z * e3, e1.w * (1 - e3) + e2.w * e3);
537
- return vec4h(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y, e1.z * (1 - e3.z) + e2.z * e3.z, e1.w * (1 - e3.w) + e2.w * e3.w);
538
- }
539
- },
540
- sin: {
541
- vec2f: unary2f(Math.sin),
542
- vec2h: unary2h(Math.sin),
543
- vec3f: unary3f(Math.sin),
544
- vec3h: unary3h(Math.sin),
545
- vec4f: unary4f(Math.sin),
546
- vec4h: unary4h(Math.sin)
547
- },
548
- cos: {
549
- vec2f: unary2f(Math.cos),
550
- vec2h: unary2h(Math.cos),
551
- vec3f: unary3f(Math.cos),
552
- vec3h: unary3h(Math.cos),
553
- vec4f: unary4f(Math.cos),
554
- vec4h: unary4h(Math.cos)
555
- },
556
- cosh: {
557
- vec2f: unary2f(Math.cosh),
558
- vec2h: unary2h(Math.cosh),
559
- vec3f: unary3f(Math.cosh),
560
- vec3h: unary3h(Math.cosh),
561
- vec4f: unary4f(Math.cosh),
562
- vec4h: unary4h(Math.cosh)
563
- },
564
- exp: {
565
- vec2f: unary2f(Math.exp),
566
- vec2h: unary2h(Math.exp),
567
- vec3f: unary3f(Math.exp),
568
- vec3h: unary3h(Math.exp),
569
- vec4f: unary4f(Math.exp),
570
- vec4h: unary4h(Math.exp)
571
- },
572
- exp2: {
573
- vec2f: unary2f((val) => 2 ** val),
574
- vec2h: unary2h((val) => 2 ** val),
575
- vec3f: unary3f((val) => 2 ** val),
576
- vec3h: unary3h((val) => 2 ** val),
577
- vec4f: unary4f((val) => 2 ** val),
578
- vec4h: unary4h((val) => 2 ** val)
579
- },
580
- log: {
581
- vec2f: unary2f(Math.log),
582
- vec2h: unary2h(Math.log),
583
- vec3f: unary3f(Math.log),
584
- vec3h: unary3h(Math.log),
585
- vec4f: unary4f(Math.log),
586
- vec4h: unary4h(Math.log)
587
- },
588
- log2: {
589
- vec2f: unary2f(Math.log2),
590
- vec2h: unary2h(Math.log2),
591
- vec3f: unary3f(Math.log2),
592
- vec3h: unary3h(Math.log2),
593
- vec4f: unary4f(Math.log2),
594
- vec4h: unary4h(Math.log2)
595
- },
596
- fract: {
597
- vec2f: unary2f((value) => value - Math.floor(value)),
598
- vec2h: unary2h((value) => value - Math.floor(value)),
599
- vec3f: unary3f((value) => value - Math.floor(value)),
600
- vec3h: unary3h((value) => value - Math.floor(value)),
601
- vec4f: unary4f((value) => value - Math.floor(value)),
602
- vec4h: unary4h((value) => value - Math.floor(value))
603
- },
604
- isCloseToZero: {
605
- vec2f: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n,
606
- vec2h: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n,
607
- vec3f: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n && Math.abs(v.z) <= n,
608
- vec3h: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n && Math.abs(v.z) <= n,
609
- vec4f: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n && Math.abs(v.z) <= n && Math.abs(v.w) <= n,
610
- vec4h: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n && Math.abs(v.z) <= n && Math.abs(v.w) <= n
611
- },
612
- neg: {
613
- vec2f: unary2f((value) => -value),
614
- vec2h: unary2h((value) => -value),
615
- vec2i: unary2i((value) => -value),
616
- vec2u: unary2u((value) => -value),
617
- "vec2<bool>": (e) => vec2b(!e.x, !e.y),
618
- vec3f: unary3f((value) => -value),
619
- vec3h: unary3h((value) => -value),
620
- vec3i: unary3i((value) => -value),
621
- vec3u: unary3u((value) => -value),
622
- "vec3<bool>": (e) => vec3b(!e.x, !e.y, !e.z),
623
- vec4f: unary4f((value) => -value),
624
- vec4h: unary4h((value) => -value),
625
- vec4i: unary4i((value) => -value),
626
- vec4u: unary4u((value) => -value),
627
- "vec4<bool>": (e) => vec4b(!e.x, !e.y, !e.z, !e.w)
628
- },
629
- select: {
630
- vec2f: (f, t, c) => vec2f(c.x ? t.x : f.x, c.y ? t.y : f.y),
631
- vec2h: (f, t, c) => vec2h(c.x ? t.x : f.x, c.y ? t.y : f.y),
632
- vec2i: (f, t, c) => vec2i(c.x ? t.x : f.x, c.y ? t.y : f.y),
633
- vec2u: (f, t, c) => vec2u(c.x ? t.x : f.x, c.y ? t.y : f.y),
634
- "vec2<bool>": (f, t, c) => vec2b(c.x ? t.x : f.x, c.y ? t.y : f.y),
635
- vec3f: (f, t, c) => vec3f(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
636
- vec3h: (f, t, c) => vec3h(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
637
- vec3i: (f, t, c) => vec3i(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
638
- vec3u: (f, t, c) => vec3u(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
639
- "vec3<bool>": (f, t, c) => vec3b(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
640
- vec4f: (f, t, c) => vec4f(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w),
641
- vec4h: (f, t, c) => vec4h(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w),
642
- vec4i: (f, t, c) => vec4i(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w),
643
- vec4u: (f, t, c) => vec4u(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w),
644
- "vec4<bool>": (f, t, c) => vec4b(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w)
645
- },
646
- tanh: {
647
- vec2f: unary2f(Math.tanh),
648
- vec2h: unary2h(Math.tanh),
649
- vec3f: unary3f(Math.tanh),
650
- vec3h: unary3h(Math.tanh),
651
- vec4f: unary4f(Math.tanh),
652
- vec4h: unary4h(Math.tanh)
653
- },
654
- bitShiftLeft: {
655
- vec2i: binaryComponentWise2i2u((a, b) => a << b),
656
- vec2u: binaryComponentWise2u((a, b) => a << b),
657
- vec3i: binaryComponentWise3i3u((a, b) => a << b),
658
- vec3u: binaryComponentWise3u((a, b) => a << b),
659
- vec4i: binaryComponentWise4i4u((a, b) => a << b),
660
- vec4u: binaryComponentWise4u((a, b) => a << b)
661
- },
662
- bitShiftRight: {
663
- vec2i: binaryComponentWise2i2u((a, b) => a >> b),
664
- vec2u: binaryComponentWise2u((a, b) => a >> b),
665
- vec3i: binaryComponentWise3i3u((a, b) => a >> b),
666
- vec3u: binaryComponentWise3u((a, b) => a >> b),
667
- vec4i: binaryComponentWise4i4u((a, b) => a >> b),
668
- vec4u: binaryComponentWise4u((a, b) => a >> b)
669
- },
670
- bitcastU32toF32: {
671
- vec2u: (n) => vec2f(bitcastU32toF32Impl(n.x), bitcastU32toF32Impl(n.y)),
672
- vec3u: (n) => vec3f(bitcastU32toF32Impl(n.x), bitcastU32toF32Impl(n.y), bitcastU32toF32Impl(n.z)),
673
- vec4u: (n) => vec4f(bitcastU32toF32Impl(n.x), bitcastU32toF32Impl(n.y), bitcastU32toF32Impl(n.z), bitcastU32toF32Impl(n.w))
674
- },
675
- bitcastU32toI32: {
676
- vec2u: (n) => vec2i(bitcastU32toI32Impl(n.x), bitcastU32toI32Impl(n.y)),
677
- vec3u: (n) => vec3i(bitcastU32toI32Impl(n.x), bitcastU32toI32Impl(n.y), bitcastU32toI32Impl(n.z)),
678
- vec4u: (n) => vec4i(bitcastU32toI32Impl(n.x), bitcastU32toI32Impl(n.y), bitcastU32toI32Impl(n.z), bitcastU32toI32Impl(n.w))
679
- }
85
+ export const VectorOps = {
86
+ eq: {
87
+ vec2f: (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
88
+ vec2h: (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
89
+ vec2i: (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
90
+ vec2u: (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
91
+ 'vec2<bool>': (e1, e2) => vec2b(e1.x === e2.x, e1.y === e2.y),
92
+ vec3f: (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
93
+ vec3h: (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
94
+ vec3i: (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
95
+ vec3u: (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
96
+ 'vec3<bool>': (e1, e2) => vec3b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z),
97
+ vec4f: (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w),
98
+ vec4h: (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w),
99
+ vec4i: (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w),
100
+ vec4u: (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w),
101
+ 'vec4<bool>': (e1, e2) => vec4b(e1.x === e2.x, e1.y === e2.y, e1.z === e2.z, e1.w === e2.w),
102
+ },
103
+ lt: {
104
+ vec2f: (e1, e2) => vec2b(e1.x < e2.x, e1.y < e2.y),
105
+ vec2h: (e1, e2) => vec2b(e1.x < e2.x, e1.y < e2.y),
106
+ vec2i: (e1, e2) => vec2b(e1.x < e2.x, e1.y < e2.y),
107
+ vec2u: (e1, e2) => vec2b(e1.x < e2.x, e1.y < e2.y),
108
+ vec3f: (e1, e2) => vec3b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z),
109
+ vec3h: (e1, e2) => vec3b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z),
110
+ vec3i: (e1, e2) => vec3b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z),
111
+ vec3u: (e1, e2) => vec3b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z),
112
+ vec4f: (e1, e2) => vec4b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z, e1.w < e2.w),
113
+ vec4h: (e1, e2) => vec4b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z, e1.w < e2.w),
114
+ vec4i: (e1, e2) => vec4b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z, e1.w < e2.w),
115
+ vec4u: (e1, e2) => vec4b(e1.x < e2.x, e1.y < e2.y, e1.z < e2.z, e1.w < e2.w),
116
+ },
117
+ or: {
118
+ 'vec2<bool>': (e1, e2) => vec2b(e1.x || e2.x, e1.y || e2.y),
119
+ 'vec3<bool>': (e1, e2) => vec3b(e1.x || e2.x, e1.y || e2.y, e1.z || e2.z),
120
+ 'vec4<bool>': (e1, e2) => vec4b(e1.x || e2.x, e1.y || e2.y, e1.z || e2.z, e1.w || e2.w),
121
+ },
122
+ all: {
123
+ 'vec2<bool>': (e) => e.x && e.y,
124
+ 'vec3<bool>': (e) => e.x && e.y && e.z,
125
+ 'vec4<bool>': (e) => e.x && e.y && e.z && e.w,
126
+ },
127
+ abs: {
128
+ vec2f: unary2f(Math.abs),
129
+ vec2h: unary2h(Math.abs),
130
+ vec2i: unary2i(Math.abs),
131
+ vec2u: unary2u(Math.abs),
132
+ vec3f: unary3f(Math.abs),
133
+ vec3h: unary3h(Math.abs),
134
+ vec3i: unary3i(Math.abs),
135
+ vec3u: unary3u(Math.abs),
136
+ vec4f: unary4f(Math.abs),
137
+ vec4h: unary4h(Math.abs),
138
+ vec4i: unary4i(Math.abs),
139
+ vec4u: unary4u(Math.abs),
140
+ },
141
+ atan2: {
142
+ vec2f: binaryComponentWise2f(Math.atan2),
143
+ vec2h: binaryComponentWise2h(Math.atan2),
144
+ vec3f: binaryComponentWise3f(Math.atan2),
145
+ vec3h: binaryComponentWise3h(Math.atan2),
146
+ vec4f: binaryComponentWise4f(Math.atan2),
147
+ vec4h: binaryComponentWise4h(Math.atan2),
148
+ },
149
+ acos: {
150
+ vec2f: unary2f(Math.acos),
151
+ vec2h: unary2h(Math.acos),
152
+ vec2i: unary2i(Math.acos),
153
+ vec2u: unary2u(Math.acos),
154
+ vec3f: unary3f(Math.acos),
155
+ vec3h: unary3h(Math.acos),
156
+ vec3i: unary3i(Math.acos),
157
+ vec3u: unary3u(Math.acos),
158
+ vec4f: unary4f(Math.acos),
159
+ vec4h: unary4h(Math.acos),
160
+ vec4i: unary4i(Math.acos),
161
+ vec4u: unary4u(Math.acos),
162
+ },
163
+ acosh: {
164
+ vec2f: unary2f(Math.acosh),
165
+ vec2h: unary2h(Math.acosh),
166
+ vec3f: unary3f(Math.acosh),
167
+ vec3h: unary3h(Math.acosh),
168
+ vec4f: unary4f(Math.acosh),
169
+ vec4h: unary4h(Math.acosh),
170
+ },
171
+ asin: {
172
+ vec2f: unary2f(Math.asin),
173
+ vec2h: unary2h(Math.asin),
174
+ vec3f: unary3f(Math.asin),
175
+ vec3h: unary3h(Math.asin),
176
+ vec4f: unary4f(Math.asin),
177
+ vec4h: unary4h(Math.asin),
178
+ },
179
+ asinh: {
180
+ vec2f: unary2f(Math.asinh),
181
+ vec2h: unary2h(Math.asinh),
182
+ vec3f: unary3f(Math.asinh),
183
+ vec3h: unary3h(Math.asinh),
184
+ vec4f: unary4f(Math.asinh),
185
+ vec4h: unary4h(Math.asinh),
186
+ },
187
+ atan: {
188
+ vec2f: unary2f(Math.atan),
189
+ vec2h: unary2h(Math.atan),
190
+ vec3f: unary3f(Math.atan),
191
+ vec3h: unary3h(Math.atan),
192
+ vec4f: unary4f(Math.atan),
193
+ vec4h: unary4h(Math.atan),
194
+ },
195
+ atanh: {
196
+ vec2f: unary2f(Math.atanh),
197
+ vec2h: unary2h(Math.atanh),
198
+ vec3f: unary3f(Math.atanh),
199
+ vec3h: unary3h(Math.atanh),
200
+ vec4f: unary4f(Math.atanh),
201
+ vec4h: unary4h(Math.atanh),
202
+ },
203
+ ceil: {
204
+ vec2f: unary2f(Math.ceil),
205
+ vec2h: unary2h(Math.ceil),
206
+ vec3f: unary3f(Math.ceil),
207
+ vec3h: unary3h(Math.ceil),
208
+ vec4f: unary4f(Math.ceil),
209
+ vec4h: unary4h(Math.ceil),
210
+ },
211
+ clamp: {
212
+ vec2f: (v, low, high) => vec2f(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
213
+ vec2h: (v, low, high) => vec2h(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
214
+ vec2i: (v, low, high) => vec2i(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
215
+ vec2u: (v, low, high) => vec2u(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y)),
216
+ vec3f: (v, low, high) => vec3f(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z)),
217
+ vec3h: (v, low, high) => vec3h(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z)),
218
+ vec3i: (v, low, high) => vec3i(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z)),
219
+ vec3u: (v, low, high) => vec3u(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z)),
220
+ vec4f: (v, low, high) => vec4f(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z), clamp(v.w, low.w, high.w)),
221
+ vec4h: (v, low, high) => vec4h(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z), clamp(v.w, low.w, high.w)),
222
+ vec4i: (v, low, high) => vec4i(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z), clamp(v.w, low.w, high.w)),
223
+ vec4u: (v, low, high) => vec4u(clamp(v.x, low.x, high.x), clamp(v.y, low.y, high.y), clamp(v.z, low.z, high.z), clamp(v.w, low.w, high.w)),
224
+ },
225
+ length: {
226
+ vec2f: lengthVec2,
227
+ vec2h: lengthVec2,
228
+ vec3f: lengthVec3,
229
+ vec3h: lengthVec3,
230
+ vec4f: lengthVec4,
231
+ vec4h: lengthVec4,
232
+ },
233
+ add: {
234
+ vec2f: binaryComponentWise2f((a, b) => a + b),
235
+ vec2h: binaryComponentWise2h((a, b) => a + b),
236
+ vec2i: binaryComponentWise2i((a, b) => a + b),
237
+ vec2u: binaryComponentWise2u((a, b) => a + b),
238
+ vec3f: binaryComponentWise3f((a, b) => a + b),
239
+ vec3h: binaryComponentWise3h((a, b) => a + b),
240
+ vec3i: binaryComponentWise3i((a, b) => a + b),
241
+ vec3u: binaryComponentWise3u((a, b) => a + b),
242
+ vec4f: binaryComponentWise4f((a, b) => a + b),
243
+ vec4h: binaryComponentWise4h((a, b) => a + b),
244
+ vec4i: binaryComponentWise4i((a, b) => a + b),
245
+ vec4u: binaryComponentWise4u((a, b) => a + b),
246
+ mat2x2f: binaryComponentWise2x2f((a, b) => a + b),
247
+ mat3x3f: binaryComponentWise3x3f((a, b) => a + b),
248
+ mat4x4f: binaryComponentWise4x4f((a, b) => a + b),
249
+ },
250
+ smoothstep: {
251
+ vec2f: ternaryComponentWise2f(smoothstepScalar),
252
+ vec2h: ternaryComponentWise2h(smoothstepScalar),
253
+ vec3f: ternaryComponentWise3f(smoothstepScalar),
254
+ vec3h: ternaryComponentWise3h(smoothstepScalar),
255
+ vec4f: ternaryComponentWise4f(smoothstepScalar),
256
+ vec4h: ternaryComponentWise4h(smoothstepScalar),
257
+ },
258
+ addMixed: {
259
+ vec2f: (a, b) => unary2f((e) => e + b)(a),
260
+ vec2h: (a, b) => unary2h((e) => e + b)(a),
261
+ vec2i: (a, b) => unary2i((e) => e + b)(a),
262
+ vec2u: (a, b) => unary2u((e) => e + b)(a),
263
+ vec3f: (a, b) => unary3f((e) => e + b)(a),
264
+ vec3h: (a, b) => unary3h((e) => e + b)(a),
265
+ vec3i: (a, b) => unary3i((e) => e + b)(a),
266
+ vec3u: (a, b) => unary3u((e) => e + b)(a),
267
+ vec4f: (a, b) => unary4f((e) => e + b)(a),
268
+ vec4h: (a, b) => unary4h((e) => e + b)(a),
269
+ vec4i: (a, b) => unary4i((e) => e + b)(a),
270
+ vec4u: (a, b) => unary4u((e) => e + b)(a),
271
+ mat2x2f: (a, b) => unary2x2f((e) => e + b)(a),
272
+ mat3x3f: (a, b) => unary3x3f((e) => e + b)(a),
273
+ mat4x4f: (a, b) => unary4x4f((e) => e + b)(a),
274
+ },
275
+ mulSxV: {
276
+ vec2f: (s, v) => unary2f((e) => s * e)(v),
277
+ vec2h: (s, v) => unary2h((e) => s * e)(v),
278
+ vec2i: (s, v) => unary2i((e) => s * e)(v),
279
+ vec2u: (s, v) => unary2u((e) => s * e)(v),
280
+ vec3f: (s, v) => unary3f((e) => s * e)(v),
281
+ vec3h: (s, v) => unary3h((e) => s * e)(v),
282
+ vec3i: (s, v) => unary3i((e) => s * e)(v),
283
+ vec3u: (s, v) => unary3u((e) => s * e)(v),
284
+ vec4f: (s, v) => unary4f((e) => s * e)(v),
285
+ vec4h: (s, v) => unary4h((e) => s * e)(v),
286
+ vec4i: (s, v) => unary4i((e) => s * e)(v),
287
+ vec4u: (s, v) => unary4u((e) => s * e)(v),
288
+ mat2x2f: (s, m) => unary2x2f((e) => s * e)(m),
289
+ mat3x3f: (s, m) => unary3x3f((e) => s * e)(m),
290
+ mat4x4f: (s, m) => unary4x4f((e) => s * e)(m),
291
+ },
292
+ mulVxV: {
293
+ vec2f: binaryComponentWise2f((a, b) => a * b),
294
+ vec2h: binaryComponentWise2h((a, b) => a * b),
295
+ vec2i: binaryComponentWise2i((a, b) => a * b),
296
+ vec2u: binaryComponentWise2u((a, b) => a * b),
297
+ vec3f: binaryComponentWise3f((a, b) => a * b),
298
+ vec3h: binaryComponentWise3h((a, b) => a * b),
299
+ vec3i: binaryComponentWise3i((a, b) => a * b),
300
+ vec3u: binaryComponentWise3u((a, b) => a * b),
301
+ vec4f: binaryComponentWise4f((a, b) => a * b),
302
+ vec4h: binaryComponentWise4h((a, b) => a * b),
303
+ vec4i: binaryComponentWise4i((a, b) => a * b),
304
+ vec4u: binaryComponentWise4u((a, b) => a * b),
305
+ mat2x2f: (a, b) => {
306
+ const a_ = a.columns;
307
+ const b_ = b.columns;
308
+ return mat2x2f(a_[0].x * b_[0].x + a_[1].x * b_[0].y, a_[0].y * b_[0].x + a_[1].y * b_[0].y, a_[0].x * b_[1].x + a_[1].x * b_[1].y, a_[0].y * b_[1].x + a_[1].y * b_[1].y);
309
+ },
310
+ mat3x3f: (a, b) => {
311
+ const a_ = a.columns;
312
+ const b_ = b.columns;
313
+ return mat3x3f(a_[0].x * b_[0].x + a_[1].x * b_[0].y + a_[2].x * b_[0].z, a_[0].y * b_[0].x + a_[1].y * b_[0].y + a_[2].y * b_[0].z, a_[0].z * b_[0].x + a_[1].z * b_[0].y + a_[2].z * b_[0].z, a_[0].x * b_[1].x + a_[1].x * b_[1].y + a_[2].x * b_[1].z, a_[0].y * b_[1].x + a_[1].y * b_[1].y + a_[2].y * b_[1].z, a_[0].z * b_[1].x + a_[1].z * b_[1].y + a_[2].z * b_[1].z, a_[0].x * b_[2].x + a_[1].x * b_[2].y + a_[2].x * b_[2].z, a_[0].y * b_[2].x + a_[1].y * b_[2].y + a_[2].y * b_[2].z, a_[0].z * b_[2].x + a_[1].z * b_[2].y + a_[2].z * b_[2].z);
314
+ },
315
+ mat4x4f: (a, b) => {
316
+ const a_ = a.columns;
317
+ const b_ = b.columns;
318
+ return mat4x4f(a_[0].x * b_[0].x + a_[1].x * b_[0].y + a_[2].x * b_[0].z + a_[3].x * b_[0].w, a_[0].y * b_[0].x + a_[1].y * b_[0].y + a_[2].y * b_[0].z + a_[3].y * b_[0].w, a_[0].z * b_[0].x + a_[1].z * b_[0].y + a_[2].z * b_[0].z + a_[3].z * b_[0].w, a_[0].w * b_[0].x + a_[1].w * b_[0].y + a_[2].w * b_[0].z + a_[3].w * b_[0].w, a_[0].x * b_[1].x + a_[1].x * b_[1].y + a_[2].x * b_[1].z + a_[3].x * b_[1].w, a_[0].y * b_[1].x + a_[1].y * b_[1].y + a_[2].y * b_[1].z + a_[3].y * b_[1].w, a_[0].z * b_[1].x + a_[1].z * b_[1].y + a_[2].z * b_[1].z + a_[3].z * b_[1].w, a_[0].w * b_[1].x + a_[1].w * b_[1].y + a_[2].w * b_[1].z + a_[3].w * b_[1].w, a_[0].x * b_[2].x + a_[1].x * b_[2].y + a_[2].x * b_[2].z + a_[3].x * b_[2].w, a_[0].y * b_[2].x + a_[1].y * b_[2].y + a_[2].y * b_[2].z + a_[3].y * b_[2].w, a_[0].z * b_[2].x + a_[1].z * b_[2].y + a_[2].z * b_[2].z + a_[3].z * b_[2].w, a_[0].w * b_[2].x + a_[1].w * b_[2].y + a_[2].w * b_[2].z + a_[3].w * b_[2].w, a_[0].x * b_[3].x + a_[1].x * b_[3].y + a_[2].x * b_[3].z + a_[3].x * b_[3].w, a_[0].y * b_[3].x + a_[1].y * b_[3].y + a_[2].y * b_[3].z + a_[3].y * b_[3].w, a_[0].z * b_[3].x + a_[1].z * b_[3].y + a_[2].z * b_[3].z + a_[3].z * b_[3].w, a_[0].w * b_[3].x + a_[1].w * b_[3].y + a_[2].w * b_[3].z + a_[3].w * b_[3].w);
319
+ },
320
+ },
321
+ mulMxV: {
322
+ mat2x2f: (m, v) => {
323
+ const m_ = m.columns;
324
+ return vec2f(m_[0].x * v.x + m_[1].x * v.y, m_[0].y * v.x + m_[1].y * v.y);
325
+ },
326
+ mat3x3f: (m, v) => {
327
+ const m_ = m.columns;
328
+ return vec3f(m_[0].x * v.x + m_[1].x * v.y + m_[2].x * v.z, m_[0].y * v.x + m_[1].y * v.y + m_[2].y * v.z, m_[0].z * v.x + m_[1].z * v.y + m_[2].z * v.z);
329
+ },
330
+ mat4x4f: (m, v) => {
331
+ const m_ = m.columns;
332
+ return vec4f(m_[0].x * v.x + m_[1].x * v.y + m_[2].x * v.z + m_[3].x * v.w, m_[0].y * v.x + m_[1].y * v.y + m_[2].y * v.z + m_[3].y * v.w, m_[0].z * v.x + m_[1].z * v.y + m_[2].z * v.z + m_[3].z * v.w, m_[0].w * v.x + m_[1].w * v.y + m_[2].w * v.z + m_[3].w * v.w);
333
+ },
334
+ },
335
+ mulVxM: {
336
+ mat2x2f: (v, m) => {
337
+ const m_ = m.columns;
338
+ return vec2f(v.x * m_[0].x + v.y * m_[0].y, v.x * m_[1].x + v.y * m_[1].y);
339
+ },
340
+ mat3x3f: (v, m) => {
341
+ const m_ = m.columns;
342
+ return vec3f(v.x * m_[0].x + v.y * m_[0].y + v.z * m_[0].z, v.x * m_[1].x + v.y * m_[1].y + v.z * m_[1].z, v.x * m_[2].x + v.y * m_[2].y + v.z * m_[2].z);
343
+ },
344
+ mat4x4f: (v, m) => {
345
+ const m_ = m.columns;
346
+ return vec4f(v.x * m_[0].x + v.y * m_[0].y + v.z * m_[0].z + v.w * m_[0].w, v.x * m_[1].x + v.y * m_[1].y + v.z * m_[1].z + v.w * m_[1].w, v.x * m_[2].x + v.y * m_[2].y + v.z * m_[2].z + v.w * m_[2].w, v.x * m_[3].x + v.y * m_[3].y + v.z * m_[3].z + v.w * m_[3].w);
347
+ },
348
+ },
349
+ div: {
350
+ vec2f: binaryComponentWise2f((a, b) => a / b),
351
+ vec2h: binaryComponentWise2h((a, b) => a / b),
352
+ vec2i: binaryComponentWise2i(divInteger),
353
+ vec2u: binaryComponentWise2u(divInteger),
354
+ vec3f: binaryComponentWise3f((a, b) => a / b),
355
+ vec3h: binaryComponentWise3h((a, b) => a / b),
356
+ vec3i: binaryComponentWise3i(divInteger),
357
+ vec3u: binaryComponentWise3u(divInteger),
358
+ vec4f: binaryComponentWise4f((a, b) => a / b),
359
+ vec4h: binaryComponentWise4h((a, b) => a / b),
360
+ vec4i: binaryComponentWise4i(divInteger),
361
+ vec4u: binaryComponentWise4u(divInteger),
362
+ },
363
+ dot: {
364
+ vec2f: dotVec2,
365
+ vec2h: dotVec2,
366
+ vec2i: dotVec2,
367
+ vec2u: dotVec2,
368
+ vec3f: dotVec3,
369
+ vec3h: dotVec3,
370
+ vec3i: dotVec3,
371
+ vec3u: dotVec3,
372
+ vec4f: dotVec4,
373
+ vec4h: dotVec4,
374
+ vec4i: dotVec4,
375
+ vec4u: dotVec4,
376
+ },
377
+ normalize: {
378
+ vec2f: (v) => {
379
+ const len = lengthVec2(v);
380
+ return vec2f(v.x / len, v.y / len);
381
+ },
382
+ vec2h: (v) => {
383
+ const len = lengthVec2(v);
384
+ return vec2h(v.x / len, v.y / len);
385
+ },
386
+ vec2i: (v) => {
387
+ const len = lengthVec2(v);
388
+ return vec2i(v.x / len, v.y / len);
389
+ },
390
+ vec2u: (v) => {
391
+ const len = lengthVec2(v);
392
+ return vec2u(v.x / len, v.y / len);
393
+ },
394
+ vec3f: (v) => {
395
+ const len = lengthVec3(v);
396
+ return vec3f(v.x / len, v.y / len, v.z / len);
397
+ },
398
+ vec3h: (v) => {
399
+ const len = lengthVec3(v);
400
+ return vec3h(v.x / len, v.y / len, v.z / len);
401
+ },
402
+ vec3i: (v) => {
403
+ const len = lengthVec3(v);
404
+ return vec3i(v.x / len, v.y / len, v.z / len);
405
+ },
406
+ vec3u: (v) => {
407
+ const len = lengthVec3(v);
408
+ return vec3u(v.x / len, v.y / len, v.z / len);
409
+ },
410
+ vec4f: (v) => {
411
+ const len = lengthVec4(v);
412
+ return vec4f(v.x / len, v.y / len, v.z / len, v.w / len);
413
+ },
414
+ vec4h: (v) => {
415
+ const len = lengthVec4(v);
416
+ return vec4h(v.x / len, v.y / len, v.z / len, v.w / len);
417
+ },
418
+ vec4i: (v) => {
419
+ const len = lengthVec4(v);
420
+ return vec4i(v.x / len, v.y / len, v.z / len, v.w / len);
421
+ },
422
+ vec4u: (v) => {
423
+ const len = lengthVec4(v);
424
+ return vec4u(v.x / len, v.y / len, v.z / len, v.w / len);
425
+ },
426
+ },
427
+ cross: {
428
+ vec3f: (a, b) => {
429
+ return vec3f(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
430
+ },
431
+ vec3h: (a, b) => {
432
+ return vec3h(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
433
+ },
434
+ },
435
+ mod: {
436
+ vec2f: binaryComponentWise2f((a, b) => a % b),
437
+ vec2h: binaryComponentWise2h((a, b) => a % b),
438
+ vec2i: binaryComponentWise2i((a, b) => a % b),
439
+ vec2u: binaryComponentWise2u((a, b) => a % b),
440
+ vec3f: binaryComponentWise3f((a, b) => a % b),
441
+ vec3h: binaryComponentWise3h((a, b) => a % b),
442
+ vec3i: binaryComponentWise3i((a, b) => a % b),
443
+ vec3u: binaryComponentWise3u((a, b) => a % b),
444
+ vec4f: binaryComponentWise4f((a, b) => a % b),
445
+ vec4h: binaryComponentWise4h((a, b) => a % b),
446
+ vec4i: binaryComponentWise4i((a, b) => a % b),
447
+ vec4u: binaryComponentWise4u((a, b) => a % b),
448
+ },
449
+ floor: {
450
+ vec2f: unary2f(Math.floor),
451
+ vec2h: unary2h(Math.floor),
452
+ vec3f: unary3f(Math.floor),
453
+ vec3h: unary3h(Math.floor),
454
+ vec4f: unary4f(Math.floor),
455
+ vec4h: unary4h(Math.floor),
456
+ },
457
+ max: {
458
+ vec2f: binaryComponentWise2f(Math.max),
459
+ vec2h: binaryComponentWise2h(Math.max),
460
+ vec2i: binaryComponentWise2i(Math.max),
461
+ vec2u: binaryComponentWise2u(Math.max),
462
+ vec3f: binaryComponentWise3f(Math.max),
463
+ vec3h: binaryComponentWise3h(Math.max),
464
+ vec3i: binaryComponentWise3i(Math.max),
465
+ vec3u: binaryComponentWise3u(Math.max),
466
+ vec4f: binaryComponentWise4f(Math.max),
467
+ vec4h: binaryComponentWise4h(Math.max),
468
+ vec4i: binaryComponentWise4i(Math.max),
469
+ vec4u: binaryComponentWise4u(Math.max),
470
+ },
471
+ min: {
472
+ vec2f: binaryComponentWise2f(Math.min),
473
+ vec2h: binaryComponentWise2h(Math.min),
474
+ vec2i: binaryComponentWise2i(Math.min),
475
+ vec2u: binaryComponentWise2u(Math.min),
476
+ vec3f: binaryComponentWise3f(Math.min),
477
+ vec3h: binaryComponentWise3h(Math.min),
478
+ vec3i: binaryComponentWise3i(Math.min),
479
+ vec3u: binaryComponentWise3u(Math.min),
480
+ vec4f: binaryComponentWise4f(Math.min),
481
+ vec4h: binaryComponentWise4h(Math.min),
482
+ vec4i: binaryComponentWise4i(Math.min),
483
+ vec4u: binaryComponentWise4u(Math.min),
484
+ },
485
+ pow: {
486
+ vec2f: (base, exponent) => vec2f(base.x ** exponent.x, base.y ** exponent.y),
487
+ vec2h: (base, exponent) => vec2h(base.x ** exponent.x, base.y ** exponent.y),
488
+ vec3f: (base, exponent) => vec3f(base.x ** exponent.x, base.y ** exponent.y, base.z ** exponent.z),
489
+ vec3h: (base, exponent) => vec3h(base.x ** exponent.x, base.y ** exponent.y, base.z ** exponent.z),
490
+ vec4f: (base, exponent) => vec4f(base.x ** exponent.x, base.y ** exponent.y, base.z ** exponent.z, base.w ** exponent.w),
491
+ vec4h: (base, exponent) => vec4h(base.x ** exponent.x, base.y ** exponent.y, base.z ** exponent.z, base.w ** exponent.w),
492
+ },
493
+ sign: {
494
+ vec2f: unary2f(Math.sign),
495
+ vec2h: unary2h(Math.sign),
496
+ vec2i: unary2i(Math.sign),
497
+ vec3f: unary3f(Math.sign),
498
+ vec3h: unary3h(Math.sign),
499
+ vec3i: unary3i(Math.sign),
500
+ vec4f: unary4f(Math.sign),
501
+ vec4h: unary4h(Math.sign),
502
+ vec4i: unary4i(Math.sign),
503
+ },
504
+ sqrt: {
505
+ vec2f: unary2f(Math.sqrt),
506
+ vec2h: unary2h(Math.sqrt),
507
+ vec3f: unary3f(Math.sqrt),
508
+ vec3h: unary3h(Math.sqrt),
509
+ vec4f: unary4f(Math.sqrt),
510
+ vec4h: unary4h(Math.sqrt),
511
+ },
512
+ mix: {
513
+ vec2f: (e1, e2, e3) => {
514
+ if (typeof e3 === 'number') {
515
+ return vec2f(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3);
516
+ }
517
+ return vec2f(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y);
518
+ },
519
+ vec2h: (e1, e2, e3) => {
520
+ if (typeof e3 === 'number') {
521
+ return vec2h(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3);
522
+ }
523
+ return vec2h(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y);
524
+ },
525
+ vec3f: (e1, e2, e3) => {
526
+ if (typeof e3 === 'number') {
527
+ return vec3f(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3, e1.z * (1 - e3) + e2.z * e3);
528
+ }
529
+ return vec3f(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y, e1.z * (1 - e3.z) + e2.z * e3.z);
530
+ },
531
+ vec3h: (e1, e2, e3) => {
532
+ if (typeof e3 === 'number') {
533
+ return vec3h(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3, e1.z * (1 - e3) + e2.z * e3);
534
+ }
535
+ return vec3h(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y, e1.z * (1 - e3.z) + e2.z * e3.z);
536
+ },
537
+ vec4f: (e1, e2, e3) => {
538
+ if (typeof e3 === 'number') {
539
+ return vec4f(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3, e1.z * (1 - e3) + e2.z * e3, e1.w * (1 - e3) + e2.w * e3);
540
+ }
541
+ return vec4f(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y, e1.z * (1 - e3.z) + e2.z * e3.z, e1.w * (1 - e3.w) + e2.w * e3.w);
542
+ },
543
+ vec4h: (e1, e2, e3) => {
544
+ if (typeof e3 === 'number') {
545
+ return vec4h(e1.x * (1 - e3) + e2.x * e3, e1.y * (1 - e3) + e2.y * e3, e1.z * (1 - e3) + e2.z * e3, e1.w * (1 - e3) + e2.w * e3);
546
+ }
547
+ return vec4h(e1.x * (1 - e3.x) + e2.x * e3.x, e1.y * (1 - e3.y) + e2.y * e3.y, e1.z * (1 - e3.z) + e2.z * e3.z, e1.w * (1 - e3.w) + e2.w * e3.w);
548
+ },
549
+ },
550
+ sin: {
551
+ vec2f: unary2f(Math.sin),
552
+ vec2h: unary2h(Math.sin),
553
+ vec3f: unary3f(Math.sin),
554
+ vec3h: unary3h(Math.sin),
555
+ vec4f: unary4f(Math.sin),
556
+ vec4h: unary4h(Math.sin),
557
+ },
558
+ cos: {
559
+ vec2f: unary2f(Math.cos),
560
+ vec2h: unary2h(Math.cos),
561
+ vec3f: unary3f(Math.cos),
562
+ vec3h: unary3h(Math.cos),
563
+ vec4f: unary4f(Math.cos),
564
+ vec4h: unary4h(Math.cos),
565
+ },
566
+ cosh: {
567
+ vec2f: unary2f(Math.cosh),
568
+ vec2h: unary2h(Math.cosh),
569
+ vec3f: unary3f(Math.cosh),
570
+ vec3h: unary3h(Math.cosh),
571
+ vec4f: unary4f(Math.cosh),
572
+ vec4h: unary4h(Math.cosh),
573
+ },
574
+ exp: {
575
+ vec2f: unary2f(Math.exp),
576
+ vec2h: unary2h(Math.exp),
577
+ vec3f: unary3f(Math.exp),
578
+ vec3h: unary3h(Math.exp),
579
+ vec4f: unary4f(Math.exp),
580
+ vec4h: unary4h(Math.exp),
581
+ },
582
+ exp2: {
583
+ vec2f: unary2f((val) => 2 ** val),
584
+ vec2h: unary2h((val) => 2 ** val),
585
+ vec3f: unary3f((val) => 2 ** val),
586
+ vec3h: unary3h((val) => 2 ** val),
587
+ vec4f: unary4f((val) => 2 ** val),
588
+ vec4h: unary4h((val) => 2 ** val),
589
+ },
590
+ log: {
591
+ vec2f: unary2f(Math.log),
592
+ vec2h: unary2h(Math.log),
593
+ vec3f: unary3f(Math.log),
594
+ vec3h: unary3h(Math.log),
595
+ vec4f: unary4f(Math.log),
596
+ vec4h: unary4h(Math.log),
597
+ },
598
+ log2: {
599
+ vec2f: unary2f(Math.log2),
600
+ vec2h: unary2h(Math.log2),
601
+ vec3f: unary3f(Math.log2),
602
+ vec3h: unary3h(Math.log2),
603
+ vec4f: unary4f(Math.log2),
604
+ vec4h: unary4h(Math.log2),
605
+ },
606
+ fract: {
607
+ vec2f: unary2f((value) => value - Math.floor(value)),
608
+ vec2h: unary2h((value) => value - Math.floor(value)),
609
+ vec3f: unary3f((value) => value - Math.floor(value)),
610
+ vec3h: unary3h((value) => value - Math.floor(value)),
611
+ vec4f: unary4f((value) => value - Math.floor(value)),
612
+ vec4h: unary4h((value) => value - Math.floor(value)),
613
+ },
614
+ isCloseToZero: {
615
+ vec2f: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n,
616
+ vec2h: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n,
617
+ vec3f: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n && Math.abs(v.z) <= n,
618
+ vec3h: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n && Math.abs(v.z) <= n,
619
+ vec4f: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n && Math.abs(v.z) <= n && Math.abs(v.w) <= n,
620
+ vec4h: (v, n) => Math.abs(v.x) <= n && Math.abs(v.y) <= n && Math.abs(v.z) <= n && Math.abs(v.w) <= n,
621
+ },
622
+ neg: {
623
+ vec2f: unary2f((value) => -value),
624
+ vec2h: unary2h((value) => -value),
625
+ vec2i: unary2i((value) => -value),
626
+ vec2u: unary2u((value) => -value),
627
+ 'vec2<bool>': (e) => vec2b(!e.x, !e.y),
628
+ vec3f: unary3f((value) => -value),
629
+ vec3h: unary3h((value) => -value),
630
+ vec3i: unary3i((value) => -value),
631
+ vec3u: unary3u((value) => -value),
632
+ 'vec3<bool>': (e) => vec3b(!e.x, !e.y, !e.z),
633
+ vec4f: unary4f((value) => -value),
634
+ vec4h: unary4h((value) => -value),
635
+ vec4i: unary4i((value) => -value),
636
+ vec4u: unary4u((value) => -value),
637
+ 'vec4<bool>': (e) => vec4b(!e.x, !e.y, !e.z, !e.w),
638
+ },
639
+ select: {
640
+ vec2f: (f, t, c) => vec2f(c.x ? t.x : f.x, c.y ? t.y : f.y),
641
+ vec2h: (f, t, c) => vec2h(c.x ? t.x : f.x, c.y ? t.y : f.y),
642
+ vec2i: (f, t, c) => vec2i(c.x ? t.x : f.x, c.y ? t.y : f.y),
643
+ vec2u: (f, t, c) => vec2u(c.x ? t.x : f.x, c.y ? t.y : f.y),
644
+ 'vec2<bool>': (f, t, c) => vec2b(c.x ? t.x : f.x, c.y ? t.y : f.y),
645
+ vec3f: (f, t, c) => vec3f(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
646
+ vec3h: (f, t, c) => vec3h(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
647
+ vec3i: (f, t, c) => vec3i(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
648
+ vec3u: (f, t, c) => vec3u(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
649
+ 'vec3<bool>': (f, t, c) => vec3b(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z),
650
+ vec4f: (f, t, c) => vec4f(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w),
651
+ vec4h: (f, t, c) => vec4h(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w),
652
+ vec4i: (f, t, c) => vec4i(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w),
653
+ vec4u: (f, t, c) => vec4u(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w),
654
+ 'vec4<bool>': (f, t, c) => vec4b(c.x ? t.x : f.x, c.y ? t.y : f.y, c.z ? t.z : f.z, c.w ? t.w : f.w),
655
+ },
656
+ tanh: {
657
+ vec2f: unary2f(Math.tanh),
658
+ vec2h: unary2h(Math.tanh),
659
+ vec3f: unary3f(Math.tanh),
660
+ vec3h: unary3h(Math.tanh),
661
+ vec4f: unary4f(Math.tanh),
662
+ vec4h: unary4h(Math.tanh),
663
+ },
664
+ bitShiftLeft: {
665
+ vec2i: binaryComponentWise2i2u((a, b) => a << b),
666
+ vec2u: binaryComponentWise2u((a, b) => a << b),
667
+ vec3i: binaryComponentWise3i3u((a, b) => a << b),
668
+ vec3u: binaryComponentWise3u((a, b) => a << b),
669
+ vec4i: binaryComponentWise4i4u((a, b) => a << b),
670
+ vec4u: binaryComponentWise4u((a, b) => a << b),
671
+ },
672
+ bitShiftRight: {
673
+ vec2i: binaryComponentWise2i2u((a, b) => a >> b),
674
+ vec2u: binaryComponentWise2u((a, b) => a >>> b),
675
+ vec3i: binaryComponentWise3i3u((a, b) => a >> b),
676
+ vec3u: binaryComponentWise3u((a, b) => a >>> b),
677
+ vec4i: binaryComponentWise4i4u((a, b) => a >> b),
678
+ vec4u: binaryComponentWise4u((a, b) => a >>> b),
679
+ },
680
+ bitcastU32toF32: {
681
+ vec2u: (n) => vec2f(bitcastU32toF32Impl(n.x), bitcastU32toF32Impl(n.y)),
682
+ vec3u: (n) => vec3f(bitcastU32toF32Impl(n.x), bitcastU32toF32Impl(n.y), bitcastU32toF32Impl(n.z)),
683
+ vec4u: (n) => vec4f(bitcastU32toF32Impl(n.x), bitcastU32toF32Impl(n.y), bitcastU32toF32Impl(n.z), bitcastU32toF32Impl(n.w)),
684
+ },
685
+ bitcastU32toI32: {
686
+ vec2u: (n) => vec2i(bitcastU32toI32Impl(n.x), bitcastU32toI32Impl(n.y)),
687
+ vec3u: (n) => vec3i(bitcastU32toI32Impl(n.x), bitcastU32toI32Impl(n.y), bitcastU32toI32Impl(n.z)),
688
+ vec4u: (n) => vec4i(bitcastU32toI32Impl(n.x), bitcastU32toI32Impl(n.y), bitcastU32toI32Impl(n.z), bitcastU32toI32Impl(n.w)),
689
+ },
690
+ bitcastF32toU32: {
691
+ vec2f: (n) => vec2u(bitcastF32toU32Impl(n.x), bitcastF32toU32Impl(n.y)),
692
+ vec3f: (n) => vec3u(bitcastF32toU32Impl(n.x), bitcastF32toU32Impl(n.y), bitcastF32toU32Impl(n.z)),
693
+ vec4f: (n) => vec4u(bitcastF32toU32Impl(n.x), bitcastF32toU32Impl(n.y), bitcastF32toU32Impl(n.z), bitcastF32toU32Impl(n.w)),
694
+ },
680
695
  };
681
-
682
- //#endregion
683
- export { VectorOps };