@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.1e3686f

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/index.js CHANGED
@@ -22305,7 +22305,7 @@ function oV({
22305
22305
  const nV = Array(6).fill(2 * Math.PI);
22306
22306
  class $c {
22307
22307
  constructor(t = [], r = {}) {
22308
- this.currentValues = [], this.targetValues = [], this.previousTargetValues = [], this.targetUpdateTime = 0, this.animationId = null, this.velocities = [], this.animate = () => {
22308
+ this.currentValues = [], this.targetValues = [], this.previousTargetValues = [], this.targetUpdateTime = 0, this.animationId = null, this.updateCount = 0, this.velocities = [], this.animate = () => {
22309
22309
  this.update(0.016666666666666666) ? this.animationId = null : this.animationId = requestAnimationFrame(this.animate);
22310
22310
  }, this.options = {
22311
22311
  tension: 120,
@@ -22316,28 +22316,36 @@ class $c {
22316
22316
  onComplete: () => {
22317
22317
  },
22318
22318
  ...r
22319
- }, this.currentValues = [...t], this.targetValues = [...t], this.previousTargetValues = [...t], this.velocities = new Array(t.length).fill(0), this.targetUpdateTime = performance.now();
22319
+ }, this.currentValues = [...t], this.targetValues = [...t], this.previousTargetValues = [...t], this.velocities = new Array(t.length).fill(0), this.targetUpdateTime = performance.now(), this.updateCount = 0;
22320
22320
  }
22321
22321
  /**
22322
- * Update interpolation using spring physics (call this in useFrame for frame-rate independence)
22323
- * @param delta - Frame delta time for smooth animation
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;
22327
- const o = Math.min(t, 1 / 15);
22328
- for (let n = 0; n < this.currentValues.length; n++) {
22329
- const s = this.currentValues[n], l = this.targetValues[n], i = this.velocities[n], c = l - s, d = c * this.options.tension, p = i * this.options.friction, u = d - p, y = i + u * o, g = s + y * o;
22330
- Math.abs(c) < this.options.threshold && Math.abs(y) < this.options.threshold * 10 ? this.currentValues[n] !== l && (this.currentValues[n] = l, this.velocities[n] = 0, r = !0) : (a = !1, this.currentValues[n] = g, this.velocities[n] = y, r = !0);
22332
+ this.updateCount++;
22333
+ const o = Math.min(t, 1 / 15), n = this.updateCount <= 3 ? Math.min(this.updateCount / 3, 1) : 1;
22334
+ for (let s = 0; s < this.currentValues.length; s++) {
22335
+ const l = this.currentValues[s], i = this.targetValues[s], c = this.velocities[s], d = i - l, p = d * this.options.tension * n, u = c * this.options.friction, y = p - u, g = c + y * o, m = l + g * o;
22336
+ Math.abs(d) < this.options.threshold && Math.abs(g) < this.options.threshold * 10 ? this.currentValues[s] !== i && (this.currentValues[s] = i, this.velocities[s] = 0, r = !0) : (a = !1, this.currentValues[s] = m, this.velocities[s] = g, r = !0);
22331
22337
  }
22332
22338
  return r && this.options.onChange(this.currentValues), a && this.options.onComplete(this.currentValues), a;
22333
22339
  }
22334
22340
  /**
22335
- * Set new target values to interpolate towards
22336
- * Handles irregular target updates smoothly by considering update frequency
22341
+ * Set new target values for the interpolation to move towards
22342
+ *
22343
+ * Includes smart blending for very rapid target updates (faster than 120fps)
22344
+ * to prevent jarring movements when targets change frequently.
22337
22345
  */
22338
22346
  setTarget(t) {
22339
22347
  const r = performance.now(), a = r - this.targetUpdateTime;
22340
- if (this.previousTargetValues = [...this.targetValues], this.targetValues = [...t], this.targetUpdateTime = r, a < 8 && a > 0 && this.previousTargetValues.length > 0) {
22348
+ if (this.previousTargetValues = [...this.targetValues], this.targetValues = [...t], this.targetUpdateTime = r, this.updateCount = 0, a < 8 && a > 0 && this.previousTargetValues.length > 0) {
22341
22349
  const o = Math.min(a / 8, 1);
22342
22350
  for (let n = 0; n < this.targetValues.length; n++) {
22343
22351
  const s = this.previousTargetValues[n] || 0, l = t[n] || 0;
@@ -22349,25 +22357,31 @@ class $c {
22349
22357
  this.currentValues.length > t.length && (this.currentValues = this.currentValues.slice(0, t.length), this.velocities = this.velocities.slice(0, t.length));
22350
22358
  }
22351
22359
  /**
22352
- * Get the current interpolated values
22360
+ * Get a copy of all current interpolated values
22353
22361
  */
22354
22362
  getCurrentValues() {
22355
22363
  return [...this.currentValues];
22356
22364
  }
22357
22365
  /**
22358
- * Get a specific interpolated value by index
22366
+ * Get a single interpolated value by its array index
22359
22367
  */
22360
22368
  getValue(t) {
22361
22369
  return this.currentValues[t] ?? 0;
22362
22370
  }
22363
22371
  /**
22364
- * Check if interpolation is currently active
22372
+ * Check if automatic interpolation is currently running
22373
+ *
22374
+ * This only tracks auto-interpolation started with startAutoInterpolation().
22375
+ * Manual update() calls are not tracked by this method.
22365
22376
  */
22366
22377
  isInterpolating() {
22367
22378
  return this.animationId !== null;
22368
22379
  }
22369
22380
  /**
22370
- * Stop the current interpolation
22381
+ * Stop automatic interpolation if it's running
22382
+ *
22383
+ * This cancels the internal animation frame loop but does not affect
22384
+ * manual update() calls.
22371
22385
  */
22372
22386
  stop() {
22373
22387
  this.animationId !== null && (cancelAnimationFrame(this.animationId), this.animationId = null);
@@ -22376,7 +22390,7 @@ class $c {
22376
22390
  * Instantly set values without interpolation
22377
22391
  */
22378
22392
  setImmediate(t) {
22379
- this.stop(), this.currentValues = [...t], this.targetValues = [...t], this.previousTargetValues = [...t], this.velocities = new Array(t.length).fill(0), this.targetUpdateTime = performance.now(), this.options.onChange(this.currentValues);
22393
+ this.stop(), this.currentValues = [...t], this.targetValues = [...t], this.previousTargetValues = [...t], this.velocities = new Array(t.length).fill(0), this.targetUpdateTime = performance.now(), this.updateCount = 0, this.options.onChange(this.currentValues);
22380
22394
  }
22381
22395
  /**
22382
22396
  * Update interpolation options
@@ -22385,13 +22399,20 @@ class $c {
22385
22399
  this.options = { ...this.options, ...t };
22386
22400
  }
22387
22401
  /**
22388
- * Start automatic interpolation (use when not calling update() manually)
22402
+ * Start automatic interpolation with an animation loop
22403
+ *
22404
+ * This begins a requestAnimationFrame loop that calls update() automatically.
22405
+ * For React Three Fiber components, prefer using manual update() calls
22406
+ * within useFrame hooks instead.
22389
22407
  */
22390
22408
  startAutoInterpolation() {
22391
22409
  this.startInterpolation();
22392
22410
  }
22393
22411
  /**
22394
- * Destroy the interpolator and clean up resources
22412
+ * Clean up all resources and stop any running animations
22413
+ *
22414
+ * This cancels any active animation frames and resets internal state.
22415
+ * Call this when the component unmounts or is no longer needed.
22395
22416
  */
22396
22417
  destroy() {
22397
22418
  this.stop();
@@ -22458,9 +22479,9 @@ function Lc({
22458
22479
  );
22459
22480
  return s.current = new $c(p, {
22460
22481
  tension: 120,
22461
- // Spring tension for smooth animation
22482
+ // Controls spring stiffness - higher values create faster, more responsive motion
22462
22483
  friction: 20,
22463
- // Spring friction for natural settling
22484
+ // Controls damping - higher values reduce oscillation and create smoother settling
22464
22485
  threshold: 1e-3
22465
22486
  }), () => {
22466
22487
  var u;