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): wear the halo, crown and drone on the figure

rubenluetke10-beepceb21c59c49f
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.tsx
index d960713f0d..ed9d1fbd05 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficeAgents.tsx
@@ -41,7 +41,7 @@ import { agentLogoAsset } from "@/components/agentic/AgentMark";
import { LevelChip } from "../progression/LevelHud";
import { agentSubject, petSubject } from "../progression/progressionApi";
import { useProgression } from "../progression/progressionStore";
-import { AngelWings, useWearsWings } from "../progression/effects/AngelWings";
+import { figureGadgetSlots, useWornGadget } from "../progression/wornGadget";
/** The agent's symbol walks behind it as a little pet, about a fifth of its height. */
export const PET_SIZE_M = 0.26;
@@ -225,7 +225,8 @@ function Walker({ agent, desk, ctx, arrivesByElevator, awake, reduced, selected,
const body = useRef<Group>(null);
const ring = useRef<Mesh>(null);
const drive = useRef<FigureDrive>({ mode: "idle", speed: 0 });
- const wings = useWearsWings("agent", agentSubject(agent.agentId));
+ const gadget = useWornGadget("agent", agentSubject(agent.agentId));
+ const worn = figureGadgetSlots(gadget, { drive, top: OFFICE_FIGURE_HEIGHT_M + 0.02, paused: !awake, reduced });
const rng = useMemo(() => createRng(agent.agentId), [agent.agentId]);
const mover = useRef<Mover>({ ...(arrivesByElevator ? ctx.spawn : { x: 0, z: 0 }), heading: Math.PI, path: [] });
const plan = useRef<Plan | null>(null);
@@ -428,7 +429,8 @@ function Walker({ agent, desk, ctx, arrivesByElevator, awake, reduced, selected,
onPointerOver={() => { document.body.style.cursor = "pointer"; }}
onPointerOut={() => { document.body.style.cursor = ""; }}>
{!isGigi && <ToyFigure look={look} drive={drive} paused={!awake} heightM={OFFICE_FIGURE_HEIGHT_M} seatHeight={seatHeight}
- back={wings ? <AngelWings drive={drive} paused={!awake} reduced={reduced} /> : undefined} />}
+ back={worn.back} headwear={worn.headwear} />}
+ {!isGigi && worn.beside}
</group>
<Nameplate agent={agent} activity={activity} selected={selected} onSelect={onSelect} height={isGigi ? leadPlate : undefined} />
<AgentBubble agent={agent} lines={lines} selected={selected} onSelect={onSelect}
diff --git a/jarvis/ui/web/frontend/src/components/society/office/OfficePlayer.tsx b/jarvis/ui/web/frontend/src/components/society/office/OfficePlayer.tsx
index f09ff51663..033d5ee309 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/OfficePlayer.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/OfficePlayer.tsx
@@ -25,7 +25,7 @@ import { jumpSquash, newJump, pressJump, stepJump } from "./officeJump";
import { useProgression } from "../progression/progressionStore";
import { PERSON_SUBJECT } from "../progression/progressionApi";
import { LevelChip } from "../progression/LevelHud";
-import { AngelWings, useWearsWings } from "../progression/effects/AngelWings";
+import { figureGadgetSlots, useWornGadget } from "../progression/wornGadget";
/** The person's pace: a brisk walk, and a sprint on Shift (m/s). */
export const PLAYER_WALK_SPEED = 2.0;
@@ -165,8 +165,9 @@ export function OfficePlayer({ layout, grid, look, name, awake, reduced }: {
if (state.cheerUntil > prev.cheerUntil && !reduced) pressJump(jump);
}), [jump, reduced]);
const level = useProgression((s) => (s.snapshot ? s.subjects[PERSON_SUBJECT]?.level ?? 1 : null));
- const wings = useWearsWings("person", PERSON_SUBJECT);
+ const gadget = useWornGadget("person", PERSON_SUBJECT);
const airborne = useMemo(() => () => jump.airborne, [jump]);
+ const worn = figureGadgetSlots(gadget, { drive, top: OFFICE_FIGURE_HEIGHT_M + 0.02, airborne, paused: !awake, reduced });
// Arrive by the elevator once per app run; coming back to the map keeps the
// character where it was, unless a changed floor plan put that spot in a wall.
@@ -294,7 +295,8 @@ export function OfficePlayer({ layout, grid, look, name, awake, reduced }: {
</mesh>
<group ref={body}>
<ToyFigure look={look} drive={drive} paused={!awake} heightM={OFFICE_FIGURE_HEIGHT_M} holding={hasBone ? <TreatBone scale={1.15} /> : undefined}
- back={wings ? <AngelWings drive={drive} airborne={airborne} paused={!awake} reduced={reduced} /> : undefined} />
+ back={worn.back} headwear={worn.headwear} />
+ {worn.beside}
{!firstPerson && (
<Html center position={[0, OFFICE_FIGURE_HEIGHT_M + 0.35, 0]} zIndexRange={[25, 0]}>
<span className="office-plate office-plate-player" data-office-ui>
diff --git a/jarvis/ui/web/frontend/src/components/society/office/ToyFigure.tsx b/jarvis/ui/web/frontend/src/components/society/office/ToyFigure.tsx
index 3da1b85715..b86f824d76 100644
--- a/jarvis/ui/web/frontend/src/components/society/office/ToyFigure.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/office/ToyFigure.tsx
@@ -171,6 +171,12 @@ function HairCap({ color, grow = 0, fringe = true }: { color: string; grow?: num
);
}
+/** How far each hair style or hat rises above the bare head top, so headwear sits on it instead of inside it. */
+const HAIR_TOP: Record<HairStyle, number> = {
+ bald: 0, buzz: 0.012, short: 0.035, slick: 0.035, sidepart: 0.04, long: 0.035, ponytail: 0.035,
+ curly: 0.07, bun: 0.06, spiky: 0.08, beanie: 0.06, cap: 0.035,
+};
+
const SPIKES: Array<[number, number, number, number, number]> = [
[0, 0.6, 0.1, 0.75, 0], [-0.12, 0.6, 0.04, 0.35, 0.45], [0.12, 0.6, 0.04, 0.35, -0.45],
[0, 0.62, -0.05, -0.2, 0], [-0.21, 0.52, -0.04, -0.1, 0.95], [0.21, 0.52, -0.04, -0.1, -0.95],
@@ -524,9 +530,11 @@ export interface ToyFigureProps {
holding?: ReactNode;
/** Worn on the upper back (e.g. the level wings); rides the torso through every hop and lean. */
back?: ReactNode;
+ /** Worn on top of the head (e.g. the level halo or crown); rides every nod, hop and lean. */
+ headwear?: ReactNode;
}
-export function ToyFigure({ look, drive, paused, heightM = TOY_HEIGHT, seatHeight = 0.52, holding, back }: ToyFigureProps) {
+export function ToyFigure({ look, drive, paused, heightM = TOY_HEIGHT, seatHeight = 0.52, holding, back, headwear }: ToyFigureProps) {
const holds = useRef(false);
holds.current = !!holding;
const scale = heightM / TOY_HEIGHT;
@@ -628,6 +636,7 @@ export function ToyFigure({ look, drive, paused, heightM = TOY_HEIGHT, seatHeigh
<Face look={look} />
<Eyewear look={look} />
<Hair style={look.hairStyle} look={look} />
+ {headwear && <group position={[0, HD.y + HD.ry + HAIR_TOP[look.hairStyle] + 0.02, 0]}>{headwear}</group>}
</group>
</group>
</group>
diff --git a/jarvis/ui/web/frontend/src/components/society/progression/ProgressionLayer.tsx b/jarvis/ui/web/frontend/src/components/society/progression/ProgressionLayer.tsx
index 554af9115f..b5b7a4ad26 100644
--- a/jarvis/ui/web/frontend/src/components/society/progression/ProgressionLayer.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/progression/ProgressionLayer.tsx
@@ -43,15 +43,16 @@ function agentSource(agentId: string): FlairSource {
};
}
-function Flair({ loadout, source, topSource, top, scale, paused, reduced }: {
+/** `gadgetOnFigure`: the wearer is a figure that wears its gadget on its own body (`wornGadget.tsx`). */
+function Flair({ loadout, source, topSource, top, scale, paused, reduced, gadgetOnFigure = false }: {
loadout: Loadout; source: FlairSource; topSource?: FlairSource; top: number; scale: number; paused: boolean; reduced: boolean;
+ gadgetOnFigure?: boolean;
}) {
return (
<>
{loadout.aura && <CosmeticAura kind={loadout.aura as AuraKind} source={source} scale={scale} paused={paused} reduced={reduced} />}
{loadout.trail && !reduced && <CosmeticTrail kind={loadout.trail as TrailKind} source={source} scale={scale} paused={paused} />}
- {/* The wings are worn on the figure itself (AngelWings in ToyFigure's back slot), not floated beside it. */}
- {loadout.gadget && loadout.gadget !== "gadget_wings" && <CosmeticGadget kind={loadout.gadget as GadgetKind} source={topSource ?? source} top={top} scale={scale}
+ {loadout.gadget && !gadgetOnFigure && <CosmeticGadget kind={loadout.gadget as GadgetKind} source={topSource ?? source} top={top} scale={scale}
paused={paused} reduced={reduced} />}
</>
);
@@ -59,7 +60,7 @@ function Flair({ loadout, source, topSource, top, scale, paused, reduced }: {
function AgentFlair({ agentId, loadout, paused, reduced }: { agentId: string; loadout: Loadout; paused: boolean; reduced: boolean }) {
const source = useMemo(() => agentSource(agentId), [agentId]);
- return <Flair loadout={loadout} source={source} top={OFFICE_FIGURE_HEIGHT_M + 0.02} scale={1} paused={paused} reduced={reduced} />;
+ return <Flair loadout={loadout} source={source} top={OFFICE_FIGURE_HEIGHT_M + 0.02} scale={1} paused={paused} reduced={reduced} gadgetOnFigure />;
}
/** Where a subject stands, for a burst or a "+XP", and how tall it is there. */
@@ -131,7 +132,7 @@ export function ProgressionLayer({ agents, awake, reduced }: { agents: ReadonlyM
return (
<group>
- <Flair loadout={personLoadout} source={personSource} top={OFFICE_FIGURE_HEIGHT_M + 0.02} scale={1} paused={paused} reduced={reduced} />
+ <Flair loadout={personLoadout} source={personSource} top={OFFICE_FIGURE_HEIGHT_M + 0.02} scale={1} paused={paused} reduced={reduced} gadgetOnFigure />
<Flair loadout={petLoadout} source={petSource} topSource={petTopSource} top={0.5} scale={0.55} paused={paused} reduced={reduced} />
{agentLoadouts.map(({ agentId, loadout }) => <AgentFlair key={agentId} agentId={agentId} loadout={loadout} paused={paused} reduced={reduced} />)}
{bursts.map((burst) => {
diff --git a/jarvis/ui/web/frontend/src/components/society/progression/effects/AngelWings.tsx b/jarvis/ui/web/frontend/src/components/society/progression/effects/AngelWings.tsx
index 0fd5f96c0f..584b678507 100644
--- a/jarvis/ui/web/frontend/src/components/society/progression/effects/AngelWings.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/progression/effects/AngelWings.tsx
@@ -21,8 +21,6 @@ import {
type Group, type InstancedMesh, type Material, type Points,
} from "three";
import type { FigureMode } from "../../figures/FigureRig";
-import { useProgression } from "../progressionStore";
-import { equippedFor } from "../cosmetics";
import { glowTexture, starTexture } from "./flairTextures";
/** One feather in its wing's plane: x points away from the body, y up (rig metres). */
@@ -368,13 +366,3 @@ export function AngelWings({ drive, airborne, paused, reduced }: {
</group>
);
}
-
-/** True when this subject currently wears the wings (unlocked, and not swapped out by the person). */
-export function useWearsWings(kind: "person" | "agent", subjectId: string): boolean {
- return useProgression((s) => {
- const rewards = s.snapshot?.rewards;
- const level = s.subjects[subjectId]?.level;
- if (!rewards || !level) return false;
- return equippedFor(rewards, kind, level, kind === "person" ? s.choices.person : undefined).gadget === "gadget_wings";
- });
-}
diff --git a/jarvis/ui/web/frontend/src/components/society/progression/effects/CosmeticWear.tsx b/jarvis/ui/web/frontend/src/components/society/progression/effects/CosmeticWear.tsx
index 702e5b7940..d063112903 100644
--- a/jarvis/ui/web/frontend/src/components/society/progression/effects/CosmeticWear.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/progression/effects/CosmeticWear.tsx
@@ -1,7 +1,9 @@
/**
* What a levelled-up figure wears: an aura on the floor under it and a
- * gadget on or around it. Both follow the wearer's ground position every
- * frame; nothing here is solid, casts a shadow or takes a click.
+ * gadget on or around it. The aura follows the wearer's ground position
+ * every frame; a figure wears its gadget on its own body (`wornGadget.tsx`)
+ * and only the pet's follows a position. Nothing here is solid, casts a
+ * shadow or takes a click.
*
* Auras: a warm glow, a turning rune circle, a crackling storm ring and the
* prismatic legend circle with rising motes. Gadgets: a hovering drone, a
@@ -173,15 +175,21 @@ function Motes({ radius, paused }: { radius: number; paused: boolean }) {
// ------------------------------------------------------------------ gadgets
-/** `top` is the height of the wearer's head top above the floor. */
-export function CosmeticGadget({ kind, source, top, scale = 1, paused, reduced }: {
- kind: GadgetKind; source: FlairSource; top: number; scale?: number; paused: boolean; reduced: boolean;
+/**
+ * A gadget drawn around its own origin, which is the top of the wearer's
+ * head. A figure wears it in its head slot (halo, crown) or body group
+ * (drone) so it rides every hop; the pet's follows its position instead.
+ */
+export function GadgetModel({ kind, scale = 1, paused, reduced }: {
+ kind: GadgetKind; scale?: number; paused: boolean; reduced: boolean;
}) {
const spinner = useRef<Group>(null);
const extra = useRef<Group>(null);
const blink = useRef<Mesh>(null);
- const group = useFollow(source, paused, (g, at, t) => {
- g.position.set(at.x, at.y ?? top, at.z);
+ const clock = useRef(Math.random() * 10);
+ useFrame((_, rawDt) => {
+ clock.current += paused ? 0 : Math.min(rawDt, 0.1);
+ const t = clock.current;
const calm = reduced ? 0 : 1;
if (kind === "gadget_halo" && spinner.current) {
spinner.current.position.y = 0.14 * scale + 0.025 * Math.sin(t * 2.2) * calm;
@@ -199,7 +207,7 @@ export function CosmeticGadget({ kind, source, top, scale = 1, paused, reduced }
});
const [main, accent] = EFFECT_COLOURS[kind];
return (
- <group ref={group}>
+ <group>
{kind === "gadget_halo" && (
<group ref={spinner}>
<mesh rotation={[Math.PI / 2, 0, 0]}>
@@ -256,3 +264,15 @@ export function CosmeticGadget({ kind, source, top, scale = 1, paused, reduced }
</group>
);
}
+
+/** A gadget that follows a ground position; `top` is the wearer's head-top height above the floor. */
+export function CosmeticGadget({ kind, source, top, scale = 1, paused, reduced }: {
+ kind: GadgetKind; source: FlairSource; top: number; scale?: number; paused: boolean; reduced: boolean;
+}) {
+ const group = useFollow(source, paused, (g, at) => { g.position.set(at.x, at.y ?? top, at.z); });
+ return (
+ <group ref={group}>
+ <GadgetModel kind={kind} scale={scale} paused={paused} reduced={reduced} />
+ </group>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/components/society/progression/hall/LoadoutPreview.tsx b/jarvis/ui/web/frontend/src/components/society/progression/hall/LoadoutPreview.tsx
index d9671afeb1..3b9fc8efe1 100644
--- a/jarvis/ui/web/frontend/src/components/society/progression/hall/LoadoutPreview.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/progression/hall/LoadoutPreview.tsx
@@ -28,7 +28,7 @@ import { OFFICE_FIGURE_HEIGHT_M } from "../../office/OfficeAgents";
import { ToyFigure } from "../../office/ToyFigure";
import type { ToyLook } from "../../office/toyFigureModel";
import type { Loadout } from "../cosmetics";
-import { AngelWings } from "../effects/AngelWings";
+import { figureGadgetSlots } from "../wornGadget";
import { CosmeticTrail, type FlairSource, type TrailKind } from "../effects/CosmeticTrail";
import { CosmeticAura, CosmeticGadget, type AuraKind, type GadgetKind } from "../effects/CosmeticWear";
@@ -66,6 +66,7 @@ function PreviewScene({ subject, loadout, paused, reduced, spin }: {
const walkR = WALK_R / grow;
const scale = pet ? 0.5 : 1;
const gigi = useMemo(() => ({ ...defaultCompanion("jarvis"), sizeM: GIGI_OFFICE_SIZE_M }), []);
+ const worn = figureGadgetSlots(pet ? null : (loadout.gadget as GadgetKind | undefined), { drive: figureDrive, top, paused, reduced });
useFrame((_, rawDt) => {
const dt = paused ? 0 : Math.min(rawDt, 0.1);
@@ -118,13 +119,16 @@ function PreviewScene({ subject, loadout, paused, reduced, spin }: {
</Suspense>
</ModelBoundary>
) : (
- <ToyFigure look={(subject as Extract<PreviewSubject, { kind: "person" }>).look} drive={figureDrive} paused={paused} heightM={OFFICE_FIGURE_HEIGHT_M}
- back={loadout.gadget === "gadget_wings" ? <AngelWings drive={figureDrive} paused={paused} reduced={reduced} /> : undefined} />
+ <>
+ <ToyFigure look={(subject as Extract<PreviewSubject, { kind: "person" }>).look} drive={figureDrive} paused={paused} heightM={OFFICE_FIGURE_HEIGHT_M}
+ back={worn.back} headwear={worn.headwear} />
+ {worn.beside}
+ </>
)}
</group>
{loadout.aura && <CosmeticAura key={loadout.aura} kind={loadout.aura as AuraKind} source={ground} scale={scale} paused={paused} reduced={reduced} />}
{walking && <CosmeticTrail key={loadout.trail} kind={loadout.trail as TrailKind} source={ground} scale={scale} paused={paused} />}
- {loadout.gadget && loadout.gadget !== "gadget_wings" && (
+ {loadout.gadget && pet && (
<CosmeticGadget key={loadout.gadget} kind={loadout.gadget as GadgetKind} source={head} top={top} scale={scale} paused={paused} reduced={reduced} />
)}
</group>
diff --git a/jarvis/ui/web/frontend/src/components/society/progression/wornGadget.tsx b/jarvis/ui/web/frontend/src/components/society/progression/wornGadget.tsx
new file mode 100644
index 0000000000..6519962388
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/components/society/progression/wornGadget.tsx
@@ -0,0 +1,60 @@
+/**
+ * Gadgets a figure (the person or an agent) wears on its own body, so they
+ * ride every hop, bob and lean instead of floating at a fixed height: the
+ * wings on its back, the halo and the crown on its head, the drone beside it
+ * in the body's frame. The pet keeps its gadget in `ProgressionLayer`.
+ */
+import type { ReactNode } from "react";
+import type { FigureMode } from "../figures/FigureRig";
+import { equippedFor } from "./cosmetics";
+import { useProgression } from "./progressionStore";
+import { AngelWings, type WingMotion } from "./effects/AngelWings";
+import { GadgetModel, type GadgetKind } from "./effects/CosmeticWear";
+
+/** The gadget this figure wears right now, or null (unlocked, and not swapped out by the person). */
+export function useWornGadget(kind: "person" | "agent", subjectId: string): GadgetKind | null {
+ return useProgression((s) => {
+ const rewards = s.snapshot?.rewards;
+ const level = s.subjects[subjectId]?.level;
+ if (!rewards || !level) return null;
+ const gadget = equippedFor(rewards, kind, level, kind === "person" ? s.choices.person : undefined).gadget;
+ return (gadget as GadgetKind | undefined) ?? null;
+ });
+}
+
+export interface FigureGadgetSlots {
+ /** For ToyFigure's `back` slot. */
+ back?: ReactNode;
+ /** For ToyFigure's `headwear` slot. */
+ headwear?: ReactNode;
+ /** Rendered beside the figure inside the group that carries its hop. */
+ beside?: ReactNode;
+}
+
+const HEADWEAR_SCALE = 1.25;
+
+/** Where a figure wears `gadget`; every slot is empty when it wears none. */
+export function figureGadgetSlots(gadget: GadgetKind | null | undefined, opts: {
+ drive: { current: { mode: FigureMode } };
+ /** Height of the figure's head top above its feet (m); the drone hovers off it. */
+ top: number;
+ paused: boolean;
+ reduced: boolean;
+} & WingMotion): FigureGadgetSlots {
+ const { drive, top, paused, reduced, airborne } = opts;
+ if (gadget === "gadget_wings") return { back: <AngelWings drive={drive} airborne={airborne} paused={paused} reduced={reduced} /> };
+ if (gadget === "gadget_halo" || gadget === "gadget_crown") {
+ // A touch larger than the pet's, so it reads on a full-size head.
+ return { headwear: <GadgetModel key={gadget} kind={gadget} scale={HEADWEAR_SCALE} paused={paused} reduced={reduced} /> };
+ }
+ if (gadget === "gadget_drone") {
+ return {
+ beside: (
+ <group position={[0, top, 0]}>
+ <GadgetModel kind={gadget} paused={paused} reduced={reduced} />
+ </group>
+ ),
+ };
+ }
+ return {};
+}