diff --git a/docs/superpowers/specs/2026-11-18-generation-logo-loader-design.md b/docs/superpowers/specs/2026-11-18-generation-logo-loader-design.md
new file mode 100644
index 00000000..f1819a92
--- /dev/null
+++ b/docs/superpowers/specs/2026-11-18-generation-logo-loader-design.md
@@ -0,0 +1,25 @@
+# Generate: playful logo loader while a mesh is generated
+
+## Intent
+
+While a mesh generates, the Generate viewer shows nothing but the small progress card. Showing the real mesh as it forms is not possible (generators work in latent space; the mesh exists only after the final decode, and extensions are black boxes). Instead, the maintainer wants an animated, playful Modly logo the user can play with while waiting.
+
+## Approaches
+
+- **A. Logo assembles with the progress.** Ties the animation to the %, but the maintainer preferred a free loop.
+- **B. Decorative loop with hover and click (picked).** Slow rotation; hover highlights a piece; click detaches it, it floats away, then returns.
+
+## Design
+
+- An overlay over the Generate viewer, shown only while `currentJob.status` is `uploading` or `generating`. The scene behind is dimmed; `GenerationHUD` stays on top at the bottom. The overlay captures the pointer (no orbiting the scene meanwhile).
+- Its own `@react-three/fiber` canvas, transparent background. The three pieces are the three paths of `src/shared/components/ui/ModlyLogo.tsx`, parsed (e.g. three's `SVGLoader`), centered, extruded thin.
+- Look: violet wireframe with a visible triangulated mesh and small vertex dots, a soft glow, as in the reference image (dark background, `#c084fc` to `#9333ea` palette).
+- Idle: the logo rotates slowly around the vertical axis.
+- Hover: the hovered piece lights up (brighter violet fill and edges), cursor becomes a pointer.
+- Click: the piece moves outward from the logo center (with a slight tilt) and leaves a short trail of particles, holds briefly, then returns and snaps back; total about 1.5 s. Clicks during its flight are ignored for that piece.
+- End: the overlay fades out when the job leaves `uploading`/`generating`.
+- `prefers-reduced-motion`: no rotation, no float-away; hover highlight stays.
+
+## Left to the builder
+
+Exact geometry (extrude depth, how the face is triangulated for the wireframe look), easing curves, glow technique (postprocessing bloom or additive materials), file layout under `src/areas/generate/components/`.
diff --git a/package.json b/package.json
index 605c5726..45baa960 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
"prepare-resources": "node scripts/download-python-embed.js",
"test": "npm run test:py && npm run test:node",
"test:py": "node scripts/run-pytests.mjs",
- "test:node": "node --test --experimental-strip-types --experimental-loader ./scripts/node-ts-extensionless-loader.mjs src/shared/types/assetLibrary.test.ts src/areas/generate/assetLibraryProjection.test.ts src/areas/generate/assetLibraryService.test.ts src/areas/generate/assetLibraryUi.test.ts src/areas/library/libraryView.test.ts src/areas/library/gridWindow.test.ts src/areas/generate/orcaSlicerLink.test.ts src/shared/utils/agentStream.test.ts src/shared/thumbnails/assetThumbnailQueue.test.ts src/shared/thumbnails/assetThumbnailStore.test.ts src/shared/components/agent/clientTools.test.ts src/shared/components/agent/agentContext.test.ts src/shared/utils/ollamaHealth.test.ts src/shared/utils/notification.test.ts src/shared/utils/agentConversations.test.ts electron/main/artifact-registry-service.test.ts electron/main/asset-thumbnail-cache.test.ts electron/main/extension-path-guard.test.ts electron/main/storage-directory-guard.test.ts electron/main/storage-ownership.test.ts electron/main/startup-error.test.ts electron/main/api-port.test.ts electron/main/api-guard.test.ts electron/main/agent-conversations.test.ts electron/main/gpu-memory.test.ts electron/preload/artifact-registry-preload.test.ts src/shared/stores/meshHistory.test.ts src/areas/generate/meshEditPanel.test.ts src/areas/generate/sculpt/SculptMesh.test.ts src/areas/generate/sculpt/SculptMesh.perf.test.ts src/areas/generate/sculpt/sculptLogic.test.ts src/shared/pages/pageRegistry.test.ts src/shared/pages/startPage.test.ts src/areas/home/recents.test.ts src/areas/workflows/workflowRunRecord.test.ts src/areas/queue/queueModel.test.ts electron/main/workspace-images.test.ts src/areas/image-studio/imageStudioStore.test.ts src/areas/image-studio/imageOps.test.ts src/areas/image-studio/cropGeometry.test.ts src/shared/utils/imageInput.test.ts src/areas/print/printBed.test.ts src/shared/three/viewScale.test.ts src/areas/workflows/nodes/mesh-exporter/obj.test.ts && node --test electron/main/*.test.mjs src/**/*.test.mjs",
+ "test:node": "node --test --experimental-strip-types --experimental-loader ./scripts/node-ts-extensionless-loader.mjs src/shared/types/assetLibrary.test.ts src/areas/generate/assetLibraryProjection.test.ts src/areas/generate/assetLibraryService.test.ts src/areas/generate/assetLibraryUi.test.ts src/areas/library/libraryView.test.ts src/areas/library/gridWindow.test.ts src/areas/generate/orcaSlicerLink.test.ts src/shared/utils/agentStream.test.ts src/shared/thumbnails/assetThumbnailQueue.test.ts src/shared/thumbnails/assetThumbnailStore.test.ts src/shared/components/agent/clientTools.test.ts src/shared/components/agent/agentContext.test.ts src/shared/utils/ollamaHealth.test.ts src/shared/utils/notification.test.ts src/shared/utils/agentConversations.test.ts electron/main/artifact-registry-service.test.ts electron/main/asset-thumbnail-cache.test.ts electron/main/extension-path-guard.test.ts electron/main/storage-directory-guard.test.ts electron/main/storage-ownership.test.ts electron/main/startup-error.test.ts electron/main/api-port.test.ts electron/main/api-guard.test.ts electron/main/agent-conversations.test.ts electron/main/gpu-memory.test.ts electron/preload/artifact-registry-preload.test.ts src/shared/stores/meshHistory.test.ts src/areas/generate/meshEditPanel.test.ts src/areas/generate/sculpt/SculptMesh.test.ts src/areas/generate/sculpt/SculptMesh.perf.test.ts src/areas/generate/sculpt/sculptLogic.test.ts src/shared/pages/pageRegistry.test.ts src/shared/pages/startPage.test.ts src/areas/home/recents.test.ts src/areas/workflows/workflowRunRecord.test.ts src/areas/queue/queueModel.test.ts electron/main/workspace-images.test.ts src/areas/image-studio/imageStudioStore.test.ts src/areas/image-studio/imageOps.test.ts src/areas/image-studio/cropGeometry.test.ts src/areas/generate/components/logoLoaderGeometry.test.ts src/areas/generate/components/logoLoaderMotion.test.ts src/shared/utils/imageInput.test.ts src/areas/print/printBed.test.ts src/shared/three/viewScale.test.ts src/areas/workflows/nodes/mesh-exporter/obj.test.ts && node --test electron/main/*.test.mjs src/**/*.test.mjs",
"package": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=false npm run build && npm run prepare-resources && electron-builder",
"package:mac": "cross-env CSC_IDENTITY_AUTO_DISCOVERY=false npm run build && npm run prepare-resources && electron-builder --mac --arm64",
"lint": "eslint ."
diff --git a/src/areas/generate/GeneratePage.tsx b/src/areas/generate/GeneratePage.tsx
index 819009f6..ee5def6a 100644
--- a/src/areas/generate/GeneratePage.tsx
+++ b/src/areas/generate/GeneratePage.tsx
@@ -7,6 +7,7 @@ import { redoDepth, undoDepth } from '@shared/stores/meshHistory'
import { useApi } from '@shared/hooks/useApi'
import { ColorPicker } from '@shared/components/ui'
import GenerationHUD from './components/GenerationHUD'
+import GenerationLogoLoader from './components/GenerationLogoLoader'
import Viewer3D from './components/Viewer3D'
import WorkflowPanel from './components/WorkflowPanel'
import EditPanel from './components/EditPanel'
@@ -1359,6 +1360,7 @@ export default function GeneratePage(): JSX.Element {
onSelectPointLight={handleSelectPointLight}
onPointLightsChange={setPointLights}
/>
+
{editPanelOpen && { void closeEditPanel() }} />}
diff --git a/src/areas/generate/components/GenerationLogoLoader.tsx b/src/areas/generate/components/GenerationLogoLoader.tsx
new file mode 100644
index 00000000..8dc95b31
--- /dev/null
+++ b/src/areas/generate/components/GenerationLogoLoader.tsx
@@ -0,0 +1,349 @@
+import { useEffect, useMemo, useRef, useState } from 'react'
+import * as THREE from 'three'
+import { Canvas, useFrame, useThree, type ThreeEvent } from '@react-three/fiber'
+import { useAppStore } from '@shared/stores/appStore'
+import { MODLY_LOGO_PATHS } from '@shared/components/ui/modlyLogoPaths'
+import { buildLogoPieces, pieceDirection, uniqueEdges, type LogoPiece, type Vec2 } from './logoLoaderGeometry'
+import { flightPose, trailSample } from './logoLoaderMotion'
+
+// ─── Tuning ─────────────────────────────────────────────────────────────────
+
+const LOGO_SIZE = 2.1 // world units across the logo's largest side
+const MESH_SPACING = 0.17 // target triangle edge length (the low-poly grain)
+const DEPTH = 0.14 // extrusion thickness
+const FLY_DISTANCE = 0.6 // how far a clicked piece travels outward
+const FLY_LIFT = 0.35 // and how far it comes toward the camera
+const FLY_TILT = 0.55 // radians of tilt at the far point
+const TRAIL_POINTS = 20 // outline samples that shed trail particles
+const TRAIL_STEPS = 7 // particles per sample, each further back in time
+const TRAIL_LAG_MS = 38
+const SPIN_SPEED = 0.4 // rad/s idle rotation
+const SPIN_SPEED_HOVER = 0.1
+const FADE_MS = 450
+
+const VIOLET_DEEP = new THREE.Color('#7e22ce')
+const VIOLET = new THREE.Color('#9333ea')
+const VIOLET_LIGHT = new THREE.Color('#c084fc')
+const LILAC = new THREE.Color('#e9d5ff')
+
+// ─── Per-piece GPU resources ────────────────────────────────────────────────
+
+interface PieceResources {
+ piece: LogoPiece
+ dir: Vec2
+ face: THREE.BufferGeometry
+ inner: THREE.BufferGeometry
+ outline: THREE.BufferGeometry
+ dots: THREE.BufferGeometry
+ trail: THREE.BufferGeometry
+ /** Piece-local XY of the outline samples that emit trail particles. */
+ trailOrigins: Vec2[]
+ faceMat: THREE.MeshBasicMaterial
+ innerMat: THREE.LineBasicMaterial
+ outlineMat: THREE.LineBasicMaterial
+ dotsMat: THREE.PointsMaterial
+ trailMat: THREE.PointsMaterial
+}
+
+function additive(mat: T): T {
+ mat.transparent = true
+ mat.depthWrite = false
+ mat.blending = THREE.AdditiveBlending
+ return mat
+}
+
+function buildPieceResources(piece: LogoPiece, dotTexture: THREE.Texture): PieceResources {
+ const { vertices, triangles, boundaryCount: b } = piece
+ const n = vertices.length
+ const h = DEPTH / 2
+
+ // Closed slab: front face, back face, and side walls along the outline.
+ const pos = new Float32Array(n * 2 * 3)
+ vertices.forEach((v, k) => {
+ pos.set([v.x, v.y, h], k * 3)
+ pos.set([v.x, v.y, -h], (k + n) * 3)
+ })
+ const index: number[] = []
+ for (const [a, c, d] of triangles) index.push(a, c, d, a + n, d + n, c + n)
+ for (let i = 0; i < b; i++) {
+ const j = (i + 1) % b
+ index.push(i, j + n, j, i, i + n, j + n)
+ }
+ const face = new THREE.BufferGeometry()
+ face.setAttribute('position', new THREE.BufferAttribute(pos, 3))
+ face.setIndex(index)
+ face.computeBoundingSphere()
+
+ // Inner triangulation on both faces, plus the ribs joining front and back.
+ const isOutlineEdge = (u: number, v: number): boolean =>
+ u < b && v < b && (Math.abs(u - v) === 1 || Math.abs(u - v) === b - 1)
+ const innerPts: number[] = []
+ for (const [u, v] of uniqueEdges(triangles)) {
+ if (isOutlineEdge(u, v)) continue
+ for (const z of [h, -h]) innerPts.push(vertices[u]!.x, vertices[u]!.y, z, vertices[v]!.x, vertices[v]!.y, z)
+ }
+ for (let i = 0; i < b; i++) innerPts.push(vertices[i]!.x, vertices[i]!.y, h, vertices[i]!.x, vertices[i]!.y, -h)
+ const inner = new THREE.BufferGeometry()
+ inner.setAttribute('position', new THREE.Float32BufferAttribute(innerPts, 3))
+
+ // Crisp outline on both faces.
+ const outlinePts: number[] = []
+ for (const z of [h, -h]) {
+ for (let i = 0; i < b; i++) {
+ const p = vertices[i]!, q = vertices[(i + 1) % b]!
+ outlinePts.push(p.x, p.y, z, q.x, q.y, z)
+ }
+ }
+ const outline = new THREE.BufferGeometry()
+ outline.setAttribute('position', new THREE.Float32BufferAttribute(outlinePts, 3))
+
+ // Vertex dots on both faces.
+ const dotPts: number[] = []
+ for (const z of [h, -h]) vertices.forEach((v) => dotPts.push(v.x, v.y, z))
+ const dots = new THREE.BufferGeometry()
+ dots.setAttribute('position', new THREE.Float32BufferAttribute(dotPts, 3))
+
+ // Trail: positions and colors are rewritten every frame while the piece flies.
+ const trailOrigins: Vec2[] = []
+ const stride = Math.max(1, Math.floor(b / TRAIL_POINTS))
+ for (let i = 0; i < b && trailOrigins.length < TRAIL_POINTS; i += stride) trailOrigins.push(vertices[i]!)
+ const trailCount = trailOrigins.length * TRAIL_STEPS
+ const trail = new THREE.BufferGeometry()
+ trail.setAttribute('position', new THREE.BufferAttribute(new Float32Array(trailCount * 3), 3))
+ trail.setAttribute('color', new THREE.BufferAttribute(new Float32Array(trailCount * 3), 3))
+
+ return {
+ piece,
+ dir: pieceDirection(piece.center, { x: 0, y: 0 }),
+ face, inner, outline, dots, trail, trailOrigins,
+ faceMat: additive(new THREE.MeshBasicMaterial({ color: VIOLET_DEEP, opacity: 0.07, side: THREE.DoubleSide })),
+ innerMat: additive(new THREE.LineBasicMaterial({ color: VIOLET_LIGHT, opacity: 0.4 })),
+ outlineMat: additive(new THREE.LineBasicMaterial({ color: LILAC, opacity: 0.85 })),
+ dotsMat: additive(new THREE.PointsMaterial({ color: LILAC, map: dotTexture, size: 0.05, opacity: 0.9, sizeAttenuation: true })),
+ trailMat: additive(new THREE.PointsMaterial({ map: dotTexture, size: 0.055, vertexColors: true, sizeAttenuation: true })),
+ }
+}
+
+function disposePieceResources(r: PieceResources): void {
+ for (const g of [r.face, r.inner, r.outline, r.dots, r.trail]) g.dispose()
+ for (const m of [r.faceMat, r.innerMat, r.outlineMat, r.dotsMat, r.trailMat]) m.dispose()
+}
+
+function makeDotTexture(): THREE.Texture {
+ const size = 64
+ const canvas = document.createElement('canvas')
+ canvas.width = canvas.height = size
+ const ctx = canvas.getContext('2d')!
+ const g = ctx.createRadialGradient(size / 2, size / 2, 0, size / 2, size / 2, size / 2)
+ g.addColorStop(0, 'rgba(255,255,255,1)')
+ g.addColorStop(0.35, 'rgba(255,255,255,0.85)')
+ g.addColorStop(1, 'rgba(255,255,255,0)')
+ ctx.fillStyle = g
+ ctx.fillRect(0, 0, size, size)
+ const tex = new THREE.CanvasTexture(canvas)
+ tex.colorSpace = THREE.SRGBColorSpace
+ return tex
+}
+
+/** Deterministic jitter in [-1, 1) so trail particles scatter the same way every flight. */
+function jitter(i: number, k: number, axis: number): number {
+ const s = Math.sin(i * 12.9898 + k * 78.233 + axis * 37.719) * 43758.5453
+ return (s - Math.floor(s)) * 2 - 1
+}
+
+// ─── Scene ──────────────────────────────────────────────────────────────────
+
+interface SceneProps {
+ hovered: number | null
+ onHover: (index: number | null) => void
+ reducedMotion: boolean
+}
+
+function LogoScene({ hovered, onHover, reducedMotion }: SceneProps): JSX.Element {
+ const resources = useMemo(() => {
+ const dotTexture = makeDotTexture()
+ const pieces = buildLogoPieces(MODLY_LOGO_PATHS, LOGO_SIZE, MESH_SPACING)
+ return { dotTexture, pieces: pieces.map((p) => buildPieceResources(p, dotTexture)) }
+ }, [])
+ useEffect(() => () => {
+ resources.pieces.forEach(disposePieceResources)
+ resources.dotTexture.dispose()
+ }, [resources])
+
+ const clock = useThree((s) => s.clock)
+ const logoRef = useRef(null)
+ const pieceRefs = useRef<(THREE.Group | null)[]>([])
+ const flightStart = useRef<(number | null)[]>(resources.pieces.map(() => null))
+ const spin = useRef(SPIN_SPEED)
+ const hoveredRef = useRef(hovered)
+ hoveredRef.current = hovered
+
+ const axis = useMemo(() => new THREE.Vector3(), [])
+ const color = useMemo(() => new THREE.Color(), [])
+
+ useFrame((state, dt) => {
+ const now = state.clock.elapsedTime * 1000
+ const ease = 1 - Math.exp(-dt * 12)
+ const logo = logoRef.current
+ if (logo) {
+ if (reducedMotion) {
+ logo.rotation.set(-0.12, -0.45, 0)
+ logo.position.y = 0.12
+ } else {
+ spin.current += ((hoveredRef.current === null ? SPIN_SPEED : SPIN_SPEED_HOVER) - spin.current) * (1 - Math.exp(-dt * 3))
+ logo.rotation.y += spin.current * dt
+ logo.rotation.x = -0.12
+ logo.position.y = 0.12 + Math.sin(state.clock.elapsedTime * 0.9) * 0.04
+ }
+ }
+
+ resources.pieces.forEach((r, i) => {
+ const group = pieceRefs.current[i]
+ if (!group) return
+ const start = flightStart.current[i]
+ const elapsed = start === null ? -1 : now - start
+ const pose = flightPose(elapsed)
+ if (start !== null && !pose.inFlight) flightStart.current[i] = null
+
+ const { center } = r.piece
+ group.position.set(
+ center.x + r.dir.x * FLY_DISTANCE * pose.offset,
+ center.y + r.dir.y * FLY_DISTANCE * pose.offset,
+ FLY_LIFT * pose.offset,
+ )
+ axis.set(-r.dir.y, r.dir.x, 0)
+ group.quaternion.setFromAxisAngle(axis, -FLY_TILT * pose.tilt)
+ group.scale.setScalar(pose.scale)
+
+ const hot = hoveredRef.current === i ? 1 : 0
+ const lit = Math.min(1, hot + pose.flash * 0.8)
+ r.faceMat.opacity += (0.07 + 0.24 * lit - r.faceMat.opacity) * ease
+ r.faceMat.color.lerp(color.lerpColors(VIOLET_DEEP, VIOLET, lit), ease)
+ r.innerMat.opacity += (0.4 + 0.45 * lit - r.innerMat.opacity) * ease
+ r.outlineMat.opacity += (0.85 + 0.15 * lit - r.outlineMat.opacity) * ease
+ r.dotsMat.size += (0.05 + 0.02 * lit - r.dotsMat.size) * ease
+
+ // Trail particles, in logo space, lagging behind the flying piece.
+ const posAttr = r.trail.getAttribute('position') as THREE.BufferAttribute
+ const colAttr = r.trail.getAttribute('color') as THREE.BufferAttribute
+ const visible = start !== null
+ r.trailMat.visible = visible
+ if (!visible) return
+ let p = 0
+ for (let s = 0; s < r.trailOrigins.length; s++) {
+ const o = r.trailOrigins[s]!
+ for (let k = 1; k <= TRAIL_STEPS; k++, p++) {
+ const sample = trailSample(elapsed, k * TRAIL_LAG_MS)
+ const spread = 0.012 * k
+ posAttr.setXYZ(
+ p,
+ center.x + o.x + r.dir.x * FLY_DISTANCE * sample.offset + jitter(s, k, 0) * spread,
+ center.y + o.y + r.dir.y * FLY_DISTANCE * sample.offset + jitter(s, k, 1) * spread,
+ FLY_LIFT * sample.offset + jitter(s, k, 2) * spread,
+ )
+ const a = sample.alpha * (1 - (k - 1) / TRAIL_STEPS)
+ colAttr.setXYZ(p, VIOLET_LIGHT.r * a, VIOLET_LIGHT.g * a, VIOLET_LIGHT.b * a)
+ }
+ }
+ posAttr.needsUpdate = true
+ colAttr.needsUpdate = true
+ })
+ })
+
+ function handleClick(i: number, e: ThreeEvent): void {
+ e.stopPropagation()
+ if (reducedMotion || flightStart.current[i] !== null) return
+ flightStart.current[i] = clock.elapsedTime * 1000
+ }
+
+ return (
+
+ {resources.pieces.map((r, i) => (
+
+ { pieceRefs.current[i] = g }}>
+ { e.stopPropagation(); onHover(i) }}
+ onPointerOut={() => { if (hoveredRef.current === i) onHover(null) }}
+ onClick={(e) => handleClick(i, e)}
+ />
+
+
+
+
+
+
+ ))}
+
+ )
+}
+
+// ─── Overlay ────────────────────────────────────────────────────────────────
+
+function usePrefersReducedMotion(): boolean {
+ const [reduced, setReduced] = useState(() => window.matchMedia('(prefers-reduced-motion: reduce)').matches)
+ useEffect(() => {
+ const mq = window.matchMedia('(prefers-reduced-motion: reduce)')
+ const update = (): void => setReduced(mq.matches)
+ mq.addEventListener('change', update)
+ return () => mq.removeEventListener('change', update)
+ }, [])
+ return reduced
+}
+
+/**
+ * Playful 3D Modly logo shown over the Generate viewer while a mesh is being
+ * generated. Hover lights a piece up; a click sends it flying and back.
+ */
+export default function GenerationLogoLoader(): JSX.Element | null {
+ const status = useAppStore((s) => s.currentJob?.status)
+ const active = status === 'uploading' || status === 'generating'
+ const [mounted, setMounted] = useState(active)
+ const [shown, setShown] = useState(false)
+ const [hovered, setHovered] = useState(null)
+ const reducedMotion = usePrefersReducedMotion()
+
+ useEffect(() => {
+ if (active) {
+ setMounted(true)
+ // Two frames so the transparent state is painted before fading in.
+ let id = requestAnimationFrame(() => { id = requestAnimationFrame(() => setShown(true)) })
+ return () => cancelAnimationFrame(id)
+ }
+ setShown(false)
+ const id = setTimeout(() => { setMounted(false); setHovered(null) }, FADE_MS)
+ return () => clearTimeout(id)
+ }, [active])
+
+ if (!mounted) return null
+
+ return (
+
+ )
+}
diff --git a/src/areas/generate/components/logoLoaderGeometry.test.ts b/src/areas/generate/components/logoLoaderGeometry.test.ts
new file mode 100644
index 00000000..2f1f7a6c
--- /dev/null
+++ b/src/areas/generate/components/logoLoaderGeometry.test.ts
@@ -0,0 +1,133 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import {
+ buildLogoPieces, delaunay, fitPolygons, pathToPolygons, pieceDirection, pointInPolygon,
+ polygonCentroid, resamplePolygon, signedArea, simplifyPolygon, triangulatePiece, uniqueEdges, type Polygon,
+} from './logoLoaderGeometry'
+import { MODLY_LOGO_PATHS } from '../../../shared/components/ui/modlyLogoPaths'
+
+const square: Polygon = [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 2 }, { x: 0, y: 2 }]
+
+test('pathToPolygons reads absolute moves and relative lines', () => {
+ assert.deepEqual(pathToPolygons('M10 10 l5 0 0 5 -5 0z'), [[
+ { x: 10, y: 10 }, { x: 15, y: 10 }, { x: 15, y: 15 }, { x: 10, y: 15 },
+ ]])
+})
+
+test('pathToPolygons flattens relative cubics ending on their endpoint', () => {
+ const [poly] = pathToPolygons('M0 0 c0 10 10 10 10 0 l0 -5z', 4)
+ assert.equal(poly!.length, 1 + 4 + 1)
+ assert.deepEqual(poly![4], { x: 10, y: 0 })
+ assert.deepEqual(poly![5], { x: 10, y: -5 })
+ assert.ok(poly![2]!.y > 5, 'the curve bulges toward its control points')
+})
+
+test('pathToPolygons rejects commands outside the supported subset', () => {
+ assert.throws(() => pathToPolygons('M0 0 A 1 1 0 0 0 5 5z'), /Unsupported|Bad/)
+})
+
+test('polygon helpers: area, centroid, inside test', () => {
+ assert.equal(signedArea(square), 4)
+ assert.deepEqual(polygonCentroid(square), { x: 1, y: 1 })
+ assert.equal(pointInPolygon({ x: 1, y: 1 }, square), true)
+ assert.equal(pointInPolygon({ x: 3, y: 1 }, square), false)
+})
+
+test('fitPolygons centers on the origin and fits the largest side', () => {
+ const [[fit]] = fitPolygons([[square.map((p) => ({ x: p.x + 10, y: p.y * 0.5 + 4 }))]], 1)
+ const xs = fit!.map((p) => p.x), ys = fit!.map((p) => p.y)
+ assert.deepEqual([Math.min(...xs), Math.max(...xs)], [-0.5, 0.5])
+ assert.deepEqual([Math.min(...ys), Math.max(...ys)], [-0.25, 0.25])
+})
+
+test('resamplePolygon keeps corners and spaces points along straight runs', () => {
+ const out = resamplePolygon(square, 0.5)
+ assert.equal(out.length, 16)
+ for (const c of square) assert.ok(out.some((p) => p.x === c.x && p.y === c.y), `corner ${c.x},${c.y} kept`)
+})
+
+test('delaunay triangulates a square grid without overlap', () => {
+ const pts = [{ x: 0, y: 0 }, { x: 1, y: 0.01 }, { x: 0.02, y: 1 }, { x: 1, y: 1 }, { x: 0.5, y: 0.45 }]
+ const tris = delaunay(pts)
+ assert.equal(tris.length, 4)
+ let area = 0
+ for (const [a, b, c] of tris) {
+ const A = pts[a]!, B = pts[b]!, C = pts[c]!
+ const cross = (B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x)
+ assert.ok(cross > 0, 'counter-clockwise')
+ area += cross / 2
+ }
+ const hull = [pts[0]!, pts[1]!, pts[3]!, pts[2]!]
+ assert.ok(Math.abs(area - signedArea(hull)) < 1e-9, 'triangles tile the convex hull')
+})
+
+test('triangulatePiece covers the shape area and stays inside it', () => {
+ const piece = triangulatePiece(square, 0.4)
+ let area = 0
+ for (const [a, b, c] of piece.triangles) {
+ const A = piece.vertices[a]!, B = piece.vertices[b]!, C = piece.vertices[c]!
+ area += ((B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x)) / 2
+ }
+ assert.ok(Math.abs(area - 4) < 1e-6, `area ${area}`)
+ assert.ok(piece.vertices.length > piece.boundaryCount, 'has interior vertices')
+ assert.deepEqual(piece.center, { x: 1, y: 1 })
+})
+
+test('simplifyPolygon straightens wobbly sides and keeps the corners', () => {
+ // A 2x2 square whose sides wobble by 0.005 and whose corner (2,2) is rounded.
+ const wobbly: Polygon = [
+ { x: 0, y: 0 }, { x: 1, y: 0.005 }, { x: 2, y: 0 },
+ { x: 2.004, y: 1 }, { x: 2, y: 1.97 }, { x: 1.99, y: 1.99 }, { x: 1.97, y: 2 },
+ { x: 1, y: 1.996 }, { x: 0, y: 2 }, { x: -0.005, y: 1 },
+ ]
+ const out = simplifyPolygon(wobbly, 0.02)
+ assert.ok(out.length >= 4 && out.length <= 6, `got ${out.length} vertices`)
+ for (const corner of [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 0, y: 2 }]) {
+ assert.ok(out.some((p) => p.x === corner.x && p.y === corner.y), `corner ${corner.x},${corner.y} kept`)
+ }
+ assert.deepEqual(simplifyPolygon(square, 0.01), square)
+})
+
+test('the logo outline points lie on straight edges', () => {
+ for (const piece of buildLogoPieces(MODLY_LOGO_PATHS, 2, 0.12)) {
+ const outline = piece.vertices.slice(0, piece.boundaryCount)
+ const n = outline.length
+ // Each point is either a corner or collinear with its two neighbours.
+ let straight = 0
+ for (let i = 0; i < n; i++) {
+ const p = outline[(i + n - 1) % n]!, q = outline[i]!, r = outline[(i + 1) % n]!
+ const cross = (q.x - p.x) * (r.y - q.y) - (q.y - p.y) * (r.x - q.x)
+ if (Math.abs(cross) < 1e-9) straight++
+ }
+ assert.ok(straight > n / 2, `${straight}/${n} outline points on straight runs`)
+ }
+})
+
+test('uniqueEdges lists shared edges once', () => {
+ assert.equal(uniqueEdges([[0, 1, 2], [2, 1, 3]]).length, 5)
+})
+
+test('pieceDirection points away from the center, up when degenerate', () => {
+ assert.deepEqual(pieceDirection({ x: 3, y: 4 }, { x: 0, y: 0 }), { x: 0.6, y: 0.8 })
+ assert.deepEqual(pieceDirection({ x: 1, y: 1 }, { x: 1, y: 1 }), { x: 0, y: 1 })
+})
+
+test('the Modly logo builds three Y-up pieces that fill their outlines', () => {
+ const pieces = buildLogoPieces(MODLY_LOGO_PATHS, 2, 0.12)
+ assert.equal(pieces.length, 3)
+ const [top, right, bottom] = pieces
+ // Path space is Y-up: the first piece sits above the third, the second on the right.
+ assert.ok(top!.center.y > bottom!.center.y)
+ assert.ok(right!.center.x > top!.center.x)
+ for (const piece of pieces) {
+ assert.ok(piece.triangles.length > 20, 'triangulated')
+ const outline = piece.vertices.slice(0, piece.boundaryCount)
+ let area = 0
+ for (const [a, b, c] of piece.triangles) {
+ const A = piece.vertices[a]!, B = piece.vertices[b]!, C = piece.vertices[c]!
+ area += ((B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x)) / 2
+ }
+ const rel = Math.abs(area - signedArea(outline)) / signedArea(outline)
+ assert.ok(rel < 0.02, `triangles cover the outline (off by ${(rel * 100).toFixed(2)}%)`)
+ }
+})
diff --git a/src/areas/generate/components/logoLoaderGeometry.ts b/src/areas/generate/components/logoLoaderGeometry.ts
new file mode 100644
index 00000000..ca11a329
--- /dev/null
+++ b/src/areas/generate/components/logoLoaderGeometry.ts
@@ -0,0 +1,384 @@
+/**
+ * Pure 2D geometry behind the generation logo loader: turns the Modly SVG
+ * paths into evenly triangulated low-poly pieces (no three.js, no DOM).
+ */
+
+export interface Vec2 { x: number, y: number }
+export type Polygon = Vec2[]
+export type Triangle = [number, number, number]
+
+export interface LogoPiece {
+ /** Piece centroid in logo space. */
+ center: Vec2
+ /** Vertices relative to `center`; the first `boundaryCount` are the outline, in order. */
+ vertices: Vec2[]
+ boundaryCount: number
+ /** Counter-clockwise triangles (indices into `vertices`). */
+ triangles: Triangle[]
+}
+
+// ─── SVG path → polygons ────────────────────────────────────────────────────
+
+const TOKEN = /[MmLlCcZz]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g
+
+/**
+ * Parse the subset of SVG path syntax the logo uses (M, L, C and Z, absolute
+ * or relative) into one polygon per subpath, flattening each cubic into
+ * `curveSteps` segments. Coordinates stay in path space.
+ */
+export function pathToPolygons(d: string, curveSteps = 12): Polygon[] {
+ const tokens = d.match(TOKEN) ?? []
+ const polygons: Polygon[] = []
+ let current: Polygon = []
+ let cx = 0, cy = 0
+ let command = ''
+ let i = 0
+ const num = (): number => {
+ const t = tokens[i++]
+ const n = Number(t)
+ if (t === undefined || Number.isNaN(n)) throw new Error(`Bad SVG path number near token ${i}`)
+ return n
+ }
+ const close = (): void => {
+ if (current.length > 1) {
+ const a = current[0]!, b = current[current.length - 1]!
+ if (Math.hypot(a.x - b.x, a.y - b.y) < 1e-9) current.pop()
+ }
+ if (current.length >= 3) polygons.push(current)
+ current = []
+ }
+
+ while (i < tokens.length) {
+ const t = tokens[i]!
+ if (/^[A-Za-z]$/.test(t)) { command = t; i++ }
+ else if (!command) throw new Error('SVG path must start with a command')
+ const rel = command === command.toLowerCase()
+ switch (command.toUpperCase()) {
+ case 'M': {
+ close()
+ const x = num() + (rel ? cx : 0), y = num() + (rel ? cy : 0)
+ cx = x; cy = y
+ current.push({ x, y })
+ command = rel ? 'l' : 'L' // extra pairs after a moveto are linetos
+ break
+ }
+ case 'L': {
+ const x = num() + (rel ? cx : 0), y = num() + (rel ? cy : 0)
+ cx = x; cy = y
+ current.push({ x, y })
+ break
+ }
+ case 'C': {
+ const ox = rel ? cx : 0, oy = rel ? cy : 0
+ const x1 = num() + ox, y1 = num() + oy
+ const x2 = num() + ox, y2 = num() + oy
+ const x = num() + ox, y = num() + oy
+ for (let s = 1; s <= curveSteps; s++) {
+ const u = s / curveSteps, v = 1 - u
+ current.push({
+ x: v * v * v * cx + 3 * v * v * u * x1 + 3 * v * u * u * x2 + u * u * u * x,
+ y: v * v * v * cy + 3 * v * v * u * y1 + 3 * v * u * u * y2 + u * u * u * y,
+ })
+ }
+ cx = x; cy = y
+ break
+ }
+ case 'Z': {
+ const start = current[0]
+ close()
+ if (start) { cx = start.x; cy = start.y }
+ command = ''
+ break
+ }
+ default:
+ throw new Error(`Unsupported SVG path command "${command}"`)
+ }
+ }
+ close()
+ return polygons
+}
+
+// ─── Polygon helpers ────────────────────────────────────────────────────────
+
+export function signedArea(poly: Polygon): number {
+ let a = 0
+ for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {
+ a += poly[j]!.x * poly[i]!.y - poly[i]!.x * poly[j]!.y
+ }
+ return a / 2
+}
+
+/** Area-weighted centroid of a simple polygon. */
+export function polygonCentroid(poly: Polygon): Vec2 {
+ let cx = 0, cy = 0
+ for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {
+ const p = poly[j]!, q = poly[i]!
+ const cross = p.x * q.y - q.x * p.y
+ cx += (p.x + q.x) * cross
+ cy += (p.y + q.y) * cross
+ }
+ const a = signedArea(poly)
+ return { x: cx / (6 * a), y: cy / (6 * a) }
+}
+
+export function pointInPolygon(p: Vec2, poly: Polygon): boolean {
+ let inside = false
+ for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {
+ const a = poly[i]!, b = poly[j]!
+ if ((a.y > p.y) !== (b.y > p.y) && p.x < ((b.x - a.x) * (p.y - a.y)) / (b.y - a.y) + a.x) inside = !inside
+ }
+ return inside
+}
+
+export function distanceToPolygon(p: Vec2, poly: Polygon): number {
+ let best = Infinity
+ for (let i = 0, j = poly.length - 1; i < poly.length; j = i++) {
+ const a = poly[j]!, b = poly[i]!
+ const dx = b.x - a.x, dy = b.y - a.y
+ const len2 = dx * dx + dy * dy
+ const t = len2 === 0 ? 0 : Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / len2))
+ best = Math.min(best, Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy)))
+ }
+ return best
+}
+
+/**
+ * Fit several polygon groups into a square of side `size` centered on the
+ * origin, keeping proportions. Path space is already Y-up, so no flip.
+ */
+export function fitPolygons(groups: Polygon[][], size: number): Polygon[][] {
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity
+ for (const g of groups) for (const poly of g) for (const p of poly) {
+ minX = Math.min(minX, p.x); maxX = Math.max(maxX, p.x)
+ minY = Math.min(minY, p.y); maxY = Math.max(maxY, p.y)
+ }
+ const s = size / Math.max(maxX - minX, maxY - minY)
+ const mx = (minX + maxX) / 2, my = (minY + maxY) / 2
+ return groups.map((g) => g.map((poly) => poly.map((p) => ({ x: (p.x - mx) * s, y: (p.y - my) * s }))))
+}
+
+/**
+ * Resample an outline to roughly `spacing` between vertices — the low-poly
+ * look — while keeping sharp corners (turn above `cornerDeg`) in place.
+ */
+export function resamplePolygon(poly: Polygon, spacing: number, cornerDeg = 35): Polygon {
+ const n = poly.length
+ const isCorner = (i: number): boolean => {
+ const p = poly[(i + n - 1) % n]!, q = poly[i]!, r = poly[(i + 1) % n]!
+ const a1 = Math.atan2(q.y - p.y, q.x - p.x), a2 = Math.atan2(r.y - q.y, r.x - q.x)
+ let turn = Math.abs(a2 - a1)
+ if (turn > Math.PI) turn = 2 * Math.PI - turn
+ return turn > (cornerDeg * Math.PI) / 180
+ }
+ // Start on a corner when there is one so the seam does not cut it.
+ let start = 0
+ for (let i = 0; i < n; i++) if (isCorner(i)) { start = i; break }
+
+ // Split the outline into runs between corners, then place evenly spaced
+ // points along each run (never fewer than one segment per run).
+ const out: Polygon = []
+ let run: Polygon = [poly[start]!]
+ const flush = (): void => {
+ let length = 0
+ for (let k = 1; k < run.length; k++) length += Math.hypot(run[k]!.x - run[k - 1]!.x, run[k]!.y - run[k - 1]!.y)
+ const count = Math.max(1, Math.round(length / spacing))
+ const step = length / count
+ out.push(run[0]!)
+ let k = 1, walked = 0, target = step
+ for (let c = 1; c < count; c++, target += step) {
+ while (k < run.length) {
+ const a = run[k - 1]!, b = run[k]!
+ const seg = Math.hypot(b.x - a.x, b.y - a.y)
+ if (walked + seg >= target) {
+ const t = seg === 0 ? 0 : (target - walked) / seg
+ out.push({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t })
+ break
+ }
+ walked += seg
+ k++
+ }
+ }
+ }
+ for (let s = 1; s <= n; s++) {
+ const i = (start + s) % n
+ run.push(poly[i]!)
+ if (s === n || isCorner(i)) { flush(); run = [poly[i]!] }
+ }
+ return out
+}
+
+// ─── Triangulation ──────────────────────────────────────────────────────────
+
+/** Deterministic pseudo-random in [0, 1) from two integers. */
+function hash2(i: number, j: number): number {
+ const s = Math.sin(i * 127.1 + j * 311.7) * 43758.5453
+ return s - Math.floor(s)
+}
+
+/** Jittered hexagonal grid of points inside `poly`, kept clear of its outline. */
+export function interiorPoints(poly: Polygon, spacing: number): Vec2[] {
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity
+ for (const p of poly) {
+ minX = Math.min(minX, p.x); maxX = Math.max(maxX, p.x)
+ minY = Math.min(minY, p.y); maxY = Math.max(maxY, p.y)
+ }
+ const rowH = spacing * Math.sqrt(3) / 2
+ const out: Vec2[] = []
+ for (let j = 0, y = minY + rowH / 2; y < maxY; j++, y += rowH) {
+ for (let i = 0, x = minX + (j % 2 ? spacing / 2 : 0); x < maxX; i++, x += spacing) {
+ const p = {
+ x: x + (hash2(i, j) - 0.5) * spacing * 0.35,
+ y: y + (hash2(j, i + 17) - 0.5) * spacing * 0.35,
+ }
+ if (pointInPolygon(p, poly) && distanceToPolygon(p, poly) > spacing * 0.55) out.push(p)
+ }
+ }
+ return out
+}
+
+/** Bowyer–Watson Delaunay triangulation; returns counter-clockwise triangles. */
+export function delaunay(points: Vec2[]): Triangle[] {
+ const n = points.length
+ if (n < 3) return []
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity
+ for (const p of points) {
+ minX = Math.min(minX, p.x); maxX = Math.max(maxX, p.x)
+ minY = Math.min(minY, p.y); maxY = Math.max(maxY, p.y)
+ }
+ const d = Math.max(maxX - minX, maxY - minY) * 20 || 1
+ const mx = (minX + maxX) / 2, my = (minY + maxY) / 2
+ const pts = [...points, { x: mx - d, y: my - d }, { x: mx + d, y: my - d }, { x: mx, y: my + d }]
+
+ interface Tri { a: number, b: number, c: number, x: number, y: number, r2: number }
+ const make = (a: number, b: number, c: number): Tri => {
+ const A = pts[a]!, B = pts[b]!, C = pts[c]!
+ const det = 2 * (A.x * (B.y - C.y) + B.x * (C.y - A.y) + C.x * (A.y - B.y))
+ if (Math.abs(det) < 1e-12) return { a, b, c, x: 0, y: 0, r2: Infinity }
+ const a2 = A.x * A.x + A.y * A.y, b2 = B.x * B.x + B.y * B.y, c2 = C.x * C.x + C.y * C.y
+ const x = (a2 * (B.y - C.y) + b2 * (C.y - A.y) + c2 * (A.y - B.y)) / det
+ const y = (a2 * (C.x - B.x) + b2 * (A.x - C.x) + c2 * (B.x - A.x)) / det
+ return { a, b, c, x, y, r2: (A.x - x) ** 2 + (A.y - y) ** 2 }
+ }
+
+ let tris: Tri[] = [make(n, n + 1, n + 2)]
+ for (let i = 0; i < n; i++) {
+ const p = pts[i]!
+ const keep: Tri[] = []
+ const edges = new Map()
+ for (const t of tris) {
+ if ((p.x - t.x) ** 2 + (p.y - t.y) ** 2 < t.r2 * (1 - 1e-12)) {
+ for (const [u, v] of [[t.a, t.b], [t.b, t.c], [t.c, t.a]] as const) {
+ const key = u < v ? `${u},${v}` : `${v},${u}`
+ const e = edges.get(key)
+ if (e) e[2]++
+ else edges.set(key, [u, v, 1])
+ }
+ } else keep.push(t)
+ }
+ for (const [u, v, count] of edges.values()) if (count === 1) keep.push(make(u, v, i))
+ tris = keep
+ }
+
+ const out: Triangle[] = []
+ for (const t of tris) {
+ if (t.a >= n || t.b >= n || t.c >= n) continue
+ const A = points[t.a]!, B = points[t.b]!, C = points[t.c]!
+ const cross = (B.x - A.x) * (C.y - A.y) - (B.y - A.y) * (C.x - A.x)
+ if (Math.abs(cross) < 1e-12) continue
+ out.push(cross > 0 ? [t.a, t.b, t.c] : [t.a, t.c, t.b])
+ }
+ return out
+}
+
+/** Distance from `p` to the segment `a`–`b`. */
+function distanceToSegment(p: Vec2, a: Vec2, b: Vec2): number {
+ const dx = b.x - a.x, dy = b.y - a.y
+ const len2 = dx * dx + dy * dy
+ const t = len2 === 0 ? 0 : Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / len2))
+ return Math.hypot(p.x - (a.x + t * dx), p.y - (a.y + t * dy))
+}
+
+/** Ramer–Douglas–Peucker on an open polyline, endpoints kept. */
+function simplifyPolyline(points: Polygon, tolerance: number): Polygon {
+ if (points.length < 3) return points
+ const a = points[0]!, b = points[points.length - 1]!
+ let worst = 0, at = 0
+ for (let i = 1; i < points.length - 1; i++) {
+ const d = distanceToSegment(points[i]!, a, b)
+ if (d > worst) { worst = d; at = i }
+ }
+ if (worst <= tolerance) return [a, b]
+ const left = simplifyPolyline(points.slice(0, at + 1), tolerance)
+ const right = simplifyPolyline(points.slice(at), tolerance)
+ return [...left.slice(0, -1), ...right]
+}
+
+/**
+ * Closed-polygon Ramer–Douglas–Peucker: drops the vertices that stray less
+ * than `tolerance` from a straight edge. Split at the vertex farthest from the
+ * first one so both halves are open polylines.
+ */
+export function simplifyPolygon(poly: Polygon, tolerance: number): Polygon {
+ if (poly.length < 4) return poly
+ const first = poly[0]!
+ let far = 0, farDist = -1
+ poly.forEach((p, i) => {
+ const d = Math.hypot(p.x - first.x, p.y - first.y)
+ if (d > farDist) { farDist = d; far = i }
+ })
+ const a = simplifyPolyline(poly.slice(0, far + 1), tolerance)
+ const b = simplifyPolyline([...poly.slice(far), first], tolerance)
+ return [...a.slice(0, -1), ...b.slice(0, -1)]
+}
+
+/**
+ * Low-poly triangulation of one simple polygon: resampled outline plus a
+ * jittered interior grid, Delaunay-triangulated and clipped to the shape.
+ */
+export function triangulatePiece(poly: Polygon, spacing: number): LogoPiece {
+ // The logo's sides are drawn as near-straight cubics with slightly rounded
+ // corners: simplify them to true straight edges first, so the resampled
+ // outline lies on straight lines instead of following the curve's wobble.
+ const ccw = simplifyPolygon(signedArea(poly) < 0 ? [...poly].reverse() : poly, spacing * 0.1)
+ // Every vertex left after simplification is a real corner.
+ const outline = resamplePolygon(ccw, spacing, 0)
+ const all = [...outline, ...interiorPoints(ccw, spacing)]
+ const triangles = delaunay(all).filter(([a, b, c]) => {
+ const A = all[a]!, B = all[b]!, C = all[c]!
+ return pointInPolygon({ x: (A.x + B.x + C.x) / 3, y: (A.y + B.y + C.y) / 3 }, ccw)
+ })
+ const center = polygonCentroid(ccw)
+ return {
+ center,
+ vertices: all.map((p) => ({ x: p.x - center.x, y: p.y - center.y })),
+ boundaryCount: outline.length,
+ triangles,
+ }
+}
+
+/** Every triangle edge once, as [low, high] index pairs. */
+export function uniqueEdges(triangles: Triangle[]): [number, number][] {
+ const seen = new Set()
+ const out: [number, number][] = []
+ for (const [a, b, c] of triangles) {
+ for (const [u, v] of [[a, b], [b, c], [c, a]] as const) {
+ const lo = Math.min(u, v), hi = Math.max(u, v)
+ const key = `${lo},${hi}`
+ if (!seen.has(key)) { seen.add(key); out.push([lo, hi]) }
+ }
+ }
+ return out
+}
+
+/** Unit vector from the logo center toward a piece; straight up when they coincide. */
+export function pieceDirection(piece: Vec2, logoCenter: Vec2): Vec2 {
+ const dx = piece.x - logoCenter.x, dy = piece.y - logoCenter.y
+ const len = Math.hypot(dx, dy)
+ return len < 1e-9 ? { x: 0, y: 1 } : { x: dx / len, y: dy / len }
+}
+
+/** Parse, fit and triangulate the logo paths into pieces centered on the origin. */
+export function buildLogoPieces(paths: readonly string[], size: number, spacing: number): LogoPiece[] {
+ const fitted = fitPolygons(paths.map((d) => pathToPolygons(d)), size)
+ return fitted.map((polys) => triangulatePiece(polys[0]!, spacing))
+}
diff --git a/src/areas/generate/components/logoLoaderMotion.test.ts b/src/areas/generate/components/logoLoaderMotion.test.ts
new file mode 100644
index 00000000..a45c377b
--- /dev/null
+++ b/src/areas/generate/components/logoLoaderMotion.test.ts
@@ -0,0 +1,38 @@
+import test from 'node:test'
+import assert from 'node:assert/strict'
+import { FLIGHT_MS, flightPose, trailSample } from './logoLoaderMotion'
+
+test('a piece rests before and after its flight', () => {
+ for (const t of [-10, 0, FLIGHT_MS, FLIGHT_MS + 500, Number.NaN]) {
+ const p = flightPose(t)
+ assert.equal(p.offset, 0)
+ assert.equal(p.scale, 1)
+ assert.equal(p.inFlight, t === 0)
+ }
+})
+
+test('the flight goes out, holds, comes back and snaps in', () => {
+ assert.ok(flightPose(200).offset > 0.5, 'leaves fast')
+ assert.ok(flightPose(600).offset >= 1, 'holds at the far point')
+ const back = [850, 950, 1050, 1150, 1240].map((t) => flightPose(t).offset)
+ for (let i = 1; i < back.length; i++) assert.ok(back[i]! < back[i - 1]!, 'returns monotonically')
+ const snap = flightPose(1350)
+ assert.equal(snap.offset, 0)
+ assert.ok(snap.scale > 1 && snap.flash > 0 && snap.inFlight)
+})
+
+test('the offset curve is continuous at phase boundaries', () => {
+ for (const edge of [450, 800, 1250]) {
+ const jump = Math.abs(flightPose(edge - 0.01).offset - flightPose(edge).offset)
+ assert.ok(jump < 0.01, `continuous at ${edge} ms (jump ${jump})`)
+ }
+})
+
+test('trail particles only show while the piece travels', () => {
+ assert.ok(trailSample(200, 60).alpha > 0, 'visible on the way out')
+ assert.ok(trailSample(200, 60).offset < flightPose(200).offset, 'lags behind the piece')
+ assert.ok(trailSample(1150, 60).alpha > 0, 'visible on the way back')
+ assert.ok(trailSample(625, 30).alpha < 0.05, 'nearly gone while hovering')
+ assert.equal(trailSample(FLIGHT_MS + 100, 60).alpha, 0)
+ assert.equal(trailSample(1400, 60).alpha, 0, 'gone once snapped back')
+})
diff --git a/src/areas/generate/components/logoLoaderMotion.ts b/src/areas/generate/components/logoLoaderMotion.ts
new file mode 100644
index 00000000..f9f4b5c2
--- /dev/null
+++ b/src/areas/generate/components/logoLoaderMotion.ts
@@ -0,0 +1,64 @@
+/**
+ * Pure animation curves for the generation logo loader: where a clicked
+ * piece is, as a function of the time since the click.
+ */
+
+/** Total length of one click flight. */
+export const FLIGHT_MS = 1500
+const OUT_END = 450
+const HOLD_END = 800
+const RETURN_END = 1250
+
+export interface FlightPose {
+ /** 0 at rest, 1 at the farthest point outward. */
+ offset: number
+ /** Tilt amount, 0..1 (the caller maps it to an angle). */
+ tilt: number
+ /** Uniform scale of the piece. */
+ scale: number
+ /** Brightness kick when the piece snaps back, 0..1. */
+ flash: number
+ /** Whether the piece is still busy (clicks are ignored meanwhile). */
+ inFlight: boolean
+}
+
+const REST: FlightPose = { offset: 0, tilt: 0, scale: 1, flash: 0, inFlight: false }
+
+export const easeOutCubic = (t: number): number => 1 - (1 - t) ** 3
+export const easeInCubic = (t: number): number => t ** 3
+const clamp01 = (t: number): number => Math.min(1, Math.max(0, t))
+
+/**
+ * Pose of a piece `elapsedMs` after it was clicked: shoots out, hovers with a
+ * small bob, falls back faster and faster, then snaps in with a little pulse.
+ */
+export function flightPose(elapsedMs: number): FlightPose {
+ if (!(elapsedMs >= 0) || elapsedMs >= FLIGHT_MS) return REST
+ const t = elapsedMs
+ if (t < OUT_END) {
+ const o = easeOutCubic(t / OUT_END)
+ return { offset: o, tilt: o, scale: 1 + 0.04 * o, flash: 0, inFlight: true }
+ }
+ if (t < HOLD_END) {
+ const o = 1 + 0.04 * Math.sin((Math.PI * (t - OUT_END)) / (HOLD_END - OUT_END))
+ return { offset: o, tilt: 1, scale: 1.04, flash: 0, inFlight: true }
+ }
+ if (t < RETURN_END) {
+ const o = 1 - easeInCubic((t - HOLD_END) / (RETURN_END - HOLD_END))
+ return { offset: o, tilt: o, scale: 1 + 0.04 * o, flash: 0, inFlight: true }
+ }
+ const p = (t - RETURN_END) / (FLIGHT_MS - RETURN_END)
+ return { offset: 0, tilt: 0, scale: 1 + 0.07 * Math.sin(Math.PI * p), flash: 1 - p, inFlight: true }
+}
+
+/**
+ * A trail particle shows where the piece was `lagMs` ago. Its opacity follows
+ * how far the piece has moved since then, so the trail is only visible while
+ * the piece travels and vanishes while it hovers or rests.
+ */
+export function trailSample(elapsedMs: number, lagMs: number): { offset: number, alpha: number } {
+ const past = flightPose(Math.max(0, elapsedMs - lagMs)).offset
+ const now = flightPose(elapsedMs).offset
+ const moving = elapsedMs - lagMs < RETURN_END ? Math.abs(now - past) : 0
+ return { offset: past, alpha: clamp01(moving * 3) }
+}
diff --git a/src/shared/components/ui/ModlyLogo.tsx b/src/shared/components/ui/ModlyLogo.tsx
index 8b62b221..08b52291 100644
--- a/src/shared/components/ui/ModlyLogo.tsx
+++ b/src/shared/components/ui/ModlyLogo.tsx
@@ -1,7 +1,9 @@
+import { MODLY_LOGO_PATHS, MODLY_LOGO_PATH_TRANSFORM, MODLY_LOGO_VIEWBOX_SIZE } from './modlyLogoPaths'
+
/** The Modly mark, in its violet gradient. */
export default function ModlyLogo({ size = 64, className }: { size?: number, className?: string }): JSX.Element {
return (
-