@adatechnology/game-characters-three 0.5.1 → 0.7.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/dist/index.d.ts +91 -18
- package/dist/index.global.js +457 -110
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +458 -110
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -287,6 +287,8 @@ type RichRig = {
|
|
|
287
287
|
readonly fig: Node3;
|
|
288
288
|
readonly upper: Node3;
|
|
289
289
|
readonly headG: Node3;
|
|
290
|
+
/** The neck cylinder, taken by identity; absent when the head is cut off. */
|
|
291
|
+
readonly neck?: Node3;
|
|
290
292
|
readonly arms: RigArm[];
|
|
291
293
|
readonly legs: RigLeg[];
|
|
292
294
|
readonly dangles: {
|
|
@@ -1026,6 +1028,26 @@ declare const UNDEAD_VOICE_GROUP = "undead_voice";
|
|
|
1026
1028
|
declare const CHARACTER_SOUNDS: readonly SoundRecipe[];
|
|
1027
1029
|
declare const CHARACTER_SOUND_BANK: SoundBank;
|
|
1028
1030
|
|
|
1031
|
+
/**
|
|
1032
|
+
* The eye the hands are seen from, given per call to `apply` (null or none is the body seen from outside: nothing changes). `reachBend` keeps the elbow bent where a hand is out of reach, the hand stopping
|
|
1033
|
+
* short instead of the arm locking; `keepOutside` pulls a hand back so it stays in front of the surface `contact` finds along the camera's forward.
|
|
1034
|
+
*/
|
|
1035
|
+
type ReachView = {
|
|
1036
|
+
readonly camera: THREE_NS.Object3D;
|
|
1037
|
+
/** The least interior bend of the elbow, radians, right then left. Default `ARM_REACH.viewBend`. */
|
|
1038
|
+
readonly reachBend?: readonly [number, number];
|
|
1039
|
+
readonly keepOutside?: {
|
|
1040
|
+
/** The distance to the surface from `origin` along `direction` within `maxDistance`, or null. */
|
|
1041
|
+
contact(origin: [number, number, number], direction: [number, number, number], maxDistance: number): number | null;
|
|
1042
|
+
/** Default `ARM_REACH.contactMargin`. */
|
|
1043
|
+
readonly margin?: number;
|
|
1044
|
+
/** Default `ARM_REACH.contactNearest`. */
|
|
1045
|
+
readonly nearest?: number;
|
|
1046
|
+
};
|
|
1047
|
+
};
|
|
1048
|
+
|
|
1049
|
+
type AvatarViewMode = 'first' | 'third';
|
|
1050
|
+
|
|
1029
1051
|
type PlayerAvatarSpec = Record<string, unknown>;
|
|
1030
1052
|
type PlayerAvatarOptions = {
|
|
1031
1053
|
/** The body spec for the rich builder (`createBestBuilder.build`). Default: the team game's player (`player-avatar.json`). Merged over the default. */
|
|
@@ -1045,6 +1067,10 @@ type PlayerAvatarOptions = {
|
|
|
1045
1067
|
* still be on their way when it ends (a punch that never reaches the shoulder). 1 keeps the walk's pace. Default 5.
|
|
1046
1068
|
*/
|
|
1047
1069
|
readonly clipCascade?: number;
|
|
1070
|
+
/** Where the eye sits against the builder's eye point, in the head's frame (so it follows the head's scale and turn). Default [0, -0.068, 0]: about 1.70 m standing. */
|
|
1071
|
+
readonly eyeOffset?: readonly [number, number, number];
|
|
1072
|
+
/** How much of the walking and running bob of the body reaches the eye: 0 none, 1 all of it. Default 0.5. */
|
|
1073
|
+
readonly eyeBob?: number;
|
|
1048
1074
|
};
|
|
1049
1075
|
type AvatarEvent = PoseClipEvent & {
|
|
1050
1076
|
clip: string;
|
|
@@ -1053,6 +1079,8 @@ type AvatarItemUsePose = {
|
|
|
1053
1079
|
readonly id: string;
|
|
1054
1080
|
readonly position: readonly [number, number, number];
|
|
1055
1081
|
readonly rotation: readonly [number, number, number];
|
|
1082
|
+
/** How closed the other hand is (0 open to 1 closed) when it works on the item, as a hand turning a cap off opens between strokes; the room brings it there with `reach`. */
|
|
1083
|
+
readonly gripL?: number;
|
|
1056
1084
|
};
|
|
1057
1085
|
type AvatarUpdate = {
|
|
1058
1086
|
/** Ground speed, m/s. Ties cadence and swing to the ground (the game's `walkCad` and `walkGait`). */
|
|
@@ -1076,6 +1104,21 @@ type AvatarUpdate = {
|
|
|
1076
1104
|
readonly phase: 'grip' | 'push' | 'strain';
|
|
1077
1105
|
readonly progress: number;
|
|
1078
1106
|
} | null;
|
|
1107
|
+
/** On a seat: `sit` folds the legs under hips `hip` metres above the feet, `lie` lays the body face up with the pelvis there, the head behind the facing. */
|
|
1108
|
+
seat?: {
|
|
1109
|
+
readonly pose: 'sit' | 'lie';
|
|
1110
|
+
readonly hip: number;
|
|
1111
|
+
} | null;
|
|
1112
|
+
/**
|
|
1113
|
+
* A hand on a door, lid or drawer: `reach` to the handle, `swing` with it (`pull` toward the body or pushed away), `release` back, `rattle` on a locked one.
|
|
1114
|
+
* `height` is the hand over the feet, metres (a fridge handle, a car door, a low drawer).
|
|
1115
|
+
*/
|
|
1116
|
+
door?: {
|
|
1117
|
+
readonly phase: 'reach' | 'swing' | 'release' | 'rattle';
|
|
1118
|
+
readonly progress: number;
|
|
1119
|
+
readonly height: number;
|
|
1120
|
+
readonly pull: boolean;
|
|
1121
|
+
} | null;
|
|
1079
1122
|
};
|
|
1080
1123
|
type PlayPoseOptions = {
|
|
1081
1124
|
onEvent?: (event: AvatarEvent) => void;
|
|
@@ -1098,11 +1141,26 @@ type PlayerAvatar = {
|
|
|
1098
1141
|
/** The three.js namespace the body was made with, so what is made to fit it (the first-person arms) uses the same one. */
|
|
1099
1142
|
readonly three: Three;
|
|
1100
1143
|
update(dt: number, state?: AvatarUpdate): void;
|
|
1144
|
+
/**
|
|
1145
|
+
* The world position of the eyes, as `update` left them: sampled at its end, before any `reach()` (which turns the chest and would swing the head), and kept in the
|
|
1146
|
+
* body's own frame so it stays right when the host moves `root` afterwards. With `out` it fills that vector instead of making one.
|
|
1147
|
+
*/
|
|
1148
|
+
eye(out?: THREE_NS.Vector3): THREE_NS.Vector3;
|
|
1149
|
+
/** In 'first' with a camera, the head and neck are not drawn for that camera only (shadows, mirrors and every other camera still see them); 'third' draws them. */
|
|
1150
|
+
setView(mode: AvatarViewMode, camera: THREE_NS.Object3D | null): void;
|
|
1101
1151
|
play(clip: string | PoseClip, options?: PlayPoseOptions): void;
|
|
1102
1152
|
stop(): void;
|
|
1103
1153
|
readonly playing: string | null;
|
|
1104
1154
|
/** A socket at the hand: 'R' is the weapon hand (the puppet's right, at -x), 'L' the other one. */
|
|
1105
1155
|
hand(side: 'R' | 'L'): THREE_NS.Object3D;
|
|
1156
|
+
/** The joint of a shoulder ('R' the weapon side, at -x): where a long gun's stock rests, just inside it. */
|
|
1157
|
+
shoulder(side: 'R' | 'L'): THREE_NS.Object3D;
|
|
1158
|
+
/**
|
|
1159
|
+
* Brings the hands to where the tool in them asks (`HandTargets`, world space) after `update`: shoulder, elbow and wrist each bend inside the human range, the chest turns and the shoulder
|
|
1160
|
+
* blade slides toward a hand out of reach. Null, a strike playing or the body going down leave the arms as `update` posed them. Call it after the tool is placed and the root moved.
|
|
1161
|
+
* `view` (given on each call, as the camera moves) is for the body seen from its own eyes: the elbows keep their bend and the hands stay out of walls; without it nothing changes.
|
|
1162
|
+
*/
|
|
1163
|
+
reach(targets: HandTargets | null, view?: ReachView | null): void;
|
|
1106
1164
|
on(type: 'event', listener: (event: AvatarEvent) => void): () => void;
|
|
1107
1165
|
dispose(): void;
|
|
1108
1166
|
};
|
|
@@ -1138,6 +1196,17 @@ type FirstPersonRig = {
|
|
|
1138
1196
|
fore: number;
|
|
1139
1197
|
/** How far (m) a shoulder may move toward a hand it cannot reach, so long tools stay in the hands. 0 keeps the shoulders where they are. */
|
|
1140
1198
|
reachShift: number;
|
|
1199
|
+
/**
|
|
1200
|
+
* The elbow bend (radians, 0 straight) an arm keeps when its shoulder comes forward to a far hand, right then left: the shoulder stops short of a straight arm, so the
|
|
1201
|
+
* elbow and the wrist read on screen. Leave it out to stretch the arm to its full length first.
|
|
1202
|
+
*/
|
|
1203
|
+
reachBend?: readonly [number, number];
|
|
1204
|
+
/**
|
|
1205
|
+
* Holding a tool, the way from the wrist to the elbow (camera space, right arm then left; x right, y up, -z ahead): the elbow is put there, kept inside the view, and the shoulder
|
|
1206
|
+
* behind it out of the view, so the bend of the arm shows on screen (a trigger elbow out to the side, a support elbow out under the forend). Leave it out to keep the
|
|
1207
|
+
* shoulders fixed and bend the elbows toward `elbowPole`; null for one arm keeps that arm so (a support hand cups a handguard from below, its elbow under the view).
|
|
1208
|
+
*/
|
|
1209
|
+
elbowView?: readonly [Triple | null, Triple | null];
|
|
1141
1210
|
/** From the wrist (where the sleeve ends) to the middle of the palm. */
|
|
1142
1211
|
wrist: number;
|
|
1143
1212
|
/** The way the elbow bends, for the right arm; mirrored for the left. */
|
|
@@ -1258,23 +1327,27 @@ type RoomAvatarLike = {
|
|
|
1258
1327
|
readonly phase: 'grip' | 'push' | 'strain';
|
|
1259
1328
|
readonly progress: number;
|
|
1260
1329
|
} | null;
|
|
1330
|
+
door?: {
|
|
1331
|
+
readonly phase: 'reach' | 'swing' | 'release' | 'rattle';
|
|
1332
|
+
readonly progress: number;
|
|
1333
|
+
readonly height: number;
|
|
1334
|
+
readonly pull: boolean;
|
|
1335
|
+
} | null;
|
|
1261
1336
|
holding?: boolean;
|
|
1262
1337
|
itemUse?: AvatarItemUsePose | null;
|
|
1338
|
+
seat?: {
|
|
1339
|
+
readonly pose: 'sit' | 'lie';
|
|
1340
|
+
readonly hip: number;
|
|
1341
|
+
} | null;
|
|
1263
1342
|
}): void;
|
|
1264
1343
|
hand(side: 'R' | 'L'): THREE_NS.Object3D;
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
speed: number;
|
|
1273
|
-
running: boolean;
|
|
1274
|
-
crouch: boolean;
|
|
1275
|
-
contact?(origin: [number, number, number], direction: [number, number, number], maxDistance: number): number | null;
|
|
1276
|
-
}): void;
|
|
1277
|
-
};
|
|
1344
|
+
shoulder(side: 'R' | 'L'): THREE_NS.Object3D;
|
|
1345
|
+
/** Where the body's eyes are after its pose (`RoomAvatar.eye`): the room draws the body in both views and puts the first-person camera there. */
|
|
1346
|
+
eye(out?: THREE_NS.Vector3): THREE_NS.Vector3;
|
|
1347
|
+
/** Hides the head and neck from `camera` in first person (`RoomAvatar.setView`). */
|
|
1348
|
+
setView(mode: AvatarViewMode, camera: THREE_NS.Object3D | null): void;
|
|
1349
|
+
/** Brings the body's hands to the tool in them, in both views; `view` keeps them in the first-person view (`RoomAvatar.reach`). */
|
|
1350
|
+
reach(targets: HandTargets | null, view?: ReachView | null): void;
|
|
1278
1351
|
/** Plays a strike on the body and the arms and answers the seconds to its impact (`RoomAvatar.strike`). */
|
|
1279
1352
|
strike(clipId: string, options?: {
|
|
1280
1353
|
leg?: 'left' | 'right';
|
|
@@ -1282,11 +1355,11 @@ type RoomAvatarLike = {
|
|
|
1282
1355
|
}): number | null;
|
|
1283
1356
|
/** The avatar it wraps. */
|
|
1284
1357
|
readonly avatar: PlayerAvatar;
|
|
1285
|
-
/**
|
|
1358
|
+
/** Separate first-person arms, only when `toRoomAvatar` was asked for them (`firstPerson`); the room draws the body in both views and does not use them. */
|
|
1286
1359
|
readonly arms: FirstPersonArms | null;
|
|
1287
1360
|
};
|
|
1288
1361
|
type ToRoomAvatarOptions = {
|
|
1289
|
-
/**
|
|
1362
|
+
/** Separate first-person arms (the options of `createFirstPersonArms`, merged over the colours of the body and `firstPersonClips`); default none: the body is the first-person view. */
|
|
1290
1363
|
firstPerson?: false | FirstPersonArmsOptions;
|
|
1291
1364
|
/** The third-person strike clips `strike` finds by id. Default `ATTACK_CLIPS` of game-characters-people. */
|
|
1292
1365
|
strikeClips?: readonly PoseClip[];
|
|
@@ -1301,8 +1374,8 @@ type ToRoomAvatarOptions = {
|
|
|
1301
1374
|
};
|
|
1302
1375
|
/**
|
|
1303
1376
|
* Fits the player's body to the test room's `RoomAvatar` (`room.setAvatar(toRoomAvatar(createPlayerAvatar(THREE)))`). It changes the sign of the pitch: the room
|
|
1304
|
-
* counts a look up as positive, the team game's `view.pitch` (what `AvatarUpdate.pitch` reads) counts a look down as positive.
|
|
1305
|
-
*
|
|
1377
|
+
* counts a look up as positive, the team game's `view.pitch` (what `AvatarUpdate.pitch` reads) counts a look down as positive. The same body is the first-person view (`eye`, `setView`;
|
|
1378
|
+
* separate arms only with `firstPerson`), and `strike(clipId)` plays the strike on the body (the attack clips) and answers the seconds to its
|
|
1306
1379
|
* impact, which are the same in both views. A kick with the left leg (`leg: 'left'`) or a punch with the left hand (`hand: 'left'`) plays the mirror of the clip written for the right.
|
|
1307
1380
|
* After a punch the body holds the guard (`guardClip`) for `guardHold` seconds while it stands, so the next punch leaves from the guard.
|
|
1308
1381
|
*/
|
|
@@ -1380,4 +1453,4 @@ type TwoBone = {
|
|
|
1380
1453
|
*/
|
|
1381
1454
|
declare const solveTwoBone: (root: THREE_NS.Vector3, target: THREE_NS.Vector3, upper: number, lower: number, pole: THREE_NS.Vector3, out: TwoBone) => TwoBone;
|
|
1382
1455
|
|
|
1383
|
-
export { AVATAR_AREA_ID, type AreaContext, type AvatarEvent, type AvatarItemUsePose, type AvatarTestOptions, type AvatarUpdate, 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, FIRST_PERSON_BOB, FIRST_PERSON_COLORS, FIRST_PERSON_RIG, FIRST_PERSON_STANCES, type FilmSink, type FirstPersonArms, type FirstPersonArmsOptions, type FirstPersonArmsState, type FirstPersonBob, type FirstPersonColors, type FirstPersonEvent, type FirstPersonRig, 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 PlayPoseOptions, type PlayerAvatar, type PlayerAvatarColors, type PlayerAvatarOptions, type PlayerAvatarSpec, type PoseTargets, type ProfessionCard, type RestPose, type RichRig, type RigAnimator, type RigAnimatorOptions, type RoomAvatarLike, type StanceDef, type Three, type ToRoomAvatarOptions, type TwoBone, 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, createAvatarTestModule, createBestBuilder, createBodyBatch, createBodyChunk, createBodyMaterial, createCharacterSound, createCharactersTestModule, createEye, createFirstPersonArms, createFluidsBridge, createFlyingLimbs, createFlyingPieces, createGlowTexture, createPendulum, createPersonBuilder, createPlayerAvatar, createRigAnimator, createVariantBatches, createWoundMaterials, createWounds, exitWound, explodeChunks, findEyes, gouge, jointsOf, lodAt, makeCut, makeStump, personSpecOf, registerBodyMaterial, ringWound, solveTwoBone, starGeometry, stepPendulum, toRoomAvatar, woundBodyOf, woundDecal };
|
|
1456
|
+
export { AVATAR_AREA_ID, type AreaContext, type AvatarEvent, type AvatarItemUsePose, type AvatarTestOptions, type AvatarUpdate, type AvatarViewMode, 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, FIRST_PERSON_BOB, FIRST_PERSON_COLORS, FIRST_PERSON_RIG, FIRST_PERSON_STANCES, type FilmSink, type FirstPersonArms, type FirstPersonArmsOptions, type FirstPersonArmsState, type FirstPersonBob, type FirstPersonColors, type FirstPersonEvent, type FirstPersonRig, 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 PlayPoseOptions, type PlayerAvatar, type PlayerAvatarColors, type PlayerAvatarOptions, type PlayerAvatarSpec, type PoseTargets, type ProfessionCard, type ReachView, type RestPose, type RichRig, type RigAnimator, type RigAnimatorOptions, type RoomAvatarLike, type StanceDef, type Three, type ToRoomAvatarOptions, type TwoBone, 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, createAvatarTestModule, createBestBuilder, createBodyBatch, createBodyChunk, createBodyMaterial, createCharacterSound, createCharactersTestModule, createEye, createFirstPersonArms, createFluidsBridge, createFlyingLimbs, createFlyingPieces, createGlowTexture, createPendulum, createPersonBuilder, createPlayerAvatar, createRigAnimator, createVariantBatches, createWoundMaterials, createWounds, exitWound, explodeChunks, findEyes, gouge, jointsOf, lodAt, makeCut, makeStump, personSpecOf, registerBodyMaterial, ringWound, solveTwoBone, starGeometry, stepPendulum, toRoomAvatar, woundBodyOf, woundDecal };
|