@wandelbots/wandelbots-js-react-components 3.2.0-pr.feat-improve-exports.414.40b4b4e → 3.2.0
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/README.md +2 -79
- package/dist/components/jogging/JoggingStore.d.ts +1 -1
- package/dist/index.cjs +155 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +30530 -0
- package/dist/index.js.map +1 -0
- package/package.json +3 -24
- package/dist/3d.cjs.js +0 -2
- package/dist/3d.cjs.js.map +0 -1
- package/dist/3d.d.ts +0 -11
- package/dist/3d.d.ts.map +0 -1
- package/dist/3d.es.js +0 -16
- package/dist/3d.es.js.map +0 -1
- package/dist/PoseJointValues-C3bsJdfd.js +0 -5446
- package/dist/PoseJointValues-C3bsJdfd.js.map +0 -1
- package/dist/PoseJointValues-wLOjcYDe.cjs +0 -21
- package/dist/PoseJointValues-wLOjcYDe.cjs.map +0 -1
- package/dist/ProgramStateIndicator-CTT-CAcJ.js +0 -268
- package/dist/ProgramStateIndicator-CTT-CAcJ.js.map +0 -1
- package/dist/ProgramStateIndicator-DYKBcj1s.cjs +0 -2
- package/dist/ProgramStateIndicator-DYKBcj1s.cjs.map +0 -1
- package/dist/VelocitySlider-2Zme2MN7.cjs +0 -5
- package/dist/VelocitySlider-2Zme2MN7.cjs.map +0 -1
- package/dist/VelocitySlider-QSg_8eb1.js +0 -1906
- package/dist/VelocitySlider-QSg_8eb1.js.map +0 -1
- package/dist/core.cjs.js +0 -2
- package/dist/core.cjs.js.map +0 -1
- package/dist/core.d.ts +0 -23
- package/dist/core.d.ts.map +0 -1
- package/dist/core.es.js +0 -46
- package/dist/core.es.js.map +0 -1
- package/dist/createSvgIcon-BG4_bQuX.cjs +0 -56
- package/dist/createSvgIcon-BG4_bQuX.cjs.map +0 -1
- package/dist/createSvgIcon-D3GRPlVu.js +0 -3072
- package/dist/createSvgIcon-D3GRPlVu.js.map +0 -1
- package/dist/data.cjs.js +0 -2
- package/dist/data.cjs.js.map +0 -1
- package/dist/data.d.ts +0 -4
- package/dist/data.d.ts.map +0 -1
- package/dist/data.es.js +0 -7
- package/dist/data.es.js.map +0 -1
- package/dist/externalizeComponent-C12Qf79R.cjs +0 -24
- package/dist/externalizeComponent-C12Qf79R.cjs.map +0 -1
- package/dist/externalizeComponent-RpcZ_G17.js +0 -491
- package/dist/externalizeComponent-RpcZ_G17.js.map +0 -1
- package/dist/index-8UEqiXug.cjs +0 -7
- package/dist/index-8UEqiXug.cjs.map +0 -1
- package/dist/index-CQDi5W62.cjs +0 -2
- package/dist/index-CQDi5W62.cjs.map +0 -1
- package/dist/index-DSz82V23.js +0 -1801
- package/dist/index-DSz82V23.js.map +0 -1
- package/dist/index-DZubFUuo.js +0 -4909
- package/dist/index-DZubFUuo.js.map +0 -1
- package/dist/index-MyU3fVEK.cjs +0 -50
- package/dist/index-MyU3fVEK.cjs.map +0 -1
- package/dist/index-VURe0U2S.js +0 -9443
- package/dist/index-VURe0U2S.js.map +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es.js +0 -72
- package/dist/index.es.js.map +0 -1
- package/dist/interpolation-CVSmVNjc.cjs +0 -2
- package/dist/interpolation-CVSmVNjc.cjs.map +0 -1
- package/dist/interpolation-DjBX_Si-.js +0 -138
- package/dist/interpolation-DjBX_Si-.js.map +0 -1
- package/dist/jogging.cjs.js +0 -2
- package/dist/jogging.cjs.js.map +0 -1
- package/dist/jogging.d.ts +0 -9
- package/dist/jogging.d.ts.map +0 -1
- package/dist/jogging.es.js +0 -12
- package/dist/jogging.es.js.map +0 -1
- package/dist/manufacturerHomePositions-DHqcbFON.js +0 -979
- package/dist/manufacturerHomePositions-DHqcbFON.js.map +0 -1
- package/dist/manufacturerHomePositions-zd-CKEiQ.cjs +0 -2
- package/dist/manufacturerHomePositions-zd-CKEiQ.cjs.map +0 -1
- package/dist/theming-BO8z_Hpa.js +0 -2198
- package/dist/theming-BO8z_Hpa.js.map +0 -1
- package/dist/theming-D5DvGuxX.cjs +0 -4
- package/dist/theming-D5DvGuxX.cjs.map +0 -1
- package/dist/useThemeProps-P648Ox74.cjs +0 -2
- package/dist/useThemeProps-P648Ox74.cjs.map +0 -1
- package/dist/useThemeProps-jE_Qg6SI.js +0 -40
- package/dist/useThemeProps-jE_Qg6SI.js.map +0 -1
- package/src/3d.ts +0 -15
- package/src/core.ts +0 -23
- package/src/data.ts +0 -4
- package/src/jogging.ts +0 -9
package/dist/index.cjs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./manufacturerHomePositions-zd-CKEiQ.cjs"),e=require("./theming-D5DvGuxX.cjs"),n=require("./index-MyU3fVEK.cjs"),t=require("./PoseJointValues-wLOjcYDe.cjs"),r=require("./VelocitySlider-2Zme2MN7.cjs"),i=require("./ProgramStateIndicator-DYKBcj1s.cjs"),a=require("./index-8UEqiXug.cjs"),s=require("./interpolation-CVSmVNjc.cjs"),g=require("./externalizeComponent-C12Qf79R.cjs");exports.CollisionSceneRenderer=o.CollisionSceneRenderer;exports.MANUFACTURER_HOME_CONFIGS=o.MANUFACTURER_HOME_CONFIGS;exports.PresetEnvironment=o.PresetEnvironment;exports.Robot=o.Robot;exports.RobotCard=o.RobotCard;exports.SafetyZonesRenderer=o.SafetyZonesRenderer;exports.SupportedRobot=o.SupportedRobot;exports.TrajectoryRenderer=o.TrajectoryRenderer;exports.defaultAxisConfig=o.defaultAxisConfig;exports.defaultGetModel=o.defaultGetModel;exports.extractManufacturer=o.extractManufacturer;exports.getDefaultHomeConfig=o.getDefaultHomeConfig;exports.AppHeader=e.AppHeader;exports.ConnectedMotionGroup=e.ConnectedMotionGroup;exports.LogPanel=e.LogPanel;exports.LogStore=e.LogStore;exports.LogViewer=e.LogViewer;exports.NoMotionGroupModal=e.NoMotionGroupModal;exports.RobotListItem=e.RobotListItem;exports.RobotSetupReadinessIndicator=e.RobotSetupReadinessIndicator;exports.RobotSetupReadinessState=e.RobotSetupReadinessState;exports.SafetyBar=e.SafetyBar;exports.SelectableFab=e.SelectableFab;exports.TabBar=e.TabBar;exports.WandelscriptEditor=e.WandelscriptEditor;exports.createDebugMessage=e.createDebugMessage;exports.createErrorMessage=e.createErrorMessage;exports.createInfoMessage=e.createInfoMessage;exports.createLogMessage=e.createLogMessage;exports.createNovaMuiTheme=e.createNovaMuiTheme;exports.createWarningMessage=e.createWarningMessage;exports.CycleTimer=n.CycleTimer;exports.Timer=n.Timer;exports.WandelbotsDataGrid=n.WandelbotsDataGrid;exports.JoggerConnection=t.JoggerConnection;exports.JoggingCartesianAxisControl=t.JoggingCartesianAxisControl;exports.JoggingJointRotationControl=t.JoggingJointRotationControl;exports.JoggingPanel=t.JoggingPanel;exports.JoggingStore=t.JoggingStore;exports.MotionStreamConnection=t.MotionStreamConnection;exports.PoseCartesianValues=t.PoseCartesianValues;exports.PoseJointValues=t.PoseJointValues;exports.LoadingCover=r.LoadingCover;exports.LoadingErrorMessage=r.LoadingErrorMessage;exports.VelocitySlider=r.VelocitySlider;exports.VelocitySliderLabel=r.VelocitySliderLabel;exports.jointValuesEqual=r.jointValuesEqual;exports.poseEqual=r.poseEqual;exports.tcpMotionEqual=r.tcpMotionEqual;exports.unwrapRotationVector=r.unwrapRotationVector;exports.ProgramControl=i.ProgramControl;exports.ProgramState=i.ProgramState;exports.ProgramStateIndicator=i.ProgramStateIndicator;exports.useAnimationFrame=a.useAnimationFrame;exports.useAutorun=a.useAutorun;exports.useMounted=a.useMounted;exports.useReaction=a.useReaction;exports.ValueInterpolator=s.ValueInterpolator;exports.useInterpolation=s.useInterpolation;exports.i18n=g.i18n;
|
|
2
|
-
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.es.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { C as o, M as s, P as t, b as r, R as n, S as i, c as g, T as l, a as u, d as c, e as d, g as p } from "./manufacturerHomePositions-DHqcbFON.js";
|
|
2
|
-
import { A as f, C, a as M, L as b, h as R, N as S, R as x, j as P, i as L, S as V, k as E, T, W as A, d as J, g as I, e as y, b as G, c as N, f as W } from "./theming-BO8z_Hpa.js";
|
|
3
|
-
import { C as F, T as q, W as v } from "./index-VURe0U2S.js";
|
|
4
|
-
import { e as H, a as h, b as w, c as B, J as O, M as U, P as _, d as k } from "./PoseJointValues-C3bsJdfd.js";
|
|
5
|
-
import { L as z, a as K, V as Q, b as X, j as Y, p as $, t as aa, u as ea } from "./VelocitySlider-QSg_8eb1.js";
|
|
6
|
-
import { a as sa, P as ta, b as ra } from "./ProgramStateIndicator-CTT-CAcJ.js";
|
|
7
|
-
import { c as ia, a as ga, u as la, b as ua } from "./index-DSz82V23.js";
|
|
8
|
-
import { V as da, u as pa } from "./interpolation-DjBX_Si-.js";
|
|
9
|
-
import { i as fa } from "./externalizeComponent-RpcZ_G17.js";
|
|
10
|
-
export {
|
|
11
|
-
f as AppHeader,
|
|
12
|
-
o as CollisionSceneRenderer,
|
|
13
|
-
C as ConnectedMotionGroup,
|
|
14
|
-
F as CycleTimer,
|
|
15
|
-
H as JoggerConnection,
|
|
16
|
-
h as JoggingCartesianAxisControl,
|
|
17
|
-
w as JoggingJointRotationControl,
|
|
18
|
-
B as JoggingPanel,
|
|
19
|
-
O as JoggingStore,
|
|
20
|
-
z as LoadingCover,
|
|
21
|
-
K as LoadingErrorMessage,
|
|
22
|
-
M as LogPanel,
|
|
23
|
-
b as LogStore,
|
|
24
|
-
R as LogViewer,
|
|
25
|
-
s as MANUFACTURER_HOME_CONFIGS,
|
|
26
|
-
U as MotionStreamConnection,
|
|
27
|
-
S as NoMotionGroupModal,
|
|
28
|
-
_ as PoseCartesianValues,
|
|
29
|
-
k as PoseJointValues,
|
|
30
|
-
t as PresetEnvironment,
|
|
31
|
-
sa as ProgramControl,
|
|
32
|
-
ta as ProgramState,
|
|
33
|
-
ra as ProgramStateIndicator,
|
|
34
|
-
r as Robot,
|
|
35
|
-
n as RobotCard,
|
|
36
|
-
x as RobotListItem,
|
|
37
|
-
P as RobotSetupReadinessIndicator,
|
|
38
|
-
L as RobotSetupReadinessState,
|
|
39
|
-
V as SafetyBar,
|
|
40
|
-
i as SafetyZonesRenderer,
|
|
41
|
-
E as SelectableFab,
|
|
42
|
-
g as SupportedRobot,
|
|
43
|
-
T as TabBar,
|
|
44
|
-
q as Timer,
|
|
45
|
-
l as TrajectoryRenderer,
|
|
46
|
-
da as ValueInterpolator,
|
|
47
|
-
Q as VelocitySlider,
|
|
48
|
-
X as VelocitySliderLabel,
|
|
49
|
-
v as WandelbotsDataGrid,
|
|
50
|
-
A as WandelscriptEditor,
|
|
51
|
-
J as createDebugMessage,
|
|
52
|
-
I as createErrorMessage,
|
|
53
|
-
y as createInfoMessage,
|
|
54
|
-
G as createLogMessage,
|
|
55
|
-
N as createNovaMuiTheme,
|
|
56
|
-
W as createWarningMessage,
|
|
57
|
-
u as defaultAxisConfig,
|
|
58
|
-
c as defaultGetModel,
|
|
59
|
-
d as extractManufacturer,
|
|
60
|
-
p as getDefaultHomeConfig,
|
|
61
|
-
fa as i18n,
|
|
62
|
-
Y as jointValuesEqual,
|
|
63
|
-
$ as poseEqual,
|
|
64
|
-
aa as tcpMotionEqual,
|
|
65
|
-
ea as unwrapRotationVector,
|
|
66
|
-
ia as useAnimationFrame,
|
|
67
|
-
ga as useAutorun,
|
|
68
|
-
pa as useInterpolation,
|
|
69
|
-
la as useMounted,
|
|
70
|
-
ua as useReaction
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const l=require("react");class g{constructor(t=[],s={}){this.currentValues=[],this.targetValues=[],this.previousTargetValues=[],this.targetUpdateTime=0,this.animationId=null,this.updateCount=0,this.velocities=[],this.animate=()=>{this.update(.016666666666666666)?this.animationId=null:this.animationId=requestAnimationFrame(this.animate)},this.options={tension:120,friction:20,threshold:.001,onChange:()=>{},onComplete:()=>{},...s},this.currentValues=[...t],this.targetValues=[...t],this.previousTargetValues=[...t],this.velocities=new Array(t.length).fill(0),this.targetUpdateTime=performance.now(),this.updateCount=0}update(t=1/60){let s=!1,i=!0;this.updateCount++;const o=Math.min(t,1/15),a=this.updateCount===1?.7:1;for(let e=0;e<this.currentValues.length;e++){const n=this.currentValues[e],r=this.targetValues[e],h=this.velocities[e],p=r-n,m=p*this.options.tension*a,d=h*this.options.friction,V=m-d,u=h+V*o,f=n+u*o;Math.abs(p)<this.options.threshold&&Math.abs(u)<this.options.threshold*10?this.currentValues[e]!==r&&(this.currentValues[e]=r,this.velocities[e]=0,s=!0):(i=!1,this.currentValues[e]=f,this.velocities[e]=u,s=!0)}return s&&this.options.onChange(this.currentValues),i&&this.options.onComplete(this.currentValues),i}setTarget(t){const s=performance.now(),i=s-this.targetUpdateTime;this.previousTargetValues=[...this.targetValues],this.targetValues=[...t],this.targetUpdateTime=s,this.updateCount=0;const o=this.previousTargetValues.every((a,e)=>a===this.currentValues[e]);if(i<8&&i>0&&this.previousTargetValues.length>0&&!o){const a=Math.min(i/8,1);for(let e=0;e<this.targetValues.length;e++){const n=this.previousTargetValues[e]||0,r=t[e]||0;Math.abs(r-n)>.1&&(this.targetValues[e]=n+(r-n)*a)}}for(;this.currentValues.length<t.length;)this.currentValues.push(t[this.currentValues.length]),this.velocities.push(0);this.currentValues.length>t.length&&(this.currentValues=this.currentValues.slice(0,t.length),this.velocities=this.velocities.slice(0,t.length))}getCurrentValues(){return[...this.currentValues]}getValue(t){return this.currentValues[t]??0}isInterpolating(){return this.animationId!==null}stop(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}setImmediate(t){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)}updateOptions(t){this.options={...this.options,...t}}startAutoInterpolation(){this.startInterpolation()}destroy(){this.stop()}startInterpolation(){this.animationId===null&&this.animate()}}function C(c=[],t={}){const s=l.useRef(null);return s.current||(s.current=new g(c,t)),l.useEffect(()=>{var i;(i=s.current)==null||i.updateOptions(t)},[t]),l.useEffect(()=>()=>{var i;(i=s.current)==null||i.destroy()},[]),[s.current]}exports.ValueInterpolator=g;exports.useInterpolation=C;
|
|
2
|
-
//# sourceMappingURL=interpolation-CVSmVNjc.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interpolation-CVSmVNjc.cjs","sources":["../src/components/utils/interpolation.ts"],"sourcesContent":["import React from \"react\"\n\n/**\n * Smooth value interpolation utility using spring physics with tension and friction.\n * Designed for React Three Fiber applications with smooth, natural animations.\n *\n * Features:\n * - Spring physics with configurable tension and friction\n * - Frame-rate independent using delta timing\n * - Handles irregular frame timing and rapid target updates\n * - Manual update() calls for useFrame integration (no automatic RAF loop)\n * - Direct mutation for performance\n *\n * @example\n * ```tsx\n * // Basic spring animation\n * const interpolator = new ValueInterpolator([0, 0, 0], {\n * tension: 120, // Higher = faster, stiffer spring (default: 120)\n * friction: 20, // Higher = more damping, less oscillation (default: 20)\n * onChange: (values) => {\n * robot.joints.forEach((joint, i) => {\n * joint.rotation.y = values[i]\n * })\n * }\n * })\n *\n * interpolator.setTarget([1.5, -0.8, 2.1])\n *\n * // React Three Fiber usage\n * function MyComponent() {\n * const [interpolator] = useInterpolation([0, 0, 0])\n *\n * useFrame((state, delta) => {\n * interpolator.update(delta)\n * })\n *\n * useEffect(() => {\n * interpolator.setTarget([1, 2, 3])\n * }, [])\n *\n * return <mesh position={interpolator.getCurrentValues()} />\n * }\n * ```\n */\n\nexport interface InterpolationOptions {\n /** Spring tension (higher = faster, stiffer spring) - default: 120 */\n tension?: number\n /** Spring friction (higher = more damping, less oscillation) - default: 20 */\n friction?: number\n /** Minimum threshold to consider interpolation complete - default: 0.001 */\n threshold?: number\n /** Callback when values change during interpolation */\n onChange?: (values: number[]) => void\n /** Callback when interpolation reaches target values */\n onComplete?: (values: number[]) => void\n}\n\nexport class ValueInterpolator {\n private currentValues: number[] = []\n private targetValues: number[] = []\n private previousTargetValues: number[] = []\n private targetUpdateTime: number = 0\n private animationId: number | null = null\n private options: Required<InterpolationOptions>\n private updateCount: number = 0 // Track how many updates have occurred\n\n // Spring physics state\n private velocities: number[] = []\n\n constructor(\n initialValues: number[] = [],\n options: InterpolationOptions = {},\n ) {\n this.options = {\n tension: 120,\n friction: 20,\n threshold: 0.001,\n onChange: () => {},\n onComplete: () => {},\n ...options,\n }\n\n this.currentValues = [...initialValues]\n this.targetValues = [...initialValues]\n this.previousTargetValues = [...initialValues]\n this.velocities = new Array(initialValues.length).fill(0)\n this.targetUpdateTime = performance.now()\n this.updateCount = 0\n }\n\n /**\n * Update interpolation using spring physics\n *\n * Call this method every frame for smooth animation. In React Three Fiber,\n * call from within useFrame callback with the provided delta time.\n *\n * @param delta - Time elapsed since last update in seconds (e.g., 1/60 ≈ 0.0167 for 60fps)\n * @returns true when interpolation is complete (all values reached their targets)\n */\n update(delta: number = 1 / 60): boolean {\n let hasChanges = false\n let isComplete = true\n\n // Increment update counter for initialization smoothing\n this.updateCount++\n\n // Limit delta to prevent physics instability during large frame drops\n const clampedDelta = Math.min(delta, 1 / 15) // Maximum 66ms frame time allowed\n\n // Apply gentle ramp-up for the first few frames to prevent initial jumpiness\n // Only apply reduced force for the very first frame to prevent jarring starts\n const initializationFactor =\n this.updateCount === 1\n ? 0.7 // Slightly reduced force only on the very first frame\n : 1\n\n for (let i = 0; i < this.currentValues.length; i++) {\n const current = this.currentValues[i]\n const target = this.targetValues[i]\n const velocity = this.velocities[i]\n\n // Calculate spring physics forces\n const displacement = target - current\n const springForce =\n displacement * this.options.tension * initializationFactor\n const dampingForce = velocity * this.options.friction\n\n // Calculate acceleration from net force (F = ma, assuming mass = 1)\n const acceleration = springForce - dampingForce\n\n // Integrate physics using Verlet method for numerical stability\n const newVelocity = velocity + acceleration * clampedDelta\n const newValue = current + newVelocity * clampedDelta\n\n // Determine if this value has settled (close to target with low velocity)\n const isValueComplete =\n Math.abs(displacement) < this.options.threshold &&\n Math.abs(newVelocity) < this.options.threshold * 10\n\n if (!isValueComplete) {\n isComplete = false\n // Continue spring animation\n this.currentValues[i] = newValue\n this.velocities[i] = newVelocity\n hasChanges = true\n } else {\n // Snap exactly to target when close enough (prevents endless micro-movements)\n if (this.currentValues[i] !== target) {\n this.currentValues[i] = target\n this.velocities[i] = 0\n hasChanges = true\n }\n }\n }\n\n if (hasChanges) {\n this.options.onChange(this.currentValues)\n }\n\n if (isComplete) {\n this.options.onComplete(this.currentValues)\n }\n\n return isComplete\n }\n\n /**\n * Set new target values for the interpolation to move towards\n *\n * Includes smart blending for very rapid target updates (faster than 120fps)\n * to prevent jarring movements when targets change frequently.\n */\n setTarget(newValues: number[]): void {\n const now = performance.now()\n const timeSinceLastUpdate = now - this.targetUpdateTime\n\n // Store previous target for smooth transitions\n this.previousTargetValues = [...this.targetValues]\n this.targetValues = [...newValues]\n this.targetUpdateTime = now\n\n // Reset update counter for smooth initialization when target changes\n this.updateCount = 0\n\n // Apply target blending for extremely rapid updates to prevent jarring jumps\n // Only activates when targets change faster than 120fps (< 8ms between updates)\n // AND this is not the first target being set (avoid blending initial target with initial values)\n const isInitialTargetSet = this.previousTargetValues.every(\n (val, i) => val === this.currentValues[i],\n )\n\n if (\n timeSinceLastUpdate < 8 &&\n timeSinceLastUpdate > 0 &&\n this.previousTargetValues.length > 0 &&\n !isInitialTargetSet // Don't blend if this is the first meaningful target change\n ) {\n // Blend between previous and new target based on time elapsed\n const blendFactor = Math.min(timeSinceLastUpdate / 8, 1) // 0 to 1 over 8ms\n\n for (let i = 0; i < this.targetValues.length; i++) {\n const prev = this.previousTargetValues[i] || 0\n const next = newValues[i] || 0\n\n // Only blend significant changes to avoid unnecessary smoothing\n const change = Math.abs(next - prev)\n if (change > 0.1) {\n this.targetValues[i] = prev + (next - prev) * blendFactor\n }\n }\n }\n\n // Ensure value and velocity arrays have matching lengths\n while (this.currentValues.length < newValues.length) {\n this.currentValues.push(newValues[this.currentValues.length])\n this.velocities.push(0) // New values start with zero velocity\n }\n if (this.currentValues.length > newValues.length) {\n this.currentValues = this.currentValues.slice(0, newValues.length)\n this.velocities = this.velocities.slice(0, newValues.length)\n }\n\n // Does not start automatic interpolation - requires manual update() calls\n // This design prevents conflicts when using with React Three Fiber's useFrame\n }\n\n /**\n * Get a copy of all current interpolated values\n */\n getCurrentValues(): number[] {\n return [...this.currentValues]\n }\n\n /**\n * Get a single interpolated value by its array index\n */\n getValue(index: number): number {\n return this.currentValues[index] ?? 0\n }\n\n /**\n * Check if automatic interpolation is currently running\n *\n * This only tracks auto-interpolation started with startAutoInterpolation().\n * Manual update() calls are not tracked by this method.\n */\n isInterpolating(): boolean {\n return this.animationId !== null\n }\n\n /**\n * Stop automatic interpolation if it's running\n *\n * This cancels the internal animation frame loop but does not affect\n * manual update() calls.\n */\n stop(): void {\n if (this.animationId !== null) {\n cancelAnimationFrame(this.animationId)\n this.animationId = null\n }\n }\n\n /**\n * Instantly set values without interpolation\n */\n setImmediate(values: number[]): void {\n this.stop()\n this.currentValues = [...values]\n this.targetValues = [...values]\n this.previousTargetValues = [...values]\n this.velocities = new Array(values.length).fill(0) // Reset velocities\n this.targetUpdateTime = performance.now()\n this.updateCount = 0 // Reset update counter\n this.options.onChange(this.currentValues)\n }\n\n /**\n * Update interpolation options\n */\n updateOptions(newOptions: Partial<InterpolationOptions>): void {\n this.options = { ...this.options, ...newOptions }\n }\n\n /**\n * Start automatic interpolation with an animation loop\n *\n * This begins a requestAnimationFrame loop that calls update() automatically.\n * For React Three Fiber components, prefer using manual update() calls\n * within useFrame hooks instead.\n */\n startAutoInterpolation(): void {\n this.startInterpolation()\n }\n\n /**\n * Clean up all resources and stop any running animations\n *\n * This cancels any active animation frames and resets internal state.\n * Call this when the component unmounts or is no longer needed.\n */\n destroy(): void {\n this.stop()\n }\n\n private startInterpolation(): void {\n if (this.animationId !== null) {\n return // Already interpolating\n }\n\n this.animate()\n }\n\n private animate = (): void => {\n // Use delta timing with a fallback for consistent automatic animations\n const isComplete = this.update(1 / 60) // Simulate 60fps for auto-interpolation\n\n if (!isComplete) {\n this.animationId = requestAnimationFrame(this.animate)\n } else {\n this.animationId = null\n }\n }\n}\n\n/**\n * React hook for using the ValueInterpolator with useFrame\n *\n * This hook creates a ValueInterpolator that uses spring physics for smooth,\n * natural animations. Call interpolator.update(delta) in your useFrame callback.\n *\n * @example\n * ```tsx\n * function AnimatedMesh() {\n * const [interpolator] = useInterpolation([0, 0, 0], {\n * tension: 120, // Higher = faster spring\n * friction: 20 // Higher = more damping\n * })\n * const meshRef = useRef()\n *\n * useFrame((state, delta) => {\n * if (interpolator.update(delta)) {\n * // Animation complete\n * }\n * // Apply current values directly to mesh\n * const [x, y, z] = interpolator.getCurrentValues()\n * meshRef.current.position.set(x, y, z)\n * })\n *\n * return <mesh ref={meshRef} />\n * }\n * ```\n */\nexport function useInterpolation(\n initialValues: number[] = [],\n options: InterpolationOptions = {},\n): [ValueInterpolator] {\n const interpolatorRef = React.useRef<ValueInterpolator | null>(null)\n\n // Initialize interpolator\n if (!interpolatorRef.current) {\n interpolatorRef.current = new ValueInterpolator(initialValues, options)\n }\n\n // Update options when they change\n React.useEffect(() => {\n interpolatorRef.current?.updateOptions(options)\n }, [options])\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n interpolatorRef.current?.destroy()\n }\n }, [])\n\n return [interpolatorRef.current!]\n}\n"],"names":["ValueInterpolator","initialValues","options","delta","hasChanges","isComplete","clampedDelta","initializationFactor","i","current","target","velocity","displacement","springForce","dampingForce","acceleration","newVelocity","newValue","newValues","now","timeSinceLastUpdate","isInitialTargetSet","val","blendFactor","prev","next","index","values","newOptions","useInterpolation","interpolatorRef","React","_a"],"mappings":"sCA0DO,MAAMA,CAAkB,CAY7B,YACEC,EAA0B,GAC1BC,EAAgC,CAAA,EAChC,CAdF,KAAQ,cAA0B,CAAC,EACnC,KAAQ,aAAyB,CAAC,EAClC,KAAQ,qBAAiC,CAAC,EAC1C,KAAQ,iBAA2B,EACnC,KAAQ,YAA6B,KAErC,KAAQ,YAAsB,EAG9B,KAAQ,WAAuB,CAAC,EAsPhC,KAAQ,QAAU,IAAY,CAET,KAAK,OAAO,mBAAM,EAKnC,KAAK,YAAc,KAFd,KAAA,YAAc,sBAAsB,KAAK,OAAO,CAIzD,EAzPE,KAAK,QAAU,CACb,QAAS,IACT,SAAU,GACV,UAAW,KACX,SAAU,IAAM,CAAC,EACjB,WAAY,IAAM,CAAC,EACnB,GAAGA,CACL,EAEK,KAAA,cAAgB,CAAC,GAAGD,CAAa,EACjC,KAAA,aAAe,CAAC,GAAGA,CAAa,EAChC,KAAA,qBAAuB,CAAC,GAAGA,CAAa,EAC7C,KAAK,WAAa,IAAI,MAAMA,EAAc,MAAM,EAAE,KAAK,CAAC,EACnD,KAAA,iBAAmB,YAAY,IAAI,EACxC,KAAK,YAAc,CAAA,CAYrB,OAAOE,EAAgB,EAAI,GAAa,CACtC,IAAIC,EAAa,GACbC,EAAa,GAGZ,KAAA,cAGL,MAAMC,EAAe,KAAK,IAAIH,EAAO,EAAI,EAAE,EAIrCI,EACJ,KAAK,cAAgB,EACjB,GACA,EAEN,QAASC,EAAI,EAAGA,EAAI,KAAK,cAAc,OAAQA,IAAK,CAC5C,MAAAC,EAAU,KAAK,cAAcD,CAAC,EAC9BE,EAAS,KAAK,aAAaF,CAAC,EAC5BG,EAAW,KAAK,WAAWH,CAAC,EAG5BI,EAAeF,EAASD,EACxBI,EACJD,EAAe,KAAK,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AAU,IAAM,QACJC,EAAAF,EAAA,UAAA,MAAAE,EAAS,cAAc9B,EAAO,EAC7C,CAACA,CAAO,CAAC,EAGZ6B,EAAM,UAAU,IACP,IAAM,QACXC,EAAAF,EAAgB,UAAhB,MAAAE,EAAyB,SAC3B,EACC,EAAE,EAEE,CAACF,EAAgB,OAAQ,CAClC"}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import l from "react";
|
|
2
|
-
class f {
|
|
3
|
-
constructor(t = [], s = {}) {
|
|
4
|
-
this.currentValues = [], this.targetValues = [], this.previousTargetValues = [], this.targetUpdateTime = 0, this.animationId = null, this.updateCount = 0, this.velocities = [], this.animate = () => {
|
|
5
|
-
this.update(0.016666666666666666) ? this.animationId = null : this.animationId = requestAnimationFrame(this.animate);
|
|
6
|
-
}, this.options = {
|
|
7
|
-
tension: 120,
|
|
8
|
-
friction: 20,
|
|
9
|
-
threshold: 1e-3,
|
|
10
|
-
onChange: () => {
|
|
11
|
-
},
|
|
12
|
-
onComplete: () => {
|
|
13
|
-
},
|
|
14
|
-
...s
|
|
15
|
-
}, this.currentValues = [...t], this.targetValues = [...t], this.previousTargetValues = [...t], this.velocities = new Array(t.length).fill(0), this.targetUpdateTime = performance.now(), this.updateCount = 0;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Update interpolation using spring physics
|
|
19
|
-
*
|
|
20
|
-
* Call this method every frame for smooth animation. In React Three Fiber,
|
|
21
|
-
* call from within useFrame callback with the provided delta time.
|
|
22
|
-
*
|
|
23
|
-
* @param delta - Time elapsed since last update in seconds (e.g., 1/60 ≈ 0.0167 for 60fps)
|
|
24
|
-
* @returns true when interpolation is complete (all values reached their targets)
|
|
25
|
-
*/
|
|
26
|
-
update(t = 1 / 60) {
|
|
27
|
-
let s = !1, i = !0;
|
|
28
|
-
this.updateCount++;
|
|
29
|
-
const o = Math.min(t, 1 / 15), a = this.updateCount === 1 ? 0.7 : 1;
|
|
30
|
-
for (let e = 0; e < this.currentValues.length; e++) {
|
|
31
|
-
const n = this.currentValues[e], r = this.targetValues[e], h = this.velocities[e], p = r - n, g = p * this.options.tension * a, m = h * this.options.friction, d = g - m, u = h + d * o, V = n + u * o;
|
|
32
|
-
Math.abs(p) < this.options.threshold && Math.abs(u) < this.options.threshold * 10 ? this.currentValues[e] !== r && (this.currentValues[e] = r, this.velocities[e] = 0, s = !0) : (i = !1, this.currentValues[e] = V, this.velocities[e] = u, s = !0);
|
|
33
|
-
}
|
|
34
|
-
return s && this.options.onChange(this.currentValues), i && this.options.onComplete(this.currentValues), i;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Set new target values for the interpolation to move towards
|
|
38
|
-
*
|
|
39
|
-
* Includes smart blending for very rapid target updates (faster than 120fps)
|
|
40
|
-
* to prevent jarring movements when targets change frequently.
|
|
41
|
-
*/
|
|
42
|
-
setTarget(t) {
|
|
43
|
-
const s = performance.now(), i = s - this.targetUpdateTime;
|
|
44
|
-
this.previousTargetValues = [...this.targetValues], this.targetValues = [...t], this.targetUpdateTime = s, this.updateCount = 0;
|
|
45
|
-
const o = this.previousTargetValues.every(
|
|
46
|
-
(a, e) => a === this.currentValues[e]
|
|
47
|
-
);
|
|
48
|
-
if (i < 8 && i > 0 && this.previousTargetValues.length > 0 && !o) {
|
|
49
|
-
const a = Math.min(i / 8, 1);
|
|
50
|
-
for (let e = 0; e < this.targetValues.length; e++) {
|
|
51
|
-
const n = this.previousTargetValues[e] || 0, r = t[e] || 0;
|
|
52
|
-
Math.abs(r - n) > 0.1 && (this.targetValues[e] = n + (r - n) * a);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
for (; this.currentValues.length < t.length; )
|
|
56
|
-
this.currentValues.push(t[this.currentValues.length]), this.velocities.push(0);
|
|
57
|
-
this.currentValues.length > t.length && (this.currentValues = this.currentValues.slice(0, t.length), this.velocities = this.velocities.slice(0, t.length));
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Get a copy of all current interpolated values
|
|
61
|
-
*/
|
|
62
|
-
getCurrentValues() {
|
|
63
|
-
return [...this.currentValues];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get a single interpolated value by its array index
|
|
67
|
-
*/
|
|
68
|
-
getValue(t) {
|
|
69
|
-
return this.currentValues[t] ?? 0;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Check if automatic interpolation is currently running
|
|
73
|
-
*
|
|
74
|
-
* This only tracks auto-interpolation started with startAutoInterpolation().
|
|
75
|
-
* Manual update() calls are not tracked by this method.
|
|
76
|
-
*/
|
|
77
|
-
isInterpolating() {
|
|
78
|
-
return this.animationId !== null;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Stop automatic interpolation if it's running
|
|
82
|
-
*
|
|
83
|
-
* This cancels the internal animation frame loop but does not affect
|
|
84
|
-
* manual update() calls.
|
|
85
|
-
*/
|
|
86
|
-
stop() {
|
|
87
|
-
this.animationId !== null && (cancelAnimationFrame(this.animationId), this.animationId = null);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Instantly set values without interpolation
|
|
91
|
-
*/
|
|
92
|
-
setImmediate(t) {
|
|
93
|
-
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);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Update interpolation options
|
|
97
|
-
*/
|
|
98
|
-
updateOptions(t) {
|
|
99
|
-
this.options = { ...this.options, ...t };
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Start automatic interpolation with an animation loop
|
|
103
|
-
*
|
|
104
|
-
* This begins a requestAnimationFrame loop that calls update() automatically.
|
|
105
|
-
* For React Three Fiber components, prefer using manual update() calls
|
|
106
|
-
* within useFrame hooks instead.
|
|
107
|
-
*/
|
|
108
|
-
startAutoInterpolation() {
|
|
109
|
-
this.startInterpolation();
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Clean up all resources and stop any running animations
|
|
113
|
-
*
|
|
114
|
-
* This cancels any active animation frames and resets internal state.
|
|
115
|
-
* Call this when the component unmounts or is no longer needed.
|
|
116
|
-
*/
|
|
117
|
-
destroy() {
|
|
118
|
-
this.stop();
|
|
119
|
-
}
|
|
120
|
-
startInterpolation() {
|
|
121
|
-
this.animationId === null && this.animate();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function I(c = [], t = {}) {
|
|
125
|
-
const s = l.useRef(null);
|
|
126
|
-
return s.current || (s.current = new f(c, t)), l.useEffect(() => {
|
|
127
|
-
var i;
|
|
128
|
-
(i = s.current) == null || i.updateOptions(t);
|
|
129
|
-
}, [t]), l.useEffect(() => () => {
|
|
130
|
-
var i;
|
|
131
|
-
(i = s.current) == null || i.destroy();
|
|
132
|
-
}, []), [s.current];
|
|
133
|
-
}
|
|
134
|
-
export {
|
|
135
|
-
f as V,
|
|
136
|
-
I as u
|
|
137
|
-
};
|
|
138
|
-
//# sourceMappingURL=interpolation-DjBX_Si-.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interpolation-DjBX_Si-.js","sources":["../src/components/utils/interpolation.ts"],"sourcesContent":["import React from \"react\"\n\n/**\n * Smooth value interpolation utility using spring physics with tension and friction.\n * Designed for React Three Fiber applications with smooth, natural animations.\n *\n * Features:\n * - Spring physics with configurable tension and friction\n * - Frame-rate independent using delta timing\n * - Handles irregular frame timing and rapid target updates\n * - Manual update() calls for useFrame integration (no automatic RAF loop)\n * - Direct mutation for performance\n *\n * @example\n * ```tsx\n * // Basic spring animation\n * const interpolator = new ValueInterpolator([0, 0, 0], {\n * tension: 120, // Higher = faster, stiffer spring (default: 120)\n * friction: 20, // Higher = more damping, less oscillation (default: 20)\n * onChange: (values) => {\n * robot.joints.forEach((joint, i) => {\n * joint.rotation.y = values[i]\n * })\n * }\n * })\n *\n * interpolator.setTarget([1.5, -0.8, 2.1])\n *\n * // React Three Fiber usage\n * function MyComponent() {\n * const [interpolator] = useInterpolation([0, 0, 0])\n *\n * useFrame((state, delta) => {\n * interpolator.update(delta)\n * })\n *\n * useEffect(() => {\n * interpolator.setTarget([1, 2, 3])\n * }, [])\n *\n * return <mesh position={interpolator.getCurrentValues()} />\n * }\n * ```\n */\n\nexport interface InterpolationOptions {\n /** Spring tension (higher = faster, stiffer spring) - default: 120 */\n tension?: number\n /** Spring friction (higher = more damping, less oscillation) - default: 20 */\n friction?: number\n /** Minimum threshold to consider interpolation complete - default: 0.001 */\n threshold?: number\n /** Callback when values change during interpolation */\n onChange?: (values: number[]) => void\n /** Callback when interpolation reaches target values */\n onComplete?: (values: number[]) => void\n}\n\nexport class ValueInterpolator {\n private currentValues: number[] = []\n private targetValues: number[] = []\n private previousTargetValues: number[] = []\n private targetUpdateTime: number = 0\n private animationId: number | null = null\n private options: Required<InterpolationOptions>\n private updateCount: number = 0 // Track how many updates have occurred\n\n // Spring physics state\n private velocities: number[] = []\n\n constructor(\n initialValues: number[] = [],\n options: InterpolationOptions = {},\n ) {\n this.options = {\n tension: 120,\n friction: 20,\n threshold: 0.001,\n onChange: () => {},\n onComplete: () => {},\n ...options,\n }\n\n this.currentValues = [...initialValues]\n this.targetValues = [...initialValues]\n this.previousTargetValues = [...initialValues]\n this.velocities = new Array(initialValues.length).fill(0)\n this.targetUpdateTime = performance.now()\n this.updateCount = 0\n }\n\n /**\n * Update interpolation using spring physics\n *\n * Call this method every frame for smooth animation. In React Three Fiber,\n * call from within useFrame callback with the provided delta time.\n *\n * @param delta - Time elapsed since last update in seconds (e.g., 1/60 ≈ 0.0167 for 60fps)\n * @returns true when interpolation is complete (all values reached their targets)\n */\n update(delta: number = 1 / 60): boolean {\n let hasChanges = false\n let isComplete = true\n\n // Increment update counter for initialization smoothing\n this.updateCount++\n\n // Limit delta to prevent physics instability during large frame drops\n const clampedDelta = Math.min(delta, 1 / 15) // Maximum 66ms frame time allowed\n\n // Apply gentle ramp-up for the first few frames to prevent initial jumpiness\n // Only apply reduced force for the very first frame to prevent jarring starts\n const initializationFactor =\n this.updateCount === 1\n ? 0.7 // Slightly reduced force only on the very first frame\n : 1\n\n for (let i = 0; i < this.currentValues.length; i++) {\n const current = this.currentValues[i]\n const target = this.targetValues[i]\n const velocity = this.velocities[i]\n\n // Calculate spring physics forces\n const displacement = target - current\n const springForce =\n displacement * this.options.tension * initializationFactor\n const dampingForce = velocity * this.options.friction\n\n // Calculate acceleration from net force (F = ma, assuming mass = 1)\n const acceleration = springForce - dampingForce\n\n // Integrate physics using Verlet method for numerical stability\n const newVelocity = velocity + acceleration * clampedDelta\n const newValue = current + newVelocity * clampedDelta\n\n // Determine if this value has settled (close to target with low velocity)\n const isValueComplete =\n Math.abs(displacement) < this.options.threshold &&\n Math.abs(newVelocity) < this.options.threshold * 10\n\n if (!isValueComplete) {\n isComplete = false\n // Continue spring animation\n this.currentValues[i] = newValue\n this.velocities[i] = newVelocity\n hasChanges = true\n } else {\n // Snap exactly to target when close enough (prevents endless micro-movements)\n if (this.currentValues[i] !== target) {\n this.currentValues[i] = target\n this.velocities[i] = 0\n hasChanges = true\n }\n }\n }\n\n if (hasChanges) {\n this.options.onChange(this.currentValues)\n }\n\n if (isComplete) {\n this.options.onComplete(this.currentValues)\n }\n\n return isComplete\n }\n\n /**\n * Set new target values for the interpolation to move towards\n *\n * Includes smart blending for very rapid target updates (faster than 120fps)\n * to prevent jarring movements when targets change frequently.\n */\n setTarget(newValues: number[]): void {\n const now = performance.now()\n const timeSinceLastUpdate = now - this.targetUpdateTime\n\n // Store previous target for smooth transitions\n this.previousTargetValues = [...this.targetValues]\n this.targetValues = [...newValues]\n this.targetUpdateTime = now\n\n // Reset update counter for smooth initialization when target changes\n this.updateCount = 0\n\n // Apply target blending for extremely rapid updates to prevent jarring jumps\n // Only activates when targets change faster than 120fps (< 8ms between updates)\n // AND this is not the first target being set (avoid blending initial target with initial values)\n const isInitialTargetSet = this.previousTargetValues.every(\n (val, i) => val === this.currentValues[i],\n )\n\n if (\n timeSinceLastUpdate < 8 &&\n timeSinceLastUpdate > 0 &&\n this.previousTargetValues.length > 0 &&\n !isInitialTargetSet // Don't blend if this is the first meaningful target change\n ) {\n // Blend between previous and new target based on time elapsed\n const blendFactor = Math.min(timeSinceLastUpdate / 8, 1) // 0 to 1 over 8ms\n\n for (let i = 0; i < this.targetValues.length; i++) {\n const prev = this.previousTargetValues[i] || 0\n const next = newValues[i] || 0\n\n // Only blend significant changes to avoid unnecessary smoothing\n const change = Math.abs(next - prev)\n if (change > 0.1) {\n this.targetValues[i] = prev + (next - prev) * blendFactor\n }\n }\n }\n\n // Ensure value and velocity arrays have matching lengths\n while (this.currentValues.length < newValues.length) {\n this.currentValues.push(newValues[this.currentValues.length])\n this.velocities.push(0) // New values start with zero velocity\n }\n if (this.currentValues.length > newValues.length) {\n this.currentValues = this.currentValues.slice(0, newValues.length)\n this.velocities = this.velocities.slice(0, newValues.length)\n }\n\n // Does not start automatic interpolation - requires manual update() calls\n // This design prevents conflicts when using with React Three Fiber's useFrame\n }\n\n /**\n * Get a copy of all current interpolated values\n */\n getCurrentValues(): number[] {\n return [...this.currentValues]\n }\n\n /**\n * Get a single interpolated value by its array index\n */\n getValue(index: number): number {\n return this.currentValues[index] ?? 0\n }\n\n /**\n * Check if automatic interpolation is currently running\n *\n * This only tracks auto-interpolation started with startAutoInterpolation().\n * Manual update() calls are not tracked by this method.\n */\n isInterpolating(): boolean {\n return this.animationId !== null\n }\n\n /**\n * Stop automatic interpolation if it's running\n *\n * This cancels the internal animation frame loop but does not affect\n * manual update() calls.\n */\n stop(): void {\n if (this.animationId !== null) {\n cancelAnimationFrame(this.animationId)\n this.animationId = null\n }\n }\n\n /**\n * Instantly set values without interpolation\n */\n setImmediate(values: number[]): void {\n this.stop()\n this.currentValues = [...values]\n this.targetValues = [...values]\n this.previousTargetValues = [...values]\n this.velocities = new Array(values.length).fill(0) // Reset velocities\n this.targetUpdateTime = performance.now()\n this.updateCount = 0 // Reset update counter\n this.options.onChange(this.currentValues)\n }\n\n /**\n * Update interpolation options\n */\n updateOptions(newOptions: Partial<InterpolationOptions>): void {\n this.options = { ...this.options, ...newOptions }\n }\n\n /**\n * Start automatic interpolation with an animation loop\n *\n * This begins a requestAnimationFrame loop that calls update() automatically.\n * For React Three Fiber components, prefer using manual update() calls\n * within useFrame hooks instead.\n */\n startAutoInterpolation(): void {\n this.startInterpolation()\n }\n\n /**\n * Clean up all resources and stop any running animations\n *\n * This cancels any active animation frames and resets internal state.\n * Call this when the component unmounts or is no longer needed.\n */\n destroy(): void {\n this.stop()\n }\n\n private startInterpolation(): void {\n if (this.animationId !== null) {\n return // Already interpolating\n }\n\n this.animate()\n }\n\n private animate = (): void => {\n // Use delta timing with a fallback for consistent automatic animations\n const isComplete = this.update(1 / 60) // Simulate 60fps for auto-interpolation\n\n if (!isComplete) {\n this.animationId = requestAnimationFrame(this.animate)\n } else {\n this.animationId = null\n }\n }\n}\n\n/**\n * React hook for using the ValueInterpolator with useFrame\n *\n * This hook creates a ValueInterpolator that uses spring physics for smooth,\n * natural animations. Call interpolator.update(delta) in your useFrame callback.\n *\n * @example\n * ```tsx\n * function AnimatedMesh() {\n * const [interpolator] = useInterpolation([0, 0, 0], {\n * tension: 120, // Higher = faster spring\n * friction: 20 // Higher = more damping\n * })\n * const meshRef = useRef()\n *\n * useFrame((state, delta) => {\n * if (interpolator.update(delta)) {\n * // Animation complete\n * }\n * // Apply current values directly to mesh\n * const [x, y, z] = interpolator.getCurrentValues()\n * meshRef.current.position.set(x, y, z)\n * })\n *\n * return <mesh ref={meshRef} />\n * }\n * ```\n */\nexport function useInterpolation(\n initialValues: number[] = [],\n options: InterpolationOptions = {},\n): [ValueInterpolator] {\n const interpolatorRef = React.useRef<ValueInterpolator | null>(null)\n\n // Initialize interpolator\n if (!interpolatorRef.current) {\n interpolatorRef.current = new ValueInterpolator(initialValues, options)\n }\n\n // Update options when they change\n React.useEffect(() => {\n interpolatorRef.current?.updateOptions(options)\n }, [options])\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n interpolatorRef.current?.destroy()\n }\n }, [])\n\n return [interpolatorRef.current!]\n}\n"],"names":["ValueInterpolator","initialValues","options","delta","hasChanges","isComplete","clampedDelta","initializationFactor","i","current","target","velocity","displacement","springForce","dampingForce","acceleration","newVelocity","newValue","newValues","now","timeSinceLastUpdate","isInitialTargetSet","val","blendFactor","prev","next","index","values","newOptions","useInterpolation","interpolatorRef","React","_a"],"mappings":";AA0DO,MAAMA,EAAkB;AAAA,EAY7B,YACEC,IAA0B,IAC1BC,IAAgC,CAAA,GAChC;AAdF,SAAQ,gBAA0B,CAAC,GACnC,KAAQ,eAAyB,CAAC,GAClC,KAAQ,uBAAiC,CAAC,GAC1C,KAAQ,mBAA2B,GACnC,KAAQ,cAA6B,MAErC,KAAQ,cAAsB,GAG9B,KAAQ,aAAuB,CAAC,GAsPhC,KAAQ,UAAU,MAAY;AAI5B,MAFmB,KAAK,OAAO,oBAAM,IAKnC,KAAK,cAAc,OAFd,KAAA,cAAc,sBAAsB,KAAK,OAAO;AAAA,IAIzD,GAzPE,KAAK,UAAU;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,MACV,WAAW;AAAA,MACX,UAAU,MAAM;AAAA,MAAC;AAAA,MACjB,YAAY,MAAM;AAAA,MAAC;AAAA,MACnB,GAAGA;AAAA,IACL,GAEK,KAAA,gBAAgB,CAAC,GAAGD,CAAa,GACjC,KAAA,eAAe,CAAC,GAAGA,CAAa,GAChC,KAAA,uBAAuB,CAAC,GAAGA,CAAa,GAC7C,KAAK,aAAa,IAAI,MAAMA,EAAc,MAAM,EAAE,KAAK,CAAC,GACnD,KAAA,mBAAmB,YAAY,IAAI,GACxC,KAAK,cAAc;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYrB,OAAOE,IAAgB,IAAI,IAAa;AACtC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,CAAC,GAAGA,CAAM,GACzB,KAAA,uBAAuB,CAAC,GAAGA,CAAM,GACtC,KAAK,aAAa,IAAI,MAAMA,EAAO,MAAM,EAAE,KAAK,CAAC,GAC5C,KAAA,mBAAmB,YAAY,IAAI,GACxC,KAAK,cAAc,GACd,KAAA,QAAQ,SAAS,KAAK,aAAa;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAM1C,cAAcC,GAAiD;AAC7D,SAAK,UAAU,EAAE,GAAG,KAAK,SAAS,GAAGA,EAAW;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUlD,yBAA+B;AAC7B,SAAK,mBAAmB;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS1B,UAAgB;AACd,SAAK,KAAK;AAAA,EAAA;AAAA,EAGJ,qBAA2B;AAC7B,IAAA,KAAK,gBAAgB,QAIzB,KAAK,QAAQ;AAAA,EAAA;AAajB;AA8BO,SAASC,EACd5B,IAA0B,IAC1BC,IAAgC,CAAA,GACX;AACf,QAAA4B,IAAkBC,EAAM,OAAiC,IAAI;AAG/D,SAACD,EAAgB,YACnBA,EAAgB,UAAU,IAAI9B,EAAkBC,GAAeC,CAAO,IAIxE6B,EAAM,UAAU,MAAM;;AACJ,KAAAC,IAAAF,EAAA,YAAA,QAAAE,EAAS,cAAc9B;AAAA,EAAO,GAC7C,CAACA,CAAO,CAAC,GAGZ6B,EAAM,UAAU,MACP,MAAM;;AACX,KAAAC,IAAAF,EAAgB,YAAhB,QAAAE,EAAyB;AAAA,EAC3B,GACC,EAAE,GAEE,CAACF,EAAgB,OAAQ;AAClC;"}
|
package/dist/jogging.cjs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./PoseJointValues-wLOjcYDe.cjs");exports.JoggerConnection=o.JoggerConnection;exports.JoggingCartesianAxisControl=o.JoggingCartesianAxisControl;exports.JoggingJointRotationControl=o.JoggingJointRotationControl;exports.JoggingPanel=o.JoggingPanel;exports.JoggingStore=o.JoggingStore;exports.MotionStreamConnection=o.MotionStreamConnection;exports.PoseCartesianValues=o.PoseCartesianValues;exports.PoseJointValues=o.PoseJointValues;
|
|
2
|
-
//# sourceMappingURL=jogging.cjs.js.map
|
package/dist/jogging.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jogging.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/jogging.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./components/jogging/JoggingCartesianAxisControl";
|
|
2
|
-
export * from "./components/jogging/JoggingJointRotationControl";
|
|
3
|
-
export * from "./components/jogging/JoggingPanel";
|
|
4
|
-
export { JoggingStore } from "./components/jogging/JoggingStore";
|
|
5
|
-
export * from "./components/jogging/PoseCartesianValues";
|
|
6
|
-
export * from "./components/jogging/PoseJointValues";
|
|
7
|
-
export * from "./lib/JoggerConnection";
|
|
8
|
-
export * from "./lib/MotionStreamConnection";
|
|
9
|
-
//# sourceMappingURL=jogging.d.ts.map
|
package/dist/jogging.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jogging.d.ts","sourceRoot":"","sources":["../src/jogging.ts"],"names":[],"mappings":"AACA,cAAc,kDAAkD,CAAA;AAChE,cAAc,kDAAkD,CAAA;AAChE,cAAc,mCAAmC,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,cAAc,0CAA0C,CAAA;AACxD,cAAc,sCAAsC,CAAA;AACpD,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA"}
|
package/dist/jogging.es.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { e as a, a as s, b as e, c as g, J as t, M as i, P as r, d as J } from "./PoseJointValues-C3bsJdfd.js";
|
|
2
|
-
export {
|
|
3
|
-
a as JoggerConnection,
|
|
4
|
-
s as JoggingCartesianAxisControl,
|
|
5
|
-
e as JoggingJointRotationControl,
|
|
6
|
-
g as JoggingPanel,
|
|
7
|
-
t as JoggingStore,
|
|
8
|
-
i as MotionStreamConnection,
|
|
9
|
-
r as PoseCartesianValues,
|
|
10
|
-
J as PoseJointValues
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=jogging.es.js.map
|
package/dist/jogging.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jogging.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|