vehicle-path2 1.0.9 → 1.0.10
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.cjs +1 -1
- package/dist/core.js +48 -46
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function I(e,t){const s=t.x-e.x,n=t.y-e.y;return Math.sqrt(s*s+n*n)}function P(e,t){const s=t.x-e.x,n=t.y-e.y,o=Math.sqrt(s*s+n*n);return o===0?{x:0,y:0}:{x:s/o,y:n/o}}function V(e,t){return t*(e==="proportional-40"?.4:.5522)}function C(e,t,s,n=!1,o){const{wheelbase:c,tangentMode:r}=s;let i;o?.fromOffset!==void 0?i=D(e,o.fromOffset,o.fromIsPercentage??!1):i=e.end;let l;o?.toOffset!==void 0?l=D(t,o.toOffset,o.toIsPercentage??!1):l=t.start;const d=P(e.start,e.end),f=n?{x:i.x-d.x*c,y:i.y-d.y*c}:i,u=P(e.start,e.end),g=P(t.start,t.end),p=I(f,l),v=V(r,p),a=n?{x:f.x-u.x*v,y:f.y-u.y*v}:{x:f.x+u.x*v,y:f.y+u.y*v},m={x:l.x-g.x*v,y:l.y-g.y*v};return{p0:f,p1:a,p2:m,p3:l}}function B(e,t){return{x:e.start.x+(e.end.x-e.start.x)*t,y:e.start.y+(e.end.y-e.start.y)*t}}function D(e,t,s){const n=I(e.start,e.end);let o;return s?o=t:o=n>0?t/n:0,o=Math.max(0,Math.min(1,o)),B(e,o)}function w(e,t){const{p0:s,p1:n,p2:o,p3:c}=e,r=1-t,i=r*r,l=i*r,d=t*t,f=d*t;return{x:l*s.x+3*i*t*n.x+3*r*d*o.x+f*c.x,y:l*s.y+3*i*t*n.y+3*r*d*o.y+f*c.y}}function H(e,t,s=10){return I(e,t)<=s}function q(e,t=100){const s=[{t:0,distance:0}];let n=e.p0,o=0;for(let c=1;c<=t;c++){const r=c/t,i=w(e,r);o+=I(n,i),s.push({t:r,distance:o}),n=i}return s}function F(e,t){if(t<=0)return 0;const s=e[e.length-1].distance;if(t>=s)return 1;let n=0,o=e.length-1;for(;n<o-1;){const f=Math.floor((n+o)/2);e[f].distance<t?n=f:o=f}const c=e[n].distance,r=e[o].distance,i=e[n].t,l=e[o].t;if(r===c)return i;const d=(t-c)/(r-c);return i+d*(l-i)}function J(e){return e[e.length-1].distance}function j(e,t=100){let s=0,n=e.p0;for(let o=1;o<=t;o++){const c=o/t,r=w(e,c);s+=I(n,r),n=r}return s}function S(e,t,s,n,o){const c=I(e.start,e.end),r=c-o;if(r<=0)return c;let i;if(t===void 0)i=n;else if(s)i=t;else{const l=Math.max(0,Math.min(t,r));return o+l}return o+i*r}function T(e,t,s,n,o){const r=I(e.start,e.end)-o;if(r<=0)return 0;let i;if(t===void 0)i=n;else if(s)i=t;else return Math.max(0,Math.min(t,r));return i*r}function U(e,t,s){const n=new Map,o=new Map,c=new Map;for(const r of e)o.set(r.id,r),c.set(r.id,I(r.start,r.end)),n.set(r.id,[]);for(let r=0;r<t.length;r++){const i=t[r],l=o.get(i.fromLineId),d=o.get(i.toLineId);if(!l||!d)continue;const f=S(l,i.fromOffset,i.fromIsPercentage,1,s.wheelbase),u=T(d,i.toOffset,i.toIsPercentage,0,s.wheelbase),g=C(l,d,s,!1,{fromOffset:f,fromIsPercentage:!1,toOffset:u,toIsPercentage:!1}),p=j(g),v={curveIndex:r,fromLineId:i.fromLineId,toLineId:i.toLineId,fromOffset:f,toOffset:u,curveLength:p};n.get(i.fromLineId).push(v)}return{adjacency:n,lines:o,lineLengths:c}}function K(e,t,s,n,o=!1){const{adjacency:c,lines:r,lineLengths:i}=e;if(!r.get(s))return null;const d=i.get(s),f=o?n/100*d:n,u=[],g=new Map,p=(a,m)=>`${a}:${Math.round(m)}`;if(t.lineId===s&&f>=t.offset){const a=f-t.offset;return{segments:[{type:"line",lineId:t.lineId,startOffset:t.offset,endOffset:f,length:a}],totalDistance:a}}const v=c.get(t.lineId)||[];for(const a of v){if(a.fromOffset<t.offset)continue;const m=a.fromOffset-t.offset,L=m+a.curveLength,x={type:"line",lineId:t.lineId,startOffset:t.offset,endOffset:a.fromOffset,length:m},h={type:"curve",curveIndex:a.curveIndex,startOffset:0,endOffset:a.curveLength,length:a.curveLength};u.push({lineId:a.toLineId,entryOffset:a.toOffset,totalDistance:L,path:[x,h]})}for(u.sort((a,m)=>a.totalDistance-m.totalDistance);u.length>0;){const a=u.shift(),m=p(a.lineId,a.entryOffset),L=g.get(m);if(L!==void 0&&L<=a.totalDistance)continue;if(g.set(m,a.totalDistance),a.lineId===s){const h=Math.abs(f-a.entryOffset);if(f>=a.entryOffset){const y={type:"line",lineId:s,startOffset:a.entryOffset,endOffset:f,length:h};return{segments:[...a.path,y],totalDistance:a.totalDistance+h}}}const x=c.get(a.lineId)||[];for(const h of x){if(h.fromOffset<a.entryOffset)continue;const y=h.fromOffset-a.entryOffset,A=a.totalDistance+y+h.curveLength,W=p(h.toLineId,h.toOffset),z=g.get(W);if(z!==void 0&&z<=A)continue;const _={type:"line",lineId:a.lineId,startOffset:a.entryOffset,endOffset:h.fromOffset,length:y},E={type:"curve",curveIndex:h.curveIndex,startOffset:0,endOffset:h.curveLength,length:h.curveLength};u.push({lineId:h.toLineId,entryOffset:h.toOffset,totalDistance:A,path:[...a.path,_,E]})}u.sort((h,y)=>h.totalDistance-y.totalDistance)}return null}function b(e,t){const s=Math.sqrt(Math.pow(e.end.x-e.start.x,2)+Math.pow(e.end.y-e.start.y,2)),n=s>0?t/s:0;return{x:e.start.x+(e.end.x-e.start.x)*Math.min(1,Math.max(0,n)),y:e.start.y+(e.end.y-e.start.y)*Math.min(1,Math.max(0,n))}}function G(e){return Math.sqrt(Math.pow(e.end.x-e.start.x,2)+Math.pow(e.end.y-e.start.y,2))}function N(e,t,s){let n=0;for(let o=0;o<t;o++)n+=e.segments[o].length;return n+=s,n}function $(e,t){let s=0;for(let n=0;n<e.segments.length;n++){const o=e.segments[n],c=s+o.length;if(t<c)return{segmentIndex:n,segmentDistance:t-s};if(t===c)return n+1<e.segments.length?{segmentIndex:n+1,segmentDistance:0}:{segmentIndex:n,segmentDistance:o.length};s+=o.length}return null}function k(e,t,s,n){const c=N(e,t,s)+n;return $(e,c)}function X(e,t,s,n){const o=Math.sqrt(Math.pow(n.end.x-n.start.x,2)+Math.pow(n.end.y-n.start.y,2));let c=t+s;c=Math.min(c,o);const r=b(n,c);return{lineId:e,position:r,absoluteOffset:c}}function Q(e,t){return{...e,state:"idle"}}function R(e){return{vehicle:e,execution:null}}function Y(e,t){const s=[],n=new Map;for(const o of e){if(!t.get(o.lineId))continue;const r=Q(o);s.push(r);const i=R(r);n.set(o.id,i)}return{movingVehicles:s,stateMap:n}}function O(e,t){return{position:b(e,t),lineId:e.id,absoluteOffset:t}}function M(e,t){const s=F(e.arcLengthTable,t);return{position:w(e.bezier,s)}}function Z(e,t,s,n,o,c,r){const i=s.segments[t.currentSegmentIndex],l=t.segmentDistance+n;if(l>=i.length){const f=l-i.length,u=t.currentSegmentIndex+1;if(u>=s.segments.length){if(r!==void 0&&i.type==="line"){const a=o.get(i.lineId),m=i.startOffset+l;if(m<=r){const x=O(a,m);return{axleState:{...e,...x},execution:{...t,segmentDistance:l},completed:!1}}const L=O(a,r);return{axleState:{...e,...L},execution:{...t,segmentDistance:r-i.startOffset},completed:!0}}const v=i.type==="line"?O(o.get(i.lineId),i.endOffset):M(c.get(i.curveIndex),i.length);return{axleState:{...e,...v},execution:{...t,segmentDistance:i.length},completed:!0}}const g=s.segments[u],p=g.type==="line"?O(o.get(g.lineId),g.startOffset+f):M(c.get(g.curveIndex),f);return{axleState:{...e,...p},execution:{currentSegmentIndex:u,segmentDistance:f},completed:!1}}const d=i.type==="line"?O(o.get(i.lineId),i.startOffset+l):M(c.get(i.curveIndex),l);return{axleState:{...e,...d},execution:{...t,segmentDistance:l},completed:!1}}function ee(e,t,s,n){const o=new Map;for(const c of e.segments)if(c.type==="curve"&&c.curveIndex!==void 0){const r=t[c.curveIndex];if(r){const i=s.get(r.fromLineId),l=s.get(r.toLineId);if(i&&l){const d=S(i,r.fromOffset,r.fromIsPercentage,1,n.wheelbase),f=T(l,r.toOffset,r.toIsPercentage,0,n.wheelbase),u=C(i,l,n,!1,{fromOffset:d,fromIsPercentage:!1,toOffset:f,toIsPercentage:!1}),g=q(u);o.set(c.curveIndex,{bezier:u,arcLengthTable:g})}}}return o}function te(e,t,s){const{graph:n,linesMap:o,curves:c,config:r}=s,i=o.get(t.targetLineId);if(!i)return null;const d=G(i)-r.wheelbase;if(d<=0)return null;const f=t.isPercentage?t.targetOffset*d:Math.min(t.targetOffset,d),u=K(n,{lineId:e.rear.lineId,offset:e.rear.absoluteOffset},t.targetLineId,f,!1);if(!u)return null;const g=ee(u,c,o,r);return{path:u,curveDataMap:g}}function ne(e,t){const s=e.execution,n=t.vehicleQueues.get(e.vehicle.id),o=n?.[s.currentCommandIndex];if(o&&t.onCommandComplete&&t.onCommandComplete({vehicleId:e.vehicle.id,command:o,finalPosition:{lineId:e.vehicle.rear.lineId,absoluteOffset:e.vehicle.rear.absoluteOffset,position:e.vehicle.rear.position},payload:o.payload}),o?.awaitConfirmation)return{handled:!0,vehicle:{...e.vehicle,state:"waiting"},newExecution:s,isWaiting:!0};const c=s.currentCommandIndex+1;if(n&&c<n.length){const i=n[c],l=t.graphRef.current;if(l){const d={graph:l,linesMap:t.linesMap,curves:t.curves,config:t.config},f=t.prepareCommandPath(e.vehicle,i,d);if(f){const u=k(f.path,0,0,t.config.wheelbase);t.onCommandStart&&t.onCommandStart({vehicleId:e.vehicle.id,command:i,commandIndex:c,startPosition:{lineId:e.vehicle.rear.lineId,absoluteOffset:e.vehicle.rear.absoluteOffset,position:e.vehicle.rear.position}});const g={path:f.path,curveDataMap:f.curveDataMap,currentCommandIndex:c,rear:{currentSegmentIndex:0,segmentDistance:0},front:u?{currentSegmentIndex:u.segmentIndex,segmentDistance:u.segmentDistance}:{currentSegmentIndex:0,segmentDistance:0}};return{handled:!0,vehicle:{...e.vehicle,state:"moving"},newExecution:g}}}}return{handled:!0,vehicle:{...e.vehicle,state:"idle"},newExecution:null}}exports.arcLengthToSegmentPosition=$;exports.buildArcLengthTable=q;exports.buildGraph=U;exports.calculateBezierArcLength=j;exports.calculateFrontAxlePosition=k;exports.calculateInitialFrontPosition=X;exports.calculatePositionOnCurve=M;exports.calculatePositionOnLine=O;exports.calculateTangentLength=V;exports.createBezierCurve=C;exports.createInitialMovementState=R;exports.distance=I;exports.distanceToT=F;exports.findPath=K;exports.getArcLength=J;exports.getCumulativeArcLength=N;exports.getLineLength=G;exports.getPointOnBezier=w;exports.getPointOnLine=B;exports.getPointOnLineByOffset=D;exports.getPositionFromOffset=b;exports.handleArrival=ne;exports.initializeAllVehicles=Y;exports.initializeMovingVehicle=Q;exports.isPointNearPoint=H;exports.normalize=P;exports.prepareCommandPath=te;exports.resolveFromLineOffset=S;exports.resolveToLineOffset=T;exports.updateAxlePosition=Z;
|
package/dist/core.js
CHANGED
|
@@ -15,11 +15,11 @@ function T(e, t, o, n = !1, s) {
|
|
|
15
15
|
s?.fromOffset !== void 0 ? r = S(e, s.fromOffset, s.fromIsPercentage ?? !1) : r = e.end;
|
|
16
16
|
let l;
|
|
17
17
|
s?.toOffset !== void 0 ? l = S(t, s.toOffset, s.toIsPercentage ?? !1) : l = t.start;
|
|
18
|
-
const
|
|
18
|
+
const u = M(e.start, e.end), a = n ? {
|
|
19
19
|
// Transition with flip: kurva dimulai dari P (baseP0 - wheelbase in line direction)
|
|
20
|
-
x: r.x -
|
|
21
|
-
y: r.y -
|
|
22
|
-
} : r,
|
|
20
|
+
x: r.x - u.x * c,
|
|
21
|
+
y: r.y - u.y * c
|
|
22
|
+
} : r, d = M(e.start, e.end), g = M(t.start, t.end), p = v(a, l), I = F(i, p), f = n ? { x: a.x - d.x * I, y: a.y - d.y * I } : { x: a.x + d.x * I, y: a.y + d.y * I }, m = {
|
|
23
23
|
x: l.x - g.x * I,
|
|
24
24
|
y: l.y - g.y * I
|
|
25
25
|
};
|
|
@@ -37,10 +37,10 @@ function S(e, t, o) {
|
|
|
37
37
|
return o ? s = t : s = n > 0 ? t / n : 0, s = Math.max(0, Math.min(1, s)), K(e, s);
|
|
38
38
|
}
|
|
39
39
|
function D(e, t) {
|
|
40
|
-
const { p0: o, p1: n, p2: s, p3: c } = e, i = 1 - t, r = i * i, l = r * i,
|
|
40
|
+
const { p0: o, p1: n, p2: s, p3: c } = e, i = 1 - t, r = i * i, l = r * i, u = t * t, a = u * t;
|
|
41
41
|
return {
|
|
42
|
-
x: l * o.x + 3 * r * t * n.x + 3 * i *
|
|
43
|
-
y: l * o.y + 3 * r * t * n.y + 3 * i *
|
|
42
|
+
x: l * o.x + 3 * r * t * n.x + 3 * i * u * s.x + a * c.x,
|
|
43
|
+
y: l * o.y + 3 * r * t * n.y + 3 * i * u * s.y + a * c.y
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
function J(e, t, o = 10) {
|
|
@@ -66,8 +66,8 @@ function $(e, t) {
|
|
|
66
66
|
}
|
|
67
67
|
const c = e[n].distance, i = e[s].distance, r = e[n].t, l = e[s].t;
|
|
68
68
|
if (i === c) return r;
|
|
69
|
-
const
|
|
70
|
-
return r +
|
|
69
|
+
const u = (t - c) / (i - c);
|
|
70
|
+
return r + u * (l - r);
|
|
71
71
|
}
|
|
72
72
|
function U(e) {
|
|
73
73
|
return e[e.length - 1].distance;
|
|
@@ -89,8 +89,10 @@ function b(e, t, o, n, s) {
|
|
|
89
89
|
r = n;
|
|
90
90
|
else if (o)
|
|
91
91
|
r = t;
|
|
92
|
-
else
|
|
93
|
-
|
|
92
|
+
else {
|
|
93
|
+
const l = Math.max(0, Math.min(t, i));
|
|
94
|
+
return s + l;
|
|
95
|
+
}
|
|
94
96
|
return s + r * i;
|
|
95
97
|
}
|
|
96
98
|
function A(e, t, o, n, s) {
|
|
@@ -111,11 +113,11 @@ function X(e, t, o) {
|
|
|
111
113
|
for (const i of e)
|
|
112
114
|
s.set(i.id, i), c.set(i.id, v(i.start, i.end)), n.set(i.id, []);
|
|
113
115
|
for (let i = 0; i < t.length; i++) {
|
|
114
|
-
const r = t[i], l = s.get(r.fromLineId),
|
|
115
|
-
if (!l || !
|
|
116
|
-
const a = b(l, r.fromOffset, r.fromIsPercentage, 1, o.wheelbase),
|
|
116
|
+
const r = t[i], l = s.get(r.fromLineId), u = s.get(r.toLineId);
|
|
117
|
+
if (!l || !u) continue;
|
|
118
|
+
const a = b(l, r.fromOffset, r.fromIsPercentage, 1, o.wheelbase), d = A(u, r.toOffset, r.toIsPercentage, 0, o.wheelbase), g = T(
|
|
117
119
|
l,
|
|
118
|
-
|
|
120
|
+
u,
|
|
119
121
|
o,
|
|
120
122
|
!1,
|
|
121
123
|
// willFlip is always false now
|
|
@@ -123,7 +125,7 @@ function X(e, t, o) {
|
|
|
123
125
|
fromOffset: a,
|
|
124
126
|
fromIsPercentage: !1,
|
|
125
127
|
// Already resolved to absolute
|
|
126
|
-
toOffset:
|
|
128
|
+
toOffset: d,
|
|
127
129
|
toIsPercentage: !1
|
|
128
130
|
// Already resolved to absolute
|
|
129
131
|
}
|
|
@@ -132,7 +134,7 @@ function X(e, t, o) {
|
|
|
132
134
|
fromLineId: r.fromLineId,
|
|
133
135
|
toLineId: r.toLineId,
|
|
134
136
|
fromOffset: a,
|
|
135
|
-
toOffset:
|
|
137
|
+
toOffset: d,
|
|
136
138
|
curveLength: p
|
|
137
139
|
};
|
|
138
140
|
n.get(r.fromLineId).push(I);
|
|
@@ -142,7 +144,7 @@ function X(e, t, o) {
|
|
|
142
144
|
function G(e, t, o, n, s = !1) {
|
|
143
145
|
const { adjacency: c, lines: i, lineLengths: r } = e;
|
|
144
146
|
if (!i.get(o)) return null;
|
|
145
|
-
const
|
|
147
|
+
const u = r.get(o), a = s ? n / 100 * u : n, d = [], g = /* @__PURE__ */ new Map(), p = (f, m) => `${f}:${Math.round(m)}`;
|
|
146
148
|
if (t.lineId === o && a >= t.offset) {
|
|
147
149
|
const f = a - t.offset;
|
|
148
150
|
return {
|
|
@@ -172,15 +174,15 @@ function G(e, t, o, n, s = !1) {
|
|
|
172
174
|
endOffset: f.curveLength,
|
|
173
175
|
length: f.curveLength
|
|
174
176
|
};
|
|
175
|
-
|
|
177
|
+
d.push({
|
|
176
178
|
lineId: f.toLineId,
|
|
177
179
|
entryOffset: f.toOffset,
|
|
178
180
|
totalDistance: y,
|
|
179
181
|
path: [L, h]
|
|
180
182
|
});
|
|
181
183
|
}
|
|
182
|
-
for (
|
|
183
|
-
const f =
|
|
184
|
+
for (d.sort((f, m) => f.totalDistance - m.totalDistance); d.length > 0; ) {
|
|
185
|
+
const f = d.shift(), m = p(f.lineId, f.entryOffset), y = g.get(m);
|
|
184
186
|
if (y !== void 0 && y <= f.totalDistance)
|
|
185
187
|
continue;
|
|
186
188
|
if (g.set(m, f.totalDistance), f.lineId === o) {
|
|
@@ -218,14 +220,14 @@ function G(e, t, o, n, s = !1) {
|
|
|
218
220
|
endOffset: h.curveLength,
|
|
219
221
|
length: h.curveLength
|
|
220
222
|
};
|
|
221
|
-
|
|
223
|
+
d.push({
|
|
222
224
|
lineId: h.toLineId,
|
|
223
225
|
entryOffset: h.toOffset,
|
|
224
226
|
totalDistance: P,
|
|
225
227
|
path: [...f.path, z, B]
|
|
226
228
|
});
|
|
227
229
|
}
|
|
228
|
-
|
|
230
|
+
d.sort((h, x) => h.totalDistance - x.totalDistance);
|
|
229
231
|
}
|
|
230
232
|
return null;
|
|
231
233
|
}
|
|
@@ -324,8 +326,8 @@ function w(e, t) {
|
|
|
324
326
|
function ee(e, t, o, n, s, c, i) {
|
|
325
327
|
const r = o.segments[t.currentSegmentIndex], l = t.segmentDistance + n;
|
|
326
328
|
if (l >= r.length) {
|
|
327
|
-
const a = l - r.length,
|
|
328
|
-
if (
|
|
329
|
+
const a = l - r.length, d = t.currentSegmentIndex + 1;
|
|
330
|
+
if (d >= o.segments.length) {
|
|
329
331
|
if (i !== void 0 && r.type === "line") {
|
|
330
332
|
const f = s.get(r.lineId), m = r.startOffset + l;
|
|
331
333
|
if (m <= i) {
|
|
@@ -356,7 +358,7 @@ function ee(e, t, o, n, s, c, i) {
|
|
|
356
358
|
completed: !0
|
|
357
359
|
};
|
|
358
360
|
}
|
|
359
|
-
const g = o.segments[
|
|
361
|
+
const g = o.segments[d], p = g.type === "line" ? O(
|
|
360
362
|
s.get(g.lineId),
|
|
361
363
|
g.startOffset + a
|
|
362
364
|
) : w(
|
|
@@ -366,13 +368,13 @@ function ee(e, t, o, n, s, c, i) {
|
|
|
366
368
|
return {
|
|
367
369
|
axleState: { ...e, ...p },
|
|
368
370
|
execution: {
|
|
369
|
-
currentSegmentIndex:
|
|
371
|
+
currentSegmentIndex: d,
|
|
370
372
|
segmentDistance: a
|
|
371
373
|
},
|
|
372
374
|
completed: !1
|
|
373
375
|
};
|
|
374
376
|
}
|
|
375
|
-
const
|
|
377
|
+
const u = r.type === "line" ? O(
|
|
376
378
|
s.get(r.lineId),
|
|
377
379
|
r.startOffset + l
|
|
378
380
|
) : w(
|
|
@@ -380,7 +382,7 @@ function ee(e, t, o, n, s, c, i) {
|
|
|
380
382
|
l
|
|
381
383
|
);
|
|
382
384
|
return {
|
|
383
|
-
axleState: { ...e, ...
|
|
385
|
+
axleState: { ...e, ...u },
|
|
384
386
|
execution: { ...t, segmentDistance: l },
|
|
385
387
|
completed: !1
|
|
386
388
|
};
|
|
@@ -393,7 +395,7 @@ function H(e, t, o, n) {
|
|
|
393
395
|
if (i) {
|
|
394
396
|
const r = o.get(i.fromLineId), l = o.get(i.toLineId);
|
|
395
397
|
if (r && l) {
|
|
396
|
-
const
|
|
398
|
+
const u = b(
|
|
397
399
|
r,
|
|
398
400
|
i.fromOffset,
|
|
399
401
|
i.fromIsPercentage,
|
|
@@ -406,22 +408,22 @@ function H(e, t, o, n) {
|
|
|
406
408
|
i.toIsPercentage,
|
|
407
409
|
0,
|
|
408
410
|
n.wheelbase
|
|
409
|
-
),
|
|
411
|
+
), d = T(
|
|
410
412
|
r,
|
|
411
413
|
l,
|
|
412
414
|
n,
|
|
413
415
|
!1,
|
|
414
416
|
// willFlip is always false now
|
|
415
417
|
{
|
|
416
|
-
fromOffset:
|
|
418
|
+
fromOffset: u,
|
|
417
419
|
fromIsPercentage: !1,
|
|
418
420
|
// Already resolved to absolute
|
|
419
421
|
toOffset: a,
|
|
420
422
|
toIsPercentage: !1
|
|
421
423
|
// Already resolved to absolute
|
|
422
424
|
}
|
|
423
|
-
), g = j(
|
|
424
|
-
s.set(c.curveIndex, { bezier:
|
|
425
|
+
), g = j(d);
|
|
426
|
+
s.set(c.curveIndex, { bezier: d, arcLengthTable: g });
|
|
425
427
|
}
|
|
426
428
|
}
|
|
427
429
|
}
|
|
@@ -430,18 +432,18 @@ function H(e, t, o, n) {
|
|
|
430
432
|
function te(e, t, o) {
|
|
431
433
|
const { graph: n, linesMap: s, curves: c, config: i } = o, r = s.get(t.targetLineId);
|
|
432
434
|
if (!r) return null;
|
|
433
|
-
const
|
|
434
|
-
if (
|
|
435
|
-
const a = t.isPercentage ? t.targetOffset *
|
|
435
|
+
const u = N(r) - i.wheelbase;
|
|
436
|
+
if (u <= 0) return null;
|
|
437
|
+
const a = t.isPercentage ? t.targetOffset * u : Math.min(t.targetOffset, u), d = G(
|
|
436
438
|
n,
|
|
437
439
|
{ lineId: e.rear.lineId, offset: e.rear.absoluteOffset },
|
|
438
440
|
t.targetLineId,
|
|
439
441
|
a,
|
|
440
442
|
!1
|
|
441
443
|
);
|
|
442
|
-
if (!
|
|
443
|
-
const g = H(
|
|
444
|
-
return { path:
|
|
444
|
+
if (!d) return null;
|
|
445
|
+
const g = H(d, c, s, i);
|
|
446
|
+
return { path: d, curveDataMap: g };
|
|
445
447
|
}
|
|
446
448
|
function ne(e, t) {
|
|
447
449
|
const o = e.execution, n = t.vehicleQueues.get(e.vehicle.id), s = n?.[o.currentCommandIndex];
|
|
@@ -466,7 +468,7 @@ function ne(e, t) {
|
|
|
466
468
|
if (n && c < n.length) {
|
|
467
469
|
const r = n[c], l = t.graphRef.current;
|
|
468
470
|
if (l) {
|
|
469
|
-
const
|
|
471
|
+
const u = {
|
|
470
472
|
graph: l,
|
|
471
473
|
linesMap: t.linesMap,
|
|
472
474
|
curves: t.curves,
|
|
@@ -474,10 +476,10 @@ function ne(e, t) {
|
|
|
474
476
|
}, a = t.prepareCommandPath(
|
|
475
477
|
e.vehicle,
|
|
476
478
|
r,
|
|
477
|
-
|
|
479
|
+
u
|
|
478
480
|
);
|
|
479
481
|
if (a) {
|
|
480
|
-
const
|
|
482
|
+
const d = W(
|
|
481
483
|
a.path,
|
|
482
484
|
0,
|
|
483
485
|
0,
|
|
@@ -501,9 +503,9 @@ function ne(e, t) {
|
|
|
501
503
|
currentSegmentIndex: 0,
|
|
502
504
|
segmentDistance: 0
|
|
503
505
|
},
|
|
504
|
-
front:
|
|
505
|
-
currentSegmentIndex:
|
|
506
|
-
segmentDistance:
|
|
506
|
+
front: d ? {
|
|
507
|
+
currentSegmentIndex: d.segmentIndex,
|
|
508
|
+
segmentDistance: d.segmentDistance
|
|
507
509
|
} : {
|
|
508
510
|
currentSegmentIndex: 0,
|
|
509
511
|
segmentDistance: 0
|
package/package.json
CHANGED