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
Add workspace editor tools
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
export function normalizeDegrees(value: number) {
|
||||
return ((value % 360) + 360) % 360;
|
||||
}
|
||||
|
||||
export function cleanRotationDegrees(value: number, precision = 1) {
|
||||
if (!Number.isFinite(value)) {
|
||||
return 0;
|
||||
}
|
||||
const normalized = normalizeDegrees(value);
|
||||
const rounded = Number(normalized.toFixed(precision));
|
||||
const zeroThreshold = precision <= 1 ? 0.5 : 0.05;
|
||||
if (rounded < zeroThreshold || rounded >= 360 - zeroThreshold || Object.is(rounded, -0)) {
|
||||
return 0;
|
||||
}
|
||||
return rounded;
|
||||
}
|
||||
|
||||
export function cleanNearZero(value: number, epsilon = 0.005) {
|
||||
return Math.abs(value) < epsilon ? 0 : value;
|
||||
}
|
||||
|
||||
export function shapeWidth(shape: WorkplaneShape) {
|
||||
return shape.width ?? shape.size;
|
||||
}
|
||||
|
||||
export function shapeDepth(shape: WorkplaneShape) {
|
||||
return shape.depth ?? shape.size;
|
||||
}
|
||||
|
||||
export function resizedShapeSize(width: number, depth: number) {
|
||||
return Math.max(width, depth);
|
||||
}
|
||||
|
||||
export function proportionalResizeScale(startWidth: number, startDepth: number, nextWidth: number, nextDepth: number) {
|
||||
const widthScale = nextWidth / Math.max(0.001, startWidth);
|
||||
const depthScale = nextDepth / Math.max(0.001, startDepth);
|
||||
if (!Number.isFinite(widthScale) || !Number.isFinite(depthScale)) {
|
||||
return 1;
|
||||
}
|
||||
return Math.abs(widthScale - 1) >= Math.abs(depthScale - 1) ? widthScale : depthScale;
|
||||
}
|
||||
|
||||
export function fallbackSolidColor(shape: WorkplaneShape) {
|
||||
if (shape.kind === "cylinder") return "#d97813";
|
||||
if (shape.kind === "sphere") return "#0098c7";
|
||||
if (shape.kind === "cone") return "#6e2786";
|
||||
if (shape.kind === "pyramid") return "#f2cf10";
|
||||
return "#d41721";
|
||||
}
|
||||
|
||||
export function mirrorSign(value?: boolean) {
|
||||
return value ? -1 : 1;
|
||||
}
|
||||
|
||||
export function mirroredAxisCount(shape: WorkplaneShape) {
|
||||
return [shape.mirrorX, shape.mirrorY, shape.mirrorZ].filter(Boolean).length;
|
||||
}
|
||||
|
||||
export function canonicalizeShape(shape: WorkplaneShape): WorkplaneShape {
|
||||
const next: WorkplaneShape = {
|
||||
...shape,
|
||||
rotation: cleanRotationDegrees(shape.rotation ?? 0),
|
||||
rotationX: cleanRotationDegrees(shape.rotationX ?? 0),
|
||||
rotationZ: cleanRotationDegrees(shape.rotationZ ?? 0),
|
||||
mirrorX: shape.mirrorX || undefined,
|
||||
mirrorY: shape.mirrorY || undefined,
|
||||
mirrorZ: shape.mirrorZ || undefined,
|
||||
};
|
||||
if (shape.groupedShapes) {
|
||||
next.groupedShapes = shape.groupedShapes.map(canonicalizeShape);
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
export function workplaneShapesEqual(a: WorkplaneShape, b: WorkplaneShape) {
|
||||
return (
|
||||
a.id === b.id &&
|
||||
a.name === b.name &&
|
||||
a.kind === b.kind &&
|
||||
a.color === b.color &&
|
||||
a.hole === b.hole &&
|
||||
a.x === b.x &&
|
||||
a.z === b.z &&
|
||||
a.elevation === b.elevation &&
|
||||
a.size === b.size &&
|
||||
a.width === b.width &&
|
||||
a.depth === b.depth &&
|
||||
a.height === b.height &&
|
||||
a.rotation === b.rotation &&
|
||||
a.rotationX === b.rotationX &&
|
||||
a.rotationZ === b.rotationZ &&
|
||||
a.mirrorX === b.mirrorX &&
|
||||
a.mirrorY === b.mirrorY &&
|
||||
a.mirrorZ === b.mirrorZ &&
|
||||
a.radius === b.radius &&
|
||||
a.steps === b.steps &&
|
||||
a.sides === b.sides &&
|
||||
a.bevel === b.bevel &&
|
||||
a.segments === b.segments &&
|
||||
a.topRadius === b.topRadius &&
|
||||
a.baseRadius === b.baseRadius &&
|
||||
a.text === b.text &&
|
||||
a.font === b.font &&
|
||||
a.importedMesh === b.importedMesh &&
|
||||
a.imagePlate === b.imagePlate &&
|
||||
a.groupedShapes === b.groupedShapes &&
|
||||
a.groupedBaseWidth === b.groupedBaseWidth &&
|
||||
a.groupedBaseDepth === b.groupedBaseDepth &&
|
||||
a.groupedBaseHeight === b.groupedBaseHeight &&
|
||||
a.locked === b.locked &&
|
||||
a.hidden === b.hidden
|
||||
);
|
||||
}
|
||||
|
||||
export function serializeShapesForSync(shapes: WorkplaneShape[]) {
|
||||
return JSON.stringify(shapes.map(canonicalizeShape));
|
||||
}
|
||||
Reference in New Issue
Block a user