@lagless/animation-controller 0.0.38

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.
@@ -0,0 +1,4 @@
1
+ export * from './lib/animation-state.js';
2
+ export * from './lib/locomotion-blend.js';
3
+ export * from './lib/animation-view-adapter.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './lib/animation-state.js';
2
+ export * from './lib/locomotion-blend.js';
3
+ export * from './lib/animation-view-adapter.js';
4
+
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './lib/animation-state.js';\nexport * from './lib/locomotion-blend.js';\nexport * from './lib/animation-view-adapter.js';\n"],"names":[],"rangeMappings":";;","mappings":"AAAA,cAAc,2BAA2B;AACzC,cAAc,4BAA4B;AAC1C,cAAc,kCAAkC"}
@@ -0,0 +1,47 @@
1
+ export declare const AnimationId: {
2
+ readonly IDLE: 0;
3
+ readonly LOCOMOTION: 1;
4
+ readonly JUMP: 2;
5
+ readonly FALL: 3;
6
+ readonly LAND: 4;
7
+ };
8
+ export type AnimationIdValue = (typeof AnimationId)[keyof typeof AnimationId];
9
+ export interface IAnimationStateComponent {
10
+ animationId: {
11
+ get(e: number): number;
12
+ set(e: number, v: number): void;
13
+ };
14
+ animationTime: {
15
+ get(e: number): number;
16
+ set(e: number, v: number): void;
17
+ };
18
+ animationSpeed: {
19
+ get(e: number): number;
20
+ set(e: number, v: number): void;
21
+ };
22
+ prevAnimationId: {
23
+ get(e: number): number;
24
+ set(e: number, v: number): void;
25
+ };
26
+ transitionProgress: {
27
+ get(e: number): number;
28
+ set(e: number, v: number): void;
29
+ };
30
+ transitionDuration: {
31
+ get(e: number): number;
32
+ set(e: number, v: number): void;
33
+ };
34
+ locomotionAngle: {
35
+ get(e: number): number;
36
+ set(e: number, v: number): void;
37
+ };
38
+ locomotionSpeed: {
39
+ get(e: number): number;
40
+ set(e: number, v: number): void;
41
+ };
42
+ }
43
+ export declare class AnimationStateMachine {
44
+ play(component: IAnimationStateComponent, entity: number, animId: number, crossfadeDuration?: number): void;
45
+ tick(component: IAnimationStateComponent, entity: number, dt: number): void;
46
+ }
47
+ //# sourceMappingURL=animation-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation-state.d.ts","sourceRoot":"","sources":["../../src/lib/animation-state.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE9E,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE;QAAE,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IACzE,aAAa,EAAE;QAAE,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC3E,cAAc,EAAE;QAAE,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC5E,eAAe,EAAE;QAAE,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC7E,kBAAkB,EAAE;QAAE,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAChF,kBAAkB,EAAE;QAAE,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAChF,eAAe,EAAE;QAAE,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC7E,eAAe,EAAE;QAAE,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CAC9E;AAED,qBAAa,qBAAqB;IACzB,IAAI,CAAC,SAAS,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,SAAM,GAAG,IAAI;IAWxG,IAAI,CAAC,SAAS,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;CAgBnF"}
@@ -0,0 +1,35 @@
1
+ export const AnimationId = {
2
+ IDLE: 0,
3
+ LOCOMOTION: 1,
4
+ JUMP: 2,
5
+ FALL: 3,
6
+ LAND: 4
7
+ };
8
+ export class AnimationStateMachine {
9
+ play(component, entity, animId, crossfadeDuration = 0.2) {
10
+ const currentId = component.animationId.get(entity);
11
+ if (currentId === animId) return;
12
+ component.prevAnimationId.set(entity, currentId);
13
+ component.animationId.set(entity, animId);
14
+ component.animationTime.set(entity, 0);
15
+ component.transitionProgress.set(entity, 0);
16
+ component.transitionDuration.set(entity, crossfadeDuration);
17
+ }
18
+ tick(component, entity, dt) {
19
+ const speed = component.animationSpeed.get(entity);
20
+ const time = component.animationTime.get(entity);
21
+ component.animationTime.set(entity, time + dt * speed);
22
+ const transitionDuration = component.transitionDuration.get(entity);
23
+ if (transitionDuration > 0) {
24
+ let progress = component.transitionProgress.get(entity);
25
+ progress += dt / transitionDuration;
26
+ if (progress >= 1) {
27
+ progress = 1;
28
+ component.transitionDuration.set(entity, 0);
29
+ }
30
+ component.transitionProgress.set(entity, progress);
31
+ }
32
+ }
33
+ }
34
+
35
+ //# sourceMappingURL=animation-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/animation-state.ts"],"sourcesContent":["export const AnimationId = {\n IDLE: 0,\n LOCOMOTION: 1,\n JUMP: 2,\n FALL: 3,\n LAND: 4,\n} as const;\n\nexport type AnimationIdValue = (typeof AnimationId)[keyof typeof AnimationId];\n\nexport interface IAnimationStateComponent {\n animationId: { get(e: number): number; set(e: number, v: number): void };\n animationTime: { get(e: number): number; set(e: number, v: number): void };\n animationSpeed: { get(e: number): number; set(e: number, v: number): void };\n prevAnimationId: { get(e: number): number; set(e: number, v: number): void };\n transitionProgress: { get(e: number): number; set(e: number, v: number): void };\n transitionDuration: { get(e: number): number; set(e: number, v: number): void };\n locomotionAngle: { get(e: number): number; set(e: number, v: number): void };\n locomotionSpeed: { get(e: number): number; set(e: number, v: number): void };\n}\n\nexport class AnimationStateMachine {\n public play(component: IAnimationStateComponent, entity: number, animId: number, crossfadeDuration = 0.2): void {\n const currentId = component.animationId.get(entity);\n if (currentId === animId) return;\n\n component.prevAnimationId.set(entity, currentId);\n component.animationId.set(entity, animId);\n component.animationTime.set(entity, 0);\n component.transitionProgress.set(entity, 0);\n component.transitionDuration.set(entity, crossfadeDuration);\n }\n\n public tick(component: IAnimationStateComponent, entity: number, dt: number): void {\n const speed = component.animationSpeed.get(entity);\n const time = component.animationTime.get(entity);\n component.animationTime.set(entity, time + dt * speed);\n\n const transitionDuration = component.transitionDuration.get(entity);\n if (transitionDuration > 0) {\n let progress = component.transitionProgress.get(entity);\n progress += dt / transitionDuration;\n if (progress >= 1) {\n progress = 1;\n component.transitionDuration.set(entity, 0);\n }\n component.transitionProgress.set(entity, progress);\n }\n }\n}\n"],"names":["AnimationId","IDLE","LOCOMOTION","JUMP","FALL","LAND","AnimationStateMachine","play","component","entity","animId","crossfadeDuration","currentId","animationId","get","prevAnimationId","set","animationTime","transitionProgress","transitionDuration","tick","dt","speed","animationSpeed","time","progress"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAO,MAAMA,cAAc;IACzBC,MAAM;IACNC,YAAY;IACZC,MAAM;IACNC,MAAM;IACNC,MAAM;AACR,EAAW;AAeX,OAAO,MAAMC;IACJC,KAAKC,SAAmC,EAAEC,MAAc,EAAEC,MAAc,EAAEC,oBAAoB,GAAG,EAAQ;QAC9G,MAAMC,YAAYJ,UAAUK,WAAW,CAACC,GAAG,CAACL;QAC5C,IAAIG,cAAcF,QAAQ;QAE1BF,UAAUO,eAAe,CAACC,GAAG,CAACP,QAAQG;QACtCJ,UAAUK,WAAW,CAACG,GAAG,CAACP,QAAQC;QAClCF,UAAUS,aAAa,CAACD,GAAG,CAACP,QAAQ;QACpCD,UAAUU,kBAAkB,CAACF,GAAG,CAACP,QAAQ;QACzCD,UAAUW,kBAAkB,CAACH,GAAG,CAACP,QAAQE;IAC3C;IAEOS,KAAKZ,SAAmC,EAAEC,MAAc,EAAEY,EAAU,EAAQ;QACjF,MAAMC,QAAQd,UAAUe,cAAc,CAACT,GAAG,CAACL;QAC3C,MAAMe,OAAOhB,UAAUS,aAAa,CAACH,GAAG,CAACL;QACzCD,UAAUS,aAAa,CAACD,GAAG,CAACP,QAAQe,OAAOH,KAAKC;QAEhD,MAAMH,qBAAqBX,UAAUW,kBAAkB,CAACL,GAAG,CAACL;QAC5D,IAAIU,qBAAqB,GAAG;YAC1B,IAAIM,WAAWjB,UAAUU,kBAAkB,CAACJ,GAAG,CAACL;YAChDgB,YAAYJ,KAAKF;YACjB,IAAIM,YAAY,GAAG;gBACjBA,WAAW;gBACXjB,UAAUW,kBAAkB,CAACH,GAAG,CAACP,QAAQ;YAC3C;YACAD,UAAUU,kBAAkB,CAACF,GAAG,CAACP,QAAQgB;QAC3C;IACF;AACF"}
@@ -0,0 +1,17 @@
1
+ import { LocomotionBlendWeights } from './locomotion-blend.js';
2
+ import { IAnimationStateComponent } from './animation-state.js';
3
+ export interface AnimationViewState {
4
+ currentAnimation: number;
5
+ previousAnimation: number;
6
+ transitionWeight: number;
7
+ locomotionBlend: LocomotionBlendWeights | null;
8
+ walkRunBlend: number;
9
+ time: number;
10
+ }
11
+ export declare class AnimationViewAdapter {
12
+ private readonly _runSpeed;
13
+ private readonly _state;
14
+ constructor(_runSpeed: number);
15
+ getViewState(component: IAnimationStateComponent, entity: number): AnimationViewState;
16
+ }
17
+ //# sourceMappingURL=animation-view-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation-view-adapter.d.ts","sourceRoot":"","sources":["../../src/lib/animation-view-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC1F,OAAO,EAAe,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAE7E,MAAM,WAAW,kBAAkB;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC/C,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,oBAAoB;IAUnB,OAAO,CAAC,QAAQ,CAAC,SAAS;IATtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAOrB;gBAE2B,SAAS,EAAE,MAAM;IAEvC,YAAY,CAAC,SAAS,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB;CAyB7F"}
@@ -0,0 +1,39 @@
1
+ import { LocomotionBlendCalculator } from './locomotion-blend.js';
2
+ import { AnimationId } from './animation-state.js';
3
+ export class AnimationViewAdapter {
4
+ getViewState(component, entity) {
5
+ const state = this._state;
6
+ state.currentAnimation = component.animationId.get(entity);
7
+ state.previousAnimation = component.prevAnimationId.get(entity);
8
+ state.time = component.animationTime.get(entity);
9
+ const transitionDuration = component.transitionDuration.get(entity);
10
+ if (transitionDuration > 0) {
11
+ state.transitionWeight = component.transitionProgress.get(entity);
12
+ } else {
13
+ state.transitionWeight = 1;
14
+ }
15
+ if (state.currentAnimation === AnimationId.LOCOMOTION) {
16
+ const angle = component.locomotionAngle.get(entity);
17
+ const speed = component.locomotionSpeed.get(entity);
18
+ state.locomotionBlend = LocomotionBlendCalculator.compute(angle, speed, this._runSpeed);
19
+ state.walkRunBlend = Math.min(speed / this._runSpeed, 1);
20
+ } else {
21
+ state.locomotionBlend = null;
22
+ state.walkRunBlend = 0;
23
+ }
24
+ return state;
25
+ }
26
+ constructor(_runSpeed){
27
+ this._runSpeed = _runSpeed;
28
+ this._state = {
29
+ currentAnimation: AnimationId.IDLE,
30
+ previousAnimation: AnimationId.IDLE,
31
+ transitionWeight: 1,
32
+ locomotionBlend: null,
33
+ walkRunBlend: 0,
34
+ time: 0
35
+ };
36
+ }
37
+ }
38
+
39
+ //# sourceMappingURL=animation-view-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/animation-view-adapter.ts"],"sourcesContent":["import { LocomotionBlendCalculator, LocomotionBlendWeights } from './locomotion-blend.js';\nimport { AnimationId, IAnimationStateComponent } from './animation-state.js';\n\nexport interface AnimationViewState {\n currentAnimation: number;\n previousAnimation: number;\n transitionWeight: number;\n locomotionBlend: LocomotionBlendWeights | null;\n walkRunBlend: number;\n time: number;\n}\n\nexport class AnimationViewAdapter {\n private readonly _state: AnimationViewState = {\n currentAnimation: AnimationId.IDLE,\n previousAnimation: AnimationId.IDLE,\n transitionWeight: 1,\n locomotionBlend: null,\n walkRunBlend: 0,\n time: 0,\n };\n\n constructor(private readonly _runSpeed: number) {}\n\n public getViewState(component: IAnimationStateComponent, entity: number): AnimationViewState {\n const state = this._state;\n state.currentAnimation = component.animationId.get(entity);\n state.previousAnimation = component.prevAnimationId.get(entity);\n state.time = component.animationTime.get(entity);\n\n const transitionDuration = component.transitionDuration.get(entity);\n if (transitionDuration > 0) {\n state.transitionWeight = component.transitionProgress.get(entity);\n } else {\n state.transitionWeight = 1;\n }\n\n if (state.currentAnimation === AnimationId.LOCOMOTION) {\n const angle = component.locomotionAngle.get(entity);\n const speed = component.locomotionSpeed.get(entity);\n state.locomotionBlend = LocomotionBlendCalculator.compute(angle, speed, this._runSpeed);\n state.walkRunBlend = Math.min(speed / this._runSpeed, 1);\n } else {\n state.locomotionBlend = null;\n state.walkRunBlend = 0;\n }\n\n return state;\n }\n}\n"],"names":["LocomotionBlendCalculator","AnimationId","AnimationViewAdapter","getViewState","component","entity","state","_state","currentAnimation","animationId","get","previousAnimation","prevAnimationId","time","animationTime","transitionDuration","transitionWeight","transitionProgress","LOCOMOTION","angle","locomotionAngle","speed","locomotionSpeed","locomotionBlend","compute","_runSpeed","walkRunBlend","Math","min","constructor","IDLE"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,yBAAyB,QAAgC,wBAAwB;AAC1F,SAASC,WAAW,QAAkC,uBAAuB;AAW7E,OAAO,MAAMC;IAYJC,aAAaC,SAAmC,EAAEC,MAAc,EAAsB;QAC3F,MAAMC,QAAQ,IAAI,CAACC,MAAM;QACzBD,MAAME,gBAAgB,GAAGJ,UAAUK,WAAW,CAACC,GAAG,CAACL;QACnDC,MAAMK,iBAAiB,GAAGP,UAAUQ,eAAe,CAACF,GAAG,CAACL;QACxDC,MAAMO,IAAI,GAAGT,UAAUU,aAAa,CAACJ,GAAG,CAACL;QAEzC,MAAMU,qBAAqBX,UAAUW,kBAAkB,CAACL,GAAG,CAACL;QAC5D,IAAIU,qBAAqB,GAAG;YAC1BT,MAAMU,gBAAgB,GAAGZ,UAAUa,kBAAkB,CAACP,GAAG,CAACL;QAC5D,OAAO;YACLC,MAAMU,gBAAgB,GAAG;QAC3B;QAEA,IAAIV,MAAME,gBAAgB,KAAKP,YAAYiB,UAAU,EAAE;YACrD,MAAMC,QAAQf,UAAUgB,eAAe,CAACV,GAAG,CAACL;YAC5C,MAAMgB,QAAQjB,UAAUkB,eAAe,CAACZ,GAAG,CAACL;YAC5CC,MAAMiB,eAAe,GAAGvB,0BAA0BwB,OAAO,CAACL,OAAOE,OAAO,IAAI,CAACI,SAAS;YACtFnB,MAAMoB,YAAY,GAAGC,KAAKC,GAAG,CAACP,QAAQ,IAAI,CAACI,SAAS,EAAE;QACxD,OAAO;YACLnB,MAAMiB,eAAe,GAAG;YACxBjB,MAAMoB,YAAY,GAAG;QACvB;QAEA,OAAOpB;IACT;IA1BAuB,YAAY,AAAiBJ,SAAiB,CAAE;aAAnBA,YAAAA;aATZlB,SAA6B;YAC5CC,kBAAkBP,YAAY6B,IAAI;YAClCnB,mBAAmBV,YAAY6B,IAAI;YACnCd,kBAAkB;YAClBO,iBAAiB;YACjBG,cAAc;YACdb,MAAM;QACR;IAEiD;AA2BnD"}
@@ -0,0 +1,17 @@
1
+ export interface LocomotionBlendWeights {
2
+ forward: number;
3
+ backward: number;
4
+ left: number;
5
+ right: number;
6
+ }
7
+ export declare class LocomotionBlendCalculator {
8
+ /**
9
+ * Computes directional blend weights from angle and speed.
10
+ * @param angle Locomotion angle in radians (-PI..PI, 0=forward)
11
+ * @param speed Current speed
12
+ * @param maxSpeed Maximum speed (for normalizing)
13
+ * @returns Blend weights that sum to speedFactor (0..1)
14
+ */
15
+ static compute(angle: number, speed: number, maxSpeed: number): LocomotionBlendWeights;
16
+ }
17
+ //# sourceMappingURL=locomotion-blend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locomotion-blend.d.ts","sourceRoot":"","sources":["../../src/lib/locomotion-blend.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAID,qBAAa,yBAAyB;IACpC;;;;;;OAMG;WACW,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,sBAAsB;CAqB9F"}
@@ -0,0 +1,35 @@
1
+ import { MathOps } from '@lagless/math';
2
+ const _result = {
3
+ forward: 0,
4
+ backward: 0,
5
+ left: 0,
6
+ right: 0
7
+ };
8
+ export class LocomotionBlendCalculator {
9
+ /**
10
+ * Computes directional blend weights from angle and speed.
11
+ * @param angle Locomotion angle in radians (-PI..PI, 0=forward)
12
+ * @param speed Current speed
13
+ * @param maxSpeed Maximum speed (for normalizing)
14
+ * @returns Blend weights that sum to speedFactor (0..1)
15
+ */ static compute(angle, speed, maxSpeed) {
16
+ if (maxSpeed <= 0 || speed <= 0) {
17
+ _result.forward = 0;
18
+ _result.backward = 0;
19
+ _result.left = 0;
20
+ _result.right = 0;
21
+ return _result;
22
+ }
23
+ const speedFactor = Math.min(speed / maxSpeed, 1);
24
+ const cosA = MathOps.cos(angle);
25
+ const sinA = MathOps.sin(angle);
26
+ // Forward/backward from cos, left/right from sin
27
+ _result.forward = cosA > 0 ? cosA * speedFactor : 0;
28
+ _result.backward = cosA < 0 ? -cosA * speedFactor : 0;
29
+ _result.left = sinA < 0 ? -sinA * speedFactor : 0;
30
+ _result.right = sinA > 0 ? sinA * speedFactor : 0;
31
+ return _result;
32
+ }
33
+ }
34
+
35
+ //# sourceMappingURL=locomotion-blend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/locomotion-blend.ts"],"sourcesContent":["import { MathOps } from '@lagless/math';\n\nexport interface LocomotionBlendWeights {\n forward: number;\n backward: number;\n left: number;\n right: number;\n}\n\nconst _result: LocomotionBlendWeights = { forward: 0, backward: 0, left: 0, right: 0 };\n\nexport class LocomotionBlendCalculator {\n /**\n * Computes directional blend weights from angle and speed.\n * @param angle Locomotion angle in radians (-PI..PI, 0=forward)\n * @param speed Current speed\n * @param maxSpeed Maximum speed (for normalizing)\n * @returns Blend weights that sum to speedFactor (0..1)\n */\n public static compute(angle: number, speed: number, maxSpeed: number): LocomotionBlendWeights {\n if (maxSpeed <= 0 || speed <= 0) {\n _result.forward = 0;\n _result.backward = 0;\n _result.left = 0;\n _result.right = 0;\n return _result;\n }\n\n const speedFactor = Math.min(speed / maxSpeed, 1);\n const cosA = MathOps.cos(angle);\n const sinA = MathOps.sin(angle);\n\n // Forward/backward from cos, left/right from sin\n _result.forward = cosA > 0 ? cosA * speedFactor : 0;\n _result.backward = cosA < 0 ? -cosA * speedFactor : 0;\n _result.left = sinA < 0 ? -sinA * speedFactor : 0;\n _result.right = sinA > 0 ? sinA * speedFactor : 0;\n\n return _result;\n }\n}\n"],"names":["MathOps","_result","forward","backward","left","right","LocomotionBlendCalculator","compute","angle","speed","maxSpeed","speedFactor","Math","min","cosA","cos","sinA","sin"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,OAAO,QAAQ,gBAAgB;AASxC,MAAMC,UAAkC;IAAEC,SAAS;IAAGC,UAAU;IAAGC,MAAM;IAAGC,OAAO;AAAE;AAErF,OAAO,MAAMC;IACX;;;;;;GAMC,GACD,OAAcC,QAAQC,KAAa,EAAEC,KAAa,EAAEC,QAAgB,EAA0B;QAC5F,IAAIA,YAAY,KAAKD,SAAS,GAAG;YAC/BR,QAAQC,OAAO,GAAG;YAClBD,QAAQE,QAAQ,GAAG;YACnBF,QAAQG,IAAI,GAAG;YACfH,QAAQI,KAAK,GAAG;YAChB,OAAOJ;QACT;QAEA,MAAMU,cAAcC,KAAKC,GAAG,CAACJ,QAAQC,UAAU;QAC/C,MAAMI,OAAOd,QAAQe,GAAG,CAACP;QACzB,MAAMQ,OAAOhB,QAAQiB,GAAG,CAACT;QAEzB,iDAAiD;QACjDP,QAAQC,OAAO,GAAGY,OAAO,IAAIA,OAAOH,cAAc;QAClDV,QAAQE,QAAQ,GAAGW,OAAO,IAAI,CAACA,OAAOH,cAAc;QACpDV,QAAQG,IAAI,GAAGY,OAAO,IAAI,CAACA,OAAOL,cAAc;QAChDV,QAAQI,KAAK,GAAGW,OAAO,IAAIA,OAAOL,cAAc;QAEhD,OAAOV;IACT;AACF"}
@@ -0,0 +1 @@
1
+ {"version":"5.9.3"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@lagless/animation-controller",
3
+ "version": "0.0.38",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/GbGr/lagless",
8
+ "directory": "libs/animation-controller"
9
+ },
10
+ "type": "module",
11
+ "main": "./dist/index.js",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ "./package.json": "./package.json",
16
+ ".": {
17
+ "@lagless/source": "./src/index.ts",
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "default": "./dist/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "nx": {
31
+ "sourceRoot": "libs/animation-controller/src",
32
+ "targets": {
33
+ "build": {
34
+ "executor": "@nx/js:swc",
35
+ "outputs": [
36
+ "{options.outputPath}"
37
+ ],
38
+ "options": {
39
+ "outputPath": "libs/animation-controller/dist",
40
+ "main": "libs/animation-controller/src/index.ts",
41
+ "tsConfig": "libs/animation-controller/tsconfig.lib.json",
42
+ "stripLeadingPaths": true
43
+ }
44
+ }
45
+ }
46
+ },
47
+ "dependencies": {
48
+ "@swc/helpers": "~0.5.11",
49
+ "@lagless/math": "0.0.38"
50
+ }
51
+ }