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.
Rust electron-alternativegame-engineglobal-illuminationgraphicsjavascript-runtimemetalpath-tracingray-tracingreal-time-renderingrenderingrustthreejstypescriptvoxelvulkanwebgpuwgpu
Acceptance tools: the drive's look-ahead stays ahead at the road's end; the real-time window cut by the frame log's clock (Bugbot)
Evan (Yifeng) Wang65f70ea9c96f
diff --git a/tools/tokyo/accept-1a.ts b/tools/tokyo/accept-1a.tsindex 1e88643..2ad7ab5 100644--- a/tools/tokyo/accept-1a.ts+++ b/tools/tokyo/accept-1a.ts@@ -46,12 +46,12 @@ const result: Record<string, unknown> = {};async function realtime(name: string, room: string, cam: (t: number) => Cam, secs: number) {const log = join(out, `${name}.jsonl`);rmSync(log, { force: true });+ const launch = performance.now();const live = startLive(b, bundle, { scale: "auto", frameLog: log, room });- await live.firstFrame;+ const first = await live.firstFrame;live.send({ cmd: "camera", ...cam(0) });await sleep(4000);live.send({ cmd: "time", t: 0 });- const before = readFileSync(log, "utf8").trim().split("\n").length;const t0 = performance.now();for (let k = 0; ; k++) {const t = (performance.now() - t0) / 1000;@@ -61,7 +61,10 @@ async function realtime(name: string, room: string, cam: (t: number) => Cam, sec}await sleep(200);await live.quit();- const f = readFileSync(log, "utf8").trim().split("\n").map((l) => JSON.parse(l)).slice(before);+ // The run's frames by the log's clock (its first frame came `first` ms after the launch): a count of the log's lines+ // while the renderer runs misses the warm-up frames still in its write buffer.+ const all = readFileSync(log, "utf8").trim().split("\n").map((l) => JSON.parse(l));+ const f = all.filter((x) => x.t >= all[0].t + (t0 - launch - first));const st = f.map((x) => x.start).filter((v) => typeof v === "number").sort((p, q) => p - q);const iv = f.slice(1).map((x) => x.interval as number).sort((p, q) => p - q);const g = f.map((x) => x.gpu).filter((v) => typeof v === "number" && v > 0).sort((p, q) => p - q);diff --git a/tools/tokyo/clip.ts b/tools/tokyo/clip.tsindex 531247b..6fb4ac1 100644--- a/tools/tokyo/clip.ts+++ b/tools/tokyo/clip.ts@@ -40,12 +40,12 @@ const N = Math.round(route.secs * 60);// 1. Real time.const log = join(out, "frames.jsonl");+const launch = performance.now();let live = startLive(b, bundle, { scale: "auto", frameLog: log, room: route.room });-await live.firstFrame;+const first = await live.firstFrame;live.send({ cmd: "camera", ...route.cam(0) });await sleep(4000);live.send({ cmd: "time", t: 0 });-const before = readFileSync(log, "utf8").trim().split("\n").length;const t0 = performance.now();for (let k = 0; k <= N; k++) {live.send({ cmd: "camera", ...route.cam(Math.min(route.secs, (performance.now() - t0) / 1000)) });@@ -53,7 +53,9 @@ for (let k = 0; k <= N; k++) {}await sleep(200);await live.quit();-const run = readFileSync(log, "utf8").trim().split("\n").map((l) => JSON.parse(l)).slice(before);+// (The run's frames by the log's clock, as tools/tokyo/accept-1a.ts cuts them.)+const all = readFileSync(log, "utf8").trim().split("\n").map((l) => JSON.parse(l));+const run = all.filter((f) => f.t >= all[0].t + (t0 - launch - first));const shown = run.map((f) => ({ t: f.t - run[0].t, scale: f.scale as number })).filter((f) => f.t <= route.secs * 1000);const scales = shown.map((s) => s.scale).sort((p, q) => p - q);const scale = scales[Math.floor(scales.length / 2)];diff --git a/tools/tokyo/paths.ts b/tools/tokyo/paths.tsindex 7ed8084..529a411 100644--- a/tools/tokyo/paths.ts+++ b/tools/tokyo/paths.ts@@ -64,13 +64,15 @@ export function yasukuni(): number[][] {export function driver(pts: number[][], speed: number): { cam: (t: number) => Cam; secs: number } {const cum = [0];for (let i = 1; i < pts.length; i++) cum.push(cum[i - 1] + Math.hypot(pts[i][0] - pts[i - 1][0], pts[i][2] - pts[i - 1][2]));+ // (Past the end, along the last stretch: the look-ahead point stays ahead of the eye, which stops at the end.)const at = (s: number) => {- s = Math.min(Math.max(s, 0), cum[cum.length - 1]);+ s = Math.max(s, 0);let i = 1;while (i < cum.length - 1 && cum[i] < s) i++;const u = (s - cum[i - 1]) / Math.max(1e-6, cum[i] - cum[i - 1]);return [0, 1, 2].map((c) => pts[i - 1][c] + (pts[i][c] - pts[i - 1][c]) * u + (c === 1 ? 1.6 : 0));};- return { cam: (t) => ({ pos: at(t * speed), target: at(t * speed + 30), tan }), secs: cum[cum.length - 1] / speed };+ const end = cum[cum.length - 1];+ return { cam: (t) => ({ pos: at(Math.min(t * speed, end)), target: at(Math.min(t * speed, end) + 30), tan }), secs: end / speed };}diff --git a/tools/tokyo/test/paths.test.ts b/tools/tokyo/test/paths.test.tsnew file mode 100644index 0000000..69aed1a--- /dev/null+++ b/tools/tokyo/test/paths.test.ts@@ -0,0 +1,19 @@+// The drive's camera (tools/tokyo/paths.ts `driver`) at and past the end of its road: the eye stops at the end, the+// look-ahead point stays ahead of it along the last stretch (eye and target the same point make a NaN view).+import { test } from "node:test";+import assert from "node:assert/strict";+import { driver } from "../paths.ts";++test("the drive's look-ahead stays ahead of the eye at and past the road's end", () => {+ const d = driver([[0, 0, 0], [100, 0, 0], [100, 0, 50]], 10);+ assert.equal(d.secs, 15);+ for (const t of [0, 7.5, 15, 15 + 1 / 60, 20]) {+ const c = d.cam(t);+ const gap = Math.hypot(...c.target.map((v, k) => v - c.pos[k]));+ assert.ok(Math.abs(gap - 30) < 1e-6 || t < 15, `t ${t}: gap ${gap}`);+ assert.ok(gap > 1, `t ${t}: eye and target ${gap} m apart`);+ }+ // Past the end the eye stays at the end, the target 30 m on along the last stretch (+z).+ assert.deepEqual(d.cam(20).pos, [100, 1.6, 50]);+ assert.deepEqual(d.cam(20).target, [100, 1.6, 80]);+});