@adatechnology/game-vehicles 0.3.0 → 0.4.1
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 +6 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.global.js +337 -105
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +286 -60
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -64,6 +64,9 @@ scene.remove(c.root); kit.dispose(c)
|
|
|
64
64
|
const hurt = kit.build('meteor', 'intact', state)
|
|
65
65
|
scene.add(hurt.root)
|
|
66
66
|
|
|
67
|
+
// ...or name a registered scenario and build it in one call (explicit health / flags given alongside win)
|
|
68
|
+
const wreck = kit.build('meteor', 'intact', { scenario: 'burnt' })
|
|
69
|
+
|
|
67
70
|
// 4. animate (particles, fluids, hood, rollover, explosions)
|
|
68
71
|
kit.tick(hurt, dt)
|
|
69
72
|
```
|
|
@@ -89,7 +92,7 @@ and a band decided by the health:
|
|
|
89
92
|
| 3 | `destroyed` | 1 to 25 | Heavy deformation, parts fall off |
|
|
90
93
|
| 4 | `torn_off` | 0 | The part is gone |
|
|
91
94
|
|
|
92
|
-
Bands only change the look when the band changes; `kit.build(key, state, zoneState)` rebuilds the vehicle and reapplies every zone.
|
|
95
|
+
Bands only change the look when the band changes; `kit.build(key, state, zoneState)` rebuilds the vehicle and reapplies every zone. `zoneState` may also carry `scenario: 'id or name'`: the scenario is computed on the vehicle being built (no probe build) and any `health` / `flags` given with it are merged on top. An unknown scenario damages nothing, like `zoneScenario`.
|
|
93
96
|
|
|
94
97
|
**Content packs.** A pack is a plugin: `{ name, configure, install(kit) }`. `configure` accepts everything in the configuration table below and
|
|
95
98
|
`install` can call `kit.register(...)`, `kit.scenario(...)`, `kit.defineFluid(...)`, `kit.on(...)` and so on. The engine never imports a pack.
|
|
@@ -139,7 +142,7 @@ created with, so `kit.t('mypack.some.key')` reads from it, with English as the f
|
|
|
139
142
|
| Area | Methods |
|
|
140
143
|
|---|---|
|
|
141
144
|
| Registry | `register(spec, build)`, `find(key)`, `fleet`, `configure`, `plugin`, `on`/`hook`, `scenario`, `defineFluid` |
|
|
142
|
-
| Lifecycle | `build(key, state?, zoneState?)
|
|
145
|
+
| Lifecycle | `build(key, state?, zoneState?)` (`zoneState.scenario` runs a scenario), `dispose(c)`, `tick(c, dt)`, `settle(c, seconds)`, `defaultDamage(c)` |
|
|
143
146
|
| Zones | `bandOf(health)`, `zonesOf(c)`, `applyZones(c, state)`, `zoneScenario(c, id)`, `zoneOverall(c)`, `zoneAt(c, point)`, `zoneDamageAt(c, point, dir, force)`, `zonePoint(c, zone)`, `zoneEffect(zone, health?)`, `zoneOwner` |
|
|
144
147
|
| Events | `impact(c, point, dir, force, options?)`, `zoneImpact(c, side, force)` (side: `front`, `rear`, `left`, `right` or `rolled`), `explode(c, options?)`, `blastDamage(c, amount)`, `roll(c, side?)`, `setHood(c, open)` |
|
|
145
148
|
| Fluids and particles | `splat`, `puddle`, `wipe(c, mode)` (`wiper` or `rain`), `spawn`, `burst`, `addEmitter` |
|
|
@@ -175,6 +178,7 @@ kit.scenario({
|
|
|
175
178
|
})
|
|
176
179
|
const result = kit.zoneScenario(c, 'front') // { health, flags, scenario }
|
|
177
180
|
const hurt = kit.build('meteor', 'intact', result)
|
|
181
|
+
const same = kit.build('meteor', 'intact', { scenario: 'front' }) // the two steps in one call
|
|
178
182
|
```
|
|
179
183
|
|
|
180
184
|
`x` has `c`, `meta`, `front`, `rear`, `length`, `width`, `clearance`, `top`, `rand()`, `set(zone, health)`, `flags`, `health`, `center` (of the zone
|
package/dist/index.d.ts
CHANGED
|
@@ -337,6 +337,8 @@ interface VehicleContext {
|
|
|
337
337
|
meta: VehicleMeta;
|
|
338
338
|
zones: DamageZone[];
|
|
339
339
|
zoneState: ZoneState;
|
|
340
|
+
/** The scenario the vehicle was built in (`kit.build(key, state, { scenario })`), so a rebuild keeps it. */
|
|
341
|
+
scenario?: string;
|
|
340
342
|
/** Deterministic random generator seeded from the vehicle key and state. */
|
|
341
343
|
rand: () => number;
|
|
342
344
|
parts: VehiclePart[];
|
|
@@ -418,6 +420,11 @@ interface ZoneState {
|
|
|
418
420
|
health: Record<string, number>;
|
|
419
421
|
flags: Record<string, boolean>;
|
|
420
422
|
}
|
|
423
|
+
/** The zone-state argument of `kit.build`: a `ZoneState` plus an optional scenario to compute on the vehicle being built. */
|
|
424
|
+
interface BuildZoneState extends Partial<ZoneState> {
|
|
425
|
+
/** Id or name of a registered scenario (e.g. the fleet's `burnt`); explicit `health` / `flags` override its result. */
|
|
426
|
+
scenario?: string;
|
|
427
|
+
}
|
|
421
428
|
interface ScenarioResult {
|
|
422
429
|
health: Record<string, number>;
|
|
423
430
|
flags: Record<string, boolean>;
|
|
@@ -662,7 +669,7 @@ interface VehicleKit {
|
|
|
662
669
|
defineFluid(key: string, def: FluidDefinition): FluidDefinition;
|
|
663
670
|
on(event: string, fn: (...args: any[]) => void): VehicleKit;
|
|
664
671
|
hook(event: string, ...args: any[]): void;
|
|
665
|
-
build(key: string, state?: BuildState, zoneState?:
|
|
672
|
+
build(key: string, state?: BuildState, zoneState?: BuildZoneState, options?: BuildOptions): VehicleContext;
|
|
666
673
|
/** The damageable parts of a built vehicle as boxes (optionally in the frame of `matrix`). */
|
|
667
674
|
damageables(c: VehicleContext, matrix?: ThreeObject): Damageable[];
|
|
668
675
|
dispose(c: VehicleContext): void;
|
|
@@ -894,6 +901,8 @@ interface VehicleItemOptions {
|
|
|
894
901
|
state?: BuildState;
|
|
895
902
|
/** Build in the light mode of the kit (`kit.lod`): fewer segments and no interior, for crowds and for budgets. Default off. */
|
|
896
903
|
lod?: boolean;
|
|
904
|
+
/** A registered damage scenario (id or name, e.g. the fleet's `burnt`) built into the vehicle, through `kit.build(key, state, { scenario })`. */
|
|
905
|
+
scenario?: string;
|
|
897
906
|
}
|
|
898
907
|
interface VehicleItem {
|
|
899
908
|
/** Add this to the scene: origin at the centre of the footprint on the floor, front facing +z. */
|
|
@@ -908,4 +917,4 @@ interface VehicleItem {
|
|
|
908
917
|
*/
|
|
909
918
|
declare function buildVehicleItem(kit: VehicleKit, key: string, options?: VehicleItemOptions): VehicleItem;
|
|
910
919
|
|
|
911
|
-
export { type Band, type BandId, type BandIndex, type BandOverride, type BuildFunction, type BuildOptions, type BuildState, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type ExplodeOptions, type FlagEffect, type FluidDefinition, type ImpactOptions, JOINT_RULES, type JointDef, type KitConfiguration, type KitInternals, type KitTexts, LEGACY_STATES, LEGACY_ZONE_IDS, type LocalBox, type LocaleStrings, type LodSettings, type OverallHealth, type PartDef, type PartLabel, type PartRole, type PartialLocaleStrings, type Plugin, type ResolvedConfiguration, SEED_SALTS, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SplatOptions, type ThreeObject, type ThreeVector, type Translate, type UiHelpers, type VehicleContext, type VehicleDestructible, type VehicleDestructibleOptions, type VehicleItem, type VehicleItemOptions, type VehicleKit, type VehicleKitOptions, type VehicleMeta, type VehicleModel, type VehiclePart, type VehicleSpec, type VehicleStatus, type ZoneDamageEntry, type ZoneEffect, type ZoneState, buildVehicleItem, buildVehicleModel, clamp, createLod, createTranslate, createVehicleDestructible, createVehicleKit, defaultDamageableKinds, defaultLodSettings, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, registerLegacySeeds, registerLocale, resolveStrings, rng, smooth, strHash, wrapThreeForLod };
|
|
920
|
+
export { type Band, type BandId, type BandIndex, type BandOverride, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type ExplodeOptions, type FlagEffect, type FluidDefinition, type ImpactOptions, JOINT_RULES, type JointDef, type KitConfiguration, type KitInternals, type KitTexts, LEGACY_STATES, LEGACY_ZONE_IDS, type LocalBox, type LocaleStrings, type LodSettings, type OverallHealth, type PartDef, type PartLabel, type PartRole, type PartialLocaleStrings, type Plugin, type ResolvedConfiguration, SEED_SALTS, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SplatOptions, type ThreeObject, type ThreeVector, type Translate, type UiHelpers, type VehicleContext, type VehicleDestructible, type VehicleDestructibleOptions, type VehicleItem, type VehicleItemOptions, type VehicleKit, type VehicleKitOptions, type VehicleMeta, type VehicleModel, type VehiclePart, type VehicleSpec, type VehicleStatus, type ZoneDamageEntry, type ZoneEffect, type ZoneState, buildVehicleItem, buildVehicleModel, clamp, createLod, createTranslate, createVehicleDestructible, createVehicleKit, defaultDamageableKinds, defaultLodSettings, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, registerLegacySeeds, registerLocale, resolveStrings, rng, smooth, strHash, wrapThreeForLod };
|
package/dist/index.global.js
CHANGED
|
@@ -2501,46 +2501,79 @@ var GameVehicles = (() => {
|
|
|
2501
2501
|
}
|
|
2502
2502
|
const p = geo.attributes.position;
|
|
2503
2503
|
const n = p.count;
|
|
2504
|
-
const
|
|
2505
|
-
const
|
|
2506
|
-
const
|
|
2507
|
-
const
|
|
2508
|
-
const C = new V3();
|
|
2509
|
-
const e1 = new V3();
|
|
2510
|
-
const e2 = new V3();
|
|
2504
|
+
const faces = n / 3;
|
|
2505
|
+
const FN = new Float64Array(faces * 3);
|
|
2506
|
+
const map = /* @__PURE__ */ new Map();
|
|
2507
|
+
const RANGE = 65536;
|
|
2511
2508
|
function key(i) {
|
|
2512
|
-
|
|
2509
|
+
const x = Math.round(p.getX(i) * 2e3);
|
|
2510
|
+
const y = Math.round(p.getY(i) * 2e3);
|
|
2511
|
+
const z = Math.round(p.getZ(i) * 2e3);
|
|
2512
|
+
if (Math.abs(x) < RANGE && Math.abs(y) < RANGE && Math.abs(z) < RANGE) return ((x + RANGE) * 131072 + (y + RANGE)) * 131072 + (z + RANGE);
|
|
2513
|
+
return x + "," + y + "," + z;
|
|
2513
2514
|
}
|
|
2514
2515
|
const keys = new Array(n);
|
|
2515
|
-
for (let f = 0; f <
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
const
|
|
2520
|
-
|
|
2521
|
-
|
|
2516
|
+
for (let f = 0; f < faces; f++) {
|
|
2517
|
+
const ax = p.getX(3 * f);
|
|
2518
|
+
const ay = p.getY(3 * f);
|
|
2519
|
+
const az = p.getZ(3 * f);
|
|
2520
|
+
const bx = p.getX(3 * f + 1);
|
|
2521
|
+
const by = p.getY(3 * f + 1);
|
|
2522
|
+
const bz = p.getZ(3 * f + 1);
|
|
2523
|
+
const cx = p.getX(3 * f + 2);
|
|
2524
|
+
const cy = p.getY(3 * f + 2);
|
|
2525
|
+
const cz = p.getZ(3 * f + 2);
|
|
2526
|
+
const e1x = cx - bx;
|
|
2527
|
+
const e1y = cy - by;
|
|
2528
|
+
const e1z = cz - bz;
|
|
2529
|
+
const e2x = ax - bx;
|
|
2530
|
+
const e2y = ay - by;
|
|
2531
|
+
const e2z = az - bz;
|
|
2532
|
+
let nx = e1y * e2z - e1z * e2y;
|
|
2533
|
+
let ny = e1z * e2x - e1x * e2z;
|
|
2534
|
+
let nz = e1x * e2y - e1y * e2x;
|
|
2535
|
+
if (nx * nx + ny * ny + nz * nz > 1e-20) {
|
|
2536
|
+
const inv = 1 / (Math.sqrt(nx * nx + ny * ny + nz * nz) || 1);
|
|
2537
|
+
nx *= inv;
|
|
2538
|
+
ny *= inv;
|
|
2539
|
+
nz *= inv;
|
|
2540
|
+
}
|
|
2541
|
+
FN[3 * f] = nx;
|
|
2542
|
+
FN[3 * f + 1] = ny;
|
|
2543
|
+
FN[3 * f + 2] = nz;
|
|
2522
2544
|
for (let k = 0; k < 3; k++) {
|
|
2523
2545
|
const kk = key(3 * f + k);
|
|
2524
2546
|
keys[3 * f + k] = kk;
|
|
2525
|
-
|
|
2547
|
+
const list2 = map.get(kk);
|
|
2548
|
+
if (list2) list2.push(f);
|
|
2549
|
+
else map.set(kk, [f]);
|
|
2526
2550
|
}
|
|
2527
2551
|
}
|
|
2528
2552
|
const cs = Math.cos(deg * PI / 180);
|
|
2529
2553
|
const out = new Float32Array(n * 3);
|
|
2530
|
-
const s = new V3();
|
|
2531
2554
|
for (let i = 0; i < n; i++) {
|
|
2532
|
-
const fi = i / 3 | 0;
|
|
2533
|
-
const list2 = map
|
|
2534
|
-
|
|
2555
|
+
const fi = (i / 3 | 0) * 3;
|
|
2556
|
+
const list2 = map.get(keys[i]);
|
|
2557
|
+
let sx = 0;
|
|
2558
|
+
let sy = 0;
|
|
2559
|
+
let sz = 0;
|
|
2535
2560
|
for (let j = 0; j < list2.length; j++) {
|
|
2536
|
-
const g =
|
|
2537
|
-
if (g
|
|
2561
|
+
const g = list2[j] * 3;
|
|
2562
|
+
if (FN[g] * FN[fi] + FN[g + 1] * FN[fi + 1] + FN[g + 2] * FN[fi + 2] >= cs) {
|
|
2563
|
+
sx += FN[g];
|
|
2564
|
+
sy += FN[g + 1];
|
|
2565
|
+
sz += FN[g + 2];
|
|
2566
|
+
}
|
|
2538
2567
|
}
|
|
2539
|
-
if (
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2568
|
+
if (sx * sx + sy * sy + sz * sz < 1e-20) {
|
|
2569
|
+
sx = FN[fi];
|
|
2570
|
+
sy = FN[fi + 1];
|
|
2571
|
+
sz = FN[fi + 2];
|
|
2572
|
+
}
|
|
2573
|
+
const inv = 1 / (Math.sqrt(sx * sx + sy * sy + sz * sz) || 1);
|
|
2574
|
+
out[3 * i] = sx * inv;
|
|
2575
|
+
out[3 * i + 1] = sy * inv;
|
|
2576
|
+
out[3 * i + 2] = sz * inv;
|
|
2544
2577
|
}
|
|
2545
2578
|
geo.setAttribute("normal", new THREE.BufferAttribute(out, 3));
|
|
2546
2579
|
geo.userData.crease = true;
|
|
@@ -2924,6 +2957,58 @@ var GameVehicles = (() => {
|
|
|
2924
2957
|
Object.assign(I, { roundedBoxGeometry, taper, subdivide, crease, pathShape, tumble, loftGeometry, hullGeometry, cutGeometry, mergeGeometries, uvProject });
|
|
2925
2958
|
}
|
|
2926
2959
|
|
|
2960
|
+
// ../game-contracts/dist/index.js
|
|
2961
|
+
var DEFAULT_IGNITION_RULES = {
|
|
2962
|
+
fillCurve: [
|
|
2963
|
+
[0, 0.6],
|
|
2964
|
+
[0.1, 1],
|
|
2965
|
+
[0.35, 0.6],
|
|
2966
|
+
[0.65, 0.3],
|
|
2967
|
+
[0.9, 0.15],
|
|
2968
|
+
[1, 0.12]
|
|
2969
|
+
],
|
|
2970
|
+
flameFillInfluence: 0.5,
|
|
2971
|
+
flameDefaults: { incendiary: 0.7, tracer: 0.2 },
|
|
2972
|
+
sparkTarget: { steel: 1, iron: 1, aluminium: 0.25 },
|
|
2973
|
+
sparkMetalDefault: 0.5,
|
|
2974
|
+
sparkFluid: { diesel: 0.15 },
|
|
2975
|
+
fireNear: { radius: 1.5, chancePerSecond: 0.5 }
|
|
2976
|
+
};
|
|
2977
|
+
var resolveIgnitionRules = (rules) => ({
|
|
2978
|
+
...DEFAULT_IGNITION_RULES,
|
|
2979
|
+
...rules,
|
|
2980
|
+
flameDefaults: { ...DEFAULT_IGNITION_RULES.flameDefaults, ...rules?.flameDefaults },
|
|
2981
|
+
sparkTarget: { ...DEFAULT_IGNITION_RULES.sparkTarget, ...rules?.sparkTarget },
|
|
2982
|
+
sparkFluid: { ...DEFAULT_IGNITION_RULES.sparkFluid, ...rules?.sparkFluid },
|
|
2983
|
+
fireNear: { ...DEFAULT_IGNITION_RULES.fireNear, ...rules?.fireNear }
|
|
2984
|
+
});
|
|
2985
|
+
var fillFactor = (fill, curve = DEFAULT_IGNITION_RULES.fillCurve) => {
|
|
2986
|
+
if (curve.length === 0) return 1;
|
|
2987
|
+
const f = Math.min(1, Math.max(0, fill));
|
|
2988
|
+
if (f <= curve[0][0]) return curve[0][1];
|
|
2989
|
+
for (let i = 1; i < curve.length; i++) {
|
|
2990
|
+
const [x1, y1] = curve[i];
|
|
2991
|
+
const [x0, y0] = curve[i - 1];
|
|
2992
|
+
if (f <= x1) return x1 === x0 ? y1 : y0 + (y1 - y0) * (f - x0) / (x1 - x0);
|
|
2993
|
+
}
|
|
2994
|
+
return curve[curve.length - 1][1];
|
|
2995
|
+
};
|
|
2996
|
+
var sparkTargetFactor = (materialId, metal, rules = DEFAULT_IGNITION_RULES) => !metal ? 0 : rules.sparkTarget[materialId] ?? rules.sparkMetalDefault;
|
|
2997
|
+
var ignitionChance = (hit, target, rules = DEFAULT_IGNITION_RULES) => {
|
|
2998
|
+
const k = fillFactor(target.fill, rules.fillCurve);
|
|
2999
|
+
const spark = (hit.ignition?.spark ?? 0) * target.sparkTarget * (target.fluid === void 0 ? 1 : rules.sparkFluid[target.fluid] ?? 1) * k;
|
|
3000
|
+
const flameBase = hit.ignition?.flame ?? Math.max(hit.incendiary ? rules.flameDefaults.incendiary : 0, hit.tracer ? rules.flameDefaults.tracer : 0);
|
|
3001
|
+
const flame = flameBase * (1 - rules.flameFillInfluence * (1 - k));
|
|
3002
|
+
return 1 - (1 - Math.min(1, Math.max(0, spark))) * (1 - Math.min(1, Math.max(0, flame)));
|
|
3003
|
+
};
|
|
3004
|
+
var KIT_ORIGIN_KEY = "kitOrigin";
|
|
3005
|
+
function markKitOrigin(object2, origin) {
|
|
3006
|
+
const node = object2;
|
|
3007
|
+
node.userData = node.userData ?? {};
|
|
3008
|
+
node.userData[KIT_ORIGIN_KEY] = { ...origin };
|
|
3009
|
+
return object2;
|
|
3010
|
+
}
|
|
3011
|
+
|
|
2927
3012
|
// src/context.ts
|
|
2928
3013
|
function installContext(kit) {
|
|
2929
3014
|
const THREE = kit.THREE;
|
|
@@ -2944,6 +3029,7 @@ var GameVehicles = (() => {
|
|
|
2944
3029
|
this.effects = new THREE.Group();
|
|
2945
3030
|
this.root.add(this.vehicle);
|
|
2946
3031
|
this.root.add(this.effects);
|
|
3032
|
+
markKitOrigin(this.root, { owner: "game-vehicles", kind: "vehicle" });
|
|
2947
3033
|
this.state = state;
|
|
2948
3034
|
this.glass = [];
|
|
2949
3035
|
this.quads = [];
|
|
@@ -8198,6 +8284,153 @@ var GameVehicles = (() => {
|
|
|
8198
8284
|
return hole;
|
|
8199
8285
|
}
|
|
8200
8286
|
const _zr = new THREE.Raycaster();
|
|
8287
|
+
const PROXY_MIN_TRIANGLES = 500;
|
|
8288
|
+
const STROKE_REACH = 0.6;
|
|
8289
|
+
const _pv = new V3();
|
|
8290
|
+
const _pm = new THREE.Matrix4();
|
|
8291
|
+
function decalRegion(c, z) {
|
|
8292
|
+
const B = z.box;
|
|
8293
|
+
const lo = [0, 1, 2].map(function(k) {
|
|
8294
|
+
return I.boxLo(B, k) - STROKE_REACH;
|
|
8295
|
+
});
|
|
8296
|
+
const hi = [0, 1, 2].map(function(k) {
|
|
8297
|
+
return I.boxHi(B, k) + STROKE_REACH;
|
|
8298
|
+
});
|
|
8299
|
+
const a = axisOf(z.dir);
|
|
8300
|
+
const dn = z.dir.clone().normalize();
|
|
8301
|
+
const sg = z.dir.getComponent(a) > 0 ? 1 : -1;
|
|
8302
|
+
const outer = sg > 0 ? I.boxLo(B, a) - 0.6 : I.boxHi(B, a) + 0.6;
|
|
8303
|
+
const far = 0.6 + (I.boxHi(B, a) - I.boxLo(B, a)) + 0.05;
|
|
8304
|
+
for (let i = 0; i < 8; i++) {
|
|
8305
|
+
const p = new V3();
|
|
8306
|
+
p.setComponent(a, outer);
|
|
8307
|
+
[0, 1, 2].filter(function(k) {
|
|
8308
|
+
return k !== a;
|
|
8309
|
+
}).forEach(function(k, j) {
|
|
8310
|
+
p.setComponent(k, i >> j & 1 ? I.boxHi(B, k) : I.boxLo(B, k));
|
|
8311
|
+
});
|
|
8312
|
+
for (let e = 0; e < 2; e++) {
|
|
8313
|
+
const q = e ? p.clone().addScaledVector(dn, far) : p;
|
|
8314
|
+
for (let k = 0; k < 3; k++) {
|
|
8315
|
+
lo[k] = Math.min(lo[k], q.getComponent(k) - 0.05);
|
|
8316
|
+
hi[k] = Math.max(hi[k], q.getComponent(k) + 0.05);
|
|
8317
|
+
}
|
|
8318
|
+
}
|
|
8319
|
+
}
|
|
8320
|
+
return { lo, hi };
|
|
8321
|
+
}
|
|
8322
|
+
function regionCands(c, z, cands) {
|
|
8323
|
+
if (!cands.some(heavy)) return cands;
|
|
8324
|
+
const R = decalRegion(c, z);
|
|
8325
|
+
const Mw = c.vehicle.matrixWorld;
|
|
8326
|
+
return cands.map(function(o) {
|
|
8327
|
+
if (!heavy(o)) return o;
|
|
8328
|
+
if (!o.geometry.boundingSphere) o.geometry.computeBoundingSphere();
|
|
8329
|
+
if (!o.geometry.boundingBox) o.geometry.computeBoundingBox();
|
|
8330
|
+
return proxyIn(o, Mw, R);
|
|
8331
|
+
});
|
|
8332
|
+
}
|
|
8333
|
+
function heavy(o) {
|
|
8334
|
+
const g = o.geometry;
|
|
8335
|
+
const pos = g && g.attributes && g.attributes.position;
|
|
8336
|
+
return o.raycast === THREE.Mesh.prototype.raycast && !o.isSkinnedMesh && !Array.isArray(o.material) && pos && !pos.isInterleavedBufferAttribute && pos.itemSize === 3 && !g.groups.length && !(g.morphAttributes && g.morphAttributes.position) && (g.index ? g.index.count : pos.count) / 3 >= PROXY_MIN_TRIANGLES;
|
|
8337
|
+
}
|
|
8338
|
+
function proxyIn(o, Mw, R) {
|
|
8339
|
+
_pm.copy(o.matrixWorld).invert().multiply(Mw);
|
|
8340
|
+
const lo = [Infinity, Infinity, Infinity];
|
|
8341
|
+
const hi = [-Infinity, -Infinity, -Infinity];
|
|
8342
|
+
for (let i = 0; i < 8; i++) {
|
|
8343
|
+
_pv.set(i & 1 ? R.hi[0] : R.lo[0], i & 2 ? R.hi[1] : R.lo[1], i & 4 ? R.hi[2] : R.lo[2]).applyMatrix4(_pm);
|
|
8344
|
+
for (let k = 0; k < 3; k++) {
|
|
8345
|
+
lo[k] = Math.min(lo[k], _pv.getComponent(k));
|
|
8346
|
+
hi[k] = Math.max(hi[k], _pv.getComponent(k));
|
|
8347
|
+
}
|
|
8348
|
+
}
|
|
8349
|
+
const g = o.geometry;
|
|
8350
|
+
const P = g.attributes.position.array;
|
|
8351
|
+
const ix = g.index ? g.index.array : null;
|
|
8352
|
+
const n = ix ? ix.length : P.length / 3;
|
|
8353
|
+
const keep = new Uint32Array(n - n % 3);
|
|
8354
|
+
let nk = 0;
|
|
8355
|
+
for (let t = 0; t + 2 < n; t += 3) {
|
|
8356
|
+
const a = (ix ? ix[t] : t) * 3;
|
|
8357
|
+
const b = (ix ? ix[t + 1] : t + 1) * 3;
|
|
8358
|
+
const d = (ix ? ix[t + 2] : t + 2) * 3;
|
|
8359
|
+
let out = false;
|
|
8360
|
+
for (let k = 0; k < 3 && !out; k++) {
|
|
8361
|
+
const u = P[a + k];
|
|
8362
|
+
const v = P[b + k];
|
|
8363
|
+
const w = P[d + k];
|
|
8364
|
+
out = Math.max(u, v, w) < lo[k] || Math.min(u, v, w) > hi[k];
|
|
8365
|
+
}
|
|
8366
|
+
if (!out) {
|
|
8367
|
+
keep[nk++] = ix ? ix[t] : t;
|
|
8368
|
+
keep[nk++] = ix ? ix[t + 1] : t + 1;
|
|
8369
|
+
keep[nk++] = ix ? ix[t + 2] : t + 2;
|
|
8370
|
+
}
|
|
8371
|
+
}
|
|
8372
|
+
if (!nk) return null;
|
|
8373
|
+
const kept = keep.slice(0, nk);
|
|
8374
|
+
const box2 = new Float32Array(kept.length / 3 * 6);
|
|
8375
|
+
for (let t = 0, j = 0; t < kept.length; t += 3, j += 6) {
|
|
8376
|
+
const a = kept[t] * 3;
|
|
8377
|
+
const b = kept[t + 1] * 3;
|
|
8378
|
+
const d = kept[t + 2] * 3;
|
|
8379
|
+
for (let k = 0; k < 3; k++) {
|
|
8380
|
+
box2[j + k] = Math.min(P[a + k], P[b + k], P[d + k]);
|
|
8381
|
+
box2[j + 3 + k] = Math.max(P[a + k], P[b + k], P[d + k]);
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
const pg = new THREE.BufferGeometry();
|
|
8385
|
+
pg.setAttribute("position", g.attributes.position);
|
|
8386
|
+
pg.setIndex(new THREE.BufferAttribute(new Uint32Array(kept.length), 1));
|
|
8387
|
+
pg.boundingSphere = g.boundingSphere;
|
|
8388
|
+
pg.boundingBox = g.boundingBox;
|
|
8389
|
+
const proxy = new THREE.Mesh(pg, o.material);
|
|
8390
|
+
proxy.layers.mask = o.layers.mask;
|
|
8391
|
+
proxy.proxyOf = o;
|
|
8392
|
+
proxy.kept = kept;
|
|
8393
|
+
proxy.keptBox = box2;
|
|
8394
|
+
return proxy;
|
|
8395
|
+
}
|
|
8396
|
+
function narrowTo(rc, proxy) {
|
|
8397
|
+
const o = proxy.proxyOf;
|
|
8398
|
+
const ray = rc.ray;
|
|
8399
|
+
_pm.copy(o.matrixWorld).invert();
|
|
8400
|
+
_pv.copy(ray.origin).applyMatrix4(_pm);
|
|
8401
|
+
const x0 = _pv.x;
|
|
8402
|
+
const y0 = _pv.y;
|
|
8403
|
+
const z0 = _pv.z;
|
|
8404
|
+
_pv.copy(ray.direction).multiplyScalar(rc.far).add(ray.origin).applyMatrix4(_pm);
|
|
8405
|
+
const lo0 = Math.min(x0, _pv.x) - 1e-4;
|
|
8406
|
+
const lo1 = Math.min(y0, _pv.y) - 1e-4;
|
|
8407
|
+
const lo2 = Math.min(z0, _pv.z) - 1e-4;
|
|
8408
|
+
const hi0 = Math.max(x0, _pv.x) + 1e-4;
|
|
8409
|
+
const hi1 = Math.max(y0, _pv.y) + 1e-4;
|
|
8410
|
+
const hi2 = Math.max(z0, _pv.z) + 1e-4;
|
|
8411
|
+
const K = proxy.kept;
|
|
8412
|
+
const X = proxy.keptBox;
|
|
8413
|
+
const dst = proxy.geometry.index.array;
|
|
8414
|
+
let m = 0;
|
|
8415
|
+
for (let t = 0, j = 0; t < K.length; t += 3, j += 6) {
|
|
8416
|
+
if (X[j + 3] < lo0 || X[j] > hi0 || X[j + 4] < lo1 || X[j + 1] > hi1 || X[j + 5] < lo2 || X[j + 2] > hi2) continue;
|
|
8417
|
+
dst[m++] = K[t];
|
|
8418
|
+
dst[m++] = K[t + 1];
|
|
8419
|
+
dst[m++] = K[t + 2];
|
|
8420
|
+
}
|
|
8421
|
+
proxy.geometry.setDrawRange(0, m);
|
|
8422
|
+
}
|
|
8423
|
+
function castAt(rc, cands) {
|
|
8424
|
+
for (let i = 0; i < cands.length; i++) {
|
|
8425
|
+
const q = cands[i];
|
|
8426
|
+
if (!q.proxyOf) continue;
|
|
8427
|
+
q.matrixWorld.copy(q.proxyOf.matrixWorld);
|
|
8428
|
+
narrowTo(rc, q);
|
|
8429
|
+
}
|
|
8430
|
+
const hits = rc.intersectObjects(cands, false);
|
|
8431
|
+
for (let i = 0; i < hits.length; i++) if (hits[i].object.proxyOf) hits[i].object = hits[i].object.proxyOf;
|
|
8432
|
+
return hits;
|
|
8433
|
+
}
|
|
8201
8434
|
function zoneCands(c, z, inv, glassToo) {
|
|
8202
8435
|
const out = [];
|
|
8203
8436
|
c.vehicle.traverse(function(o) {
|
|
@@ -8250,7 +8483,7 @@ var GameVehicles = (() => {
|
|
|
8250
8483
|
});
|
|
8251
8484
|
_zr.set(org.clone().applyMatrix4(Mw), d.clone().transformDirection(Mw));
|
|
8252
8485
|
_zr.far = 0.6 + (I.boxHi(B, a) - I.boxLo(B, a)) + 0.05;
|
|
8253
|
-
const hits = _zr
|
|
8486
|
+
const hits = castAt(_zr, cands);
|
|
8254
8487
|
for (let i = 0; i < hits.length; i++) {
|
|
8255
8488
|
const h = hits[i];
|
|
8256
8489
|
if (!h.face) continue;
|
|
@@ -8278,7 +8511,7 @@ var GameVehicles = (() => {
|
|
|
8278
8511
|
const q = s.p.clone().addScaledVector(t, len * 0.5 * k / M);
|
|
8279
8512
|
_rt.set(q.clone().addScaledVector(n, 0.08).applyMatrix4(Mw), n.clone().negate().transformDirection(Mw));
|
|
8280
8513
|
_rt.far = 0.2;
|
|
8281
|
-
const h = _rt
|
|
8514
|
+
const h = castAt(_rt, cands).find(function(x) {
|
|
8282
8515
|
return x.face;
|
|
8283
8516
|
});
|
|
8284
8517
|
if (!h) return null;
|
|
@@ -8349,6 +8582,7 @@ var GameVehicles = (() => {
|
|
|
8349
8582
|
const R = c.rand;
|
|
8350
8583
|
const need = (spec.fine || 0) + (spec.deep || 0) + (spec.chip || 0) + (spec.rust || 0) + (spec.tear || 0) + (spec.ding || 0) + (spec.soot || 0) + (spec.crater || 0);
|
|
8351
8584
|
if (!need) return [];
|
|
8585
|
+
cands = regionCands(c, z, cands).filter(Boolean);
|
|
8352
8586
|
const S = zoneSurf(c, z, need + 2, R, cands);
|
|
8353
8587
|
let k = 0;
|
|
8354
8588
|
const ang0 = R() * PI;
|
|
@@ -8429,8 +8663,25 @@ var GameVehicles = (() => {
|
|
|
8429
8663
|
}
|
|
8430
8664
|
function subdivIn(geo, rel, B, maxLen) {
|
|
8431
8665
|
const a = geo.attributes.position.array;
|
|
8432
|
-
|
|
8433
|
-
|
|
8666
|
+
let out = new Float32Array(a.length + 4096);
|
|
8667
|
+
let used = 0;
|
|
8668
|
+
const push = function(a0, a1, a2, b0, b1, b2, c0, c1, c2) {
|
|
8669
|
+
if (used + 9 > out.length) {
|
|
8670
|
+
const bigger = new Float32Array(out.length * 2);
|
|
8671
|
+
bigger.set(out);
|
|
8672
|
+
out = bigger;
|
|
8673
|
+
}
|
|
8674
|
+
out[used] = a0;
|
|
8675
|
+
out[used + 1] = a1;
|
|
8676
|
+
out[used + 2] = a2;
|
|
8677
|
+
out[used + 3] = b0;
|
|
8678
|
+
out[used + 4] = b1;
|
|
8679
|
+
out[used + 5] = b2;
|
|
8680
|
+
out[used + 6] = c0;
|
|
8681
|
+
out[used + 7] = c1;
|
|
8682
|
+
out[used + 8] = c2;
|
|
8683
|
+
used += 9;
|
|
8684
|
+
};
|
|
8434
8685
|
const e = 0.15;
|
|
8435
8686
|
function d(p, q) {
|
|
8436
8687
|
return Math.hypot(p[0] - q[0], p[1] - q[1], p[2] - q[2]);
|
|
@@ -8444,7 +8695,7 @@ var GameVehicles = (() => {
|
|
|
8444
8695
|
const ca = d(C, A);
|
|
8445
8696
|
const mx = Math.max(ab, bc, ca);
|
|
8446
8697
|
if (mx <= maxLen || depth > 9) {
|
|
8447
|
-
|
|
8698
|
+
push(A[0], A[1], A[2], Bv[0], Bv[1], Bv[2], C[0], C[1], C[2]);
|
|
8448
8699
|
return;
|
|
8449
8700
|
}
|
|
8450
8701
|
if (mx === ab) {
|
|
@@ -8461,31 +8712,26 @@ var GameVehicles = (() => {
|
|
|
8461
8712
|
tri(F2, Bv, C, depth + 1);
|
|
8462
8713
|
}
|
|
8463
8714
|
}
|
|
8715
|
+
const M = rel.elements;
|
|
8716
|
+
const at = function(x, y, z, k) {
|
|
8717
|
+
const w = 1 / (M[3] * x + M[7] * y + M[11] * z + M[15]);
|
|
8718
|
+
return k === 0 ? (M[0] * x + M[4] * y + M[8] * z + M[12]) * w : k === 1 ? (M[1] * x + M[5] * y + M[9] * z + M[13]) * w : (M[2] * x + M[6] * y + M[10] * z + M[14]) * w;
|
|
8719
|
+
};
|
|
8720
|
+
const lo = [B.x0 - e, B.y0 - e, B.z0 - e];
|
|
8721
|
+
const hi = [B.x1 + e, B.y1 + e, B.z1 + e];
|
|
8464
8722
|
for (let i = 0; i < a.length; i += 9) {
|
|
8465
|
-
|
|
8466
|
-
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
[A, Bv, C].forEach(function(p) {
|
|
8475
|
-
v.set(p[0], p[1], p[2]).applyMatrix4(rel);
|
|
8476
|
-
x0 = Math.min(x0, v.x);
|
|
8477
|
-
x1 = Math.max(x1, v.x);
|
|
8478
|
-
y0 = Math.min(y0, v.y);
|
|
8479
|
-
y1 = Math.max(y1, v.y);
|
|
8480
|
-
z0 = Math.min(z0, v.z);
|
|
8481
|
-
z1 = Math.max(z1, v.z);
|
|
8482
|
-
});
|
|
8483
|
-
if (x1 < B.x0 - e || x0 > B.x1 + e || y1 < B.y0 - e || y0 > B.y1 + e || z1 < B.z0 - e || z0 > B.z1 + e)
|
|
8484
|
-
out.push(A[0], A[1], A[2], Bv[0], Bv[1], Bv[2], C[0], C[1], C[2]);
|
|
8485
|
-
else tri(A, Bv, C, 0);
|
|
8723
|
+
let outside = false;
|
|
8724
|
+
for (let k = 0; k < 3 && !outside; k++) {
|
|
8725
|
+
const p = at(a[i], a[i + 1], a[i + 2], k);
|
|
8726
|
+
const q = at(a[i + 3], a[i + 4], a[i + 5], k);
|
|
8727
|
+
const r = at(a[i + 6], a[i + 7], a[i + 8], k);
|
|
8728
|
+
outside = Math.max(p, q, r) < lo[k] || Math.min(p, q, r) > hi[k];
|
|
8729
|
+
}
|
|
8730
|
+
if (outside) push(a[i], a[i + 1], a[i + 2], a[i + 3], a[i + 4], a[i + 5], a[i + 6], a[i + 7], a[i + 8]);
|
|
8731
|
+
else tri([a[i], a[i + 1], a[i + 2]], [a[i + 3], a[i + 4], a[i + 5]], [a[i + 6], a[i + 7], a[i + 8]], 0);
|
|
8486
8732
|
}
|
|
8487
8733
|
const g = new THREE.BufferGeometry();
|
|
8488
|
-
g.setAttribute("position", new THREE.
|
|
8734
|
+
g.setAttribute("position", new THREE.BufferAttribute(out.slice(0, used), 3));
|
|
8489
8735
|
g.userData.crease = true;
|
|
8490
8736
|
g.userData.p0 = null;
|
|
8491
8737
|
return g;
|
|
@@ -8508,6 +8754,17 @@ var GameVehicles = (() => {
|
|
|
8508
8754
|
});
|
|
8509
8755
|
return out;
|
|
8510
8756
|
}
|
|
8757
|
+
function boxInFrame(B, m, tmp) {
|
|
8758
|
+
const r = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity];
|
|
8759
|
+
for (let i = 0; i < 8; i++) {
|
|
8760
|
+
tmp.set(i & 1 ? B.x1 : B.x0, i & 2 ? B.y1 : B.y0, i & 4 ? B.z1 : B.z0).applyMatrix4(m);
|
|
8761
|
+
for (let k = 0; k < 3; k++) {
|
|
8762
|
+
r[k] = Math.min(r[k], tmp.getComponent(k) - 1e-4);
|
|
8763
|
+
r[k + 3] = Math.max(r[k + 3], tmp.getComponent(k) + 1e-4);
|
|
8764
|
+
}
|
|
8765
|
+
}
|
|
8766
|
+
return r;
|
|
8767
|
+
}
|
|
8511
8768
|
function zoneDent(c, z, dents, dirty, opt) {
|
|
8512
8769
|
opt = opt || {};
|
|
8513
8770
|
const B = z.box;
|
|
@@ -8562,6 +8819,7 @@ var GameVehicles = (() => {
|
|
|
8562
8819
|
g = msh.geometry = g.clone();
|
|
8563
8820
|
msh.userData.zCloned = true;
|
|
8564
8821
|
}
|
|
8822
|
+
let boundsDue = false;
|
|
8565
8823
|
const nonIdx = !g.index;
|
|
8566
8824
|
const onlyPos = Object.keys(g.attributes).every(function(k) {
|
|
8567
8825
|
return k === "position" || k === "normal";
|
|
@@ -8570,15 +8828,17 @@ var GameVehicles = (() => {
|
|
|
8570
8828
|
const ng = subdivIn(g, rel, B, opt.sub || 0.075);
|
|
8571
8829
|
g.dispose();
|
|
8572
8830
|
g = msh.geometry = ng;
|
|
8573
|
-
|
|
8574
|
-
ng.computeBoundingBox();
|
|
8831
|
+
boundsDue = true;
|
|
8575
8832
|
dirty.add(msh);
|
|
8576
8833
|
}
|
|
8577
8834
|
irel.copy(rel).invert();
|
|
8578
8835
|
const pos = g.attributes.position;
|
|
8579
8836
|
let changed = false;
|
|
8837
|
+
const near = boxInFrame(B, irel, v);
|
|
8580
8838
|
for (let i = 0; i < pos.count; i++) {
|
|
8581
|
-
v.fromBufferAttribute(pos, i)
|
|
8839
|
+
v.fromBufferAttribute(pos, i);
|
|
8840
|
+
if (v.x < near[0] || v.x > near[3] || v.y < near[1] || v.y > near[4] || v.z < near[2] || v.z > near[5]) continue;
|
|
8841
|
+
v.applyMatrix4(rel);
|
|
8582
8842
|
const f = field(v);
|
|
8583
8843
|
if (f <= 1e-5) continue;
|
|
8584
8844
|
v.addScaledVector(d, f);
|
|
@@ -8599,9 +8859,11 @@ var GameVehicles = (() => {
|
|
|
8599
8859
|
}
|
|
8600
8860
|
if (changed) {
|
|
8601
8861
|
pos.needsUpdate = true;
|
|
8862
|
+
dirty.add(msh);
|
|
8863
|
+
}
|
|
8864
|
+
if (changed || boundsDue) {
|
|
8602
8865
|
g.computeBoundingSphere();
|
|
8603
8866
|
g.computeBoundingBox();
|
|
8604
|
-
dirty.add(msh);
|
|
8605
8867
|
}
|
|
8606
8868
|
});
|
|
8607
8869
|
const dset = new Set(c.deform);
|
|
@@ -11704,6 +11966,20 @@ var GameVehicles = (() => {
|
|
|
11704
11966
|
else kit.applyArmor(c);
|
|
11705
11967
|
}
|
|
11706
11968
|
if (zoneState == null && st === "damaged" && kit.config.damagedScenario) zoneState = kit.zoneScenario(c, kit.config.damagedScenario);
|
|
11969
|
+
else if (zoneState && zoneState.scenario != null) {
|
|
11970
|
+
c.scenario = zoneState.scenario;
|
|
11971
|
+
let fromScenario = { health: {}, flags: {} };
|
|
11972
|
+
try {
|
|
11973
|
+
fromScenario = kit.zoneScenario(c, zoneState.scenario);
|
|
11974
|
+
} catch (e) {
|
|
11975
|
+
;
|
|
11976
|
+
(c.zoneErrors = c.zoneErrors || []).push("scenario: " + (e && e.message));
|
|
11977
|
+
}
|
|
11978
|
+
zoneState = {
|
|
11979
|
+
health: Object.assign({}, fromScenario.health, zoneState.health),
|
|
11980
|
+
flags: Object.assign({}, fromScenario.flags, zoneState.flags)
|
|
11981
|
+
};
|
|
11982
|
+
}
|
|
11707
11983
|
if (zoneState) kit.applyZones(c, zoneState);
|
|
11708
11984
|
else {
|
|
11709
11985
|
c.zoneState = { health: {}, flags: {} };
|
|
@@ -11742,51 +12018,6 @@ var GameVehicles = (() => {
|
|
|
11742
12018
|
return kit;
|
|
11743
12019
|
}
|
|
11744
12020
|
|
|
11745
|
-
// ../game-contracts/dist/index.js
|
|
11746
|
-
var DEFAULT_IGNITION_RULES = {
|
|
11747
|
-
fillCurve: [
|
|
11748
|
-
[0, 0.6],
|
|
11749
|
-
[0.1, 1],
|
|
11750
|
-
[0.35, 0.6],
|
|
11751
|
-
[0.65, 0.3],
|
|
11752
|
-
[0.9, 0.15],
|
|
11753
|
-
[1, 0.12]
|
|
11754
|
-
],
|
|
11755
|
-
flameFillInfluence: 0.5,
|
|
11756
|
-
flameDefaults: { incendiary: 0.7, tracer: 0.2 },
|
|
11757
|
-
sparkTarget: { steel: 1, iron: 1, aluminium: 0.25 },
|
|
11758
|
-
sparkMetalDefault: 0.5,
|
|
11759
|
-
sparkFluid: { diesel: 0.15 },
|
|
11760
|
-
fireNear: { radius: 1.5, chancePerSecond: 0.5 }
|
|
11761
|
-
};
|
|
11762
|
-
var resolveIgnitionRules = (rules) => ({
|
|
11763
|
-
...DEFAULT_IGNITION_RULES,
|
|
11764
|
-
...rules,
|
|
11765
|
-
flameDefaults: { ...DEFAULT_IGNITION_RULES.flameDefaults, ...rules?.flameDefaults },
|
|
11766
|
-
sparkTarget: { ...DEFAULT_IGNITION_RULES.sparkTarget, ...rules?.sparkTarget },
|
|
11767
|
-
sparkFluid: { ...DEFAULT_IGNITION_RULES.sparkFluid, ...rules?.sparkFluid },
|
|
11768
|
-
fireNear: { ...DEFAULT_IGNITION_RULES.fireNear, ...rules?.fireNear }
|
|
11769
|
-
});
|
|
11770
|
-
var fillFactor = (fill, curve = DEFAULT_IGNITION_RULES.fillCurve) => {
|
|
11771
|
-
if (curve.length === 0) return 1;
|
|
11772
|
-
const f = Math.min(1, Math.max(0, fill));
|
|
11773
|
-
if (f <= curve[0][0]) return curve[0][1];
|
|
11774
|
-
for (let i = 1; i < curve.length; i++) {
|
|
11775
|
-
const [x1, y1] = curve[i];
|
|
11776
|
-
const [x0, y0] = curve[i - 1];
|
|
11777
|
-
if (f <= x1) return x1 === x0 ? y1 : y0 + (y1 - y0) * (f - x0) / (x1 - x0);
|
|
11778
|
-
}
|
|
11779
|
-
return curve[curve.length - 1][1];
|
|
11780
|
-
};
|
|
11781
|
-
var sparkTargetFactor = (materialId, metal, rules = DEFAULT_IGNITION_RULES) => !metal ? 0 : rules.sparkTarget[materialId] ?? rules.sparkMetalDefault;
|
|
11782
|
-
var ignitionChance = (hit, target, rules = DEFAULT_IGNITION_RULES) => {
|
|
11783
|
-
const k = fillFactor(target.fill, rules.fillCurve);
|
|
11784
|
-
const spark = (hit.ignition?.spark ?? 0) * target.sparkTarget * (target.fluid === void 0 ? 1 : rules.sparkFluid[target.fluid] ?? 1) * k;
|
|
11785
|
-
const flameBase = hit.ignition?.flame ?? Math.max(hit.incendiary ? rules.flameDefaults.incendiary : 0, hit.tracer ? rules.flameDefaults.tracer : 0);
|
|
11786
|
-
const flame = flameBase * (1 - rules.flameFillInfluence * (1 - k));
|
|
11787
|
-
return 1 - (1 - Math.min(1, Math.max(0, spark))) * (1 - Math.min(1, Math.max(0, flame)));
|
|
11788
|
-
};
|
|
11789
|
-
|
|
11790
12021
|
// src/destructible/model.ts
|
|
11791
12022
|
var JOINT_RULES = {
|
|
11792
12023
|
hinge: { strength: 5e3, tools: ["wrench", "screwdriver"], seconds: 3 },
|
|
@@ -13702,7 +13933,7 @@ var GameVehicles = (() => {
|
|
|
13702
13933
|
const reset = () => {
|
|
13703
13934
|
const old = c;
|
|
13704
13935
|
const parent = old.root.parent;
|
|
13705
|
-
const next = kit.build(old.key, old.state);
|
|
13936
|
+
const next = kit.build(old.key, old.state, old.scenario != null ? { scenario: old.scenario } : void 0);
|
|
13706
13937
|
if (parent) {
|
|
13707
13938
|
next.root.position.copy(old.root.position);
|
|
13708
13939
|
next.root.quaternion.copy(old.root.quaternion);
|
|
@@ -13759,7 +13990,8 @@ var GameVehicles = (() => {
|
|
|
13759
13990
|
// src/destructible/item.ts
|
|
13760
13991
|
function buildVehicleItem(kit, key, options = {}) {
|
|
13761
13992
|
const THREE = kit.THREE;
|
|
13762
|
-
const
|
|
13993
|
+
const zoneState = options.scenario != null ? { scenario: options.scenario } : void 0;
|
|
13994
|
+
const vehicle = options.lod ? kit.build(key, options.state ?? "intact", zoneState, { lod: true }) : kit.build(key, options.state ?? "intact", zoneState);
|
|
13763
13995
|
const m = vehicle.meta;
|
|
13764
13996
|
const root = new THREE.Group();
|
|
13765
13997
|
root.name = key;
|