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
fix: close folded toon sheets and preserve ink over bloom (#10713)
Adam Eivya98901b05af9
diff --git a/server/services/musicVideo/documentTemplates/shared/toonWorld.browser.test.js b/server/services/musicVideo/documentTemplates/shared/toonWorld.browser.test.jsindex 744fd06d5e..735e2fe8ca 100644--- a/server/services/musicVideo/documentTemplates/shared/toonWorld.browser.test.js+++ b/server/services/musicVideo/documentTemplates/shared/toonWorld.browser.test.js@@ -47,6 +47,8 @@ describe.skipIf(!canRun)('toon world headless dish proof', () => {expect(results.flatChanged).toBe(0);expect(new Set(results.views).size).toBe(3);expect(results.postChanged).toBeGreaterThan(1000);+ expect(results.darkInkCount).toBeGreaterThan(100);+ expect(results.bloomOverInk).toBe(0);expect(results.repeat).toBe(true);expect(errors).toEqual([]);console.log(`🎨 Toon dish proof: baseline ${results.baselineMs.toFixed(1)}ms, ink ${results.inkMs.toFixed(1)}ms, ratio ${results.ratio.toFixed(2)}`);@@ -106,6 +108,14 @@ window.manualProof=()=>{window.proof=()=>{const baseline=draw(), ink=draw({ink:true});const inkChanged=changed(baseline,ink);+ const blackInk=draw({ink:{color:'#000000',width:2}});+ const bloomedInk=draw({ink:{color:'#000000',width:2},bloom:4,bloomThreshold:0});+ let darkInkCount=0,bloomOverInk=0;+ for(let i=0;i<blackInk.length;i+=4){+ if(blackInk.slice(i,i+3).every(v=>v<3)&&baseline.slice(i,i+3).some(v=>v>50)){+ darkInkCount++;if(bloomedInk.slice(i,i+3).some(v=>v>3))bloomOverInk++;+ }+ }// Empty ground in the lower left has no silhouette or crease.const flatChanged=changed(baseline,ink,index=>{const x=index%640,y=Math.floor(index/640);return x>30&&x<100&&y>30&&y<100;});const views=[];@@ -132,6 +142,6 @@ window.proof=()=>{}const median=values=>values.sort((x,y)=>x-y)[Math.floor(values.length/2)];const baselineMs=median(a),inkMs=median(b);- return {overlaps:kit.warnOverlaps(THREE,dishes),inkChanged,hiddenChanged,flatChanged,views,postChanged,repeat,baselineMs,inkMs,ratio:inkMs/baselineMs};+ return {overlaps:kit.warnOverlaps(THREE,dishes),darkInkCount,bloomOverInk,inkChanged,hiddenChanged,flatChanged,views,postChanged,repeat,baselineMs,inkMs,ratio:inkMs/baselineMs};};`;diff --git a/server/services/musicVideo/documentTemplates/shared/toonWorld.js b/server/services/musicVideo/documentTemplates/shared/toonWorld.jsindex 0c3258f014..a64ee2be08 100644--- a/server/services/musicVideo/documentTemplates/shared/toonWorld.js+++ b/server/services/musicVideo/documentTemplates/shared/toonWorld.js@@ -56,19 +56,37 @@ export function shellLathe(profile, thickness, segments = 64) {export function solidify(geometry, thickness) {positive(thickness, 'Thickness');const source = geometry.clone();- if (!source.getAttribute('normal')) source.computeVertexNormals();- const p = source.getAttribute('position'), n = source.getAttribute('normal');+ const p = source.getAttribute('position');if (!p || p.count < 3) throw new Error('Solidify needs triangle positions');+ if (!source.getAttribute('normal')) source.computeVertexNormals();+ const n = source.getAttribute('normal');const indices = source.index ? Array.from(source.index.array) : Array.from({ length: p.count }, (_, i) => i);if (indices.length % 3) throw new Error('Solidify needs triangles');const positions = [], normals = [], uvs = [], uv = source.getAttribute('uv');- const weld = new Map(), canonical = [];+ const weld = new Map(), canonical = [], offsets = new Map();for (let i = 0; i < p.count; i++) {const key = [p.getX(i), p.getY(i), p.getZ(i)].map(v => Math.round(v * 1e6)).join(',');- if (!weld.has(key)) weld.set(key, i);- canonical[i] = weld.get(key);+ if (!weld.has(key)) weld.set(key, { index: i, normals: new Map() });+ const group = weld.get(key);+ canonical[i] = group.index;+ const normal = new GeometryTHREE.Vector3(n.getX(i), n.getY(i), n.getZ(i)).normalize();+ // Duplicate face corners must not bias a seam's offset toward whichever+ // triangle happened to repeat that corner more often.+ group.normals.set(normal.toArray().map(v => Math.round(v * 1e6)).join(','), normal);+ }+ for (const group of weld.values()) {+ const normalsAtSeam = [...group.normals.values()];+ const direction = normalsAtSeam.reduce((sum, normal) => sum.add(normal), new GeometryTHREE.Vector3()).normalize();+ const projection = Math.min(...normalsAtSeam.map(normal => normal.dot(direction)));+ if (projection <= 1e-6) throw new Error('Solidify needs consistently oriented sheet normals');+ // Miter the welded corner, retaining at least the requested thickness on+ // each incident face. Keep original shading normals on separate vertices.+ offsets.set(group.index, direction.multiplyScalar(thickness / (2 * projection)));+ }+ for (let i = 0; i < p.count; i++) {+ const offset = offsets.get(canonical[i]), point = canonical[i];for (const sign of [1, -1]) {- positions.push(p.getX(i) + sign * n.getX(i) * thickness / 2, p.getY(i) + sign * n.getY(i) * thickness / 2, p.getZ(i) + sign * n.getZ(i) * thickness / 2);+ positions.push(p.getX(point) + sign * offset.x, p.getY(point) + sign * offset.y, p.getZ(point) + sign * offset.z);normals.push(sign * n.getX(i), sign * n.getY(i), sign * n.getZ(i));uvs.push(uv?.getX(i) ?? 0, uv?.getY(i) ?? 0);}diff --git a/server/services/musicVideo/documentTemplates/shared/toonWorld.test.js b/server/services/musicVideo/documentTemplates/shared/toonWorld.test.jsindex 7dd3528f2d..553c448a85 100644--- a/server/services/musicVideo/documentTemplates/shared/toonWorld.test.js+++ b/server/services/musicVideo/documentTemplates/shared/toonWorld.test.js@@ -66,6 +66,33 @@ describe('toon world geometry and placement', () => {sheet.dispose();});+ it('closes a folded non-indexed sheet without cracks at its hard normal seam', () => {+ const folded = new THREE.BufferGeometry();+ folded.setAttribute('position', new THREE.Float32BufferAttribute([+ 0, 0, 0, 1, 0, 0, 0, 1, 0,+ 1, 0, 0, 0, 0, 0, 0, 0, 1,+ ], 3));+ const shell = solidify(folded, .2);+ const p = shell.getAttribute('position'), n = shell.getAttribute('normal');+ for (const [a, b] of [[0, 8], [2, 6], [1, 9], [3, 7]]) {+ expect([p.getX(a), p.getY(a), p.getZ(a)]).toEqual([p.getX(b), p.getY(b), p.getZ(b)]);+ }+ expect(n.getZ(0)).toBe(1); expect(n.getY(8)).toBe(1);+ const edges = new Map();+ const point = i => [p.getX(i), p.getY(i), p.getZ(i)].map(v => Math.round(v * 1e6)).join(',');+ const indices = shell.index.array;+ for (let i = 0; i < indices.length; i += 3) {+ const [a, b, c] = [...indices.slice(i, i + 3)].map(point);+ for (const pair of [[a, b], [b, c], [c, a]]) {+ const key = pair.sort().join('|');+ edges.set(key, (edges.get(key) || 0) + 1);+ }+ }+ expect([...edges.values()].every(count => count === 2)).toBe(true);+ expect(shell.index.count).toBe(36);+ folded.dispose(); shell.dispose();+ });+it('warns for actual transformed bounds, while touching or spaced bounds are allowed', () => {const objects = layoutRow({ count: 7, footprint: 2, gap: .1 }).map(p => {const mesh = new THREE.Mesh(new THREE.BoxGeometry(2, 1, 2));diff --git a/server/services/musicVideo/documentTemplates/spatial/engine.js b/server/services/musicVideo/documentTemplates/spatial/engine.jsindex 0991f3d834..3088bf75dc 100644--- a/server/services/musicVideo/documentTemplates/spatial/engine.js+++ b/server/services/musicVideo/documentTemplates/spatial/engine.js@@ -166,7 +166,7 @@ export function createPost(THREE, renderer) {// The frame is wrapped so sin() stays in precise range late in a long song.float hash(vec2 p){ return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); }void main(){- vec3 c = (applyInk(texture2D(tColor, vUv).rgb, vUv) + texture2D(tBloom, vUv).rgb * uBloom) * uExposure;+ vec3 c = applyInk(texture2D(tColor, vUv).rgb + texture2D(tBloom, vUv).rgb * uBloom, vUv) * uExposure;c = srgb(clamp(neutral(max(c, 0.)), 0., 1.));vec2 q = vUv - .5; c *= 1. - dot(q, q) * uVignette * 1.8;c += (hash(vUv * uRes + mod(uFrame, 251.) * 7.13) - .5) * uGrain;