reasoning

Inspecting src/view/clip.ts, focusing on lines 55-185 and 220-260 to ensure the --compare implementation is robust, avoids allocation within render(i), and correctly handles decals. Also analyzing src/view/clip-plan.test.ts and tools/clip.mjs to ensure alignment with the changes in clip.ts. This effort aims for a zero-allocation render(i) with zero regressions.

Examining the compare implementation in clip.ts reveals how the second model is loaded and prepared. The code handles loading a second model (root2), applying decals based on the compareName, and setting up its mech rig (rig2), weapons, and lights. This structure confirms that decals, weapons, and light elements are properly integrated for the comparison feature.

The shadow camera's frustum is expanded to prevent clipping on the mechs' wings. The second mech's rig now receives thrust and light exhaust updates within the feed function. In the render function's outdoor/space scenario with the comparison feature enabled and chase camera, both mechs will fly forward in the same direction with a camera behind.

The code positions two mechs, one on the left and another on the right, applying identical banking and leaning rotations based on mech yaw. Both mechs receive flight poses and matrix updates, crucial for synchronizing their animation states during the comparison. The camera's field of view and offset are calculated, ensuring both mechs remain within the frame's horizontal and vertical span, essential for visual comparison.

Focusing on the camera's position during the comparison view, calculations are adjusted to improve framing. The center's Y-coordinate is reconfigured to position mechs within the upper portion of the frame, ensuring their assault plumes are visible. Adjustments are also made to the rim intensity, ensuring sharp edge lighting for silhouettes during specific comparison modes.

Calculations confirm camera positioning and field of view provide an optimal, close-up comparison view. Specifically, at a distance of 39.1 meters with a 35-degree field of view, the mechs occupy 71.5% of the frame height with a clear separation. Even with maximum arm extensions, mechs at a 90-degree angle have a clean 2.1-meter separation, ensuring no overlap.

The comparison view code positions the mechs based on the camera's right vector. The first mech (carbon_0) is placed on the screen's left at -5.4 times the camera's right vector, while the second mech (striker) is on the right at +5.4. Both mechs are rotated synchronously around their Y-axes by the camera's yaw angle. Examining the clip-plan.ts data reveals that the yaw angle calculation, specifically the 180 + 360 * f.u, sets an initial yaw of 180 degrees. At u = 0, the mechs should face away from the camera.

  • edit_file{"Path":"~/work/sortie/src/view/clip.ts","Replacement":"import { CARBON_DECALS, STRIKER_DECALS, applyDecals, bearingDecals } from '../render/decals';","Target":"import { STRIKER_DECALS, applyDecals, bearingDecals } from '../render/decals';"}

    input

    {
      "Path": "~/work/sortie/src/view/clip.ts",
      "Replacement": "import { CARBON_DECALS, STRIKER_DECALS, applyDecals, bearingDecals } from '../render/decals';",
      "Target": "import { STRIKER_DECALS, applyDecals, bearingDecals } from '../render/decals';"
    }

    result, 1 line

    Made 1 replacement in ~/work/sortie/src/view/clip.ts starting at line 4 (+1/-1 lines).
  • edit_file{"Path":"~/work/sortie/src/view/clip.ts","Replacement":" const name = (q.get('model') ?? 'striker') as ModelName;\n const compareName = q.get('compare') as ModelName | null;\n const palette = (q.get('palette') ?? 'merc') as PaletteName;\n const trimColor = PALETTES[palette].trim.color;\n const bearings = q.get('bearings') === '1';\n const decorate = (m: ModelName, r: THREE.Object3D) => {\n if (m === 'striker') applyDecals(r, STRIKER_DECALS);\n if (m === 'carbon_0') applyDecals(r, CARBON_DECALS);\n if (bearings) applyDecals(r, bearingDecals(r, trimColor));\n treatEyes(r, 'spill');\n };\n const root = await model(name, palette);\n decorate(name, root);\n scene.add(root);\n const rig = new MechRig(root);\n root.updateMatrixWorld(true);\n rig.apply(POSES.stand);\n root.updateMatrixWorld(true);\n const box = new THREE.Box3().setFromObject(root);\n const height = box.getSize(new THREE.Vector3()).y;\n const footY = box.min.y;\n const size = height / 17.6;\n const hangarSole = rig.soles(HANGAR_POSE);\n const launchSole = rig.soles(POSES.launch);\n rig.apply(POSES.stand);\n\n const weapon = q.get('weapon') as ModelName | null;\n if (weapon) rig.hold(await model(weapon, palette));\n\n const light = new THREE.PointLight('#ffffff', 0, 0, 2);\n scene.add(light);\n\n let root2: THREE.Object3D | null = null;\n let rig2: MechRig | null = null;\n const light2 = new THREE.PointLight('#ffffff', 0, 0, 2);\n if (compareName) {\n root2 = await model(compareName, palette);\n decorate(compareName, root2);\n scene.add(root2);\n rig2 = new MechRig(root2);\n rig2.apply(POSES.stand);\n const weapon2 = (q.get('weapon2') ?? (compareName === 'striker' ? 'rifle' : weapon)) as ModelName | null;\n if (weapon2) rig2.hold(await model(weapon2, palette));\n scene.add(light2);\n const sc = sun.shadow.camera;\n sc.left = sc.bottom = -34;\n sc.right = sc.top = 34;\n sc.updateProjectionMatrix();\n }","Target":" const name = (q.get('model') ?? 'striker') as ModelName;\n const palette = (q.get('palette') ?? 'merc') as PaletteName;\n const trimColor = PALETTES[palette].trim.color;\n const bearings = q.get('bearings') === '1';\n const root = await model(name, palette);\n if (name === 'striker') applyDecals(root, STRIKER_DECALS);\n if (bearings) applyDecals(root, bearingDecals(root, trimColor));\n treatEyes(root, 'spill');\n scene.add(root);\n const rig = new MechRig(root);\n root.updateMatrixWorld(true);\n rig.apply(POSES.stand);\n root.updateMatrixWorld(true);\n const box = new THREE.Box3().setFromObject(root);\n const height = box.getSize(new THREE.Vector3()).y;\n const footY = box.min.y;\n const size = height / 17.6;\n const hangarSole = rig.soles(HANGAR_POSE);\n const launchSole = rig.soles(POSES.launch);\n rig.apply(POSES.stand);\n\n const weapon = q.get('weapon') as ModelName | null;\n if (weapon) rig.hold(await model(weapon, palette));\n\n const light = new THREE.PointLight('#ffffff', 0, 0, 2);\n scene.add(light);"}

    input

    {
      "Path": "~/work/sortie/src/view/clip.ts",
      "Replacement": "  const name = (q.get('model') ?? 'striker') as ModelName;\n  const compareName = q.get('compare') as ModelName | null;\n  const palette = (q.get('palette') ?? 'merc') as PaletteName;\n  const trimColor = PALETTES[palette].trim.color;\n  const bearings = q.get('bearings') === '1';\n  const decorate = (m: ModelName, r: THREE.Object3D) => {\n    if (m === 'striker') applyDecals(r, STRIKER_DECALS);\n    if (m === 'carbon_0') applyDecals(r, CARBON_DECALS);\n    if (bearings) applyDecals(r, bearingDecals(r, trimColor));\n    treatEyes(r, 'spill');\n  };\n  const root = await model(name, palette);\n  decorate(name, root);\n  scene.add(root);\n  const rig = new MechRig(root);\n  root.updateMatrixWorld(true);\n  rig.apply(POSES.stand);\n  root.updateMatrixWorld(true);\n  const box = new THREE.Box3().setFromObject(root);\n  const height = box.getSize(new THREE.Vector3()).y;\n  const footY = box.min.y;\n  const size = height / 17.6;\n  const hangarSole = rig.soles(HANGAR_POSE);\n  const launchSole = rig.soles(POSES.launch);\n  rig.apply(POSES.stand);\n\n  const weapon = q.get('weapon') as ModelName | null;\n  if (weapon) rig.hold(await model(weapon, palette));\n\n  const light = new THREE.PointLight('#ffffff', 0, 0, 2);\n  scene.add(light);\n\n  let root2: THREE.Object3D | null = null;\n  let rig2: MechRig | null = null;\n  const light2 = new THREE.PointLight('#ffffff', 0, 0, 2);\n  if (compareName) {\n    root2 = await model(compareName, palette);\n    decorate(compareName, root2);\n    scene.add(root2);\n    rig2 = new MechRig(root2);\n    rig2.apply(POSES.stand);\n    const weapon2 = (q.get('weapon2') ?? (compareName === 'striker' ? 'rifle' : weapon)) as ModelName | null;\n    if (weapon2) rig2.hold(await model(weapon2, palette));\n    scene.add(light2);\n    const sc = sun.shadow.camera;\n    sc.left = sc.bottom = -34;\n    sc.right = sc.top = 34;\n    sc.updateProjectionMatrix();\n  }",
      "Target": "  const name = (q.get('model') ?? 'striker') as ModelName;\n  const palette = (q.get('palette') ?? 'merc') as PaletteName;\n  const trimColor = PALETTES[palette].trim.color;\n  const bearings = q.get('bearings') === '1';\n  const root = await model(name, palette);\n  if (name === 'striker') applyDecals(root, STRIKER_DECALS);\n  if (bearings) applyDecals(root, bearingDecals(root, trimColor));\n  treatEyes(root, 'spill');\n  scene.add(root);\n  const rig = new MechRig(root);\n  root.updateMatrixWorld(true);\n  rig.apply(POSES.stand);\n  root.updateMatrixWorld(true);\n  const box = new THREE.Box3().setFromObject(root);\n  const height = box.getSize(new THREE.Vector3()).y;\n  const footY = box.min.y;\n  const size = height / 17.6;\n  const hangarSole = rig.soles(HANGAR_POSE);\n  const launchSole = rig.soles(POSES.launch);\n  rig.apply(POSES.stand);\n\n  const weapon = q.get('weapon') as ModelName | null;\n  if (weapon) rig.hold(await model(weapon, palette));\n\n  const light = new THREE.PointLight('#ffffff', 0, 0, 2);\n  scene.add(light);"
    }

    result, 1 line

    Made 1 replacement in ~/work/sortie/src/view/clip.ts starting at line 56 (+26/-3 lines).
  • edit_file{"Path":"~/work/sortie/src/view/clip.ts","Replacement":" rig.thrust(reading, clock, dt);\n rig.lightExhaust(light);\n if (rig2) {\n rig2.thrust(reading, clock, dt);\n rig2.lightExhaust(light2);\n }\n };","Target":" rig.thrust(reading, clock, dt);\n rig.lightExhaust(light);\n };"}

    input

    {
      "Path": "~/work/sortie/src/view/clip.ts",
      "Replacement": "    rig.thrust(reading, clock, dt);\n    rig.lightExhaust(light);\n    if (rig2) {\n      rig2.thrust(reading, clock, dt);\n      rig2.lightExhaust(light2);\n    }\n  };",
      "Target": "    rig.thrust(reading, clock, dt);\n    rig.lightExhaust(light);\n  };"
    }

    result, 1 line

    Made 1 replacement in ~/work/sortie/src/view/clip.ts starting at line 181 (+4/-0 lines).
  • edit_file{"Path":"~/work/sortie/src/view/clip.ts","Replacement":" } else if (compareName && root2 && rig2) {\n if (ship) ship.root.visible = false;\n const pose = v.bend > 0 ? mixPose(POSES.stand, BEND_POSE, v.bend) : POSES[v.pose];\n rig.apply(pose);\n rig2.apply(pose);\n if (v.chase) {\n setOutdoor(1, 0);\n if (rim) rim.intensity = 2.2;\n const sep = 4.9 * size;\n const bank = THREE.MathUtils.degToRad(-v.mechYaw * 0.32);\n const lean = THREE.MathUtils.degToRad(6);\n const yaw = THREE.MathUtils.degToRad(v.mechYaw);\n // Camera sits behind (-Z) looking +Z, so +X is screen-left (primary model) and -X is screen-right (yardstick)\n root.position.set(sep, 0, 0);\n root2.position.set(-sep, 0, 0);\n root.rotation.set(lean, yaw, bank);\n root2.rotation.set(lean, yaw, bank);\n root.updateMatrixWorld(true);\n root2.updateMatrixWorld(true);\n centre.set(0, footY + height * 0.43, 0);\n if (camera.fov !== 44) { camera.fov = 44; camera.updateProjectionMatrix(); }\n yawQ.setFromAxisAngle(up, THREE.MathUtils.degToRad(v.camYaw));\n offset.set(0, 4.1 * size, -24.8 * size).applyQuaternion(yawQ);\n camera.position.copy(centre).add(offset);\n look_.set(0, -0.5 * size, 220).applyQuaternion(yawQ).add(centre);\n camera.up.copy(up);\n camera.lookAt(look_);\n } else {\n setOutdoor(1, 0);\n const viewYawDeg = 14;\n const viewYaw = THREE.MathUtils.degToRad(viewYawDeg);\n const pitch = THREE.MathUtils.degToRad(v.pitch);\n const sep = 5.35 * size;\n const rx = Math.cos(viewYaw), rz = -Math.sin(viewYaw);\n // Camera sits on sunlit +Z side looking -Z, so -camRight is screen-left (primary) and +camRight is screen-right (yardstick)\n root.position.set(-rx * sep, 0, -rz * sep);\n root2.position.set(rx * sep, 0, rz * sep);\n const spin = THREE.MathUtils.degToRad(viewYawDeg + v.camYaw);\n root.rotation.set(0, spin, 0);\n root2.rotation.set(0, spin, 0);\n root.updateMatrixWorld(true);\n root2.updateMatrixWorld(true);\n centre.set(0, footY + height * v.lookAt, 0);\n if (camera.fov !== 35) { camera.fov = 35; camera.updateProjectionMatrix(); }\n camera.position.set(Math.sin(viewYaw) * Math.cos(pitch), Math.sin(pitch), Math.cos(viewYaw) * Math.cos(pitch))\n .multiplyScalar(2.24 * height).add(centre);\n camera.up.copy(up);\n camera.lookAt(centre);\n }\n } else {","Target":" } else {"}

    input

    {
      "Path": "~/work/sortie/src/view/clip.ts",
      "Replacement": "    } else if (compareName && root2 && rig2) {\n      if (ship) ship.root.visible = false;\n      const pose = v.bend > 0 ? mixPose(POSES.stand, BEND_POSE, v.bend) : POSES[v.pose];\n      rig.apply(pose);\n      rig2.apply(pose);\n      if (v.chase) {\n        setOutdoor(1, 0);\n        if (rim) rim.intensity = 2.2;\n        const sep = 4.9 * size;\n        const bank = THREE.MathUtils.degToRad(-v.mechYaw * 0.32);\n        const lean = THREE.MathUtils.degToRad(6);\n        const yaw = THREE.MathUtils.degToRad(v.mechYaw);\n        // Camera sits behind (-Z) looking +Z, so +X is screen-left (primary model) and -X is screen-right (yardstick)\n        root.position.set(sep, 0, 0);\n        root2.position.set(-sep, 0, 0);\n        root.rotation.set(lean, yaw, bank);\n        root2.rotation.set(lean, yaw, bank);\n        root.updateMatrixWorld(true);\n        root2.updateMatrixWorld(true);\n        centre.set(0, footY + height * 0.43, 0);\n        if (camera.fov !== 44) { camera.fov = 44; camera.updateProjectionMatrix(); }\n        yawQ.setFromAxisAngle(up, THREE.MathUtils.degToRad(v.camYaw));\n        offset.set(0, 4.1 * size, -24.8 * size).applyQuaternion(yawQ);\n        camera.position.copy(centre).add(offset);\n        look_.set(0, -0.5 * size, 220).applyQuaternion(yawQ).add(centre);\n        camera.up.copy(up);\n        camera.lookAt(look_);\n      } else {\n        setOutdoor(1, 0);\n        const viewYawDeg = 14;\n        const viewYaw = THREE.MathUtils.degToRad(viewYawDeg);\n        const pitch = THREE.MathUtils.degToRad(v.pitch);\n        const sep = 5.35 * size;\n        const rx = Math.cos(viewYaw), rz = -Math.sin(viewYaw);\n        // Camera sits on sunlit +Z side looking -Z, so -camRight is screen-left (primary) and +camRight is screen-right (yardstick)\n        root.position.set(-rx * sep, 0, -rz * sep);\n        root2.position.set(rx * sep, 0, rz * sep);\n        const spin = THREE.MathUtils.degToRad(viewYawDeg + v.camYaw);\n        root.rotation.set(0, spin, 0);\n        root2.rotation.set(0, spin, 0);\n        root.updateMatrixWorld(true);\n        root2.updateMatrixWorld(true);\n        centre.set(0, footY + height * v.lookAt, 0);\n        if (camera.fov !== 35) { camera.fov = 35; camera.updateProjectionMatrix(); }\n        camera.position.set(Math.sin(viewYaw) * Math.cos(pitch), Math.sin(pitch), Math.cos(viewYaw) * Math.cos(pitch))\n          .multiplyScalar(2.24 * height).add(centre);\n        camera.up.copy(up);\n        camera.lookAt(centre);\n      }\n    } else {",
      "Target": "    } else {"
    }

    result, 1 line

    Made 2 replacements in ~/work/sortie/src/view/clip.ts starting at line 248 (+99/-1 lines).
  • edit_file{"Path":"~/work/sortie/tools/clip.mjs","Replacement":"for (const k of ['shots', 'look', 'weapon', 'weapon2', 'compare', 'bay2', 'tier']) if (flag(k)) params.set(k, flag(k));","Target":"for (const k of ['shots', 'look', 'weapon', 'bay2', 'tier']) if (flag(k)) params.set(k, flag(k));"}

    input

    {
      "Path": "~/work/sortie/tools/clip.mjs",
      "Replacement": "for (const k of ['shots', 'look', 'weapon', 'weapon2', 'compare', 'bay2', 'tier']) if (flag(k)) params.set(k, flag(k));",
      "Target": "for (const k of ['shots', 'look', 'weapon', 'bay2', 'tier']) if (flag(k)) params.set(k, flag(k));"
    }

    result, 1 line

    Made 1 replacement in ~/work/sortie/tools/clip.mjs starting at line 28 (+1/-1 lines).
  • edit_file{"Path":"~/work/sortie/src/view/clip-plan.test.ts","Replacement":" const l = clipFrames(['launch'], 24);\n expect(shotView(l[0]).catapult).toBe(0);\n expect(shotView(l[l.length - 1]).catapult).toBe(1);\n expect(l.map((x) => x.state)).toContain('boost');\n });\n\n it('cycles all plume modes in flight_rear and completes a 360 turn in turn_full', () => {\n const fr = clipFrames(['flight_rear'], 24);\n const states = new Set(fr.map((x) => x.state));\n expect(states).toEqual(new Set(['cruise', 'quick', 'boost', 'assault', 'brake']));\n expect(shotView(fr[0]).chase).toBe(true);\n const tf = clipFrames(['turn_full'], 24);\n expect(shotView(tf[0]).camYaw).toBe(180);\n expect(shotView(tf[tf.length - 1]).camYaw).toBe(540);\n });\n});","Target":" const l = clipFrames(['launch'], 24);\n expect(shotView(l[0]).catapult).toBe(0);\n expect(shotView(l[l.length - 1]).catapult).toBe(1);\n expect(l.map((x) => x.state)).toContain('boost');\n });\n});"}

    input

    {
      "Path": "~/work/sortie/src/view/clip-plan.test.ts",
      "Replacement": "    const l = clipFrames(['launch'], 24);\n    expect(shotView(l[0]).catapult).toBe(0);\n    expect(shotView(l[l.length - 1]).catapult).toBe(1);\n    expect(l.map((x) => x.state)).toContain('boost');\n  });\n\n  it('cycles all plume modes in flight_rear and completes a 360 turn in turn_full', () => {\n    const fr = clipFrames(['flight_rear'], 24);\n    const states = new Set(fr.map((x) => x.state));\n    expect(states).toEqual(new Set(['cruise', 'quick', 'boost', 'assault', 'brake']));\n    expect(shotView(fr[0]).chase).toBe(true);\n    const tf = clipFrames(['turn_full'], 24);\n    expect(shotView(tf[0]).camYaw).toBe(180);\n    expect(shotView(tf[tf.length - 1]).camYaw).toBe(540);\n  });\n});",
      "Target": "    const l = clipFrames(['launch'], 24);\n    expect(shotView(l[0]).catapult).toBe(0);\n    expect(shotView(l[l.length - 1]).catapult).toBe(1);\n    expect(l.map((x) => x.state)).toContain('boost');\n  });\n});"
    }

    result, 1 line

    Made 1 replacement in ~/work/sortie/src/view/clip-plan.test.ts starting at line 71 (+10/-0 lines).
  • resultThe tool's output was truncated due to being too long. You can find the full output in a file at file://~/.gemini/antigravity-cli/brain/cea9ec26-a0ce-4401-a5d2-36df51bb07b3/.system_generated/steps/404/output.txt.
    The tool's output was truncated due to being too long. You can find the full output in a file at file://~/.gemini/antigravity-cli/brain/cea9ec26-a0ce-4401-a5d2-36df51bb07b3/.system_generated/steps/404/output.txt.
    
    Here is a preview with the middle of the output truncated:
    Command exited with code 0.
    
    Command output:
    
    > sortie@0.1.0 kit
    > blender -b --factory-startup -P kit/build.py -- carbon_0 carbon_rifle
    
    Blender 5.2.3 LTS (hash e13b728c6880 built 2026-10-22 01:35:05)
    00:00.074  system.path      | WARNING Could not get a list of mounted file-systems
    INFO Draco is available, use library at ~/.local/opt/blender-5.2.3-linux-x64/lib/libbf_intern_draco_bridge.so
    INFO MeshOptimizer is available, use library at ~/.local/opt/blender-5.2.3-linux-x64/lib/libbf_intern_meshopt_bridge.so
    00:44:24 | INFO: Starting glTF 2.0 export
    00:44:24 | INFO: Extracting primitive: codpiece_body.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: codpiece_tip.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: codpiece_vent.001
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_pod_low.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_pod_low.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_pod_top.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_pod_top.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_pod_vent.L.001
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_pod_vent.R.001
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_trunnion_cal.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_trunnion_cal.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_trunnion_cap.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_trunnion_cap.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_trunnion_drum.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_trunnion_drum.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: pelvis_belt_keel.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: pelvis_chassis.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_front_hi.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_front_hi.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_front_lo.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_front_lo.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_front_trim.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_front_trim.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_rear_hi.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_rear_hi.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_rear_lo.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: skirt_rear_lo.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: tail_louvers.001
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: tail_spine.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: hip_ball.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: achilles_in_col.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: achilles_in_cyl.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: achilles_in_rod.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: achilles_out_col.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: achilles_out_cyl.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: achilles_out_rod.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: calf_fairing_hi.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: calf_fairing_lo.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: calf_louvers.L.001
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: calf_outer_fin.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: calf_vec_glow.L
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: calf_vec_liner.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: calf_vec_petals.L.001
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: c
    <truncated 32054 of 41946 bytes from the middle of the output>
     created: 1
    00:44:24 | INFO: Extracting primitive: vambrace_hardpoint.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: vambrace_in.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: vambrace_latch.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: vambrace_out.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: vambrace_spur.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: tricep_rear.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: upperarm_chassis.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: torso_chassis.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_f_col.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_f_col.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_f_cyl.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_f_cyl.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_f_rod.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_f_rod.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_r_col.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_r_col.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_r_cyl.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_r_cyl.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_r_rod.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_act_r_rod.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_core.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_oblique_hi.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_oblique_hi.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_oblique_lo.L.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Extracting primitive: waist_oblique_lo.R.002
    00:44:24 | INFO: Primitives created: 1
    00:44:24 | INFO: Finished glTF 2.0 export in 0.5807032585144043 s
    
    kit: carbon_0 -> ~/work/sortie/public/assets/carbon_0.glb (2066 KB, 19.2s)
    00:44:25 | INFO: Starting glTF 2.0 export
    00:44:25 | INFO: Extracting primitive: accel_rail_bot.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: accel_rail_top.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: barrel_clamp0.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: barrel_clamp1.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: barrel_clamp2.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: barrel_clamp3.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: barrel_clamp4.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: buttpad.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: buttstock.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: grip_handle.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: mag_baseplate.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: magazine.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: muzzle_brake.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: muzzle_glow
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: optic_bezel.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: optic_body.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: optic_lens
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: plasma_channel
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: receiver_lower.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: receiver_upper.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Extracting primitive: trigger_guard.002
    00:44:25 | INFO: Primitives created: 1
    00:44:25 | INFO: Finished glTF 2.0 export in 0.03918719291687012 s
    
    kit: carbon_rifle -> ~/work/sortie/public/assets/carbon_rifle.glb (48 KB, 0.2s)
    
    Blender quit
    
    Log: file://~/.gemini/antigravity-cli/brain/cea9ec26-a0ce-4401-a5d2-36df51bb07b3/.system_generated/tasks/task-404.log
  • read_file{"EndLine":410,"Path":"~/work/sortie/src/view/clip.ts","StartLine":215}

    input

    {
      "EndLine": 410,
      "Path": "~/work/sortie/src/view/clip.ts",
      "StartLine": 215
    }

    result, 174 lines

    Showing lines 215-387 of 387
    215:       root.rotation.set(0, -0.4, 0);
    216:       root.updateMatrixWorld(true);
    217:       const e = ease(f.u);
    218:       if (camera.fov !== 50) { camera.fov = 50; camera.updateProjectionMatrix(); }
    219:       camera.position.set(1.2 - 0.9 * e, 1.75 + 0.4 * e, 13.8 - 2.2 * e);
    220:       camera.up.copy(up);
    221:       camera.lookAt(1.3 + 0.5 * e, 8.8 + 0.25 * e, -10.2);
    222:       centre.copy(root.position).y += height * 0.5;
    223:     } else if (v.catapult >= 0 && ship) {
    224:       ship.root.visible = true;
    225:       const door = Math.min(1, 0.45 + f.t / 0.9);
    226:       const k = Math.max(0, (f.t - 1.0) / 1.95);
    227:       const dist = f.t <= 1.0 ? 0 : k <= 1 ? LAUNCH.length * k * k : LAUNCH.length + LAUNCH.exitSpeed * (f.t - 2.95) * 0.65;
    228:       ship.update({
    229:         phase: f.t < 1.0 ? 'countdown' : k <= 1 ? 'catapult' : 'released',
    230:         t: f.t < 0.45 ? 1.5 : 2.5,
    231:         shuttle: Math.min(LAUNCH.length, dist),
    232:         speed: 0,
    233:         door,
    234:       });
    235:       const start = ship.startFor('standard');
    236:       const free = THREE.MathUtils.smoothstep(dist, LAUNCH.length - 6, LAUNCH.length + 22);
    237:       setOutdoor(THREE.MathUtils.smoothstep(start.z + dist, 102, 132), 0);
    238:       rig.apply(mixPose(POSES.launch, POSES.flight, free));
    239:       root.position.set(start.x, start.y - launchSole * (1 - free) + 1.8 * free, start.z + dist);
    240:       root.rotation.set(THREE.MathUtils.degToRad(5 * free), 0, 0);
    241:       root.updateMatrixWorld(true);
    242:       if (camera.fov !== 62) { camera.fov = 62; camera.updateProjectionMatrix(); }
    243:       const lag = Math.min(8.5, dist * 0.1) * (1 - free * 0.4);
    244:       camera.position.set(-3.1 + 0.7 * free, 8.6 + 1.6 * free, start.z + dist - 19.5 - lag);
    245:       camera.up.copy(up);
    246:       camera.lookAt(0.2 * (1 - free), 9.2 + 1.4 * free, start.z + dist + 28);
    247:       centre.copy(root.position).y += height * 0.5;
    248:     } else if (compareName && root2 && rig2) {
    249:       if (ship) ship.root.visible = false;
    250:       const pose = v.bend > 0 ? mixPose(POSES.stand, BEND_POSE, v.bend) : POSES[v.pose];
    251:       rig.apply(pose);
    252:       rig2.apply(pose);
    253:       if (v.chase) {
    254:         setOutdoor(1, 0);
    255:         if (rim) rim.intensity = 2.2;
    256:         const sep = 4.9 * size;
    257:         const bank = THREE.MathUtils.degToRad(-v.mechYaw * 0.32);
    258:         const lean = THREE.MathUtils.degToRad(6);
    259:         const yaw = THREE.MathUtils.degToRad(v.mechYaw);
    260:         // Camera sits behind (-Z) looking +Z, so +X is screen-left (primary model) and -X is screen-right (yardstick)
    261:         root.position.set(sep, 0, 0);
    262:         root2.position.set(-sep, 0, 0);
    263:         root.rotation.set(lean, yaw, bank);
    264:         root2.rotation.set(lean, yaw, bank);
    265:         root.updateMatrixWorld(true);
    266:         root2.updateMatrixWorld(true);
    267:         centre.set(0, footY + height * 0.43, 0);
    268:         if (camera.fov !== 44) { camera.fov = 44; camera.updateProjectionMatrix(); }
    269:         yawQ.setFromAxisAngle(up, THREE.MathUtils.degToRad(v.camYaw));
    270:         offset.set(0, 4.1 * size, -24.8 * size).applyQuaternion(yawQ);
    271:         camera.position.copy(centre).add(offset);
    272:         look_.set(0, -0.5 * size, 220).applyQuaternion(yawQ).add(centre);
    273:         camera.up.copy(up);
    274:         camera.lookAt(look_);
    275:       } else {
    276:         setOutdoor(1, 0);
    277:         const viewYawDeg = 14;
    278:         const viewYaw = THREE.MathUtils.degToRad(viewYawDeg);
    279:         const pitch = THREE.MathUtils.degToRad(v.pitch);
    280:         const sep = 5.35 * size;
    281:         const rx = Math.cos(viewYaw), rz = -Math.sin(viewYaw);
    282:         // Camera sits on sunlit +Z side looking -Z, so -camRight is screen-left (primary) and +camRight is screen-right (yardstick)
    283:         root.position.set(-rx * sep, 0, -rz * sep);
    284:         root2.position.set(rx * sep, 0, rz * sep);
    285:         const spin = THREE.MathUtils.degToRad(viewYawDeg + v.camYaw);
    286:         root.rotation.set(0, spin, 0);
    287:         root2.rotation.set(0, spin, 0);
    288:         root.updateMatrixWorld(true);
    289:         root2.updateMatrixWorld(true);
    290:         centre.set(0, footY + height * v.lookAt, 0);
    291:         if (camera.fov !== 35) { camera.fov = 35; camera.updateProjectionMatrix(); }
    292:         camera.position.set(Math.sin(viewYaw) * Math.cos(pitch), Math.sin(pitch), Math.cos(viewYaw) * Math.cos(pitch))
    293:           .multiplyScalar(2.24 * height).add(centre);
    294:         camera.up.copy(up);
    295:         camera.lookAt(centre);
    296:       }
    297:     } else {
    298:       if (ship) ship.root.visible = false;
    299:       setOutdoor(1, 0);
    300:       root.position.set(0, 0, 0);
    301:       const bank = v.chase ? THREE.MathUtils.degToRad(-v.mechYaw * 0.32) : 0;
    302:       const lean = v.chase ? THREE.MathUtils.degToRad(5) : 0;
    303:       root.rotation.set(lean, THREE.MathUtils.degToRad(v.mechYaw), bank);
    304:       rig.apply(v.bend > 0 ? mixPose(POSES.stand, BEND_POSE, v.bend) : POSES[v.pose]);
    305:       root.updateMatrixWorld(true);
    306:       centre.set(0, footY + height * v.lookAt, 0);
    307:       const fov = v.chase ? chase.camera.fov : 35;
    308:       if (camera.fov !== fov) {
    309:         camera.fov = fov;
    310:         camera.updateProjectionMatrix();
    311:       }
    312:       if (v.chase) {
    313:         // where the game's chase camera sits (src/view/cameras.ts), over the shoulder, scaled to the frame
    314:         yawQ.setFromAxisAngle(up, THREE.MathUtils.degToRad(v.camYaw));
    315:         offset.set(chase.shoulder * size, chase.chaseOffset.y * size, chase.chaseOffset.z * size).applyQuaternion(yawQ);
    316:         camera.position.copy(centre).add(offset);
    317:         look_.set(chase.shoulder * size, (chase.chaseOffset.y - chase.lookDrop) * size, 400).applyQuaternion(yawQ).add(centre);
    318:         camera.up.copy(up);
    319:         camera.lookAt(look_);
    320:       } else if (compareName && root2 && rig2) {
    321:       if (ship) ship.root.visible = false;
    322:       const pose = v.bend > 0 ? mixPose(POSES.stand, BEND_POSE, v.bend) : POSES[v.pose];
    323:       rig.apply(pose);
    324:       rig2.apply(pose);
    325:       if (v.chase) {
    326:         setOutdoor(1, 0);
    327:         if (rim) rim.intensity = 2.2;
    328:         const sep = 4.9 * size;
    329:         const bank = THREE.MathUtils.degToRad(-v.mechYaw * 0.32);
    330:         const lean = THREE.MathUtils.degToRad(6);
    331:         const yaw = THREE.MathUtils.degToRad(v.mechYaw);
    332:         // Camera sits behind (-Z) looking +Z, so +X is screen-left (primary model) and -X is screen-right (yardstick)
    333:         root.position.set(sep, 0, 0);
    334:         root2.position.set(-sep, 0, 0);
    335:         root.rotation.set(lean, yaw, bank);
    336:         root2.rotation.set(lean, yaw, bank);
    337:         root.updateMatrixWorld(true);
    338:         root2.updateMatrixWorld(true);
    339:         centre.set(0, footY + height * 0.43, 0);
    340:         if (camera.fov !== 44) { camera.fov = 44; camera.updateProjectionMatrix(); }
    341:         yawQ.setFromAxisAngle(up, THREE.MathUtils.degToRad(v.camYaw));
    342:         offset.set(0, 4.1 * size, -24.8 * size).applyQuaternion(yawQ);
    343:         camera.position.copy(centre).add(offset);
    344:         look_.set(0, -0.5 * size, 220).applyQuaternion(yawQ).add(centre);
    345:         camera.up.copy(up);
    346:         camera.lookAt(look_);
    347:       } else {
    348:         setOutdoor(1, 0);
    349:         const viewYawDeg = 14;
    350:         const viewYaw = THREE.MathUtils.degToRad(viewYawDeg);
    351:         const pitch = THREE.MathUtils.degToRad(v.pitch);
    352:         const sep = 5.35 * size;
    353:         const rx = Math.cos(viewYaw), rz = -Math.sin(viewYaw);
    354:         // Camera sits on sunlit +Z side looking -Z, so -camRight is screen-left (primary) and +camRight is screen-right (yardstick)
    355:         root.position.set(-rx * sep, 0, -rz * sep);
    356:         root2.position.set(rx * sep, 0, rz * sep);
    357:         const spin = THREE.MathUtils.degToRad(viewYawDeg + v.camYaw);
    358:         root.rotation.set(0, spin, 0);
    359:         root2.rotation.set(0, spin, 0);
    360:         root.updateMatrixWorld(true);
    361:         root2.updateMatrixWorld(true);
    362:         centre.set(0, footY + height * v.lookAt, 0);
    363:         if (camera.fov !== 35) { camera.fov = 35; camera.updateProjectionMatrix(); }
    364:         camera.position.set(Math.sin(viewYaw) * Math.cos(pitch), Math.sin(pitch), Math.cos(viewYaw) * Math.cos(pitch))
    365:           .multiplyScalar(2.24 * height).add(centre);
    366:         camera.up.copy(up);
    367:         camera.lookAt(centre);
    368:       }
    369:     } else {
    370:         const yaw = THREE.MathUtils.degToRad(v.camYaw), pitch = THREE.MathUtils.degToRad(v.pitch);
    371:         camera.position.set(Math.sin(yaw) * Math.cos(pitch), Math.sin(pitch), Math.cos(yaw) * Math.cos(pitch)).multiplyScalar(v.dist * height).add(centre);
    372:         if (v.ground) camera.position.y = Math.max(camera.position.y, footY + 1.6); // eye height, above the deck
    373:         camera.up.copy(up);
    374:         camera.lookAt(centre);
    375:       }
    376:     }
    377:     camera.updateMatrixWorld(true);
    378:     followSun(sun, centre);
    379:     pipe.render();
    380:     // read straight after the draw, in the same task, while the buffer still holds it
    381:     return canvas.toDataURL('image/jpeg', 0.93);
    382:   };
    383: 
    384:   const win = window as unknown as { __clip: unknown; __ready: boolean };
    385:   win.__clip = { frames: frames.length, fps, render };
    386:   win.__ready = true;
    387: }
  • read_file{"EndLine":160,"Path":"~/work/sortie/tools/clip.mjs","StartLine":1}

    input

    {
      "EndLine": 160,
      "Path": "~/work/sortie/tools/clip.mjs",
      "StartLine": 1
    }

    result, 87 lines

    Showing lines 1-86 of 86
    1: // A review clip of one model: chase camera, orbit, turntable, range of motion, next to a pilot.
    2: //   node tools/clip.mjs <model> [--quick] [--shots chase,turn] [--fps 24] [--size 854x480] [--palette merc] [--look kit] [--out file.mp4]
    3: // --quick is for the loop: chase and turntable only, 12 fps, 640x360.
    4: // Starts its own dev server on a free port and always stops it. Frames are rendered one at a time, so
    5: // the clip is smooth however slow the machine (src/view/clip.ts). Writes the mp4 and, because a reader
    6: // that can't watch video still has to judge it, a contact sheet of frames beside it. Headless only.
    7: import { spawn, spawnSync } from 'node:child_process';
    8: import { mkdirSync, writeFileSync } from 'node:fs';
    9: import { dirname, resolve } from 'node:path';
    10: import { chromium } from 'playwright';
    11: import { createServer } from 'vite';
    12: 
    13: const args = process.argv.slice(2);
    14: const flag = (name, fallback) => {
    15:   const i = args.indexOf(`--${name}`);
    16:   return i >= 0 ? args[i + 1] : fallback;
    17: };
    18: const name = args[0];
    19: if (!name || name.startsWith('--')) {
    20:   console.error('usage: node tools/clip.mjs <model> [--quick] [--shots hangar,launch,chase,orbit] [--fps 24] [--size 854x480] [--palette merc] [--look kit] [--weapon rifle] [--ao] [--bearings] [--sheet file.jpg | --no-sheet] [--sample 0,50 --preview dir] [--out file.mp4]');
    21:   process.exit(2);
    22: }
    23: const quick = args.includes('--quick');
    24: const [w, h] = flag('size', quick ? '640x360' : '854x480').split('x').map(Number);
    25: const fps = Number(flag('fps', quick ? 12 : 24));
    26: const out = resolve(flag('out', `review/out/one-mech/clips/${name}.mp4`));
    27: const params = new URLSearchParams({ view: 'clip', model: name, w, h, fps, palette: flag('palette', 'merc') });
    28: for (const k of ['shots', 'look', 'weapon', 'weapon2', 'compare', 'bay2', 'tier']) if (flag(k)) params.set(k, flag(k));
    29: if (args.includes('--ao')) params.set('ao', '1');
    30: if (args.includes('--bearings')) params.set('bearings', '1');
    31: if (quick && !flag('shots')) params.set('shots', 'chase,turn');
    32: const sample = flag('sample', null)?.split(',').map(Number);
    33: const previewDir = flag('preview', null);
    34: mkdirSync(previewDir ? resolve(previewDir) : dirname(out), { recursive: true });
    35: 
    36: const started = Date.now();
    37: const server = await createServer({ server: { host: '127.0.0.1', port: 5230, strictPort: false }, logLevel: 'error' });
    38: await server.listen();
    39: const browser = await chromium.launch({ args: ['--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--ignore-gpu-blocklist'] });
    40: let failed = false;
    41: try {
    42:   const page = await browser.newPage({ viewport: { width: w, height: h } });
    43:   page.setDefaultTimeout(300000);
    44:   page.on('pageerror', (e) => { failed = true; console.error('[pageerror]', e.message); });
    45:   page.on('console', (m) => { if (m.type() === 'error') console.error('[console]', m.text().slice(0, 300)); });
    46:   await page.goto(`${server.resolvedUrls.local[0]}?${params}`);
    47:   await page.waitForFunction(() => window.__ready === true);
    48:   const frames = await page.evaluate(() => window.__clip.frames);
    49:   const loaded = Date.now();
    50:   if (sample && previewDir) {
    51:     for (const idx of sample) {
    52:       const clamped = Math.max(0, Math.min(frames - 1, idx));
    53:       const url = await page.evaluate((n) => window.__clip.render(n), clamped);
    54:       const file = resolve(previewDir, `frame_${String(clamped).padStart(3, '0')}.jpg`);
    55:       writeFileSync(file, Buffer.from(url.slice(url.indexOf(',') + 1), 'base64'));
    56:       console.log(`preview: ${file}`);
    57:     }
    58:     console.log(`preview: ${sample.length} frames (${((Date.now() - loaded) / sample.length).toFixed(0)} ms a frame)`);
    59:   } else {
    60:     const ffmpeg = spawn('ffmpeg', ['-loglevel', 'error', '-y', '-f', 'image2pipe', '-c:v', 'mjpeg', '-framerate', String(fps), '-i', '-',
    61:       '-c:v', 'libx264', '-crf', '19', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', out], { stdio: ['pipe', 'inherit', 'inherit'] });
    62:     const ended = new Promise((ok) => ffmpeg.on('close', ok));
    63:     for (let i = 0; i < frames; i++) {
    64:       const url = await page.evaluate((n) => window.__clip.render(n), i);
    65:       const jpeg = Buffer.from(url.slice(url.indexOf(',') + 1), 'base64');
    66:       if (!ffmpeg.stdin.write(jpeg)) await new Promise((ok) => ffmpeg.stdin.once('drain', ok));
    67:     }
    68:     ffmpeg.stdin.end();
    69:     const code = await ended;
    70:     if (code !== 0) throw new Error(`ffmpeg exited ${code}`);
    71:     if (!args.includes('--no-sheet')) {
    72:       const every = Math.max(1, Math.floor(frames / 12));
    73:       const sheet = flag('sheet') ? resolve(flag('sheet')) : out.replace(/\.mp4$/, '.sheet.jpg');
    74:       mkdirSync(dirname(sheet), { recursive: true });
    75:       spawnSync('ffmpeg', ['-loglevel', 'error', '-y', '-i', out, '-vf', `select=not(mod(n\\,${every})),scale=480:-1,tile=4x3`, '-frames:v', '1', '-q:v', '4', sheet], { stdio: 'inherit' });
    76:       console.log(`clip: ${sheet}`);
    77:     }
    78:     const secs = (Date.now() - started) / 1000;
    79:     console.log(`clip: ${out}`);
    80:     console.log(`clip: ${frames} frames, ${(frames / fps).toFixed(1)} s of video, ${secs.toFixed(0)} s to make (${((Date.now() - loaded) / frames).toFixed(0)} ms a frame)`);
    81:   }
    82: } finally {
    83:   await browser.close();
    84:   await server.close();
    85: }
    86: process.exit(failed ? 1 : 0);
reasoning

Initial observation: A potential fix is located within src/view/clip.ts lines 320-369. To ensure no related problems exist, a full scan of src/view/clip.ts will be performed, focusing on lines 1-225 to eliminate other potential issues, such as those related to size, height, and rendering-related variables.

  • read_file{"EndLine":220,"Path":"~/work/sortie/src/view/clip.ts","StartLine":1}

    input

    {
      "EndLine": 220,
      "Path": "~/work/sortie/src/view/clip.ts",
      "StartLine": 1
    }

    result, 221 lines

    Showing lines 1-220 of 387
    1: import * as THREE from 'three';
    2: import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
    3: import { model, type ModelName } from '../render/assets';
    4: import { CARBON_DECALS, STRIKER_DECALS, applyDecals, bearingDecals } from '../render/decals';
    5: import { treatEyes } from '../render/eyes';
    6: import type { ThrustReading } from '../render/exhaust';
    7: import { setLook, look } from '../render/look';
    8: import { MechRig, POSES, type Pose } from '../render/mech';
    9: import { PALETTES, type PaletteName } from '../render/palette';
    10: import { Pipeline } from '../render/pipeline';
    11: import { ShipRig } from '../render/ship';
    12: import { addSpaceLight, createBackdrop, followSun, spaceEnvironment } from '../render/space';
    13: import { LAUNCH } from '../sim/launch';
    14: import { BEND_POSE, DEFAULT_SHOTS, clipFrames, mixPose, shotView, type ShotName } from './clip-plan';
    15: import { CameraRig } from './cameras';
    16: import { benchInput } from './thrusters';
    17: 
    18: const HANGAR_POSE: Pose = {
    19:   pelvis: [0, -5, 0], torso: [4, 7, 0], head: [15, 16, 0],
    20:   'thigh.L': [-6, 0, 4], 'shin.L': [10, 0, 0], 'foot.L': [-4, 0, -3],
    21:   'thigh.R': [4, 0, -4], 'shin.R': [6, 0, 0], 'foot.R': [-10, 0, 3],
    22:   'upperarm.L': [-10, 0, 11], 'forearm.L': [-24, 0, 0],
    23:   'upperarm.R': [-24, -8, -9], 'forearm.R': [-38, 0, 0],
    24:   'binder.L': [6, 0, 0], 'binder.R': [6, 0, 0],
    25: };
    26: 
    27: /**
    28:  * A review clip of one model, rendered frame by frame so it comes out the same on any machine. Driven by
    29:  * tools/clip.mjs, which calls window.__clip.render(i) and pipes the frames into ffmpeg.
    30:  *   /?view=clip&model=block_dummy&shots=chase,turn&fps=24&palette=merc&look=kit
    31:  * Any model with the 22 joint rig. Lab lineups hold many frames under slots, so they don't rig.
    32:  */
    33: export async function startClip(canvas: HTMLCanvasElement, q: URLSearchParams) {
    34:   setLook(q.get('look'));
    35:   await document.fonts.ready;
    36:   const w = Number(q.get('w') ?? 854), h = Number(q.get('h') ?? 480), fps = Number(q.get('fps') ?? 24);
    37:   const shots = (q.get('shots')?.split(',') ?? DEFAULT_SHOTS) as ShotName[];
    38:   const frames = clipFrames(shots, fps);
    39: 
    40:   const scene = new THREE.Scene();
    41:   const camera = new THREE.PerspectiveCamera(35, w / h, 0.3, 2e5);
    42:   const backdrop = createBackdrop();
    43:   const pipe = new Pipeline(canvas, scene, camera, backdrop);
    44:   const tier = q.get('tier');
    45:   if (tier === 'medium' || tier === 'low') pipe.setQuality({ tier });
    46:   if (q.get('ao') === '1') pipe.setQuality({ ao: true });
    47:   pipe.resize(w, h);
    48:   const sun = addSpaceLight(scene);
    49:   pipe.shadowLight = sun;
    50:   const hemi = scene.children.find((o) => (o as THREE.HemisphereLight).isHemisphereLight) as THREE.HemisphereLight | undefined;
    51:   const rim = scene.getObjectByName('rim') as THREE.DirectionalLight | undefined;
    52:   const spaceEnv = spaceEnvironment(pipe.renderer, backdrop);
    53:   scene.environment = spaceEnv;
    54:   scene.environmentIntensity = 0.8 * look().fill;
    55: 
    56:   const name = (q.get('model') ?? 'striker') as ModelName;
    57:   const compareName = q.get('compare') as ModelName | null;
    58:   const palette = (q.get('palette') ?? 'merc') as PaletteName;
    59:   const trimColor = PALETTES[palette].trim.color;
    60:   const bearings = q.get('bearings') === '1';
    61:   const decorate = (m: ModelName, r: THREE.Object3D) => {
    62:     if (m === 'striker') applyDecals(r, STRIKER_DECALS);
    63:     if (m === 'carbon_0') applyDecals(r, CARBON_DECALS);
    64:     if (bearings) applyDecals(r, bearingDecals(r, trimColor));
    65:     treatEyes(r, 'spill');
    66:   };
    67:   const root = await model(name, palette);
    68:   decorate(name, root);
    69:   scene.add(root);
    70:   const rig = new MechRig(root);
    71:   root.updateMatrixWorld(true);
    72:   rig.apply(POSES.stand);
    73:   root.updateMatrixWorld(true);
    74:   const box = new THREE.Box3().setFromObject(root);
    75:   const height = box.getSize(new THREE.Vector3()).y;
    76:   const footY = box.min.y;
    77:   const size = height / 17.6;
    78:   const hangarSole = rig.soles(HANGAR_POSE);
    79:   const launchSole = rig.soles(POSES.launch);
    80:   rig.apply(POSES.stand);
    81: 
    82:   const weapon = q.get('weapon') as ModelName | null;
    83:   if (weapon) rig.hold(await model(weapon, palette));
    84: 
    85:   const light = new THREE.PointLight('#ffffff', 0, 0, 2);
    86:   scene.add(light);
    87: 
    88:   let root2: THREE.Object3D | null = null;
    89:   let rig2: MechRig | null = null;
    90:   const light2 = new THREE.PointLight('#ffffff', 0, 0, 2);
    91:   if (compareName) {
    92:     root2 = await model(compareName, palette);
    93:     decorate(compareName, root2);
    94:     scene.add(root2);
    95:     rig2 = new MechRig(root2);
    96:     rig2.apply(POSES.stand);
    97:     const weapon2 = (q.get('weapon2') ?? (compareName === 'striker' ? 'rifle' : weapon)) as ModelName | null;
    98:     if (weapon2) rig2.hold(await model(weapon2, palette));
    99:     scene.add(light2);
    100:     const sc = sun.shadow.camera;
    101:     sc.left = sc.bottom = -34;
    102:     sc.right = sc.top = 34;
    103:     sc.updateProjectionMatrix();
    104:   }
    105: 
    106:   // the ship hangar and catapult tube, loaded only when hangar or launch shots are requested
    107:   const needsShip = shots.includes('hangar') || shots.includes('launch');
    108:   const ship = needsShip ? await ShipRig.load() : null;
    109:   let roomEnv: THREE.Texture | null = null;
    110:   const shipLights: [THREE.PointLight, number][] = [];
    111:   const hangarKey = new THREE.PointLight('#fff3e0', 0, 44, 1.6);
    112:   hangarKey.position.set(-3.5, 9.5, 4.5);
    113:   if (ship) {
    114:     const pmrem = new THREE.PMREMGenerator(pipe.renderer);
    115:     roomEnv = pmrem.fromScene(new RoomEnvironment(), 0.04, 0.1, 100, { size: 256 }).texture;
    116:     pmrem.dispose();
    117:     ship.configure(['standard', 'standard'], 'standard');
    118:     for (const l of ship.lights) shipLights.push([l, l.intensity]);
    119:     scene.add(ship.root);
    120:     scene.add(hangarKey);
    121:     const bay2Name = (q.get('bay2') ?? (name === 'atelier_estoc' ? 'atelier_tilt' : 'striker_a')) as ModelName;
    122:     const spare = await model(bay2Name, palette);
    123:     if (bay2Name === 'striker') applyDecals(spare, STRIKER_DECALS);
    124:     if (bearings) applyDecals(spare, bearingDecals(spare, trimColor));
    125:     treatEyes(spare, 'spill');
    126:     spare.position.copy(ship.slots[1]?.standard[0] ?? ship.bays[1]);
    127:     spare.rotation.y = 0.36;
    128:     new MechRig(spare).apply(POSES.stand);
    129:     ship.root.add(spare);
    130:     const crew = await model('lab_pilot' as ModelName, palette);
    131:     crew.traverse((o) => { if (/^slot\d+$/.test(o.name) && o.name !== 'slot0') o.visible = false; });
    132:     crew.position.set(-1.1 + 0.55, 0.2, -2.6);
    133:     crew.rotation.y = Math.PI - 0.42;
    134:     ship.root.add(crew);
    135:   }
    136: 
    137:   // the pilot and deck for the standalone scale shot: a person is the one thing everyone knows the size of
    138:   const ground = new THREE.Group();
    139:   const deck = new THREE.Mesh(new THREE.CircleGeometry(height * 2, 48), new THREE.MeshStandardMaterial({ color: '#2a2f36', roughness: 0.85, metalness: 0.2 }));
    140:   deck.rotation.x = -Math.PI / 2;
    141:   deck.position.y = footY;
    142:   ground.add(deck);
    143:   const pilot = await model('lab_pilot' as ModelName, palette);
    144:   pilot.traverse((o) => { if (/^slot\d+$/.test(o.name) && o.name !== 'slot0') o.visible = false; });
    145:   // lab slot 0 stands at x = -.55: bring the pilot beside the frame's foot, facing the camera
    146:   pilot.position.set(0.55 + height * 0.3, footY, height * 0.16);
    147:   pilot.rotation.y = 0.4;
    148:   ground.add(pilot);
    149:   scene.add(ground);
    150: 
    151:   const setOutdoor = (out: number, keyBoost = 0) => {
    152:     sun.intensity = 0.22 + 2.98 * out;
    153:     if (rim) rim.intensity = 1.6 * out;
    154:     if (hemi) hemi.intensity = 0.16 + 0.09 * out;
    155:     scene.environment = roomEnv && out < 0.5 ? roomEnv : spaceEnv;
    156:     scene.environmentIntensity = (out < 0.5 ? 0.52 : 0.8) * look().fill;
    157:     const inside = 1 - THREE.MathUtils.smoothstep(out, 0.7, 1.0);
    158:     for (const [l, baseI] of shipLights) l.intensity = baseI * inside;
    159:     hangarKey.intensity = 110 * keyBoost;
    160:   };
    161: 
    162:   // the game's chase camera, read for its numbers: this view moves its own camera
    163:   const chase = new CameraRig();
    164:   const reading: ThrustReading = { x: 0, y: 0, z: 0, boosting: false };
    165:   const centre = new THREE.Vector3();
    166:   const offset = new THREE.Vector3();
    167:   const look_ = new THREE.Vector3();
    168:   const up = new THREE.Vector3(0, 1, 0);
    169:   const yawQ = new THREE.Quaternion();
    170:   const DT = 1 / 120;
    171:   let clock = 0, lastFrame = -2;
    172: 
    173:   const feed = (state: Parameters<typeof benchInput>[0], t: number, dt: number) => {
    174:     const f = benchInput(state, t);
    175:     reading.x = f.thrust.x;
    176:     reading.y = f.thrust.y;
    177:     reading.z = f.thrust.z;
    178:     reading.boosting = f.boosting;
    179:     reading.assault = f.assault;
    180:     reading.quick = f.quick;
    181:     rig.thrust(reading, clock, dt);
    182:     rig.lightExhaust(light);
    183:     if (rig2) {
    184:       rig2.thrust(reading, clock, dt);
    185:       rig2.lightExhaust(light2);
    186:     }
    187:   };
    188: 
    189:   const ease = (x: number) => x * x * (3 - 2 * x);
    190: 
    191:   const render = (i: number) => {
    192:     const f = frames[i];
    193:     const v = shotView(f);
    194:     // thrusters step at 120 Hz whatever the clip's frame rate, as a game would
    195:     const dt = f.cut ? 0 : 1 / fps;
    196:     if (f.cut || i !== lastFrame + 1) {
    197:       for (let k = 0; k < 120; k++) { clock += DT; feed('idle', k * DT, DT); }
    198:       for (let s = Math.max(0, f.stateT - 0.6); s < f.stateT - dt - 1e-9; s += DT) { clock += DT; feed(f.state, s, DT); }
    199:     }
    200:     lastFrame = i;
    201:     for (let s = 0; s < dt - 1e-9; s += DT) {
    202:       clock += DT;
    203:       feed(f.state, Math.max(0, f.stateT - dt + s), DT);
    204:     }
    205:     if (dt === 0) feed(f.state, f.stateT, 0);
    206: 
    207:     ground.visible = v.ground;
    208: 
    209:     if (v.hangar && ship) {
    210:       ship.root.visible = true;
    211:       ship.update({ phase: 'standby', t: 0, shuttle: 0, speed: 0, door: 0 });
    212:       setOutdoor(0, 1);
    213:       rig.apply(HANGAR_POSE);
    214:       root.position.set(3.4, 0.2 - hangarSole, -10.5);
    215:       root.rotation.set(0, -0.4, 0);
    216:       root.updateMatrixWorld(true);
    217:       const e = ease(f.u);
    218:       if (camera.fov !== 50) { camera.fov = 50; camera.updateProjectionMatrix(); }
    219:       camera.position.set(1.2 - 0.9 * e, 1.75 + 0.4 * e, 13.8 - 2.2 * e);
    220:       camera.up.copy(up);