feat: sesli CAD asistani, bellek optimizasyonlari ve akilli cozunurluk
CI / Typecheck and unit tests (push) Canceled after 0s
Build and Push Docker Images / build (push) Canceled after 0s

- SnapVoice Turkce sesli CAD ve komut konsolu (/denetle, /ram, /eko, /otomatik, /sessiz)
- 3B uzamsal sesli radar ve gorme engelli gelistirici geometri denetim motoru
- LibreDWG/DXF ikili sikistirma, font tembel yukleme ve RAM optimizasyonu
- Monitor cozunurlugune gore otomatik uyarlamali dinamik grafik modu
This commit is contained in:
Enes Yakıştır
2026-11-02 13:37:37 +03:00
parent c09407bcb3
commit e7b6db9db6
32 changed files with 5503 additions and 285 deletions
+92 -12
View File
@@ -56,7 +56,7 @@ import {
} from "@/lib/placementWorkplane";
import { regularPolygonFootprintScale } from "@/lib/regularPolygonFootprint";
import { projectThumbnailDimensions } from "@/lib/projectThumbnail";
import { canBeginShapeDrag, DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings, shapeDimensionLimit, workplaneSettingsFingerprint, workspaceHydrationSyncDecision } from "@/lib/workplaneSettings";
import { canBeginShapeDrag, computeEffectivePixelRatio, DEFAULT_SNAP_GRID, DEFAULT_WORKPLANE_WORKSPACE, normalizeSnapGrid, normalizeWorkspaceSettings, shapeDimensionLimit, workplaneSettingsFingerprint, workspaceHydrationSyncDecision } from "@/lib/workplaneSettings";
import { interiorWorkplaneGridCoordinates, workplaneThemePalette, WORKPLANE_LINE_ELEVATION, WORKPLANE_MAJOR_GRID_INTERVAL } from "@/lib/workplaneGrid";
import { cleanNearZero, cleanRotationDegrees, fallbackSolidColor, mirroredAxisCount, mirrorSign, preservesEdgeTreatmentSize, proportionalResizeScale, resizedImportedCoordinates, resizedImportedMeshPositions, resizedShapeSize, shapeDepth, shapeHasTaper, shapeOverallFootprintDimensions, shapeTaperDimensions, shapeTaperScaleAt, shapeWidth } from "@/lib/workplaneShapes";
import { sphereTessellation } from "@/lib/sphereTessellation";
@@ -137,15 +137,27 @@ const SHAPE_KINDS = new Set<ShapeAsset["kind"]>([
"mesh",
]);
const fontLoader = new FontLoader();
const textFonts: Record<string, Font> = {
Multilanguage: fontLoader.parse(helvetikerBoldFontJson as FontData),
Sans: fontLoader.parse(droidSansBoldFontJson as FontData),
Serif: fontLoader.parse(droidSerifBoldFontJson as FontData),
Script: fontLoader.parse(gentilisBoldFontJson as FontData),
Monospace: fontLoader.parse(droidMonoFontJson as FontData),
Rounded: fontLoader.parse(optimerBoldFontJson as FontData),
Stencil: fontLoader.parse(helvetikerBoldFontJson as FontData),
const rawViewportFontData: Record<string, unknown> = {
Multilanguage: helvetikerBoldFontJson,
Sans: droidSansBoldFontJson,
Serif: droidSerifBoldFontJson,
Script: gentilisBoldFontJson,
Monospace: droidMonoFontJson,
Rounded: optimerBoldFontJson,
Stencil: helvetikerBoldFontJson,
};
const parsedViewportFontsCache = new Map<string, Font>();
function getLazyViewportFont(name?: string): Font {
const fontName = name && name in rawViewportFontData ? name : "Multilanguage";
let font = parsedViewportFontsCache.get(fontName);
if (!font) {
const rawData = rawViewportFontData[fontName] ?? rawViewportFontData.Multilanguage;
font = fontLoader.parse(rawData as FontData);
parsedViewportFontsCache.set(fontName, font);
}
return font;
}
const importedGeometryCache = new WeakMap<
NonNullable<WorkplaneShape["importedMesh"]>,
{ geometry: THREE.BufferGeometry; edges: Map<number, THREE.EdgesGeometry> }
@@ -2897,14 +2909,57 @@ export function WorkplaneViewport({
useEffect(() => {
const openWorkspaceSettings = () => setSettingsOpen(true);
const handleRamCleanup = () => {
purgeUnusedSharedCaches();
const state = threeRef.current;
if (state) {
state.renderer.renderLists?.dispose?.();
state.resize();
}
};
const handleDpiChange = () => {
const state = threeRef.current;
if (state && typeof window !== "undefined") {
const nextDpr = computeEffectivePixelRatio(workspaceRef.current, shapesRef.current.length, window.devicePixelRatio);
if (state.renderer.getPixelRatio() !== nextDpr) {
state.renderer.setPixelRatio(nextDpr);
state.resize();
}
}
};
let mediaQuery: MediaQueryList | null = null;
try {
if (typeof window !== "undefined" && window.matchMedia) {
mediaQuery = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
mediaQuery.addEventListener("change", handleDpiChange);
}
} catch {
// Ignore in unsupported environments
}
window.addEventListener("sketchforge:open-workspace-settings", openWorkspaceSettings);
return () => window.removeEventListener("sketchforge:open-workspace-settings", openWorkspaceSettings);
window.addEventListener("sketchforge:ram-cleanup", handleRamCleanup);
return () => {
window.removeEventListener("sketchforge:open-workspace-settings", openWorkspaceSettings);
window.removeEventListener("sketchforge:ram-cleanup", handleRamCleanup);
try {
mediaQuery?.removeEventListener("change", handleDpiChange);
} catch {
// Ignore
}
};
}, []);
useEffect(() => {
shapesRef.current = shapes;
const sceneExtent = sceneExtentForShapes(shapes);
applySceneCameraRange(threeRef.current, sceneExtent);
if (threeRef.current) {
const targetDpr = computeEffectivePixelRatio(workspaceRef.current, shapes.length);
if (threeRef.current.renderer.getPixelRatio() !== targetDpr) {
threeRef.current.renderer.setPixelRatio(targetDpr);
threeRef.current.resize();
}
}
// Proje açıldığında veya yeni bir model içe aktarıldığında (şekil kimlikleri
// değiştiğinde) kamera modele sığmıyorsa otomatik olarak sığdır. Sürükleme
// ve boyutlandırma sırasında kimlikler değişmediği için görünüm bozulmaz.
@@ -6867,7 +6922,13 @@ function rebuildWorkplane(
const palette = workplaneThemePalette(theme, workspace.background, workspace.gridColor);
disposeChildren(state.workplaneLayer);
state.scene.background = new THREE.Color(palette.sceneBackground);
state.renderer.shadowMap.enabled = workspace.showShadows;
const targetPixelRatio = computeEffectivePixelRatio(workspace, state.shapeLayer.children.length);
if (state.renderer.getPixelRatio() !== targetPixelRatio) {
state.renderer.setPixelRatio(targetPixelRatio);
state.resize();
}
const isEco = workspace.resolutionMode === "eco" || workspace.lowMemoryMode;
state.renderer.shadowMap.enabled = workspace.showShadows && !isEco;
state.controls.zoomSpeed = 0.28 + workspace.zoomSpeed * 0.09;
const activeIsBase = placementWorkplaneIsBase(placementWorkplane);
@@ -8564,6 +8625,25 @@ function trimSharedShapeMaterialCache() {
}
}
function purgeUnusedSharedCaches() {
for (const [key, entry] of sharedShapeGeometryCache.entries()) {
if (entry.users <= 0) {
sharedShapeGeometryCache.delete(key);
disposeSharedShapeGeometry(entry.geometry);
}
}
for (const [key, entry] of sharedShapeMaterialCache.entries()) {
if (entry.users <= 0) {
sharedShapeMaterialCache.delete(key);
entry.material.dispose();
}
}
for (const [, mat] of sharedLineMaterialCache.entries()) {
mat.dispose();
}
sharedLineMaterialCache.clear();
}
function retainSharedShapeMaterials(mesh: THREE.Mesh, materials: THREE.Material | THREE.Material[]) {
const retained: string[] = [];
(Array.isArray(materials) ? materials : [materials]).forEach((material) => {
@@ -9068,7 +9148,7 @@ function addTextShape(group: THREE.Group, material: THREE.MeshStandardMaterial,
const bevel = clamp(shape.bevel ?? 0, 0, 8);
const fontName = shape.font ?? "Multilanguage";
const next = new TextGeometry(text, {
font: textFonts[fontName] ?? textFonts.Multilanguage,
font: getLazyViewportFont(fontName),
size: 20,
depth: shape.height,
curveSegments: fontName === "Stencil" ? 1 : 8,