feat: SnapCAD Studio'yu YakHub deposuna taşı
Build and Push Docker Images / build (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s

- DWG/DXF içe aktarma ve .skf yeniden açma düzeltmeleri

- YakNet Bulut eşitlemede boş/eski kopya koruması ve yerel-only proje bildirimi

- Panelden içe aktarma duyuruları ve erişilebilir Türkçe hata mesajları

- AGPL-3.0 lisansı, README ve YakHub bağlantıları
This commit is contained in:
Enes Yakıştır
2026-10-25 18:20:21 +03:00
parent e9cb8e8681
commit 33b0940012
149 changed files with 46978 additions and 1273 deletions
+174
View File
@@ -0,0 +1,174 @@
import { describe, expect, it } from "vitest";
import * as THREE from "three";
import {
ARCHITECTURAL_TEXTURES,
getTextureDefinition,
type ArchitecturalTextureId,
} from "../../apps/web/src/lib/architecturalTextures";
import {
DEFAULT_SECTION_PLANE,
createSectionClippingPlane,
createSectionPlaneGizmo,
updateSectionGizmoTransform,
type SectionPlaneSettings,
} from "../../apps/web/src/lib/sectionPlaneSystem";
import { PhysicsSandbox } from "../../apps/web/src/lib/physicsSandbox";
import type { WorkplaneShape } from "../../apps/web/src/types/sketchforge";
describe("Architectural Materials & Textures System", () => {
it("provides comprehensive texture definitions including brick, wood, marble, glass, metal", () => {
expect(ARCHITECTURAL_TEXTURES.length).toBeGreaterThanOrEqual(9);
const ids = ARCHITECTURAL_TEXTURES.map((t) => t.id);
expect(ids).toContain("none");
expect(ids).toContain("brick");
expect(ids).toContain("wood");
expect(ids).toContain("tiles");
expect(ids).toContain("marble");
expect(ids).toContain("concrete");
expect(ids).toContain("metal");
expect(ids).toContain("glass");
expect(ids).toContain("grass");
});
it("retrieves valid texture definitions with correct physical material properties", () => {
const glassDef = getTextureDefinition("glass");
expect(glassDef.name).toBe("Buzlu / Cam");
expect(glassDef.transparent).toBe(true);
expect(glassDef.opacity).toBeLessThan(1);
expect(glassDef.roughness).toBeLessThan(0.3);
const metalDef = getTextureDefinition("metal");
expect(metalDef.metalness).toBeGreaterThan(0.8);
const woodDef = getTextureDefinition("wood");
expect(woodDef.category).toBe("Doğal");
const fallbackDef = getTextureDefinition("none");
expect(fallbackDef.id).toBe("none");
});
});
describe("Architectural Section Plane System (SketchUp Style)", () => {
it("creates accurate clipping plane along Y axis (Elevation / Floor Plan Cut)", () => {
const settings: SectionPlaneSettings = {
enabled: true,
axis: "y",
offset: 25,
invert: false,
showGizmo: true,
};
const plane = createSectionClippingPlane(settings);
// Y-axis normal pointing down by default: (0, -1, 0)
expect(plane.normal.x).toBe(0);
expect(plane.normal.y).toBe(-1);
expect(plane.normal.z).toBe(0);
// Point on plane at y=25: distanceToPoint((0, 25, 0)) should be 0
expect(plane.distanceToPoint(new THREE.Vector3(0, 25, 0))).toBeCloseTo(0);
});
it("inverts plane normal when invert flag is true", () => {
const normalCut: SectionPlaneSettings = {
enabled: true,
axis: "x",
offset: 10,
invert: false,
showGizmo: true,
};
const invertedCut: SectionPlaneSettings = {
...normalCut,
invert: true,
};
const p1 = createSectionClippingPlane(normalCut);
const p2 = createSectionClippingPlane(invertedCut);
expect(p1.normal.x).toBe(-p2.normal.x);
});
it("builds and updates visual section gizmo with plane, border, and direction arrow", () => {
const settings: SectionPlaneSettings = {
...DEFAULT_SECTION_PLANE,
offset: 40,
};
const gizmo = createSectionPlaneGizmo(settings, 200);
expect(gizmo.name).toBe("section-plane-gizmo");
expect(gizmo.children.length).toBeGreaterThanOrEqual(4);
// Position check
expect(gizmo.position.y).toBe(40);
// Update transform to X axis
updateSectionGizmoTransform(gizmo, { ...settings, axis: "x", offset: -30 });
expect(gizmo.position.x).toBe(-30);
expect(gizmo.position.y).toBe(0);
});
});
describe("Physics & Gravity Simulation Engine (Cannon-es)", () => {
it("initializes physics world and maps 3D shapes to rigid bodies", () => {
const shapes: WorkplaneShape[] = [
{
id: "box-1",
name: "Kutu 1",
kind: "box",
color: "#3b82f6",
x: 0,
z: 0,
elevation: 0,
size: 20,
width: 20,
depth: 20,
height: 20,
rotation: 0,
},
{
id: "box-2",
name: "Kutu 2 (Üstte)",
kind: "box",
color: "#ef4444",
x: 0,
z: 0,
elevation: 20,
size: 20,
width: 20,
depth: 20,
height: 20,
rotation: 0,
},
];
const meshMap = new Map<string, THREE.Object3D>();
for (const s of shapes) {
const mesh = new THREE.Mesh();
mesh.position.set(s.x, (s.elevation ?? 0) + s.height / 2, s.z);
meshMap.set(s.id, mesh);
}
let statusReport: any = null;
const sandbox = new PhysicsSandbox((st) => {
statusReport = st;
});
sandbox.initWorld(shapes, meshMap);
expect(statusReport).not.toBeNull();
expect(statusReport.active).toBe(true);
expect(statusReport.bodiesCount).toBe(2);
// Start simulation
sandbox.start();
expect(statusReport.running).toBe(true);
// Pause simulation
sandbox.pause();
expect(statusReport.running).toBe(false);
// Reset restores meshes
sandbox.reset();
expect(meshMap.get("box-2")!.position.y).toBe(30);
sandbox.stop();
});
});