@adatechnology/game-vehicles 0.6.0 → 0.6.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/dist/index.d.ts +105 -3
- package/dist/index.global.js +753 -107
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +747 -101
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MaterialId, Vec3, JointKind, ToolKind, DeferredQueue, DestructibleImpl, AnimationClipSpec, IgnitionRules, ObjectState, Enclosure } from '@adatechnology/game-contracts';
|
|
1
|
+
import { MaterialId, Vec3, JointKind, ToolKind, DeferredQueue, DestructibleImpl, AnimationClipSpec, IgnitionRules, DestructionEvent, ObjectState, Enclosure } from '@adatechnology/game-contracts';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Light mode ("lite"): the same vehicles with fewer triangles, for a whole street of them. Port of the `[LOD]` hooks of the team's Frota Leve
|
|
@@ -784,6 +784,30 @@ declare function rng(seed: number): () => number;
|
|
|
784
784
|
/** FNV-1a hash of a string, used to derive seeds from vehicle keys and zone ids. */
|
|
785
785
|
declare function strHash(s: string): number;
|
|
786
786
|
|
|
787
|
+
/**
|
|
788
|
+
* Armour levels of a vehicle, after NIJ 0108: the level says which rounds the glass and the steel stop, and how many hits they take
|
|
789
|
+
* before they give. Every number is configurable: a game passes its own table in `VehicleDestructibleOptions.armourLevels`.
|
|
790
|
+
*/
|
|
791
|
+
type ArmourLevelId = 'IIIA' | 'III';
|
|
792
|
+
type ArmourLevel = {
|
|
793
|
+
/** Energy in joules a round needs to go through the armoured glass. */
|
|
794
|
+
readonly glassStops: number;
|
|
795
|
+
/** Joules of hits the armoured glass takes before it gives way. */
|
|
796
|
+
readonly glassHp: number;
|
|
797
|
+
/** Share of a stopped round's energy the glass takes as damage (it cracks round the hit and holds). */
|
|
798
|
+
readonly glassTakes: number;
|
|
799
|
+
/** How much harder the steel skin is than a plain car's. */
|
|
800
|
+
readonly steel: number;
|
|
801
|
+
};
|
|
802
|
+
/** IIIA: civilian armour, stops handguns up to .44 Magnum, a rifle goes through. III: armour against rifles up to 7.62x51 (cash in transit, military). */
|
|
803
|
+
declare const ARMOUR_LEVELS: Readonly<Record<ArmourLevelId, ArmourLevel>>;
|
|
804
|
+
/** The level a vehicle has: the host's option, else its spec (`armor`), else III for the old `armored`/`bullet` flags, else none. */
|
|
805
|
+
declare function armourLevelOf(meta: {
|
|
806
|
+
armor?: string;
|
|
807
|
+
armored?: boolean;
|
|
808
|
+
bullet?: boolean;
|
|
809
|
+
}, option?: ArmourLevelId | null): ArmourLevelId | null;
|
|
810
|
+
|
|
787
811
|
/**
|
|
788
812
|
* Part and joint model of a vehicle for the destruction contract: every damage zone becomes a part with a material, the mechanical parts the
|
|
789
813
|
* zones do not cover (battery, alternator, gearbox, brakes, steering, shock absorbers, tow hitch, tyres, mirrors, pillars...) are added from the
|
|
@@ -822,7 +846,8 @@ interface PartDef {
|
|
|
822
846
|
explodes?: {
|
|
823
847
|
energy: number;
|
|
824
848
|
radius: number;
|
|
825
|
-
atC: number;
|
|
849
|
+
atC: number; /** The named explosion of game-vfx it plays (its fireball and its sound). */
|
|
850
|
+
effect?: string;
|
|
826
851
|
};
|
|
827
852
|
/** Temperature in Celsius at which the part catches fire (none: it does not burn). */
|
|
828
853
|
ignitionC?: number;
|
|
@@ -851,6 +876,8 @@ interface VehicleModel {
|
|
|
851
876
|
interface ModelOptions {
|
|
852
877
|
/** Fit a tow hitch. Default: the spec flag `hitch`, else a seeded choice by vehicle kind. */
|
|
853
878
|
hitch?: boolean;
|
|
879
|
+
/** Armour of the vehicle: its glass is laminated and as strong as the level says. */
|
|
880
|
+
armour?: ArmourLevel | null;
|
|
854
881
|
}
|
|
855
882
|
/** Joint kinds as the vehicle uses them: strength in joules of wear, the tools that undo them and the seconds of work. */
|
|
856
883
|
declare const JOINT_RULES: Record<'hinge' | 'bolt' | 'weld' | 'glue' | 'clip', {
|
|
@@ -913,6 +940,10 @@ interface VehicleDestructibleOptions {
|
|
|
913
940
|
* Defaults and meaning of every number: `IgnitionRules` of `@adatechnology/game-contracts`.
|
|
914
941
|
*/
|
|
915
942
|
ignition?: Partial<IgnitionRules>;
|
|
943
|
+
/** Armour level of this vehicle (`IIIA` civilian, `III` against rifles), or null for none. Default: its spec. */
|
|
944
|
+
armour?: ArmourLevelId | null;
|
|
945
|
+
/** Replaces or extends the armour table. */
|
|
946
|
+
armourLevels?: Partial<Record<ArmourLevelId, ArmourLevel>>;
|
|
916
947
|
/**
|
|
917
948
|
* One queue that smooths the normals of cut panels for every vehicle that shares it (`createCreaseQueue()`), run by a frame budget. Without it, or while
|
|
918
949
|
* nobody registered the queue with a budget, each vehicle smooths in its own `update` (2.5 ms a frame), as always.
|
|
@@ -952,7 +983,31 @@ interface VehicleDestructible extends DestructibleImpl {
|
|
|
952
983
|
rollover(side?: number): void;
|
|
953
984
|
/** Part ids that are no longer attached to the main body. */
|
|
954
985
|
detachedParts(): string[];
|
|
986
|
+
/** What the damage leaves for driving: each tyre's health where it stands, the brakes, the engine and the shocks (0 gone .. 1 whole). */
|
|
987
|
+
driveReport(): DriveReport;
|
|
988
|
+
/**
|
|
989
|
+
* The engine ran for `seconds` at `load` (0 idle .. 1 full throttle): without coolant it heats up, steams and seizes in a few minutes;
|
|
990
|
+
* without oil it wears and seizes. Call it while the vehicle is driven. Answers the engine temperature, °C.
|
|
991
|
+
*/
|
|
992
|
+
runEngine(seconds: number, load: number): number;
|
|
993
|
+
/**
|
|
994
|
+
* The vehicle rolled `meters` at `speed` m/s: a flat tyre wears through and tears off (a run-flat insert on an armoured vehicle carries it far
|
|
995
|
+
* at up to 80 km/h), then the bare rim grinds on the road throwing sparks. Answers how many rims are on the road.
|
|
996
|
+
*/
|
|
997
|
+
rollFlat(meters: number, speed: number): number;
|
|
998
|
+
/** Pushes the drawn body in by `depth` metres around `point` (world), along `direction`: the crumple of a crash. Drawing only. */
|
|
999
|
+
crumple(point: Vec3, direction: Vec3, depth: number): void;
|
|
955
1000
|
}
|
|
1001
|
+
type DriveReport = {
|
|
1002
|
+
readonly tyres: ReadonlyArray<{
|
|
1003
|
+
readonly x: number;
|
|
1004
|
+
readonly z: number;
|
|
1005
|
+
readonly health: number;
|
|
1006
|
+
}>;
|
|
1007
|
+
readonly brakes: number;
|
|
1008
|
+
readonly engine: number;
|
|
1009
|
+
readonly suspension: number;
|
|
1010
|
+
};
|
|
956
1011
|
declare function createVehicleDestructible(kit: VehicleKit, vehicleCtx: VehicleContext, options?: VehicleDestructibleOptions): VehicleDestructible;
|
|
957
1012
|
|
|
958
1013
|
interface VehicleItemOptions {
|
|
@@ -975,6 +1030,53 @@ interface VehicleItem {
|
|
|
975
1030
|
*/
|
|
976
1031
|
declare function buildVehicleItem(kit: VehicleKit, key: string, options?: VehicleItemOptions): VehicleItem;
|
|
977
1032
|
|
|
1033
|
+
/**
|
|
1034
|
+
* A vehicle running into something: the energy of the crash, from the masses and the closing speed, becomes blunt hits spread over the
|
|
1035
|
+
* contact. A wide wall crushes the whole front evenly; a pillar or a post goes deep into a narrow strip; a lighter object takes most of
|
|
1036
|
+
* the change of speed and the vehicle little. Every number is configurable through `CrashRules`.
|
|
1037
|
+
*/
|
|
1038
|
+
|
|
1039
|
+
type CrashRules = {
|
|
1040
|
+
/** Share of the deformation energy each blunt hit carries into the parts (the rest is the crumple of the structure itself). */
|
|
1041
|
+
readonly energyToDamage: number;
|
|
1042
|
+
/** Width one blunt hit stands for, metres. */
|
|
1043
|
+
readonly hitSpacing: number;
|
|
1044
|
+
/** Below this closing speed nothing deforms (a nudge), m/s. */
|
|
1045
|
+
readonly minSpeed: number;
|
|
1046
|
+
/** Heights over the contact point the blow also lands at, metres: the bumper takes it first, the front above it (hood, lights, grille) after. */
|
|
1047
|
+
readonly rows: readonly number[];
|
|
1048
|
+
/** How far the front crushes per m/s of change of speed, metres (a car into a wall at 50 km/h folds about half a metre), and at most. */
|
|
1049
|
+
readonly crushPerMs: number;
|
|
1050
|
+
readonly maxCrush: number;
|
|
1051
|
+
};
|
|
1052
|
+
declare const CRASH_RULES: CrashRules;
|
|
1053
|
+
type CrashOptions = {
|
|
1054
|
+
/** Where the vehicle touched the obstacle, world space. */
|
|
1055
|
+
readonly point: Vec3;
|
|
1056
|
+
/** The way the vehicle was moving into the obstacle, world space. */
|
|
1057
|
+
readonly direction: Vec3;
|
|
1058
|
+
/** Closing speed, m/s. */
|
|
1059
|
+
readonly speed: number;
|
|
1060
|
+
/** Mass of this vehicle, kg. */
|
|
1061
|
+
readonly massKg: number;
|
|
1062
|
+
/** Mass of what it hit, kg (`Infinity` for a wall, a pillar or anything anchored). */
|
|
1063
|
+
readonly otherMassKg: number;
|
|
1064
|
+
/** How wide the contact is, metres (a post 0.2, a wall the whole front). */
|
|
1065
|
+
readonly contactWidth: number;
|
|
1066
|
+
readonly source?: string;
|
|
1067
|
+
readonly rules?: Partial<CrashRules>;
|
|
1068
|
+
};
|
|
1069
|
+
type CrashResult = {
|
|
1070
|
+
/** Change of speed this vehicle takes, m/s. */
|
|
1071
|
+
readonly deltaV: number;
|
|
1072
|
+
/** Deformation energy this vehicle takes, joules. */
|
|
1073
|
+
readonly energy: number;
|
|
1074
|
+
readonly events: DestructionEvent[];
|
|
1075
|
+
};
|
|
1076
|
+
/** Change of speed of each body in a plastic collision: the lighter one takes more. */
|
|
1077
|
+
declare function crashDeltaV(speed: number, massKg: number, otherMassKg: number): number;
|
|
1078
|
+
declare function crashVehicle(d: VehicleDestructible, crash: CrashOptions): CrashResult;
|
|
1079
|
+
|
|
978
1080
|
/**
|
|
979
1081
|
* The cabin of a vehicle as a closed space for the smoke, dust and steam of the host's effects (`EffectSink.enclose` of the contracts): a shut car
|
|
980
1082
|
* keeps the smoke out. It is open where it is in the real world: a door standing open, a window shattered, a door, glass or roof torn off or burnt
|
|
@@ -1020,4 +1122,4 @@ declare function cabinEnclosure(source: CabinSource, options?: CabinEnclosureOpt
|
|
|
1020
1122
|
/** The material of a pane with cracks drawn on it. A host warms its program at load with any texture: the first crack is in the middle of a blast. */
|
|
1021
1123
|
declare function crackedGlassMaterial(THREE: any, texture: unknown): any;
|
|
1022
1124
|
|
|
1023
|
-
export { type Band, type BandId, type BandIndex, type BandOverride, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, CABIN_LEAK, type CabinBox, type CabinEnclosureOptions, type CabinSource, type CreaseQueue, type CreaseWork, 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 ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, 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, cabinBoxOf, cabinEnclosure, clamp, crackedGlassMaterial, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, defaultDamageableKinds, defaultLodSettings, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, registerLegacySeeds, registerLocale, resolveStrings, rng, smooth, strHash, swingOf, wrapThreeForLod };
|
|
1125
|
+
export { ARMOUR_LEVELS, type ArmourLevel, type ArmourLevelId, type Band, type BandId, type BandIndex, type BandOverride, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, CABIN_LEAK, CRASH_RULES, type CabinBox, type CabinEnclosureOptions, type CabinSource, type CrashOptions, type CrashResult, type CrashRules, type CreaseQueue, type CreaseWork, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type DriveReport, 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 ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, 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, armourLevelOf, buildVehicleItem, buildVehicleModel, cabinBoxOf, cabinEnclosure, clamp, crackedGlassMaterial, crashDeltaV, crashVehicle, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, defaultDamageableKinds, defaultLodSettings, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, registerLegacySeeds, registerLocale, resolveStrings, rng, smooth, strHash, swingOf, wrapThreeForLod };
|