Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
release: SnapCAD Studio 1.0.10 (desktop menuler, macOS kisayollari, YakNet SSO)
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import * as THREE from "three";
|
||||
import {
|
||||
cleanTriangleSoup,
|
||||
computeSignedVolumeFromPositions,
|
||||
isTriangleSoupWatertightClosed,
|
||||
normalizeClosedMeshWinding,
|
||||
sanitizeBufferGeometry,
|
||||
} from "@/lib/meshSanitizer";
|
||||
|
||||
function makeBoxTriangleSoup(width: number, height: number, depth: number, invertWinding = false): number[] {
|
||||
const geom = new THREE.BoxGeometry(width, height, depth);
|
||||
const nonIndexed = geom.index ? geom.toNonIndexed() : geom;
|
||||
const pos = nonIndexed.getAttribute("position");
|
||||
const out: number[] = [];
|
||||
for (let i = 0; i + 2 < pos.count; i += 3) {
|
||||
const order = invertWinding ? [i, i + 2, i + 1] : [i, i + 1, i + 2];
|
||||
for (const idx of order) {
|
||||
out.push(pos.getX(idx), pos.getY(idx), pos.getZ(idx));
|
||||
}
|
||||
}
|
||||
geom.dispose();
|
||||
if (nonIndexed !== geom) nonIndexed.dispose();
|
||||
return out;
|
||||
}
|
||||
|
||||
describe("Mesh Sanitizer (NassCAD Data Integrity)", () => {
|
||||
it("drops zero-area degenerate triangles and NaN coordinates cleanly", () => {
|
||||
const validTri = [0, 0, 0, 10, 0, 0, 0, 10, 0];
|
||||
const zeroAreaTri = [1, 1, 0, 2, 1, 0, 3, 1, 0]; // collinear
|
||||
const repeatedVertexTri = [5, 5, 5, 5, 5, 5, 10, 5, 5];
|
||||
const nanTri = [0, 0, 0, Number.NaN, 1, 0, 1, 1, 0];
|
||||
|
||||
const res = cleanTriangleSoup([
|
||||
...validTri,
|
||||
...zeroAreaTri,
|
||||
...repeatedVertexTri,
|
||||
...nanTri,
|
||||
]);
|
||||
|
||||
expect(res.droppedTriangles).toBe(3);
|
||||
expect(res.triangleCount).toBe(1);
|
||||
expect(res.positions).toEqual(validTri);
|
||||
});
|
||||
|
||||
it("detects closed watertight box and restores inverted closed winding", () => {
|
||||
const outwardBox = makeBoxTriangleSoup(20, 10, 30, false);
|
||||
const invertedBox = makeBoxTriangleSoup(20, 10, 30, true);
|
||||
|
||||
expect(isTriangleSoupWatertightClosed(outwardBox)).toBe(true);
|
||||
expect(computeSignedVolumeFromPositions(outwardBox)).toBeCloseTo(6000, 1);
|
||||
expect(computeSignedVolumeFromPositions(invertedBox)).toBeCloseTo(-6000, 1);
|
||||
|
||||
const fixed = normalizeClosedMeshWinding(invertedBox);
|
||||
expect(fixed.closed).toBe(true);
|
||||
expect(fixed.wasFlipped).toBe(true);
|
||||
expect(fixed.signedVolume).toBeCloseTo(6000, 1);
|
||||
expect(computeSignedVolumeFromPositions(fixed.positions)).toBeCloseTo(6000, 1);
|
||||
});
|
||||
|
||||
it("sanitizes indexed THREE.BufferGeometry while updating material groups accurately", () => {
|
||||
const geom = new THREE.BufferGeometry();
|
||||
geom.setAttribute(
|
||||
"position",
|
||||
new THREE.Float32BufferAttribute(
|
||||
[
|
||||
0, 0, 0,
|
||||
10, 0, 0,
|
||||
0, 10, 0,
|
||||
5, 5, 0, // degenerate duplicate triangle indices will reference this
|
||||
],
|
||||
3,
|
||||
),
|
||||
);
|
||||
geom.setIndex([
|
||||
0, 1, 2, // group 0: valid
|
||||
0, 0, 1, // group 0: degenerate
|
||||
0, 2, 1, // group 1: valid
|
||||
]);
|
||||
geom.addGroup(0, 6, 0);
|
||||
geom.addGroup(6, 3, 1);
|
||||
|
||||
sanitizeBufferGeometry(geom);
|
||||
expect(geom.getIndex()?.count).toBe(6);
|
||||
expect(geom.groups[0]).toEqual({ start: 0, count: 3, materialIndex: 0 });
|
||||
expect(geom.groups[1]).toEqual({ start: 3, count: 3, materialIndex: 1 });
|
||||
geom.dispose();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user