@adatechnology/game-test-room 0.19.0 → 0.19.1
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 +1 -1
- package/dist/index.global.js +140 -21
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +37 -8
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
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,6 +2952,7 @@ 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
2957
|
import { createTerrainRenderer } from "@adatechnology/game-terrain-three";
|
|
2953
2958
|
|
|
@@ -5535,6 +5540,23 @@ function createTestRoom(options) {
|
|
|
5535
5540
|
}
|
|
5536
5541
|
return m;
|
|
5537
5542
|
};
|
|
5543
|
+
let releaseBatch = null;
|
|
5544
|
+
const dropTree = (root) => {
|
|
5545
|
+
if (!root) return;
|
|
5546
|
+
if (releaseBatch) releaseBatch.push(root);
|
|
5547
|
+
else releaseObject3D2(root, { keep: scene });
|
|
5548
|
+
};
|
|
5549
|
+
const releasingTogether = (fn) => {
|
|
5550
|
+
if (releaseBatch) return fn();
|
|
5551
|
+
releaseBatch = [];
|
|
5552
|
+
try {
|
|
5553
|
+
fn();
|
|
5554
|
+
} finally {
|
|
5555
|
+
const roots = releaseBatch;
|
|
5556
|
+
releaseBatch = null;
|
|
5557
|
+
releaseObject3D2(roots, { keep: scene });
|
|
5558
|
+
}
|
|
5559
|
+
};
|
|
5538
5560
|
const removeEntry = (id) => {
|
|
5539
5561
|
const e = entries.get(id);
|
|
5540
5562
|
if (!e) return;
|
|
@@ -5551,7 +5573,10 @@ function createTestRoom(options) {
|
|
|
5551
5573
|
e.follower?.dispose?.();
|
|
5552
5574
|
if (world.has(id)) world.remove(id);
|
|
5553
5575
|
e.so.root.removeFromParent();
|
|
5576
|
+
const inner = wrapped.get(e.so.root);
|
|
5554
5577
|
letGo(e.so.root);
|
|
5578
|
+
dropTree(e.so.root);
|
|
5579
|
+
dropTree(inner);
|
|
5555
5580
|
entries.delete(id);
|
|
5556
5581
|
doors.forget(id);
|
|
5557
5582
|
rendererPieces.delete(id);
|
|
@@ -5567,12 +5592,14 @@ function createTestRoom(options) {
|
|
|
5567
5592
|
}
|
|
5568
5593
|
if (world.has(id)) world.remove(id);
|
|
5569
5594
|
p?.root.removeFromParent();
|
|
5595
|
+
dropTree(p?.root);
|
|
5570
5596
|
rendererPieces.delete(id);
|
|
5571
5597
|
splitOf.delete(id);
|
|
5572
5598
|
}
|
|
5573
5599
|
loose.length = 0;
|
|
5574
5600
|
};
|
|
5575
|
-
const clearEverything = () =>
|
|
5601
|
+
const clearEverything = () => releasingTogether(clearEverythingNow);
|
|
5602
|
+
const clearEverythingNow = () => {
|
|
5576
5603
|
if (heldEntry || heldPiece) releaseHeld();
|
|
5577
5604
|
useItemPlayer = null;
|
|
5578
5605
|
playing.length = 0;
|
|
@@ -5621,8 +5648,10 @@ function createTestRoom(options) {
|
|
|
5621
5648
|
seating.release();
|
|
5622
5649
|
pushByKey = false;
|
|
5623
5650
|
push.end();
|
|
5624
|
-
|
|
5625
|
-
|
|
5651
|
+
releasingTogether(() => {
|
|
5652
|
+
clearEverythingNow();
|
|
5653
|
+
for (const id of [...entries.keys()]) removeEntry(id);
|
|
5654
|
+
});
|
|
5626
5655
|
renderer.reset();
|
|
5627
5656
|
for (const listener of [...resetListeners]) listener();
|
|
5628
5657
|
tools.clear();
|
|
@@ -5775,11 +5804,11 @@ function createTestRoom(options) {
|
|
|
5775
5804
|
};
|
|
5776
5805
|
const reachAvatar = () => {
|
|
5777
5806
|
const doorHand = doors.handTargets();
|
|
5778
|
-
const targets = push.active ? null : heldPiece ? twistHand : handSource?.() ?? null;
|
|
5807
|
+
const targets = push.active ? null : doorHand ?? (heldPiece ? twistHand : handSource?.() ?? null);
|
|
5779
5808
|
lastHand = {
|
|
5780
5809
|
stance: push.active || doorHand ? "hold" : handStances[toolId] ?? (targets ? "hold" : "relaxed"),
|
|
5781
5810
|
triggerFinger: targets?.fingers?.index ?? null,
|
|
5782
|
-
targets: push.handTargets() ??
|
|
5811
|
+
targets: push.handTargets() ?? targets
|
|
5783
5812
|
};
|
|
5784
5813
|
if (!avatar?.reach) return;
|
|
5785
5814
|
avatar.reach(targets, { camera, keepOutside: { contact: (origin, direction, maxDistance) => rayWorld(origin, direction, maxDistance)?.distance ?? null } });
|