@wandelbots/wandelbots-js-react-components 2.26.0-pr.feature-update-to-react-19.361.916e61e → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"RobotAnimator.d.ts","sourceRoot":"","sources":["../../../src/components/robots/RobotAnimator.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACzB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAiB,MAAM,OAAO,CAAA;AACrC,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,OAAO,CAAA;AAG5C,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,2CAoDpB"}
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"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Smooth value interpolation utility for animating between values
3
+ * even with rapid updates. Uses THREE.MathUtils.lerp for optimized interpolation.
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
+ *
10
+ * @example
11
+ * ```tsx
12
+ * // Basic usage with spring-like animation (similar to react-spring)
13
+ * 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
+ * onChange: (values) => {
17
+ * // Update your objects with interpolated values
18
+ * robot.joints.forEach((joint, i) => {
19
+ * joint.rotation.y = values[i]
20
+ * })
21
+ * }
22
+ * })
23
+ *
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
+ * interpolator.setTarget([1.5, -0.8, 2.1])
32
+ *
33
+ * // React hook usage with useFrame
34
+ * function MyComponent() {
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)
43
+ * })
44
+ *
45
+ * useEffect(() => {
46
+ * interpolator.setTarget([1, 2, 3])
47
+ * }, [])
48
+ *
49
+ * return <mesh position={interpolator.getCurrentValues()} />
50
+ * }
51
+ * ```
52
+ */
53
+ export type EasingFunction = "linear" | "spring" | "easeOut" | "easeInOut";
54
+ export interface InterpolationOptions {
55
+ /** Interpolation alpha factor (0-1, frame-rate independent) */
56
+ alpha?: number;
57
+ /** Minimum threshold to consider interpolation complete */
58
+ threshold?: number;
59
+ /** Easing function to use for interpolation */
60
+ easing?: EasingFunction;
61
+ /** Callback when values change during interpolation */
62
+ onChange?: (values: number[]) => void;
63
+ /** Callback when interpolation reaches target values */
64
+ onComplete?: (values: number[]) => void;
65
+ }
66
+ export declare class ValueInterpolator {
67
+ private currentValues;
68
+ private targetValues;
69
+ private animationId;
70
+ private options;
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;
77
+ /**
78
+ * Set new target values to interpolate towards
79
+ */
80
+ setTarget(newValues: number[]): void;
81
+ /**
82
+ * Get the current interpolated values
83
+ */
84
+ getCurrentValues(): number[];
85
+ /**
86
+ * Get a specific interpolated value by index
87
+ */
88
+ getValue(index: number): number;
89
+ /**
90
+ * Check if interpolation is currently active
91
+ */
92
+ isInterpolating(): boolean;
93
+ /**
94
+ * Stop the current interpolation
95
+ */
96
+ stop(): void;
97
+ /**
98
+ * Instantly set values without interpolation
99
+ */
100
+ setImmediate(values: number[]): void;
101
+ /**
102
+ * Update interpolation options
103
+ */
104
+ updateOptions(newOptions: Partial<InterpolationOptions>): void;
105
+ /**
106
+ * Destroy the interpolator and clean up resources
107
+ */
108
+ destroy(): void;
109
+ /**
110
+ * Apply easing function to the interpolation with frame-rate independence
111
+ */
112
+ private applyEasing;
113
+ private startInterpolation;
114
+ private animate;
115
+ }
116
+ /**
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
+ * ```
137
+ */
138
+ export declare function useInterpolation(initialValues?: number[], options?: InterpolationOptions): [ValueInterpolator];
139
+ //# sourceMappingURL=interpolation.d.ts.map
@@ -0,0 +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,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;;;OAGG;IACH,MAAM,CAAC,KAAK,GAAE,MAAe,GAAG,OAAO;IAsCvC;;OAEG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI;IAcpC;;OAEG;IACH,gBAAgB,IAAI,MAAM,EAAE;IAI5B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI/B;;OAEG;IACH,eAAe,IAAI,OAAO;IAI1B;;OAEG;IACH,IAAI,IAAI,IAAI;IAOZ;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAOpC;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI;IAI9D;;OAEG;IACH,OAAO,IAAI,IAAI;IAIf;;OAEG;IACH,OAAO,CAAC,WAAW;IAqCnB,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,OAAO,CA+Bd;CACF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,GAAE,MAAM,EAAO,EAC5B,OAAO,GAAE,oBAAyB,GACjC,CAAC,iBAAiB,CAAC,CAqBrB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interpolation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interpolation.test.d.ts","sourceRoot":"","sources":["../../../src/components/utils/interpolation.test.ts"],"names":[],"mappings":""}