@adatechnology/game-vehicles 0.7.1 → 0.7.2
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 +4 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.global.js +30 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -293,3 +293,7 @@ scene.add(c.root)
|
|
|
293
293
|
## Light mode and damageable parts
|
|
294
294
|
|
|
295
295
|
`createVehicleKit({ lod })` takes the settings of the light mode (`defaultLodSettings`: every number can be overridden). `kit.build(key, state, zones, { lod: true })` builds the same vehicle with fewer triangles (rounded boxes with one ring, coarser lofts, grilles and generators, interiors tagged `userData.skipLite`) and puts the switch back; with it off nothing changes. `kit.damageables(c, matrix?)` lists the metal, glass, rubber and fuel parts of a built vehicle as `Box3` boxes (`kit.damageableKinds` maps zone types to parts and can be extended).
|
|
296
|
+
|
|
297
|
+
## Parts as bodies (`setPartSink`, spec 008 T6.9)
|
|
298
|
+
|
|
299
|
+
`destructible.setPartSink(sink | null)` hands a part that comes off (`detach`) to the host instead of throwing it as a `fling`: with a sink, the part's holder (the meshes) leaves `c.flying` and the sink gets the part, the holder, the velocity and the spin the `fling` would have had (`PartSink`). Without a sink nothing changes. `@adatechnology/game-vehicles-three` (`createCrashParts`) is the sink that turns each part into a physics body. The `fling` of explosions does not go through the sink.
|
package/dist/index.d.ts
CHANGED
|
@@ -2310,6 +2310,10 @@ interface CreaseQueue {
|
|
|
2310
2310
|
*/
|
|
2311
2311
|
declare function createCreaseQueue(): CreaseQueue;
|
|
2312
2312
|
|
|
2313
|
+
/** Takes a part that came off in place of the ballistic fling: the part, the holder that carries its drawn meshes (in the effects group, at the centre of the part), and the throw it would have had. */
|
|
2314
|
+
/** Takes a part that came off: true when it will look after the part (move and, in the end, remove it); false leaves it to the vehicle's own fling. */
|
|
2315
|
+
type PartSink = (part: PartDef, holder: Object3D, velocity: readonly [number, number, number], spin: readonly [number, number, number]) => boolean;
|
|
2316
|
+
|
|
2313
2317
|
/**
|
|
2314
2318
|
* `createVehicleDestructible`: a vehicle that follows the destruction contract of `@adatechnology/game-contracts` and brings its own rules.
|
|
2315
2319
|
* Every damage zone and mechanical part is a part with a material, hits become events (dent, hole, crack, fracture, detach, leak, ignite,
|
|
@@ -2409,6 +2413,8 @@ interface VehicleDestructible extends DestructibleImpl {
|
|
|
2409
2413
|
rollFlat(meters: number, speed: number): number;
|
|
2410
2414
|
/** Pushes the drawn body in by `depth` metres around `point` (world), along `direction`: the crumple of a crash. Drawing only. */
|
|
2411
2415
|
crumple(point: Vec3, direction: Vec3, depth: number): void;
|
|
2416
|
+
/** Takes the parts that come off in place of the ballistic fling (a physics engine makes them bodies); `null` gives the fling back. Does nothing on a headless vehicle. */
|
|
2417
|
+
setPartSink(sink: PartSink | null): void;
|
|
2412
2418
|
}
|
|
2413
2419
|
type DriveReport = {
|
|
2414
2420
|
/** `rim`: the tyre is torn off and the bare rim is on the road. */
|
|
@@ -2574,4 +2580,4 @@ declare const CABIN_MINIMUMS: Readonly<Record<CabinCategory, CabinMinimum>>;
|
|
|
2574
2580
|
/** Returns the minimum interior clearances for a cabin category. */
|
|
2575
2581
|
declare const cabinMinimumOf: (category: CabinCategory) => CabinMinimum;
|
|
2576
2582
|
|
|
2577
|
-
export { ARMOUR_LEVELS, type ArmourLevel, type ArmourLevelId, type Band, type BandId, type BandIndex, type BandOverride, type BayBox, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, type BusRowsOptions, CABIN_CATEGORIES, CABIN_LEAK, CABIN_MINIMUMS, CABIN_SOURCE, CRASH_RULES, type CabinBox, type CabinCategory, type CabinDoorMinimum, type CabinEnclosureOptions, type CabinMinimum, type CabinSource, type CarSpec, type CarWheel, type CrashOptions, type CrashResult, type CrashRules, type CreaseQueue, type CreaseWork, type CutTest, DOOR_SHELL_DEPTH, DOOR_SHELL_MAX_DEPTH, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type DashboardOptions, type DoorShellParams, type DoorShellResult, type DriveReport, ENTRY_DUCK_FACTOR, type EngineBaySpec, type ExplodeOptions, type FlagEffect, type FluidDefinition, type GlassOptions, type GlassQuad, type Greenhouse, type GrilleOptions, type HeadlightLens, type HeadlightOptions, type ImpactOptions, type InteriorOptions, JOINT_RULES, type JointDef, type KitConfiguration, type KitInternals, type KitTexts, LEGACY_STATES, LEGACY_ZONE_IDS, type LabelArgument, type LocalBox, type LocaleStrings, type LodSettings, type LoftRow, type LoftStation, type OverallHealth, PLUME_PUFFS, type PaneLook, type PartDef, type PartLabel, type PartRole, type PartialLocaleStrings, type ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, type PathItem, type Plugin, type Puddle, type PuddleLobe, RAIN_MOVE_STEP, RAIN_OPENING_DIAMETER, RAIN_TURN_STEP, type ResolvedConfiguration, type RollState, SEED_SALTS, SMOKE_LOOKS, SMOKE_WIND, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneNode, type SeatOptions, type ShellSpec, SmokeCause, type SmokeLook, type SmokePuff, type SmokePuffParams, type SmoothLoftOptions, type Splat, type SplatOptions, type StrayLamp, type TaillightOptions, type ThreeObject, type ThreeVector, type Translate, type TumbleSpec, type UiHelpers, type UnderbodySpec, type VehicleContext, type VehicleDestructible, type VehicleDestructibleOptions, type VehicleItem, type VehicleItemOptions, type VehicleKit, type VehicleKitOptions, type VehicleLamp, type VehicleMeta, type VehicleModel, type VehiclePart, type VehicleRainCover, type VehicleRainCoverOptions, type VehicleSpec, type VehicleStatus, type WarpFn, type WarpOptions, type ZoneDamageEntry, type ZoneDef, type ZoneEffect, type ZoneState, armourLevelOf, buildVehicleItem, buildVehicleModel, cabinBoxOf, cabinEnclosure, cabinMinimumOf, clamp, crackedGlassMaterial, crashDeltaV, crashVehicle, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, createVehicleRainCover, defaultDamageableKinds, defaultLodSettings, doorShell, engineBayVent, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, openEdgeCount, registerLegacySeeds, registerLocale, resolveStrings, rng, smokeCauseOfEmitter, smokePuff, smokeRate, smooth, strHash, strayLampsOf, swingOf, wrapThreeForLod };
|
|
2583
|
+
export { ARMOUR_LEVELS, type ArmourLevel, type ArmourLevelId, type Band, type BandId, type BandIndex, type BandOverride, type BayBox, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, type BusRowsOptions, CABIN_CATEGORIES, CABIN_LEAK, CABIN_MINIMUMS, CABIN_SOURCE, CRASH_RULES, type CabinBox, type CabinCategory, type CabinDoorMinimum, type CabinEnclosureOptions, type CabinMinimum, type CabinSource, type CarSpec, type CarWheel, type CrashOptions, type CrashResult, type CrashRules, type CreaseQueue, type CreaseWork, type CutTest, DOOR_SHELL_DEPTH, DOOR_SHELL_MAX_DEPTH, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type DashboardOptions, type DoorShellParams, type DoorShellResult, type DriveReport, ENTRY_DUCK_FACTOR, type EngineBaySpec, type ExplodeOptions, type FlagEffect, type FluidDefinition, type GlassOptions, type GlassQuad, type Greenhouse, type GrilleOptions, type HeadlightLens, type HeadlightOptions, type ImpactOptions, type InteriorOptions, JOINT_RULES, type JointDef, type KitConfiguration, type KitInternals, type KitTexts, LEGACY_STATES, LEGACY_ZONE_IDS, type LabelArgument, type LocalBox, type LocaleStrings, type LodSettings, type LoftRow, type LoftStation, type OverallHealth, PLUME_PUFFS, type PaneLook, type PartDef, type PartLabel, type PartRole, type PartSink, type PartialLocaleStrings, type ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, type PathItem, type Plugin, type Puddle, type PuddleLobe, RAIN_MOVE_STEP, RAIN_OPENING_DIAMETER, RAIN_TURN_STEP, type ResolvedConfiguration, type RollState, SEED_SALTS, SMOKE_LOOKS, SMOKE_WIND, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneNode, type SeatOptions, type ShellSpec, SmokeCause, type SmokeLook, type SmokePuff, type SmokePuffParams, type SmoothLoftOptions, type Splat, type SplatOptions, type StrayLamp, type TaillightOptions, type ThreeObject, type ThreeVector, type Translate, type TumbleSpec, type UiHelpers, type UnderbodySpec, type VehicleContext, type VehicleDestructible, type VehicleDestructibleOptions, type VehicleItem, type VehicleItemOptions, type VehicleKit, type VehicleKitOptions, type VehicleLamp, type VehicleMeta, type VehicleModel, type VehiclePart, type VehicleRainCover, type VehicleRainCoverOptions, type VehicleSpec, type VehicleStatus, type WarpFn, type WarpOptions, type ZoneDamageEntry, type ZoneDef, type ZoneEffect, type ZoneState, armourLevelOf, buildVehicleItem, buildVehicleModel, cabinBoxOf, cabinEnclosure, cabinMinimumOf, clamp, crackedGlassMaterial, crashDeltaV, crashVehicle, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, createVehicleRainCover, defaultDamageableKinds, defaultLodSettings, doorShell, engineBayVent, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, openEdgeCount, registerLegacySeeds, registerLocale, resolveStrings, rng, smokeCauseOfEmitter, smokePuff, smokeRate, smooth, strHash, strayLampsOf, swingOf, wrapThreeForLod };
|
package/dist/index.global.js
CHANGED
|
@@ -1740,7 +1740,8 @@ var GameVehicles = (() => {
|
|
|
1740
1740
|
PIECE_BOXES: "destruction.piece-boxes",
|
|
1741
1741
|
STATIC_COLLIDERS: "destruction.static-colliders",
|
|
1742
1742
|
SHAPES_GENERATE: "shapes.generate",
|
|
1743
|
-
WORLD_REGION: "world.region"
|
|
1743
|
+
WORLD_REGION: "world.region",
|
|
1744
|
+
VEHICLE_HULL_PLAN: "vehicles.hull-plan"
|
|
1744
1745
|
};
|
|
1745
1746
|
var WORKER_KIND_DEFAULTS = {
|
|
1746
1747
|
[WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
|
|
@@ -1748,7 +1749,8 @@ var GameVehicles = (() => {
|
|
|
1748
1749
|
[WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
|
|
1749
1750
|
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
1750
1751
|
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
1751
|
-
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" }
|
|
1752
|
+
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" },
|
|
1753
|
+
[WORKER_KIND_ID.VEHICLE_HULL_PLAN]: { lane: "build", priority: 120, late: "keep-waiting" }
|
|
1752
1754
|
};
|
|
1753
1755
|
|
|
1754
1756
|
// ../game-shapes/dist/index.js
|
|
@@ -14717,6 +14719,9 @@ var GameVehicles = (() => {
|
|
|
14717
14719
|
/** Hinged panels created for the doors and the lid, by part id. */
|
|
14718
14720
|
__publicField(this, "plates", /* @__PURE__ */ new Map());
|
|
14719
14721
|
__publicField(this, "gone", /* @__PURE__ */ new Set());
|
|
14722
|
+
/** Where a part that comes off goes instead of the fling (a physics engine takes it as a body); null: the fling. */
|
|
14723
|
+
__publicField(this, "sink", null);
|
|
14724
|
+
__publicField(this, "detaching", null);
|
|
14720
14725
|
/** Shows or hides the plate and the recess of a door or lid by its state (see `showWhenOpen`). */
|
|
14721
14726
|
__publicField(this, "syncPlates", /* @__PURE__ */ new Map());
|
|
14722
14727
|
/** Doors and lids whose own skin was cut from the body and hung on the hinge (true), or that had none to take and keep the plate (false). */
|
|
@@ -15990,10 +15995,29 @@ var GameVehicles = (() => {
|
|
|
15990
15995
|
}
|
|
15991
15996
|
fling(obj, v, w, trail) {
|
|
15992
15997
|
const piece = this.I.fling(this.c, obj, v, w);
|
|
15993
|
-
if (piece)
|
|
15998
|
+
if (!piece) return;
|
|
15999
|
+
if (!this.sink || !this.detaching) {
|
|
16000
|
+
piece.trail = trail;
|
|
16001
|
+
return;
|
|
16002
|
+
}
|
|
16003
|
+
if (!this.sink(this.detaching, piece.o, [v.x, v.y, v.z], [w.x, w.y, w.z])) {
|
|
16004
|
+
piece.trail = trail;
|
|
16005
|
+
return;
|
|
16006
|
+
}
|
|
16007
|
+
const flying = this.c.flying;
|
|
16008
|
+
const at = flying ? flying.indexOf(piece) : -1;
|
|
16009
|
+
if (flying && at >= 0) flying.splice(at, 1);
|
|
15994
16010
|
}
|
|
15995
16011
|
/** Brings a part off the vehicle and throws it. Returns whether something visible moved. */
|
|
15996
16012
|
detach(p, o) {
|
|
16013
|
+
this.detaching = p;
|
|
16014
|
+
try {
|
|
16015
|
+
return this.detachPart(p, o);
|
|
16016
|
+
} finally {
|
|
16017
|
+
this.detaching = null;
|
|
16018
|
+
}
|
|
16019
|
+
}
|
|
16020
|
+
detachPart(p, o) {
|
|
15997
16021
|
if (this.gone.has(p.id)) return false;
|
|
15998
16022
|
const V3 = this.THREE.Vector3;
|
|
15999
16023
|
const c = this.c;
|
|
@@ -17340,6 +17364,9 @@ var GameVehicles = (() => {
|
|
|
17340
17364
|
return d ? toWorld(d.box.center) : [0, 0, 0];
|
|
17341
17365
|
},
|
|
17342
17366
|
rollover,
|
|
17367
|
+
setPartSink: (sink) => {
|
|
17368
|
+
if (vis) vis.sink = sink;
|
|
17369
|
+
},
|
|
17343
17370
|
detachedParts: () => [...ps.values()].filter((p) => !p.lost && !attached(p.def.id) || p.lost && p.def.visual && js.some((j) => j.open && j.def.a === p.def.id)).map((p) => p.def.id)
|
|
17344
17371
|
};
|
|
17345
17372
|
return impl;
|