Skip to content

The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.

Client hooks: GameSession::files lists the voxel level's files too (Bugbot)

Evan (Yifeng) Wang51d8ccbee67d
diff --git a/renderer/src/script.rs b/renderer/src/script.rs
index 6de8e9c..ec53a8a 100644
--- a/renderer/src/script.rs
+++ b/renderer/src/script.rs
@@ -525,9 +525,12 @@ impl GameSession {
Self::load(bundle, room)?.open_loaded(assets, core)
}
- /// Files the built scene reads from the asset root (models, file textures, procedural assets).
+ /// Files the built scene reads from the asset root (models, file textures, procedural assets) and the voxel level
+ /// it asked for (`voxelLevel`, loaded later by `realize_voxels`), sorted, each once.
pub fn files(&self) -> Vec<String> {
- self.host.world.borrow().files()
+ let mut set: std::collections::BTreeSet<String> = self.host.world.borrow().files().into_iter().collect();
+ set.extend(self.host.voxels.borrow().files());
+ set.into_iter().collect()
}
/// Opens the first live view of a loaded session (`load_code`).
diff --git a/renderer/src/voxel.rs b/renderer/src/voxel.rs
index 026956b..b451431 100644
--- a/renderer/src/voxel.rs
+++ b/renderer/src/voxel.rs
@@ -214,6 +214,12 @@ const EDIT_DEBRIS: usize = 4096;
const MAX_OCCUPANCY_WORDS: usize = 1 << 24;
impl VoxelWorld {
+ /// Files the requested level reads from the asset root (its objects' uris), before `realize` loads them: a client
+ /// that fetches the session's files first (`GameSession::files`) must fetch these too.
+ pub fn files(&self) -> Vec<String> {
+ self.pending.iter().flat_map(|d| d.objects.iter().map(|o| o.uri.clone())).collect()
+ }
+
/// Scene code's `voxelLevel`: kept until the session knows the asset root (`realize`).
pub fn request(&mut self, d: LevelDesc) -> Result<()> {
if d.route != "mesh" && d.route != "boxes" {