Skip to content

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.

fix(verse): centre the cat torso above its stable floor anchor

rubenluetke10-beep119a140c812f
diff --git a/jarvis/ui/web/frontend/src/components/society/companion/PetModel.tsx b/jarvis/ui/web/frontend/src/components/society/companion/PetModel.tsx
index a922daac42..42bf4a1b7d 100644
--- a/jarvis/ui/web/frontend/src/components/society/companion/PetModel.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/companion/PetModel.tsx
@@ -8,7 +8,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { useGLTF } from "@react-three/drei";
import { useFrame } from "@react-three/fiber";
import {
- BoxGeometry, Color, InstancedMesh, Matrix4, MeshStandardMaterial, Object3D, Quaternion, Vector3, type Group,
+ Box3, BoxGeometry, Color, InstancedMesh, Matrix4, MeshStandardMaterial, Object3D, Quaternion, Vector3, type Group,
} from "three";
import type { CompanionPet } from "./petCompanions";
import { createRigState, rigPose, stepRig, type PartMotion, type PetMood } from "./petRig";
@@ -68,7 +68,18 @@ export function PetModel({ pet, drive, reduced, paused }: {
});
}
});
- return { model, parts };
+ const groundOffset = new Vector3();
+ if (pet.id === "miso") {
+ // The cat's torso sits behind the exported origin. Centre its rest-pose
+ // footprint once, before scaling/turning; animated paws, head and tail
+ // must never steer the floor marker or move the rotation pivot.
+ const torso = model.getObjectByName("miso_Torso");
+ if (torso) {
+ new Box3().setFromObject(torso).getCenter(groundOffset);
+ groundOffset.set(-groundOffset.x, 0, -groundOffset.z);
+ }
+ }
+ return { model, parts, groundOffset };
}, [scene, pet.id]);
const rig = useRef(createRigState());
const pose = useMemo(() => new Map<string, PartMotion>(), []);
@@ -83,7 +94,13 @@ export function PetModel({ pet, drive, reduced, paused }: {
if (part) applyMotion(part, motion);
}
});
- return <primitive object={instance.model} scale={pet.heightM / pet.modelHeightM} dispose={null} />;
+ return (
+ <group scale={pet.heightM / pet.modelHeightM}>
+ <group position={instance.groundOffset}>
+ <primitive object={instance.model} dispose={null} />
+ </group>
+ </group>
+ );
}
/** Reads a same-origin sprite sheet into voxel frames; null while loading or when unusable. */
diff --git a/jarvis/ui/web/frontend/src/components/society/office/GigiFlyer.tsx b/jarvis/ui/web/frontend/src/components/society/office/GigiFlyer.tsx
index ceb86add7c..711767d30b 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/GigiFlyer.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/GigiFlyer.tsx
@@ -139,6 +139,8 @@ export function GigiFlyer({ owner, mode, speaking, paused, reduced, clear, child
/** Floor markers and labels share the rendered position, without the body's lift, turn or scale. */
children?: ReactNode;
}) {
+ const pet = useCompanionPet((s) => s.pet);
+ const ground = !companionFlies(pet);
const groundRoot = useRef<Group>(null);
// JSX must not reset the animated anchor to a newer target on a React render,
// especially while paused or while switching between following and errands.
@@ -151,8 +153,8 @@ export function GigiFlyer({ owner, mode, speaking, paused, reduced, clear, child
const trail = useRef<Points>(null);
const light = useRef<PointLight>(null);
const orbit = useRef<Group>(null);
- const flight = useRef(createGigiFlight(owner.current.x, owner.current.z, owner.current.heading));
- const pose = useMemo(() => createGigiPose(), []);
+ const flight = useRef(createGigiFlight(owner.current.x, owner.current.z, owner.current.heading, ground));
+ const pose = useRef(createGigiPose(ground)).current;
const clock = useRef(0);
const last = useRef({ x: owner.current.x, z: owner.current.z });
const emitDebt = useRef(0);
@@ -160,8 +162,6 @@ export function GigiFlyer({ owner, mode, speaking, paused, reduced, clear, child
const side = useRef<1 | -1>(1);
const tint = useMemo(() => new Color(), []);
const appearance = useMemo(() => ({ ...defaultCompanion("jarvis"), sizeM: GIGI_OFFICE_SIZE_M }), []);
- const pet = useCompanionPet((s) => s.pet);
- const ground = !companionFlies(pet);
const groundRef = useRef(ground);
groundRef.current = ground;
const drive = useRef<PetDrive>({ speed: 0, mood: "idle" });
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.groundAnchor.test.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.groundAnchor.test.tsx
index 76845d5f60..d586b7d360 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.groundAnchor.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.groundAnchor.test.tsx
@@ -116,9 +116,11 @@ function groundObjects(scene: THREE.Scene) {
function expectCentered(scene: THREE.Scene) {
const { cat, ring } = groundObjects(scene);
- const at = cat.getWorldPosition(new THREE.Vector3());
+ const torso = cat.getObjectByName("miso_Torso");
+ if (!torso) throw new Error("The shipped cat must have its authored torso");
+ const at = new THREE.Box3().setFromObject(torso).getCenter(new THREE.Vector3());
const centre = ring.getWorldPosition(new THREE.Vector3());
- expect(Math.hypot(at.x - centre.x, at.z - centre.z), "cat ground pivot versus ring centre").toBeLessThan(1e-6);
+ expect(Math.hypot(at.x - centre.x, at.z - centre.z), "cat torso projection versus ring centre").toBeLessThan(1e-6);
// The parent floor is y=2 at scale 1.6; body hops and pulses cannot lift or resize the marker.
expect(centre.y).toBeCloseTo(2 + 0.015 * 1.6, 6);
expect(ring.getWorldScale(new THREE.Vector3()).x).toBeCloseTo(1.6, 6);
@@ -126,6 +128,15 @@ function expectCentered(scene: THREE.Scene) {
}
describe("the lead pet's floor anchor", () => {
+ it("starts on the floor instead of descending from a flyer's hover height", async () => {
+ const view = await mount(false);
+ view.scene.updateMatrixWorld(true);
+ const { cat } = groundObjects(view.scene);
+ expect(cat.getWorldPosition(new THREE.Vector3()).y).toBeCloseTo(2, 6);
+ await view.frame(1 / 60);
+ expect(cat.getWorldPosition(new THREE.Vector3()).y).toBeCloseTo(2, 6);
+ });
+
it.each([1 / 144, 1 / 30, 0.25])("keeps the real cat centred through motion and turns at dt=%s", async (dt) => {
const view = await mount(false);
// Straight travel, a right turn, a reversal, then standing still.
diff --git a/jarvis/ui/web/frontend/src/components/society/office/gigiFlight.test.ts b/jarvis/ui/web/frontend/src/components/society/office/gigiFlight.test.ts
index 1b954277fa..9761d9bbd5 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/gigiFlight.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/office/gigiFlight.test.ts
@@ -8,6 +8,22 @@ const MODES: GigiFlightMode[] = ["idle", "work", "talk", "wave", "sleep", "follo
const DT = 1 / 60;
describe("a pet on the floor (ground mode)", () => {
+ it("starts grounded and clears a previous flyer's height and bank immediately", () => {
+ expect(createGigiFlight(2, -3, 0.7, true).base).toBe(0);
+ expect(createGigiPose(true).y).toBe(0);
+ const state = createGigiFlight(2, -3);
+ state.pitch = 0.2;
+ state.roll = -0.3;
+ state.vBase = 0.4;
+ const pose = stepGigiFlight(state, {
+ targetX: 2, targetZ: -3, moving: false, mode: "idle", speaking: false, t: 0, dt: DT, ground: true,
+ });
+ expect(pose.y).toBe(0);
+ expect(pose.pitch).toBe(0);
+ expect(pose.roll).toBe(0);
+ expect(state.vBase).toBe(0);
+ });
+
it("lands on the floor, never leans or banks, and hops only while standing happy", () => {
const state = createGigiFlight(0, 0);
const pose = createGigiPose();
diff --git a/jarvis/ui/web/frontend/src/components/society/office/gigiFlight.ts b/jarvis/ui/web/frontend/src/components/society/office/gigiFlight.ts
index 7bf8bedc59..ad90423c0c 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/gigiFlight.ts
+++ b/jarvis/ui/web/frontend/src/components/society/office/gigiFlight.ts
@@ -130,15 +130,15 @@ function approach(rate: number, dt: number): number {
return 1 - Math.exp(-rate * dt);
}
-export function createGigiFlight(x: number, z: number, heading = 0): GigiFlightState {
+export function createGigiFlight(x: number, z: number, heading = 0, ground = false): GigiFlightState {
return {
- x, z, vx: 0, vz: 0, base: GIGI_HOVER_M, vBase: 0, yaw: heading, pitch: 0, roll: 0, spin: 0,
+ x, z, vx: 0, vz: 0, base: ground ? 0 : GIGI_HOVER_M, vBase: 0, yaw: heading, pitch: 0, roll: 0, spin: 0,
idleBlend: 1, workBlend: 0, sleepBlend: 0, happyBlend: 0, glow: 0.35, scale: 1,
};
}
-export function createGigiPose(): GigiFlightPose {
- return { x: 0, y: GIGI_HOVER_M, z: 0, yaw: 0, pitch: 0, roll: 0, scale: 1, glow: 0.35, speed: 0 };
+export function createGigiPose(ground = false): GigiFlightPose {
+ return { x: 0, y: ground ? 0 : GIGI_HOVER_M, z: 0, yaw: 0, pitch: 0, roll: 0, scale: 1, glow: 0.35, speed: 0 };
}
/**
@@ -205,7 +205,8 @@ export function stepGigiFlight(state: GigiFlightState, input: GigiFlightInput, o
// ---- Height -------------------------------------------------------------
const baseTarget = ground ? 0
: mode === "sleep" && !input.speaking ? GIGI_SLEEP_HOVER_M : mode === "follow" ? GIGI_FOLLOW_HOVER_M : GIGI_HOVER_M;
- if (reduced) { state.base = baseTarget; state.vBase = 0; }
+ // Ground pets start on the floor, also when replacing a hovering companion.
+ if (ground || reduced) { state.base = baseTarget; state.vBase = 0; }
else if (dt > 0) {
springStep(state.base, state.vBase, baseTarget, HEIGHT_OMEGA, dt, scratch);
state.base = scratch[0]; state.vBase = scratch[1];
@@ -246,8 +247,10 @@ export function stepGigiFlight(state: GigiFlightState, input: GigiFlightInput, o
const leanTarget = reduced || ground ? 0 : GIGI_MAX_LEAN * clamp(speed / LEAN_FULL_SPEED, 0, 1);
// Turning towards +x (yaw increasing) tips the top towards +x: negative roll.
const bankTarget = reduced || ground ? 0 : clamp(-yawRate * clamp(speed, 0, 2) * 0.12, -MAX_BANK, MAX_BANK);
- state.pitch += (leanTarget - state.pitch) * approach(6, dt);
- state.roll += (bankTarget - state.roll) * approach(6, dt);
+ // A freshly selected ground pet must not inherit a flyer's fading lean:
+ // tilting a raised torso shifts its projection away from the floor marker.
+ state.pitch = ground ? 0 : state.pitch + (leanTarget - state.pitch) * approach(6, dt);
+ state.roll = ground ? 0 : state.roll + (bankTarget - state.roll) * approach(6, dt);
// ---- Happy spin (wave): one full turn every few seconds, always finished ----
if (reduced) state.spin = 0;