@adatechnology/game-test-room 0.7.0 → 0.8.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 +13 -1
- package/dist/index.global.js +1788 -102
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +25 -4
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
package/dist/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// src/room.ts
|
|
2
2
|
import { createDestruction, JOINT_DEFAULTS as JOINT_DEFAULTS2, resolveStrings as resolveDestructionStrings } from "@adatechnology/game-destruction";
|
|
3
|
-
import {
|
|
3
|
+
import { createAudioEngine, createAudioSink } from "@adatechnology/game-audio";
|
|
4
|
+
import { createDestructionRenderer, createDestructionSound, specFromObject3D } from "@adatechnology/game-destruction-three";
|
|
4
5
|
import { createArsenal, DEFAULT_LOADOUT } from "@adatechnology/game-weapons";
|
|
5
6
|
import { createFilmLcg, createFluids, createItemUse, ITEM_USES, resolveStrings as resolveFluidStrings } from "@adatechnology/game-fluids";
|
|
6
7
|
import { createFilmBridge, createFilmManager, createFluidRenderer } from "@adatechnology/game-fluids-three";
|
|
7
8
|
import { createGroundField, createVfx } from "@adatechnology/game-vfx";
|
|
8
9
|
import { createGroundPatch, createVfxRenderer } from "@adatechnology/game-vfx-three";
|
|
9
|
-
import { checkAnimation, checkBench, checkDestructible, checkSpec } from "@adatechnology/game-contracts";
|
|
10
|
+
import { checkAnimation, checkBench, checkDestructible, checkSpec, createEnvironmentBus } from "@adatechnology/game-contracts";
|
|
10
11
|
|
|
11
12
|
// src/items.ts
|
|
12
13
|
import { buildFrame } from "@adatechnology/game-destruction";
|
|
@@ -3871,6 +3872,13 @@ function createTestRoom(options) {
|
|
|
3871
3872
|
let simTime = 0;
|
|
3872
3873
|
const log = createLog({ exportCancelled: () => t("log.export_cancelled") });
|
|
3873
3874
|
log.setClock(() => simTime);
|
|
3875
|
+
const ownAudio = options.audio === void 0;
|
|
3876
|
+
const audio = options.audio === false ? null : options.audio ?? createAudioEngine();
|
|
3877
|
+
const destructionSound = audio ? createDestructionSound(audio) : null;
|
|
3878
|
+
const playSound = (key, point, volume) => {
|
|
3879
|
+
destructionSound?.onSound(key, point, volume);
|
|
3880
|
+
options.onSound?.(key, point, volume);
|
|
3881
|
+
};
|
|
3874
3882
|
const craterField = options.craters ? createGroundField() : void 0;
|
|
3875
3883
|
const craterPatch = craterField ? createGroundPatch(THREE, { field: craterField, material: new THREE.MeshStandardMaterial({ color: 9342602, roughness: 0.95 }) }) : void 0;
|
|
3876
3884
|
if (craterPatch) {
|
|
@@ -3897,7 +3905,7 @@ function createTestRoom(options) {
|
|
|
3897
3905
|
quality,
|
|
3898
3906
|
groundAt,
|
|
3899
3907
|
pointScale,
|
|
3900
|
-
onSound:
|
|
3908
|
+
onSound: playSound,
|
|
3901
3909
|
onPiece: (piece) => {
|
|
3902
3910
|
rendererPieces.set(piece.objectId, piece);
|
|
3903
3911
|
loose.push(piece);
|
|
@@ -5120,6 +5128,10 @@ function createTestRoom(options) {
|
|
|
5120
5128
|
s.update(dt);
|
|
5121
5129
|
flushEvents(id, s);
|
|
5122
5130
|
}
|
|
5131
|
+
if (audio) {
|
|
5132
|
+
const look = camera.getWorldDirection(listenerDirection);
|
|
5133
|
+
audio.setListener({ position: [camera.position.x, camera.position.y, camera.position.z], yaw: Math.atan2(-look.x, -look.z) });
|
|
5134
|
+
}
|
|
5123
5135
|
for (const update2 of frameListeners) update2(dt);
|
|
5124
5136
|
for (const tr of tracers) {
|
|
5125
5137
|
if (tr.life > 0) {
|
|
@@ -5229,7 +5241,7 @@ function createTestRoom(options) {
|
|
|
5229
5241
|
const ev = evs[pl.fired++];
|
|
5230
5242
|
action("animation_event", t("act.anim_event", { name: pl.entry.name, clip: pl.clip.id, type: ev.type }), { objectId: pl.entry.so.objectId, itemId: pl.entry.so.itemId, data: { clip: pl.clip.id, type: ev.type, at: ev.t, ...ev.data ?? {} } });
|
|
5231
5243
|
const key = ev.type === "sound" ? ev.data?.key : void 0;
|
|
5232
|
-
if (typeof key === "string")
|
|
5244
|
+
if (typeof key === "string") playSound(key, v3(pl.entry.so.root.getWorldPosition(tmpV)), 1);
|
|
5233
5245
|
}
|
|
5234
5246
|
if (pl.t >= pl.clip.duration) {
|
|
5235
5247
|
playing.splice(i, 1);
|
|
@@ -5322,6 +5334,9 @@ function createTestRoom(options) {
|
|
|
5322
5334
|
};
|
|
5323
5335
|
const hostListeners = /* @__PURE__ */ new Set();
|
|
5324
5336
|
const frameListeners = /* @__PURE__ */ new Set();
|
|
5337
|
+
const listenerDirection = new THREE.Vector3();
|
|
5338
|
+
const environment = options.environment ?? createEnvironmentBus();
|
|
5339
|
+
const audioSink = audio ? createAudioSink(audio) : void 0;
|
|
5325
5340
|
function emitHost(event) {
|
|
5326
5341
|
for (const listener of hostListeners) listener(event);
|
|
5327
5342
|
}
|
|
@@ -5371,6 +5386,8 @@ function createTestRoom(options) {
|
|
|
5371
5386
|
scene,
|
|
5372
5387
|
camera,
|
|
5373
5388
|
locale,
|
|
5389
|
+
...audioSink ? { audio: audioSink } : {},
|
|
5390
|
+
environment,
|
|
5374
5391
|
groundAt,
|
|
5375
5392
|
effects: vfx,
|
|
5376
5393
|
tool: () => ({
|
|
@@ -5624,6 +5641,8 @@ function createTestRoom(options) {
|
|
|
5624
5641
|
arsenal,
|
|
5625
5642
|
fluids,
|
|
5626
5643
|
fluidRenderer: fluidView,
|
|
5644
|
+
audio,
|
|
5645
|
+
environment,
|
|
5627
5646
|
log,
|
|
5628
5647
|
get tool() {
|
|
5629
5648
|
return tool;
|
|
@@ -5717,6 +5736,8 @@ function createTestRoom(options) {
|
|
|
5717
5736
|
return { room: roomMetrics.sample(), module: moduleMetrics() };
|
|
5718
5737
|
},
|
|
5719
5738
|
dispose() {
|
|
5739
|
+
destructionSound?.dispose();
|
|
5740
|
+
if (ownAudio) audio?.dispose();
|
|
5720
5741
|
for (const detach of detachers.values()) detach();
|
|
5721
5742
|
detachers.clear();
|
|
5722
5743
|
for (const store of benches.values()) store.dispose();
|