@dcl-regenesislabs/bevy-explorer-web 0.1.0-23518073781.commit-c2a8f95 → 0.1.0-23535937137.commit-af71852
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/.env +1 -1
- package/engine.js +10 -0
- package/index.html +1 -1
- package/package.json +3 -3
- package/pkg/manifest.json +1 -1
- package/pkg/webgpu_build_bg.wasm +0 -0
- package/sceneUtils.js +85 -0
package/.env
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
PUBLIC_URL="https://cdn.decentraland.org/@dcl-regenesislabs/bevy-explorer-web/0.1.0-
|
|
1
|
+
PUBLIC_URL="https://cdn.decentraland.org/@dcl-regenesislabs/bevy-explorer-web/0.1.0-23535937137.commit-af71852"
|
package/engine.js
CHANGED
|
@@ -310,5 +310,15 @@ export function start() {
|
|
|
310
310
|
|
|
311
311
|
engine_run(platform, realmValue, positionValue, systemScene, true, preview, 1e7);
|
|
312
312
|
window.engine_console_command = engine_console_command;
|
|
313
|
+
window.loadSceneUtils = () => {
|
|
314
|
+
return new Promise((resolve, reject) => {
|
|
315
|
+
const basePath = window.location.pathname.replace(/\/$/, '');
|
|
316
|
+
const s = document.createElement('script');
|
|
317
|
+
s.src = new URL(`${basePath}/sceneUtils.js`, window.location.origin);
|
|
318
|
+
s.onload = () => { console.log('sceneUtils loaded'); resolve(); };
|
|
319
|
+
s.onerror = () => reject(new Error('failed to load sceneUtils.js'));
|
|
320
|
+
document.head.appendChild(s);
|
|
321
|
+
});
|
|
322
|
+
};
|
|
313
323
|
setTimeout(showCanvas, 200);
|
|
314
324
|
}
|
package/index.html
CHANGED
|
@@ -411,7 +411,7 @@
|
|
|
411
411
|
}
|
|
412
412
|
</style>
|
|
413
413
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
|
|
414
|
-
<script>window.PUBLIC_URL = "https://cdn.decentraland.org/@dcl-regenesislabs/bevy-explorer-web/0.1.0-
|
|
414
|
+
<script>window.PUBLIC_URL = "https://cdn.decentraland.org/@dcl-regenesislabs/bevy-explorer-web/0.1.0-23535937137.commit-af71852";</script>
|
|
415
415
|
</head>
|
|
416
416
|
<body>
|
|
417
417
|
<div id="header" class="container">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl-regenesislabs/bevy-explorer-web",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-23535937137.commit-af71852",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"postinstall": "node ./scripts/prebuild.js"
|
|
6
6
|
},
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/decentraland/bevy-explorer.git"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://cdn.decentraland.org/@dcl-regenesislabs/bevy-explorer-web/0.1.0-
|
|
12
|
-
"commit": "
|
|
11
|
+
"homepage": "https://cdn.decentraland.org/@dcl-regenesislabs/bevy-explorer-web/0.1.0-23535937137.commit-af71852",
|
|
12
|
+
"commit": "af718526abb2326821e9b5ecfafde2236339491d"
|
|
13
13
|
}
|
package/pkg/manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"wasmSize":
|
|
1
|
+
{"wasmSize":118230828}
|
package/pkg/webgpu_build_bg.wasm
CHANGED
|
Binary file
|
package/sceneUtils.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Scene utility functions for the browser console.
|
|
2
|
+
// Requires `engine_console_command` to be available on `window`.
|
|
3
|
+
|
|
4
|
+
async function findEntitiesByDistance(componentName) {
|
|
5
|
+
const snapshot = await engine_console_command("/crdt_snapshot").then(JSON.parse);
|
|
6
|
+
|
|
7
|
+
// Use the player entity (id=1) from the snapshot for scene-local position
|
|
8
|
+
const playerPos = snapshot["1"]?.Transform
|
|
9
|
+
? getGlobalPosition("1", snapshot)
|
|
10
|
+
: { x: 0, y: 0, z: 0 };
|
|
11
|
+
|
|
12
|
+
const results = [];
|
|
13
|
+
for (const [eid, components] of Object.entries(snapshot)) {
|
|
14
|
+
if (componentName && !components[componentName]) continue;
|
|
15
|
+
if (eid === "1" || eid === "0" || eid === "2") continue; // skip reserved entities
|
|
16
|
+
const pos = getGlobalPosition(eid, snapshot);
|
|
17
|
+
const dx = pos.x - playerPos.x, dy = pos.y - playerPos.y, dz = pos.z - playerPos.z;
|
|
18
|
+
results.push({
|
|
19
|
+
entity: eid,
|
|
20
|
+
position: pos,
|
|
21
|
+
dist: Math.sqrt(dx * dx + dy * dy + dz * dz),
|
|
22
|
+
components,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return results.sort((a, b) => a.dist - b.dist);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getGlobalPosition(entityId, snapshot) {
|
|
29
|
+
const chain = [];
|
|
30
|
+
let current = entityId;
|
|
31
|
+
while (current && current !== "0") {
|
|
32
|
+
const t = snapshot[current]?.Transform;
|
|
33
|
+
if (!t) break;
|
|
34
|
+
chain.push(t);
|
|
35
|
+
current = t.parent != null ? String(t.parent) : "0";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let gx = 0, gy = 0, gz = 0;
|
|
39
|
+
let rot = { x: 0, y: 0, z: 0, w: 1 };
|
|
40
|
+
let sx = 1, sy = 1, sz = 1;
|
|
41
|
+
for (let i = chain.length - 1; i >= 0; i--) {
|
|
42
|
+
const { position: p, rotation: r, scale: s } = chain[i];
|
|
43
|
+
const scaled = { x: p.x * sx, y: p.y * sy, z: p.z * sz };
|
|
44
|
+
const v = rotateByQuat(scaled, rot);
|
|
45
|
+
gx += v.x; gy += v.y; gz += v.z;
|
|
46
|
+
rot = multiplyQuat(rot, r);
|
|
47
|
+
sx *= s.x; sy *= s.y; sz *= s.z;
|
|
48
|
+
}
|
|
49
|
+
return { x: gx, y: gy, z: gz };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function rotateByQuat(v, q) {
|
|
53
|
+
const ix = q.w * v.x + q.y * v.z - q.z * v.y;
|
|
54
|
+
const iy = q.w * v.y + q.z * v.x - q.x * v.z;
|
|
55
|
+
const iz = q.w * v.z + q.x * v.y - q.y * v.x;
|
|
56
|
+
const iw = -q.x * v.x - q.y * v.y - q.z * v.z;
|
|
57
|
+
return {
|
|
58
|
+
x: ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y,
|
|
59
|
+
y: iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z,
|
|
60
|
+
z: iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function multiplyQuat(a, b) {
|
|
65
|
+
return {
|
|
66
|
+
x: a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,
|
|
67
|
+
y: a.w * b.y + a.y * b.w + a.z * b.x - a.x * b.z,
|
|
68
|
+
z: a.w * b.z + a.z * b.w + a.x * b.y - a.y * b.x,
|
|
69
|
+
w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function printEntitiesByDistance(componentName) {
|
|
74
|
+
return findEntitiesByDistance(componentName).then(results =>
|
|
75
|
+
console.table(
|
|
76
|
+
results.map(r => ({
|
|
77
|
+
entity: r.entity,
|
|
78
|
+
x: r.position.x.toFixed(2),
|
|
79
|
+
y: r.position.y.toFixed(2),
|
|
80
|
+
z: r.position.z.toFixed(2),
|
|
81
|
+
dist: r.dist.toFixed(2),
|
|
82
|
+
}))
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
}
|