@wandelbots/wandelbots-js-react-components 2.26.0-pr.feature-update-to-react-19.361.c3fd41e → 2.26.0-pr.feature-update-to-react-19.361.fbd0985
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/utils/interpolation.d.ts +30 -10
- package/dist/components/utils/interpolation.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/robots/RobotAnimator.tsx +4 -4
- package/src/components/utils/interpolation.ts +49 -28
package/dist/index.js
CHANGED
|
@@ -22319,8 +22319,13 @@ class $c {
|
|
|
22319
22319
|
}, this.currentValues = [...t], this.targetValues = [...t], this.previousTargetValues = [...t], this.velocities = new Array(t.length).fill(0), this.targetUpdateTime = performance.now();
|
|
22320
22320
|
}
|
|
22321
22321
|
/**
|
|
22322
|
-
* Update interpolation using spring physics
|
|
22323
|
-
*
|
|
22322
|
+
* Update interpolation using spring physics
|
|
22323
|
+
*
|
|
22324
|
+
* Call this method every frame for smooth animation. In React Three Fiber,
|
|
22325
|
+
* call from within useFrame callback with the provided delta time.
|
|
22326
|
+
*
|
|
22327
|
+
* @param delta - Time elapsed since last update in seconds (e.g., 1/60 ≈ 0.0167 for 60fps)
|
|
22328
|
+
* @returns true when interpolation is complete (all values reached their targets)
|
|
22324
22329
|
*/
|
|
22325
22330
|
update(t = 1 / 60) {
|
|
22326
22331
|
let r = !1, a = !0;
|
|
@@ -22332,8 +22337,10 @@ class $c {
|
|
|
22332
22337
|
return r && this.options.onChange(this.currentValues), a && this.options.onComplete(this.currentValues), a;
|
|
22333
22338
|
}
|
|
22334
22339
|
/**
|
|
22335
|
-
* Set new target values to
|
|
22336
|
-
*
|
|
22340
|
+
* Set new target values for the interpolation to move towards
|
|
22341
|
+
*
|
|
22342
|
+
* Includes smart blending for very rapid target updates (faster than 120fps)
|
|
22343
|
+
* to prevent jarring movements when targets change frequently.
|
|
22337
22344
|
*/
|
|
22338
22345
|
setTarget(t) {
|
|
22339
22346
|
const r = performance.now(), a = r - this.targetUpdateTime;
|
|
@@ -22349,25 +22356,31 @@ class $c {
|
|
|
22349
22356
|
this.currentValues.length > t.length && (this.currentValues = this.currentValues.slice(0, t.length), this.velocities = this.velocities.slice(0, t.length));
|
|
22350
22357
|
}
|
|
22351
22358
|
/**
|
|
22352
|
-
* Get
|
|
22359
|
+
* Get a copy of all current interpolated values
|
|
22353
22360
|
*/
|
|
22354
22361
|
getCurrentValues() {
|
|
22355
22362
|
return [...this.currentValues];
|
|
22356
22363
|
}
|
|
22357
22364
|
/**
|
|
22358
|
-
* Get a
|
|
22365
|
+
* Get a single interpolated value by its array index
|
|
22359
22366
|
*/
|
|
22360
22367
|
getValue(t) {
|
|
22361
22368
|
return this.currentValues[t] ?? 0;
|
|
22362
22369
|
}
|
|
22363
22370
|
/**
|
|
22364
|
-
* Check if interpolation is currently
|
|
22371
|
+
* Check if automatic interpolation is currently running
|
|
22372
|
+
*
|
|
22373
|
+
* This only tracks auto-interpolation started with startAutoInterpolation().
|
|
22374
|
+
* Manual update() calls are not tracked by this method.
|
|
22365
22375
|
*/
|
|
22366
22376
|
isInterpolating() {
|
|
22367
22377
|
return this.animationId !== null;
|
|
22368
22378
|
}
|
|
22369
22379
|
/**
|
|
22370
|
-
* Stop
|
|
22380
|
+
* Stop automatic interpolation if it's running
|
|
22381
|
+
*
|
|
22382
|
+
* This cancels the internal animation frame loop but does not affect
|
|
22383
|
+
* manual update() calls.
|
|
22371
22384
|
*/
|
|
22372
22385
|
stop() {
|
|
22373
22386
|
this.animationId !== null && (cancelAnimationFrame(this.animationId), this.animationId = null);
|
|
@@ -22385,13 +22398,20 @@ class $c {
|
|
|
22385
22398
|
this.options = { ...this.options, ...t };
|
|
22386
22399
|
}
|
|
22387
22400
|
/**
|
|
22388
|
-
* Start automatic interpolation
|
|
22401
|
+
* Start automatic interpolation with an animation loop
|
|
22402
|
+
*
|
|
22403
|
+
* This begins a requestAnimationFrame loop that calls update() automatically.
|
|
22404
|
+
* For React Three Fiber components, prefer using manual update() calls
|
|
22405
|
+
* within useFrame hooks instead.
|
|
22389
22406
|
*/
|
|
22390
22407
|
startAutoInterpolation() {
|
|
22391
22408
|
this.startInterpolation();
|
|
22392
22409
|
}
|
|
22393
22410
|
/**
|
|
22394
|
-
*
|
|
22411
|
+
* Clean up all resources and stop any running animations
|
|
22412
|
+
*
|
|
22413
|
+
* This cancels any active animation frames and resets internal state.
|
|
22414
|
+
* Call this when the component unmounts or is no longer needed.
|
|
22395
22415
|
*/
|
|
22396
22416
|
destroy() {
|
|
22397
22417
|
this.stop();
|
|
@@ -22458,9 +22478,9 @@ function Lc({
|
|
|
22458
22478
|
);
|
|
22459
22479
|
return s.current = new $c(p, {
|
|
22460
22480
|
tension: 120,
|
|
22461
|
-
//
|
|
22481
|
+
// Controls spring stiffness - higher values create faster, more responsive motion
|
|
22462
22482
|
friction: 20,
|
|
22463
|
-
//
|
|
22483
|
+
// Controls damping - higher values reduce oscillation and create smoother settling
|
|
22464
22484
|
threshold: 1e-3
|
|
22465
22485
|
}), () => {
|
|
22466
22486
|
var u;
|