# Aletheia Three.js Animation - recreation prompt and code specification ## Purpose Recreate the current `aletheia-threejs-animation.htm` as a single portable browser app. The app is an interactive Three.js particle animation that cycles through: 1. a star spiral, 2. the letters `AI`, 3. the word `Aletheia`. The same particles move between the three target shapes. A bright central sun remains behind the particles. A Star-Wars-style crawl moves toward the centre. A small top-left panel contains the title and a **Debug** button. Debug UI is hidden by default and reveals the live controls only when requested. The implementation must be an independent Aletheia implementation, not copied from another site's source code. --- ## Aletheia recreation prompt **Create a single HTML file named `aletheia-threejs-animation.htm`.** Use Three.js in the browser and keep the app lightweight enough to run as a GitHub Pages page. ### Visual design - Full-window dark navy-black universe. - Sparse, distant static stars in the background. - One animated foreground particle system with about 5,600 points. - Particle colours are mainly cyan, pale blue and white. - Use additive blending so bright clusters glow. - Add a central warm-white sun made from a radial-gradient canvas texture on a Three.js `Sprite`. - The sun remains behind the animated particles. - Default sun size: **4.0**. - Default particle display scale: **0.30**. - Default universe scale: **1.00**. - Default camera multiplier: **0.50**. ### Particle targets Create three target arrays with exactly the same number of particle positions. #### Spiral Create three main spiral arms with occasional sibling branches. The arms should curl strongly near the centre and become progressively straighter as they move outward. Use a parameter `t` from 0 to 1 and make the angular curvature decrease with distance, for example: ```js const curve = thetaMax * Math.pow(1 - t, 1.28); ``` Use a small Gaussian spread to stop the arms looking mechanically perfect. #### AI Render the text `AI` into an off-screen 2D canvas using a heavy sans-serif face. Read the pixels with `getImageData()`. Gather the opaque pixels and randomly assign them as particle targets. The I should have a visible top and base because the text raster comes from a proper bold typeface rather than a plain rectangle. #### Aletheia Render `Aletheia` into an off-screen canvas using a Greek/classical-looking Latin typeface. Use **Cinzel** first, with serif fallbacks. Do **not** substitute Greek characters. The displayed word is `Aletheia` in Latin letters. Sample the visible text pixels and build a target point cloud in the same way as `AI`. ### Morphing Keep one `THREE.Points` object. Do not create separate particle systems for the three stages. Every animation frame, move the current positions toward the selected target positions: ```js pos[j] += (target[j] - pos[j]) * attraction; ``` Use a frame-rate-aware attraction factor so the movement is smooth. Auto-cycle: - Spiral: about 7 seconds - AI: about 9 seconds - Aletheia: about 10 seconds - then return to Spiral. The morph should be slow enough that the viewer can watch the particles migrate. ### Mouse interaction - Drag the canvas to rotate the particle universe in 3D. - Move the pointer through the point field to push nearby particles aside. - Use a Three.js `Raycaster` and a plane through the universe centre to map the pointer into the particle coordinate system. ### Camera and fitting Use a `PerspectiveCamera`. Provide a `FIT UNIVERSE` debug function that calculates the current particle bounding sphere and positions the camera so the entire point cloud fits in the field of view. Do not allow normal mouse-wheel scrolling to silently change the camera multiplier. ### Star crawl Create the crawl with normal HTML/CSS above the canvas, not with Three.js geometry. - Full-width transparent overlay. - `perspective` on the viewport. - `rotateX(...)` on the text. - CSS keyframe animation translates the crawl upward into the distance. - Keep the crawl overlay transparent so it does not block the star animation. - Use gold text. - The first word, **Aletheia**, is large, bold and approximately twice the size of the earlier small heading. - Crawl text: ```text Aletheia Let AI do the walking Guided by the Aletheia and Thalia protocols. Truth checking, practical tools, stories, and interfaces. Starfields to local knowledge. Curiosity to prototypes. Open experiments, human-led, AI-assisted. github.com/karstenevans/aletheia-protocol github.com/karstenevans/thalia-protocol github.com/karstenevans/aletheia-knowledge ``` ### Top-left panel Show: - title: `Aletheia Three.js Animation` - small instruction line: `Drag to rotate. Move the pointer through the particles to push them aside.` - a `Debug` button. When Debug is off, hide: - scale/control panel, - stage badge, - bottom stage buttons, - bottom-right debug summary. ### Debug UI When Debug is enabled, reveal: #### Bottom-left panel Controls: - Universe scale slider. - Particle scale slider. - Camera multiplier slider. - Sun size slider. - Sun on/off checkbox. - Quick universe buttons: `0.5x`, `0.7x`, `1x`. - `FIT UNIVERSE`. - `RESET VIEW`. - diagnostic text showing stage, current values, camera z, local radius, world radius and point count. Defaults after reset: - Universe = 1.00 - Particles = 0.30 - Camera = 0.50 - Sun = 4.0 #### Bottom-middle buttons - Spiral - AI - Aletheia - Auto On/Off - Replay - Crawl On/Off - Fullscreen #### Bottom-right live summary Show a live string such as: ```text Debug ยท Universe 1.00 / Particles 0.30 / Camera 0.50 / Sun 4.0 ``` This text must be generated from the live variables, not hard-coded. Update it whenever a slider or toggle changes. ### External dependencies Use: - Three.js from jsDelivr. - Google Fonts Cinzel for the Aletheia classical/Greek-style Latin lettering. The app should fail gracefully if Three.js cannot load **or** the browser cannot create the required WebGL renderer/context. Do not assume failure means "Apple has no Three.js". Three.js is a JavaScript library and Safari/WebKit can run it when the required browser graphics capabilities and dependencies are available. Detect the actual condition. Fallback behaviour: 1. Keep a lightweight HTML/CSS visual layer available independently of Three.js. 2. If the library load or renderer creation fails, hide/disable the unusable WebGL surface. 3. Keep the title, crawl, explanatory text and navigation visible. 4. Show a concise message such as "3D animation is unavailable in this browser/session; the lightweight version is shown." 5. Offer RETRY/RELOAD when useful. 6. Never leave the user with only an unexplained black/empty canvas or a cropped crawl box. 7. Respect `prefers-reduced-motion`; a deliberately reduced/static version is a valid successful fallback. --- ## Acceptance checklist - [ ] File is named `aletheia-threejs-animation.htm`. - [ ] Full browser window is used as the canvas. - [ ] Spiral is visible at Universe 1.00. - [ ] Particle scale defaults to 0.30. - [ ] Camera multiplier defaults to 0.50. - [ ] Sun defaults to 4.0 and can be disabled. - [ ] Same particles morph Spiral -> AI -> Aletheia. - [ ] Aletheia uses Latin letters with a classical/Greek-style typeface. - [ ] Crawl is transparent and does not create a black rectangle. - [ ] Crawl's first `Aletheia` is large and bold. - [ ] Debug is hidden by default. - [ ] Debug button reveals all controls. - [ ] Bottom-right debug summary follows the live controls. - [ ] Drag rotates the universe. - [ ] Pointer repels particles. - [ ] Fullscreen works. - [ ] App runs from a local `.htm` file when internet access is available for the CDN/font. - [ ] Library-load failure shows the useful lightweight fallback. - [ ] WebGL renderer/context failure shows the useful lightweight fallback. - [ ] Safari/WebKit is tested by capability, not disabled by OS detection. - [ ] Reduced-motion users receive a usable static/reduced experience. - [ ] Test current Chrome/Edge on Windows, Chrome on Android, and Safari on macOS/iPhone/iPad where available; record untested combinations rather than claiming universal compatibility. --- ## Safari / WebKit compatibility implementation - 26 September 2026 Aletheia Improve was run against the live `aletheia-threejs-animation.htm` after the owner reported: - Windows/PC: works; - Android: works; - Apple: HTML/CSS crawl visible, but Three.js stars / Spiral / AI / Aletheia not visible. ### Findings The crawl is intentionally independent HTML/CSS. The previous Three.js path could fail before useful diagnostics in two important ways: 1. older Safari/WebKit could reject optional-chaining syntax used in the inline application script before any runtime error handler executed; 2. `new THREE.WebGLRenderer(...)` was not guarded, so WebGL context-creation failure could abort all Three.js setup while leaving the independent crawl running. WebKit has documented WebGL context-loss regressions affecting iOS/iPadOS/Safari. This is a browser/device capability problem, not evidence that Three.js is categorically unsupported on Apple. ### Current renderer ladder Keep Three.js **r160** for this compatibility build: 1. try WebGL2 with antialiasing; 2. if that fails, replace the canvas and try WebGL1 without antialiasing; 3. if necessary, try `experimental-webgl`; 4. if no usable WebGL context survives, replace the canvas with a lightweight **Canvas 2D compatibility mode**; 5. keep the HTML/CSS crawl independently available throughout. The fresh-canvas replacement matters because a canvas that has already acquired one graphics-context type cannot reliably be reused to request a different context type. ### Why not upgrade Three.js during this repair The current Three.js release is newer than r160, but the r160 -> r161 migration removed the old global `three.min.js` build and r163 removed WebGL1 support from `WebGLRenderer`. A later Three.js upgrade should therefore be a deliberate separate migration to ES modules / current rendering architecture, not bundled into this Safari repair. Keeping r160 temporarily preserves a WebGL1 recovery path for older/problematic WebKit sessions. ### Canvas 2D compatibility mode If WebGL fails or is lost, the page now keeps: - dark space background; - animated starfield; - central glow; - Spiral stage; - AI stage; - Aletheia stage; - the independent HTML/CSS crawl. The 2D mode intentionally omits the full 3D drag / raycast particle-repulsion behaviour. It is a useful fallback, not a false claim that Three.js itself is still running. ### Other compatibility changes - removed avoidable optional-chaining syntax from the application path; - added WebKit-prefixed fullscreen fallback; - added reduced-motion behaviour; - WebGL context loss switches to compatibility mode instead of leaving an unexplained empty canvas; - inline JavaScript syntax check passes after the changes. ### Current external evidence - Three.js migration guide: https://github.com/mrdoob/three.js/wiki/Migration-Guide - WebKit bug 264684, WebGL context loss: https://bugs.webkit.org/show_bug.cgi?id=264684 - WebKit bug 301800, iOS/Safari 18.7.2 context loss: https://bugs.webkit.org/show_bug.cgi?id=301800 - WebKit bug 321667, later iOS WebGL shader/context regression: https://bugs.webkit.org/show_bug.cgi?id=321667 ### Device verification still required Do **not** mark Apple support complete until tested on the actual failing Apple device/browser. On Apple, record: - device model; - iOS/iPadOS/macOS version; - Safari version where available; - whether mode is full Three.js WebGL2, WebGL1 recovery, or Canvas 2D fallback; - whether Spiral, AI, Aletheia and crawl all display; - whether page reload restores full WebGL after a context-loss session; - any console error if available. The desired result is: > Full Three.js where WebGL works; useful Canvas 2D compatibility where WebKit itself cannot sustain WebGL; never unexplained crawl-only failure. ### Responsive default profiles Use the available viewport width, not operating-system detection. For compact/mobile layout at **900 CSS px or narrower**: - Universe: **1.20** - Particle scale: **0.70** - Camera multiplier: **1.30** - Sun size: **3.0** For wider/desktop layout: - Universe: **1.00** - Particle scale: **0.30** - Camera multiplier: **0.50** - Sun size: **4.0** Apply the profile on first load. **RESET VIEW** must re-read the current viewport profile and restore the matching defaults. Do not overwrite a user's live slider adjustments merely because the browser is resized; only initial load and explicit Reset apply defaults.