glre 0.39.0 → 0.41.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.
- package/README.md +8 -4
- package/dist/addons.cjs +1 -1
- package/dist/addons.cjs.map +1 -1
- package/dist/addons.d.ts +853 -22
- package/dist/addons.js +1 -1
- package/dist/addons.js.map +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +47 -28
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/native.d.ts +60 -33
- package/dist/node.cjs +59 -30
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +39 -26
- package/dist/node.js +59 -30
- package/dist/node.js.map +1 -1
- package/dist/react.d.ts +47 -28
- package/dist/solid.d.ts +47 -28
- package/package.json +24 -24
- package/src/addons/animation/easing/backIn.ts +10 -0
- package/src/addons/animation/easing/backInOut.ts +12 -0
- package/src/addons/animation/easing/backOut.ts +10 -0
- package/src/addons/animation/easing/bounceIn.ts +10 -0
- package/src/addons/animation/easing/bounceInOut.ts +13 -0
- package/src/addons/animation/easing/bounceOut.ts +30 -0
- package/src/addons/animation/easing/circularIn.ts +9 -0
- package/src/addons/animation/easing/circularInOut.ts +11 -0
- package/src/addons/animation/easing/circularOut.ts +9 -0
- package/src/addons/animation/easing/cubicIn.ts +9 -0
- package/src/addons/animation/easing/cubicInOut.ts +11 -0
- package/src/addons/animation/easing/cubicOut.ts +10 -0
- package/src/addons/animation/easing/elasticIn.ts +10 -0
- package/src/addons/animation/easing/elasticInOut.ts +21 -0
- package/src/addons/animation/easing/elasticOut.ts +12 -0
- package/src/addons/animation/easing/exponentialIn.ts +9 -0
- package/src/addons/animation/easing/exponentialInOut.ts +13 -0
- package/src/addons/animation/easing/exponentialOut.ts +9 -0
- package/src/addons/animation/easing/index.ts +33 -0
- package/src/addons/animation/easing/linearIn.ts +9 -0
- package/src/addons/animation/easing/linearInOut.ts +9 -0
- package/src/addons/animation/easing/linearOut.ts +9 -0
- package/src/addons/animation/easing/quadraticIn.ts +9 -0
- package/src/addons/animation/easing/quadraticInOut.ts +10 -0
- package/src/addons/animation/easing/quadraticOut.ts +9 -0
- package/src/addons/animation/easing/quarticIn.ts +9 -0
- package/src/addons/animation/easing/quarticInOut.ts +11 -0
- package/src/addons/animation/easing/quarticOut.ts +10 -0
- package/src/addons/animation/easing/quinticIn.ts +9 -0
- package/src/addons/animation/easing/quinticInOut.ts +11 -0
- package/src/addons/animation/easing/quinticOut.ts +9 -0
- package/src/addons/animation/easing/sineIn.ts +10 -0
- package/src/addons/animation/easing/sineInOut.ts +10 -0
- package/src/addons/animation/easing/sineOut.ts +10 -0
- package/src/addons/color/palette/macbeth.ts +42 -0
- package/src/addons/color/space/cmyk2rgb.ts +12 -0
- package/src/addons/color/space/gamma2linear.ts +19 -0
- package/src/addons/color/space/hsl2rgb.ts +20 -0
- package/src/addons/color/space/hsv2rgb.ts +18 -0
- package/src/addons/color/space/hue2rgb.ts +12 -0
- package/src/addons/color/space/index.ts +29 -0
- package/src/addons/color/space/lab2lch.ts +22 -0
- package/src/addons/color/space/lab2rgb.ts +19 -0
- package/src/addons/color/space/lab2xyz.ts +32 -0
- package/src/addons/color/space/lch2lab.ts +21 -0
- package/src/addons/color/space/lch2rgb.ts +22 -0
- package/src/addons/color/space/linear2gamma.ts +19 -0
- package/src/addons/color/space/oklab2rgb.ts +35 -0
- package/src/addons/color/space/rgb2cmyk.ts +13 -0
- package/src/addons/color/space/rgb2hcv.ts +29 -0
- package/src/addons/color/space/rgb2hsl.ts +23 -0
- package/src/addons/color/space/rgb2hsv.ts +36 -0
- package/src/addons/color/space/rgb2hue.ts +29 -0
- package/src/addons/color/space/rgb2lab.ts +19 -0
- package/src/addons/color/space/rgb2lch.ts +22 -0
- package/src/addons/color/space/rgb2oklab.ts +45 -0
- package/src/addons/color/space/rgb2srgb.ts +34 -0
- package/src/addons/color/space/rgb2xyz.ts +20 -0
- package/src/addons/color/space/rgb2yiq.ts +22 -0
- package/src/addons/color/space/rgb2yuv.ts +32 -0
- package/src/addons/color/space/srgb2rgb.ts +34 -0
- package/src/addons/color/space/xyz2lab.ts +27 -0
- package/src/addons/color/space/xyz2rgb.ts +30 -0
- package/src/addons/color/space/yiq2rgb.ts +22 -0
- package/src/addons/color/space/yuv2rgb.ts +32 -0
- package/src/addons/draw/arrows.ts +75 -0
- package/src/addons/draw/axis.ts +57 -0
- package/src/addons/draw/bridge.ts +81 -0
- package/src/addons/draw/char.ts +30 -0
- package/src/addons/draw/circle.ts +29 -0
- package/src/addons/draw/fill.ts +25 -0
- package/src/addons/draw/flip.ts +45 -0
- package/src/addons/draw/hex.ts +29 -0
- package/src/addons/draw/index.ts +13 -0
- package/src/addons/draw/line.ts +16 -0
- package/src/addons/draw/point.ts +30 -0
- package/src/addons/draw/rect.ts +52 -0
- package/src/addons/draw/stroke.ts +31 -0
- package/src/addons/draw/tri.ts +29 -0
- package/src/addons/generative/cnoise.ts +239 -0
- package/src/addons/generative/curl.ts +64 -0
- package/src/addons/generative/fbm.ts +69 -0
- package/src/addons/generative/gerstnerWave.ts +21 -0
- package/src/addons/generative/gnoise.ts +113 -0
- package/src/addons/generative/index.ts +15 -0
- package/src/addons/generative/noised.ts +139 -0
- package/src/addons/generative/pnoise.ts +249 -0
- package/src/addons/generative/psrdnoise.ts +277 -0
- package/src/addons/generative/random.ts +136 -0
- package/src/addons/generative/snoise.ts +199 -0
- package/src/addons/generative/srandom.ts +90 -0
- package/src/addons/generative/voronoi.ts +134 -0
- package/src/addons/generative/voronoise.ts +69 -0
- package/src/addons/generative/wavelet.ts +77 -0
- package/src/addons/generative/worley.ts +99 -0
- package/src/addons/geometry/aabb/aabb.ts +8 -0
- package/src/addons/geometry/aabb/centroid.ts +10 -0
- package/src/addons/geometry/aabb/contain.ts +19 -0
- package/src/addons/geometry/aabb/diagonal.ts +10 -0
- package/src/addons/geometry/aabb/expand.ts +16 -0
- package/src/addons/geometry/aabb/index.ts +7 -0
- package/src/addons/geometry/aabb/intersect.ts +20 -0
- package/src/addons/geometry/aabb/square.ts +17 -0
- package/src/addons/geometry/index.ts +2 -0
- package/src/addons/geometry/triangle/area.ts +10 -0
- package/src/addons/geometry/triangle/barycentric.ts +50 -0
- package/src/addons/geometry/triangle/centroid.ts +10 -0
- package/src/addons/geometry/triangle/closestPoint.ts +85 -0
- package/src/addons/geometry/triangle/contain.ts +19 -0
- package/src/addons/geometry/triangle/distanceSq.ts +38 -0
- package/src/addons/geometry/triangle/index.ts +10 -0
- package/src/addons/geometry/triangle/intersect.ts +49 -0
- package/src/addons/geometry/triangle/normal.ts +12 -0
- package/src/addons/geometry/triangle/signedDistance.ts +31 -0
- package/src/addons/geometry/triangle/triangle.ts +9 -0
- package/src/addons/index.ts +8 -6
- package/src/addons/lighting/ray.ts +8 -0
- package/src/addons/math/aafloor.ts +13 -0
- package/src/addons/math/aafract.ts +38 -0
- package/src/addons/math/aamirror.ts +12 -0
- package/src/addons/math/aastep.ts +14 -0
- package/src/addons/math/absi.ts +9 -0
- package/src/addons/math/adaptiveThreshold.ts +24 -0
- package/src/addons/math/bump.ts +20 -0
- package/src/addons/math/const.ts +19 -0
- package/src/addons/math/cubic.ts +101 -0
- package/src/addons/math/cubicMix.ts +49 -0
- package/src/addons/math/decimate.ts +12 -0
- package/src/addons/math/dist.ts +143 -0
- package/src/addons/math/fcos.ts +11 -0
- package/src/addons/math/frac.ts +9 -0
- package/src/addons/math/gain.ts +14 -0
- package/src/addons/math/gaussian.ts +14 -0
- package/src/addons/math/grad4.ts +19 -0
- package/src/addons/math/hammersley.ts +54 -0
- package/src/addons/math/highPass.ts +12 -0
- package/src/addons/math/index.ts +63 -0
- package/src/addons/math/inside.ts +68 -0
- package/src/addons/math/invCubic.ts +9 -0
- package/src/addons/math/invQuartic.ts +9 -0
- package/src/addons/math/inverse.ts +9 -0
- package/src/addons/math/lengthSq.ts +10 -0
- package/src/addons/math/map.ts +27 -0
- package/src/addons/math/mirror.ts +12 -0
- package/src/addons/math/mmax.ts +27 -0
- package/src/addons/math/mmin.ts +28 -0
- package/src/addons/math/mmix.ts +47 -0
- package/src/addons/math/mod2.ts +44 -0
- package/src/addons/math/mod289.ts +46 -0
- package/src/addons/math/modi.ts +15 -0
- package/src/addons/math/nyquist.ts +15 -0
- package/src/addons/math/pack.ts +15 -0
- package/src/addons/math/parabola.ts +12 -0
- package/src/addons/math/permute.ts +42 -0
- package/src/addons/math/pow2.ts +10 -0
- package/src/addons/math/pow3.ts +9 -0
- package/src/addons/math/pow5.ts +10 -0
- package/src/addons/math/pow7.ts +12 -0
- package/src/addons/math/powFast.ts +18 -0
- package/src/addons/math/quartic.ts +15 -0
- package/src/addons/math/quat/index.ts +14 -0
- package/src/addons/math/quat/quat2mat3.ts +28 -0
- package/src/addons/math/quat/quat2mat4.ts +16 -0
- package/src/addons/math/quat/quatAdd.ts +18 -0
- package/src/addons/math/quat/quatConj.ts +14 -0
- package/src/addons/math/quat/quatDiv.ts +18 -0
- package/src/addons/math/quat/quatIdentity.ts +9 -0
- package/src/addons/math/quat/quatInverse.ts +17 -0
- package/src/addons/math/quat/quatLength.ts +15 -0
- package/src/addons/math/quat/quatLengthSq.ts +14 -0
- package/src/addons/math/quat/quatLerp.ts +40 -0
- package/src/addons/math/quat/quatMul.ts +38 -0
- package/src/addons/math/quat/quatNeg.ts +14 -0
- package/src/addons/math/quat/quatNorm.ts +16 -0
- package/src/addons/math/quat/quatSub.ts +18 -0
- package/src/addons/math/quintic.ts +16 -0
- package/src/addons/math/rotate2d.ts +16 -0
- package/src/addons/math/rotate3d.ts +37 -0
- package/src/addons/math/rotate3dX.ts +20 -0
- package/src/addons/math/rotate3dY.ts +20 -0
- package/src/addons/math/rotate3dZ.ts +20 -0
- package/src/addons/math/rotate4d.ts +41 -0
- package/src/addons/math/rotate4dX.ts +21 -0
- package/src/addons/math/rotate4dY.ts +16 -0
- package/src/addons/math/rotate4dZ.ts +21 -0
- package/src/addons/math/saturateMediump.ts +11 -0
- package/src/addons/math/scale2d.ts +44 -0
- package/src/addons/math/scale3d.ts +17 -0
- package/src/addons/math/scale4d.ts +50 -0
- package/src/addons/math/smootherstep.ts +16 -0
- package/src/addons/math/taylorInvSqrt.ts +9 -0
- package/src/addons/math/toMat3.ts +14 -0
- package/src/addons/math/toMat4.ts +14 -0
- package/src/addons/math/translate4d.ts +31 -0
- package/src/addons/math/unpack.ts +88 -0
- package/src/addons/sdf/boxSDF.ts +24 -0
- package/src/addons/sdf/circleSDF.ts +20 -0
- package/src/addons/sdf/crossSDF.ts +17 -0
- package/src/addons/sdf/hexSDF.ts +18 -0
- package/src/addons/sdf/index.ts +7 -0
- package/src/addons/sdf/lineSDF.ts +33 -0
- package/src/addons/sdf/rectSDF.ts +46 -0
- package/src/addons/sdf/sphereSDF.ts +20 -0
- package/src/addons/sdf/triSDF.ts +14 -0
- package/src/addons/space/aspect.ts +14 -0
- package/src/addons/space/bracketing.ts +44 -0
- package/src/addons/space/brickTile.ts +44 -0
- package/src/addons/space/cart2polar.ts +20 -0
- package/src/addons/space/center.ts +32 -0
- package/src/addons/space/checkerTile.ts +41 -0
- package/src/addons/space/depth2viewZ.ts +43 -0
- package/src/addons/space/displace.ts +55 -0
- package/src/addons/space/equirect2xyz.ts +17 -0
- package/src/addons/space/eulerView.ts +19 -0
- package/src/addons/space/fisheye2xyz.ts +18 -0
- package/src/addons/space/flipY.ts +25 -0
- package/src/addons/space/hexTile.ts +18 -0
- package/src/addons/space/index.ts +38 -0
- package/src/addons/space/kaleidoscope.ts +48 -0
- package/src/addons/space/linearizeDepth.ts +17 -0
- package/src/addons/space/lookAt.ts +49 -0
- package/src/addons/space/lookAtView.ts +40 -0
- package/src/addons/space/mirrorTile.ts +73 -0
- package/src/addons/space/nearest.ts +13 -0
- package/src/addons/space/orthographic.ts +25 -0
- package/src/addons/space/parallaxMapping.ts +149 -0
- package/src/addons/space/perspective.ts +24 -0
- package/src/addons/space/polar2cart.ts +24 -0
- package/src/addons/space/ratio.ts +14 -0
- package/src/addons/space/rotate.ts +37 -0
- package/src/addons/space/rotateX.ts +54 -0
- package/src/addons/space/rotateY.ts +54 -0
- package/src/addons/space/rotateZ.ts +54 -0
- package/src/addons/space/scale.ts +13 -0
- package/src/addons/space/sprite.ts +16 -0
- package/src/addons/space/sqTile.ts +20 -0
- package/src/addons/space/tbn.ts +26 -0
- package/src/addons/space/translate.ts +12 -0
- package/src/addons/space/triTile.ts +32 -0
- package/src/addons/space/uncenter.ts +32 -0
- package/src/addons/space/unratio.ts +12 -0
- package/src/addons/space/viewZ2depth.ts +25 -0
- package/src/addons/space/windmillTile.ts +58 -0
- package/src/addons/space/xyz2equirect.ts +10 -0
- package/src/index.ts +5 -2
- package/src/node/build.ts +62 -52
- package/src/node/create.ts +3 -0
- package/src/node/index.ts +1 -2
- package/src/node/scope.ts +27 -25
- package/src/node/types.ts +16 -12
- package/src/node/utils/const.ts +12 -11
- package/src/node/utils/index.ts +15 -12
- package/src/node/utils/infer.ts +17 -6
- package/src/node/utils/parse.ts +37 -13
- package/src/node/utils/utils.ts +40 -22
- package/src/types.ts +13 -5
- package/src/utils/helpers.ts +80 -7
- package/src/utils/pipeline.ts +21 -5
- package/src/utils/program.ts +68 -42
- package/src/utils/webgl.ts +47 -37
- package/src/utils/webgpu.ts +30 -38
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Fn, Float, Vec2, Vec3, Vec4 } from '../../node'
|
|
2
|
+
|
|
3
|
+
export const cubic = Fn(([v]: [Float]): Float => {
|
|
4
|
+
return v.mul(v).mul(v.mul(-2).add(3))
|
|
5
|
+
}).setLayout({
|
|
6
|
+
name: 'cubicFloat',
|
|
7
|
+
type: 'float',
|
|
8
|
+
inputs: [{ name: 'v', type: 'float' }],
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
export const cubicVec2 = Fn(([v]: [Vec2]): Vec2 => {
|
|
12
|
+
return v.mul(v).mul(v.mul(-2).add(3))
|
|
13
|
+
}).setLayout({
|
|
14
|
+
name: 'cubicVec2',
|
|
15
|
+
type: 'vec2',
|
|
16
|
+
inputs: [{ name: 'v', type: 'vec2' }],
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
export const cubicVec3 = Fn(([v]: [Vec3]): Vec3 => {
|
|
20
|
+
return v.mul(v).mul(v.mul(-2).add(3))
|
|
21
|
+
}).setLayout({
|
|
22
|
+
name: 'cubicVec3',
|
|
23
|
+
type: 'vec3',
|
|
24
|
+
inputs: [{ name: 'v', type: 'vec3' }],
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const cubicVec4 = Fn(([v]: [Vec4]): Vec4 => {
|
|
28
|
+
return v.mul(v).mul(v.mul(-2).add(3))
|
|
29
|
+
}).setLayout({
|
|
30
|
+
name: 'cubicVec4',
|
|
31
|
+
type: 'vec4',
|
|
32
|
+
inputs: [{ name: 'v', type: 'vec4' }],
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export const cubicFloatSlopes = Fn(([v, slope0, slope1]: [Float, Float, Float]): Float => {
|
|
36
|
+
const a = slope0.add(slope1).sub(2).toVar('a')
|
|
37
|
+
const b = slope0.mul(-2).sub(slope1).add(3).toVar('b')
|
|
38
|
+
const c = slope0.toVar('c')
|
|
39
|
+
const v2 = v.mul(v).toVar('v2')
|
|
40
|
+
const v3 = v.mul(v2).toVar('v3')
|
|
41
|
+
return a.mul(v3).add(b.mul(v2)).add(c.mul(v))
|
|
42
|
+
}).setLayout({
|
|
43
|
+
name: 'cubicFloatSlopes',
|
|
44
|
+
type: 'float',
|
|
45
|
+
inputs: [
|
|
46
|
+
{ name: 'v', type: 'float' },
|
|
47
|
+
{ name: 'slope0', type: 'float' },
|
|
48
|
+
{ name: 'slope1', type: 'float' },
|
|
49
|
+
],
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
export const cubicVec2Slopes = Fn(([v, slope0, slope1]: [Vec2, Float, Float]): Vec2 => {
|
|
53
|
+
const a = slope0.add(slope1).sub(2).toVar('a')
|
|
54
|
+
const b = slope0.mul(-2).sub(slope1).add(3).toVar('b')
|
|
55
|
+
const c = slope0.toVar('c')
|
|
56
|
+
const v2 = v.mul(v).toVar('v2')
|
|
57
|
+
const v3 = v.mul(v2).toVar('v3')
|
|
58
|
+
return a.mul(v3).add(b.mul(v2)).add(c.mul(v))
|
|
59
|
+
}).setLayout({
|
|
60
|
+
name: 'cubicVec2Slopes',
|
|
61
|
+
type: 'vec2',
|
|
62
|
+
inputs: [
|
|
63
|
+
{ name: 'v', type: 'vec2' },
|
|
64
|
+
{ name: 'slope0', type: 'float' },
|
|
65
|
+
{ name: 'slope1', type: 'float' },
|
|
66
|
+
],
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
export const cubicVec3Slopes = Fn(([v, slope0, slope1]: [Vec3, Float, Float]): Vec3 => {
|
|
70
|
+
const a = slope0.add(slope1).sub(2).toVar('a')
|
|
71
|
+
const b = slope0.mul(-2).sub(slope1).add(3).toVar('b')
|
|
72
|
+
const c = slope0.toVar('c')
|
|
73
|
+
const v2 = v.mul(v).toVar('v2')
|
|
74
|
+
const v3 = v.mul(v2).toVar('v3')
|
|
75
|
+
return a.mul(v3).add(b.mul(v2)).add(c.mul(v))
|
|
76
|
+
}).setLayout({
|
|
77
|
+
name: 'cubicVec3Slopes',
|
|
78
|
+
type: 'vec3',
|
|
79
|
+
inputs: [
|
|
80
|
+
{ name: 'v', type: 'vec3' },
|
|
81
|
+
{ name: 'slope0', type: 'float' },
|
|
82
|
+
{ name: 'slope1', type: 'float' },
|
|
83
|
+
],
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
export const cubicVec4Slopes = Fn(([v, slope0, slope1]: [Vec4, Float, Float]): Vec4 => {
|
|
87
|
+
const a = slope0.add(slope1).sub(2).toVar('a')
|
|
88
|
+
const b = slope0.mul(-2).sub(slope1).add(3).toVar('b')
|
|
89
|
+
const c = slope0.toVar('c')
|
|
90
|
+
const v2 = v.mul(v).toVar('v2')
|
|
91
|
+
const v3 = v.mul(v2).toVar('v3')
|
|
92
|
+
return a.mul(v3).add(b.mul(v2)).add(c.mul(v))
|
|
93
|
+
}).setLayout({
|
|
94
|
+
name: 'cubicVec4Slopes',
|
|
95
|
+
type: 'vec4',
|
|
96
|
+
inputs: [
|
|
97
|
+
{ name: 'v', type: 'vec4' },
|
|
98
|
+
{ name: 'slope0', type: 'float' },
|
|
99
|
+
{ name: 'slope1', type: 'float' },
|
|
100
|
+
],
|
|
101
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { X, Fn, Float, Vec2, Vec3, Vec4 } from '../../node'
|
|
2
|
+
import { cubic, cubicVec2, cubicVec3, cubicVec4 } from './cubic'
|
|
3
|
+
|
|
4
|
+
export const cubicMix = Fn(([a, b, t]: [Float, Float, Float]): X => {
|
|
5
|
+
return a.add(b.sub(a).mul(cubic(t)))
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'cubicMix',
|
|
8
|
+
type: 'auto',
|
|
9
|
+
inputs: [
|
|
10
|
+
{ name: 'a', type: 'auto' },
|
|
11
|
+
{ name: 'b', type: 'auto' },
|
|
12
|
+
{ name: 't', type: 'auto' },
|
|
13
|
+
],
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export const cubicMixVec2 = Fn(([a, b, t]: [Vec2, Vec2, Vec2]): X => {
|
|
17
|
+
return a.add(b.sub(a).mul(cubicVec2(t)))
|
|
18
|
+
}).setLayout({
|
|
19
|
+
name: 'cubicMixVec2',
|
|
20
|
+
type: 'auto',
|
|
21
|
+
inputs: [
|
|
22
|
+
{ name: 'a', type: 'auto' },
|
|
23
|
+
{ name: 'b', type: 'auto' },
|
|
24
|
+
{ name: 't', type: 'auto' },
|
|
25
|
+
],
|
|
26
|
+
})
|
|
27
|
+
export const cubicMixVec3 = Fn(([a, b, t]: [Vec3, Vec3, Vec3]): X => {
|
|
28
|
+
return a.add(b.sub(a).mul(cubicVec3(t)))
|
|
29
|
+
}).setLayout({
|
|
30
|
+
name: 'cubicMixVec3',
|
|
31
|
+
type: 'auto',
|
|
32
|
+
inputs: [
|
|
33
|
+
{ name: 'a', type: 'auto' },
|
|
34
|
+
{ name: 'b', type: 'auto' },
|
|
35
|
+
{ name: 't', type: 'auto' },
|
|
36
|
+
],
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
export const cubicMixVec4 = Fn(([a, b, t]: [Vec4, Vec4, Vec4]): X => {
|
|
40
|
+
return a.add(b.sub(a).mul(cubicVec4(t)))
|
|
41
|
+
}).setLayout({
|
|
42
|
+
name: 'cubicMixVec4',
|
|
43
|
+
type: 'auto',
|
|
44
|
+
inputs: [
|
|
45
|
+
{ name: 'a', type: 'auto' },
|
|
46
|
+
{ name: 'b', type: 'auto' },
|
|
47
|
+
{ name: 't', type: 'auto' },
|
|
48
|
+
],
|
|
49
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { X, Fn } from '../../node'
|
|
2
|
+
|
|
3
|
+
export const decimate = Fn(([v, p]: [X, X]): X => {
|
|
4
|
+
return v.mul(p).floor().div(p)
|
|
5
|
+
}).setLayout({
|
|
6
|
+
name: 'decimate',
|
|
7
|
+
type: 'auto',
|
|
8
|
+
inputs: [
|
|
9
|
+
{ name: 'v', type: 'auto' },
|
|
10
|
+
{ name: 'p', type: 'auto' },
|
|
11
|
+
],
|
|
12
|
+
})
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Fn, Vec2, Vec3, Vec4, Float, abs, distance, max, pow } from '../../node'
|
|
2
|
+
|
|
3
|
+
const DIST_MINKOWSKI_P = 2.0
|
|
4
|
+
|
|
5
|
+
export const distEuclidean = Fn(([a, b]: [Vec2 | Vec3 | Vec4, Vec2 | Vec3 | Vec4]): Float => {
|
|
6
|
+
return distance(a, b)
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'distEuclidean',
|
|
9
|
+
type: 'float',
|
|
10
|
+
inputs: [
|
|
11
|
+
{ name: 'a', type: 'auto' },
|
|
12
|
+
{ name: 'b', type: 'auto' },
|
|
13
|
+
],
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export const distManhattan = Fn(([a, b]: [Vec2, Vec2]): Float => {
|
|
17
|
+
return abs(a.x.sub(b.x)).add(abs(a.y.sub(b.y)))
|
|
18
|
+
}).setLayout({
|
|
19
|
+
name: 'distManhattan',
|
|
20
|
+
type: 'float',
|
|
21
|
+
inputs: [
|
|
22
|
+
{ name: 'a', type: 'vec2' },
|
|
23
|
+
{ name: 'b', type: 'vec2' },
|
|
24
|
+
],
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const distManhattan3 = Fn(([a, b]: [Vec3, Vec3]): Float => {
|
|
28
|
+
return abs(a.x.sub(b.x))
|
|
29
|
+
.add(abs(a.y.sub(b.y)))
|
|
30
|
+
.add(abs(a.z.sub(b.z)))
|
|
31
|
+
}).setLayout({
|
|
32
|
+
name: 'distManhattan',
|
|
33
|
+
type: 'float',
|
|
34
|
+
inputs: [
|
|
35
|
+
{ name: 'a', type: 'vec3' },
|
|
36
|
+
{ name: 'b', type: 'vec3' },
|
|
37
|
+
],
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
export const distManhattan4 = Fn(([a, b]: [Vec4, Vec4]): Float => {
|
|
41
|
+
return abs(a.x.sub(b.x))
|
|
42
|
+
.add(abs(a.y.sub(b.y)))
|
|
43
|
+
.add(abs(a.z.sub(b.z)))
|
|
44
|
+
.add(abs(a.w.sub(b.w)))
|
|
45
|
+
}).setLayout({
|
|
46
|
+
name: 'distManhattan',
|
|
47
|
+
type: 'float',
|
|
48
|
+
inputs: [
|
|
49
|
+
{ name: 'a', type: 'vec4' },
|
|
50
|
+
{ name: 'b', type: 'vec4' },
|
|
51
|
+
],
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
export const distChebychev = Fn(([a, b]: [Vec2, Vec2]): Float => {
|
|
55
|
+
return max(abs(a.x.sub(b.x)), abs(a.y.sub(b.y)))
|
|
56
|
+
}).setLayout({
|
|
57
|
+
name: 'distChebychev',
|
|
58
|
+
type: 'float',
|
|
59
|
+
inputs: [
|
|
60
|
+
{ name: 'a', type: 'vec2' },
|
|
61
|
+
{ name: 'b', type: 'vec2' },
|
|
62
|
+
],
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
export const distChebychev3 = Fn(([a, b]: [Vec3, Vec3]): Float => {
|
|
66
|
+
return max(abs(a.x.sub(b.x)), max(abs(a.y.sub(b.y)), abs(a.z.sub(b.z))))
|
|
67
|
+
}).setLayout({
|
|
68
|
+
name: 'distChebychev',
|
|
69
|
+
type: 'float',
|
|
70
|
+
inputs: [
|
|
71
|
+
{ name: 'a', type: 'vec3' },
|
|
72
|
+
{ name: 'b', type: 'vec3' },
|
|
73
|
+
],
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
export const distChebychev4 = Fn(([a, b]: [Vec4, Vec4]): Float => {
|
|
77
|
+
return max(abs(a.x.sub(b.x)), max(abs(a.y.sub(b.y)), max(abs(a.z.sub(b.z)), abs(a.w.sub(b.w)))))
|
|
78
|
+
}).setLayout({
|
|
79
|
+
name: 'distChebychev',
|
|
80
|
+
type: 'float',
|
|
81
|
+
inputs: [
|
|
82
|
+
{ name: 'a', type: 'vec4' },
|
|
83
|
+
{ name: 'b', type: 'vec4' },
|
|
84
|
+
],
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
export const distMinkowski = Fn(([a, b]: [Vec2, Vec2]): Float => {
|
|
88
|
+
const p = DIST_MINKOWSKI_P
|
|
89
|
+
return pow(pow(abs(a.x.sub(b.x)), p).add(pow(abs(a.y.sub(b.y)), p)), 1 / p)
|
|
90
|
+
}).setLayout({
|
|
91
|
+
name: 'distMinkowski',
|
|
92
|
+
type: 'float',
|
|
93
|
+
inputs: [
|
|
94
|
+
{ name: 'a', type: 'vec2' },
|
|
95
|
+
{ name: 'b', type: 'vec2' },
|
|
96
|
+
],
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
export const distMinkowski3 = Fn(([a, b]: [Vec3, Vec3]): Float => {
|
|
100
|
+
const p = DIST_MINKOWSKI_P
|
|
101
|
+
return pow(
|
|
102
|
+
pow(abs(a.x.sub(b.x)), p)
|
|
103
|
+
.add(pow(abs(a.y.sub(b.y)), p))
|
|
104
|
+
.add(pow(abs(a.z.sub(b.z)), p)),
|
|
105
|
+
1 / p
|
|
106
|
+
)
|
|
107
|
+
}).setLayout({
|
|
108
|
+
name: 'distMinkowski',
|
|
109
|
+
type: 'float',
|
|
110
|
+
inputs: [
|
|
111
|
+
{ name: 'a', type: 'vec3' },
|
|
112
|
+
{ name: 'b', type: 'vec3' },
|
|
113
|
+
],
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
export const distMinkowski4 = Fn(([a, b]: [Vec4, Vec4]): Float => {
|
|
117
|
+
const p = DIST_MINKOWSKI_P
|
|
118
|
+
return pow(
|
|
119
|
+
pow(abs(a.x.sub(b.x)), p)
|
|
120
|
+
.add(pow(abs(a.y.sub(b.y)), p))
|
|
121
|
+
.add(pow(abs(a.z.sub(b.z)), p))
|
|
122
|
+
.add(pow(abs(a.w.sub(b.w)), p)),
|
|
123
|
+
1 / p
|
|
124
|
+
)
|
|
125
|
+
}).setLayout({
|
|
126
|
+
name: 'distMinkowski',
|
|
127
|
+
type: 'float',
|
|
128
|
+
inputs: [
|
|
129
|
+
{ name: 'a', type: 'vec4' },
|
|
130
|
+
{ name: 'b', type: 'vec4' },
|
|
131
|
+
],
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
export const dist = Fn(([a, b]: [Vec2 | Vec3 | Vec4, Vec2 | Vec3 | Vec4]): Float => {
|
|
135
|
+
return distEuclidean(a, b)
|
|
136
|
+
}).setLayout({
|
|
137
|
+
name: 'dist',
|
|
138
|
+
type: 'float',
|
|
139
|
+
inputs: [
|
|
140
|
+
{ name: 'a', type: 'auto' },
|
|
141
|
+
{ name: 'b', type: 'auto' },
|
|
142
|
+
],
|
|
143
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Fn, Float, cos, fwidth, smoothstep } from '../../node'
|
|
2
|
+
import { TWO_PI } from './const'
|
|
3
|
+
|
|
4
|
+
export const fcos = Fn(([x]: [Float]): Float => {
|
|
5
|
+
const w = fwidth(x)
|
|
6
|
+
return cos(x).mul(smoothstep(TWO_PI, 0, w))
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'fcos',
|
|
9
|
+
type: 'float',
|
|
10
|
+
inputs: [{ name: 'x', type: 'float' }],
|
|
11
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Fn, X, float, select } from '../../node'
|
|
2
|
+
|
|
3
|
+
export const gain = Fn(([x, k]: [X, X]): X => {
|
|
4
|
+
const conditionValue = select(x.oneMinus(), x, x.lessThan(0.5))
|
|
5
|
+
const a = float(0.5).mul(float(2).mul(conditionValue).pow(k)).toVar('a')
|
|
6
|
+
return select(a.oneMinus(), a, x.lessThan(0.5))
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'gain',
|
|
9
|
+
type: 'auto',
|
|
10
|
+
inputs: [
|
|
11
|
+
{ name: 'x', type: 'auto' },
|
|
12
|
+
{ name: 'k', type: 'auto' },
|
|
13
|
+
],
|
|
14
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Fn, X, dot } from '../../node'
|
|
2
|
+
|
|
3
|
+
export const gaussian = Fn(([d, s]: [X<'vec2' | 'vec3' | 'vec4' | 'ivec2' | 'ivec3' | 'ivec4'>, X]): X => {
|
|
4
|
+
const dotProduct = dot(d, d)
|
|
5
|
+
const variance = s.mul(s).mul(2)
|
|
6
|
+
return dotProduct.negate().div(variance).exp()
|
|
7
|
+
}).setLayout({
|
|
8
|
+
name: 'gaussian',
|
|
9
|
+
type: 'float',
|
|
10
|
+
inputs: [
|
|
11
|
+
{ name: 'd', type: 'auto' },
|
|
12
|
+
{ name: 's', type: 'auto' },
|
|
13
|
+
],
|
|
14
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fn, Float, Vec4, vec4, vec3, float } from '../../node'
|
|
2
|
+
|
|
3
|
+
export const grad4 = Fn(([j, ip]: [Float, Vec4]): Vec4 => {
|
|
4
|
+
const ones = vec4(1, 1, 1, -1).toVar('ones')
|
|
5
|
+
const p = vec4(0).toVar('p')
|
|
6
|
+
const s = vec4(0).toVar('s')
|
|
7
|
+
p.xyz = vec3(j, j, j).mul(ip.xyz).fract().mul(7).floor().mul(ip.z).sub(1)
|
|
8
|
+
p.w = float(1.5).sub(p.xyz.abs().dot(ones.xyz))
|
|
9
|
+
s.assign(vec4(p.x.lessThan(0.0), p.y.lessThan(0.0), p.z.lessThan(0.0), p.w.lessThan(0.0)))
|
|
10
|
+
p.xyz = p.xyz.add(s.xyz.mul(2).sub(1).mul(s.www))
|
|
11
|
+
return p
|
|
12
|
+
}).setLayout({
|
|
13
|
+
name: 'grad4',
|
|
14
|
+
type: 'vec4',
|
|
15
|
+
inputs: [
|
|
16
|
+
{ name: 'j', type: 'float' },
|
|
17
|
+
{ name: 'ip', type: 'vec4' },
|
|
18
|
+
],
|
|
19
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PI } from './const'
|
|
2
|
+
import { Fn, Int, Vec2, Vec3, float, vec2, vec3, uint } from '../../node'
|
|
3
|
+
|
|
4
|
+
export const hammersley = Fn(([index, numSamples]: [Int, Int]): Vec2 => {
|
|
5
|
+
const tof = float(0.5).div(float(2147483648)).toVar('tof')
|
|
6
|
+
const bits = uint(index).toVar('bits')
|
|
7
|
+
|
|
8
|
+
bits.assign(bits.shiftLeft(uint(16)).bitOr(bits.shiftRight(uint(16))))
|
|
9
|
+
bits.assign(
|
|
10
|
+
bits
|
|
11
|
+
.bitAnd(uint(0x55555555))
|
|
12
|
+
.shiftLeft(uint(1))
|
|
13
|
+
.bitOr(bits.bitAnd(uint(0xaaaaaaaa)).shiftRight(uint(1)))
|
|
14
|
+
)
|
|
15
|
+
bits.assign(
|
|
16
|
+
bits
|
|
17
|
+
.bitAnd(uint(0x33333333))
|
|
18
|
+
.shiftLeft(uint(2))
|
|
19
|
+
.bitOr(bits.bitAnd(uint(0xcccccccc)).shiftRight(uint(2)))
|
|
20
|
+
)
|
|
21
|
+
bits.assign(
|
|
22
|
+
bits
|
|
23
|
+
.bitAnd(uint(0x0f0f0f0f))
|
|
24
|
+
.shiftLeft(uint(4))
|
|
25
|
+
.bitOr(bits.bitAnd(uint(0xf0f0f0f0)).shiftRight(uint(4)))
|
|
26
|
+
)
|
|
27
|
+
bits.assign(
|
|
28
|
+
bits
|
|
29
|
+
.bitAnd(uint(0x00ff00ff))
|
|
30
|
+
.shiftLeft(uint(8))
|
|
31
|
+
.bitOr(bits.bitAnd(uint(0xff00ff00)).shiftRight(uint(8)))
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
return vec2(float(index).div(float(numSamples)), float(bits).mul(tof))
|
|
35
|
+
}).setLayout({
|
|
36
|
+
name: 'hammersley',
|
|
37
|
+
type: 'vec2',
|
|
38
|
+
inputs: [
|
|
39
|
+
{ name: 'index', type: 'int' },
|
|
40
|
+
{ name: 'numSamples', type: 'int' },
|
|
41
|
+
],
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
export const hemisphereCosSample = Fn(([u]: [Vec2]): Vec3 => {
|
|
45
|
+
const phi = float(2).mul(PI).mul(u.x).toVar('phi')
|
|
46
|
+
const cosTheta2 = float(1).sub(u.y).toVar('cosTheta2')
|
|
47
|
+
const cosTheta = cosTheta2.sqrt().toVar('cosTheta')
|
|
48
|
+
const sinTheta = float(1).sub(cosTheta2).sqrt().toVar('sinTheta')
|
|
49
|
+
return vec3(phi.cos().mul(sinTheta), phi.sin().mul(sinTheta), cosTheta)
|
|
50
|
+
}).setLayout({
|
|
51
|
+
name: 'hemisphereCosSample',
|
|
52
|
+
type: 'vec3',
|
|
53
|
+
inputs: [{ name: 'u', type: 'vec2' }],
|
|
54
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fn, Float, max, float } from '../../node'
|
|
2
|
+
|
|
3
|
+
export const highPass = Fn(([v, b]: [Float, Float]): Float => {
|
|
4
|
+
return max(v.sub(b), 0).div(float(1).sub(b))
|
|
5
|
+
}).setLayout({
|
|
6
|
+
name: 'highPass',
|
|
7
|
+
type: 'float',
|
|
8
|
+
inputs: [
|
|
9
|
+
{ name: 'v', type: 'float' },
|
|
10
|
+
{ name: 'b', type: 'float' },
|
|
11
|
+
],
|
|
12
|
+
})
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export * from './aafloor'
|
|
2
|
+
export * from './aafract'
|
|
3
|
+
export * from './aamirror'
|
|
4
|
+
export * from './aastep'
|
|
5
|
+
export * from './absi'
|
|
6
|
+
export * from './adaptiveThreshold'
|
|
7
|
+
export * from './bump'
|
|
8
|
+
export * from './const'
|
|
9
|
+
export * from './cubic'
|
|
10
|
+
export * from './cubicMix'
|
|
11
|
+
export * from './decimate'
|
|
12
|
+
export * from './dist'
|
|
13
|
+
export * from './fcos'
|
|
14
|
+
export * from './frac'
|
|
15
|
+
export * from './gain'
|
|
16
|
+
export * from './gaussian'
|
|
17
|
+
export * from './grad4'
|
|
18
|
+
export * from './hammersley'
|
|
19
|
+
export * from './highPass'
|
|
20
|
+
export * from './inside'
|
|
21
|
+
export * from './invCubic'
|
|
22
|
+
export * from './invQuartic'
|
|
23
|
+
export * from './inverse'
|
|
24
|
+
export * from './lengthSq'
|
|
25
|
+
export * from './map'
|
|
26
|
+
export * from './mirror'
|
|
27
|
+
export * from './mmax'
|
|
28
|
+
export * from './mmin'
|
|
29
|
+
export * from './mmix'
|
|
30
|
+
export * from './mod289'
|
|
31
|
+
export * from './mod2'
|
|
32
|
+
export * from './modi'
|
|
33
|
+
export * from './nyquist'
|
|
34
|
+
export * from './pack'
|
|
35
|
+
export * from './parabola'
|
|
36
|
+
export * from './permute'
|
|
37
|
+
export * from './pow2'
|
|
38
|
+
export * from './pow3'
|
|
39
|
+
export * from './pow5'
|
|
40
|
+
export * from './pow7'
|
|
41
|
+
export * from './powFast'
|
|
42
|
+
export * from './quat'
|
|
43
|
+
export * from './quartic'
|
|
44
|
+
export * from './quintic'
|
|
45
|
+
export * from './rotate2d'
|
|
46
|
+
export * from './rotate3d'
|
|
47
|
+
export * from './rotate3dX'
|
|
48
|
+
export * from './rotate3dY'
|
|
49
|
+
export * from './rotate3dZ'
|
|
50
|
+
export * from './rotate4d'
|
|
51
|
+
export * from './rotate4dX'
|
|
52
|
+
export * from './rotate4dY'
|
|
53
|
+
export * from './rotate4dZ'
|
|
54
|
+
export * from './saturateMediump'
|
|
55
|
+
export * from './scale2d'
|
|
56
|
+
export * from './scale3d'
|
|
57
|
+
export * from './scale4d'
|
|
58
|
+
export * from './smootherstep'
|
|
59
|
+
export * from './taylorInvSqrt'
|
|
60
|
+
export * from './toMat3'
|
|
61
|
+
export * from './toMat4'
|
|
62
|
+
export * from './translate4d'
|
|
63
|
+
export * from './unpack'
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Fn, all } from '../../node'
|
|
2
|
+
import type { Bool, Float, Vec2, Vec3, Vec4, X } from '../../node/types'
|
|
3
|
+
|
|
4
|
+
export const inside = Fn(([x, min, max]: [X, X, X]): Bool => {
|
|
5
|
+
return all(x.greaterThanEqual(min).and(x.lessThanEqual(max)))
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'inside',
|
|
8
|
+
type: 'bool',
|
|
9
|
+
inputs: [
|
|
10
|
+
{ name: 'x', type: 'auto' },
|
|
11
|
+
{ name: 'min', type: 'auto' },
|
|
12
|
+
{ name: 'max', type: 'auto' },
|
|
13
|
+
],
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export const insideFloat = Fn(([x, min, max]: [Float, Float, Float]): Bool => {
|
|
17
|
+
return x.greaterThanEqual(min).and(x.lessThanEqual(max))
|
|
18
|
+
}).setLayout({
|
|
19
|
+
name: 'insideFloat',
|
|
20
|
+
type: 'bool',
|
|
21
|
+
inputs: [
|
|
22
|
+
{ name: 'x', type: 'float' },
|
|
23
|
+
{ name: 'min', type: 'float' },
|
|
24
|
+
{ name: 'max', type: 'float' },
|
|
25
|
+
],
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
export const insideVec2 = Fn(([v, min, max]: [Vec2, Vec2, Vec2]): Bool => {
|
|
29
|
+
return v.x
|
|
30
|
+
.greaterThanEqual(min.x)
|
|
31
|
+
.and(v.x.lessThanEqual(max.x))
|
|
32
|
+
.and(v.y.greaterThanEqual(min.y).and(v.y.lessThanEqual(max.y)))
|
|
33
|
+
}).setLayout({
|
|
34
|
+
name: 'insideVec2',
|
|
35
|
+
type: 'bool',
|
|
36
|
+
inputs: [
|
|
37
|
+
{ name: 'v', type: 'vec2' },
|
|
38
|
+
{ name: 'min', type: 'vec2' },
|
|
39
|
+
{ name: 'max', type: 'vec2' },
|
|
40
|
+
],
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
export const insideVec3 = Fn(([v, min, max]: [Vec3, Vec3, Vec3]): Bool => {
|
|
44
|
+
return v.x
|
|
45
|
+
.greaterThanEqual(min.x)
|
|
46
|
+
.and(v.x.lessThanEqual(max.x))
|
|
47
|
+
.and(v.y.greaterThanEqual(min.y).and(v.y.lessThanEqual(max.y)))
|
|
48
|
+
.and(v.z.greaterThanEqual(min.z).and(v.z.lessThanEqual(max.z)))
|
|
49
|
+
}).setLayout({
|
|
50
|
+
name: 'insideVec3',
|
|
51
|
+
type: 'bool',
|
|
52
|
+
inputs: [
|
|
53
|
+
{ name: 'v', type: 'vec3' },
|
|
54
|
+
{ name: 'min', type: 'vec3' },
|
|
55
|
+
{ name: 'max', type: 'vec3' },
|
|
56
|
+
],
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
export const insideAABB = Fn(([v, aabb]: [Vec2, Vec4]): Bool => {
|
|
60
|
+
return insideVec2(v, aabb.xy, aabb.zw)
|
|
61
|
+
}).setLayout({
|
|
62
|
+
name: 'insideAABB',
|
|
63
|
+
type: 'bool',
|
|
64
|
+
inputs: [
|
|
65
|
+
{ name: 'v', type: 'vec2' },
|
|
66
|
+
{ name: 'aabb', type: 'vec4' },
|
|
67
|
+
],
|
|
68
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Fn, X, float } from '../../node'
|
|
2
|
+
|
|
3
|
+
export const invCubic = Fn(([v]: [X]): X => {
|
|
4
|
+
return float(0.5).sub(float(1).sub(float(2).mul(v)).asin().div(3).sin())
|
|
5
|
+
}).setLayout({
|
|
6
|
+
name: 'invCubic',
|
|
7
|
+
type: 'auto',
|
|
8
|
+
inputs: [{ name: 'v', type: 'auto' }],
|
|
9
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fn } from '../../node'
|
|
2
|
+
import type { Vec2, X } from '../../node/types'
|
|
3
|
+
|
|
4
|
+
export const lengthSq = Fn(([v]: [X]): X => {
|
|
5
|
+
return (v as Vec2).dot(v as Vec2) as X
|
|
6
|
+
}).setLayout({
|
|
7
|
+
name: 'lengthSq',
|
|
8
|
+
type: 'auto',
|
|
9
|
+
inputs: [{ name: 'v', type: 'auto' }],
|
|
10
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Fn, X } from '../../node'
|
|
2
|
+
|
|
3
|
+
export const map = Fn(([v, iMin, iMax]: [X, X, X]): X => {
|
|
4
|
+
return v.sub(iMin).div(iMax.sub(iMin))
|
|
5
|
+
}).setLayout({
|
|
6
|
+
name: 'map',
|
|
7
|
+
type: 'auto',
|
|
8
|
+
inputs: [
|
|
9
|
+
{ name: 'v', type: 'auto' },
|
|
10
|
+
{ name: 'iMin', type: 'auto' },
|
|
11
|
+
{ name: 'iMax', type: 'auto' },
|
|
12
|
+
],
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const mapRange = Fn(([v, iMin, iMax, oMin, oMax]: [X, X, X, X, X]): X => {
|
|
16
|
+
return oMin.add(oMax.sub(oMin).mul(v.sub(iMin).div(iMax.sub(iMin))))
|
|
17
|
+
}).setLayout({
|
|
18
|
+
name: 'mapRange',
|
|
19
|
+
type: 'auto',
|
|
20
|
+
inputs: [
|
|
21
|
+
{ name: 'v', type: 'auto' },
|
|
22
|
+
{ name: 'iMin', type: 'auto' },
|
|
23
|
+
{ name: 'iMax', type: 'auto' },
|
|
24
|
+
{ name: 'oMin', type: 'auto' },
|
|
25
|
+
{ name: 'oMax', type: 'auto' },
|
|
26
|
+
],
|
|
27
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fn, X } from '../../node'
|
|
2
|
+
|
|
3
|
+
export const mirror = Fn(([x]: [X]): X => {
|
|
4
|
+
const f = x.fract()
|
|
5
|
+
const m = x.mod(2).floor()
|
|
6
|
+
const fm = f.mul(m)
|
|
7
|
+
return f.add(m).sub(fm.mul(2))
|
|
8
|
+
}).setLayout({
|
|
9
|
+
name: 'mirror',
|
|
10
|
+
type: 'auto',
|
|
11
|
+
inputs: [{ name: 'x', type: 'auto' }],
|
|
12
|
+
})
|