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
count planes from each axis min so a mesh far from the origin keeps its resolution (#3482)
[._.]/ Adam Eivy2b12e6157779
diff --git a/server/lib/threejsModel.js b/server/lib/threejsModel.jsindex a815ad08bb..4a4f02b5ef 100644--- a/server/lib/threejsModel.js+++ b/server/lib/threejsModel.js@@ -476,23 +476,30 @@ const COPLANAR_DETERMINANT = 1e-6;// once the majority of buildable identity features are backed by nothing else.const FLAT_IDENTITY_RATIO_THRESHOLD = 0.6;-const axisExtent = (vertices, axis) => {+const axisBounds = (vertices, axis) => {let min = Infinity;let max = -Infinity;for (let index = axis; index < vertices.length; index += 3) {if (vertices[index] < min) min = vertices[index];if (vertices[index] > max) max = vertices[index];}- return max - min;+ return [min, max];};const countAxisPlanes = (vertices) => {- const quantum = Math.max(axisExtent(vertices, 0), axisExtent(vertices, 1), axisExtent(vertices, 2))- * RELATIVE_PLANE_QUANTUM;+ const bounds = [0, 1, 2].map((axis) => axisBounds(vertices, axis));+ const quantum = Math.max(...bounds.map(([min, max]) => max - min)) * RELATIVE_PLANE_QUANTUM;// Every vertex sits on one point, so there is exactly one plane per axis.if (!(quantum > 0)) return [1, 1, 1];const axes = [new Set(), new Set(), new Set()];- vertices.forEach((value, index) => axes[index % 3].add(Math.round(value / quantum)));+ // Bucketed from each axis's own minimum rather than the absolute coordinate,+ // so the count is a property of the shape and not of where it was authored:+ // a mesh built far from the origin divides a large offset by a small quantum+ // and loses distinct planes to float resolution.+ vertices.forEach((value, index) => {+ const axis = index % 3;+ axes[axis].add(Math.round((value - bounds[axis][0]) / quantum));+ });return axes.map((axis) => axis.size);};diff --git a/server/lib/threejsModel.test.js b/server/lib/threejsModel.test.jsindex 0a3b0cec01..8fd0f2aaa0 100644--- a/server/lib/threejsModel.test.js+++ b/server/lib/threejsModel.test.js@@ -505,6 +505,13 @@ describe('evaluateThreejsFlatness', () => {expect(flatness.findings.map((finding) => finding.code)).toEqual(['flat-identity-parts']);});+ it('judges the shape, not where it was authored', () => {+ const shifted = solidShellGeometry();+ shifted.vertices = shifted.vertices.map((value, index) => (index % 3 === 0 ? value + 900 : value));+ const flatness = evaluateThreejsFlatness(flatnessSpec([geometryPart('shell', shifted)]));+ expect(flatness).toMatchObject({ flatIdentityDetailCount: 0, findings: [] });+ });+it('does not punish a small part for being small', () => {// A fixed absolute plane grid would give a 0.005-unit mesh five planes per// axis however round it is; the quantum is relative to the mesh's own size.