@khr3/core 0.1.4 → 0.1.5
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/KhrVehicle.d.ts +5 -3
- package/dist/curves.d.ts +32 -11
- package/dist/curves.js +54 -28
- package/dist/index.js +150 -140
- package/dist/khrTypes.d.ts +4 -0
- package/dist/khrVehicleChassis.d.ts +9 -2
- package/dist/pacejka.d.ts +1 -1
- package/dist/vehicle.d.ts +1 -1
- package/dist/vehicle.js +131 -100
- package/package.json +1 -1
package/dist/KhrVehicle.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { type EcctrlVehicleHandle, type EcctrlVehicleProps
|
|
2
|
+
import { type EcctrlVehicleHandle, type EcctrlVehicleProps } from "@pinkaphant/ecctrl/vehicle";
|
|
3
3
|
import { type KhrAssetBundle, type KhrCarConfig, type KhrDroneConfig } from "./khrTypes.js";
|
|
4
|
+
import { type KhrPropellerConfig, type KhrPropellerConfigSelector, type KhrWheelConfig, type KhrWheelConfigSelector } from "./khrVehicleChassis.js";
|
|
4
5
|
export { solveWheelLoads, type SolvedWheel } from "./wheelLoads.js";
|
|
6
|
+
export type { KhrPropellerConfig, KhrPropellerConfigSelector, KhrWheelConfig, KhrWheelConfigSelector };
|
|
5
7
|
/** Default wheel + tire assembly density (kg/m^3) when `.glb` omits `ecctrlWheel.wheelDensity`. */
|
|
6
8
|
export declare const WHEEL_ASSEMBLY_DENSITY_KG_M3 = 220;
|
|
7
|
-
export type KhrWheelConfig = Partial<Omit<ShapeCastWheelProps, "ref" | "key" | "children">>;
|
|
8
|
-
export type KhrPropellerConfig = Partial<Omit<ThrustPropellerProps, "ref" | "key" | "children">>;
|
|
9
9
|
export interface KhrVehicleProps extends Omit<EcctrlVehicleProps, "ref" | "carConfig" | "droneConfig"> {
|
|
10
10
|
ref?: React.Ref<EcctrlVehicleHandle>;
|
|
11
11
|
bundle: KhrAssetBundle;
|
|
@@ -15,6 +15,8 @@ export interface KhrVehicleProps extends Omit<EcctrlVehicleProps, "ref" | "carCo
|
|
|
15
15
|
wheelConfig?: KhrWheelConfig;
|
|
16
16
|
frontWheelConfig?: KhrWheelConfig;
|
|
17
17
|
rearWheelConfig?: KhrWheelConfig;
|
|
18
|
+
wheelConfigs?: KhrWheelConfigSelector;
|
|
18
19
|
propellerConfig?: KhrPropellerConfig;
|
|
20
|
+
propellerConfigs?: KhrPropellerConfigSelector;
|
|
19
21
|
}
|
|
20
22
|
export declare function KhrVehicle({ scale, colliders, bundle, ...rest }: KhrVehicleProps): React.JSX.Element;
|
package/dist/curves.d.ts
CHANGED
|
@@ -97,13 +97,13 @@ export declare const ENGINE_TORQUE_CURVES: {
|
|
|
97
97
|
readonly x: 0.95;
|
|
98
98
|
readonly y: 0.962;
|
|
99
99
|
readonly r_in: -0.68;
|
|
100
|
-
readonly r_out: -
|
|
100
|
+
readonly r_out: -1.45;
|
|
101
101
|
readonly w_in: 1;
|
|
102
102
|
readonly w_out: 1;
|
|
103
103
|
}, {
|
|
104
104
|
readonly x: 1;
|
|
105
|
-
readonly y: 0
|
|
106
|
-
readonly r_in:
|
|
105
|
+
readonly y: 0;
|
|
106
|
+
readonly r_in: 0;
|
|
107
107
|
readonly w_in: 1;
|
|
108
108
|
}];
|
|
109
109
|
};
|
|
@@ -142,10 +142,17 @@ export declare const ENGINE_TORQUE_CURVES: {
|
|
|
142
142
|
readonly r_out: -0.66;
|
|
143
143
|
readonly w_in: 1;
|
|
144
144
|
readonly w_out: 1;
|
|
145
|
+
}, {
|
|
146
|
+
readonly x: 0.96;
|
|
147
|
+
readonly y: 0.86;
|
|
148
|
+
readonly r_in: -1.05;
|
|
149
|
+
readonly r_out: -1.45;
|
|
150
|
+
readonly w_in: 1;
|
|
151
|
+
readonly w_out: 1;
|
|
145
152
|
}, {
|
|
146
153
|
readonly x: 1;
|
|
147
|
-
readonly y: 0
|
|
148
|
-
readonly r_in:
|
|
154
|
+
readonly y: 0;
|
|
155
|
+
readonly r_in: 0;
|
|
149
156
|
readonly w_in: 1;
|
|
150
157
|
}];
|
|
151
158
|
};
|
|
@@ -184,10 +191,17 @@ export declare const ENGINE_TORQUE_CURVES: {
|
|
|
184
191
|
readonly r_out: -0.92;
|
|
185
192
|
readonly w_in: 1;
|
|
186
193
|
readonly w_out: 1;
|
|
194
|
+
}, {
|
|
195
|
+
readonly x: 0.94;
|
|
196
|
+
readonly y: 0.36;
|
|
197
|
+
readonly r_in: -1.02;
|
|
198
|
+
readonly r_out: -1.35;
|
|
199
|
+
readonly w_in: 1;
|
|
200
|
+
readonly w_out: 1;
|
|
187
201
|
}, {
|
|
188
202
|
readonly x: 1;
|
|
189
|
-
readonly y: 0
|
|
190
|
-
readonly r_in:
|
|
203
|
+
readonly y: 0;
|
|
204
|
+
readonly r_in: 0;
|
|
191
205
|
readonly w_in: 1;
|
|
192
206
|
}];
|
|
193
207
|
};
|
|
@@ -226,10 +240,17 @@ export declare const ENGINE_TORQUE_CURVES: {
|
|
|
226
240
|
readonly r_out: -0.4842;
|
|
227
241
|
readonly w_in: 1;
|
|
228
242
|
readonly w_out: 1;
|
|
243
|
+
}, {
|
|
244
|
+
readonly x: 0.95;
|
|
245
|
+
readonly y: 0.3368;
|
|
246
|
+
readonly r_in: -0.3408;
|
|
247
|
+
readonly r_out: -1.35;
|
|
248
|
+
readonly w_in: 1;
|
|
249
|
+
readonly w_out: 1;
|
|
229
250
|
}, {
|
|
230
251
|
readonly x: 1;
|
|
231
|
-
readonly y: 0
|
|
232
|
-
readonly r_in:
|
|
252
|
+
readonly y: 0;
|
|
253
|
+
readonly r_in: 0;
|
|
233
254
|
readonly w_in: 1;
|
|
234
255
|
}];
|
|
235
256
|
};
|
|
@@ -323,14 +344,14 @@ export declare const STEER_SPEED_CURVES: {
|
|
|
323
344
|
readonly x: 0.2;
|
|
324
345
|
readonly y: 0.28;
|
|
325
346
|
readonly r_in: -1.1;
|
|
326
|
-
readonly r_out: -
|
|
347
|
+
readonly r_out: -0.96;
|
|
327
348
|
readonly w_in: 1;
|
|
328
349
|
readonly w_out: 1;
|
|
329
350
|
}, {
|
|
330
351
|
readonly x: 0.5;
|
|
331
352
|
readonly y: 0.11;
|
|
332
353
|
readonly r_in: -0.25;
|
|
333
|
-
readonly r_out: -0.
|
|
354
|
+
readonly r_out: -0.2;
|
|
334
355
|
readonly w_in: 1;
|
|
335
356
|
readonly w_out: 1;
|
|
336
357
|
}, {
|
package/dist/curves.js
CHANGED
|
@@ -16,19 +16,21 @@ function t(t, n, r, i = 100, a = "lng") {
|
|
|
16
16
|
let f = Math.max(l(u), 1e-6), p = (e) => {
|
|
17
17
|
let i = t * o(e), a = i - r * (i - Math.atan(i)), c = Math.atan(a), l = Math.sin(n * c) / f, u = t * s(e) * (1 - r * i * i / (1 + i * i));
|
|
18
18
|
return [l, n * Math.cos(n * c) * u / ((1 + a * a) * f)];
|
|
19
|
-
}, m = 1 - u, h = [
|
|
19
|
+
}, m = 1 - u, h = Number(u.toFixed(3)), g = [
|
|
20
20
|
0,
|
|
21
21
|
Number((.32 * u).toFixed(3)),
|
|
22
|
-
Number((.68 * u).toFixed(3))
|
|
23
|
-
|
|
22
|
+
Number((.68 * u).toFixed(3))
|
|
23
|
+
].filter((e, t, n) => e < h - .01 && (t === 0 || e - n[t - 1] >= .01)), _ = [
|
|
24
24
|
Number((u + .06 * m).toFixed(3)),
|
|
25
25
|
Number((u + .18 * m).toFixed(3)),
|
|
26
|
-
Number((u + .48 * m).toFixed(3))
|
|
26
|
+
Number((u + .48 * m).toFixed(3))
|
|
27
|
+
].filter((e, t, n) => e > h + .01 && e < .99 && (t === 0 || e - n[t - 1] >= .01)), v = h >= .99 ? [...g, 1] : [
|
|
28
|
+
...g,
|
|
29
|
+
h,
|
|
30
|
+
..._,
|
|
27
31
|
1
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
let g = (e) => Number(Math.max(0, Math.min(1, e)).toFixed(4)), _ = Number(u.toFixed(3)), v = h.map((e) => {
|
|
31
|
-
if (Math.abs(e - _) < 1e-6) return {
|
|
32
|
+
], y = (e) => Number(Math.max(0, Math.min(1, e)).toFixed(4)), b = v.map((e) => {
|
|
33
|
+
if (Math.abs(e - h) < 1e-6) return {
|
|
32
34
|
x: e,
|
|
33
35
|
y: 1,
|
|
34
36
|
m: 0,
|
|
@@ -43,28 +45,28 @@ function t(t, n, r, i = 100, a = "lng") {
|
|
|
43
45
|
let [t, n] = p(e);
|
|
44
46
|
return {
|
|
45
47
|
x: e,
|
|
46
|
-
y:
|
|
48
|
+
y: y(t),
|
|
47
49
|
m: t <= 0 || t >= 1 ? 0 : n,
|
|
48
50
|
isPeak: !1
|
|
49
51
|
};
|
|
50
52
|
});
|
|
51
|
-
for (let e = 0; e <
|
|
52
|
-
let t = (
|
|
53
|
-
if (Math.abs(t) < 1e-9)
|
|
53
|
+
for (let e = 0; e < b.length - 1; e++) {
|
|
54
|
+
let t = (b[e + 1].y - b[e].y) / (b[e + 1].x - b[e].x);
|
|
55
|
+
if (Math.abs(t) < 1e-9) b[e].m = 0, b[e + 1].m = 0;
|
|
54
56
|
else for (let n of [e, e + 1]) {
|
|
55
|
-
let e =
|
|
56
|
-
e < 0 ?
|
|
57
|
+
let e = b[n].m / t;
|
|
58
|
+
e < 0 ? b[n].m = 0 : e > 2.85 && (b[n].m = 2.85 * t);
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
return {
|
|
60
|
-
points:
|
|
62
|
+
points: b.map((e, t) => {
|
|
61
63
|
let n = Number(Math.max(-1.54, Math.min(1.54, Math.atan(e.m))).toFixed(4));
|
|
62
64
|
return t === 0 ? {
|
|
63
65
|
x: 0,
|
|
64
66
|
y: 0,
|
|
65
67
|
r_out: n,
|
|
66
68
|
w_out: 1
|
|
67
|
-
} : t ===
|
|
69
|
+
} : t === b.length - 1 ? {
|
|
68
70
|
x: 1,
|
|
69
71
|
y: e.y,
|
|
70
72
|
r_in: n,
|
|
@@ -89,7 +91,7 @@ function t(t, n, r, i = 100, a = "lng") {
|
|
|
89
91
|
};
|
|
90
92
|
}
|
|
91
93
|
function n(e, t = .5) {
|
|
92
|
-
return Number((2 * e - t).toFixed(4));
|
|
94
|
+
return Number(Math.max(0, 2 * e - t).toFixed(4));
|
|
93
95
|
}
|
|
94
96
|
function r(e, t) {
|
|
95
97
|
return Number((e * t / 7022).toFixed(1));
|
|
@@ -186,14 +188,14 @@ var i = {
|
|
|
186
188
|
x: .95,
|
|
187
189
|
y: .962,
|
|
188
190
|
r_in: -.68,
|
|
189
|
-
r_out:
|
|
191
|
+
r_out: -1.45,
|
|
190
192
|
w_in: 1,
|
|
191
193
|
w_out: 1
|
|
192
194
|
},
|
|
193
195
|
{
|
|
194
196
|
x: 1,
|
|
195
|
-
y:
|
|
196
|
-
r_in:
|
|
197
|
+
y: 0,
|
|
198
|
+
r_in: 0,
|
|
197
199
|
w_in: 1
|
|
198
200
|
}
|
|
199
201
|
]
|
|
@@ -239,10 +241,18 @@ var i = {
|
|
|
239
241
|
w_in: 1,
|
|
240
242
|
w_out: 1
|
|
241
243
|
},
|
|
244
|
+
{
|
|
245
|
+
x: .96,
|
|
246
|
+
y: .86,
|
|
247
|
+
r_in: -1.05,
|
|
248
|
+
r_out: -1.45,
|
|
249
|
+
w_in: 1,
|
|
250
|
+
w_out: 1
|
|
251
|
+
},
|
|
242
252
|
{
|
|
243
253
|
x: 1,
|
|
244
|
-
y:
|
|
245
|
-
r_in:
|
|
254
|
+
y: 0,
|
|
255
|
+
r_in: 0,
|
|
246
256
|
w_in: 1
|
|
247
257
|
}
|
|
248
258
|
]
|
|
@@ -288,10 +298,18 @@ var i = {
|
|
|
288
298
|
w_in: 1,
|
|
289
299
|
w_out: 1
|
|
290
300
|
},
|
|
301
|
+
{
|
|
302
|
+
x: .94,
|
|
303
|
+
y: .36,
|
|
304
|
+
r_in: -1.02,
|
|
305
|
+
r_out: -1.35,
|
|
306
|
+
w_in: 1,
|
|
307
|
+
w_out: 1
|
|
308
|
+
},
|
|
291
309
|
{
|
|
292
310
|
x: 1,
|
|
293
|
-
y:
|
|
294
|
-
r_in:
|
|
311
|
+
y: 0,
|
|
312
|
+
r_in: 0,
|
|
295
313
|
w_in: 1
|
|
296
314
|
}
|
|
297
315
|
]
|
|
@@ -337,10 +355,18 @@ var i = {
|
|
|
337
355
|
w_in: 1,
|
|
338
356
|
w_out: 1
|
|
339
357
|
},
|
|
358
|
+
{
|
|
359
|
+
x: .95,
|
|
360
|
+
y: .3368,
|
|
361
|
+
r_in: -.3408,
|
|
362
|
+
r_out: -1.35,
|
|
363
|
+
w_in: 1,
|
|
364
|
+
w_out: 1
|
|
365
|
+
},
|
|
340
366
|
{
|
|
341
367
|
x: 1,
|
|
342
|
-
y:
|
|
343
|
-
r_in:
|
|
368
|
+
y: 0,
|
|
369
|
+
r_in: 0,
|
|
344
370
|
w_in: 1
|
|
345
371
|
}
|
|
346
372
|
]
|
|
@@ -449,7 +475,7 @@ var i = {
|
|
|
449
475
|
x: .2,
|
|
450
476
|
y: .28,
|
|
451
477
|
r_in: -1.1,
|
|
452
|
-
r_out:
|
|
478
|
+
r_out: -.96,
|
|
453
479
|
w_in: 1,
|
|
454
480
|
w_out: 1
|
|
455
481
|
},
|
|
@@ -457,7 +483,7 @@ var i = {
|
|
|
457
483
|
x: .5,
|
|
458
484
|
y: .11,
|
|
459
485
|
r_in: -.25,
|
|
460
|
-
r_out: -.
|
|
486
|
+
r_out: -.2,
|
|
461
487
|
w_in: 1,
|
|
462
488
|
w_out: 1
|
|
463
489
|
},
|