@wandelbots/wandelbots-js-react-components 2.26.0-pr.feature-update-to-react-19.361.0d1640d → 2.26.0-pr.feature-update-to-react-19.361.49c57ce
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/dist/components/robots/RobotAnimator.d.ts.map +1 -1
- package/dist/components/utils/interpolation.d.ts +45 -12
- package/dist/components/utils/interpolation.d.ts.map +1 -1
- package/dist/index.cjs +26 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1436 -1424
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/robots/RobotAnimator.tsx +11 -9
- package/src/components/utils/interpolation.test.ts +46 -26
- package/src/components/utils/interpolation.ts +102 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RobotAnimator.d.ts","sourceRoot":"","sources":["../../../src/components/robots/RobotAnimator.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACzB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAA4B,MAAM,OAAO,CAAA;AAChD,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,OAAO,CAAA;AAK5C,KAAK,kBAAkB,GAAG;IACxB,0BAA0B,EAAE,wBAAwB,CAAA;IACpD,YAAY,EAAE,WAAW,EAAE,CAAA;IAC3B,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACvE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,0BAA0B,EAC1B,YAAY,EACZ,iBAAiB,EACjB,QAAQ,GACT,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"RobotAnimator.d.ts","sourceRoot":"","sources":["../../../src/components/robots/RobotAnimator.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACzB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAA4B,MAAM,OAAO,CAAA;AAChD,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,OAAO,CAAA;AAK5C,KAAK,kBAAkB,GAAG;IACxB,0BAA0B,EAAE,wBAAwB,CAAA;IACpD,YAAY,EAAE,WAAW,EAAE,CAAA;IAC3B,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACvE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,0BAA0B,EAC1B,YAAY,EACZ,iBAAiB,EACjB,QAAQ,GACT,EAAE,kBAAkB,2CA2EpB"}
|
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
* Smooth value interpolation utility for animating between values
|
|
3
3
|
* even with rapid updates. Uses THREE.MathUtils.lerp for optimized interpolation.
|
|
4
4
|
*
|
|
5
|
+
* Follows React Three Fiber best practices:
|
|
6
|
+
* - Uses frame deltas for refresh-rate independence
|
|
7
|
+
* - Avoids object creation in animation loops
|
|
8
|
+
* - Direct mutation for performance
|
|
9
|
+
*
|
|
5
10
|
* @example
|
|
6
11
|
* ```tsx
|
|
7
12
|
* // Basic usage with spring-like animation (similar to react-spring)
|
|
8
13
|
* const interpolator = new ValueInterpolator([0, 0, 0], {
|
|
9
|
-
*
|
|
14
|
+
* alpha: 0.1, // Interpolation alpha (0-1, frame-rate independent)
|
|
10
15
|
* easing: 'spring', // Spring-like animation with slight overshoot
|
|
11
16
|
* onChange: (values) => {
|
|
12
17
|
* // Update your objects with interpolated values
|
|
@@ -25,26 +30,30 @@
|
|
|
25
30
|
* // Set new target values
|
|
26
31
|
* interpolator.setTarget([1.5, -0.8, 2.1])
|
|
27
32
|
*
|
|
28
|
-
* // React hook usage
|
|
33
|
+
* // React hook usage with useFrame
|
|
29
34
|
* function MyComponent() {
|
|
30
|
-
* const [interpolator
|
|
31
|
-
*
|
|
32
|
-
* easing: 'spring'
|
|
33
|
-
*
|
|
35
|
+
* const [interpolator] = useInterpolation([0, 0, 0], {
|
|
36
|
+
* alpha: 0.1,
|
|
37
|
+
* easing: 'spring'
|
|
38
|
+
* })
|
|
39
|
+
*
|
|
40
|
+
* useFrame((state, delta) => {
|
|
41
|
+
* // Frame-rate independent updates
|
|
42
|
+
* interpolator.update(delta)
|
|
34
43
|
* })
|
|
35
44
|
*
|
|
36
45
|
* useEffect(() => {
|
|
37
46
|
* interpolator.setTarget([1, 2, 3])
|
|
38
47
|
* }, [])
|
|
39
48
|
*
|
|
40
|
-
* return <
|
|
49
|
+
* return <mesh position={interpolator.getCurrentValues()} />
|
|
41
50
|
* }
|
|
42
51
|
* ```
|
|
43
52
|
*/
|
|
44
53
|
export type EasingFunction = "linear" | "spring" | "easeOut" | "easeInOut";
|
|
45
54
|
export interface InterpolationOptions {
|
|
46
|
-
/** Interpolation
|
|
47
|
-
|
|
55
|
+
/** Interpolation alpha factor (0-1, frame-rate independent) */
|
|
56
|
+
alpha?: number;
|
|
48
57
|
/** Minimum threshold to consider interpolation complete */
|
|
49
58
|
threshold?: number;
|
|
50
59
|
/** Easing function to use for interpolation */
|
|
@@ -60,6 +69,11 @@ export declare class ValueInterpolator {
|
|
|
60
69
|
private animationId;
|
|
61
70
|
private options;
|
|
62
71
|
constructor(initialValues?: number[], options?: InterpolationOptions);
|
|
72
|
+
/**
|
|
73
|
+
* Update interpolation (call this in useFrame for frame-rate independence)
|
|
74
|
+
* @param delta - Frame delta time for smooth animation
|
|
75
|
+
*/
|
|
76
|
+
update(delta?: number): boolean;
|
|
63
77
|
/**
|
|
64
78
|
* Set new target values to interpolate towards
|
|
65
79
|
*/
|
|
@@ -93,14 +107,33 @@ export declare class ValueInterpolator {
|
|
|
93
107
|
*/
|
|
94
108
|
destroy(): void;
|
|
95
109
|
/**
|
|
96
|
-
* Apply easing function to the interpolation
|
|
110
|
+
* Apply easing function to the interpolation with frame-rate independence
|
|
97
111
|
*/
|
|
98
112
|
private applyEasing;
|
|
99
113
|
private startInterpolation;
|
|
100
114
|
private animate;
|
|
101
115
|
}
|
|
102
116
|
/**
|
|
103
|
-
* React hook for using the ValueInterpolator
|
|
117
|
+
* React hook for using the ValueInterpolator with useFrame
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```tsx
|
|
121
|
+
* function AnimatedMesh() {
|
|
122
|
+
* const [interpolator] = useInterpolation([0, 0, 0], { alpha: 0.1 })
|
|
123
|
+
* const meshRef = useRef()
|
|
124
|
+
*
|
|
125
|
+
* useFrame((state, delta) => {
|
|
126
|
+
* if (interpolator.update(delta)) {
|
|
127
|
+
* // Animation complete
|
|
128
|
+
* }
|
|
129
|
+
* // Apply current values directly to mesh
|
|
130
|
+
* const [x, y, z] = interpolator.getCurrentValues()
|
|
131
|
+
* meshRef.current.position.set(x, y, z)
|
|
132
|
+
* })
|
|
133
|
+
*
|
|
134
|
+
* return <mesh ref={meshRef} />
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
104
137
|
*/
|
|
105
|
-
export declare function useInterpolation(initialValues?: number[], options?: InterpolationOptions): [ValueInterpolator
|
|
138
|
+
export declare function useInterpolation(initialValues?: number[], options?: InterpolationOptions): [ValueInterpolator];
|
|
106
139
|
//# sourceMappingURL=interpolation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../../src/components/utils/interpolation.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../../src/components/utils/interpolation.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,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