@flighthq/motionpath 0.5.1-next.815.cc08b93 → 0.5.1-next.903.f434bc2
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 -2
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +1 -0
- package/dist/contract.js.map +1 -1
- package/dist/motionPath.d.ts +2 -1
- package/dist/motionPath.d.ts.map +1 -1
- package/dist/motionPath.js +20 -17
- package/dist/motionPath.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/motionpath`. The `@f
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/motionpath@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/motionpath@0.5.1-next.903.f434bc2](https://github.com/flighthq/flight/tree/f434bc233778d75aeea61995df3a8cfaec459a85/packages/motionpath)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/f434bc233778d75aeea61995df3a8cfaec459a85/LICENSE.md)
|
package/dist/contract.d.ts
CHANGED
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/contract.js
CHANGED
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/motionPath.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { MotionPath, MotionPathLoopMode, Path, Vector2Like } from '@flighthq/types/contract';
|
|
1
|
+
import type { EntityConstruction, MotionPath, MotionPathLoopMode, Path, Vector2Like } from '@flighthq/types/contract';
|
|
2
2
|
export declare function createMotionPath(path: Path, speed?: number, loopMode?: MotionPathLoopMode, tolerance?: number): MotionPath;
|
|
3
3
|
export declare function getMotionPathHeading(mp: Readonly<MotionPath>): number;
|
|
4
4
|
export declare function getMotionPathPosition(mp: Readonly<MotionPath>, pointOut: Vector2Like, tangentOut: Vector2Like): boolean;
|
|
5
5
|
export declare function getMotionPathProgress(mp: Readonly<MotionPath>): number;
|
|
6
|
+
export declare function initializeMotionPath(out: EntityConstruction<MotionPath>, path: Path, speed?: number, loopMode?: MotionPathLoopMode, tolerance?: number): void;
|
|
6
7
|
export declare function setMotionPathDistance(mp: MotionPath, distance: number): void;
|
|
7
8
|
export declare function setMotionPathProgress(mp: MotionPath, t: number): void;
|
|
8
9
|
export declare function updateMotionPath(mp: MotionPath, deltaTime: number): void;
|
package/dist/motionPath.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motionPath.d.ts","sourceRoot":"","sources":["../src/motionPath.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"motionPath.d.ts","sourceRoot":"","sources":["../src/motionPath.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEtH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,EACV,KAAK,SAAI,EACT,QAAQ,GAAE,kBAA4B,EACtC,SAAS,CAAC,EAAE,MAAM,GACjB,UAAU,CAIZ;AAMD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAGrE;AAMD,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,EACxB,QAAQ,EAAE,WAAW,EACrB,UAAU,EAAE,WAAW,GACtB,OAAO,CAET;AAMD,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAEtE;AASD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,kBAAkB,CAAC,UAAU,CAAC,EACnC,IAAI,EAAE,IAAI,EACV,KAAK,SAAI,EACT,QAAQ,GAAE,kBAA4B,EACtC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAON;AAID,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAM5E;AAID,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAKrE;AAMD,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAQxE"}
|
package/dist/motionPath.js
CHANGED
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { createVector2 } from '@flighthq/geometry/contract';
|
|
3
3
|
import { getPathLength, getPathPositionAtDistance, getPathTangentAtDistance } from '@flighthq/path/contract';
|
|
4
|
-
// Allocate a `MotionPath` marker at the start of `path` (`distance` 0, `direction` forward).
|
|
5
|
-
// `speed` is the traversal rate in path units per second (a magnitude; default 0 = stationary),
|
|
6
|
-
// `loopMode` the end behavior (default `clamp`). The path's total arc length is measured once here
|
|
7
|
-
// with `getPathLength(path, tolerance)` and cached in `length`; per-frame updates reuse it rather
|
|
8
|
-
// than re-measuring. `tolerance` is the curve-flattening tolerance forwarded to the arc-length
|
|
9
|
-
// measurement. This is the only allocating function; `updateMotionPath` and the seek helpers write
|
|
10
|
-
// into an existing marker.
|
|
11
4
|
export function createMotionPath(path, speed = 0, loopMode = 'clamp', tolerance) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
length: getPathLength(path, tolerance),
|
|
16
|
-
loopMode,
|
|
17
|
-
path,
|
|
18
|
-
speed,
|
|
19
|
-
});
|
|
5
|
+
const out = allocateEntity();
|
|
6
|
+
initializeMotionPath(out, path, speed, loopMode, tolerance);
|
|
7
|
+
return finishEntity(out);
|
|
20
8
|
}
|
|
21
9
|
// Return the marker's heading angle in radians — `atan2(tangentY, tangentX)` of the path tangent at
|
|
22
10
|
// the current `distance` — for orienting an object along the curve. Samples the tangent into a
|
|
@@ -26,7 +14,6 @@ export function getMotionPathHeading(mp) {
|
|
|
26
14
|
getPathTangentAtDistance(mp.path, mp.distance, scratchTangent);
|
|
27
15
|
return Math.atan2(scratchTangent.y, scratchTangent.x);
|
|
28
16
|
}
|
|
29
|
-
const scratchTangent = createVector2();
|
|
30
17
|
// Sample the marker's current world position and unit tangent, writing them into `pointOut` and
|
|
31
18
|
// `tangentOut`. Returns `true` on success, `false` for an empty/degenerate path (in which case the
|
|
32
19
|
// outputs are left unchanged). Delegates to `@flighthq/path`'s `getPathPositionAtDistance` at the
|
|
@@ -34,11 +21,27 @@ const scratchTangent = createVector2();
|
|
|
34
21
|
export function getMotionPathPosition(mp, pointOut, tangentOut) {
|
|
35
22
|
return getPathPositionAtDistance(mp.path, mp.distance, pointOut, tangentOut);
|
|
36
23
|
}
|
|
24
|
+
const scratchTangent = createVector2();
|
|
37
25
|
// Return the marker's normalized progress along the path, `distance / length` in `[0, 1]`. A
|
|
38
26
|
// zero-length path reports 0.
|
|
39
27
|
export function getMotionPathProgress(mp) {
|
|
40
28
|
return mp.length > 0 ? mp.distance / mp.length : 0;
|
|
41
29
|
}
|
|
30
|
+
// Allocate a `MotionPath` marker at the start of `path` (`distance` 0, `direction` forward).
|
|
31
|
+
// `speed` is the traversal rate in path units per second (a magnitude; default 0 = stationary),
|
|
32
|
+
// `loopMode` the end behavior (default `clamp`). The path's total arc length is measured once here
|
|
33
|
+
// with `getPathLength(path, tolerance)` and cached in `length`; per-frame updates reuse it rather
|
|
34
|
+
// than re-measuring. `tolerance` is the curve-flattening tolerance forwarded to the arc-length
|
|
35
|
+
// measurement. This is the only allocating function; `updateMotionPath` and the seek helpers write
|
|
36
|
+
// into an existing marker.
|
|
37
|
+
export function initializeMotionPath(out, path, speed = 0, loopMode = 'clamp', tolerance) {
|
|
38
|
+
out.direction = 1;
|
|
39
|
+
out.distance = 0;
|
|
40
|
+
out.length = getPathLength(path, tolerance);
|
|
41
|
+
out.loopMode = loopMode;
|
|
42
|
+
out.path = path;
|
|
43
|
+
out.speed = speed;
|
|
44
|
+
}
|
|
42
45
|
// Seek the marker to an absolute arc-length `distance`, clamping to the valid `[0, length]` range.
|
|
43
46
|
// Does not change `direction` or `speed`.
|
|
44
47
|
export function setMotionPathDistance(mp, distance) {
|
package/dist/motionPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motionPath.js","sourceRoot":"","sources":["../src/motionPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"motionPath.js","sourceRoot":"","sources":["../src/motionPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;A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,IAAI,MAAM,CAAC;QACrC,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;YACvB,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACvB,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,EAAE,CAAC,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;YAChC,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QACpB,CAAC;QACD,OAAO;IACT,CAAC;IAED,QAAQ;IACR,IAAI,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC;IAC1C,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,CAAC;SACxB,IAAI,OAAO,GAAG,MAAM;QAAE,OAAO,GAAG,MAAM,CAAC;IAC5C,EAAE,CAAC,QAAQ,GAAG,OAAO,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/motionpath",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.903.f434bc2",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/geometry": "0.5.1-next.
|
|
43
|
-
"@flighthq/path": "0.5.1-next.
|
|
44
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.903.f434bc2",
|
|
42
|
+
"@flighthq/geometry": "0.5.1-next.903.f434bc2",
|
|
43
|
+
"@flighthq/path": "0.5.1-next.903.f434bc2",
|
|
44
|
+
"@flighthq/types": "0.5.1-next.903.f434bc2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"typescript": "^5.3.0"
|