@adatechnology/game-animals-three 0.1.4 → 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/dist/index.d.ts +55 -2
- package/dist/index.global.js +229 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +100 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AnimalSpecies, QuadrupedSpec, TextureMarker, AnimalVisualState } from '@adatechnology/game-animals';
|
|
2
2
|
import { NodeSkin } from '@adatechnology/game-props3d';
|
|
3
3
|
import * as THREE_NS from 'three';
|
|
4
|
-
import {
|
|
4
|
+
import { SoundRecipe, SoundBank } from '@adatechnology/game-audio';
|
|
5
|
+
import { Vec3, SoundRequest, TestableModule } from '@adatechnology/game-contracts';
|
|
5
6
|
|
|
6
7
|
/** What the animation needs each frame. */
|
|
7
8
|
type AnimateParams = {
|
|
@@ -98,6 +99,56 @@ type AnimalRig = {
|
|
|
98
99
|
triangles: number;
|
|
99
100
|
};
|
|
100
101
|
|
|
102
|
+
/** `latido`: two square clicks 0.22 s apart, 520 Hz falling to 0.6, 0.12 s each. */
|
|
103
|
+
declare const DOG_BARK: SoundRecipe;
|
|
104
|
+
/** `queroquero`: three squares 0.14 s apart, 2400 Hz falling to 0.6, 0.09 s each. */
|
|
105
|
+
declare const LAPWING_CALL: SoundRecipe;
|
|
106
|
+
/** `cacarejo`: four squares 0.14 s apart, 900 Hz falling to 0.6, 0.09 s each. */
|
|
107
|
+
declare const HEN_CLUCK: SoundRecipe;
|
|
108
|
+
/** `mugido`: one sawtooth, 140 Hz falling to 0.8, 1.2 s. */
|
|
109
|
+
declare const COW_MOO: SoundRecipe;
|
|
110
|
+
declare const ANIMAL_SOUNDS: readonly SoundRecipe[];
|
|
111
|
+
declare const ANIMAL_SOUND_BANK: SoundBank;
|
|
112
|
+
|
|
113
|
+
/** The call of a species: the recipe, the seconds the page waits before the same animal calls again, and the metres its noise reaches the AI (`emitNoise`). */
|
|
114
|
+
type AnimalCall = {
|
|
115
|
+
readonly sound: string;
|
|
116
|
+
readonly cooldown: number;
|
|
117
|
+
readonly noiseMetres: number;
|
|
118
|
+
};
|
|
119
|
+
/** The calls the page delivered, by species id. The other species (horse, pig, boar, capybara, jaguar, cat, vulture, snake, rat) have none: the page gives them no sound. */
|
|
120
|
+
declare const ANIMAL_CALLS: Readonly<Record<string, AnimalCall>>;
|
|
121
|
+
declare const ANIMAL_CALL_SOURCES: readonly string[];
|
|
122
|
+
/** The part of the host's sound an animal needs: `play`, and `register` to put the bank in its engine (`createAudioSink(...)` has both). */
|
|
123
|
+
type AnimalSoundSink = {
|
|
124
|
+
play(request: SoundRequest): unknown;
|
|
125
|
+
register?(bank: unknown): void;
|
|
126
|
+
};
|
|
127
|
+
type AnimalSoundOptions = {
|
|
128
|
+
/** Replaces a species' call; `null` silences it. */
|
|
129
|
+
readonly calls?: Readonly<Record<string, AnimalCall | null>>;
|
|
130
|
+
};
|
|
131
|
+
type AnimalSound = {
|
|
132
|
+
/** The call of a species, if it has one. */
|
|
133
|
+
callOf(speciesId: string): AnimalCall | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* Makes the species call where the animal is. `key` is the animal (default the species): the same animal waits out its cooldown, and the call is
|
|
136
|
+
* refused (false) until then. Returns whether a sound was asked for.
|
|
137
|
+
*/
|
|
138
|
+
call(speciesId: string, position: Vec3, options?: {
|
|
139
|
+
readonly volume?: number;
|
|
140
|
+
readonly key?: string;
|
|
141
|
+
}): boolean;
|
|
142
|
+
/** Counts the cooldowns down: call it each frame. */
|
|
143
|
+
update(dt: number): void;
|
|
144
|
+
dispose(): void;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Plays the calls of the animals on the host's sound: the four of the Bichos do Vale (hen, lapwing, cow, dog), positional with the page's linear 70 m
|
|
148
|
+
* fall, each animal waiting out the page's cooldown. The bank is registered in the host's engine.
|
|
149
|
+
*/
|
|
150
|
+
declare function createAnimalSound(sink: AnimalSoundSink, options?: AnimalSoundOptions): AnimalSound;
|
|
151
|
+
|
|
101
152
|
type MaterialExtras = Partial<THREE_NS.MeshStandardMaterialParameters>;
|
|
102
153
|
/** The part builders of the page's `Animal` (`M`, `ball`, `limb`, `joint`, `pivot`), bound to one rig. */
|
|
103
154
|
type RigTools = {
|
|
@@ -210,6 +261,8 @@ type AnimalsTestOptions = {
|
|
|
210
261
|
readonly timeScale: number;
|
|
211
262
|
}) => OutbreakLike;
|
|
212
263
|
readonly document?: DocumentLike;
|
|
264
|
+
/** The calls of the animals on the room's engine (`host.audio`); `false` leaves the area silent. */
|
|
265
|
+
readonly sound?: false | AnimalSoundOptions;
|
|
213
266
|
/** Seed of the draws of the area (default 7, the page's). */
|
|
214
267
|
readonly seed?: number;
|
|
215
268
|
};
|
|
@@ -248,4 +301,4 @@ type AnimalsThree = {
|
|
|
248
301
|
};
|
|
249
302
|
declare const createAnimalsThree: (THREE: Three, options?: AnimalsThreeOptions) => AnimalsThree;
|
|
250
303
|
|
|
251
|
-
export { ANIMALS_AREA_ID, ANIMAL_ITEM_PREFIX, type AnimalLeg, type AnimalPivot, type AnimalRig, type AnimalWing, type AnimalsContext, type AnimalsTestOptions, type AnimalsThree, type AnimalsThreeOptions, type AnimateParams, BIRD_EXTRAS, type BirdExtra, type BirdParts, type CanvasLike, type DocumentLike, type ExtraContext, type LineUpOptions, type OutbreakLike, QUADRUPED_EXTRAS, type QuadrupedExtra, type QuadrupedParts, type Three, applyVisualState, createAnimalsTestModule, createAnimalsThree, createCoatTexture, lineUpAnimals, profileGeometry, setJointView, setSplit, updateSplit };
|
|
304
|
+
export { ANIMALS_AREA_ID, ANIMAL_CALLS, ANIMAL_CALL_SOURCES, ANIMAL_ITEM_PREFIX, ANIMAL_SOUNDS, ANIMAL_SOUND_BANK, type AnimalCall, type AnimalLeg, type AnimalPivot, type AnimalRig, type AnimalSound, type AnimalSoundOptions, type AnimalSoundSink, type AnimalWing, type AnimalsContext, type AnimalsTestOptions, type AnimalsThree, type AnimalsThreeOptions, type AnimateParams, BIRD_EXTRAS, type BirdExtra, type BirdParts, COW_MOO, type CanvasLike, DOG_BARK, type DocumentLike, type ExtraContext, HEN_CLUCK, LAPWING_CALL, type LineUpOptions, type OutbreakLike, QUADRUPED_EXTRAS, type QuadrupedExtra, type QuadrupedParts, type Three, applyVisualState, createAnimalSound, createAnimalsTestModule, createAnimalsThree, createCoatTexture, lineUpAnimals, profileGeometry, setJointView, setSplit, updateSplit };
|
package/dist/index.global.js
CHANGED
|
@@ -22,10 +22,19 @@ var GameAnimalsThree = (() => {
|
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
24
|
ANIMALS_AREA_ID: () => ANIMALS_AREA_ID,
|
|
25
|
+
ANIMAL_CALLS: () => ANIMAL_CALLS,
|
|
26
|
+
ANIMAL_CALL_SOURCES: () => ANIMAL_CALL_SOURCES,
|
|
25
27
|
ANIMAL_ITEM_PREFIX: () => ANIMAL_ITEM_PREFIX,
|
|
28
|
+
ANIMAL_SOUNDS: () => ANIMAL_SOUNDS,
|
|
29
|
+
ANIMAL_SOUND_BANK: () => ANIMAL_SOUND_BANK,
|
|
26
30
|
BIRD_EXTRAS: () => BIRD_EXTRAS,
|
|
31
|
+
COW_MOO: () => COW_MOO,
|
|
32
|
+
DOG_BARK: () => DOG_BARK,
|
|
33
|
+
HEN_CLUCK: () => HEN_CLUCK,
|
|
34
|
+
LAPWING_CALL: () => LAPWING_CALL,
|
|
27
35
|
QUADRUPED_EXTRAS: () => QUADRUPED_EXTRAS,
|
|
28
36
|
applyVisualState: () => applyVisualState,
|
|
37
|
+
createAnimalSound: () => createAnimalSound,
|
|
29
38
|
createAnimalsTestModule: () => createAnimalsTestModule,
|
|
30
39
|
createAnimalsThree: () => createAnimalsThree,
|
|
31
40
|
createCoatTexture: () => createCoatTexture,
|
|
@@ -971,6 +980,213 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
971
980
|
});
|
|
972
981
|
};
|
|
973
982
|
|
|
983
|
+
// ../game-audio/dist/index.js
|
|
984
|
+
var DISTANCE_CURVES = {
|
|
985
|
+
/** The game's `sfx`: `vol / (1 + d² × 0.004)`, cutoff `/ (1 + d × 0.01)`, silent below 0.01 (jogo L62091–62092, L62101). */
|
|
986
|
+
game_sfx: { model: "inverse_square", k: 4e-3, cutoffK: 0.01, minGain: 0.01 },
|
|
987
|
+
/** The game's `grito`: `1 / (1 + d² × 0.006)`, silent below 0.02 (jogo L62129–62130). */
|
|
988
|
+
game_scream: { model: "inverse_square", k: 6e-3, minGain: 0.02 },
|
|
989
|
+
/** The game's `voz`: `1 / (1 + d² × 0.01)`, silent below 0.02 (jogo L62146–62147). */
|
|
990
|
+
game_voice: { model: "inverse_square", k: 0.01, minGain: 0.02 },
|
|
991
|
+
/** The game's `boom`: `1.4 / (1 + d² × 0.002)`, never silent (jogo L68280). */
|
|
992
|
+
game_boom: { model: "inverse_square", k: 2e-3, scale: 1.4 },
|
|
993
|
+
/** The art scene's `outAt`: `vol / (1 + d² × 0.008)` (cena L1320). */
|
|
994
|
+
art_scene: { model: "inverse_square", k: 8e-3 },
|
|
995
|
+
/** The game's animal calls: `max(0, 1 − d / 70) × 0.25`, silent at or below 0.005 (jogo L66627–66628). */
|
|
996
|
+
animals: { model: "linear", range: 70, scale: 0.25, minGain: 5e-3 }
|
|
997
|
+
};
|
|
998
|
+
var mix_profiles_default = [
|
|
999
|
+
{
|
|
1000
|
+
id: "game",
|
|
1001
|
+
master: 0.5,
|
|
1002
|
+
noise: { seconds: 1.5, create: "lazy" },
|
|
1003
|
+
sources: ["jogo:L62077-62081 master 0.5 to the output", "jogo:L62082-62088 noise 1.5 s made by the first sound that needs it"]
|
|
1004
|
+
},
|
|
1005
|
+
{
|
|
1006
|
+
id: "art_scene",
|
|
1007
|
+
master: 0.85,
|
|
1008
|
+
compressor: { threshold: -12, ratio: 5 },
|
|
1009
|
+
reverb: { seconds: 2.2, decay: 3.4, wet: 0.4 },
|
|
1010
|
+
noise: { seconds: 2, create: "eager" },
|
|
1011
|
+
sources: [
|
|
1012
|
+
"cena:L1308 compressor -12 dB, ratio 5",
|
|
1013
|
+
"cena:L1309 master 0.85",
|
|
1014
|
+
"cena:L1310 convolver, impulse 2.2 s of (1 - i/len)^3.4",
|
|
1015
|
+
"cena:L1311 wet 0.4",
|
|
1016
|
+
"cena:L1312 noise 2 s made with the chain"
|
|
1017
|
+
]
|
|
1018
|
+
}
|
|
1019
|
+
];
|
|
1020
|
+
var MIX_PROFILES = Object.fromEntries(
|
|
1021
|
+
mix_profiles_default.map((profile) => [profile.id, profile])
|
|
1022
|
+
);
|
|
1023
|
+
var game_sfx_default = {
|
|
1024
|
+
sources: ["jogo:L62089-62107"],
|
|
1025
|
+
note: "The game's sfx table P: [lowpass cutoff Hz, peak gain, seconds]. Played as a noise burst with the game's distance curve (falloff game_sfx) and a 0.05 s tail. Team names in `team`.",
|
|
1026
|
+
classes: [
|
|
1027
|
+
{ id: "pistol", team: "pistola", bus: "weapons", cutoff: 1800, gain: 0.9, seconds: 0.18 },
|
|
1028
|
+
{ id: "shotgun", team: "escopeta", bus: "weapons", cutoff: 900, gain: 1.2, seconds: 0.35 },
|
|
1029
|
+
{ id: "rifle", team: "fuzil", bus: "weapons", cutoff: 1400, gain: 1.1, seconds: 0.28 },
|
|
1030
|
+
{ id: "long_rifle", team: "rifle", bus: "weapons", cutoff: 1100, gain: 1.3, seconds: 0.45 },
|
|
1031
|
+
{ id: "impact", team: "impacto", bus: "world", cutoff: 2500, gain: 0.25, seconds: 0.05 },
|
|
1032
|
+
{ id: "flesh", team: "carne", bus: "world", cutoff: 600, gain: 0.35, seconds: 0.08 },
|
|
1033
|
+
{ id: "step", team: "passo", bus: "world", cutoff: 400, gain: 0.08, seconds: 0.05 },
|
|
1034
|
+
{ id: "glass", team: "vidro", bus: "world", cutoff: 5e3, gain: 0.5, seconds: 0.3 },
|
|
1035
|
+
{ id: "wood", team: "madeira", bus: "world", cutoff: 700, gain: 0.5, seconds: 0.2 },
|
|
1036
|
+
{ id: "reload", team: "recarga", bus: "weapons", cutoff: 3e3, gain: 0.15, seconds: 0.06 },
|
|
1037
|
+
{ id: "empty", team: "vazio", bus: "weapons", cutoff: 4e3, gain: 0.12, seconds: 0.03 },
|
|
1038
|
+
{ id: "explosion", team: "explosao", bus: "world", cutoff: 200, gain: 1.6, seconds: 1.4 }
|
|
1039
|
+
],
|
|
1040
|
+
fallback: { id: "unknown", team: "(any other name)", bus: "world", cutoff: 1e3, gain: 0.5, seconds: 0.1 }
|
|
1041
|
+
};
|
|
1042
|
+
var GAME_SFX = game_sfx_default;
|
|
1043
|
+
var GAME_SFX_CLASSES = GAME_SFX.classes;
|
|
1044
|
+
var GAME_SFX_FALLBACK = GAME_SFX.fallback;
|
|
1045
|
+
function noiseClassRecipe(row, id = `sfx_${row.id}`) {
|
|
1046
|
+
return {
|
|
1047
|
+
id,
|
|
1048
|
+
bus: row.bus,
|
|
1049
|
+
order: "burst",
|
|
1050
|
+
duration: row.seconds,
|
|
1051
|
+
tail: 0.05,
|
|
1052
|
+
layers: [
|
|
1053
|
+
{
|
|
1054
|
+
source: { kind: "noise", offset: "random" },
|
|
1055
|
+
filters: { mode: "serial", bank: [{ type: "lowpass", frequency: { set: row.cutoff } }] },
|
|
1056
|
+
envelope: [
|
|
1057
|
+
[0, row.gain, "set"],
|
|
1058
|
+
["1d", 1e-3, "exp", "fixed"]
|
|
1059
|
+
]
|
|
1060
|
+
}
|
|
1061
|
+
],
|
|
1062
|
+
falloff: DISTANCE_CURVES.game_sfx,
|
|
1063
|
+
sources: [...GAME_SFX.sources.map((source) => `${source} ${row.team}`)]
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
var GAME_SFX_BANK = { id: "game_sfx", sounds: [...GAME_SFX_CLASSES, GAME_SFX_FALLBACK].map((row) => noiseClassRecipe(row)) };
|
|
1067
|
+
var BENCH_BANK = {
|
|
1068
|
+
id: "audio_bench",
|
|
1069
|
+
sounds: [
|
|
1070
|
+
{
|
|
1071
|
+
id: "bench_ping",
|
|
1072
|
+
bus: "ui",
|
|
1073
|
+
pan: true,
|
|
1074
|
+
duration: 0.25,
|
|
1075
|
+
layers: [
|
|
1076
|
+
{
|
|
1077
|
+
gain: 0.5,
|
|
1078
|
+
wet: 0.3,
|
|
1079
|
+
source: { kind: "osc", wave: "sine", frequency: { from: 880 } },
|
|
1080
|
+
envelope: [
|
|
1081
|
+
[0, 1e-4, "set", "fixed"],
|
|
1082
|
+
[2e-3, 1, "exp"],
|
|
1083
|
+
["1d", 1e-4, "exp", "fixed"]
|
|
1084
|
+
]
|
|
1085
|
+
}
|
|
1086
|
+
],
|
|
1087
|
+
falloff: DISTANCE_CURVES.art_scene,
|
|
1088
|
+
sources: ["sdk: bench probe, a 880 Hz ping through the art scene output stage"]
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
id: "bench_hiss",
|
|
1092
|
+
bus: "ui",
|
|
1093
|
+
pan: true,
|
|
1094
|
+
duration: [0.3, 0.9],
|
|
1095
|
+
layers: [
|
|
1096
|
+
{
|
|
1097
|
+
gain: 0.4,
|
|
1098
|
+
source: { kind: "noise", offset: "random", offsetScale: 1.5, loop: true },
|
|
1099
|
+
filters: { mode: "serial", bank: [{ type: "highpass", frequency: { set: 3e3 }, q: 0.7 }] },
|
|
1100
|
+
envelope: [
|
|
1101
|
+
[0, 1e-4, "set", "fixed"],
|
|
1102
|
+
[2e-3, 1, "exp"],
|
|
1103
|
+
["1d", 1e-4, "exp", "fixed"]
|
|
1104
|
+
]
|
|
1105
|
+
}
|
|
1106
|
+
],
|
|
1107
|
+
falloff: DISTANCE_CURVES.art_scene,
|
|
1108
|
+
sources: ["sdk: bench probe, a highpass hiss of random length"]
|
|
1109
|
+
}
|
|
1110
|
+
]
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
// src/audio/recipes.ts
|
|
1114
|
+
var call = (o) => ({
|
|
1115
|
+
id: o.id,
|
|
1116
|
+
bus: "world",
|
|
1117
|
+
order: "calls",
|
|
1118
|
+
duration: o.seconds,
|
|
1119
|
+
tail: 0.02,
|
|
1120
|
+
// the page makes its gain and filter before it looks at the level
|
|
1121
|
+
keepSilent: true,
|
|
1122
|
+
layers: [
|
|
1123
|
+
{
|
|
1124
|
+
repeat: { count: o.count, spacing: o.spacing },
|
|
1125
|
+
source: { kind: "osc", wave: o.wave, frequency: { from: o.frequency, to: o.frequency * o.drop, curve: "exp", over: "duration" } },
|
|
1126
|
+
filters: { mode: "serial", bank: [{ type: "bandpass", frequency: { set: o.frequency * 1.2 }, q: 3 }] },
|
|
1127
|
+
envelope: [
|
|
1128
|
+
[0, 1e-4, "set", "fixed"],
|
|
1129
|
+
[0.015, 1, "exp"],
|
|
1130
|
+
["1d", 1e-4, "exp", "fixed"]
|
|
1131
|
+
]
|
|
1132
|
+
}
|
|
1133
|
+
],
|
|
1134
|
+
falloff: DISTANCE_CURVES.animals,
|
|
1135
|
+
sources: [`jogo:L66625-66639 bichoSom('${o.team}')`]
|
|
1136
|
+
});
|
|
1137
|
+
var DOG_BARK = call({ id: "dog_bark", team: "latido", count: 2, spacing: 0.22, seconds: 0.12, wave: "square", frequency: 520, drop: 0.6 });
|
|
1138
|
+
var LAPWING_CALL = call({ id: "lapwing_call", team: "queroquero", count: 3, spacing: 0.14, seconds: 0.09, wave: "square", frequency: 2400, drop: 0.6 });
|
|
1139
|
+
var HEN_CLUCK = call({ id: "hen_cluck", team: "cacarejo", count: 4, spacing: 0.14, seconds: 0.09, wave: "square", frequency: 900, drop: 0.6 });
|
|
1140
|
+
var COW_MOO = call({ id: "cow_moo", team: "mugido", count: 1, spacing: 0.14, seconds: 1.2, wave: "sawtooth", frequency: 140, drop: 0.8 });
|
|
1141
|
+
var ANIMAL_SOUNDS = [DOG_BARK, LAPWING_CALL, HEN_CLUCK, COW_MOO];
|
|
1142
|
+
var ANIMAL_SOUND_BANK = { id: "animals_three", sounds: ANIMAL_SOUNDS };
|
|
1143
|
+
|
|
1144
|
+
// src/audio/calls.json
|
|
1145
|
+
var calls_default = {
|
|
1146
|
+
sources: [
|
|
1147
|
+
"jogo:L66677 galinha: cacarejo, 6 s between calls, noise 30 m",
|
|
1148
|
+
"jogo:L66680 quero-quero: queroquero when the player is near (alarme), 8 s, noise 40 m",
|
|
1149
|
+
"jogo:L66681 vaca: mugido, 30 s, noise 80 m",
|
|
1150
|
+
"jogo:L66683 cachorro: latido when a zombie is within 12 m, 3 s, noise 60 m"
|
|
1151
|
+
],
|
|
1152
|
+
species: {
|
|
1153
|
+
chicken: { sound: "hen_cluck", cooldown: 6, noiseMetres: 30 },
|
|
1154
|
+
southern_lapwing: { sound: "lapwing_call", cooldown: 8, noiseMetres: 40 },
|
|
1155
|
+
cow: { sound: "cow_moo", cooldown: 30, noiseMetres: 80 },
|
|
1156
|
+
dog: { sound: "dog_bark", cooldown: 3, noiseMetres: 60 }
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
// src/audio/sound.ts
|
|
1161
|
+
var DATA = calls_default;
|
|
1162
|
+
var ANIMAL_CALLS = DATA.species;
|
|
1163
|
+
var ANIMAL_CALL_SOURCES = DATA.sources;
|
|
1164
|
+
function createAnimalSound(sink, options = {}) {
|
|
1165
|
+
sink.register?.(ANIMAL_SOUND_BANK);
|
|
1166
|
+
const calls = { ...ANIMAL_CALLS, ...options.calls };
|
|
1167
|
+
const waiting = /* @__PURE__ */ new Map();
|
|
1168
|
+
const callOf = (speciesId) => calls[speciesId] ?? void 0;
|
|
1169
|
+
return {
|
|
1170
|
+
callOf,
|
|
1171
|
+
call(speciesId, position, o = {}) {
|
|
1172
|
+
const found = callOf(speciesId);
|
|
1173
|
+
if (!found) return false;
|
|
1174
|
+
const key = o.key ?? speciesId;
|
|
1175
|
+
if ((waiting.get(key) ?? 0) > 0) return false;
|
|
1176
|
+
waiting.set(key, found.cooldown);
|
|
1177
|
+
sink.play({ sound: found.sound, position, ...o.volume === void 0 ? {} : { volume: o.volume } });
|
|
1178
|
+
return true;
|
|
1179
|
+
},
|
|
1180
|
+
update(dt) {
|
|
1181
|
+
for (const [key, seconds] of waiting) {
|
|
1182
|
+
if (seconds - dt <= 0) waiting.delete(key);
|
|
1183
|
+
else waiting.set(key, seconds - dt);
|
|
1184
|
+
}
|
|
1185
|
+
},
|
|
1186
|
+
dispose: () => waiting.clear()
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
|
|
974
1190
|
// src/line-up.ts
|
|
975
1191
|
var lineUpAnimals = (rigs, options = {}) => {
|
|
976
1192
|
const start = options.start ?? -19;
|
|
@@ -1073,7 +1289,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
1073
1289
|
time_scale: "Game seconds per real second for the bite timers (60: ten minutes pass in ten seconds)"
|
|
1074
1290
|
},
|
|
1075
1291
|
options: { visual_state: { alive: "Alive", infected: "Infected", dead: "Dead" }, gait: { idle: "Idle", walk: "Walk", run: "Run" } },
|
|
1076
|
-
actions: { bite_all: "Bite every animal", recover: "Heal every animal", skin_40: "Add 40 animals as node skins", clear_skins: "Remove the skins" },
|
|
1292
|
+
actions: { bite_all: "Bite every animal", recover: "Heal every animal", call: "Make the animals with a call call (hen, lapwing, cow, dog)", skin_40: "Add 40 animals as node skins", clear_skins: "Remove the skins" },
|
|
1077
1293
|
layers: { joints: "Joints", split: "Split view", sound_range: "Sound range", carcass_lure: "Carcass lure radius" },
|
|
1078
1294
|
metrics: { animals: "Animals", draw_calls: "Draw calls", triangles: "Triangles", nodes_per_skin: "Nodes per skin", incubating: "Incubating", turned: "Turned", dead: "Dead" },
|
|
1079
1295
|
scenarios: {
|
|
@@ -1096,7 +1312,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
1096
1312
|
time_scale: "Segundos de jogo por segundo real nos prazos da mordida (60: dez minutos passam em dez segundos)"
|
|
1097
1313
|
},
|
|
1098
1314
|
options: { visual_state: { alive: "Vivo", infected: "Infectado", dead: "Morto" }, gait: { idle: "Parado", walk: "Andando", run: "Correndo" } },
|
|
1099
|
-
actions: { bite_all: "Morder todos os bichos", recover: "Curar todos os bichos", skin_40: "P\xF4r 40 bichos como pele de n\xF3s", clear_skins: "Tirar as peles" },
|
|
1315
|
+
actions: { bite_all: "Morder todos os bichos", recover: "Curar todos os bichos", call: "Fazer os bichos com chamado chamarem (galinha, quero-quero, vaca, cachorro)", skin_40: "P\xF4r 40 bichos como pele de n\xF3s", clear_skins: "Tirar as peles" },
|
|
1100
1316
|
layers: { joints: "Juntas", split: "Vista aberta", sound_range: "Alcance do som", carcass_lure: "Raio de atra\xE7\xE3o da carca\xE7a" },
|
|
1101
1317
|
metrics: { animals: "Bichos", draw_calls: "Chamadas de desenho", triangles: "Tri\xE2ngulos", nodes_per_skin: "N\xF3s por pele", incubating: "Incubando", turned: "Viraram", dead: "Morreram" },
|
|
1102
1318
|
scenarios: {
|
|
@@ -1125,6 +1341,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
1125
1341
|
let animals = null;
|
|
1126
1342
|
let host = null;
|
|
1127
1343
|
let outbreak = null;
|
|
1344
|
+
let sound = null;
|
|
1128
1345
|
let time = 0;
|
|
1129
1346
|
let clock = 0;
|
|
1130
1347
|
let skinGroup = null;
|
|
@@ -1227,6 +1444,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
1227
1444
|
delete entry.counted;
|
|
1228
1445
|
animals?.setVisualState(entry.rig, settings.visual);
|
|
1229
1446
|
}
|
|
1447
|
+
} else if (change.id === "call" && sound) {
|
|
1448
|
+
for (const [id, entry] of placed) {
|
|
1449
|
+
const at = entry.rig.root.getWorldPosition(new three.Vector3());
|
|
1450
|
+
sound.call(entry.rig.species.id, [at.x, at.y + 0.5, at.z], { key: id });
|
|
1451
|
+
}
|
|
1230
1452
|
} else if (change.id === "skin_40") addSkins();
|
|
1231
1453
|
else if (change.id === "clear_skins") clearSkins();
|
|
1232
1454
|
return;
|
|
@@ -1257,6 +1479,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
1257
1479
|
const frame = (dt) => {
|
|
1258
1480
|
time += dt * settings.speed;
|
|
1259
1481
|
clock += dt;
|
|
1482
|
+
sound?.update(dt);
|
|
1260
1483
|
for (const [id, entry] of placed) {
|
|
1261
1484
|
if (!entry.rig.root.parent) {
|
|
1262
1485
|
placed.delete(id);
|
|
@@ -1334,6 +1557,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
1334
1557
|
{ kind: "number", id: "time_scale", name: text.controls.time_scale, hint: text.hints.time_scale, min: 1, max: 600, step: 1, default: DEFAULT_TIME_SCALE },
|
|
1335
1558
|
{ kind: "action", id: "bite_all", name: text.actions.bite_all },
|
|
1336
1559
|
{ kind: "action", id: "recover", name: text.actions.recover },
|
|
1560
|
+
{ kind: "action", id: "call", name: text.actions.call },
|
|
1337
1561
|
{ kind: "action", id: "skin_40", name: text.actions.skin_40 },
|
|
1338
1562
|
{ kind: "action", id: "clear_skins", name: text.actions.clear_skins }
|
|
1339
1563
|
],
|
|
@@ -1351,6 +1575,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
1351
1575
|
attach(lent) {
|
|
1352
1576
|
host = lent;
|
|
1353
1577
|
ensure(lent.THREE);
|
|
1578
|
+
sound = lent.audio && options.sound !== false ? createAnimalSound(lent.audio, options.sound ?? {}) : null;
|
|
1354
1579
|
const stopChange = lent.bench?.onChange(onChange);
|
|
1355
1580
|
const stopFrame = lent.onFrame(frame);
|
|
1356
1581
|
return () => {
|
|
@@ -1358,6 +1583,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
1358
1583
|
stopFrame();
|
|
1359
1584
|
clearRings();
|
|
1360
1585
|
clearSkins();
|
|
1586
|
+
sound?.dispose();
|
|
1587
|
+
sound = null;
|
|
1361
1588
|
host = null;
|
|
1362
1589
|
};
|
|
1363
1590
|
}
|