Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
make the default lens inert so worlds that never touch ctx.lens render exactly as before
[._.]/ Adam Eivy7960671cf91c
diff --git a/server/services/codeAnimation/prompt.js b/server/services/codeAnimation/prompt.jsindex 98e9c78cda..4dc2d92f08 100644--- a/server/services/codeAnimation/prompt.js+++ b/server/services/codeAnimation/prompt.js@@ -415,7 +415,7 @@ export function buildMixedMediaDocumentPrompt({ title, song, palette, treatment,const sections = (song.sections || []).filter((section) => !onlySectionId || section.id === onlySectionId);return [`MEDIA POLICY: ${mediaMode}. Code always authors composition, staging, characters, camera, text, motion and timing. Never generate guide images in code-only mode.`,- renderer === 'three' ? `Write complete authored Three.js worlds, one function render(ctx, env) per section. ctx = { THREE, scene, camera, text, lens }; THREE is the installed locally packaged library; scene is a fresh Scene on EACH seek, camera a PerspectiveCamera, text a transparent Canvas2D overlay with local MV Mono font, lens a per-frame object you set to direct the host post stack. LENS: the host renders HDR then applies depth of field, bloom, a PBR Neutral highlight shoulder, vignette and grain. Set ctx.lens.focus (camera distance, or a THREE.Vector3 such as the subject's head) and ctx.lens.aperture (blur pixels at 1080p; 0 is sharp, 3-6 for wide shots, 10-18 for character close-ups) and animate focus from env.t for rack focus; ctx.lens.maxBlur caps it (default 16). Only colours above ctx.lens.bloomThreshold (default 1) glow, so drive emissive screens, lamps and sparks above 1 (e.g. new THREE.Color(3, 1.6, 0.8)) and raise the threshold above a bright daytime sky so daylight does not haze; ctx.lens.bloom (default 0.3), exposure, vignette and grain are also settable. Light a character with a key that casts shadows plus a soft fill near the camera so faces stay readable in night or backlit shots, and keep additive particles small and away from the lens. Build modeled characters with articulated limbs and expressive poses, environments with depth/lighting/shadows, props, narrative action and camera choreography. Position every object analytically from env.t/localT; no simulation accumulation. Add geometry/lights to ctx.scene and set ctx.camera explicitly. Use ctx.text for designed typography. Render fills the whole frame; a particle field or text overlays alone are not a scene. Do not create a renderer, DOM elements, textures loaded from files, or another clock. env provides t, localT, frame, width, height, song, section, palette, safe, events and reactiveGain. No imports, require, fetch, Math.random, Date, performance, globalThis, window, document or external assets. The host draws aligned subtitles after your text; reserve lower title-safe space. Use reusable local functions within each section for anatomy and world construction.` : `Write original Canvas 2D section functions for a mixed-media music-video document titled ${JSON.stringify(trimTo(title, 200))}. The host owns the document, song clock, selected local media and lyric pass. Return code functions only; do not request or generate image/video assets.`,+ renderer === 'three' ? `Write complete authored Three.js worlds, one function render(ctx, env) per section. ctx = { THREE, scene, camera, text, lens }; THREE is the installed locally packaged library; scene is a fresh Scene on EACH seek, camera a PerspectiveCamera, text a transparent Canvas2D overlay with local MV Mono font, lens a per-frame object you set to direct the host post stack. LENS: every lens setting starts off; once any is set the host renders HDR then applies depth of field, bloom, a PBR Neutral highlight shoulder, vignette and grain. For a finished look set ctx.lens.bloom 0.3, vignette 0.3 and grain 0.02 alongside your focus. Set ctx.lens.focus (camera distance, or a THREE.Vector3 such as the subject's head) and ctx.lens.aperture (blur pixels at 1080p; 0 is sharp, 3-6 for wide shots, 10-18 for character close-ups) and animate focus from env.t for rack focus; ctx.lens.maxBlur caps it (default 16). Only colours above ctx.lens.bloomThreshold (default 1) glow, so drive emissive screens, lamps and sparks above 1 (e.g. new THREE.Color(3, 1.6, 0.8)) and raise the threshold above a bright daytime sky so daylight does not haze; exposure is also settable (default 1). Light a character with a key that casts shadows plus a soft fill near the camera so faces stay readable in night or backlit shots, and keep additive particles small and away from the lens. Build modeled characters with articulated limbs and expressive poses, environments with depth/lighting/shadows, props, narrative action and camera choreography. Position every object analytically from env.t/localT; no simulation accumulation. Add geometry/lights to ctx.scene and set ctx.camera explicitly. Use ctx.text for designed typography. Render fills the whole frame; a particle field or text overlays alone are not a scene. Do not create a renderer, DOM elements, textures loaded from files, or another clock. env provides t, localT, frame, width, height, song, section, palette, safe, events and reactiveGain. No imports, require, fetch, Math.random, Date, performance, globalThis, window, document or external assets. The host draws aligned subtitles after your text; reserve lower title-safe space. Use reusable local functions within each section for anatomy and world construction.` : `Write original Canvas 2D section functions for a mixed-media music-video document titled ${JSON.stringify(trimTo(title, 200))}. The host owns the document, song clock, selected local media and lyric pass. Return code functions only; do not request or generate image/video assets.`,renderer === 'three' ? '' : CODE_VIDEO_RULES.replace('- Canvas 2D only. No external assets, fonts, or network.', '- Canvas 2D only. No network, remote URLs, filesystem paths or font loading. The host binds only the listed selected project assets; draw over footage/stills without obscuring them, and draw the entire authored world for card scenes, including characters, environments, camera staging, lighting and narrative actions. Local packaged fonts MV Mono, MV Cond and MV Stencil are available; authored titles are allowed, but do not duplicate host subtitles.'),MUSIC_VIDEO_DIRECTION,MUSIC_VIDEO_CHOREOGRAPHY,diff --git a/server/services/musicVideo/documentRender.browser.test.js b/server/services/musicVideo/documentRender.browser.test.jsindex 8a1e7547f2..6976f1b37e 100644--- a/server/services/musicVideo/documentRender.browser.test.js+++ b/server/services/musicVideo/documentRender.browser.test.js@@ -200,7 +200,9 @@ describe.skipIf(!canRun)('layered template with real Chrome and ffmpeg', () => {// A Vector3 focus is view-space depth, not straight-line distance from the// camera's local position: an off-axis head seen through a rig-parented// camera stays as sharp as with no depth of field at all.- const headSharpness = (aperture) => page.evaluate(async (aperture) => {+ // focus 'card' passes the Vector3; 'local' passes the straight-line distance+ // from the camera's local position, the depth the old code used.+ const headSharpness = (focusOn) => page.evaluate(async (focusOn) => {window.PORTOS_MV_GENERATED.sections.world = (ctx, env) => {window.authoredWorld(ctx, env);const { THREE, scene, camera } = ctx;@@ -214,7 +216,7 @@ describe.skipIf(!canRun)('layered template with real Chrome and ffmpeg', () => {card.add(new THREE.Mesh(new THREE.PlaneGeometry(1, 1), new THREE.MeshBasicMaterial({ color: 0x000000 })));for (let i = -2; i <= 2; i++) { const bar = new THREE.Mesh(new THREE.PlaneGeometry(0.06, 1), new THREE.MeshBasicMaterial({ color: 0xffffff })); bar.position.set(i * 0.18, 0, 0.001); card.add(bar); }card.lookAt(at);- Object.assign(ctx.lens, { grain: 0, vignette: 0, bloom: 0, focus: head, aperture, maxBlur: 24 });+ Object.assign(ctx.lens, { focus: focusOn === 'card' ? head : head.distanceTo(camera.position), aperture: 18, maxBlur: 24 });window.projectHead = () => head.clone().project(camera);};await window.portosComposition.seek(0);@@ -227,11 +229,11 @@ describe.skipIf(!canRun)('layered template with real Chrome and ffmpeg', () => {const { data } = g.getImageData(0, 0, 80, 80);let sum = 0; for (let i = 4; i < data.length; i += 4) sum += Math.abs(data[i] - data[i - 4]);return { sum, offAxis: Math.abs(window.headOnScreen.x) };- }, aperture);- const sharpHead = await headSharpness(0);- const focusedHead = await headSharpness(18);- expect(sharpHead.offAxis).toBeGreaterThan(0.1);- expect(focusedHead.sum).toBeGreaterThan(sharpHead.sum * 0.99); // straight-line distance from the local position gives ~0.95+ }, focusOn);+ const focusedHead = await headSharpness('card');+ const missedHead = await headSharpness('local');+ expect(focusedHead.offAxis).toBeGreaterThan(0.1);+ expect(focusedHead.sum).toBeGreaterThan(missedHead.sum * 1.03);expect(await page.evaluate(() => window.liveTextureCount())).toBe(textures);expect(warnings.filter((text) => text.includes('PCFSoftShadowMap'))).toEqual([]);expect(errors).toEqual([]);diff --git a/server/services/musicVideo/documentTemplates/spatial/engine.js b/server/services/musicVideo/documentTemplates/spatial/engine.jsindex fdcea68368..6748ca6adb 100644--- a/server/services/musicVideo/documentTemplates/spatial/engine.js+++ b/server/services/musicVideo/documentTemplates/spatial/engine.js@@ -5,9 +5,8 @@ const authored = window.PORTOS_MV_GENERATED;const canvas = document.getElementById('world');const overlay = document.getElementById('type');const text = overlay.getContext('2d');-// No canvas MSAA: the scene is multisampled in the HDR target, and the canvas-// only ever receives one full-screen composite.-const renderer = new THREE.WebGLRenderer({ canvas, antialias: false, preserveDrawingBuffer: true });+// Canvas MSAA serves the untouched-lens path, which renders straight to it.+const renderer = new THREE.WebGLRenderer({ canvas, antialias: true, preserveDrawingBuffer: true });renderer.setPixelRatio(1);renderer.shadowMap.enabled = true;// three r186 removed PCFSoftShadowMap; PCF plus light.shadow.radius is the soft path.@@ -94,11 +93,12 @@ globalThis.portosComposition = {}-// A section may set any of these on ctx.lens for its frame. Defaults keep a-// world sharp with a light finish; only HDR values above the threshold bloom.+// A section may set any of these on ctx.lens for its frame. The defaults are+// inert, so a world that never touches the lens renders exactly as before,+// straight to the canvas; only HDR values above the threshold bloom.// focus is a camera distance or a THREE.Vector3; aperture/maxBlur are pixels// at 1080p, so a 0 aperture disables depth of field.-const LENS_DEFAULTS = Object.freeze({ focus: 10, aperture: 0, maxBlur: 16, bloom: 0.3, bloomThreshold: 1, exposure: 1, vignette: 0.3, grain: 0.02 });+const LENS_DEFAULTS = Object.freeze({ focus: 10, aperture: 0, maxBlur: 16, bloom: 0, bloomThreshold: 1, exposure: 1, vignette: 0, grain: 0 });// Persistent cinematic post stack: the scene renders once into an HDR target// with depth, then a depth-aware gather DOF, a thresholded quarter-res bloom@@ -205,9 +205,15 @@ function createPost(THREE, renderer) {else focus = num(lens.focus, LENS_DEFAULTS.focus, 0.01, 1e5);const aperture = num(lens.aperture, 0, 0, 64) * px, maxBlur = num(lens.maxBlur, LENS_DEFAULTS.maxBlur, 0, 48) * px;const bloom = num(lens.bloom, LENS_DEFAULTS.bloom, 0, 4);+ const exposure = num(lens.exposure, 1, 0, 8), vignette = num(lens.vignette, LENS_DEFAULTS.vignette, 0, 1), grain = num(lens.grain, LENS_DEFAULTS.grain, 0, 0.2);// Software-rendered captures pay per full-screen pass, so a lens setting- // that does nothing skips its pass outright.+ // that does nothing skips its pass outright, and an untouched lens skips+ // the HDR path entirely.const focusing = aperture > 0 && maxBlur >= 0.5;+ if (!focusing && !bloom && !vignette && !grain && exposure === 1) {+ renderer.setRenderTarget(null); renderer.render(world, view);+ return;+ }const sceneTarget = focusing ? hdrDepth : hdr;renderer.setRenderTarget(sceneTarget); renderer.clear(); renderer.render(world, view);let sharp = sceneTarget.texture;@@ -230,8 +236,8 @@ function createPost(THREE, renderer) {}const u = composite.uniforms;u.tColor.value = sharp; u.tBloom.value = small.texture; u.uRes.value.set(w, h);- u.uBloom.value = bloom; u.uExposure.value = num(lens.exposure, 1, 0, 8);- u.uVignette.value = num(lens.vignette, LENS_DEFAULTS.vignette, 0, 1); u.uGrain.value = num(lens.grain, LENS_DEFAULTS.grain, 0, 0.2);+ u.uBloom.value = bloom; u.uExposure.value = exposure;+ u.uVignette.value = vignette; u.uGrain.value = grain;u.uFrame.value = frame;draw(composite, null);},