vehicle-path2 2.0.0 → 2.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/dist/core/algorithms/pathFinding.d.ts +10 -10
- package/dist/core/index.d.ts +1 -0
- package/dist/core/snapshot.d.ts +54 -0
- package/dist/core.cjs +1 -1
- package/dist/core.js +73 -30
- package/dist/index-B3uagMdY.js +712 -0
- package/dist/index-DA33ne3M.cjs +1 -0
- package/dist/vehicle-path.cjs +1 -1
- package/dist/vehicle-path.js +31 -730
- package/package.json +1 -1
|
@@ -35,21 +35,21 @@ export interface VehiclePosition {
|
|
|
35
35
|
*/
|
|
36
36
|
export declare function calculateBezierArcLength(bezier: BezierCurve, segments?: number): number;
|
|
37
37
|
/**
|
|
38
|
-
* Resolve offset untuk FROM line (garis asal kurva)
|
|
39
|
-
*
|
|
40
|
-
* - 100% → lineLength (ujung garis)
|
|
38
|
+
* Resolve offset untuk FROM line (garis asal kurva).
|
|
39
|
+
* Kurva bisa ditempatkan di mana saja pada line: range [0, lineLength].
|
|
41
40
|
*
|
|
42
|
-
*
|
|
41
|
+
* Untuk absolute offset: clamp ke [0, lineLength].
|
|
42
|
+
* Untuk percentage (0-1): map ke [0, lineLength].
|
|
43
43
|
*/
|
|
44
|
-
export declare function resolveFromLineOffset(line: Line, offset: number | undefined, isPercentage: boolean | undefined, defaultPercentage: number,
|
|
44
|
+
export declare function resolveFromLineOffset(line: Line, offset: number | undefined, isPercentage: boolean | undefined, defaultPercentage: number, _maxWheelbase: number): number;
|
|
45
45
|
/**
|
|
46
|
-
* Resolve offset untuk TO line (garis tujuan kurva)
|
|
47
|
-
*
|
|
48
|
-
* - 100% → lineLength - wheelbase (untuk memberi ruang vehicle)
|
|
46
|
+
* Resolve offset untuk TO line (garis tujuan kurva).
|
|
47
|
+
* Kurva bisa ditempatkan di mana saja pada line: range [0, lineLength].
|
|
49
48
|
*
|
|
50
|
-
*
|
|
49
|
+
* Untuk absolute offset: clamp ke [0, lineLength].
|
|
50
|
+
* Untuk percentage (0-1): map ke [0, lineLength].
|
|
51
51
|
*/
|
|
52
|
-
export declare function resolveToLineOffset(line: Line, offset: number | undefined, isPercentage: boolean | undefined, defaultPercentage: number,
|
|
52
|
+
export declare function resolveToLineOffset(line: Line, offset: number | undefined, isPercentage: boolean | undefined, defaultPercentage: number, _maxWheelbase: number): number;
|
|
53
53
|
/**
|
|
54
54
|
* Membangun graph dari lines dan curves
|
|
55
55
|
*/
|
package/dist/core/index.d.ts
CHANGED
|
@@ -19,3 +19,4 @@ export { buildGraph, findPath, calculateBezierArcLength, resolveFromLineOffset,
|
|
|
19
19
|
export { initializeMovingVehicle, createInitialMovementState, initializeAllVehicles, calculateInitialAxlePositions, type InitializationResult, updateAxlePosition, calculatePositionOnLine, calculatePositionOnCurve, calculateFrontAxlePosition, getCumulativeArcLength, arcLengthToSegmentPosition, prepareCommandPath, type PreparedPath, handleArrival, type SegmentCompletionContext, type SegmentCompletionResult, type SegmentVehicleState, moveVehicle, getPositionFromOffset, getLineLength } from './algorithms/vehicleMovement';
|
|
20
20
|
export { PathEngine, type PathEngineConfig, type VehiclePathState, type PathExecution } from './engine';
|
|
21
21
|
export { distance, normalize, getPointOnLine, getPointOnLineByOffset, getPointOnBezier, createBezierCurve, buildArcLengthTable, distanceToT, getArcLength, calculateTangentLength, isPointNearPoint, type ArcLengthEntry, type CurveOffsetOptions } from './algorithms/math';
|
|
22
|
+
export { serializeScene, deserializeScene, type SceneSnapshot } from './snapshot';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Line } from './types/geometry';
|
|
2
|
+
export interface SceneSnapshot {
|
|
3
|
+
lines: Line[];
|
|
4
|
+
curves: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
fromLineId: string;
|
|
7
|
+
toLineId: string;
|
|
8
|
+
fromOffset: number;
|
|
9
|
+
fromIsPercentage: boolean;
|
|
10
|
+
toOffset: number;
|
|
11
|
+
toIsPercentage: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
vehicles: Array<{
|
|
14
|
+
id: string;
|
|
15
|
+
lineId: string;
|
|
16
|
+
axles: Array<{
|
|
17
|
+
offset: number;
|
|
18
|
+
}>;
|
|
19
|
+
axleSpacings: number[];
|
|
20
|
+
isPercentage: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Serialize scene state to a JSON string suitable for clipboard or storage.
|
|
25
|
+
* Strips derived fields (bezier curves, axle positions) — only source-of-truth
|
|
26
|
+
* data is included.
|
|
27
|
+
*
|
|
28
|
+
* Note: lineId is per-vehicle (not per-axle) because this snapshot captures
|
|
29
|
+
* static placement where all axles share the same line. For mid-movement state,
|
|
30
|
+
* use AxleState directly.
|
|
31
|
+
*/
|
|
32
|
+
export declare function serializeScene(lines: Line[], curves: Array<{
|
|
33
|
+
id: string;
|
|
34
|
+
fromLineId: string;
|
|
35
|
+
toLineId: string;
|
|
36
|
+
fromOffset: number;
|
|
37
|
+
fromIsPercentage?: boolean;
|
|
38
|
+
toOffset: number;
|
|
39
|
+
toIsPercentage?: boolean;
|
|
40
|
+
}>, vehicles: Array<{
|
|
41
|
+
id: string;
|
|
42
|
+
axles: Array<{
|
|
43
|
+
lineId: string;
|
|
44
|
+
offset: number;
|
|
45
|
+
[key: string]: unknown;
|
|
46
|
+
}>;
|
|
47
|
+
axleSpacings: number[];
|
|
48
|
+
isPercentage?: boolean;
|
|
49
|
+
}>): string;
|
|
50
|
+
/**
|
|
51
|
+
* Deserialize a JSON string back into a SceneSnapshot.
|
|
52
|
+
* Throws if the string is not valid JSON or missing required fields.
|
|
53
|
+
*/
|
|
54
|
+
export declare function deserializeScene(json: string): SceneSnapshot;
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DA33ne3M.cjs");function o(r,n,t){const a={lines:r,curves:n.map(i=>({id:i.id,fromLineId:i.fromLineId,toLineId:i.toLineId,fromOffset:i.fromOffset,fromIsPercentage:i.fromIsPercentage??!1,toOffset:i.toOffset,toIsPercentage:i.toIsPercentage??!1})),vehicles:t.map(i=>({id:i.id,lineId:i.axles[0].lineId,axles:i.axles.map(l=>({offset:l.offset})),axleSpacings:i.axleSpacings,isPercentage:i.isPercentage??!1}))};return JSON.stringify(a,null,2)}function s(r){let n;try{n=JSON.parse(r)}catch{throw new Error("deserializeScene: invalid JSON")}if(!n||typeof n!="object"||Array.isArray(n))throw new Error("deserializeScene: expected a JSON object");const t=n;if(!Array.isArray(t.lines))throw new Error('deserializeScene: missing "lines"');if(!Array.isArray(t.curves))throw new Error('deserializeScene: missing "curves"');if(!Array.isArray(t.vehicles))throw new Error('deserializeScene: missing "vehicles"');return{lines:t.lines,curves:t.curves,vehicles:t.vehicles}}exports.PathEngine=e.PathEngine;exports.arcLengthToSegmentPosition=e.arcLengthToSegmentPosition;exports.buildArcLengthTable=e.buildArcLengthTable;exports.buildGraph=e.buildGraph;exports.calculateBezierArcLength=e.calculateBezierArcLength;exports.calculateFrontAxlePosition=e.calculateFrontAxlePosition;exports.calculateInitialAxlePositions=e.calculateInitialAxlePositions;exports.calculatePositionOnCurve=e.calculatePositionOnCurve;exports.calculatePositionOnLine=e.calculatePositionOnLine;exports.calculateTangentLength=e.calculateTangentLength;exports.createBezierCurve=e.createBezierCurve;exports.createInitialMovementState=e.createInitialMovementState;exports.distance=e.distance;exports.distanceToT=e.distanceToT;exports.findPath=e.findPath;exports.getArcLength=e.getArcLength;exports.getCumulativeArcLength=e.getCumulativeArcLength;exports.getLineLength=e.getLineLength;exports.getPointOnBezier=e.getPointOnBezier;exports.getPointOnLine=e.getPointOnLine;exports.getPointOnLineByOffset=e.getPointOnLineByOffset;exports.getPositionFromOffset=e.getPositionFromOffset;exports.handleArrival=e.handleArrival;exports.initializeAllVehicles=e.initializeAllVehicles;exports.initializeMovingVehicle=e.initializeMovingVehicle;exports.isPointNearPoint=e.isPointNearPoint;exports.moveVehicle=e.moveVehicle;exports.normalize=e.normalize;exports.prepareCommandPath=e.prepareCommandPath;exports.resolveFromLineOffset=e.resolveFromLineOffset;exports.resolveToLineOffset=e.resolveToLineOffset;exports.updateAxlePosition=e.updateAxlePosition;exports.deserializeScene=s;exports.serializeScene=o;
|
package/dist/core.js
CHANGED
|
@@ -1,35 +1,78 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as f, a as g, b as h, c as d, d as u, e as m, f as P, g as A, h as v, i as L, j as O, k as p, l as S, m as z, n as y, o as w, p as x, q as I, r as b, s as E, t as T, u as B, v as C, w as N, x as j, y as J, z as F, A as V, B as M, C as k, D as q, E as D } from "./index-B3uagMdY.js";
|
|
2
|
+
function n(s, a, i) {
|
|
3
|
+
const r = {
|
|
4
|
+
lines: s,
|
|
5
|
+
curves: a.map((e) => ({
|
|
6
|
+
id: e.id,
|
|
7
|
+
fromLineId: e.fromLineId,
|
|
8
|
+
toLineId: e.toLineId,
|
|
9
|
+
fromOffset: e.fromOffset,
|
|
10
|
+
fromIsPercentage: e.fromIsPercentage ?? !1,
|
|
11
|
+
toOffset: e.toOffset,
|
|
12
|
+
toIsPercentage: e.toIsPercentage ?? !1
|
|
13
|
+
})),
|
|
14
|
+
vehicles: i.map((e) => ({
|
|
15
|
+
id: e.id,
|
|
16
|
+
lineId: e.axles[0].lineId,
|
|
17
|
+
axles: e.axles.map((t) => ({ offset: t.offset })),
|
|
18
|
+
axleSpacings: e.axleSpacings,
|
|
19
|
+
isPercentage: e.isPercentage ?? !1
|
|
20
|
+
}))
|
|
21
|
+
};
|
|
22
|
+
return JSON.stringify(r, null, 2);
|
|
23
|
+
}
|
|
24
|
+
function o(s) {
|
|
25
|
+
let a;
|
|
26
|
+
try {
|
|
27
|
+
a = JSON.parse(s);
|
|
28
|
+
} catch {
|
|
29
|
+
throw new Error("deserializeScene: invalid JSON");
|
|
30
|
+
}
|
|
31
|
+
if (!a || typeof a != "object" || Array.isArray(a))
|
|
32
|
+
throw new Error("deserializeScene: expected a JSON object");
|
|
33
|
+
const i = a;
|
|
34
|
+
if (!Array.isArray(i.lines)) throw new Error('deserializeScene: missing "lines"');
|
|
35
|
+
if (!Array.isArray(i.curves)) throw new Error('deserializeScene: missing "curves"');
|
|
36
|
+
if (!Array.isArray(i.vehicles)) throw new Error('deserializeScene: missing "vehicles"');
|
|
37
|
+
return {
|
|
38
|
+
lines: i.lines,
|
|
39
|
+
curves: i.curves,
|
|
40
|
+
vehicles: i.vehicles
|
|
41
|
+
};
|
|
42
|
+
}
|
|
2
43
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
44
|
+
f as PathEngine,
|
|
45
|
+
g as arcLengthToSegmentPosition,
|
|
46
|
+
h as buildArcLengthTable,
|
|
47
|
+
d as buildGraph,
|
|
48
|
+
u as calculateBezierArcLength,
|
|
49
|
+
m as calculateFrontAxlePosition,
|
|
50
|
+
P as calculateInitialAxlePositions,
|
|
51
|
+
A as calculatePositionOnCurve,
|
|
52
|
+
v as calculatePositionOnLine,
|
|
53
|
+
L as calculateTangentLength,
|
|
54
|
+
O as createBezierCurve,
|
|
55
|
+
p as createInitialMovementState,
|
|
56
|
+
o as deserializeScene,
|
|
57
|
+
S as distance,
|
|
58
|
+
z as distanceToT,
|
|
59
|
+
y as findPath,
|
|
60
|
+
w as getArcLength,
|
|
61
|
+
x as getCumulativeArcLength,
|
|
62
|
+
I as getLineLength,
|
|
63
|
+
b as getPointOnBezier,
|
|
64
|
+
E as getPointOnLine,
|
|
23
65
|
T as getPointOnLineByOffset,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
66
|
+
B as getPositionFromOffset,
|
|
67
|
+
C as handleArrival,
|
|
68
|
+
N as initializeAllVehicles,
|
|
69
|
+
j as initializeMovingVehicle,
|
|
70
|
+
J as isPointNearPoint,
|
|
29
71
|
F as moveVehicle,
|
|
30
72
|
V as normalize,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
73
|
+
M as prepareCommandPath,
|
|
74
|
+
k as resolveFromLineOffset,
|
|
75
|
+
q as resolveToLineOffset,
|
|
76
|
+
n as serializeScene,
|
|
77
|
+
D as updateAxlePosition
|
|
35
78
|
};
|