@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.23b1e20

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.
@@ -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,2CAyEpB"}
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,2CA+EpB"}
@@ -2,11 +2,20 @@
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
+ * - Manual update() calls for useFrame integration (no automatic RAF loop)
10
+ *
11
+ * Note: When using with useFrame(), call update(delta) manually.
12
+ * For standalone usage, call startAutoInterpolation() to begin automatic updates.
13
+ *
5
14
  * @example
6
15
  * ```tsx
7
16
  * // Basic usage with spring-like animation (similar to react-spring)
8
17
  * const interpolator = new ValueInterpolator([0, 0, 0], {
9
- * speed: 0.1, // Interpolation speed (0-1)
18
+ * alpha: 0.1, // Interpolation alpha (0-1, frame-rate independent)
10
19
  * easing: 'spring', // Spring-like animation with slight overshoot
11
20
  * onChange: (values) => {
12
21
  * // Update your objects with interpolated values
@@ -25,26 +34,30 @@
25
34
  * // Set new target values
26
35
  * interpolator.setTarget([1.5, -0.8, 2.1])
27
36
  *
28
- * // React hook usage
37
+ * // React hook usage with useFrame
29
38
  * function MyComponent() {
30
- * const [interpolator, currentValues] = useInterpolation([0, 0, 0], {
31
- * speed: 0.15,
32
- * easing: 'spring',
33
- * onChange: (values) => console.log('Values updated:', values)
39
+ * const [interpolator] = useInterpolation([0, 0, 0], {
40
+ * alpha: 0.1,
41
+ * easing: 'spring'
42
+ * })
43
+ *
44
+ * useFrame((state, delta) => {
45
+ * // Frame-rate independent updates
46
+ * interpolator.update(delta)
34
47
  * })
35
48
  *
36
49
  * useEffect(() => {
37
50
  * interpolator.setTarget([1, 2, 3])
38
51
  * }, [])
39
52
  *
40
- * return <div>Current values: {currentValues.join(', ')}</div>
53
+ * return <mesh position={interpolator.getCurrentValues()} />
41
54
  * }
42
55
  * ```
43
56
  */
44
57
  export type EasingFunction = "linear" | "spring" | "easeOut" | "easeInOut";
45
58
  export interface InterpolationOptions {
46
- /** Interpolation speed factor (0-1, where 1 is instant) */
47
- speed?: number;
59
+ /** Interpolation alpha factor (0-1, frame-rate independent) */
60
+ alpha?: number;
48
61
  /** Minimum threshold to consider interpolation complete */
49
62
  threshold?: number;
50
63
  /** Easing function to use for interpolation */
@@ -60,6 +73,11 @@ export declare class ValueInterpolator {
60
73
  private animationId;
61
74
  private options;
62
75
  constructor(initialValues?: number[], options?: InterpolationOptions);
76
+ /**
77
+ * Update interpolation (call this in useFrame for frame-rate independence)
78
+ * @param delta - Frame delta time for smooth animation
79
+ */
80
+ update(delta?: number): boolean;
63
81
  /**
64
82
  * Set new target values to interpolate towards
65
83
  */
@@ -88,19 +106,46 @@ export declare class ValueInterpolator {
88
106
  * Update interpolation options
89
107
  */
90
108
  updateOptions(newOptions: Partial<InterpolationOptions>): void;
109
+ /**
110
+ * Start automatic interpolation (use when not calling update() manually)
111
+ */
112
+ startAutoInterpolation(): void;
91
113
  /**
92
114
  * Destroy the interpolator and clean up resources
93
115
  */
94
116
  destroy(): void;
95
117
  /**
96
- * Apply easing function to the interpolation
118
+ * Apply easing function to the interpolation with frame-rate independence
97
119
  */
98
120
  private applyEasing;
99
121
  private startInterpolation;
100
122
  private animate;
101
123
  }
102
124
  /**
103
- * React hook for using the ValueInterpolator
125
+ * React hook for using the ValueInterpolator with useFrame
126
+ *
127
+ * This hook creates a ValueInterpolator that's designed for manual updates
128
+ * via useFrame(). It will not start automatic interpolation - you must
129
+ * call interpolator.update(delta) in your useFrame callback.
130
+ *
131
+ * @example
132
+ * ```tsx
133
+ * function AnimatedMesh() {
134
+ * const [interpolator] = useInterpolation([0, 0, 0], { alpha: 0.1 })
135
+ * const meshRef = useRef()
136
+ *
137
+ * useFrame((state, delta) => {
138
+ * if (interpolator.update(delta)) {
139
+ * // Animation complete
140
+ * }
141
+ * // Apply current values directly to mesh
142
+ * const [x, y, z] = interpolator.getCurrentValues()
143
+ * meshRef.current.position.set(x, y, z)
144
+ * })
145
+ *
146
+ * return <mesh ref={meshRef} />
147
+ * }
148
+ * ```
104
149
  */
105
- export declare function useInterpolation(initialValues?: number[], options?: InterpolationOptions): [ValueInterpolator, number[]];
150
+ export declare function useInterpolation(initialValues?: number[], options?: InterpolationOptions): [ValueInterpolator];
106
151
  //# sourceMappingURL=interpolation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interpolation.d.ts","sourceRoot":"","sources":["../../../src/components/utils/interpolation.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAA;AAE1E,MAAM,WAAW,oBAAoB;IACnC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACrC,wDAAwD;IACxD,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;CACxC;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,aAAa,CAAe;IACpC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,OAAO,CAAgC;gBAG7C,aAAa,GAAE,MAAM,EAAO,EAC5B,OAAO,GAAE,oBAAyB;IAepC;;OAEG;IACH,SAAS,CAA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