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 SketchForge 0.5 edge tools
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
bakeCadMetadataForShapeTransform,
|
||||
cadBrepTransformForShape,
|
||||
cadModifierPrimitiveForAnalyticBox,
|
||||
cadModifierPrimitiveForBakedShape,
|
||||
} from "@/lib/cadBakeMetadata";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
function expectTransformClose(actual: number[] | undefined, expected: number[]) {
|
||||
expect(actual).toHaveLength(expected.length);
|
||||
expected.forEach((value, index) => {
|
||||
expect(actual?.[index]).toBeCloseTo(value, 6);
|
||||
});
|
||||
}
|
||||
|
||||
function treatedMeshShape(overrides: Partial<WorkplaneShape> = {}): WorkplaneShape {
|
||||
return {
|
||||
id: "treated-mesh",
|
||||
name: "Treated Mesh",
|
||||
kind: "mesh",
|
||||
color: "#d41721",
|
||||
x: 10,
|
||||
z: 0,
|
||||
elevation: 5,
|
||||
size: 2,
|
||||
width: 2,
|
||||
depth: 2,
|
||||
height: 2,
|
||||
rotation: 0,
|
||||
rotationX: 0,
|
||||
rotationZ: 0,
|
||||
importedMesh: {
|
||||
positions: [-1, 0, 0, 1, 0, 0, 0, 2, 0],
|
||||
baseWidth: 2,
|
||||
baseDepth: 2,
|
||||
baseHeight: 2,
|
||||
triangleCount: 1,
|
||||
sourceFormat: "json",
|
||||
},
|
||||
edgeTreatments: [{ kind: "fillet", amount: 0.5, edgeCount: 1 }],
|
||||
cadDisplayEdges: [{ points: [-1, 0, 0, 1, 0, 0] }],
|
||||
cadDisplayEdgesVersion: 2,
|
||||
cadBrep: "stored-brep-before-rotation",
|
||||
cadBrepFrame: {
|
||||
x: 10,
|
||||
z: 0,
|
||||
elevation: 5,
|
||||
width: 2,
|
||||
depth: 2,
|
||||
height: 2,
|
||||
},
|
||||
locked: false,
|
||||
hidden: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function boxShape(overrides: Partial<WorkplaneShape> = {}): WorkplaneShape {
|
||||
return {
|
||||
id: "box",
|
||||
name: "Box",
|
||||
kind: "box",
|
||||
color: "#d41721",
|
||||
x: 4,
|
||||
z: -6,
|
||||
elevation: 2,
|
||||
size: 20,
|
||||
width: 20,
|
||||
depth: 18,
|
||||
height: 16,
|
||||
rotation: 32,
|
||||
rotationX: 18,
|
||||
rotationZ: 24,
|
||||
locked: false,
|
||||
hidden: false,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("SketchForge transform baking", () => {
|
||||
it("preserves exact BREP and rebases CAD display edges after wheel rotation", () => {
|
||||
const shape = treatedMeshShape({ rotationZ: 90 });
|
||||
const baked = bakeCadMetadataForShapeTransform(shape, {
|
||||
centerX: 10,
|
||||
minY: 5,
|
||||
centerZ: 0,
|
||||
width: 2,
|
||||
depth: 2,
|
||||
height: 2,
|
||||
yawDegrees: 0,
|
||||
});
|
||||
const expectedTransform = [0, -1, 0, 16, 1, 0, 0, -4, 0, 0, 1, 0];
|
||||
|
||||
expect(baked.cadBrep).toBe("stored-brep-before-rotation");
|
||||
expect(baked.cadBrepFrame).toMatchObject({
|
||||
x: 10,
|
||||
z: 0,
|
||||
elevation: 5,
|
||||
width: 2,
|
||||
depth: 2,
|
||||
height: 2,
|
||||
});
|
||||
expectTransformClose(baked.cadBrepFrame?.sourceTransform, expectedTransform);
|
||||
expect(baked.cadDisplayEdgesVersion).toBe(2);
|
||||
expect(baked.cadDisplayEdges?.[0].points).toEqual([1, 0, 0, 1, 2, 0]);
|
||||
|
||||
const bakedShape: WorkplaneShape = {
|
||||
...shape,
|
||||
...baked,
|
||||
x: 10,
|
||||
z: 0,
|
||||
elevation: 5,
|
||||
width: 2,
|
||||
depth: 2,
|
||||
height: 2,
|
||||
size: 2,
|
||||
rotation: 0,
|
||||
rotationX: 0,
|
||||
rotationZ: 0,
|
||||
};
|
||||
expectTransformClose(cadBrepTransformForShape(bakedShape), expectedTransform);
|
||||
});
|
||||
|
||||
it("preserves an analytic box primitive when wheel rotation bakes it to a mesh", () => {
|
||||
const shape = boxShape();
|
||||
const directPrimitive = cadModifierPrimitiveForAnalyticBox(shape);
|
||||
expect(directPrimitive?.transform).toBeDefined();
|
||||
|
||||
const baked = bakeCadMetadataForShapeTransform(shape, {
|
||||
centerX: 4.5,
|
||||
minY: -2,
|
||||
centerZ: -5.5,
|
||||
width: 27,
|
||||
depth: 26,
|
||||
height: 25,
|
||||
yawDegrees: 32,
|
||||
});
|
||||
|
||||
expect(baked.cadPrimitiveFrame).toMatchObject({
|
||||
kind: "box",
|
||||
width: 20,
|
||||
depth: 18,
|
||||
height: 16,
|
||||
frame: {
|
||||
x: 4.5,
|
||||
z: -5.5,
|
||||
elevation: -2,
|
||||
width: 27,
|
||||
depth: 26,
|
||||
height: 25,
|
||||
},
|
||||
});
|
||||
expectTransformClose(baked.cadPrimitiveFrame?.frame.sourceTransform, directPrimitive?.transform ?? []);
|
||||
|
||||
const bakedShape: WorkplaneShape = {
|
||||
...shape,
|
||||
...baked,
|
||||
kind: "mesh",
|
||||
x: 4.5,
|
||||
z: -5.5,
|
||||
elevation: -2,
|
||||
width: 27,
|
||||
depth: 26,
|
||||
height: 25,
|
||||
size: 27,
|
||||
rotation: 0,
|
||||
rotationX: 0,
|
||||
rotationZ: 0,
|
||||
importedMesh: {
|
||||
positions: [-1, 0, 0, 1, 0, 0, 0, 1, 0],
|
||||
baseWidth: 27,
|
||||
baseDepth: 26,
|
||||
baseHeight: 25,
|
||||
triangleCount: 1,
|
||||
sourceFormat: "json",
|
||||
},
|
||||
};
|
||||
const restoredPrimitive = cadModifierPrimitiveForBakedShape(bakedShape);
|
||||
expect(restoredPrimitive).toMatchObject({
|
||||
kind: "box",
|
||||
width: 20,
|
||||
depth: 18,
|
||||
height: 16,
|
||||
});
|
||||
expectTransformClose(restoredPrimitive?.transform, directPrimitive?.transform ?? []);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user