@wandelbots/wandelbots-js-react-components 2.26.0-pr.feature-update-to-react-19.361.49c57ce → 2.26.0-pr.feature-update-to-react-19.361.c3fd41e

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,2CA2EpB"}
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"}
@@ -1,44 +1,34 @@
1
1
  /**
2
- * Smooth value interpolation utility for animating between values
3
- * even with rapid updates. Uses THREE.MathUtils.lerp for optimized interpolation.
2
+ * Smooth value interpolation utility using spring physics with tension and friction.
3
+ * Designed for React Three Fiber applications with smooth, natural animations.
4
4
  *
5
- * Follows React Three Fiber best practices:
6
- * - Uses frame deltas for refresh-rate independence
7
- * - Avoids object creation in animation loops
5
+ * Features:
6
+ * - Spring physics with configurable tension and friction
7
+ * - Frame-rate independent using delta timing
8
+ * - Handles irregular frame timing and rapid target updates
9
+ * - Manual update() calls for useFrame integration (no automatic RAF loop)
8
10
  * - Direct mutation for performance
9
11
  *
10
12
  * @example
11
13
  * ```tsx
12
- * // Basic usage with spring-like animation (similar to react-spring)
14
+ * // Basic spring animation
13
15
  * const interpolator = new ValueInterpolator([0, 0, 0], {
14
- * alpha: 0.1, // Interpolation alpha (0-1, frame-rate independent)
15
- * easing: 'spring', // Spring-like animation with slight overshoot
16
+ * tension: 120, // Higher = faster, stiffer spring (default: 120)
17
+ * friction: 20, // Higher = more damping, less oscillation (default: 20)
16
18
  * onChange: (values) => {
17
- * // Update your objects with interpolated values
18
19
  * robot.joints.forEach((joint, i) => {
19
20
  * joint.rotation.y = values[i]
20
21
  * })
21
22
  * }
22
23
  * })
23
24
  *
24
- * // Different easing options:
25
- * // 'linear' - smooth linear interpolation
26
- * // 'spring' - spring-like with overshoot (similar to react-spring)
27
- * // 'easeOut' - smooth deceleration
28
- * // 'easeInOut' - smooth acceleration and deceleration
29
- *
30
- * // Set new target values
31
25
  * interpolator.setTarget([1.5, -0.8, 2.1])
32
26
  *
33
- * // React hook usage with useFrame
27
+ * // React Three Fiber usage
34
28
  * function MyComponent() {
35
- * const [interpolator] = useInterpolation([0, 0, 0], {
36
- * alpha: 0.1,
37
- * easing: 'spring'
38
- * })
29
+ * const [interpolator] = useInterpolation([0, 0, 0])
39
30
  *
40
31
  * useFrame((state, delta) => {
41
- * // Frame-rate independent updates
42
32
  * interpolator.update(delta)
43
33
  * })
44
34
  *
@@ -50,14 +40,13 @@
50
40
  * }
51
41
  * ```
52
42
  */
53
- export type EasingFunction = "linear" | "spring" | "easeOut" | "easeInOut";
54
43
  export interface InterpolationOptions {
55
- /** Interpolation alpha factor (0-1, frame-rate independent) */
56
- alpha?: number;
57
- /** Minimum threshold to consider interpolation complete */
44
+ /** Spring tension (higher = faster, stiffer spring) - default: 120 */
45
+ tension?: number;
46
+ /** Spring friction (higher = more damping, less oscillation) - default: 20 */
47
+ friction?: number;
48
+ /** Minimum threshold to consider interpolation complete - default: 0.001 */
58
49
  threshold?: number;
59
- /** Easing function to use for interpolation */
60
- easing?: EasingFunction;
61
50
  /** Callback when values change during interpolation */
62
51
  onChange?: (values: number[]) => void;
63
52
  /** Callback when interpolation reaches target values */
@@ -66,16 +55,20 @@ export interface InterpolationOptions {
66
55
  export declare class ValueInterpolator {
67
56
  private currentValues;
68
57
  private targetValues;
58
+ private previousTargetValues;
59
+ private targetUpdateTime;
69
60
  private animationId;
70
61
  private options;
62
+ private velocities;
71
63
  constructor(initialValues?: number[], options?: InterpolationOptions);
72
64
  /**
73
- * Update interpolation (call this in useFrame for frame-rate independence)
65
+ * Update interpolation using spring physics (call this in useFrame for frame-rate independence)
74
66
  * @param delta - Frame delta time for smooth animation
75
67
  */
76
68
  update(delta?: number): boolean;
77
69
  /**
78
70
  * Set new target values to interpolate towards
71
+ * Handles irregular target updates smoothly by considering update frequency
79
72
  */
80
73
  setTarget(newValues: number[]): void;
81
74
  /**
@@ -103,23 +96,29 @@ export declare class ValueInterpolator {
103
96
  */
104
97
  updateOptions(newOptions: Partial<InterpolationOptions>): void;
105
98
  /**
106
- * Destroy the interpolator and clean up resources
99
+ * Start automatic interpolation (use when not calling update() manually)
107
100
  */
108
- destroy(): void;
101
+ startAutoInterpolation(): void;
109
102
  /**
110
- * Apply easing function to the interpolation with frame-rate independence
103
+ * Destroy the interpolator and clean up resources
111
104
  */
112
- private applyEasing;
105
+ destroy(): void;
113
106
  private startInterpolation;
114
107
  private animate;
115
108
  }
116
109
  /**
117
110
  * React hook for using the ValueInterpolator with useFrame
118
111
  *
112
+ * This hook creates a ValueInterpolator that uses spring physics for smooth,
113
+ * natural animations. Call interpolator.update(delta) in your useFrame callback.
114
+ *
119
115
  * @example
120
116
  * ```tsx
121
117
  * function AnimatedMesh() {
122
- * const [interpolator] = useInterpolation([0, 0, 0], { alpha: 0.1 })
118
+ * const [interpolator] = useInterpolation([0, 0, 0], {
119
+ * tension: 120, // Higher = faster spring
120
+ * friction: 20 // Higher = more damping
121
+ * })
123
122
  * const meshRef = useRef()
124
123
  *
125
124
  * useFrame((state, delta) => {
@@ -1 +1 @@
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,GAAG,WAAW,CAAA;AAE1E,MAAM,WAAW,oBAAoB;IACnC,+DAA+D;IAC/D,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,KA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