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.

feat(society): let the stars of a starry design twinkle on 3D agent faces (#615)

Ruben Lütkea3b749aa83fa
diff --git a/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx b/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx
index 6fbf462950..a2efa72972 100644
--- a/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/AgentSymbol.tsx
@@ -20,7 +20,7 @@ import {
} from "./companion/accessories";
import type { FigureLook } from "./companion/figureScene";
import { ShapeFigure, useFiguresSupported } from "./companion/ShapeFigure";
-import { SkinDefs, SkinGlow, SkinOverlay } from "./companion/SkinLayers";
+import { SkinDefs, SkinGlow, SkinOverlay, SkinStars } from "./companion/SkinLayers";
import { SKIN_EFFECTS, skinEffect, skinHighlight, type CompanionSkin } from "./companion/skins";
import "./agentSymbol.css";
export type { SymbolShape } from "./companion/appearance";
@@ -197,6 +197,7 @@ function FigureSymbol(props: SymbolProps) {
const eyeY = symbolEyeY(shape);
return <ShapeFigure look={look} size={size} shape={shape} fallback={<FlatSymbol {...props} />}
flow={skin && effect === "flow" ? { colors: skin.colors, angle: skin.angle } : undefined} shine={effect === "shimmer"}
+ inside={effect === "stars" ? <SkinStars /> : undefined}
smoke={(plume, index) => <SmokePuffs c={[0, 0, 0]} size={plume.size} fill={plume.fill} id={`${id}-smoke-${index}`} />}
behind={skin && effect === "glow" ? <span aria-hidden className="agent-figure-halo" style={{ background: `radial-gradient(closest-side, ${skinHighlight(skin.colors)}, transparent)` }} /> : undefined}
overlay={skin && effect === "sparkle" ? <svg aria-hidden focusable="false" viewBox="0 0 40 44" className="society-agent-symbol"><SkinOverlay id={id} skin={skin} body={() => null} /></svg> : undefined}>
diff --git a/jarvis/ui/web/frontend/src/components/society/agentSymbol.css b/jarvis/ui/web/frontend/src/components/society/agentSymbol.css
index da4459bb44..2761e6ad6c 100644
--- a/jarvis/ui/web/frontend/src/components/society/agentSymbol.css
+++ b/jarvis/ui/web/frontend/src/components/society/agentSymbol.css
@@ -157,7 +157,8 @@
/* Effects that move across the body: layers over the still picture, cut to the body's outline by a mask
of the same picture and moved by transforms only. */
.agent-figure-picture > .agent-figure-flow,
-.society-agent-figure > .agent-figure-shine {
+.society-agent-figure > .agent-figure-shine,
+.society-agent-figure > .agent-figure-inside {
position: absolute;
inset: 0;
overflow: hidden;
@@ -168,6 +169,13 @@
mask-repeat: no-repeat;
}
+.agent-figure-inside > svg {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+}
+
/* A flowing design: the body is drawn white with its light and shade, and the colours are multiplied onto
it, so they run over a lit volume. One gradient period spans the face; the strip moves by exactly one. */
.agent-figure-picture > .agent-figure-flow { mix-blend-mode: multiply; }
diff --git a/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx b/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx
index b202a06b86..c661cd0956 100644
--- a/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/companion/ShapeFigure.tsx
@@ -58,7 +58,7 @@ function outlineUrl(figure: Figure, grown: boolean): string | undefined {
* colours of a flowing design (multiplied onto a white body), the shine of a
* shimmering one, both cut to the body's outline, and the smoke of a cigar.
*/
-export function ShapeFigure({ look, size, shape, behind, children, overlay, fallback, flow, shine, smoke }: {
+export function ShapeFigure({ look, size, shape, behind, children, overlay, fallback, flow, shine, inside, smoke }: {
look: FigureLook; size: number;
/** Shown when this look could not be drawn and no earlier picture is there. */
fallback: ReactNode;
@@ -72,6 +72,8 @@ export function ShapeFigure({ look, size, shape, behind, children, overlay, fall
flow?: { colors: readonly string[]; angle: number };
/** A shine sweeps across the body. */
shine?: boolean;
+ /** Drawn on the body in the flat symbol's units and cut to its outline (twinkling stars). */
+ inside?: ReactNode;
/** Draws one plume of smoke, in symbol units around its source. */
smoke?: (plume: FigureSmoke, index: number) => ReactNode;
children?: ReactNode;
@@ -119,6 +121,11 @@ export function ShapeFigure({ look, size, shape, behind, children, overlay, fall
</span>}
</span>
{cut && shine && <span aria-hidden className="agent-figure-shine" style={cut}><i /></span>}
+ {cut && shown && inside && <span aria-hidden className="agent-figure-inside" style={cut}>
+ <svg focusable="false" viewBox={`0 0 ${shown.pixels} ${shown.pixels}`} className="society-agent-symbol">
+ <g transform={`matrix(${shown.face.map(value => +value.toFixed(4)).join(" ")})`}>{inside}</g>
+ </svg>
+ </span>}
{shown && children && <svg aria-hidden focusable="false" viewBox={`0 0 ${shown.pixels} ${shown.pixels}`} className="society-agent-symbol" data-expressive="true">
<g transform={`matrix(${shown.face.map(value => +value.toFixed(4)).join(" ")})`}>{children}</g>
</svg>}
diff --git a/jarvis/ui/web/frontend/src/components/society/companion/SkinLayers.tsx b/jarvis/ui/web/frontend/src/components/society/companion/SkinLayers.tsx
index da8654bb78..4ee93c446d 100644
--- a/jarvis/ui/web/frontend/src/components/society/companion/SkinLayers.tsx
+++ b/jarvis/ui/web/frontend/src/components/society/companion/SkinLayers.tsx
@@ -34,6 +34,13 @@ export function SkinDefs({ id, skin }: { id: string; skin: CompanionSkin }) {
</defs>;
}
+/** The twinkling specks of a starry design, in symbol units; whoever draws them cuts them to the body. */
+export function SkinStars() {
+ return <g className="agent-skin-stars" fill="#ffffff">
+ {STARS.map(([x, y, r], index) => <circle key={index} cx={x} cy={y} r={r} style={{ animationDelay: `${-index * 0.43}s` }} />)}
+ </g>;
+}
+
/** A soft pulsing halo of the design's brightest colour, drawn behind the body. */
export function SkinGlow({ id, skin, body }: { id: string; skin: CompanionSkin; body: (fill: string) => ReactNode }) {
if (skinEffect(skin) !== "glow") return null;
@@ -62,9 +69,7 @@ export function SkinOverlay({ id, skin, body }: { id: string; skin: CompanionSki
return <g data-skin-effect={effect}>
<mask id={maskId} maskUnits="userSpaceOnUse" x={-20} y={-20} width={80} height={84}>{body("#ffffff")}</mask>
<g mask={`url(#${maskId})`}>
- {effect === "stars" && <g className="agent-skin-stars" fill="#ffffff">
- {STARS.map(([x, y, r], index) => <circle key={index} cx={x} cy={y} r={r} style={{ animationDelay: `${-index * 0.43}s` }} />)}
- </g>}
+ {effect === "stars" && <SkinStars />}
{effect === "shimmer" && <>
<defs><linearGradient id={`${id}-shine`} x1="0" y1="0" x2="1" y2="0">
<stop offset="0" stopColor="#ffffff" stopOpacity="0" /><stop offset="0.5" stopColor="#ffffff" stopOpacity="0.75" /><stop offset="1" stopColor="#ffffff" stopOpacity="0" />
diff --git a/jarvis/ui/web/frontend/src/components/society/companion/figureRender.test.ts b/jarvis/ui/web/frontend/src/components/society/companion/figureRender.test.ts
index effb987b9a..8bca8bbf57 100644
--- a/jarvis/ui/web/frontend/src/components/society/companion/figureRender.test.ts
+++ b/jarvis/ui/web/frontend/src/components/society/companion/figureRender.test.ts
@@ -6,7 +6,7 @@ import { ACCESSORY_CATALOG, ACCESSORY_ITEMS } from "./accessories";
import { COMPANION_SHAPES } from "./appearance";
import { meshesByName, readGlb } from "./figureGlb";
import { figureCover, renderFigure, shadeFigure, traceFigure } from "./figureRender";
-import { bodyEffectMoves, EFFECT_FLOW, figureFaceMatrix, figureKey, figureParts, figureSmoke, figureTraceKey, type FigureLook } from "./figureScene";
+import { bodyEffectMoves, EFFECT_FLOW, EFFECT_STARS, figureFaceMatrix, figureKey, figureParts, figureSmoke, figureTraceKey, type FigureLook } from "./figureScene";
const ASSETS = path.resolve(__dirname, "../../../assets/society/companions");
function load(name: string) {
@@ -106,6 +106,9 @@ describe("3D profile faces", () => {
const flowing = look({ skin, accessories: { head: "top_hat" } });
expect(bodyEffectMoves(flowing)).toBe(true);
expect(bodyEffectMoves(look())).toBe(false);
+ // Stars twinkle as a layer cut to the body, so a starry look reports its cover too; a glow does not move across it.
+ expect(bodyEffectMoves(look({ skin: { ...skin, effect: EFFECT_STARS } }))).toBe(true);
+ expect(bodyEffectMoves(look({ skin: { ...skin, effect: 4 } }))).toBe(false);
const parts = figureParts(flowing, bodies, worn);
const trace = traceFigure(parts, 64);
const image = shadeFigure(trace, parts);
diff --git a/jarvis/ui/web/frontend/src/components/society/companion/figureRender.ts b/jarvis/ui/web/frontend/src/components/society/companion/figureRender.ts
index 2bb9f9c515..561d3a6305 100644
--- a/jarvis/ui/web/frontend/src/components/society/companion/figureRender.ts
+++ b/jarvis/ui/web/frontend/src/components/society/companion/figureRender.ts
@@ -387,7 +387,6 @@ export function shadeFigure(trace: FigureTrace, coats: readonly FigureCoat[]): F
const along = paint.radial ? Math.hypot(bx + 0.12, by - 0.16, bz - 0.3) * 1.25 : bx * Math.sin(rad) + by * Math.cos(rad) + 0.5;
if (paint.effect === 3) ring(paint.colors, along * 0.9, skin); else ramp(paint.colors, along, skin);
cr = skin[0]!; cg = skin[1]!; cb = skin[2]!;
- if (paint.effect === 1) { const s = specks(bx, by, bz, 7, 0.3) * 2.2; er = s; eg = s; eb = s; }
if (paint.effect === 4) { er = paint.highlight[0] * 0.3; eg = paint.highlight[1] * 0.3; eb = paint.highlight[2] * 0.3; }
if (paint.effect === 5) { const s = specks(bx, by, bz, 5, 0.18) * 2.2; er = paint.highlight[0] * s; eg = paint.highlight[1] * s; eb = paint.highlight[2] * s; }
}
diff --git a/jarvis/ui/web/frontend/src/components/society/companion/figureScene.ts b/jarvis/ui/web/frontend/src/components/society/companion/figureScene.ts
index 0e79ba27a0..c4066bfd18 100644
--- a/jarvis/ui/web/frontend/src/components/society/companion/figureScene.ts
+++ b/jarvis/ui/web/frontend/src/components/society/companion/figureScene.ts
@@ -23,11 +23,12 @@ export interface FigureLook {
const INK: LinearRgb = [0.0052, 0.0052, 0.007];
/** Indices in SKIN_EFFECTS of the two effects that move across the body. */
-export const EFFECT_SHIMMER = 2, EFFECT_FLOW = 3;
+export const EFFECT_STARS = 1, EFFECT_SHIMMER = 2, EFFECT_FLOW = 3;
/** True when a moving layer is cut to the body's outline, so the picture needs its cover. */
export function bodyEffectMoves(look: FigureLook): boolean {
- return look.skin?.effect === EFFECT_SHIMMER || look.skin?.effect === EFFECT_FLOW;
+ const effect = look.skin?.effect;
+ return effect === EFFECT_STARS || effect === EFFECT_SHIMMER || effect === EFFECT_FLOW;
}
/** A plume of smoke over the picture: where it rises, pixels, and how large one symbol unit is there. */