@adatechnology/game-characters-three 0.1.3 → 0.2.0
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 +5 -0
- package/dist/index.d.ts +171 -21
- package/dist/index.global.js +557 -53
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +357 -53
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -22,3 +22,8 @@ batch.push({ a: [x, z, yaw, phase], b: [1.8, 1, stride, 0], c: [missingMask, inf
|
|
|
22
22
|
batch.end()
|
|
23
23
|
time.value += dt
|
|
24
24
|
```
|
|
25
|
+
|
|
26
|
+
**Sound and blood of the bodies** (on `@adatechnology/game-audio` and the running film of `@adatechnology/game-fluids-three`):
|
|
27
|
+
|
|
28
|
+
- `createCharacterSound(host.audio, { style? })`: `voice(typeId, 'idle' | 'alert' | 'special', position)` for the 13 undead types (`UNDEAD_VOICES`: the game's groans and scream, the art scene's `voice` groan, scream and leap, with the class rule of the page for the types it does not have), `body(event, position)` (wound = flesh, cut = sever, burst or split = gore), `player('grab' | 'bite' | 'hurt')`. The 16 recipes (`CHARACTER_SOUND_BANK`) leave the same trace as the team code.
|
|
29
|
+
- `createFluidsBridge({ sink, film })` and `bloodLookOfAge(age)`: a `body` event throws drops of blood into the film, in the fresh and dry colours of the infection age (`ages.json`), `old_blood` for the thin ones.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as THREE_NS from 'three';
|
|
2
2
|
import { BodySpec, CascadeJoint, RestPose, StrideParams, GaitSample, lerpPose, GaitProfile, SegmentId, CharacterKit, CharacterPack, CharacterSpec, DamageCharacter, BodyHit } from '@adatechnology/game-characters';
|
|
3
|
-
import { Vec3 as Vec3$1, DestructionEvent, TestableModule } from '@adatechnology/game-contracts';
|
|
3
|
+
import { Vec3 as Vec3$1, DestructionEvent, SoundRequest, TestableModule } from '@adatechnology/game-contracts';
|
|
4
|
+
import { SoundRecipe, SoundBank } from '@adatechnology/game-audio';
|
|
4
5
|
|
|
5
6
|
/** The three.js namespace the host passes in: the package never imports three itself, so one script tag works. */
|
|
6
7
|
type Three = typeof THREE_NS;
|
|
@@ -614,6 +615,86 @@ declare const gouge: (three: Three, materials: WoundMaterials, random: () => num
|
|
|
614
615
|
/** Arsenal `explodeSeg`: 14 chunks the size of the part, thrown from its centre along the blow. */
|
|
615
616
|
declare const explodeChunks: (three: Three, materials: WoundMaterials, random: () => number, box: THREE_NS.Box3, direction: THREE_NS.Vector3, fling: (chunk: THREE_NS.Object3D, velocity: THREE_NS.Vector3, spin: THREE_NS.Vector3) => void) => THREE_NS.Vector3;
|
|
616
617
|
|
|
618
|
+
/** The part of a fluid world the bridge needs; `FluidWorld` from `@adatechnology/game-fluids` has it. The package does not import the fluids packages. */
|
|
619
|
+
type BloodSink = {
|
|
620
|
+
splash(liquid: string, point: Vec3$1, liters: number, velocity?: Vec3$1): void;
|
|
621
|
+
};
|
|
622
|
+
/** Colours of one body's blood: the wet film and what it dries to (the infection age of a zombie: `ages.json`). */
|
|
623
|
+
type BloodLook = {
|
|
624
|
+
/** Liquid of the blood in the fluid world and in the film (default: the bridge's `liquid`). An old body can bleed `old_blood`. */
|
|
625
|
+
readonly liquid?: string;
|
|
626
|
+
readonly tint?: {
|
|
627
|
+
readonly fresh: number;
|
|
628
|
+
readonly dry: number;
|
|
629
|
+
};
|
|
630
|
+
/** How much of the blood is left, 0 to 1 (the age's `blood` factor): it scales the drops thrown into the film, so a dried-out body throws none. Default 1. */
|
|
631
|
+
readonly amount?: number;
|
|
632
|
+
};
|
|
633
|
+
/** The part of an infection age the look needs (`UndeadAge` of `@adatechnology/game-characters-undead` has all of it). */
|
|
634
|
+
type BloodAge = {
|
|
635
|
+
readonly id: string;
|
|
636
|
+
readonly blood: number;
|
|
637
|
+
readonly freshBloodColor: string;
|
|
638
|
+
readonly dryBloodColor: string;
|
|
639
|
+
};
|
|
640
|
+
type BloodLookOptions = {
|
|
641
|
+
/** Ages with a blood factor below this bleed `thinLiquid` (default 0.3: the old and the decrepit). */
|
|
642
|
+
readonly thinBelow?: number;
|
|
643
|
+
/** Liquid of the thin blood (default `old_blood`). */
|
|
644
|
+
readonly thinLiquid?: string;
|
|
645
|
+
};
|
|
646
|
+
/** The blood of an infection age: its fresh and dry colours (`ages.json`), its amount, and `old_blood` for the thin ones. */
|
|
647
|
+
declare const bloodLookOfAge: (age: BloodAge, options?: BloodLookOptions) => BloodLook;
|
|
648
|
+
/** A drop thrown into the running film of the liquids (`createFilmBridge(...)` of `@adatechnology/game-fluids-three` has it). The package does not import the fluids packages. */
|
|
649
|
+
type FilmSink = {
|
|
650
|
+
splat(splat: {
|
|
651
|
+
fluid: string;
|
|
652
|
+
point: Vec3$1;
|
|
653
|
+
direction?: Vec3$1;
|
|
654
|
+
speed?: number;
|
|
655
|
+
radius?: number;
|
|
656
|
+
count?: number;
|
|
657
|
+
tint?: {
|
|
658
|
+
fresh: number;
|
|
659
|
+
dry: number;
|
|
660
|
+
};
|
|
661
|
+
}): number;
|
|
662
|
+
};
|
|
663
|
+
/** What a `wound` throws into the film: the drops, how fast and how big. Defaults 3 drops at 2.5 m/s of 3.2 mm. */
|
|
664
|
+
type WoundSpray = {
|
|
665
|
+
readonly count?: number;
|
|
666
|
+
readonly speed?: number;
|
|
667
|
+
readonly radius?: number;
|
|
668
|
+
};
|
|
669
|
+
type FluidsBridgeOptions = {
|
|
670
|
+
readonly sink: BloodSink;
|
|
671
|
+
/** The running film: when given, a wound, a severed or destroyed segment and a split throw drops of blood into it, in the colours of the body's `BloodLook`. */
|
|
672
|
+
readonly film?: FilmSink;
|
|
673
|
+
/** Drops of a wound (`wound` change of a `body` event). */
|
|
674
|
+
readonly spray?: WoundSpray;
|
|
675
|
+
/** Drops thrown by a cut, a burst and a split (default 4, 7 and 10). */
|
|
676
|
+
readonly burstDrops?: Readonly<Record<'severed' | 'destroyed' | 'split', number>>;
|
|
677
|
+
/** Id of the blood in the fluid world. Default `blood`. */
|
|
678
|
+
readonly liquid?: string;
|
|
679
|
+
/** Metres per second a pressurised leak (a cut artery) throws its drops. Default 1.4. */
|
|
680
|
+
readonly spurtSpeed?: number;
|
|
681
|
+
};
|
|
682
|
+
type FluidsBridge = {
|
|
683
|
+
/** Reads a body's events: `leak` (bleeding) becomes blood on the surface below. Other events are ignored. */
|
|
684
|
+
handle(event: DestructionEvent): void;
|
|
685
|
+
/** The blood a cut, a burst or a split spills at once, at the world point the piece left from (and the drops it throws into the film, when there is one). */
|
|
686
|
+
burst(change: 'severed' | 'destroyed' | 'split', point: Vec3$1, look?: BloodLook, direction?: Vec3$1): void;
|
|
687
|
+
/** A wound that does not cut anything off (the `wound` change of the `body` event): drops of blood in the film, thrown along `direction` (default straight down). Returns how many found a grid. */
|
|
688
|
+
wound(point: Vec3$1, look?: BloodLook, direction?: Vec3$1): number;
|
|
689
|
+
/** Blood from the engine's own bleeders: `litersPerSecond` over `dt` seconds at `point`. */
|
|
690
|
+
bleed(point: Vec3$1, litersPerSecond: number, dt: number, direction?: Vec3$1, pressurized?: boolean): void;
|
|
691
|
+
};
|
|
692
|
+
/**
|
|
693
|
+
* Connects the wounds to the fluids packages, with the fluid world injected: the body keeps its own bleeders (rate, duration, spurt) and this turns them
|
|
694
|
+
* into blood, so the stains, pools and drying are the fluids' business and the character code draws none.
|
|
695
|
+
*/
|
|
696
|
+
declare const createFluidsBridge: ({ sink, film, spray, burstDrops, liquid, spurtSpeed }: FluidsBridgeOptions) => FluidsBridge;
|
|
697
|
+
|
|
617
698
|
/** The group that stands for one segment of the engine's tree on a drawn body, with what the wounds need to cut it off. */
|
|
618
699
|
type WoundNode = {
|
|
619
700
|
/** The group that leaves (its children go with it). */
|
|
@@ -633,6 +714,8 @@ type WoundBody = {
|
|
|
633
714
|
readonly root: THREE_NS.Object3D;
|
|
634
715
|
readonly rig: RichRig;
|
|
635
716
|
readonly nodes: Partial<Record<SegmentId, WoundNode>>;
|
|
717
|
+
/** The colours this body bleeds in (the infection age of a zombie). Without it the bridge's liquid and the liquid's own colours. */
|
|
718
|
+
blood?: BloodLook;
|
|
636
719
|
};
|
|
637
720
|
/**
|
|
638
721
|
* Maps the rich body the best builder makes onto the engine's segments. The left side is +x, as the engine has it. The drawn body has no hand or foot
|
|
@@ -640,30 +723,82 @@ type WoundBody = {
|
|
|
640
723
|
*/
|
|
641
724
|
declare const woundBodyOf: (root: THREE_NS.Object3D) => WoundBody | undefined;
|
|
642
725
|
|
|
643
|
-
/**
|
|
644
|
-
type
|
|
645
|
-
|
|
726
|
+
/** One sound of a voice: the recipe and, for a sequence, the seconds after the first. */
|
|
727
|
+
type VoiceStep = {
|
|
728
|
+
readonly sound: string;
|
|
729
|
+
readonly delay?: number;
|
|
646
730
|
};
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
731
|
+
/**
|
|
732
|
+
* The voice of one undead type:
|
|
733
|
+
* - `origin` says where it comes from: `team` (the page has a sound for this very type), `rule` (the page's class rule applied to the type: the Brutamonte,
|
|
734
|
+
* a chase speed above 3.4, or a walker) or `extra` (the nearest sound of the pages to the voice line of `types.json`, the kit's choice);
|
|
735
|
+
* - `groan` / `gameGroan` is the groan of the art scene and of the game;
|
|
736
|
+
* - `idle` (a body that wanders or chases) and `alert` (it noticed the player or woke up) default to the groan; `special` is what the type does at its
|
|
737
|
+
* ability (the screamer's call, the leaper's jump), and `gameSpecial` its game version (the game has no leap sound, so the art scene's is kept).
|
|
738
|
+
*/
|
|
739
|
+
type UndeadVoice = {
|
|
740
|
+
readonly origin: 'team' | 'rule' | 'extra';
|
|
741
|
+
readonly groan: string;
|
|
742
|
+
readonly gameGroan: string;
|
|
743
|
+
readonly idle?: readonly VoiceStep[];
|
|
744
|
+
readonly alert?: readonly VoiceStep[];
|
|
745
|
+
readonly special?: readonly VoiceStep[];
|
|
746
|
+
readonly gameSpecial?: readonly VoiceStep[];
|
|
653
747
|
};
|
|
654
|
-
type
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
748
|
+
/** The voices of the 13 types of the Bestiario, by type id. */
|
|
749
|
+
declare const UNDEAD_VOICES: Readonly<Record<string, UndeadVoice>>;
|
|
750
|
+
declare const UNDEAD_VOICE_SOURCES: readonly string[];
|
|
751
|
+
type VoiceMoment = 'idle' | 'alert' | 'special';
|
|
752
|
+
type CharacterSoundStyle = 'art_scene' | 'game';
|
|
753
|
+
/** What a change of a body sounds like, by the `change` of the `body` event. A head or a jaw hit is brighter (`flesh_head`). */
|
|
754
|
+
type BodySoundRule = {
|
|
755
|
+
readonly sound: string;
|
|
756
|
+
readonly head?: string;
|
|
757
|
+
};
|
|
758
|
+
/** Art scene: bloodHit (cena L1084) is `flesh`, a cut is `sever` (L1127, L1143), a burst or an opened belly is `gore` (L1101, L1132). Game: the flesh class of `sfx`. */
|
|
759
|
+
declare const BODY_SOUNDS: Readonly<Record<CharacterSoundStyle, Readonly<Record<string, BodySoundRule>>>>;
|
|
760
|
+
/** What the player hears when a body grabs, bites or hurts him (cena L1350-L1352, at the listener). */
|
|
761
|
+
declare const PLAYER_SOUNDS: {
|
|
762
|
+
readonly grab: "grab";
|
|
763
|
+
readonly bite: "bite";
|
|
764
|
+
readonly hurt: "hurt";
|
|
765
|
+
};
|
|
766
|
+
/** The part of the host's sound a body needs: `play`, and `register` to put the banks in its engine (`createAudioSink(...)` has both). */
|
|
767
|
+
type CharacterSoundSink = {
|
|
768
|
+
play(request: SoundRequest): unknown;
|
|
769
|
+
register?(bank: unknown): void;
|
|
770
|
+
};
|
|
771
|
+
type CharacterSoundOptions = {
|
|
772
|
+
/** Which team answers (default `art_scene`, the kit mix). `game` plays the game's groans, scream and flesh, and the art scene for what the game lacks. */
|
|
773
|
+
readonly style?: CharacterSoundStyle;
|
|
774
|
+
/** Replaces a type's voice; `null` silences it. */
|
|
775
|
+
readonly voices?: Readonly<Record<string, UndeadVoice | null>>;
|
|
776
|
+
/** Replaces a `body` change's rule; `null` silences it. */
|
|
777
|
+
readonly body?: Readonly<Record<string, BodySoundRule | null>>;
|
|
778
|
+
/** The type used for an id that has no voice (default none: silent). */
|
|
779
|
+
readonly fallbackType?: string;
|
|
780
|
+
};
|
|
781
|
+
type CharacterSound = {
|
|
782
|
+
/** The steps a type plays at a moment. */
|
|
783
|
+
stepsOf(typeId: string, moment: VoiceMoment): readonly VoiceStep[];
|
|
784
|
+
/** Plays the voice of a type at a moment where the body is. Returns how many sounds were started or queued. */
|
|
785
|
+
voice(typeId: string, moment: VoiceMoment, position: Vec3$1, volume?: number): number;
|
|
786
|
+
/** Reads a `body` event of a body at `position`: a wound is flesh, a cut is `sever`, a burst or a split is `gore`. Other events are ignored. Returns true when a sound was asked for. */
|
|
787
|
+
body(event: DestructionEvent, position: Vec3$1, volume?: number): boolean;
|
|
788
|
+
/** The player is grabbed, bitten or hurt (heard at the listener). */
|
|
789
|
+
player(kind: keyof typeof PLAYER_SOUNDS, volume?: number): void;
|
|
790
|
+
/** Runs the sequences (the screamer's inhale, then the call): call it each frame. */
|
|
791
|
+
update(dt: number): void;
|
|
792
|
+
/** Sounds waiting for their time. */
|
|
793
|
+
readonly pending: () => number;
|
|
794
|
+
dispose(): void;
|
|
661
795
|
};
|
|
662
796
|
/**
|
|
663
|
-
*
|
|
664
|
-
*
|
|
797
|
+
* Plays the sounds of the bodies on the host's sound: the voices of the undead types (the Bestiario's 13), what a wound sounds like and what the player
|
|
798
|
+
* hears. The banks are registered in the host's engine, the sounds are positional, and the groans go through the engine's `undead_voice` limiter
|
|
799
|
+
* (five at once, one every 0.25 s, nearer than 40 m). The team sounds are the recipes of `./recipes`; the table of who says what is data.
|
|
665
800
|
*/
|
|
666
|
-
declare
|
|
801
|
+
declare function createCharacterSound(sink: CharacterSoundSink, options?: CharacterSoundOptions): CharacterSound;
|
|
667
802
|
|
|
668
803
|
type WoundsOptions = {
|
|
669
804
|
readonly random: () => number;
|
|
@@ -672,6 +807,8 @@ type WoundsOptions = {
|
|
|
672
807
|
readonly groundAt?: (x: number, z: number) => number;
|
|
673
808
|
/** The fluids bridge, when the game has the fluids packages. Without it the wounds draw no blood on the ground. */
|
|
674
809
|
readonly bridge?: FluidsBridge;
|
|
810
|
+
/** The sounds of the bodies (`createCharacterSound`): a wound, a cut and a burst sound where the segment was. Without it the wounds are silent. */
|
|
811
|
+
readonly sound?: CharacterSound;
|
|
675
812
|
readonly materials?: WoundMaterials;
|
|
676
813
|
/** Pieces alive at once. Default 40. */
|
|
677
814
|
readonly maxPieces?: number;
|
|
@@ -767,6 +904,7 @@ type UndeadLike = {
|
|
|
767
904
|
}): DamageCharacter;
|
|
768
905
|
traitsOf(character: DamageCharacter): {
|
|
769
906
|
readonly type: string;
|
|
907
|
+
readonly age?: string;
|
|
770
908
|
readonly speeds: Readonly<Record<string, number>>;
|
|
771
909
|
} | undefined;
|
|
772
910
|
speedFor(traits: {
|
|
@@ -800,6 +938,12 @@ type CharactersTestOptions = {
|
|
|
800
938
|
readonly professions?: readonly ProfessionCard[];
|
|
801
939
|
/** Where the blood of the wounds goes (the room's fluid world: `room.fluids`). Without it the wounds draw no blood on the ground. */
|
|
802
940
|
readonly fluids?: BloodSink;
|
|
941
|
+
/** The running film of the liquids (the room's `room.film`): wounds throw drops of blood into it, in the colours `bloodOf` gives. Without it only the fluid world gets blood. */
|
|
942
|
+
readonly film?: FilmSink;
|
|
943
|
+
/** The sounds of the bodies on the room's engine (`host.audio`): wounds, cuts and the voices of the bench. `false` leaves the area silent. */
|
|
944
|
+
readonly sound?: false | CharacterSoundOptions;
|
|
945
|
+
/** The blood of a body by its infection age (`bloodLookOfAge` over the content's ages). Bodies without an age, and games without this option, bleed the liquid's own colours. */
|
|
946
|
+
readonly bloodOf?: (age: string) => BloodLook | undefined;
|
|
803
947
|
/** Seed of the draws of the area (default 1). */
|
|
804
948
|
readonly seed?: number;
|
|
805
949
|
/** Crowd types to bake for the instanced field, by undead id (default walker and runner). */
|
|
@@ -873,4 +1017,10 @@ declare const registerBodyMaterial: (world: {
|
|
|
873
1017
|
readonly materials: Map<string, unknown>;
|
|
874
1018
|
}) => void;
|
|
875
1019
|
|
|
876
|
-
|
|
1020
|
+
/** The voice limiter group of the undead (`undead_voice`: five at once, one every 0.25 s, nearer than 40 m). */
|
|
1021
|
+
declare const UNDEAD_VOICE_GROUP = "undead_voice";
|
|
1022
|
+
/** The sounds of the game and of the art scene for the bodies, in one bank. */
|
|
1023
|
+
declare const CHARACTER_SOUNDS: readonly SoundRecipe[];
|
|
1024
|
+
declare const CHARACTER_SOUND_BANK: SoundBank;
|
|
1025
|
+
|
|
1026
|
+
export { type AreaContext, BAKE_NEUTRAL_POSE, BODY_CHUNK, BODY_MATERIAL_DEF, BODY_SOUNDS, type BakeBuilders, type BakeSpec, type BakedBody, type BestBuilder, type BestBuilderOptions, type BestTypeCard, type BloodAge, type BloodLook, type BloodLookOptions, type BloodSink, type BodyBatch, type BodyBatchOptions, type BodyChunkOptions, type BodyInstance, type BodyJoints, type BodyMaterialParams, type BodySoundRule, type BodyVariant, type BuildInstancedBodyParams, CHARACTERS_AREA_ID, CHARACTER_SOUNDS, CHARACTER_SOUND_BANK, type CharacterSound, type CharacterSoundOptions, type CharacterSoundSink, type CharacterSoundStyle, type CharactersTestOptions, EXTRAS, type EyeOptions, type Eyes, FACE_FEATURES, type FilmSink, type FluidsBridge, type FluidsBridgeOptions, type FlyingLimb, type FlyingLimbs, type FlyingLimbsOptions, type FlyingPiece, type FlyingPieces, type FlyingPiecesOptions, HAND_ITEMS, HATS, HIT_PRESETS, type HitPreset, LOD_BAKE, LOD_BATCH_CAPACITY, LOD_CASTS_SHADOW, LOD_DISTANCES, LOD_SEGMENTS, type LimbEffects, type LimbLaunch, PENDULUM, PERSON_ITEM_PREFIX, PLAYER_SOUNDS, type Pendulum, type PersonBuilder, type PersonBuilderOptions, type PoseTargets, type ProfessionCard, type RichRig, type RigAnimator, type RigAnimatorOptions, type Three, UNDEAD_VOICES, UNDEAD_VOICE_GROUP, UNDEAD_VOICE_SOURCES, type UndeadCard, type UndeadLike, type UndeadVoice, type VariantType, type VoiceMoment, type VoiceStep, type WoundBody, type WoundMaterials, type WoundNode, type WoundSpray, type Wounds, type WoundsOptions, ZOMBIE_ITEM_PREFIX, bakeBody, bakeVariants, blobGeometry, blobRadii, bloodLookOfAge, buildInstancedBody, createBestBuilder, createBodyBatch, createBodyChunk, createBodyMaterial, createCharacterSound, createCharactersTestModule, createEye, createFluidsBridge, createFlyingLimbs, createFlyingPieces, createGlowTexture, createPendulum, createPersonBuilder, createRigAnimator, createVariantBatches, createWoundMaterials, createWounds, exitWound, explodeChunks, findEyes, gouge, jointsOf, lodAt, makeCut, makeStump, registerBodyMaterial, ringWound, starGeometry, stepPendulum, woundBodyOf, woundDecal };
|