Skip to content

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

fix: transform custom meshes in membrane checks (#4632)

Adam Eivy58124ede5fe3
diff --git a/server/lib/threejsModel.js b/server/lib/threejsModel.js
index 19734a6dbd..1a6bd0928e 100644
--- a/server/lib/threejsModel.js
+++ b/server/lib/threejsModel.js
@@ -867,11 +867,19 @@ const applyLinear = (matrix, vector) => [
const vectorLength = (vector) => Math.hypot(...vector);
+const transformVertices = (vertices, matrix) => {
+ const transformed = [];
+ for (let index = 0; index + 2 < vertices.length; index += 3) {
+ transformed.push(...applyLinear(matrix, vertices.slice(index, index + 3)));
+ }
+ return transformed;
+};
+
const isZeroThicknessGeometry = (geometry, worldLinear = IDENTITY_LINEAR) => {
if (!geometry) return false;
if (geometry.type === 'custom') {
const vertices = Array.isArray(geometry.vertices) ? geometry.vertices : [];
- return vertices.length >= 9 && isCoplanarCloud(vertices);
+ return vertices.length >= 9 && isCoplanarCloud(transformVertices(vertices, worldLinear));
}
if (geometry.type !== 'extrude') return false;
const outline = Array.isArray(geometry.outline) ? geometry.outline : [];
diff --git a/server/lib/threejsModel.test.js b/server/lib/threejsModel.test.js
index c5e792d614..fccd458be1 100644
--- a/server/lib/threejsModel.test.js
+++ b/server/lib/threejsModel.test.js
@@ -436,6 +436,12 @@ const solidShellGeometry = () => {
return { type: 'custom', vertices, indices };
};
+const thinCustomGeometry = () => {
+ const outline = [[-1, -1], [1, -1], [1, 1], [-1, 1]];
+ const vertices = [-0.0005, 0.0005].flatMap((z) => outline.flatMap(([x, y]) => [x, y, z]));
+ return { type: 'custom', vertices, indices: [0, 1, 2, 0, 2, 3, 4, 6, 5, 4, 7, 6] };
+};
+
const geometryPart = (id, geometry) => ({
id,
name: `${id} part`,
@@ -648,6 +654,15 @@ describe('evaluateThreejsFlatness', () => {
expect(flatness.findings[0].severity).toBe('warning');
});
+ it('keeps a thin custom solid in the warning after normal-axis scaling', () => {
+ const spec = flatnessSpec([geometryPart('plate', thinCustomGeometry())]);
+ spec.parts[0].scale = [1, 1, 1_000];
+ spec.materials.body.side = 'double';
+ const flatness = evaluateThreejsFlatness(spec);
+ expect(flatness).toMatchObject({ warningCount: 1, noteCount: 0, flatRatio: 1 });
+ expect(flatness.findings[0].severity).toBe('warning');
+ });
+
it('keeps duplicate feature labels classified independently', () => {
const membrane = geometryPart('membrane', flatFanGeometry());
const plate = geometryPart('plate', validExtrude());