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
89 lines
2.3 KiB
TypeScript
89 lines
2.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
||||
|
|
import {
|
|||
|
|
calculateSmartPlacementPoint,
|
|||
|
|
calculateTopSurfaceElevation,
|
|||
|
|
} from "@/lib/smartPlacement";
|
|||
|
|
import type { WorkplaneShape } from "@/types/sketchforge";
|
|||
|
|
|
|||
|
|
describe("Smart Placement & Anti-Collision (Akıllı Yerleşim ve Çakışma Önleme)", () => {
|
|||
|
|
it("places at origin when scene is empty", () => {
|
|||
|
|
const point = calculateSmartPlacementPoint([], { width: 20, depth: 20 });
|
|||
|
|
expect(point.x).toBe(0);
|
|||
|
|
expect(point.z).toBe(0);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
it("places cleanly beside an existing house centered at (0, 0)", () => {
|
|||
|
|
// Miniature house centered at (0, 0), width 80, depth 60
|
|||
|
|
const house: WorkplaneShape = {
|
|||
|
|
id: "house-1",
|
|||
|
|
name: "Minyatür Ev",
|
|||
|
|
kind: "box",
|
|||
|
|
color: "#f59e0b",
|
|||
|
|
x: 0,
|
|||
|
|
z: 0,
|
|||
|
|
width: 80,
|
|||
|
|
depth: 60,
|
|||
|
|
height: 50,
|
|||
|
|
elevation: 0,
|
|||
|
|
rotation: 0,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// New 20x20 cube added
|
|||
|
|
const point = calculateSmartPlacementPoint([house], { width: 20, depth: 20 });
|
|||
|
|
|
|||
|
|
// House extends from X = -40 to +40.
|
|||
|
|
// New cube should be placed to the right: 40 + 10 (half width) + 12 (margin) = 62
|
|||
|
|
expect(point.x).toBe(62);
|
|||
|
|
expect(point.z).toBe(0);
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
it("calculates top surface elevation to pop an interior cube onto the roof", () => {
|
|||
|
|
const houseBody: WorkplaneShape = {
|
|||
|
|
id: "house-body",
|
|||
|
|
name: "Ev Gövdesi",
|
|||
|
|
kind: "box",
|
|||
|
|
color: "#f59e0b",
|
|||
|
|
x: 0,
|
|||
|
|
z: 0,
|
|||
|
|
width: 60,
|
|||
|
|
depth: 60,
|
|||
|
|
height: 40,
|
|||
|
|
elevation: 0,
|
|||
|
|
rotation: 0,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
const roof: WorkplaneShape = {
|
|||
|
|
id: "house-roof",
|
|||
|
|
name: "Çatı",
|
|||
|
|
kind: "roof",
|
|||
|
|
color: "#dc2626",
|
|||
|
|
x: 0,
|
|||
|
|
z: 0,
|
|||
|
|
width: 64,
|
|||
|
|
depth: 64,
|
|||
|
|
height: 25,
|
|||
|
|
elevation: 40, // sits on top of body (40 + 25 = 65)
|
|||
|
|
rotation: 0,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// Cube swallowed inside at (0, 0, 0)
|
|||
|
|
const swallowedCube: WorkplaneShape = {
|
|||
|
|
id: "cube-inside",
|
|||
|
|
name: "Kutu",
|
|||
|
|
kind: "box",
|
|||
|
|
color: "#3b82f6",
|
|||
|
|
x: 0,
|
|||
|
|
z: 0,
|
|||
|
|
width: 20,
|
|||
|
|
depth: 20,
|
|||
|
|
height: 20,
|
|||
|
|
elevation: 0,
|
|||
|
|
rotation: 0,
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
const topElevation = calculateTopSurfaceElevation(swallowedCube, [houseBody, roof, swallowedCube]);
|
|||
|
|
|
|||
|
|
// Top of the roof is 40 + 25 = 65mm
|
|||
|
|
expect(topElevation).toBe(65);
|
|||
|
|
});
|
|||
|
|
});
|