3D engine that AI agents drive
Merge remote-tracking branch 'origin/design/hero-chipfab' into design/home-hero-loop-vfx
Nguyen Xuan An9f15804e212f
diff --cc src/hero-lab/loop/scenes.jsindex a533f2ec,0dc6b37e..5283aa4c--- a/src/hero-lab/loop/scenes.js+++ b/src/hero-lab/loop/scenes.js@@@ -45,14 -45,18 +45,18 @@@ export const SCENES =id: 'chipfab',name: 'Chip fab',description: '/showcase/chipfab/scene.json',-- seconds: 10,++ seconds: 11, // the merged clip is 12 s: 11 s on screen plus the fadescrim: 0.6,- near: 0.5,- far: 4000,+ near: 0.3,+ far: 400,+ // Cleanroom bay, 124 m long, in glTF units (Y up). FLIGHT NOTES: low down the aisle (y 1.5 to 2.8) between the tool rows+ // (rows start at |z| 5.2, pods and rails at |z| 4.4), then up to 4.8 m under the hoist rails (5.8 m). Ends before the x = 88 rail crossing.keys: [- { at: 0, eye: [80.7, 76.4, 118.6], target: [77.6, 69.3, 109.4], fov: 30 },- { at: 0.5, eye: [64, 75, 114], target: [60, 69, 107], fov: 32 },- { at: 1, eye: [46, 76, 116], target: [42, 69, 108], fov: 34 },+ { at: 0, eye: [0.5, 1.5, 0.8], target: [24, 1.7, -0.5], fov: 58 },+ { at: 0.3, eye: [14, 1.7, -0.6], target: [40, 1.9, 0.4], fov: 58 },+ { at: 0.6, eye: [30, 2.7, 0.2], target: [58, 2.6, 0], fov: 56 },+ { at: 0.85, eye: [40, 4.2, 0], target: [60, 4.6, 2.5], fov: 54 },+ { at: 1, eye: [46, 4.7, -1.2], target: [64, 5.0, 4], fov: 52 },],credits: [],},@@@ -91,7 -92,3 +95,4 @@@credits: [NVIDIA_SIMREADY],},];+- // TEMPORARY while the chip fab is rebuilt: ?skip=chipfab (comma list) leaves scenes out of the loop. Remove with the chip fab swap.- const skipped = new Set((new URLSearchParams(typeof location === 'undefined' ? '' : location.search).get('skip') ?? '').split(',').filter(Boolean));- export const SCENES = ALL_SCENES.filter(scene => !skipped.has(scene.id));diff --cc src/hero-lab/loop/world.jsindex d046536e,e3ed4b7b..a2a1cd14--- a/src/hero-lab/loop/world.js+++ b/src/hero-lab/loop/world.js@@@ -43,28 -39,16 +43,30 @@@ export async function fetchWorld(descriexport async function buildWorld(download, canvas, overrides = {}) {const { description, paths, models, sky } = download;+ const timings = {};+ let lapStart = performance.now();+ const lap = name => {+ const now = performance.now();+ timings[name] = Math.round(now - lapStart);+ (window.__phases ??= []).push([description.id, name, Math.round(lapStart), Math.round(now)]);+ lapStart = now;+ };const sharedTextures = createSharedTextures();const files = [];+ let animated = null;for (const [index, model] of models.entries()) {const loaded = await loadGltf(model, { baseUrl: baseUrlOf(paths[index]), sharedTextures, ...description.gltfOptions });+ if (loaded.animations?.length) animated = loaded;files.push({ parts: loaded.parts, ranks: await readPartRanks(model) });+ await yieldToMain();}+ lap('parseMs');const options = description.renderer;const environmentMap = await loadHdri(description.hdri, { ...description.hdriOptions, fetchImplementation: async () => new Response(sky) });+ await yieldToMain();+ lap('hdriMs');+ const effects = prepareEffects(description.id, inWholeWorldOrder(files));+ if (effects?.needsFogAddon) await import('../../fog-shader.js');const surfaceOf = parts => (description.waterReflection && WATER_MIRROR_ENABLED ? applyWaterReflection(parts) : { parts, surface: null });// The renderer starts on the first file's parts and takes the whole world through replaceParts, the order the showcase page// uses: a water mirror attached to a renderer built on the whole world drew nothing after its first frame.@@@ -89,22 -69,20 +91,33 @@@detachReflection();detachReflection = attachWaterReflection(renderer, whole.surface);}+ lap('rendererMs');+ let animationOrigin = null;++ let animationShadowStep = -1;const frame = { ...description.frame, exposure: description.exposure ?? 1 };return {id: description.id,title: description.title,description,canvas,+ renderer,+ timings,render(camera, seconds) {+ // A GLB with an animation clip (vehicles on rails, people walking) plays from the world's first drawn frame.+ if (animated) {+ animationOrigin ??= seconds;- renderer.updateParts(animated.applyAnimation(seconds - animationOrigin, 0));++ const clipSeconds = seconds - animationOrigin;++ // The shadow map follows the clip 8 times a second, not on every frame.++ const shadowStep = Math.floor(clipSeconds * 8);++ renderer.updateParts(animated.applyAnimation(clipSeconds, 0), { shadows: shadowStep !== animationShadowStep });++ animationShadowStep = shadowStep;+ }- renderer.render({ ...frame, eye: camera.eye, target: camera.target, fov: camera.fov, time: seconds });+ const drawn = effects ? effects.apply(renderer, seconds, frame) : frame;+ renderer.render({ ...drawn, eye: camera.eye, target: camera.target, fov: camera.fov, time: seconds });+ },+ // One draw while the canvas is still hidden: shaders compile and textures upload now, not on the first frame of a fade.+ warm(camera) {+ renderer.render({ ...frame, eye: camera.eye, target: camera.target, fov: camera.fov, time: 0 });},resize: () => renderer.resize(),dispose() {