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: publish v0.9.0 modeling update
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
CAD_MODIFIER_MAX_SHARP_ANGLE,
|
||||
CAD_MODIFIER_MAX_PREPARE_TIMEOUT_MS,
|
||||
CAD_MODIFIER_REQUEST_TIMEOUT_MS,
|
||||
CAD_MODIFIER_RUNTIME_BASE,
|
||||
cadModifierPrepareTimeoutMs,
|
||||
cadModifierTopologyEdgeIsSelectable,
|
||||
cadTransformRequiresGeneralTransform,
|
||||
cadModifierTimeoutMessage,
|
||||
@@ -23,10 +25,16 @@ describe("CAD modifier runtime state", () => {
|
||||
expect(edgeModifierSelectionStatus(true, 2, 12)).toBe("2 of 12 sharp edges selected");
|
||||
});
|
||||
|
||||
it("sets a bounded preparation wait and an actionable compatibility error", () => {
|
||||
it("keeps exact CAD preparation short and gives imported meshes a bounded triangle-aware budget", () => {
|
||||
expect(CAD_MODIFIER_REQUEST_TIMEOUT_MS).toBeGreaterThanOrEqual(20_000);
|
||||
expect(CAD_MODIFIER_REQUEST_TIMEOUT_MS).toBeLessThanOrEqual(60_000);
|
||||
expect(cadModifierTimeoutMessage("prepare")).toContain("Firefox 121+");
|
||||
expect(cadModifierPrepareTimeoutMs(0)).toBe(CAD_MODIFIER_REQUEST_TIMEOUT_MS);
|
||||
expect(cadModifierPrepareTimeoutMs(Number.NaN)).toBe(CAD_MODIFIER_REQUEST_TIMEOUT_MS);
|
||||
expect(cadModifierPrepareTimeoutMs(10_000)).toBe(60_000);
|
||||
expect(cadModifierPrepareTimeoutMs(100_000)).toBe(120_000);
|
||||
expect(cadModifierPrepareTimeoutMs(180_000)).toBe(CAD_MODIFIER_MAX_PREPARE_TIMEOUT_MS);
|
||||
expect(cadModifierTimeoutMessage("prepare")).toContain("lower-detail STL");
|
||||
expect(cadModifierTimeoutMessage("prepare")).not.toContain("Firefox");
|
||||
});
|
||||
|
||||
it("does not expose thresholds above the worker's folded edge-angle range", () => {
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createMoveDimensionOverlay, formatMoveDimension } from "@/lib/moveDimensionLines";
|
||||
|
||||
describe("move dimension lines", () => {
|
||||
const project = ({ x, z }: { x: number; y: number; z: number }) => ({ x: 400 + x * 4, y: 300 + z * 4 });
|
||||
|
||||
it("creates signed X and Z measurements from the common drag origin", () => {
|
||||
const overlay = createMoveDimensionOverlay({
|
||||
originX: 10,
|
||||
originZ: -5,
|
||||
planeY: 0,
|
||||
deltaX: -14,
|
||||
deltaZ: -17,
|
||||
accuracy: 2,
|
||||
width: 800,
|
||||
height: 600,
|
||||
project,
|
||||
});
|
||||
|
||||
expect(overlay?.lines.map((line) => [line.axis, line.label])).toEqual([
|
||||
["x", "-14.00"],
|
||||
["z", "-17.00"],
|
||||
]);
|
||||
expect(overlay?.lines[0]).toMatchObject({ x1: 452, y1: 280, x2: 384, y2: 280 });
|
||||
expect(overlay?.lines[1]).toMatchObject({ x1: 440, y1: 292, x2: 440, y2: 212 });
|
||||
expect(overlay?.guides).toEqual([
|
||||
{ axis: "x", x1: 384, y1: 280, x2: 384, y2: 212 },
|
||||
{ axis: "z", x1: 440, y1: 212, x2: 384, y2: 212 },
|
||||
]);
|
||||
});
|
||||
|
||||
it("uses the workspace accuracy and suppresses near-zero movement", () => {
|
||||
expect(formatMoveDimension(-0.0001, 2)).toBe("0.00");
|
||||
expect(createMoveDimensionOverlay({
|
||||
originX: 0,
|
||||
originZ: 0,
|
||||
planeY: 0,
|
||||
deltaX: 0.004,
|
||||
deltaZ: -0.004,
|
||||
accuracy: 2,
|
||||
width: 800,
|
||||
height: 600,
|
||||
project,
|
||||
})).toBeNull();
|
||||
});
|
||||
|
||||
it("shows only the axis that actually moved", () => {
|
||||
const overlay = createMoveDimensionOverlay({
|
||||
originX: 0,
|
||||
originZ: 0,
|
||||
planeY: 0,
|
||||
deltaX: 12.5,
|
||||
deltaZ: 0,
|
||||
accuracy: 1,
|
||||
width: 800,
|
||||
height: 600,
|
||||
project,
|
||||
});
|
||||
|
||||
expect(overlay?.lines).toHaveLength(1);
|
||||
expect(overlay?.lines[0]).toMatchObject({ axis: "x", label: "12.5" });
|
||||
});
|
||||
|
||||
it("keeps a single-axis label on a stable side when projection noise changes sign", () => {
|
||||
const makeOverlay = (noise: number) => createMoveDimensionOverlay({
|
||||
originX: 0,
|
||||
originZ: 0,
|
||||
planeY: 0,
|
||||
deltaX: 12.5,
|
||||
deltaZ: 0,
|
||||
accuracy: 1,
|
||||
width: 800,
|
||||
height: 600,
|
||||
project: ({ x, z }) => ({
|
||||
x: 400 + x * 4,
|
||||
y: 300 + z * 4 + (x === 0 && z === 0 ? noise : 0),
|
||||
}),
|
||||
});
|
||||
|
||||
const above = makeOverlay(0.001)?.lines[0];
|
||||
const below = makeOverlay(-0.001)?.lines[0];
|
||||
expect(above?.labelY).toBeGreaterThan(300);
|
||||
expect(below?.labelY).toBeGreaterThan(300);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,110 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
horizontalPlacementWorkplane,
|
||||
placementPatchForNewShape,
|
||||
placementWorkplaneCoordinates,
|
||||
placementWorkplaneFromSurface,
|
||||
placementWorkplanePoint,
|
||||
snapPlacementWorkplaneOrigin,
|
||||
translationToWorkplane,
|
||||
} from "@/lib/placementWorkplane";
|
||||
|
||||
describe("placement workplanes", () => {
|
||||
it("round-trips coordinates on an oriented surface", () => {
|
||||
const plane = placementWorkplaneFromSurface(
|
||||
{ x: 10, y: 5, z: -4 },
|
||||
{ x: 0, y: 0, z: 1 },
|
||||
{ x: 1, y: 0, z: 0 },
|
||||
);
|
||||
const world = placementWorkplanePoint(plane, 12, -7);
|
||||
const local = placementWorkplaneCoordinates(plane, world);
|
||||
|
||||
expect(local.x).toBeCloseTo(12);
|
||||
expect(local.y).toBeCloseTo(0);
|
||||
expect(local.z).toBeCloseTo(-7);
|
||||
});
|
||||
|
||||
it("places a new shape flush with a vertical face", () => {
|
||||
const plane = placementWorkplaneFromSurface(
|
||||
{ x: 20, y: 10, z: 0 },
|
||||
{ x: 1, y: 0, z: 0 },
|
||||
{ x: 0, y: 1, z: 0 },
|
||||
);
|
||||
const patch = placementPatchForNewShape({ height: 8 }, plane);
|
||||
|
||||
expect(patch.x).toBeCloseTo(24);
|
||||
expect(patch.elevation).toBeCloseTo(6);
|
||||
expect(Math.abs(patch.rotationZ ?? 0)).toBeCloseTo(90);
|
||||
});
|
||||
|
||||
it("reverses which side receives newly placed shapes", () => {
|
||||
const normal = { x: 0, y: 1, z: 0 };
|
||||
const regular = placementWorkplaneFromSurface({ x: 0, y: 4, z: 0 }, normal, { x: 1, y: 0, z: 0 });
|
||||
const reversed = placementWorkplaneFromSurface({ x: 0, y: 4, z: 0 }, normal, { x: 1, y: 0, z: 0 }, true);
|
||||
|
||||
expect(placementPatchForNewShape({ height: 10 }, regular).elevation).toBe(4);
|
||||
expect(placementPatchForNewShape({ height: 10 }, reversed).elevation).toBe(-6);
|
||||
});
|
||||
|
||||
it("snaps a horizontal surface origin to the base grid", () => {
|
||||
const plane = placementWorkplaneFromSurface(
|
||||
{ x: 7.3, y: 12, z: -4.6 },
|
||||
{ x: 0, y: 1, z: 0 },
|
||||
{ x: 1, y: 0, z: 0 },
|
||||
);
|
||||
const snapped = snapPlacementWorkplaneOrigin(plane, 2);
|
||||
|
||||
expect(snapped.origin).toEqual({ x: 8, y: 12, z: -4 });
|
||||
});
|
||||
|
||||
it("snaps both in-plane coordinates without moving a vertical surface", () => {
|
||||
const plane = placementWorkplaneFromSurface(
|
||||
{ x: 20, y: 7.3, z: -4.6 },
|
||||
{ x: 1, y: 0, z: 0 },
|
||||
{ x: 0, y: 1, z: 0 },
|
||||
);
|
||||
const snapped = snapPlacementWorkplaneOrigin(plane, 2);
|
||||
|
||||
expect(snapped.origin).toEqual({ x: 20, y: 8, z: -4 });
|
||||
expect(snapped.origin.x).toBe(plane.origin.x);
|
||||
});
|
||||
|
||||
it("keeps an angled surface coplanar while snapping from the base origin", () => {
|
||||
const plane = placementWorkplaneFromSurface(
|
||||
{ x: 7.2, y: 5.1, z: -3.8 },
|
||||
{ x: 1, y: 1, z: 0 },
|
||||
{ x: 0, y: 0, z: 1 },
|
||||
);
|
||||
const snapped = snapPlacementWorkplaneOrigin(plane, 2.5);
|
||||
const snappedCoordinates = placementWorkplaneCoordinates(plane, snapped.origin);
|
||||
const planeOffset = (
|
||||
plane.origin.x * plane.normal.x
|
||||
+ plane.origin.y * plane.normal.y
|
||||
+ plane.origin.z * plane.normal.z
|
||||
);
|
||||
const baseGridAnchor = {
|
||||
...plane,
|
||||
origin: {
|
||||
x: plane.normal.x * planeOffset,
|
||||
y: plane.normal.y * planeOffset,
|
||||
z: plane.normal.z * planeOffset,
|
||||
},
|
||||
};
|
||||
const gridCoordinates = placementWorkplaneCoordinates(baseGridAnchor, snapped.origin);
|
||||
|
||||
expect(snappedCoordinates.y).toBeCloseTo(0);
|
||||
expect(gridCoordinates.x / 2.5).toBeCloseTo(Math.round(gridCoordinates.x / 2.5));
|
||||
expect(gridCoordinates.z / 2.5).toBeCloseTo(Math.round(gridCoordinates.z / 2.5));
|
||||
});
|
||||
|
||||
it("computes the exact translation required to drop geometry onto a plane", () => {
|
||||
const plane = horizontalPlacementWorkplane(3);
|
||||
const translation = translationToWorkplane(plane, [
|
||||
{ x: -2, y: 8, z: -2 },
|
||||
{ x: 2, y: 8, z: 2 },
|
||||
{ x: 0, y: 12, z: 0 },
|
||||
]);
|
||||
|
||||
expect(translation).toEqual({ x: 0, y: -5, z: 0 });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { regularPolygonFootprintScale } from "@/lib/regularPolygonFootprint";
|
||||
|
||||
function scaledFootprintBounds(width: number, depth: number, sides: number) {
|
||||
const count = Math.max(3, Math.round(sides));
|
||||
const scale = regularPolygonFootprintScale(width, depth, count);
|
||||
const points = Array.from({ length: count }, (_, index) => {
|
||||
const angle = (index / count) * Math.PI * 2;
|
||||
return {
|
||||
x: Math.sin(angle) * scale.x + scale.offsetX,
|
||||
z: Math.cos(angle) * scale.z + scale.offsetZ,
|
||||
};
|
||||
});
|
||||
|
||||
const xValues = points.map((point) => point.x);
|
||||
const zValues = points.map((point) => point.z);
|
||||
return {
|
||||
width: Math.max(...xValues) - Math.min(...xValues),
|
||||
depth: Math.max(...zValues) - Math.min(...zValues),
|
||||
centerX: (Math.max(...xValues) + Math.min(...xValues)) / 2,
|
||||
centerZ: (Math.max(...zValues) + Math.min(...zValues)) / 2,
|
||||
};
|
||||
}
|
||||
|
||||
describe("regular polygon footprint scaling", () => {
|
||||
it.each([3, 5, 6, 7, 12])(
|
||||
"fits a %i-sided pyramid base to the requested dimensions",
|
||||
(sides) => {
|
||||
const bounds = scaledFootprintBounds(20, 30, sides);
|
||||
expect(bounds.width).toBeCloseTo(20, 8);
|
||||
expect(bounds.depth).toBeCloseTo(30, 8);
|
||||
expect(bounds.centerX).toBeCloseTo(0, 8);
|
||||
expect(bounds.centerZ).toBeCloseTo(0, 8);
|
||||
},
|
||||
);
|
||||
|
||||
it("supports fractional inputs by using the same rounded side count as the geometry", () => {
|
||||
const bounds = scaledFootprintBounds(18, 24, 4.6);
|
||||
expect(bounds.width).toBeCloseTo(18, 8);
|
||||
expect(bounds.depth).toBeCloseTo(24, 8);
|
||||
expect(bounds.centerX).toBeCloseTo(0, 8);
|
||||
expect(bounds.centerZ).toBeCloseTo(0, 8);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { placementWorkplaneFromSurface } from "@/lib/placementWorkplane";
|
||||
import { placeSketchExtrusion } from "@/lib/sketchPlacement";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
function extrusion(overrides: Partial<WorkplaneShape> = {}): WorkplaneShape {
|
||||
return {
|
||||
id: "sketch-extrusion-1",
|
||||
name: "Sketch extrusion",
|
||||
kind: "mesh",
|
||||
color: "#d41721",
|
||||
x: 3,
|
||||
z: -2,
|
||||
elevation: 0,
|
||||
size: 12,
|
||||
width: 12,
|
||||
depth: 8,
|
||||
height: 10,
|
||||
rotation: 0,
|
||||
rotationX: 0,
|
||||
rotationZ: 0,
|
||||
importedMesh: {
|
||||
positions: [0, 0, 0, 1, 0, 0, 0, 1, 0],
|
||||
baseWidth: 12,
|
||||
baseDepth: 8,
|
||||
baseHeight: 10,
|
||||
triangleCount: 1,
|
||||
sourceFormat: "json",
|
||||
},
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("sketch extrusion placement", () => {
|
||||
it("places a new extrusion outward from a vertical face", () => {
|
||||
const workplane = placementWorkplaneFromSurface(
|
||||
{ x: 20, y: 7, z: 4 },
|
||||
{ x: 1, y: 0, z: 0 },
|
||||
{ x: 0, y: 1, z: 0 },
|
||||
);
|
||||
const placed = placeSketchExtrusion(extrusion(), workplane);
|
||||
|
||||
expect(placed.x).toBeCloseTo(25);
|
||||
expect(placed.elevation).toBeCloseTo(5);
|
||||
expect(placed.rotationZ).toBeCloseTo(270);
|
||||
});
|
||||
|
||||
it("keeps an edited extrusion's existing world transform", () => {
|
||||
const existing = extrusion({
|
||||
x: 28,
|
||||
z: 14,
|
||||
elevation: 9,
|
||||
rotation: 18,
|
||||
rotationX: 32,
|
||||
rotationZ: -21,
|
||||
});
|
||||
const regenerated = extrusion({ width: 20 });
|
||||
const placed = placeSketchExtrusion(
|
||||
regenerated,
|
||||
placementWorkplaneFromSurface(
|
||||
{ x: 0, y: 0, z: 0 },
|
||||
{ x: 0, y: 1, z: 0 },
|
||||
{ x: 1, y: 0, z: 0 },
|
||||
),
|
||||
existing,
|
||||
);
|
||||
|
||||
expect(placed).toEqual(expect.objectContaining({
|
||||
x: 28,
|
||||
z: 14,
|
||||
elevation: 9,
|
||||
rotation: 18,
|
||||
rotationX: 32,
|
||||
rotationZ: 339,
|
||||
width: 20,
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { strFromU8, strToU8, unzipSync, zipSync } from "fflate";
|
||||
import { editorHistoryEntry } from "@/lib/editorHistory";
|
||||
import { placementWorkplaneFromSurface } from "@/lib/placementWorkplane";
|
||||
import { projectAssetFromBytes } from "@/lib/projectAssets";
|
||||
import { canonicalizeShape } from "@/lib/workplaneShapes";
|
||||
import {
|
||||
@@ -125,6 +126,28 @@ describe("SketchForge .skf project packages", () => {
|
||||
expect(document.assets.filter((entry) => entry.kind === "derived-mesh")).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("preserves an oriented placement workplane", async () => {
|
||||
const placementWorkplane = placementWorkplaneFromSurface(
|
||||
{ x: 12, y: 8, z: -3 },
|
||||
{ x: 1, y: 0, z: 0 },
|
||||
{ x: 0, y: 1, z: 0 },
|
||||
);
|
||||
const sketchPlacementWorkplane = placementWorkplaneFromSurface(
|
||||
{ x: -4, y: 6, z: 9 },
|
||||
{ x: 0, y: 0, z: -1 },
|
||||
{ x: 1, y: 0, z: 0 },
|
||||
);
|
||||
const exported = await exportSkfProject(input([shape("box")], {
|
||||
placementElevation: 0,
|
||||
placementWorkplane,
|
||||
sketchPlacementWorkplane,
|
||||
}));
|
||||
const restored = await importSkfProject(exported);
|
||||
|
||||
expect(restored.placementWorkplane).toEqual(placementWorkplane);
|
||||
expect(restored.sketchPlacementWorkplane).toEqual(sketchPlacementWorkplane);
|
||||
});
|
||||
|
||||
it("preserves editable revolve sketch settings and generated geometry", async () => {
|
||||
const revolve = shape("mesh", "revolve-sketch", {
|
||||
name: "Sketch revolve",
|
||||
|
||||
@@ -57,7 +57,7 @@ describe("workplane settings helpers", () => {
|
||||
expect(normalizeWorkspaceSettings({ accuracy: 9 }, fallback).accuracy).toBe(fallback.accuracy);
|
||||
expect(normalizeWorkspaceSettings({ historyLimit: 73 }).historyLimit).toBe(73);
|
||||
expect(normalizeWorkspaceSettings({ historyLimit: 9000 }).historyLimit).toBe(5000);
|
||||
expect(normalizeWorkspaceSettings({ historyLimit: "invalid" }).historyLimit).toBe("unlimited");
|
||||
expect(normalizeWorkspaceSettings({ historyLimit: "invalid" }).historyLimit).toBe(100);
|
||||
expect(normalizeWorkspaceSettings({ gridColor: "not-a-color" }).gridColor).toBe(DEFAULT_WORKPLANE_WORKSPACE.gridColor);
|
||||
});
|
||||
|
||||
|
||||
@@ -150,6 +150,17 @@ describe("workplane shape helpers", () => {
|
||||
expect(grouped.groupedShapes?.[0].color).toBe("#222222");
|
||||
});
|
||||
|
||||
it("preserves the selected solid color while toggling hole mode", () => {
|
||||
const colored = shape({ color: "#35a86b" });
|
||||
const hole = withHoleMode(colored, true);
|
||||
const solid = withHoleMode(hole, false);
|
||||
|
||||
expect(hole.hole).toBe(true);
|
||||
expect(hole.color).toBe("#35a86b");
|
||||
expect(solid.hole).toBe(false);
|
||||
expect(solid.color).toBe("#35a86b");
|
||||
});
|
||||
|
||||
it("can resize the body while preserving fillet and chamfer boundary distances", () => {
|
||||
const modified = shape({
|
||||
kind: "mesh",
|
||||
|
||||
Reference in New Issue
Block a user