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.

Merge pull request #26 from taichi-dev/sync-doodlewind-main

Evan (Yifeng) Wangc55ff90031aa
diff --cc renderer/src/script.rs
index c6f9680,ec53a8a..7741981
--- a/renderer/src/script.rs
+++ b/renderer/src/script.rs
@@@ -349,13 -312,18 +366,18 @@@ impl ScriptHost
let ctx = Context::full(&rt)?;
let world = Rc::new(RefCell::new(World::default()));
let voxels = Rc::new(RefCell::new(crate::voxel::VoxelWorld::default()));
- let mut h = ScriptHost { _rt: rt, ctx, deadline, epoch, info: serde_json::Value::Null, world, voxels, physics: Default::default() };
- let (w, v, ph) = (h.world.clone(), h.voxels.clone(), h.physics.clone());
+ let mut h = ScriptHost { _rt: rt, ctx, budget, epoch, info: serde_json::Value::Null, world, voxels, physics: Default::default() };
+ let (w, v, ph, d2) = (h.world.clone(), h.voxels.clone(), h.physics.clone(), h.budget.clone());
let info: String = h.call(SETUP_MS, |ctx| {
let g = ctx.globals();
- g.set("__host_log", Function::new(ctx.clone(), |level: String, msg: String| eprintln!("[game{}] {msg}", if level == "info" { String::new() } else { format!(" {level}") }))?)?;
+ g.set("__host_log", Function::new(ctx.clone(), |level: String, msg: String| {
+ eprintln!("[game{}] {msg}", if level == "info" { String::new() } else { format!(" {level}") });
+ if let Some(sink) = LOG_SINK.read().ok().and_then(|s| *s) {
+ sink(&level, &msg);
+ }
+ })?)?;
g.set("__host_now", Function::new(ctx.clone(), move || epoch.elapsed().as_secs_f64() * 1000.0)?)?;
- install_engine(ctx, &w, &v, &ph)?;
+ install_engine(ctx, &w, &v, &ph, &d2)?;
ctx.eval::<(), _>(PRELUDE)?;
code(ctx)?;
host(ctx)?.get::<_, Function>("describe")?.call(())