glre 0.39.0 → 0.40.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 (281) hide show
  1. package/README.md +8 -4
  2. package/dist/addons.cjs +1 -1
  3. package/dist/addons.cjs.map +1 -1
  4. package/dist/addons.d.ts +849 -19
  5. package/dist/addons.js +1 -1
  6. package/dist/addons.js.map +1 -1
  7. package/dist/index.cjs +8 -8
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts +38 -20
  10. package/dist/index.js +8 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/native.d.ts +48 -22
  13. package/dist/node.cjs +59 -30
  14. package/dist/node.cjs.map +1 -1
  15. package/dist/node.d.ts +34 -22
  16. package/dist/node.js +59 -30
  17. package/dist/node.js.map +1 -1
  18. package/dist/react.d.ts +38 -20
  19. package/dist/solid.d.ts +38 -20
  20. package/package.json +24 -24
  21. package/src/addons/animation/easing/backIn.ts +10 -0
  22. package/src/addons/animation/easing/backInOut.ts +12 -0
  23. package/src/addons/animation/easing/backOut.ts +10 -0
  24. package/src/addons/animation/easing/bounceIn.ts +10 -0
  25. package/src/addons/animation/easing/bounceInOut.ts +13 -0
  26. package/src/addons/animation/easing/bounceOut.ts +30 -0
  27. package/src/addons/animation/easing/circularIn.ts +9 -0
  28. package/src/addons/animation/easing/circularInOut.ts +11 -0
  29. package/src/addons/animation/easing/circularOut.ts +9 -0
  30. package/src/addons/animation/easing/cubicIn.ts +9 -0
  31. package/src/addons/animation/easing/cubicInOut.ts +11 -0
  32. package/src/addons/animation/easing/cubicOut.ts +10 -0
  33. package/src/addons/animation/easing/elasticIn.ts +10 -0
  34. package/src/addons/animation/easing/elasticInOut.ts +21 -0
  35. package/src/addons/animation/easing/elasticOut.ts +12 -0
  36. package/src/addons/animation/easing/exponentialIn.ts +9 -0
  37. package/src/addons/animation/easing/exponentialInOut.ts +13 -0
  38. package/src/addons/animation/easing/exponentialOut.ts +9 -0
  39. package/src/addons/animation/easing/index.ts +33 -0
  40. package/src/addons/animation/easing/linearIn.ts +9 -0
  41. package/src/addons/animation/easing/linearInOut.ts +9 -0
  42. package/src/addons/animation/easing/linearOut.ts +9 -0
  43. package/src/addons/animation/easing/quadraticIn.ts +9 -0
  44. package/src/addons/animation/easing/quadraticInOut.ts +10 -0
  45. package/src/addons/animation/easing/quadraticOut.ts +9 -0
  46. package/src/addons/animation/easing/quarticIn.ts +9 -0
  47. package/src/addons/animation/easing/quarticInOut.ts +11 -0
  48. package/src/addons/animation/easing/quarticOut.ts +10 -0
  49. package/src/addons/animation/easing/quinticIn.ts +9 -0
  50. package/src/addons/animation/easing/quinticInOut.ts +11 -0
  51. package/src/addons/animation/easing/quinticOut.ts +9 -0
  52. package/src/addons/animation/easing/sineIn.ts +10 -0
  53. package/src/addons/animation/easing/sineInOut.ts +10 -0
  54. package/src/addons/animation/easing/sineOut.ts +10 -0
  55. package/src/addons/color/palette/macbeth.ts +42 -0
  56. package/src/addons/color/space/cmyk2rgb.ts +12 -0
  57. package/src/addons/color/space/gamma2linear.ts +19 -0
  58. package/src/addons/color/space/hsl2rgb.ts +20 -0
  59. package/src/addons/color/space/hsv2rgb.ts +18 -0
  60. package/src/addons/color/space/hue2rgb.ts +12 -0
  61. package/src/addons/color/space/index.ts +29 -0
  62. package/src/addons/color/space/lab2lch.ts +22 -0
  63. package/src/addons/color/space/lab2rgb.ts +19 -0
  64. package/src/addons/color/space/lab2xyz.ts +32 -0
  65. package/src/addons/color/space/lch2lab.ts +21 -0
  66. package/src/addons/color/space/lch2rgb.ts +22 -0
  67. package/src/addons/color/space/linear2gamma.ts +19 -0
  68. package/src/addons/color/space/oklab2rgb.ts +35 -0
  69. package/src/addons/color/space/rgb2cmyk.ts +13 -0
  70. package/src/addons/color/space/rgb2hcv.ts +29 -0
  71. package/src/addons/color/space/rgb2hsl.ts +23 -0
  72. package/src/addons/color/space/rgb2hsv.ts +36 -0
  73. package/src/addons/color/space/rgb2hue.ts +29 -0
  74. package/src/addons/color/space/rgb2lab.ts +19 -0
  75. package/src/addons/color/space/rgb2lch.ts +22 -0
  76. package/src/addons/color/space/rgb2oklab.ts +45 -0
  77. package/src/addons/color/space/rgb2srgb.ts +34 -0
  78. package/src/addons/color/space/rgb2xyz.ts +20 -0
  79. package/src/addons/color/space/rgb2yiq.ts +22 -0
  80. package/src/addons/color/space/rgb2yuv.ts +32 -0
  81. package/src/addons/color/space/srgb2rgb.ts +34 -0
  82. package/src/addons/color/space/xyz2lab.ts +27 -0
  83. package/src/addons/color/space/xyz2rgb.ts +30 -0
  84. package/src/addons/color/space/yiq2rgb.ts +22 -0
  85. package/src/addons/color/space/yuv2rgb.ts +32 -0
  86. package/src/addons/draw/arrows.ts +75 -0
  87. package/src/addons/draw/axis.ts +57 -0
  88. package/src/addons/draw/bridge.ts +81 -0
  89. package/src/addons/draw/char.ts +30 -0
  90. package/src/addons/draw/circle.ts +29 -0
  91. package/src/addons/draw/fill.ts +25 -0
  92. package/src/addons/draw/flip.ts +45 -0
  93. package/src/addons/draw/hex.ts +29 -0
  94. package/src/addons/draw/index.ts +13 -0
  95. package/src/addons/draw/line.ts +16 -0
  96. package/src/addons/draw/point.ts +30 -0
  97. package/src/addons/draw/rect.ts +52 -0
  98. package/src/addons/draw/stroke.ts +31 -0
  99. package/src/addons/draw/tri.ts +29 -0
  100. package/src/addons/generative/cnoise.ts +239 -0
  101. package/src/addons/generative/curl.ts +64 -0
  102. package/src/addons/generative/fbm.ts +69 -0
  103. package/src/addons/generative/gerstnerWave.ts +21 -0
  104. package/src/addons/generative/gnoise.ts +113 -0
  105. package/src/addons/generative/index.ts +15 -0
  106. package/src/addons/generative/noised.ts +139 -0
  107. package/src/addons/generative/pnoise.ts +249 -0
  108. package/src/addons/generative/psrdnoise.ts +277 -0
  109. package/src/addons/generative/random.ts +136 -0
  110. package/src/addons/generative/snoise.ts +199 -0
  111. package/src/addons/generative/srandom.ts +90 -0
  112. package/src/addons/generative/voronoi.ts +134 -0
  113. package/src/addons/generative/voronoise.ts +69 -0
  114. package/src/addons/generative/wavelet.ts +77 -0
  115. package/src/addons/generative/worley.ts +99 -0
  116. package/src/addons/geometry/aabb/aabb.ts +8 -0
  117. package/src/addons/geometry/aabb/centroid.ts +10 -0
  118. package/src/addons/geometry/aabb/contain.ts +19 -0
  119. package/src/addons/geometry/aabb/diagonal.ts +10 -0
  120. package/src/addons/geometry/aabb/expand.ts +16 -0
  121. package/src/addons/geometry/aabb/index.ts +7 -0
  122. package/src/addons/geometry/aabb/intersect.ts +20 -0
  123. package/src/addons/geometry/aabb/square.ts +17 -0
  124. package/src/addons/geometry/index.ts +2 -0
  125. package/src/addons/geometry/triangle/area.ts +10 -0
  126. package/src/addons/geometry/triangle/barycentric.ts +50 -0
  127. package/src/addons/geometry/triangle/centroid.ts +10 -0
  128. package/src/addons/geometry/triangle/closestPoint.ts +85 -0
  129. package/src/addons/geometry/triangle/contain.ts +19 -0
  130. package/src/addons/geometry/triangle/distanceSq.ts +38 -0
  131. package/src/addons/geometry/triangle/index.ts +10 -0
  132. package/src/addons/geometry/triangle/intersect.ts +49 -0
  133. package/src/addons/geometry/triangle/normal.ts +12 -0
  134. package/src/addons/geometry/triangle/signedDistance.ts +31 -0
  135. package/src/addons/geometry/triangle/triangle.ts +9 -0
  136. package/src/addons/index.ts +8 -6
  137. package/src/addons/lighting/ray.ts +8 -0
  138. package/src/addons/math/aafloor.ts +13 -0
  139. package/src/addons/math/aafract.ts +38 -0
  140. package/src/addons/math/aamirror.ts +12 -0
  141. package/src/addons/math/aastep.ts +14 -0
  142. package/src/addons/math/absi.ts +9 -0
  143. package/src/addons/math/adaptiveThreshold.ts +24 -0
  144. package/src/addons/math/bump.ts +20 -0
  145. package/src/addons/math/const.ts +19 -0
  146. package/src/addons/math/cubic.ts +101 -0
  147. package/src/addons/math/cubicMix.ts +49 -0
  148. package/src/addons/math/decimate.ts +12 -0
  149. package/src/addons/math/dist.ts +143 -0
  150. package/src/addons/math/fcos.ts +11 -0
  151. package/src/addons/math/frac.ts +9 -0
  152. package/src/addons/math/gain.ts +14 -0
  153. package/src/addons/math/gaussian.ts +14 -0
  154. package/src/addons/math/grad4.ts +19 -0
  155. package/src/addons/math/hammersley.ts +54 -0
  156. package/src/addons/math/highPass.ts +12 -0
  157. package/src/addons/math/index.ts +63 -0
  158. package/src/addons/math/inside.ts +68 -0
  159. package/src/addons/math/invCubic.ts +9 -0
  160. package/src/addons/math/invQuartic.ts +9 -0
  161. package/src/addons/math/inverse.ts +9 -0
  162. package/src/addons/math/lengthSq.ts +10 -0
  163. package/src/addons/math/map.ts +27 -0
  164. package/src/addons/math/mirror.ts +12 -0
  165. package/src/addons/math/mmax.ts +27 -0
  166. package/src/addons/math/mmin.ts +28 -0
  167. package/src/addons/math/mmix.ts +47 -0
  168. package/src/addons/math/mod2.ts +44 -0
  169. package/src/addons/math/mod289.ts +46 -0
  170. package/src/addons/math/modi.ts +15 -0
  171. package/src/addons/math/nyquist.ts +15 -0
  172. package/src/addons/math/pack.ts +15 -0
  173. package/src/addons/math/parabola.ts +12 -0
  174. package/src/addons/math/permute.ts +42 -0
  175. package/src/addons/math/pow2.ts +10 -0
  176. package/src/addons/math/pow3.ts +9 -0
  177. package/src/addons/math/pow5.ts +10 -0
  178. package/src/addons/math/pow7.ts +12 -0
  179. package/src/addons/math/powFast.ts +18 -0
  180. package/src/addons/math/quartic.ts +15 -0
  181. package/src/addons/math/quat/index.ts +14 -0
  182. package/src/addons/math/quat/quat2mat3.ts +28 -0
  183. package/src/addons/math/quat/quat2mat4.ts +16 -0
  184. package/src/addons/math/quat/quatAdd.ts +18 -0
  185. package/src/addons/math/quat/quatConj.ts +14 -0
  186. package/src/addons/math/quat/quatDiv.ts +18 -0
  187. package/src/addons/math/quat/quatIdentity.ts +9 -0
  188. package/src/addons/math/quat/quatInverse.ts +17 -0
  189. package/src/addons/math/quat/quatLength.ts +15 -0
  190. package/src/addons/math/quat/quatLengthSq.ts +14 -0
  191. package/src/addons/math/quat/quatLerp.ts +40 -0
  192. package/src/addons/math/quat/quatMul.ts +38 -0
  193. package/src/addons/math/quat/quatNeg.ts +14 -0
  194. package/src/addons/math/quat/quatNorm.ts +16 -0
  195. package/src/addons/math/quat/quatSub.ts +18 -0
  196. package/src/addons/math/quintic.ts +16 -0
  197. package/src/addons/math/rotate2d.ts +16 -0
  198. package/src/addons/math/rotate3d.ts +37 -0
  199. package/src/addons/math/rotate3dX.ts +20 -0
  200. package/src/addons/math/rotate3dY.ts +20 -0
  201. package/src/addons/math/rotate3dZ.ts +20 -0
  202. package/src/addons/math/rotate4d.ts +41 -0
  203. package/src/addons/math/rotate4dX.ts +21 -0
  204. package/src/addons/math/rotate4dY.ts +16 -0
  205. package/src/addons/math/rotate4dZ.ts +21 -0
  206. package/src/addons/math/saturateMediump.ts +11 -0
  207. package/src/addons/math/scale2d.ts +44 -0
  208. package/src/addons/math/scale3d.ts +17 -0
  209. package/src/addons/math/scale4d.ts +50 -0
  210. package/src/addons/math/smootherstep.ts +16 -0
  211. package/src/addons/math/taylorInvSqrt.ts +9 -0
  212. package/src/addons/math/toMat3.ts +14 -0
  213. package/src/addons/math/toMat4.ts +14 -0
  214. package/src/addons/math/translate4d.ts +31 -0
  215. package/src/addons/math/unpack.ts +88 -0
  216. package/src/addons/sdf/boxSDF.ts +24 -0
  217. package/src/addons/sdf/circleSDF.ts +20 -0
  218. package/src/addons/sdf/crossSDF.ts +17 -0
  219. package/src/addons/sdf/hexSDF.ts +18 -0
  220. package/src/addons/sdf/index.ts +7 -0
  221. package/src/addons/sdf/lineSDF.ts +33 -0
  222. package/src/addons/sdf/rectSDF.ts +46 -0
  223. package/src/addons/sdf/sphereSDF.ts +20 -0
  224. package/src/addons/sdf/triSDF.ts +14 -0
  225. package/src/addons/space/aspect.ts +14 -0
  226. package/src/addons/space/bracketing.ts +44 -0
  227. package/src/addons/space/brickTile.ts +44 -0
  228. package/src/addons/space/cart2polar.ts +20 -0
  229. package/src/addons/space/center.ts +32 -0
  230. package/src/addons/space/checkerTile.ts +41 -0
  231. package/src/addons/space/depth2viewZ.ts +43 -0
  232. package/src/addons/space/displace.ts +55 -0
  233. package/src/addons/space/equirect2xyz.ts +17 -0
  234. package/src/addons/space/eulerView.ts +19 -0
  235. package/src/addons/space/fisheye2xyz.ts +18 -0
  236. package/src/addons/space/flipY.ts +25 -0
  237. package/src/addons/space/hexTile.ts +18 -0
  238. package/src/addons/space/index.ts +38 -0
  239. package/src/addons/space/kaleidoscope.ts +48 -0
  240. package/src/addons/space/linearizeDepth.ts +17 -0
  241. package/src/addons/space/lookAt.ts +49 -0
  242. package/src/addons/space/lookAtView.ts +40 -0
  243. package/src/addons/space/mirrorTile.ts +73 -0
  244. package/src/addons/space/nearest.ts +13 -0
  245. package/src/addons/space/orthographic.ts +25 -0
  246. package/src/addons/space/parallaxMapping.ts +149 -0
  247. package/src/addons/space/perspective.ts +24 -0
  248. package/src/addons/space/polar2cart.ts +24 -0
  249. package/src/addons/space/ratio.ts +14 -0
  250. package/src/addons/space/rotate.ts +37 -0
  251. package/src/addons/space/rotateX.ts +54 -0
  252. package/src/addons/space/rotateY.ts +54 -0
  253. package/src/addons/space/rotateZ.ts +54 -0
  254. package/src/addons/space/scale.ts +13 -0
  255. package/src/addons/space/sprite.ts +16 -0
  256. package/src/addons/space/sqTile.ts +20 -0
  257. package/src/addons/space/tbn.ts +26 -0
  258. package/src/addons/space/translate.ts +12 -0
  259. package/src/addons/space/triTile.ts +32 -0
  260. package/src/addons/space/uncenter.ts +32 -0
  261. package/src/addons/space/unratio.ts +12 -0
  262. package/src/addons/space/viewZ2depth.ts +25 -0
  263. package/src/addons/space/windmillTile.ts +58 -0
  264. package/src/addons/space/xyz2equirect.ts +10 -0
  265. package/src/index.ts +5 -2
  266. package/src/node/build.ts +62 -52
  267. package/src/node/create.ts +3 -0
  268. package/src/node/index.ts +1 -2
  269. package/src/node/scope.ts +26 -25
  270. package/src/node/types.ts +15 -11
  271. package/src/node/utils/const.ts +12 -11
  272. package/src/node/utils/index.ts +14 -12
  273. package/src/node/utils/infer.ts +15 -5
  274. package/src/node/utils/parse.ts +37 -13
  275. package/src/node/utils/utils.ts +46 -23
  276. package/src/types.ts +9 -2
  277. package/src/utils/helpers.ts +56 -0
  278. package/src/utils/pipeline.ts +21 -5
  279. package/src/utils/program.ts +57 -38
  280. package/src/utils/webgl.ts +41 -35
  281. package/src/utils/webgpu.ts +19 -35
package/dist/react.d.ts CHANGED
@@ -3,7 +3,7 @@ import { EventState, Nested } from 'reev';
3
3
  import * as refr from 'refr';
4
4
  import { Queue, Frame } from 'refr';
5
5
 
6
- declare const CONVERSIONS: readonly ["toBool", "toUint", "toInt", "toFloat", "toBvec2", "toIvec2", "toUvec2", "toVec2", "toBvec3", "toIvec3", "toUvec3", "toVec3", "toBvec4", "toIvec4", "toUvec4", "toVec4", "toColor", "toMat2", "toMat3", "toMat4"];
6
+ declare const CONVERSIONS: readonly ["toBool", "toUInt", "toInt", "toFloat", "toBVec2", "toIVec2", "toUVec2", "toVec2", "toBVec3", "toIVec3", "toUVec3", "toVec3", "toBVec4", "toIVec4", "toUVec4", "toVec4", "toColor", "toMat2", "toMat3", "toMat4"];
7
7
  declare const TYPE_MAPPING: {
8
8
  readonly bool: "bool";
9
9
  readonly uint: "u32";
@@ -68,7 +68,7 @@ declare const OPERATOR_TYPE_RULES: readonly [readonly ["float", "vec2", "vec2"],
68
68
  * 1.2. index.ts functions and
69
69
  * 3.2. types.ts _N
70
70
  */
71
- declare const FUNCTIONS: readonly [...("texture" | "all" | "any" | "determinant" | "distance" | "dot" | "length" | "lengthSq" | "luminance" | "cross" | "cubeTexture" | "texelFetch" | "textureLod")[], "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "ceil", "cos", "cosh", "dFdx", "dFdy", "degrees", "exp", "exp2", "floor", "fract", "fwidth", "inverseSqrt", "log", "log2", "negate", "normalize", "oneMinus", "radians", "reciprocal", "round", "saturate", "sign", "sin", "sinh", "sqrt", "tan", "tanh", "trunc", "atan2", "clamp", "max", "min", "mix", "pow", "reflect", "refract", "smoothstep", "step"];
71
+ declare const FUNCTIONS: readonly [...("texture" | "all" | "any" | "determinant" | "distance" | "dot" | "length" | "lengthSq" | "luminance" | "cross" | "cubeTexture" | "texelFetch" | "textureLod")[], "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "ceil", "cos", "cosh", "dFdx", "dFdy", "degrees", "exp", "exp2", "floor", "fract", "fwidth", "inverse", "inverseSqrt", "log", "log2", "negate", "normalize", "oneMinus", "radians", "reciprocal", "round", "sign", "sin", "sinh", "sqrt", "tan", "tanh", "trunc", "saturate", "atan2", "clamp", "max", "min", "mix", "pow", "reflect", "refract", "smoothstep", "step"];
72
72
 
73
73
  type Constants = (typeof CONSTANTS)[number] | 'void';
74
74
  type Conversions = (typeof CONVERSIONS)[number];
@@ -82,14 +82,14 @@ interface FnLayout {
82
82
  type: C | 'auto';
83
83
  inputs?: Array<{
84
84
  name: string;
85
- type: C;
85
+ type: C | 'auto';
86
86
  }>;
87
87
  }
88
88
  type StructFields = Record<string, X>;
89
89
  /**
90
90
  * node
91
91
  */
92
- type NodeTypes = 'attribute' | 'storage' | 'uniform' | 'constant' | 'variable' | 'varying' | 'ternary' | 'builtin' | 'conversion' | 'operator' | 'function' | 'struct' | 'member' | 'element' | 'gather' | 'scatter' | 'scope' | 'assign' | 'loop' | 'define' | 'if' | 'switch' | 'declare' | 'return' | 'break' | 'continue';
92
+ type NodeTypes = 'attribute' | 'instance' | 'storage' | 'uniform' | 'constant' | 'variable' | 'varying' | 'ternary' | 'builtin' | 'conversion' | 'operator' | 'function' | 'struct' | 'member' | 'element' | 'gather' | 'scatter' | 'scope' | 'assign' | 'loop' | 'define' | 'if' | 'switch' | 'declare' | 'return' | 'break' | 'continue';
93
93
  interface NodeProps {
94
94
  id?: string;
95
95
  args?: any[];
@@ -194,10 +194,11 @@ type XImpl<T extends C> = _X<T> & {
194
194
  };
195
195
  type C = Constants;
196
196
  type X<T extends C = C> = T extends keyof ConstantsToType ? ConstantsToType[T] : _X<T>;
197
- type Methods = Functions | Operators | Conversions | Swizzles | '__nodeType' | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString' | 'element';
197
+ type Methods = Functions | Operators | Conversions | Swizzles | '__nodeType' | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString' | 'element' | 'select';
198
198
  interface _X<T extends C> {
199
199
  readonly __nodeType?: T;
200
200
  assign(x: any): X<T>;
201
+ select(x: number | X<T>, y: X<'bool'>): X<T>;
201
202
  fragment(c: NodeContext): string;
202
203
  toVar(name?: string): X<T>;
203
204
  toString(c?: NodeContext): string;
@@ -241,20 +242,20 @@ interface _X<T extends C> {
241
242
  shiftLeftAssign<U extends C>(x: ValidateOperator<T, U> extends 0 ? never : number | X<U>): X<T>;
242
243
  shiftRightAssign<U extends C>(x: ValidateOperator<T, U> extends 0 ? never : number | X<U>): X<T>;
243
244
  toBool(): Bool;
244
- toUint(): UInt;
245
+ toUInt(): UInt;
245
246
  toInt(): Int;
246
247
  toFloat(): Float;
247
- toBvec2(): BVec2;
248
- toIvec2(): IVec2;
249
- toUvec2(): UVec2;
248
+ toBVec2(): BVec2;
249
+ toIVec2(): IVec2;
250
+ toUVec2(): UVec2;
250
251
  toVec2(): Vec2;
251
- toBvec3(): BVec3;
252
- toIvec3(): IVec3;
253
- toUvec3(): UVec3;
252
+ toBVec3(): BVec3;
253
+ toIVec3(): IVec3;
254
+ toUVec3(): UVec3;
254
255
  toVec3(): Vec3;
255
- toBvec4(): BVec4;
256
- toIvec4(): IVec4;
257
- toUvec4(): UVec4;
256
+ toBVec4(): BVec4;
257
+ toIVec4(): IVec4;
258
+ toUVec4(): UVec4;
258
259
  toVec4(): Vec4;
259
260
  toColor(): Color;
260
261
  toMat2(): Mat2;
@@ -338,14 +339,17 @@ type GL = EventState<{
338
339
  isWebGL: boolean;
339
340
  isError: boolean;
340
341
  isLoop: boolean;
342
+ isDebug: boolean;
343
+ isDepth: boolean;
341
344
  isGL: true;
342
345
  width?: number;
343
346
  height?: number;
344
347
  size: [number, number];
345
348
  mouse: [number, number];
346
349
  count: number;
350
+ instanceCount: number;
351
+ particleCount: number | [number, number] | [number, number, number];
347
352
  loading: number;
348
- particles: 64 | 256 | 576 | 1024 | 1600 | 2304 | 3136 | 4096 | 4096 | 5184 | 6400;
349
353
  el: HTMLCanvasElement;
350
354
  vs?: string | Vec4;
351
355
  cs?: string | Void;
@@ -372,7 +376,7 @@ type GL = EventState<{
372
376
  error(e?: string): void;
373
377
  render(): void;
374
378
  resize(e?: Event): void;
375
- mousemove(e: Event): void;
379
+ mousemove(e: MouseEvent): void;
376
380
  loop(): void;
377
381
  /**
378
382
  * setter
@@ -392,6 +396,11 @@ type GL = EventState<{
392
396
  attribute(target: {
393
397
  [key: string]: Attribute;
394
398
  }): GL;
399
+ _instance?(key: string, value: Attribute, at?: number): GL;
400
+ instance(key: string, value: Attribute, at?: number): GL;
401
+ instance(target: {
402
+ [key: string]: Attribute;
403
+ }): GL;
395
404
  _storage?(key: string, value: Storage): GL;
396
405
  storage(key: string, value: Storage): GL;
397
406
  storage(target: {
@@ -422,6 +431,7 @@ interface AttribData {
422
431
  buffer: GPUBuffer;
423
432
  location: number;
424
433
  stride: number;
434
+ isInstance?: boolean;
425
435
  }
426
436
  interface StorageData {
427
437
  array: Float32Array;
@@ -453,14 +463,17 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
453
463
  isWebGL: boolean;
454
464
  isError: boolean;
455
465
  isLoop: boolean;
466
+ isDebug: boolean;
467
+ isDepth: boolean;
456
468
  isGL: true;
457
469
  width?: number;
458
470
  height?: number;
459
471
  size: [number, number];
460
472
  mouse: [number, number];
461
473
  count: number;
474
+ instanceCount: number;
475
+ particleCount: number | [number, number] | [number, number, number];
462
476
  loading: number;
463
- particles: 64 | 256 | 576 | 1024 | 1600 | 2304 | 3136 | 4096 | 4096 | 5184 | 6400;
464
477
  el: HTMLCanvasElement;
465
478
  vs?: string | Vec4;
466
479
  cs?: string | Void;
@@ -481,7 +494,7 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
481
494
  error(e?: string): void;
482
495
  render(): void;
483
496
  resize(e?: Event): void;
484
- mousemove(e: Event): void;
497
+ mousemove(e: MouseEvent): void;
485
498
  loop(): void;
486
499
  _uniform?(key: string, value: number | number[] | Float32Array<ArrayBufferLike>, isMatrix?: boolean): GL;
487
500
  uniform(key: string, value: number | number[] | Float32Array<ArrayBufferLike>, isMatrix?: boolean): GL;
@@ -498,6 +511,11 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
498
511
  attribute(target: {
499
512
  [key: string]: number[] | Float32Array<ArrayBufferLike>;
500
513
  }): GL;
514
+ _instance?(key: string, value: number[] | Float32Array<ArrayBufferLike>, at?: number): GL;
515
+ instance(key: string, value: number[] | Float32Array<ArrayBufferLike>, at?: number): GL;
516
+ instance(target: {
517
+ [key: string]: number[] | Float32Array<ArrayBufferLike>;
518
+ }): GL;
501
519
  _storage?(key: string, value: number[] | Float32Array<ArrayBufferLike>): GL;
502
520
  storage(key: string, value: number[] | Float32Array<ArrayBufferLike>): GL;
503
521
  storage(target: {
@@ -507,4 +525,4 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
507
525
 
508
526
  declare const useGL: (props?: Partial<GL>) => reev.EventState<GL>;
509
527
 
510
- export { AttribData, GL, StorageData, TextureData, UniformData, WebGLState, WebGPUState, createGL, isGL, isServer, isWebGPUSupported, useGL };
528
+ export { type AttribData, type GL, type StorageData, type TextureData, type UniformData, type WebGLState, type WebGPUState, createGL, isGL, isServer, isWebGPUSupported, useGL };
package/dist/solid.d.ts CHANGED
@@ -3,7 +3,7 @@ import { EventState, Nested } from 'reev';
3
3
  import * as refr from 'refr';
4
4
  import { Queue, Frame } from 'refr';
5
5
 
6
- declare const CONVERSIONS: readonly ["toBool", "toUint", "toInt", "toFloat", "toBvec2", "toIvec2", "toUvec2", "toVec2", "toBvec3", "toIvec3", "toUvec3", "toVec3", "toBvec4", "toIvec4", "toUvec4", "toVec4", "toColor", "toMat2", "toMat3", "toMat4"];
6
+ declare const CONVERSIONS: readonly ["toBool", "toUInt", "toInt", "toFloat", "toBVec2", "toIVec2", "toUVec2", "toVec2", "toBVec3", "toIVec3", "toUVec3", "toVec3", "toBVec4", "toIVec4", "toUVec4", "toVec4", "toColor", "toMat2", "toMat3", "toMat4"];
7
7
  declare const TYPE_MAPPING: {
8
8
  readonly bool: "bool";
9
9
  readonly uint: "u32";
@@ -68,7 +68,7 @@ declare const OPERATOR_TYPE_RULES: readonly [readonly ["float", "vec2", "vec2"],
68
68
  * 1.2. index.ts functions and
69
69
  * 3.2. types.ts _N
70
70
  */
71
- declare const FUNCTIONS: readonly [...("texture" | "all" | "any" | "determinant" | "distance" | "dot" | "length" | "lengthSq" | "luminance" | "cross" | "cubeTexture" | "texelFetch" | "textureLod")[], "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "ceil", "cos", "cosh", "dFdx", "dFdy", "degrees", "exp", "exp2", "floor", "fract", "fwidth", "inverseSqrt", "log", "log2", "negate", "normalize", "oneMinus", "radians", "reciprocal", "round", "saturate", "sign", "sin", "sinh", "sqrt", "tan", "tanh", "trunc", "atan2", "clamp", "max", "min", "mix", "pow", "reflect", "refract", "smoothstep", "step"];
71
+ declare const FUNCTIONS: readonly [...("texture" | "all" | "any" | "determinant" | "distance" | "dot" | "length" | "lengthSq" | "luminance" | "cross" | "cubeTexture" | "texelFetch" | "textureLod")[], "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "ceil", "cos", "cosh", "dFdx", "dFdy", "degrees", "exp", "exp2", "floor", "fract", "fwidth", "inverse", "inverseSqrt", "log", "log2", "negate", "normalize", "oneMinus", "radians", "reciprocal", "round", "sign", "sin", "sinh", "sqrt", "tan", "tanh", "trunc", "saturate", "atan2", "clamp", "max", "min", "mix", "pow", "reflect", "refract", "smoothstep", "step"];
72
72
 
73
73
  type Constants = (typeof CONSTANTS)[number] | 'void';
74
74
  type Conversions = (typeof CONVERSIONS)[number];
@@ -82,14 +82,14 @@ interface FnLayout {
82
82
  type: C | 'auto';
83
83
  inputs?: Array<{
84
84
  name: string;
85
- type: C;
85
+ type: C | 'auto';
86
86
  }>;
87
87
  }
88
88
  type StructFields = Record<string, X>;
89
89
  /**
90
90
  * node
91
91
  */
92
- type NodeTypes = 'attribute' | 'storage' | 'uniform' | 'constant' | 'variable' | 'varying' | 'ternary' | 'builtin' | 'conversion' | 'operator' | 'function' | 'struct' | 'member' | 'element' | 'gather' | 'scatter' | 'scope' | 'assign' | 'loop' | 'define' | 'if' | 'switch' | 'declare' | 'return' | 'break' | 'continue';
92
+ type NodeTypes = 'attribute' | 'instance' | 'storage' | 'uniform' | 'constant' | 'variable' | 'varying' | 'ternary' | 'builtin' | 'conversion' | 'operator' | 'function' | 'struct' | 'member' | 'element' | 'gather' | 'scatter' | 'scope' | 'assign' | 'loop' | 'define' | 'if' | 'switch' | 'declare' | 'return' | 'break' | 'continue';
93
93
  interface NodeProps {
94
94
  id?: string;
95
95
  args?: any[];
@@ -194,10 +194,11 @@ type XImpl<T extends C> = _X<T> & {
194
194
  };
195
195
  type C = Constants;
196
196
  type X<T extends C = C> = T extends keyof ConstantsToType ? ConstantsToType[T] : _X<T>;
197
- type Methods = Functions | Operators | Conversions | Swizzles | '__nodeType' | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString' | 'element';
197
+ type Methods = Functions | Operators | Conversions | Swizzles | '__nodeType' | 'type' | 'props' | 'isProxy' | 'assign' | 'toVar' | 'toString' | 'element' | 'select';
198
198
  interface _X<T extends C> {
199
199
  readonly __nodeType?: T;
200
200
  assign(x: any): X<T>;
201
+ select(x: number | X<T>, y: X<'bool'>): X<T>;
201
202
  fragment(c: NodeContext): string;
202
203
  toVar(name?: string): X<T>;
203
204
  toString(c?: NodeContext): string;
@@ -241,20 +242,20 @@ interface _X<T extends C> {
241
242
  shiftLeftAssign<U extends C>(x: ValidateOperator<T, U> extends 0 ? never : number | X<U>): X<T>;
242
243
  shiftRightAssign<U extends C>(x: ValidateOperator<T, U> extends 0 ? never : number | X<U>): X<T>;
243
244
  toBool(): Bool;
244
- toUint(): UInt;
245
+ toUInt(): UInt;
245
246
  toInt(): Int;
246
247
  toFloat(): Float;
247
- toBvec2(): BVec2;
248
- toIvec2(): IVec2;
249
- toUvec2(): UVec2;
248
+ toBVec2(): BVec2;
249
+ toIVec2(): IVec2;
250
+ toUVec2(): UVec2;
250
251
  toVec2(): Vec2;
251
- toBvec3(): BVec3;
252
- toIvec3(): IVec3;
253
- toUvec3(): UVec3;
252
+ toBVec3(): BVec3;
253
+ toIVec3(): IVec3;
254
+ toUVec3(): UVec3;
254
255
  toVec3(): Vec3;
255
- toBvec4(): BVec4;
256
- toIvec4(): IVec4;
257
- toUvec4(): UVec4;
256
+ toBVec4(): BVec4;
257
+ toIVec4(): IVec4;
258
+ toUVec4(): UVec4;
258
259
  toVec4(): Vec4;
259
260
  toColor(): Color;
260
261
  toMat2(): Mat2;
@@ -338,14 +339,17 @@ type GL = EventState<{
338
339
  isWebGL: boolean;
339
340
  isError: boolean;
340
341
  isLoop: boolean;
342
+ isDebug: boolean;
343
+ isDepth: boolean;
341
344
  isGL: true;
342
345
  width?: number;
343
346
  height?: number;
344
347
  size: [number, number];
345
348
  mouse: [number, number];
346
349
  count: number;
350
+ instanceCount: number;
351
+ particleCount: number | [number, number] | [number, number, number];
347
352
  loading: number;
348
- particles: 64 | 256 | 576 | 1024 | 1600 | 2304 | 3136 | 4096 | 4096 | 5184 | 6400;
349
353
  el: HTMLCanvasElement;
350
354
  vs?: string | Vec4;
351
355
  cs?: string | Void;
@@ -372,7 +376,7 @@ type GL = EventState<{
372
376
  error(e?: string): void;
373
377
  render(): void;
374
378
  resize(e?: Event): void;
375
- mousemove(e: Event): void;
379
+ mousemove(e: MouseEvent): void;
376
380
  loop(): void;
377
381
  /**
378
382
  * setter
@@ -392,6 +396,11 @@ type GL = EventState<{
392
396
  attribute(target: {
393
397
  [key: string]: Attribute;
394
398
  }): GL;
399
+ _instance?(key: string, value: Attribute, at?: number): GL;
400
+ instance(key: string, value: Attribute, at?: number): GL;
401
+ instance(target: {
402
+ [key: string]: Attribute;
403
+ }): GL;
395
404
  _storage?(key: string, value: Storage): GL;
396
405
  storage(key: string, value: Storage): GL;
397
406
  storage(target: {
@@ -422,6 +431,7 @@ interface AttribData {
422
431
  buffer: GPUBuffer;
423
432
  location: number;
424
433
  stride: number;
434
+ isInstance?: boolean;
425
435
  }
426
436
  interface StorageData {
427
437
  array: Float32Array;
@@ -453,14 +463,17 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
453
463
  isWebGL: boolean;
454
464
  isError: boolean;
455
465
  isLoop: boolean;
466
+ isDebug: boolean;
467
+ isDepth: boolean;
456
468
  isGL: true;
457
469
  width?: number;
458
470
  height?: number;
459
471
  size: [number, number];
460
472
  mouse: [number, number];
461
473
  count: number;
474
+ instanceCount: number;
475
+ particleCount: number | [number, number] | [number, number, number];
462
476
  loading: number;
463
- particles: 64 | 256 | 576 | 1024 | 1600 | 2304 | 3136 | 4096 | 4096 | 5184 | 6400;
464
477
  el: HTMLCanvasElement;
465
478
  vs?: string | Vec4;
466
479
  cs?: string | Void;
@@ -481,7 +494,7 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
481
494
  error(e?: string): void;
482
495
  render(): void;
483
496
  resize(e?: Event): void;
484
- mousemove(e: Event): void;
497
+ mousemove(e: MouseEvent): void;
485
498
  loop(): void;
486
499
  _uniform?(key: string, value: number | number[] | Float32Array<ArrayBufferLike>, isMatrix?: boolean): GL;
487
500
  uniform(key: string, value: number | number[] | Float32Array<ArrayBufferLike>, isMatrix?: boolean): GL;
@@ -498,6 +511,11 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
498
511
  attribute(target: {
499
512
  [key: string]: number[] | Float32Array<ArrayBufferLike>;
500
513
  }): GL;
514
+ _instance?(key: string, value: number[] | Float32Array<ArrayBufferLike>, at?: number): GL;
515
+ instance(key: string, value: number[] | Float32Array<ArrayBufferLike>, at?: number): GL;
516
+ instance(target: {
517
+ [key: string]: number[] | Float32Array<ArrayBufferLike>;
518
+ }): GL;
501
519
  _storage?(key: string, value: number[] | Float32Array<ArrayBufferLike>): GL;
502
520
  storage(key: string, value: number[] | Float32Array<ArrayBufferLike>): GL;
503
521
  storage(target: {
@@ -507,4 +525,4 @@ declare const createGL: (props?: Partial<GL>) => EventState<{
507
525
 
508
526
  declare const onGL: (props?: Partial<GL>) => reev.EventState<GL>;
509
527
 
510
- export { AttribData, GL, StorageData, TextureData, UniformData, WebGLState, WebGPUState, createGL, isGL, isServer, isWebGPUSupported, onGL };
528
+ export { type AttribData, type GL, type StorageData, type TextureData, type UniformData, type WebGLState, type WebGPUState, createGL, isGL, isServer, isWebGPUSupported, onGL };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glre",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "author": "tseijp",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -30,26 +30,26 @@
30
30
  "module": "./dist/index.js",
31
31
  "exports": {
32
32
  "./packages.json": "./packages.json",
33
- "./src/node": {
34
- "types": "./src/node/index.ts",
35
- "import": "./src/node/index.ts",
36
- "default": "./src/node/index.ts"
37
- },
38
- "./src/react": {
39
- "types": "./src/react.ts",
40
- "import": "./src/react.ts",
41
- "default": "./src/react.ts"
42
- },
43
33
  "./src/addons": {
44
34
  "types": "./src/addons/index.ts",
45
35
  "import": "./src/addons/index.ts",
46
36
  "default": "./src/addons/index.ts"
47
37
  },
38
+ "./src/node": {
39
+ "types": "./src/node/index.ts",
40
+ "import": "./src/node/index.ts",
41
+ "default": "./src/node/index.ts"
42
+ },
48
43
  "./src/native": {
49
44
  "types": "./src/native.ts",
50
45
  "import": "./src/native.ts",
51
46
  "default": "./src/native.ts"
52
47
  },
48
+ "./src/react": {
49
+ "types": "./src/react.ts",
50
+ "import": "./src/react.ts",
51
+ "default": "./src/react.ts"
52
+ },
53
53
  "./src/solid": {
54
54
  "types": "./src/solid.ts",
55
55
  "import": "./src/solid.ts",
@@ -86,19 +86,6 @@
86
86
  "require": "./dist/node.cjs",
87
87
  "default": "./dist/node.js"
88
88
  },
89
- "./react": {
90
- "types": "./dist/react.d.ts",
91
- "import": {
92
- "types": "./dist/react.d.ts",
93
- "default": "./dist/react.js"
94
- },
95
- "module": {
96
- "types": "./dist/react.d.ts",
97
- "default": "./dist/react.js"
98
- },
99
- "require": "./dist/react.cjs",
100
- "default": "./dist/react.js"
101
- },
102
89
  "./native": {
103
90
  "types": "./dist/native.d.ts",
104
91
  "import": {
@@ -112,6 +99,19 @@
112
99
  "require": "./dist/native.cjs",
113
100
  "default": "./dist/native.js"
114
101
  },
102
+ "./react": {
103
+ "types": "./dist/react.d.ts",
104
+ "import": {
105
+ "types": "./dist/react.d.ts",
106
+ "default": "./dist/react.js"
107
+ },
108
+ "module": {
109
+ "types": "./dist/react.d.ts",
110
+ "default": "./dist/react.js"
111
+ },
112
+ "require": "./dist/react.cjs",
113
+ "default": "./dist/react.js"
114
+ },
115
115
  "./solid": {
116
116
  "types": "./dist/solid.d.ts",
117
117
  "import": {
@@ -0,0 +1,10 @@
1
+ import { Fn, Float, pow, sin } from '../../../node'
2
+ import { PI } from '../../math/const'
3
+
4
+ export const backIn = Fn(([t]: [Float]): Float => {
5
+ return pow(t, 3).sub(t.mul(sin(t.mul(PI))))
6
+ }).setLayout({
7
+ name: 'backIn',
8
+ type: 'float',
9
+ inputs: [{ name: 't', type: 'float' }],
10
+ })
@@ -0,0 +1,12 @@
1
+ import { Fn, Float, float } from '../../../node'
2
+ import { backIn } from './backIn'
3
+
4
+ export const backInOut = Fn(([t]: [Float]): Float => {
5
+ const f = t.mul(2).select(float(1).sub(t.mul(2).sub(1)), t.lessThan(0.5))
6
+ const g = backIn(f)
7
+ return g.div(2).select(float(1).sub(g).div(2).add(0.5), t.lessThan(0.5))
8
+ }).setLayout({
9
+ name: 'backInOut',
10
+ type: 'float',
11
+ inputs: [{ name: 't', type: 'float' }],
12
+ })
@@ -0,0 +1,10 @@
1
+ import { Fn, Float, float } from '../../../node'
2
+ import { backIn } from './backIn'
3
+
4
+ export const backOut = Fn(([t]: [Float]): Float => {
5
+ return float(1).sub(backIn(float(1).sub(t)))
6
+ }).setLayout({
7
+ name: 'backOut',
8
+ type: 'float',
9
+ inputs: [{ name: 't', type: 'float' }],
10
+ })
@@ -0,0 +1,10 @@
1
+ import { Fn, Float, float } from '../../../node'
2
+ import { bounceOut } from './bounceOut'
3
+
4
+ export const bounceIn = Fn(([t]: [Float]): Float => {
5
+ return float(1).sub(bounceOut(float(1).sub(t)))
6
+ }).setLayout({
7
+ name: 'bounceIn',
8
+ type: 'float',
9
+ inputs: [{ name: 't', type: 'float' }],
10
+ })
@@ -0,0 +1,13 @@
1
+ import { Fn, Float, float } from '../../../node'
2
+ import { bounceOut } from './bounceOut'
3
+
4
+ export const bounceInOut = Fn(([t]: [Float]): Float => {
5
+ return float(1)
6
+ .sub(bounceOut(float(1).sub(t.mul(2))))
7
+ .div(2)
8
+ .select(bounceOut(t.mul(2).sub(1)).div(2).add(0.5), t.lessThan(0.5))
9
+ }).setLayout({
10
+ name: 'bounceInOut',
11
+ type: 'float',
12
+ inputs: [{ name: 't', type: 'float' }],
13
+ })
@@ -0,0 +1,30 @@
1
+ import { Fn, Float, float } from '../../../node'
2
+
3
+ export const bounceOut = Fn(([t]: [Float]): Float => {
4
+ const a = float(4 / 11)
5
+ const b = float(8 / 11)
6
+ const c = float(9 / 10)
7
+ const ca = float(4356.0 / 361.0)
8
+ const cb = float(35442.0 / 1805.0)
9
+ const cc = float(16061.0 / 1805.0)
10
+ const t2 = t.mul(t)
11
+ return t2.mul(7.5625).select(
12
+ t2
13
+ .mul(9.075)
14
+ .sub(t.mul(9.9))
15
+ .add(3.4)
16
+ .select(
17
+ t2
18
+ .mul(ca)
19
+ .sub(t.mul(cb))
20
+ .add(cc)
21
+ .select(t2.mul(10.8).sub(t.mul(20.52)).add(10.72), t.lessThan(c)),
22
+ t.lessThan(b)
23
+ ),
24
+ t.lessThan(a)
25
+ )
26
+ }).setLayout({
27
+ name: 'bounceOut',
28
+ type: 'float',
29
+ inputs: [{ name: 't', type: 'float' }],
30
+ })
@@ -0,0 +1,9 @@
1
+ import { Fn, X } from '../../../node'
2
+
3
+ export const circularIn = Fn(([t]: [X]): X => {
4
+ return t.mul(t).oneMinus().sqrt().oneMinus()
5
+ }).setLayout({
6
+ name: 'circularIn',
7
+ type: 'auto',
8
+ inputs: [{ name: 't', type: 'auto' }],
9
+ })
@@ -0,0 +1,11 @@
1
+ import { Fn, X } from '../../../node'
2
+
3
+ export const circularInOut = Fn(([t]: [X]): X => {
4
+ const early = t.mul(t).mul(4).oneMinus().sqrt().oneMinus().div(2)
5
+ const late = t.mul(2).sub(1).mul(t.mul(-2).add(3)).sqrt().add(1).div(2)
6
+ return (early as any).select(late, t.lessThan(0.5))
7
+ }).setLayout({
8
+ name: 'circularInOut',
9
+ type: 'auto',
10
+ inputs: [{ name: 't', type: 'auto' }],
11
+ })
@@ -0,0 +1,9 @@
1
+ import { Fn, X, float } from '../../../node'
2
+
3
+ export const circularOut = Fn(([t]: [X]): X => {
4
+ return float(2).sub(t).mul(t).sqrt()
5
+ }).setLayout({
6
+ name: 'circularOut',
7
+ type: 'auto',
8
+ inputs: [{ name: 't', type: 'auto' }],
9
+ })
@@ -0,0 +1,9 @@
1
+ import { Fn, X } from '../../../node'
2
+
3
+ export const cubicIn = Fn(([t]: [X]): X => {
4
+ return t.mul(t).mul(t)
5
+ }).setLayout({
6
+ name: 'cubicIn',
7
+ type: 'auto',
8
+ inputs: [{ name: 't', type: 'auto' }],
9
+ })
@@ -0,0 +1,11 @@
1
+ import { Fn, X } from '../../../node'
2
+
3
+ export const cubicInOut = Fn(([t]: [X]): X => {
4
+ const early = t.mul(t).mul(t).mul(4)
5
+ const late = t.mul(2).sub(2).pow(3).div(2).add(1)
6
+ return (early as any).select(late, t.lessThan(0.5))
7
+ }).setLayout({
8
+ name: 'cubicInOut',
9
+ type: 'auto',
10
+ inputs: [{ name: 't', type: 'auto' }],
11
+ })
@@ -0,0 +1,10 @@
1
+ import { Fn, X } from '../../../node'
2
+
3
+ export const cubicOut = Fn(([t]: [X]): X => {
4
+ const f = t.sub(1)
5
+ return f.mul(f).mul(f).add(1)
6
+ }).setLayout({
7
+ name: 'cubicOut',
8
+ type: 'auto',
9
+ inputs: [{ name: 't', type: 'auto' }],
10
+ })
@@ -0,0 +1,10 @@
1
+ import { Fn, Float, sin, pow, float } from '../../../node'
2
+ import { HALF_PI } from '../../math/const'
3
+
4
+ export const elasticIn = Fn(([t]: [Float]): Float => {
5
+ return sin(t.mul(13).mul(HALF_PI)).mul(pow(float(2), t.sub(1).mul(10)))
6
+ }).setLayout({
7
+ name: 'elasticIn',
8
+ type: 'float',
9
+ inputs: [{ name: 't', type: 'float' }],
10
+ })
@@ -0,0 +1,21 @@
1
+ import { Fn, Float, sin, pow, float } from '../../../node'
2
+ import { HALF_PI } from '../../math/const'
3
+
4
+ export const elasticInOut = Fn(([t]: [Float]): Float => {
5
+ const t2 = t.mul(2)
6
+ const t2minus1 = t2.sub(1)
7
+ return sin(HALF_PI.mul(13).mul(t2))
8
+ .mul(pow(float(2), t2minus1.mul(10)))
9
+ .div(2)
10
+ .select(
11
+ sin(HALF_PI.mul(-13).mul(t2minus1.add(1)))
12
+ .mul(pow(float(2), t2minus1.mul(-10)))
13
+ .div(2)
14
+ .add(1),
15
+ t.lessThan(0.5)
16
+ )
17
+ }).setLayout({
18
+ name: 'elasticInOut',
19
+ type: 'float',
20
+ inputs: [{ name: 't', type: 'float' }],
21
+ })
@@ -0,0 +1,12 @@
1
+ import { Fn, Float, sin, pow, float } from '../../../node'
2
+ import { HALF_PI } from '../../math/const'
3
+
4
+ export const elasticOut = Fn(([t]: [Float]): Float => {
5
+ return sin(float(-13).mul(t.add(1)).mul(HALF_PI))
6
+ .mul(pow(float(2), float(-10).mul(t)))
7
+ .add(1)
8
+ }).setLayout({
9
+ name: 'elasticOut',
10
+ type: 'float',
11
+ inputs: [{ name: 't', type: 'float' }],
12
+ })
@@ -0,0 +1,9 @@
1
+ import { Fn, X } from '../../../node'
2
+
3
+ export const exponentialIn = Fn(([t]: [X]): X => {
4
+ return (t as any).select(t.sub(1).mul(10).exp2(), t.equal(0))
5
+ }).setLayout({
6
+ name: 'exponentialIn',
7
+ type: 'auto',
8
+ inputs: [{ name: 't', type: 'auto' }],
9
+ })