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.
- package/README.md +8 -4
- package/dist/addons.cjs +1 -1
- package/dist/addons.cjs.map +1 -1
- package/dist/addons.d.ts +849 -19
- 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 +38 -20
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/native.d.ts +48 -22
- package/dist/node.cjs +59 -30
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +34 -22
- package/dist/node.js +59 -30
- package/dist/node.js.map +1 -1
- package/dist/react.d.ts +38 -20
- package/dist/solid.d.ts +38 -20
- 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 +26 -25
- package/src/node/types.ts +15 -11
- package/src/node/utils/const.ts +12 -11
- package/src/node/utils/index.ts +14 -12
- package/src/node/utils/infer.ts +15 -5
- package/src/node/utils/parse.ts +37 -13
- package/src/node/utils/utils.ts +46 -23
- package/src/types.ts +9 -2
- package/src/utils/helpers.ts +56 -0
- package/src/utils/pipeline.ts +21 -5
- package/src/utils/program.ts +57 -38
- package/src/utils/webgl.ts +41 -35
- 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", "
|
|
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", "
|
|
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
|
-
|
|
245
|
+
toUInt(): UInt;
|
|
245
246
|
toInt(): Int;
|
|
246
247
|
toFloat(): Float;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
toBVec2(): BVec2;
|
|
249
|
+
toIVec2(): IVec2;
|
|
250
|
+
toUVec2(): UVec2;
|
|
250
251
|
toVec2(): Vec2;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
toBVec3(): BVec3;
|
|
253
|
+
toIVec3(): IVec3;
|
|
254
|
+
toUVec3(): UVec3;
|
|
254
255
|
toVec3(): Vec3;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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:
|
|
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:
|
|
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", "
|
|
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", "
|
|
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
|
-
|
|
245
|
+
toUInt(): UInt;
|
|
245
246
|
toInt(): Int;
|
|
246
247
|
toFloat(): Float;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
toBVec2(): BVec2;
|
|
249
|
+
toIVec2(): IVec2;
|
|
250
|
+
toUVec2(): UVec2;
|
|
250
251
|
toVec2(): Vec2;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
toBVec3(): BVec3;
|
|
253
|
+
toIVec3(): IVec3;
|
|
254
|
+
toUVec3(): UVec3;
|
|
254
255
|
toVec3(): Vec3;
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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:
|
|
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:
|
|
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.
|
|
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,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,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, 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
|
+
})
|