Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(office): stop the floor flickering in black bands when zooming out
rubenluetke10-beep6b81eaf6692e
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeCameraRig.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeCameraRig.tsxindex ace8f61874..151644fa46 100644--- a/jarvis/ui/web/frontend/src/components/society/office/OfficeCameraRig.tsx+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeCameraRig.tsx@@ -15,7 +15,7 @@ import { OrbitControls } from "@react-three/drei";import { useFrame, useThree } from "@react-three/fiber";import { MOUSE, Vector3, type PerspectiveCamera } from "three";import type { OrbitControls as OrbitControlsImpl } from "three-stdlib";-import { cameraHome, CAMERA_LIMITS, DRAG_CLICK_PX, HOME_PITCH_RAD, HOME_YAW_RAD, wheelZoomSpeed } from "./officeCamera";+import { cameraHome, CAMERA_LIMITS, depthNear, DRAG_CLICK_PX, HOME_PITCH_RAD, HOME_YAW_RAD, wheelZoomSpeed } from "./officeCamera";import { seatOf, type OfficeLayout } from "./officeLayout";import { useLeadSeat } from "./leadSeat";import { cameraView, officeSession, player, useOfficeStore } from "./officeStore";@@ -207,6 +207,17 @@ export function OfficeCameraRig({ layout, overview }: { layout: OfficeLayout; ov};}, [connected, gl]);+ // The near plane follows the zoom, or coplanar layers (oak over slab) fight in bands when zoomed out.+ useFrame(() => {+ const c = controls.current;+ const lens = camera as PerspectiveCamera;+ if (!c || !lens.isPerspectiveCamera) return;+ const near = depthNear(camera.position.distanceTo(c.target));+ if (Math.abs(near - lens.near) < lens.near * 0.05) return;+ lens.near = near;+ lens.updateProjectionMatrix();+ });+useFrame((_, rawDt) => {const c = controls.current;if (!c) return;diff --git a/jarvis/ui/web/frontend/src/components/society/office/officeCamera.test.ts b/jarvis/ui/web/frontend/src/components/society/office/officeCamera.test.tsindex 522154d0d1..246c88b5c7 100644--- a/jarvis/ui/web/frontend/src/components/society/office/officeCamera.test.ts+++ b/jarvis/ui/web/frontend/src/components/society/office/officeCamera.test.ts@@ -1,5 +1,5 @@import { describe, expect, it } from "vitest";-import { cameraHome, CAMERA_LIMITS, wheelZoomSpeed } from "./officeCamera";+import { cameraHome, CAMERA_LIMITS, depthNear, wheelZoomSpeed } from "./officeCamera";/** OrbitControls' dolly factor for one wheel event at this zoom speed. */const step = (speed: number) => 1 / Math.pow(0.95, speed);@@ -34,3 +34,24 @@ describe("office wheel zoom", () => {expect(CAMERA_LIMITS.minDistance).toBeGreaterThanOrEqual(2);});});++/** Smallest depth step a 24-bit buffer resolves at `depth` metres with this near plane. */+const depthStep = (depth: number, near: number) => (depth * depth) / (near * 2 ** 24);++describe("office depth precision", () => {+ it("keeps the oak floor 1 mm above the slab resolvable at every zoom", () => {+ for (const distance of [CAMERA_LIMITS.minDistance, 15, 40, 90, CAMERA_LIMITS.maxDistance]) {+ // The far edge of the floor lies up to ~30 m behind the orbit target.+ expect(depthStep(distance + 30, depthNear(distance))).toBeLessThan(0.001);+ }+ });++ it("never clips the floor or the walls in front of the camera", () => {+ for (const distance of [CAMERA_LIMITS.minDistance, 15, 40, 90, CAMERA_LIMITS.maxDistance]) {+ // At the flattest allowed tilt the camera still stands this high above the floor.+ const height = distance * Math.cos(CAMERA_LIMITS.maxPolar);+ expect(depthNear(distance)).toBeLessThan(Math.max(0.5, height - 3));+ }+ expect(depthNear(CAMERA_LIMITS.minDistance)).toBe(0.2);+ });+});diff --git a/jarvis/ui/web/frontend/src/components/society/office/officeCamera.ts b/jarvis/ui/web/frontend/src/components/society/office/officeCamera.tsindex f0764aaa17..2600c2115f 100644--- a/jarvis/ui/web/frontend/src/components/society/office/officeCamera.ts+++ b/jarvis/ui/web/frontend/src/components/society/office/officeCamera.ts@@ -13,6 +13,23 @@ export const CAMERA_LIMITS = {maxDistance: 140,} as const;+/** Near clip plane up close, and the most it may grow to when zoomed out. */+const NEAR_MIN = 0.2;+const NEAR_MAX = 6;+/** Near plane per metre of orbit distance: the closest geometry is always far more than this in front. */+const NEAR_PER_METRE = 0.04;++/**+ * The near clip plane for a camera this far from its orbit target. Depth+ * precision falls with distance squared over the near plane: with a fixed+ * 0.2 m near plane, the oak floor 1 mm above the dark slab fought it in black+ * bands once the camera was zoomed out (~0.6 cm of precision at 140 m).+ * Growing the near plane with the zoom keeps it under a millimetre everywhere.+ */+export function depthNear(distance: number): number {+ return Math.min(NEAR_MAX, Math.max(NEAR_MIN, distance * NEAR_PER_METRE));+}+/*** A press that travelled further than this (CSS px) turned the camera; the* click it ends in is not a click. Measured over the whole press, so a drag