@adatechnology/game-test-room 0.19.0 → 0.20.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 +2 -2
- package/dist/index.d.ts +16 -1
- package/dist/index.global.js +743 -134
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +78 -9
- package/dist/index.js.map +1 -1
- package/package.json +14 -13
package/dist/index.js
CHANGED
|
@@ -472,6 +472,7 @@ function buildFromSpec(THREE, spec, options = {}) {
|
|
|
472
472
|
}
|
|
473
473
|
|
|
474
474
|
// src/explosives.ts
|
|
475
|
+
import { releaseObject3D } from "@adatechnology/game-shapes-three";
|
|
475
476
|
import { ExplosiveBody, backblastEffect, blastEffect, createExplosiveBody, tripwireSegment } from "@adatechnology/game-weapons";
|
|
476
477
|
|
|
477
478
|
// src/segment-box.ts
|
|
@@ -514,9 +515,13 @@ function createExplosives(context) {
|
|
|
514
515
|
const projectiles = [];
|
|
515
516
|
const meshes = [];
|
|
516
517
|
const up = new THREE.Vector3(0, 1, 0);
|
|
518
|
+
const drop = (objects) => {
|
|
519
|
+
for (const object of objects) object.removeFromParent();
|
|
520
|
+
releaseObject3D(objects, { keep: scene });
|
|
521
|
+
};
|
|
517
522
|
const clear = () => {
|
|
518
523
|
projectiles.length = 0;
|
|
519
|
-
|
|
524
|
+
drop(meshes);
|
|
520
525
|
meshes.length = 0;
|
|
521
526
|
};
|
|
522
527
|
const addMesh = (geometry, color, metalness, at) => {
|
|
@@ -540,13 +545,12 @@ function createExplosives(context) {
|
|
|
540
545
|
};
|
|
541
546
|
const remove = (projectile) => {
|
|
542
547
|
for (const extra of projectile.attached ?? []) {
|
|
543
|
-
extra.removeFromParent();
|
|
544
548
|
const extraAt = meshes.indexOf(extra);
|
|
545
549
|
if (extraAt >= 0) meshes.splice(extraAt, 1);
|
|
546
550
|
}
|
|
547
|
-
projectile.mesh.removeFromParent();
|
|
548
551
|
const meshAt = meshes.indexOf(projectile.mesh);
|
|
549
552
|
if (meshAt >= 0) meshes.splice(meshAt, 1);
|
|
553
|
+
drop([...projectile.attached ?? [], projectile.mesh]);
|
|
550
554
|
const at = projectiles.indexOf(projectile);
|
|
551
555
|
if (at >= 0) projectiles.splice(at, 1);
|
|
552
556
|
};
|
|
@@ -2948,8 +2952,9 @@ function createRoomDoors(options) {
|
|
|
2948
2952
|
}
|
|
2949
2953
|
|
|
2950
2954
|
// src/room.ts
|
|
2955
|
+
import { releaseObject3D as releaseObject3D2 } from "@adatechnology/game-shapes-three";
|
|
2951
2956
|
import { createTerrain, createTerrainImpl, DEFAULT_PROFILE } from "@adatechnology/game-terrain";
|
|
2952
|
-
import { createTerrainRenderer } from "@adatechnology/game-terrain-three";
|
|
2957
|
+
import { createTerrainRenderer, terrainProfileName } from "@adatechnology/game-terrain-three";
|
|
2953
2958
|
|
|
2954
2959
|
// src/avatar.ts
|
|
2955
2960
|
var DEFAULT_STRIKE_CLIPS = { hand: "punch_right", fists: "punch_right", shove: "shove_two_hands", kick: "front_kick" };
|
|
@@ -3320,6 +3325,8 @@ var en = {
|
|
|
3320
3325
|
"ins.damage": "Marks",
|
|
3321
3326
|
"ins.damage_counts": "{dents}, {holes}, {cracks}",
|
|
3322
3327
|
"ins.mass": "Mass",
|
|
3328
|
+
"ins.dug": "Dug",
|
|
3329
|
+
"ins.dig_limit": "Ground left to dig",
|
|
3323
3330
|
"ins.load": "Load",
|
|
3324
3331
|
"ins.stress": "Stress",
|
|
3325
3332
|
"ins.joints": "Joints",
|
|
@@ -3668,6 +3675,8 @@ var ptBR = {
|
|
|
3668
3675
|
"ins.damage": "Marcas",
|
|
3669
3676
|
"ins.damage_counts": "{dents}, {holes}, {cracks}",
|
|
3670
3677
|
"ins.mass": "Massa",
|
|
3678
|
+
"ins.dug": "Escavado",
|
|
3679
|
+
"ins.dig_limit": "Ch\xE3o at\xE9 o limite",
|
|
3671
3680
|
"ins.load": "Carga",
|
|
3672
3681
|
"ins.stress": "Tens\xE3o",
|
|
3673
3682
|
"ins.joints": "Juntas",
|
|
@@ -4555,6 +4564,15 @@ function createUi(o) {
|
|
|
4555
4564
|
insp.appendChild(mk3("div", void 0, t("ui.aim_at_something")));
|
|
4556
4565
|
return;
|
|
4557
4566
|
}
|
|
4567
|
+
if (i.ground) {
|
|
4568
|
+
const g = i.ground;
|
|
4569
|
+
insp.appendChild(mk3("div", "t", `${i.object} \u203A ${g.surface}`));
|
|
4570
|
+
insp.appendChild(row(t("ins.material"), g.material));
|
|
4571
|
+
insp.appendChild(row(t("ins.dug"), `${num(g.dug * 100, 0)} cm`));
|
|
4572
|
+
insp.appendChild(row(t("ins.dig_limit"), `${num(g.remaining, 2)} m`));
|
|
4573
|
+
if (g.scorch > 0.01) insp.appendChild(row(t("ins.char"), `${num(g.scorch * 100, 0)} %`));
|
|
4574
|
+
return;
|
|
4575
|
+
}
|
|
4558
4576
|
if (i.thumbnail) insp.appendChild(thumb(i.thumbnail, i.thumbnailCredit));
|
|
4559
4577
|
insp.appendChild(mk3("div", "t", `${i.object} \u203A ${i.part}`));
|
|
4560
4578
|
insp.appendChild(row(t("ins.material"), i.material));
|
|
@@ -5535,6 +5553,23 @@ function createTestRoom(options) {
|
|
|
5535
5553
|
}
|
|
5536
5554
|
return m;
|
|
5537
5555
|
};
|
|
5556
|
+
let releaseBatch = null;
|
|
5557
|
+
const dropTree = (root) => {
|
|
5558
|
+
if (!root) return;
|
|
5559
|
+
if (releaseBatch) releaseBatch.push(root);
|
|
5560
|
+
else releaseObject3D2(root, { keep: scene });
|
|
5561
|
+
};
|
|
5562
|
+
const releasingTogether = (fn) => {
|
|
5563
|
+
if (releaseBatch) return fn();
|
|
5564
|
+
releaseBatch = [];
|
|
5565
|
+
try {
|
|
5566
|
+
fn();
|
|
5567
|
+
} finally {
|
|
5568
|
+
const roots = releaseBatch;
|
|
5569
|
+
releaseBatch = null;
|
|
5570
|
+
releaseObject3D2(roots, { keep: scene });
|
|
5571
|
+
}
|
|
5572
|
+
};
|
|
5538
5573
|
const removeEntry = (id) => {
|
|
5539
5574
|
const e = entries.get(id);
|
|
5540
5575
|
if (!e) return;
|
|
@@ -5551,7 +5586,10 @@ function createTestRoom(options) {
|
|
|
5551
5586
|
e.follower?.dispose?.();
|
|
5552
5587
|
if (world.has(id)) world.remove(id);
|
|
5553
5588
|
e.so.root.removeFromParent();
|
|
5589
|
+
const inner = wrapped.get(e.so.root);
|
|
5554
5590
|
letGo(e.so.root);
|
|
5591
|
+
dropTree(e.so.root);
|
|
5592
|
+
dropTree(inner);
|
|
5555
5593
|
entries.delete(id);
|
|
5556
5594
|
doors.forget(id);
|
|
5557
5595
|
rendererPieces.delete(id);
|
|
@@ -5567,12 +5605,14 @@ function createTestRoom(options) {
|
|
|
5567
5605
|
}
|
|
5568
5606
|
if (world.has(id)) world.remove(id);
|
|
5569
5607
|
p?.root.removeFromParent();
|
|
5608
|
+
dropTree(p?.root);
|
|
5570
5609
|
rendererPieces.delete(id);
|
|
5571
5610
|
splitOf.delete(id);
|
|
5572
5611
|
}
|
|
5573
5612
|
loose.length = 0;
|
|
5574
5613
|
};
|
|
5575
|
-
const clearEverything = () =>
|
|
5614
|
+
const clearEverything = () => releasingTogether(clearEverythingNow);
|
|
5615
|
+
const clearEverythingNow = () => {
|
|
5576
5616
|
if (heldEntry || heldPiece) releaseHeld();
|
|
5577
5617
|
useItemPlayer = null;
|
|
5578
5618
|
playing.length = 0;
|
|
@@ -5621,8 +5661,10 @@ function createTestRoom(options) {
|
|
|
5621
5661
|
seating.release();
|
|
5622
5662
|
pushByKey = false;
|
|
5623
5663
|
push.end();
|
|
5624
|
-
|
|
5625
|
-
|
|
5664
|
+
releasingTogether(() => {
|
|
5665
|
+
clearEverythingNow();
|
|
5666
|
+
for (const id of [...entries.keys()]) removeEntry(id);
|
|
5667
|
+
});
|
|
5626
5668
|
renderer.reset();
|
|
5627
5669
|
for (const listener of [...resetListeners]) listener();
|
|
5628
5670
|
tools.clear();
|
|
@@ -5775,11 +5817,11 @@ function createTestRoom(options) {
|
|
|
5775
5817
|
};
|
|
5776
5818
|
const reachAvatar = () => {
|
|
5777
5819
|
const doorHand = doors.handTargets();
|
|
5778
|
-
const targets = push.active ? null : heldPiece ? twistHand : handSource?.() ?? null;
|
|
5820
|
+
const targets = push.active ? null : doorHand ?? (heldPiece ? twistHand : handSource?.() ?? null);
|
|
5779
5821
|
lastHand = {
|
|
5780
5822
|
stance: push.active || doorHand ? "hold" : handStances[toolId] ?? (targets ? "hold" : "relaxed"),
|
|
5781
5823
|
triggerFinger: targets?.fingers?.index ?? null,
|
|
5782
|
-
targets: push.handTargets() ??
|
|
5824
|
+
targets: push.handTargets() ?? targets
|
|
5783
5825
|
};
|
|
5784
5826
|
if (!avatar?.reach) return;
|
|
5785
5827
|
avatar.reach(targets, { camera, keepOutside: { contact: (origin, direction, maxDistance) => rayWorld(origin, direction, maxDistance)?.distance ?? null } });
|
|
@@ -6889,9 +6931,36 @@ function createTestRoom(options) {
|
|
|
6889
6931
|
if (!leaf) return void 0;
|
|
6890
6932
|
return t(leaf.locked ? "hud.door_hint_locked" : leaf.open ? "hud.door_hint_close" : "hud.door_hint_open");
|
|
6891
6933
|
};
|
|
6934
|
+
const groundInspect = (r) => {
|
|
6935
|
+
const onFloor = terrain.raycast(aimO, aimD, r.distance + 3);
|
|
6936
|
+
const [x, , z] = onFloor?.point ?? r.point;
|
|
6937
|
+
const column = terrain.columnAt(x, z);
|
|
6938
|
+
const materialName = S.text[`material.${column.material}`] ?? dStrings.materialNames[column.material] ?? column.material;
|
|
6939
|
+
return {
|
|
6940
|
+
object: t("ground.name"),
|
|
6941
|
+
objectId: GROUND_ID,
|
|
6942
|
+
part: column.profile,
|
|
6943
|
+
material: materialName,
|
|
6944
|
+
status: "",
|
|
6945
|
+
hp: 0,
|
|
6946
|
+
maxHp: 0,
|
|
6947
|
+
temperature: 0,
|
|
6948
|
+
burning: false,
|
|
6949
|
+
char: column.scorch,
|
|
6950
|
+
melt: 0,
|
|
6951
|
+
dents: 0,
|
|
6952
|
+
holes: 0,
|
|
6953
|
+
cracks: 0,
|
|
6954
|
+
mass: 0,
|
|
6955
|
+
joints: [],
|
|
6956
|
+
distance: onFloor?.distance ?? r.distance,
|
|
6957
|
+
ground: { surface: terrainProfileName(column.profile, locale), material: materialName, dug: column.depth, remaining: column.remaining, scorch: column.scorch }
|
|
6958
|
+
};
|
|
6959
|
+
};
|
|
6892
6960
|
const inspectInfo = () => {
|
|
6893
6961
|
const r = inspectTarget();
|
|
6894
6962
|
if (!r) return null;
|
|
6963
|
+
if (r.object === GROUND_ID) return groundInspect(r);
|
|
6895
6964
|
const st = world.state(r.object);
|
|
6896
6965
|
const p = world.part(r.object, r.part);
|
|
6897
6966
|
if (!st || !p) return null;
|