Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2608,6 +2608,24 @@ the code before. A test holds moves and edits in place, alone and several in a c
world as it is then (`live::inplace_tests::moves_in_place_leave_what_a_build_does`: 0.02–0.08 of an 8-bit step;
0.9 with nothing built), with one build a commit. No other picture changes (render-identity: 239 outputs).

**One proxy an object (2026-11-17, scene step B, second part).** Where what an object draws landed was spread over
fourteen maps keyed by the object: nine the build filled (its object-table entry, its card, its dynamic triangles,
its instance, whether its moves are the instance's, its rigid model, its pose group, whether its mesh is its own,
its emitter mesh, its instanced copies), four the edits kept beside them for what they placed (its record, its
value as picks test it, an instanced range, the mesh it draws) and one for procedural objects. They are one table,
`scene::Retained::proxies`: `Proxy { object, card, draw }`, `Draw` = Fixed | Dynamic | Instance | Procedural |
Rigid | Instanced. A proxy holds the object's record; the record's value is in `instances[record]` or
`procs[record - the first procedural record]`, for what an edit places as for the build's, and a record's slot is
`inst_base` + it for all of them. "An edit placed it" is its record being the room's (`EditState::in_room`); a
mesh a body drives moves as an instance because its proxy says so, whoever placed it. Lights, media and particles
keep their tables' own indices (a table a kind). No picture changes (render-identity: 239 outputs), the voxel
level's debris and batch routes time as before. Two faults went with the maps, each shown by a test first: an
instanced object the build flattened had an entry in none of them, so removing it in place did nothing and it
stayed in the picture (it has a proxy now, and is rebuilt out); an instanced object an edit added had an object
entry of its own beside its copies', so its node's power or customData wrote over copy 0's. Still two mechanisms
in what they can do: what the build flattened or placed as a model's instance is rebuilt to change, what an edit
placed is not moved unless a body drives it (step E).

## 2. Temporal fixes

Targets (2026-11-08): bench-temporal, bench-ghosting and their UE MRQ references move to Bistro night (§ 0 step 7); the
Expand Down
2 changes: 1 addition & 1 deletion docs/RUNTIME.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ runtime, and drives the engine directly, the way a UE game drives its actors:
| Engine API | `packages/scene/src/engine.ts` (`Engine`), `renderer/src/script.rs` (`__engine` natives) | Handles (u32) for geometries (typed arrays), textures (asset path, encoded image or RGBA8 pixels), material-function code, materials, objects (group / mesh / model / light / camera) and their transform, visibility, power, light / camera parameters; the environment and render settings. Descriptors are JSON-shaped (`renderer/src/desc.rs`). |
| Scene binding | `packages/scene/src/engine.ts` `SceneBinding` | Keeps the engine in step with a DSL scene. Objects report their own changes (core.ts change tracking: transforms, visibility, power, shadow flag, mesh geometry / material, add / remove), so a sync visits only what changed. Lights, cameras and materials are compared against what was last sent. |
| World | `renderer/src/world.rs` | The engine's objects, resources, environment and settings, and what changed since the last commit: parameter changes (power, light / material parameters, environment, camera) or structural ones. Asset paths must stay inside the asset root (game code is untrusted on nodes). |
| Live commit | `renderer/src/live/edits.rs` `LiveCore::commit`, `tables.rs`, `live/state.rs` | Parameter changes rewrite GPU table entries in place (materials, lights, object power, emitter CDF), and so does hiding or showing a volume, a light without a card or a particle system that is not light-sampled by its own `visible`. What is not the scene's data is held beside it and derived whole from the world, by the same function at load and on an edit (`live/state.rs`): the view's state (`ViewState`: the scene camera's lens, depth of field and exposure, which camera is the scene's, the render preset) and the environment (`Environment`: wetness, rain, fog or a background, appearing or going with another variant of the kernel; its sky, baked and put in place by `apply_sky`). What the edits of a commit change above the triangles (instances moved, meshes built again, triangles re-transformed) is built once at its end, every BLAS named and the TLAS in one call (`gpu::TopBuild`, `LiveCore::build_top`). Anything structural rebuilds the GPU scene from the world, in memory; history survives, validated per pixel. The view's size is the view's: `LiveCore::resize` makes the buffers that follow it again (`live/targets.rs`) and leaves the scene's data and the radiance cache; the window (`play`) follows its size and its display's density, the headless runner takes `{"cmd":"resize"}`. |
| Live commit | `renderer/src/live/edits.rs` `LiveCore::commit`, `tables.rs`, `live/state.rs` | Parameter changes rewrite GPU table entries in place (materials, lights, object power, emitter CDF), and so does hiding or showing a volume, a light without a card or a particle system that is not light-sampled by its own `visible`. Where what an object draws landed is its proxy (`scene::Retained::proxies`: its object-table entry and how its geometry is held, with its record), for what the build placed and what an edit placed alike; edits in place read and keep it. What is not the scene's data is held beside it and derived whole from the world, by the same function at load and on an edit (`live/state.rs`): the view's state (`ViewState`: the scene camera's lens, depth of field and exposure, which camera is the scene's, the render preset) and the environment (`Environment`: wetness, rain, fog or a background, appearing or going with another variant of the kernel; its sky, baked and put in place by `apply_sky`). What the edits of a commit change above the triangles (instances moved, meshes built again, triangles re-transformed) is built once at its end, every BLAS named and the TLAS in one call (`gpu::TopBuild`, `LiveCore::build_top`). Anything structural rebuilds the GPU scene from the world, in memory; history survives, validated per pixel. The view's size is the view's: `LiveCore::resize` makes the buffers that follow it again (`live/targets.rs`) and leaves the scene's data and the radiance cache; the window (`play`) follows its size and its display's density, the headless runner takes `{"cmd":"resize"}`. |
| Scene runtime | `renderer/src/script.rs` `ScriptHost` | QuickJS (rquickjs) with no I/O (no fs, network or timers; what needs the outside is asked of the app, "The host channel"). Loads a bundle (one script) or ES modules (`game.js` + `threert-runtime.js`, the cloud layout). Memory capped at 1 GiB. Time budgets: setup 120 s, event 1 s, frame 50 ms; the interrupt handler aborts overruns. Every entry ends by running the promise jobs it left, inside its budget ("Promises", below). The time the engine spends inside a voxel call (`voxelExplode`, `voxelEdit`, `voxelFrame`) is the engine's, not the script's: the deadline moves by it as measured, up to 250 ms an entry; past that it counts against the script, and a voxel call made after the deadline throws "interrupted" at once. A prelude adds `TextEncoder`, `structuredClone`, `atob` and `console`. |
| Node host | `packages/gameplay/src/node-host.ts` | `globalThis.__threert`: `setup(room, seed)`, `event(type, payload, ts)` (local authority: execute + commit), `commit(writes, seq)` / `setState(state, seq)` (room authority), `state()`, `frame(dt, now)`, `hostMessages(list, ts)` (the app's messages), `sync()` (the engine follows the scene once more: after an entry's promise jobs), and the editor's `outline()`, `inspect(name)`, `edit(name, path, value)`. |
| World handlers | `packages/gameplay/src/world.ts` | `on[type](world, ev)`: an event handled on this node, changing the scene at once. `WorldContext`: `scene`, `camera`, read-only `state`, `object(id)`, `time`, `now`, `random()`, `emit(type, payload)`. |
Expand Down
12 changes: 2 additions & 10 deletions renderer/src/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ impl EditRoom {
/// Whether the scene gets room (`for_scene`): editable geometry under hardware RT, or under software traversal
/// with units (`hwrt` true for them too: `lib.rs prepare`).
pub fn editable(scene: &Scene, hwrt: bool) -> bool {
hwrt && Self::reserve() > 0.0 && (!scene.procs.is_empty() || !scene.retained.own_instance.is_empty())
hwrt && Self::reserve() > 0.0 && (!scene.procs.is_empty() || scene.retained.has_own_instances())
}

/// `units`: software traversal with units, whose room does not grow (hardware traversal's does, from nothing): a
/// scene of theirs without editable geometry still gets records and object entries, for instances of the meshes
/// it has (a mesh it has not rebuilds the scene: no triangles).
pub(crate) fn for_scene(scene: &Scene, tris: usize, records: usize, hwrt: bool, units: bool) -> EditRoom {
let k = Self::reserve();
let (procs, meshes) = (!scene.procs.is_empty(), !scene.retained.own_instance.is_empty());
let (procs, meshes) = (!scene.procs.is_empty(), scene.retained.has_own_instances());
let part = |n: usize, min: usize| ((n as f64 * 0.25 * k) as usize).max((min as f64 * k) as usize);
if !Self::editable(scene, hwrt || units) {
return if units && k > 0.0 {
Expand Down Expand Up @@ -823,14 +823,6 @@ impl<'a> Top<'a> {
}
}

/// The slot of the first procedural object (`proc_first`: its record).
pub fn proc_base(&self, proc_first: usize) -> usize {
match self {
Top::Hw(a) => a.proc_base,
Top::Sw(_) => proc_first,
}
}

pub fn sw(&self) -> bool {
matches!(self, Top::Sw(_))
}
Expand Down
4 changes: 2 additions & 2 deletions renderer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,10 @@ pub fn prepare_as(hwrt: bool, units: bool, sc: &mut scene::Scene, timings: &mut
v
};
// Posed models: where each of their triangles landed (they are re-skinned in place, hardware RT only).
if hwrt && (!sc.retained.dynamic.is_empty() || !sc.retained.rigid.is_empty() || !sc.particles.is_empty() || !sc.gpu_particles.is_empty()) {
if hwrt && (sc.retained.dynamics_mut().next().is_some() || !sc.particles.is_empty() || !sc.gpu_particles.is_empty()) {
let first_dynamic: usize = groups[..4].iter().sum();
let finals: std::collections::HashMap<u32, u32> = bvh.order[first_dynamic..].iter().enumerate().map(|(k, &i)| (i, (first_dynamic + k) as u32)).collect();
for d in sc.retained.dynamic.values_mut().chain(sc.retained.rigid.values_mut().map(|r| &mut r.rest)) {
for d in sc.retained.dynamics_mut() {
d.finals = (0..d.mats.len() as u32).map(|j| finals[&(d.first + j)]).collect();
}
// A particle system's triangles stay together (one group, the order within a group is the build order).
Expand Down
Loading