@wandelbots/wandelbots-js-react-components 2.26.0-pr.feature-update-to-react-19.361.fbd0985 → 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/components/utils/interpolation.d.ts +1 -0
- package/dist/components/utils/interpolation.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/utils/interpolation.test.ts +28 -0
- package/src/components/utils/interpolation.ts +17 -1
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,7 +22316,7 @@ 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
22322
|
* Update interpolation using spring physics
|
|
@@ -22329,10 +22329,11 @@ class $c {
|
|
|
22329
22329
|
*/
|
|
22330
22330
|
update(t = 1 / 60) {
|
|
22331
22331
|
let r = !1, a = !0;
|
|
22332
|
-
|
|
22333
|
-
|
|
22334
|
-
|
|
22335
|
-
|
|
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);
|
|
22336
22337
|
}
|
|
22337
22338
|
return r && this.options.onChange(this.currentValues), a && this.options.onComplete(this.currentValues), a;
|
|
22338
22339
|
}
|
|
@@ -22344,7 +22345,7 @@ class $c {
|
|
|
22344
22345
|
*/
|
|
22345
22346
|
setTarget(t) {
|
|
22346
22347
|
const r = performance.now(), a = r - this.targetUpdateTime;
|
|
22347
|
-
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) {
|
|
22348
22349
|
const o = Math.min(a / 8, 1);
|
|
22349
22350
|
for (let n = 0; n < this.targetValues.length; n++) {
|
|
22350
22351
|
const s = this.previousTargetValues[n] || 0, l = t[n] || 0;
|
|
@@ -22389,7 +22390,7 @@ class $c {
|
|
|
22389
22390
|
* Instantly set values without interpolation
|
|
22390
22391
|
*/
|
|
22391
22392
|
setImmediate(t) {
|
|
22392
|
-
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);
|
|
22393
22394
|
}
|
|
22394
22395
|
/**
|
|
22395
22396
|
* Update interpolation options
|