feat: SketchUp klasik arayuzu, kisayollar, VCB olcu kutusu ve YakNet 3B bilesen havuzu
Build and Push Docker Images / build (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s

This commit is contained in:
Enes Yakıştır
2026-11-10 19:13:46 +03:00
parent e7b6db9db6
commit dc09b61779
16 changed files with 6655 additions and 488 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -351,8 +351,16 @@ export function GlobalAccessibilityToolbar({
setDrawerOpen(false);
}
};
const onOpenA11yDrawer = () => {
setDrawerOpen(true);
setPaletteOpen(false);
};
window.addEventListener("keydown", onKeyDown);
return () => window.removeEventListener("keydown", onKeyDown);
window.addEventListener("snapcad:open-a11y-drawer", onOpenA11yDrawer);
return () => {
window.removeEventListener("keydown", onKeyDown);
window.removeEventListener("snapcad:open-a11y-drawer", onOpenA11yDrawer);
};
}, []);
const update = (patch: Partial<SnapCadA11ySettings>, msg?: string) => {
@@ -1,7 +1,8 @@
"use client";
import { Box, Compass, Crosshair, Eye, Grid3X3, Layers, Maximize2, MoveRight, Ruler } from "lucide-react";
import { useCallback, useEffect, useRef, useState, type ChangeEvent, type KeyboardEvent } from "react";
import { Box, Compass, Crosshair, Eye, Grid3X3, MoveRight, Ruler } from "lucide-react";
import { useEffect, useRef, useState, type ChangeEvent, type KeyboardEvent } from "react";
import { SKETCHUP_TOOLS, type SketchUpToolId } from "@/lib/sketchupInterface";
import type { GridSize } from "@/types/sketchforge";
export type DirectModelingToolMode = "select" | "push-pull" | "face-sketch" | "measure";
@@ -24,6 +25,9 @@ export interface PrecisionBarData {
interface EnterprisePrecisionBarProps {
data: PrecisionBarData;
activeTool: DirectModelingToolMode;
activeSketchUpTool?: SketchUpToolId;
activeHintText?: string;
vcbDisplayText?: string;
onToolChange?: (tool: DirectModelingToolMode) => void;
snapGrid: GridSize;
onSnapGridChange?: (size: GridSize) => void;
@@ -32,6 +36,7 @@ interface EnterprisePrecisionBarProps {
onResetView?: () => void;
onSetCameraView?: (face: "top" | "front" | "right" | "isometric") => void;
onCommitValue?: (value: number) => void;
onCommitVcbRaw?: (raw: string) => void;
unitLabel?: string;
className?: string;
axisLock?: "x" | "z" | null;
@@ -42,31 +47,38 @@ const SNAP_OPTIONS: GridSize[] = ["0.1 mm", "0.25 mm", "0.5 mm", "1.0 mm", "2.0
export function EnterprisePrecisionBar({
data,
activeTool,
activeSketchUpTool = "select",
activeHintText,
vcbDisplayText,
onToolChange,
snapGrid,
onSnapGridChange,
isOrthographic = false,
onToggleProjection,
onResetView,
onSetCameraView,
onCommitValue,
onCommitVcbRaw,
unitLabel = "mm",
className = "",
axisLock = null,
}: EnterprisePrecisionBarProps) {
const [inputValue, setInputValue] = useState<string>("");
const inputRef = useRef<HTMLInputElement | null>(null);
const toolMeta = SKETCHUP_TOOLS[activeSketchUpTool] ?? SKETCHUP_TOOLS.select;
const resolvedLabel = data.valueLabel || toolMeta.vcbLabel || "Ölçü";
const resolvedHint = activeHintText || toolMeta.hint;
// Sync input value with live distance during dragging if user hasn't focused it
// Sync input value with live distance/dimensions during dragging if user hasn't focused it
useEffect(() => {
if (data.currentValue !== undefined && data.currentValue !== null) {
if (document.activeElement !== inputRef.current) {
setInputValue(data.currentValue.toFixed(2));
}
} else if (!data.isDragging && document.activeElement !== inputRef.current) {
if (document.activeElement === inputRef.current) return;
if (vcbDisplayText) {
setInputValue(vcbDisplayText);
} else if (data.currentValue !== undefined && data.currentValue !== null) {
setInputValue(data.currentValue.toFixed(2));
} else if (!data.isDragging) {
setInputValue("");
}
}, [data.currentValue, data.isDragging]);
}, [data.currentValue, data.isDragging, vcbDisplayText]);
const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value);
@@ -75,14 +87,27 @@ export function EnterprisePrecisionBar({
const handleInputKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter") {
e.preventDefault();
const num = parseFloat(inputValue.replace(",", "."));
const trimmed = inputValue.trim();
if (!trimmed) return;
if (onCommitVcbRaw) {
onCommitVcbRaw(trimmed);
inputRef.current?.blur();
return;
}
const num = parseFloat(trimmed.replace(",", "."));
if (!Number.isNaN(num)) {
onCommitValue?.(num);
inputRef.current?.blur();
}
} else if (e.key === "Escape") {
inputRef.current?.blur();
setInputValue(data.currentValue !== undefined && data.currentValue !== null ? data.currentValue.toFixed(2) : "");
setInputValue(
vcbDisplayText
? vcbDisplayText
: data.currentValue !== undefined && data.currentValue !== null
? data.currentValue.toFixed(2)
: "",
);
}
};
@@ -90,9 +115,9 @@ export function EnterprisePrecisionBar({
<footer
className={`enterprise-precision-bar ${className}`}
role="region"
aria-label="Hassas Çizim ve Durum Çubuğu (Precision HUD)"
aria-label="Hassas Çizim ve Ölçü Kutusu (Measurements VCB)"
>
{/* 1. Sol Kısım: Araç Modu ve Yüzey Rozeti */}
{/* 1. Sol Kısım: Araç Modu, Canlı Eğitmen İpucu ve Yüzey Rozeti */}
<div className="precision-group tools-group">
<button
type="button"
@@ -102,7 +127,7 @@ export function EnterprisePrecisionBar({
aria-pressed={activeTool === "select"}
>
<Box size={14} className="icon" aria-hidden="true" />
<span>3B Katı CAD</span>
<span>3B Katı</span>
</button>
<button
@@ -113,11 +138,21 @@ export function EnterprisePrecisionBar({
aria-pressed={activeTool === "push-pull"}
>
<MoveRight size={14} className="icon" aria-hidden="true" />
<span>İt / Çek (Push/Pull)</span>
<span>İt / Çek</span>
</button>
{resolvedHint ? (
<span
className="hidden xl:inline-block truncate max-w-[340px] text-[11px] text-slate-400"
title={resolvedHint}
>
<strong className="text-sky-400 mr-1">{toolMeta.name}:</strong>
{resolvedHint}
</span>
) : null}
{data.activeFaceInfo ? (
<span className="face-indicator-badge" title="Algılanan Yüzey Normali">
<span className="face-indicator-badge hidden 2xl:inline-flex" title="Algılanan Yüzey Normali">
<span className="dot" />
<span className="name">{data.activeFaceInfo.shapeName}</span>
<span className="normal font-mono">
@@ -133,13 +168,13 @@ export function EnterprisePrecisionBar({
<div className="live-coords-hud" title="İmleç Dünyası Koordinatları">
<Crosshair size={13} className="text-sky-400" aria-hidden="true" />
<span className="coord-item">
<strong className="text-rose-400">X:</strong> {data.cursorX.toFixed(2)}
<strong className="text-rose-400">X:</strong> {data.cursorX.toFixed(1)}
</span>
<span className="coord-item">
<strong className="text-emerald-400">Y:</strong> {data.cursorY.toFixed(2)}
<strong className="text-emerald-400">Y:</strong> {data.cursorY.toFixed(1)}
</span>
<span className="coord-item">
<strong className="text-sky-400">Z:</strong> {data.cursorZ.toFixed(2)} {unitLabel}
<strong className="text-sky-400">Z:</strong> {data.cursorZ.toFixed(1)} {unitLabel}
</span>
{axisLock ? (
<span
@@ -161,23 +196,26 @@ export function EnterprisePrecisionBar({
</div>
{/* Değer Kontrol Kutusu (VCB) */}
<div className="vcb-input-box" title="Değer Kontrol Kutusu: Bir sayı yazıp Enter'a basarak doğrudan ölçülendirin">
<div
className="vcb-input-box"
title="SketchUp Ölçü Kutusu (VCB): Örn. 100;60 (Boyut), *5 (Çoğalt), /4 (Böl), 45° (Açı), 25 (Ölçü) yazıp Enter'a basın"
>
<label htmlFor="precision-vcb-input" className="vcb-label">
<Ruler size={13} aria-hidden="true" />
<span>{data.valueLabel || "Ölçü"}:</span>
<span>{resolvedLabel}:</span>
</label>
<div className="vcb-input-wrap">
<input
id="precision-vcb-input"
ref={inputRef}
type="text"
inputMode="decimal"
inputMode="text"
className="vcb-field font-mono"
placeholder={data.isDragging ? "Ölçü yazın..." : "0.00"}
placeholder={data.isDragging ? "Ölçü..." : "100;50 / *5"}
value={inputValue}
onChange={handleInputChange}
onKeyDown={handleInputKeyDown}
aria-label={`${data.valueLabel || "Ölçü"} değeri milimetre cinsinden`}
aria-label={`${resolvedLabel} değeri (100;50, *5, /4 veya mm)`}
/>
<span className="unit-suffix font-mono">{unitLabel}</span>
</div>
@@ -0,0 +1,990 @@
"use client";
import { useCallback, useEffect, useMemo, useState } from "react";
import {
BookOpen,
Box,
Boxes,
Camera,
Check,
ChevronDown,
ChevronRight,
Cloud,
CloudUpload,
Compass,
Download,
Eye,
EyeOff,
FolderTree,
Info,
Layers,
Lock,
PaintBucket,
Palette,
Plus,
RefreshCw,
Search,
Sparkles,
Sun,
Trash2,
Unlock,
} from "lucide-react";
import { ARCHITECTURAL_TEXTURES, getTextureDefinition } from "@/lib/architecturalTextures";
import {
CLOUD_COMPONENT_CATEGORIES,
deleteCloudComponent,
getCloudComponent,
instantiateComponentShapes,
listCloudComponents,
publishCloudComponent,
type CloudComponentSummary,
} from "@/lib/cloudComponents";
import {
SKETCHUP_TOOLS,
VISUAL_STYLE_OPTIONS,
type DefaultTraySectionId,
type SketchUpToolId,
type VisualStyleMode,
} from "@/lib/sketchupInterface";
import { SNAPCAD_PREFABS } from "@/lib/snapcadPrefabs";
import { calculateSunPosition, SOLAR_LOCATIONS, type SolarStudySettings } from "@/lib/solarSystem";
import type { ArchitecturalScene, ArchitecturalTextureId, WorkplaneShape } from "@/types/sketchforge";
const QUICK_COLORS = [
"#e2e8f0",
"#94a3b8",
"#475569",
"#ef4444",
"#b91c1c",
"#f59e0b",
"#b45309",
"#10b981",
"#0ea5e9",
"#2563eb",
"#8b5cf6",
"#1e293b",
];
export interface SketchUpDefaultTrayProps {
openSections: DefaultTraySectionId[];
onToggleSection: (section: DefaultTraySectionId) => void;
shapes: WorkplaneShape[];
selectedIds: string[];
onSelectShapes: (ids: string[]) => void;
onUpdateShape: (id: string, patch: Partial<WorkplaneShape>) => void;
onUpdateAllShapes: (shapes: WorkplaneShape[], notice?: string) => void;
onInsertShapes: (newShapes: WorkplaneShape[], notice?: string) => void;
onMakeComponent: () => void;
onMakeUnique: () => void;
activeTool: SketchUpToolId;
visualStyle: VisualStyleMode;
onSelectVisualStyle: (style: VisualStyleMode) => void;
xRayMode: boolean;
onToggleXRay: () => void;
backEdgesEnabled: boolean;
onToggleBackEdges: () => void;
skyGroundEnabled: boolean;
onToggleSkyGround: () => void;
activePaintColor: string;
onSelectPaintColor: (color: string) => void;
activePaintTexture: ArchitecturalTextureId;
onSelectPaintTexture: (texture: ArchitecturalTextureId) => void;
paintBucketMode: boolean;
onTogglePaintBucket: () => void;
solarSettings: SolarStudySettings;
onChangeSolarSettings: (settings: SolarStudySettings) => void;
scenes: ArchitecturalScene[];
onAddScene: () => void;
onDeleteScene: (id: string) => void;
onSelectScene: (scene: ArchitecturalScene) => void;
onOpenLayersModal: () => void;
onZoomSelection: () => void;
onNotice: (message: string) => void;
}
const SECTION_META: Array<{ id: DefaultTraySectionId; title: string; icon: typeof Info }> = [
{ id: "entity-info", title: "Öğe Bilgisi (Entity Info)", icon: Info },
{ id: "outliner", title: "Ana Hatlar (Outliner)", icon: FolderTree },
{ id: "components", title: "Bileşenler (3B Havuz)", icon: Boxes },
{ id: "materials", title: "Malzemeler (Materials)", icon: PaintBucket },
{ id: "styles", title: "Stiller (Styles)", icon: Palette },
{ id: "tags", title: "Etiketler (Tags / Layers)", icon: Layers },
{ id: "shadows", title: "Gölgeler & Güneş (Shadows)", icon: Sun },
{ id: "scenes", title: "Sahneler (Scenes)", icon: Camera },
{ id: "instructor", title: "Eğitmen (Instructor)", icon: BookOpen },
];
export function SketchUpDefaultTray({
openSections,
onToggleSection,
shapes,
selectedIds,
onSelectShapes,
onUpdateShape,
onUpdateAllShapes,
onInsertShapes,
onMakeComponent,
onMakeUnique,
activeTool,
visualStyle,
onSelectVisualStyle,
xRayMode,
onToggleXRay,
backEdgesEnabled,
onToggleBackEdges,
skyGroundEnabled,
onToggleSkyGround,
activePaintColor,
onSelectPaintColor,
activePaintTexture,
onSelectPaintTexture,
paintBucketMode,
onTogglePaintBucket,
solarSettings,
onChangeSolarSettings,
scenes,
onAddScene,
onDeleteScene,
onSelectScene,
onOpenLayersModal,
onZoomSelection,
onNotice,
}: SketchUpDefaultTrayProps) {
const [outlinerQuery, setOutlinerQuery] = useState("");
const [componentTab, setComponentTab] = useState<"local" | "cloud">("local");
const [compSearch, setCompSearch] = useState("");
const [compCategory, setCompCategory] = useState("Tümü");
const [cloudComponents, setCloudComponents] = useState<CloudComponentSummary[]>([]);
const [cloudLoading, setCloudLoading] = useState(false);
const [cloudError, setCloudError] = useState<string | null>(null);
const [publishOpen, setPublishOpen] = useState(false);
const [publishTitle, setPublishTitle] = useState("");
const [publishCategory, setPublishCategory] = useState(CLOUD_COMPONENT_CATEGORIES[0]);
const [publishDesc, setPublishDesc] = useState("");
const [publishBusy, setPublishBusy] = useState(false);
const selectedShapes = useMemo(
() => shapes.filter((s) => selectedIds.includes(s.id)),
[shapes, selectedIds],
);
const primaryShape = selectedShapes.length === 1 ? selectedShapes[0] : null;
const componentSiblingsCount = useMemo(() => {
if (!primaryShape?.componentDefId) return 0;
return shapes.filter((s) => s.componentDefId === primaryShape.componentDefId).length;
}, [primaryShape?.componentDefId, shapes]);
const filteredOutlinerShapes = useMemo(() => {
const q = outlinerQuery.trim().toLowerCase();
if (!q) return shapes;
return shapes.filter(
(s) =>
(s.name || "").toLowerCase().includes(q) ||
(s.tag || "").toLowerCase().includes(q) ||
(s.componentName || "").toLowerCase().includes(q),
);
}, [shapes, outlinerQuery]);
const tagSummary = useMemo(() => {
const map = new Map<string, { name: string; count: number; allHidden: boolean }>();
for (const s of shapes) {
const name = (s.tag && s.tag.trim()) || "Katman 0 (Genel)";
const cur = map.get(name) ?? { name, count: 0, allHidden: true };
cur.count += 1;
if (!s.hidden) cur.allHidden = false;
map.set(name, cur);
}
return Array.from(map.values());
}, [shapes]);
const refreshCloudComponents = useCallback(async () => {
setCloudLoading(true);
setCloudError(null);
const result = await listCloudComponents({
category: compCategory === "Tümü" ? undefined : compCategory,
q: compSearch.trim() || undefined,
});
setCloudLoading(false);
if (!result.ok) {
setCloudError(result.error || "Bileşen havuzu yüklenemedi.");
return;
}
setCloudComponents(result.components);
}, [compCategory, compSearch]);
useEffect(() => {
if (openSections.includes("components") && componentTab === "cloud") {
void refreshCloudComponents();
}
}, [openSections, componentTab, refreshCloudComponents]);
const handleInsertPrefab = (prefabId: string) => {
const prefab = SNAPCAD_PREFABS.find((p) => p.id === prefabId);
if (!prefab) return;
const offset = shapes.length > 0 ? { x: (shapes.length % 4) * 30 - 30, z: 0, elevation: 0 } : { x: 0, z: 0, elevation: 0 };
const built = instantiateComponentShapes(prefab.buildShapes(), {
componentDefId: `prefab_${prefab.id}`,
componentName: prefab.title,
targetOffset: offset,
});
onInsertShapes(built, `"${prefab.title}" bileşeni eklendi (${built.length} parça)`);
};
const handleInsertCloudComponent = async (item: CloudComponentSummary) => {
setCloudLoading(true);
const res = await getCloudComponent(item.component_uid);
setCloudLoading(false);
if (!res.ok || !res.component) {
onNotice(res.error || "Bileşen sunucudan yüklenemedi.");
return;
}
const inst = instantiateComponentShapes(res.component.shapes, {
componentDefId: item.component_uid,
componentName: item.title,
targetOffset: { x: 0, z: 0, elevation: 0 },
});
onInsertShapes(inst, `YakNet Havuz: "${item.title}" sahneye eklendi (${inst.length} parça)`);
};
const handlePublishSelected = async () => {
const targets = selectedShapes.length > 0 ? selectedShapes : shapes;
if (targets.length === 0) {
onNotice("Paylaşmak için sahnede en az 1 nesne seçin.");
return;
}
if (!publishTitle.trim()) {
onNotice("Lütfen bileşen için bir ad girin.");
return;
}
setPublishBusy(true);
const res = await publishCloudComponent({
title: publishTitle.trim(),
category: publishCategory,
description: publishDesc.trim(),
is_public: true,
shapes: targets,
});
setPublishBusy(false);
if (!res.ok) {
onNotice(res.error || "Bileşen paylaşılamadı (YakNet hesabınızla giriş yapın).");
return;
}
setPublishOpen(false);
setPublishTitle("");
setPublishDesc("");
onNotice(res.message || "Bileşen YakNet 3B Bileşen Havuzuna paylaşıldı.");
setComponentTab("cloud");
void refreshCloudComponents();
};
const handleSolarHourChange = (hour: number) => {
const next: SolarStudySettings = { ...solarSettings, enabled: true, hour };
onChangeSolarSettings(next);
const calc = calculateSunPosition(next);
if (typeof window !== "undefined") {
window.dispatchEvent(new CustomEvent("snapcad:solar-update", { detail: calc }));
}
};
const applyMaterialToSelection = (texture: ArchitecturalTextureId, color: string) => {
if (selectedShapes.length === 0) {
onNotice("Önce bir nesne seçin veya Boya Kovası (B) ile tıklayın.");
return;
}
const texLabel = getTextureDefinition(texture).name;
selectedShapes.forEach((s) => onUpdateShape(s.id, { texture, color }));
onNotice(`${selectedShapes.length} nesneye "${texLabel}" malzemesi uygulandı.`);
};
const toolMeta = SKETCHUP_TOOLS[activeTool];
return (
<aside
className="sketchup-default-tray"
role="complementary"
aria-label="Varsayılan Tepsi (Default Tray)"
>
<div className="tray-top-header">
<span className="tray-top-title">Varsayılan Tepsi</span>
<span className="tray-top-count">{shapes.length} nesne</span>
</div>
<div className="tray-accordion-scroll">
{SECTION_META.map(({ id, title, icon: Icon }) => {
const isOpen = openSections.includes(id);
return (
<section key={id} className={`tray-section ${isOpen ? "open" : ""}`} aria-labelledby={`tray-hdr-${id}`}>
<h2 id={`tray-hdr-${id}`} className="tray-section-heading">
<button
type="button"
className="tray-section-trigger"
aria-expanded={isOpen}
aria-controls={`tray-body-${id}`}
onClick={() => onToggleSection(id)}
>
<span className="tray-trigger-left">
{isOpen ? <ChevronDown size={13} aria-hidden="true" /> : <ChevronRight size={13} aria-hidden="true" />}
<Icon size={13} aria-hidden="true" />
<span>{title}</span>
</span>
</button>
</h2>
{isOpen ? (
<div id={`tray-body-${id}`} className="tray-section-body">
{/* 1. ÖĞE BİLGİSİ (ENTITY INFO) */}
{id === "entity-info" ? (
selectedShapes.length === 0 ? (
<p className="tray-muted-note">
Özelliklerini görmek için bir nesne seçin. Ekran okuyucuda <kbd>[</kbd> / <kbd>]</kbd> ile gezebilirsiniz.
</p>
) : primaryShape ? (
<div className="tray-form-stack">
<label className="tray-field">
<span>Ad</span>
<input
type="text"
value={primaryShape.name}
onChange={(e) => onUpdateShape(primaryShape.id, { name: e.target.value })}
/>
</label>
<label className="tray-field">
<span>Etiket (Tag)</span>
<input
type="text"
value={primaryShape.tag ?? ""}
placeholder="Örn: Duvarlar, Çatı"
onChange={(e) => onUpdateShape(primaryShape.id, { tag: e.target.value })}
/>
</label>
<div className="tray-dim-row">
<label className="tray-mini-field">
<span>En (X)</span>
<input
type="number"
step={1}
value={Number(primaryShape.width.toFixed(2))}
onChange={(e) => {
const v = parseFloat(e.target.value);
if (Number.isFinite(v) && v > 0.1) onUpdateShape(primaryShape.id, { width: v });
}}
/>
</label>
<label className="tray-mini-field">
<span>Boy (Z)</span>
<input
type="number"
step={1}
value={Number(primaryShape.depth.toFixed(2))}
onChange={(e) => {
const v = parseFloat(e.target.value);
if (Number.isFinite(v) && v > 0.1) onUpdateShape(primaryShape.id, { depth: v });
}}
/>
</label>
<label className="tray-mini-field">
<span>Yüks (Y)</span>
<input
type="number"
step={1}
value={Number(primaryShape.height.toFixed(2))}
onChange={(e) => {
const v = parseFloat(e.target.value);
if (Number.isFinite(v) && v > 0.1) onUpdateShape(primaryShape.id, { height: v });
}}
/>
</label>
</div>
<div className="tray-btn-row">
<button
type="button"
className={`tray-pill-btn ${primaryShape.hole ? "active" : ""}`}
onClick={() => onUpdateShape(primaryShape.id, { hole: !primaryShape.hole })}
>
{primaryShape.hole ? "Delik (Kesici)" : "Katı (Solid)"}
</button>
<button
type="button"
className={`tray-pill-btn ${primaryShape.locked ? "active" : ""}`}
onClick={() => onUpdateShape(primaryShape.id, { locked: !primaryShape.locked })}
>
{primaryShape.locked ? "Kilitli" : "Kilitle"}
</button>
<button
type="button"
className="tray-pill-btn"
onClick={onZoomSelection}
title="Seçileni Çerçevele (Alt+Z)"
>
Odakla
</button>
</div>
<div className="tray-comp-box">
{primaryShape.componentDefId ? (
<>
<span className="tray-comp-badge">
Bileşen: {primaryShape.componentName || primaryShape.name} ({componentSiblingsCount} kopya)
</span>
<button type="button" className="tray-action-btn" onClick={onMakeUnique}>
Benzersiz Yap
</button>
</>
) : (
<button type="button" className="tray-action-btn" onClick={onMakeComponent}>
Bileşen Oluştur (G)
</button>
)}
</div>
</div>
) : (
<div className="tray-form-stack">
<p className="tray-muted-note">
<strong>{selectedShapes.length} nesne</strong> seçili. Toplu işlem yapabilirsiniz:
</p>
<div className="tray-btn-row">
<button type="button" className="tray-action-btn" onClick={onMakeComponent}>
Bileşen Yap (G)
</button>
<button type="button" className="tray-pill-btn" onClick={onZoomSelection}>
Odakla
</button>
</div>
</div>
)
) : null}
{/* 2. ANA HATLAR (OUTLINER) */}
{id === "outliner" ? (
<div className="tray-form-stack">
<div className="tray-search-box">
<Search size={12} aria-hidden="true" />
<input
type="search"
placeholder="Nesne veya katman ara…"
value={outlinerQuery}
onChange={(e) => setOutlinerQuery(e.target.value)}
aria-label="Ana Hatlar içinde nesne ara"
/>
</div>
<ul className="tray-outliner-list" aria-label="Sahnedeki tüm 3B nesneler">
{filteredOutlinerShapes.length === 0 ? (
<li className="tray-muted-note">Eşleşen nesne yok.</li>
) : (
filteredOutlinerShapes.map((shape) => {
const isSel = selectedIds.includes(shape.id);
return (
<li key={shape.id} className={`tray-outliner-item ${isSel ? "selected" : ""}`}>
<button
type="button"
className="tray-outliner-select"
onClick={(e) => {
if (e.shiftKey) {
const next = isSel
? selectedIds.filter((i) => i !== shape.id)
: [...selectedIds, shape.id];
onSelectShapes(next);
} else {
onSelectShapes([shape.id]);
}
}}
>
<Box size={12} aria-hidden="true" style={{ color: shape.color }} />
<span className="truncate">{shape.name || shape.kind}</span>
{shape.componentDefId ? <span className="tray-mini-badge">Bileşen</span> : null}
</button>
<div className="tray-outliner-actions">
<button
type="button"
title={shape.hidden ? "Göster" : "Gizle"}
aria-label={`${shape.name} ${shape.hidden ? "göster" : "gizle"}`}
onClick={() => onUpdateShape(shape.id, { hidden: !shape.hidden })}
>
{shape.hidden ? <EyeOff size={12} /> : <Eye size={12} />}
</button>
<button
type="button"
title={shape.locked ? "Kilidi Aç" : "Kilitle"}
aria-label={`${shape.name} ${shape.locked ? "kilidini aç" : "kilitle"}`}
onClick={() => onUpdateShape(shape.id, { locked: !shape.locked })}
>
{shape.locked ? <Lock size={12} /> : <Unlock size={12} />}
</button>
</div>
</li>
);
})
)}
</ul>
</div>
) : null}
{/* 3. BİLEŞENLER (YEREL & YAKNET 3B HAVUZ) */}
{id === "components" ? (
<div className="tray-form-stack">
<div className="tray-seg-tabs" role="tablist">
<button
type="button"
role="tab"
aria-selected={componentTab === "local"}
className={`tray-seg-btn ${componentTab === "local" ? "active" : ""}`}
onClick={() => setComponentTab("local")}
>
Hazır Kütüphane
</button>
<button
type="button"
role="tab"
aria-selected={componentTab === "cloud"}
className={`tray-seg-btn ${componentTab === "cloud" ? "active" : ""}`}
onClick={() => setComponentTab("cloud")}
>
<Cloud size={11} aria-hidden="true" />
<span>YakNet 3B Havuz</span>
</button>
</div>
{componentTab === "local" ? (
<div className="tray-prefab-list">
{SNAPCAD_PREFABS.slice(0, 12).map((prefab) => (
<button
key={prefab.id}
type="button"
className="tray-prefab-card"
onClick={() => handleInsertPrefab(prefab.id)}
title={prefab.description}
>
<span className="tray-prefab-dot" style={{ background: prefab.accentColor }} />
<span className="tray-prefab-info">
<strong>{prefab.title}</strong>
<small>{prefab.categoryLabel} · {prefab.badge}</small>
</span>
<Plus size={13} aria-hidden="true" />
</button>
))}
</div>
) : (
<div className="tray-form-stack">
<div className="tray-search-box">
<Search size={12} aria-hidden="true" />
<input
type="search"
placeholder="Topluluk bileşeni ara…"
value={compSearch}
onChange={(e) => setCompSearch(e.target.value)}
/>
<button
type="button"
className="tray-icon-tiny"
onClick={() => void refreshCloudComponents()}
title="Yenile"
aria-label="Bileşen havuzunu yenile"
>
<RefreshCw size={12} className={cloudLoading ? "animate-spin" : ""} />
</button>
</div>
<select
className="tray-select"
value={compCategory}
onChange={(e) => setCompCategory(e.target.value)}
aria-label="Bileşen kategorisi"
>
<option value="Tümü">Tüm Kategoriler</option>
{CLOUD_COMPONENT_CATEGORIES.map((c) => (
<option key={c} value={c}>{c}</option>
))}
</select>
<button
type="button"
className="tray-action-btn"
onClick={() => {
if (selectedShapes.length === 1 && !publishTitle) {
setPublishTitle(selectedShapes[0].componentName || selectedShapes[0].name || "");
}
setPublishOpen((p) => !p);
}}
>
<CloudUpload size={13} aria-hidden="true" />
<span>{selectedShapes.length > 0 ? "Seçiliyi 3B Havuza Yükle" : "Sahneyi 3B Havuza Yükle"}</span>
</button>
{publishOpen ? (
<div className="tray-publish-box">
<input
type="text"
placeholder="Bileşen adı (örn: Ahşap Pencere)"
value={publishTitle}
onChange={(e) => setPublishTitle(e.target.value)}
/>
<select
className="tray-select"
value={publishCategory}
onChange={(e) => setPublishCategory(e.target.value)}
>
{CLOUD_COMPONENT_CATEGORIES.map((c) => (
<option key={c} value={c}>{c}</option>
))}
</select>
<input
type="text"
placeholder="Kısa açıklama (opsiyonel)"
value={publishDesc}
onChange={(e) => setPublishDesc(e.target.value)}
/>
<button
type="button"
disabled={publishBusy}
className="tray-action-btn primary"
onClick={() => void handlePublishSelected()}
>
{publishBusy ? "Gönderiliyor…" : "Havuzda Yayınla"}
</button>
</div>
) : null}
{cloudError ? <p className="tray-error-note">{cloudError}</p> : null}
<div className="tray-prefab-list">
{!cloudLoading && cloudComponents.length === 0 && !cloudError ? (
<p className="tray-muted-note">
Henüz paylaşılan bileşen yok. İlk bileşeni yukarıdan siz paylaşabilirsiniz!
</p>
) : null}
{cloudComponents.map((item) => (
<div key={item.component_uid} className="tray-cloud-row">
<button
type="button"
className="tray-cloud-insert"
onClick={() => void handleInsertCloudComponent(item)}
title={item.description || item.title}
>
<strong>{item.title}</strong>
<small>{item.category} · {item.author_name} ({item.shapes_count} parça)</small>
</button>
<button
type="button"
className="tray-icon-tiny"
onClick={() => void handleInsertCloudComponent(item)}
title="Sahneye Ekle"
aria-label={`${item.title} ekle`}
>
<Download size={12} />
</button>
{item.is_owner ? (
<button
type="button"
className="tray-icon-tiny danger"
onClick={async () => {
await deleteCloudComponent(item.component_uid);
void refreshCloudComponents();
}}
title="Bileşeni Sil"
aria-label={`${item.title} sil`}
>
<Trash2 size={12} />
</button>
) : null}
</div>
))}
</div>
</div>
)}
</div>
) : null}
{/* 4. MALZEMELER (MATERIALS) */}
{id === "materials" ? (
<div className="tray-form-stack">
<div className="tray-color-row">
{QUICK_COLORS.map((hex) => (
<button
key={hex}
type="button"
className={`tray-swatch ${activePaintColor.toLowerCase() === hex ? "active" : ""}`}
style={{ backgroundColor: hex }}
aria-label={`Renk ${hex}`}
onClick={() => {
onSelectPaintColor(hex);
if (selectedShapes.length > 0 && !paintBucketMode) {
selectedShapes.forEach((s) => onUpdateShape(s.id, { color: hex, hole: false }));
}
}}
/>
))}
</div>
<div className="tray-texture-grid">
{ARCHITECTURAL_TEXTURES.map((tex) => (
<button
key={tex.id}
type="button"
className={`tray-texture-tile ${activePaintTexture === tex.id ? "active" : ""}`}
onClick={() => {
onSelectPaintTexture(tex.id);
if (selectedShapes.length > 0) {
applyMaterialToSelection(tex.id, activePaintColor);
}
}}
title={tex.description}
>
<span
className="tray-texture-swatch"
style={
tex.id === "brick"
? { background: "repeating-linear-gradient(0deg, #b91c1c, #b91c1c 6px, #e2e8f0 6px, #e2e8f0 8px)" }
: tex.id === "wood"
? { background: "linear-gradient(90deg, #78350f, #b45309, #92400e)" }
: tex.id === "tiles"
? { background: "linear-gradient(45deg, #e2e8f0 25%, #cbd5e1 25%, #cbd5e1 50%, #e2e8f0 50%)" }
: tex.id === "marble"
? { background: "linear-gradient(135deg, #f8fafc, #cbd5e1)" }
: tex.id === "metal"
? { background: "linear-gradient(135deg, #475569, #cbd5e1, #475569)" }
: tex.id === "glass"
? { background: "rgba(56, 189, 248, 0.45)" }
: tex.id === "grass"
? { background: "#15803d" }
: tex.id === "concrete"
? { background: "#94a3b8" }
: { background: activePaintColor }
}
/>
<span>{tex.name}</span>
</button>
))}
</div>
<div className="tray-btn-row">
<button
type="button"
className={`tray-action-btn ${paintBucketMode ? "primary" : ""}`}
onClick={onTogglePaintBucket}
>
<PaintBucket size={12} aria-hidden="true" />
<span>{paintBucketMode ? "Boya Kovası Aktif (B)" : "Boya Kovasını Aç (B)"}</span>
</button>
{selectedShapes.length > 0 ? (
<button
type="button"
className="tray-pill-btn"
onClick={() => applyMaterialToSelection(activePaintTexture, activePaintColor)}
>
Seçiliye Uygula
</button>
) : null}
</div>
</div>
) : null}
{/* 5. STİLLER (STYLES) */}
{id === "styles" ? (
<div className="tray-form-stack">
<div className="tray-style-list">
{VISUAL_STYLE_OPTIONS.map((style) => (
<button
key={style.id}
type="button"
className={`tray-style-item ${visualStyle === style.id ? "active" : ""}`}
onClick={() => onSelectVisualStyle(style.id)}
>
<span className="tray-style-thumb" style={{ background: style.swatch }} aria-hidden="true" />
<span className="tray-style-text">
<strong>{style.label}</strong>
<small>{style.description}</small>
</span>
{visualStyle === style.id ? <Check size={13} className="text-sky-400 shrink-0" /> : null}
</button>
))}
</div>
<div className="tray-btn-row">
<button
type="button"
className={`tray-pill-btn ${xRayMode ? "active" : ""}`}
onClick={onToggleXRay}
>
X-Ray (X)
</button>
<button
type="button"
className={`tray-pill-btn ${backEdgesEnabled ? "active" : ""}`}
onClick={onToggleBackEdges}
>
Arka Kenar (K)
</button>
<button
type="button"
className={`tray-pill-btn ${skyGroundEnabled ? "active" : ""}`}
onClick={onToggleSkyGround}
>
Gökyüzü
</button>
</div>
</div>
) : null}
{/* 6. ETİKETLER (TAGS / LAYERS) */}
{id === "tags" ? (
<div className="tray-form-stack">
{tagSummary.length === 0 ? (
<p className="tray-muted-note">Sahnede katman bulunmuyor.</p>
) : (
<ul className="tray-tag-list">
{tagSummary.map((tag) => (
<li key={tag.name} className="tray-tag-row">
<button
type="button"
className="tray-tag-select"
onClick={() => {
const ids = shapes
.filter((s) => ((s.tag && s.tag.trim()) || "Katman 0 (Genel)") === tag.name)
.map((s) => s.id);
onSelectShapes(ids);
}}
>
<span className="truncate">{tag.name}</span>
<small>({tag.count})</small>
</button>
<button
type="button"
className="tray-icon-tiny"
title={tag.allHidden ? "Katmanı Göster" : "Katmanı Gizle"}
onClick={() => {
const nextHidden = !tag.allHidden;
const updated = shapes.map((s) =>
((s.tag && s.tag.trim()) || "Katman 0 (Genel)") === tag.name
? { ...s, hidden: nextHidden }
: s,
);
onUpdateAllShapes(updated, `${tag.name} ${nextHidden ? "gizlendi" : "görünür yapıldı"}`);
}}
>
{tag.allHidden ? <EyeOff size={12} /> : <Eye size={12} />}
</button>
</li>
))}
</ul>
)}
<button type="button" className="tray-action-btn" onClick={onOpenLayersModal}>
Detaylı Katman Yöneticisi…
</button>
</div>
) : null}
{/* 7. GÖLGELER & GÜNEŞ ETÜDÜ */}
{id === "shadows" ? (
<div className="tray-form-stack">
<label className="tray-slider-field">
<span>Saat: {Math.floor(solarSettings.hour)}:{Math.round((solarSettings.hour % 1) * 60) >= 30 ? "30" : "00"}</span>
<input
type="range"
min={6}
max={20}
step={0.5}
value={solarSettings.hour}
onChange={(e) => handleSolarHourChange(parseFloat(e.target.value))}
/>
</label>
<select
className="tray-select"
value={solarSettings.locationIndex}
onChange={(e) => {
const idx = parseInt(e.target.value, 10);
const next = { ...solarSettings, enabled: true, locationIndex: idx };
onChangeSolarSettings(next);
if (typeof window !== "undefined") {
window.dispatchEvent(new CustomEvent("snapcad:solar-update", { detail: calculateSunPosition(next) }));
}
}}
aria-label="Güneş etüdü konumu"
>
{SOLAR_LOCATIONS.map((loc, idx) => (
<option key={loc.name} value={idx}>{loc.name}</option>
))}
</select>
<div className="tray-btn-row">
<button
type="button"
className={`tray-pill-btn ${solarSettings.month === 5 ? "active" : ""}`}
onClick={() => {
const next = { ...solarSettings, enabled: true, month: 5, day: 21 };
onChangeSolarSettings(next);
if (typeof window !== "undefined") {
window.dispatchEvent(new CustomEvent("snapcad:solar-update", { detail: calculateSunPosition(next) }));
}
}}
>
Yaz (21 Haz)
</button>
<button
type="button"
className={`tray-pill-btn ${solarSettings.month === 11 ? "active" : ""}`}
onClick={() => {
const next = { ...solarSettings, enabled: true, month: 11, day: 21 };
onChangeSolarSettings(next);
if (typeof window !== "undefined") {
window.dispatchEvent(new CustomEvent("snapcad:solar-update", { detail: calculateSunPosition(next) }));
}
}}
>
Kış (21 Ara)
</button>
</div>
</div>
) : null}
{/* 8. SAHNELER (SCENES) */}
{id === "scenes" ? (
<div className="tray-form-stack">
<button type="button" className="tray-action-btn" onClick={onAddScene}>
<Plus size={12} aria-hidden="true" />
<span>Yeni Sahne Ekle</span>
</button>
<ul className="tray-outliner-list">
{scenes.map((sc) => (
<li key={sc.id} className="tray-outliner-item">
<button type="button" className="tray-outliner-select" onClick={() => onSelectScene(sc)}>
<Compass size={12} className="text-sky-400" aria-hidden="true" />
<span className="truncate">{sc.name}</span>
</button>
<button
type="button"
className="tray-icon-tiny danger"
onClick={() => onDeleteScene(sc.id)}
title="Sahneyi Sil"
aria-label={`${sc.name} sahnesini sil`}
>
<Trash2 size={12} />
</button>
</li>
))}
</ul>
</div>
) : null}
{/* 9. EĞİTMEN (INSTRUCTOR) */}
{id === "instructor" ? (
<div className="tray-instructor-card" aria-live="polite">
<div className="tray-instructor-head">
<strong>{toolMeta.name}</strong>
{toolMeta.shortcut ? <kbd>{toolMeta.shortcut}</kbd> : null}
</div>
<p className="tray-instructor-hint">{toolMeta.hint}</p>
<ul className="tray-instructor-steps">
{toolMeta.instructorSteps.map((step, i) => (
<li key={i}>{step}</li>
))}
</ul>
<div className="tray-instructor-tip">
<Sparkles size={11} aria-hidden="true" />
<span>Ölçü Kutusuna (VCB) <code>100;50</code>, <code>*5</code> veya <code>/4</code> yazıp Enter&apos;a basabilirsiniz.</span>
</div>
</div>
) : null}
</div>
) : null}
</section>
);
})}
</div>
</aside>
);
}
@@ -0,0 +1,532 @@
"use client";
import { useEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from "react";
import { Check, ChevronRight, Keyboard, LayoutPanelLeft, LayoutPanelTop, PanelRight } from "lucide-react";
import type {
DefaultTraySectionId,
SketchUpToolId,
SketchUpWorkspacePrefs,
VisualStyleMode,
} from "@/lib/sketchupInterface";
export interface SketchUpMenuBarProps {
prefs: SketchUpWorkspacePrefs;
onUpdatePrefs: (patch: Partial<SketchUpWorkspacePrefs>) => void;
onOpenTraySection: (section: DefaultTraySectionId) => void;
activeTool: SketchUpToolId;
onSelectTool: (tool: SketchUpToolId) => void;
visualStyle: VisualStyleMode;
onSelectVisualStyle: (style: VisualStyleMode) => void;
xRayMode: boolean;
onToggleXRay: () => void;
isOrthographic: boolean;
onToggleProjection: () => void;
canUndo: boolean;
canRedo: boolean;
hasSelection: boolean;
canGroup: boolean;
canUngroup: boolean;
hiddenCount: number;
guidesCount: number;
onUndo: () => void;
onRedo: () => void;
onCut: () => void;
onCopy: () => void;
onPaste: () => void;
onDuplicate: () => void;
onDelete: () => void;
onSelectAll: () => void;
onClearSelection: () => void;
onMakeComponent: () => void;
onMakeUnique: () => void;
onGroup: () => void;
onUngroup: () => void;
onToggleHidden: () => void;
onShowHidden: () => void;
onClearGuides: () => void;
onOpenImport: () => void;
onOpenExport: () => void;
onBackToDashboard?: () => void;
onOpenLayers: () => void;
onOpenSolar: () => void;
onOpenFollowMe: () => void;
onOpenTerrain: () => void;
onOpenWallOpening: () => void;
onRunStructuralTest: () => void;
onOpenAudit: () => void;
onOpenVoiceCad: () => void;
onOpenTutorial: () => void;
onOpenDailyChallenges: () => void;
onOpenWorkspaceSettings: () => void;
onOpenA11ySettings?: () => void;
onReadShortcutHelp: () => void;
onRadarScan: () => void;
onCameraView: (view: "top" | "bottom" | "front" | "back" | "left" | "right" | "isometric" | "extents" | "selection" | "previous" | "two-point") => void;
}
type MenuItemDef =
| { kind: "separator" }
| {
kind: "action";
id: string;
label: string;
shortcut?: string;
checked?: boolean;
disabled?: boolean;
onSelect: () => void;
};
type MenuDef = {
id: string;
label: string;
items: MenuItemDef[];
};
export function SketchUpMenuBar(props: SketchUpMenuBarProps) {
const {
prefs,
onUpdatePrefs,
onOpenTraySection,
activeTool,
onSelectTool,
visualStyle,
onSelectVisualStyle,
xRayMode,
onToggleXRay,
isOrthographic,
onToggleProjection,
canUndo,
canRedo,
hasSelection,
canGroup,
canUngroup,
hiddenCount,
guidesCount,
} = props;
const [openMenuId, setOpenMenuId] = useState<string | null>(null);
const barRef = useRef<HTMLDivElement | null>(null);
const triggerRefs = useRef<Record<string, HTMLButtonElement | null>>({});
useEffect(() => {
if (!openMenuId) return;
const handlePointerDown = (e: MouseEvent) => {
if (barRef.current && !barRef.current.contains(e.target as Node)) {
setOpenMenuId(null);
}
};
const handleEsc = (e: KeyboardEvent) => {
if (e.key === "Escape") {
setOpenMenuId(null);
}
};
window.addEventListener("mousedown", handlePointerDown);
window.addEventListener("keydown", handleEsc);
return () => {
window.removeEventListener("mousedown", handlePointerDown);
window.removeEventListener("keydown", handleEsc);
};
}, [openMenuId]);
const menus: MenuDef[] = [
{
id: "file",
label: "Dosya",
items: [
...(props.onBackToDashboard
? [
{
kind: "action" as const,
id: "file-dashboard",
label: "Projeler Paneli / Yeni Tasarım",
onSelect: () => props.onBackToDashboard?.(),
},
{ kind: "separator" as const },
]
: []),
{
kind: "action",
id: "file-import",
label: "İçe Aktar (SKF, DWG, DXF, STEP, STL, OBJ, SVG)…",
onSelect: props.onOpenImport,
},
{
kind: "action",
id: "file-export",
label: "Dışa Aktar (STL, OBJ, STEP, DXF, 3MF, SKF)…",
onSelect: props.onOpenExport,
},
{ kind: "separator" },
{
kind: "action",
id: "file-ws-settings",
label: "Model Bilgisi & Çalışma Alanı Birimleri…",
onSelect: props.onOpenWorkspaceSettings,
},
],
},
{
id: "edit",
label: "Düzenle",
items: [
{ kind: "action", id: "edit-undo", label: "Geri Al", shortcut: "Ctrl+Z", disabled: !canUndo, onSelect: props.onUndo },
{ kind: "action", id: "edit-redo", label: "Yinele", shortcut: "Ctrl+Y", disabled: !canRedo, onSelect: props.onRedo },
{ kind: "separator" },
{ kind: "action", id: "edit-cut", label: "Kes", shortcut: "Ctrl+X", disabled: !hasSelection, onSelect: props.onCut },
{ kind: "action", id: "edit-copy", label: "Kopyala", shortcut: "Ctrl+C", disabled: !hasSelection, onSelect: props.onCopy },
{ kind: "action", id: "edit-paste", label: "Yapıştır", shortcut: "Ctrl+V", onSelect: props.onPaste },
{ kind: "action", id: "edit-dup", label: "Çoğalt", shortcut: "Ctrl+D", disabled: !hasSelection, onSelect: props.onDuplicate },
{ kind: "action", id: "edit-del", label: "Sil", shortcut: "Del", disabled: !hasSelection, onSelect: props.onDelete },
{ kind: "separator" },
{ kind: "action", id: "edit-all", label: "Tümünü Seç", shortcut: "Ctrl+A", onSelect: props.onSelectAll },
{ kind: "action", id: "edit-none", label: "Seçimi Bırak", shortcut: "Esc", disabled: !hasSelection, onSelect: props.onClearSelection },
{ kind: "separator" },
{
kind: "action",
id: "edit-comp",
label: "Bileşen Oluştur (Make Component)…",
shortcut: prefs.keymapProfile === "classic-sketchup" ? "G" : "",
disabled: !hasSelection,
onSelect: props.onMakeComponent,
},
{
kind: "action",
id: "edit-unique",
label: "Bileşeni Benzersiz Yap (Make Unique)",
disabled: !hasSelection,
onSelect: props.onMakeUnique,
},
{ kind: "action", id: "edit-group", label: "Grupla (Make Group)", shortcut: "Ctrl+G", disabled: !canGroup, onSelect: props.onGroup },
{ kind: "action", id: "edit-ungroup", label: "Grubu Çöz (Explode)", shortcut: "Ctrl+Shift+G", disabled: !canUngroup, onSelect: props.onUngroup },
{ kind: "separator" },
{ kind: "action", id: "edit-hide", label: "Gizle / Göster", shortcut: "Ctrl+H", disabled: !hasSelection, onSelect: props.onToggleHidden },
{ kind: "action", id: "edit-unhide-all", label: `Gizlileri Göster (${hiddenCount})`, shortcut: "Ctrl+Shift+H", disabled: hiddenCount === 0, onSelect: props.onShowHidden },
],
},
{
id: "view",
label: "Görünüm",
items: [
{
kind: "action",
id: "view-toolset",
label: "Büyük Araç Seti (Sol Panel)",
checked: prefs.showLeftToolset,
onSelect: () => onUpdatePrefs({ showLeftToolset: !prefs.showLeftToolset }),
},
{
kind: "action",
id: "view-tray",
label: "Varsayılan Tepsi (Sağ Panel)",
checked: prefs.showDefaultTray,
onSelect: () => onUpdatePrefs({ showDefaultTray: !prefs.showDefaultTray }),
},
{
kind: "action",
id: "view-ribbon",
label: "SnapCAD Üst Araç Şeridi",
checked: prefs.showSecondaryRibbon,
onSelect: () => onUpdatePrefs({ showSecondaryRibbon: !prefs.showSecondaryRibbon }),
},
{ kind: "separator" },
{
kind: "action",
id: "view-sky",
label: "Gökyüzü & Ufuk Zemini (Sky / Ground)",
checked: prefs.skyGroundEnabled,
onSelect: () => onUpdatePrefs({ skyGroundEnabled: !prefs.skyGroundEnabled }),
},
{
kind: "action",
id: "view-backedges",
label: "Arka Kenarlar (Back Edges)",
shortcut: prefs.keymapProfile === "classic-sketchup" ? "K" : "",
checked: prefs.backEdgesEnabled,
onSelect: () => onUpdatePrefs({ backEdgesEnabled: !prefs.backEdgesEnabled }),
},
{
kind: "action",
id: "view-xray",
label: "X-Ray (Röntgen Modu)",
shortcut: "X",
checked: xRayMode,
onSelect: props.onToggleXRay,
},
{ kind: "separator" },
{ kind: "action", id: "style-shaded", label: "Yüz Stili: Dokulu & Gölgeli", checked: visualStyle === "shaded", onSelect: () => onSelectVisualStyle("shaded") },
{ kind: "action", id: "style-mono", label: "Yüz Stili: Monokrom", checked: visualStyle === "monochrome", onSelect: () => onSelectVisualStyle("monochrome") },
{ kind: "action", id: "style-hidden", label: "Yüz Stili: Gizli Çizgi (Hidden Line)", checked: visualStyle === "hidden-line", onSelect: () => onSelectVisualStyle("hidden-line") },
{ kind: "action", id: "style-wire", label: "Yüz Stili: Tel Kafes (Wireframe)", checked: visualStyle === "wireframe", onSelect: () => onSelectVisualStyle("wireframe") },
{ kind: "action", id: "style-blue", label: "Yüz Stili: Mimari Ozalit (Blueprint)", checked: visualStyle === "blueprint", onSelect: () => onSelectVisualStyle("blueprint") },
{ kind: "action", id: "style-clay", label: "Yüz Stili: Sıcak Kil", checked: visualStyle === "clay", onSelect: () => onSelectVisualStyle("clay") },
{ kind: "separator" },
{ kind: "action", id: "view-layers", label: "Etiketler / Katmanlar…", onSelect: props.onOpenLayers },
{ kind: "action", id: "view-solar", label: "Güneş & Gölgeler Etüdü…", onSelect: props.onOpenSolar },
{ kind: "action", id: "view-clear-guides", label: `Kılavuzları Temizle (${guidesCount})`, disabled: guidesCount === 0, onSelect: props.onClearGuides },
],
},
{
id: "camera",
label: "Kamera",
items: [
{ kind: "action", id: "cam-iso", label: "İzometrik Görünüm", shortcut: "Home", onSelect: () => props.onCameraView("isometric") },
{ kind: "action", id: "cam-top", label: "Üst (Top)", shortcut: "5", onSelect: () => props.onCameraView("top") },
{ kind: "action", id: "cam-front", label: "Ön (Front)", shortcut: "1", onSelect: () => props.onCameraView("front") },
{ kind: "action", id: "cam-right", label: "Sağ (Right)", shortcut: "4", onSelect: () => props.onCameraView("right") },
{ kind: "action", id: "cam-back", label: "Arka (Back)", shortcut: "2", onSelect: () => props.onCameraView("back") },
{ kind: "action", id: "cam-left", label: "Sol (Left)", shortcut: "3", onSelect: () => props.onCameraView("left") },
{ kind: "action", id: "cam-bottom", label: "Alt (Bottom)", shortcut: "6", onSelect: () => props.onCameraView("bottom") },
{ kind: "separator" },
{
kind: "action",
id: "cam-proj",
label: isOrthographic ? "Perspektif Görünüme Geç" : "Paralel İzdüşüm (Parallel Projection)",
shortcut: prefs.keymapProfile === "classic-sketchup" ? "Shift+V" : "O",
checked: isOrthographic,
onSelect: onToggleProjection,
},
{ kind: "action", id: "cam-2p", label: "İki Kaçışlı Perspektif (2-Point)", onSelect: () => props.onCameraView("two-point") },
{ kind: "separator" },
{ kind: "action", id: "cam-orbit", label: "Yörünge (Orbit)", shortcut: prefs.keymapProfile === "classic-sketchup" ? "O" : "", checked: activeTool === "orbit", onSelect: () => onSelectTool("orbit") },
{ kind: "action", id: "cam-pan", label: "Kaydır (Pan)", shortcut: prefs.keymapProfile === "classic-sketchup" ? "H" : "", checked: activeTool === "pan", onSelect: () => onSelectTool("pan") },
{ kind: "action", id: "cam-zoom", label: "Yakınlaştır (Zoom)", shortcut: "Z", checked: activeTool === "zoom", onSelect: () => onSelectTool("zoom") },
{ kind: "action", id: "cam-extents", label: "Ekrana Sığdır (Zoom Extents)", shortcut: "Shift+Z", onSelect: () => props.onCameraView("extents") },
{ kind: "action", id: "cam-sel", label: "Seçileni Çerçevele (Zoom Selection)", shortcut: "Alt+Z", onSelect: () => props.onCameraView("selection") },
{ kind: "action", id: "cam-prev", label: "Önceki Görünüm (Previous)", shortcut: "Alt+P", onSelect: () => props.onCameraView("previous") },
{ kind: "separator" },
{ kind: "action", id: "cam-walk", label: "İçinde Yürü (Walk / WASD)", onSelect: () => onSelectTool("walk") },
],
},
{
id: "draw",
label: "Çizim",
items: [
{ kind: "action", id: "draw-line", label: "Çizgi (Line)", shortcut: "L", checked: activeTool === "line", onSelect: () => onSelectTool("line") },
{ kind: "action", id: "draw-free", label: "Serbest / Eğri (Freehand)", checked: activeTool === "freehand", onSelect: () => onSelectTool("freehand") },
{ kind: "action", id: "draw-arc", label: "Yay (Arc)", shortcut: "A", checked: activeTool === "arc", onSelect: () => onSelectTool("arc") },
{ kind: "separator" },
{ kind: "action", id: "draw-rect", label: "Dikdörtgen (Rectangle)", shortcut: "R", checked: activeTool === "rectangle", onSelect: () => onSelectTool("rectangle") },
{ kind: "action", id: "draw-circle", label: "Daire (Circle)", shortcut: "C", checked: activeTool === "circle", onSelect: () => onSelectTool("circle") },
{ kind: "action", id: "draw-poly", label: "Çokgen (Polygon)", checked: activeTool === "polygon", onSelect: () => onSelectTool("polygon") },
{ kind: "separator" },
{ kind: "action", id: "draw-text", label: "3B Metin Ekle (3D Text)", onSelect: () => onSelectTool("3d-text") },
],
},
{
id: "tools",
label: "Araçlar",
items: [
{ kind: "action", id: "tool-select", label: "Seçim (Select)", shortcut: "Space", checked: activeTool === "select", onSelect: () => onSelectTool("select") },
{ kind: "action", id: "tool-eraser", label: "Silgi (Eraser)", shortcut: "E", checked: activeTool === "eraser", onSelect: () => onSelectTool("eraser") },
{ kind: "action", id: "tool-paint", label: "Boya Kovası (Paint Bucket)", shortcut: "B", checked: activeTool === "paint", onSelect: () => onSelectTool("paint") },
{ kind: "separator" },
{ kind: "action", id: "tool-move", label: "Taşı (Move)", shortcut: "M", checked: activeTool === "move", onSelect: () => onSelectTool("move") },
{ kind: "action", id: "tool-pp", label: "İt / Çek (Push/Pull)", shortcut: "P", checked: activeTool === "push-pull", onSelect: () => onSelectTool("push-pull") },
{ kind: "action", id: "tool-rot", label: "Döndür (Rotate)", shortcut: prefs.keymapProfile === "classic-sketchup" ? "Q" : "", checked: activeTool === "rotate", onSelect: () => onSelectTool("rotate") },
{ kind: "action", id: "tool-scale", label: "Ölçekle (Scale)", shortcut: "S", checked: activeTool === "scale", onSelect: () => onSelectTool("scale") },
{ kind: "action", id: "tool-offset", label: "Ofset (Offset)", shortcut: prefs.keymapProfile === "classic-sketchup" ? "F" : "", checked: activeTool === "offset", onSelect: () => onSelectTool("offset") },
{ kind: "action", id: "tool-follow", label: "Beni Takip Et (Follow Me)…", onSelect: props.onOpenFollowMe },
{ kind: "separator" },
{ kind: "action", id: "tool-tape", label: "Şerit Metre & Kılavuz (Tape Measure)", shortcut: "T", checked: activeTool === "tape", onSelect: () => onSelectTool("tape") },
{ kind: "action", id: "tool-prot", label: "İletki / Açılı Kılavuz (Protractor)", onSelect: () => onSelectTool("protractor") },
{ kind: "action", id: "tool-axes", label: "Eksenler / Çalışma Düzlemi (Axes)", shortcut: "W", checked: activeTool === "axes", onSelect: () => onSelectTool("axes") },
{ kind: "action", id: "tool-sec", label: "Kesit Düzlemi (Section Plane)", onSelect: () => onSelectTool("section") },
{ kind: "separator" },
{ kind: "action", id: "tool-wall", label: "Duvar Kapı / Pencere Boşluğu Aç…", onSelect: props.onOpenWallOpening },
{ kind: "action", id: "tool-terrain", label: "Arazi & Yükselti Üreticisi (Sandbox)…", onSelect: props.onOpenTerrain },
{ kind: "action", id: "tool-static", label: "Statik & Deprem Dayanım Testi…", onSelect: props.onRunStructuralTest },
],
},
{
id: "window",
label: "Pencere",
items: [
{ kind: "action", id: "win-entity", label: "Tepsi: Öğe Bilgisi (Entity Info)", checked: prefs.showDefaultTray && prefs.openTraySections.includes("entity-info"), onSelect: () => onOpenTraySection("entity-info") },
{ kind: "action", id: "win-outliner", label: "Tepsi: Ana Hatlar (Outliner)", checked: prefs.showDefaultTray && prefs.openTraySections.includes("outliner"), onSelect: () => onOpenTraySection("outliner") },
{ kind: "action", id: "win-comp", label: "Tepsi: Bileşenler (3B Havuz)", checked: prefs.showDefaultTray && prefs.openTraySections.includes("components"), onSelect: () => onOpenTraySection("components") },
{ kind: "action", id: "win-mat", label: "Tepsi: Malzemeler (Materials)", checked: prefs.showDefaultTray && prefs.openTraySections.includes("materials"), onSelect: () => onOpenTraySection("materials") },
{ kind: "action", id: "win-styles", label: "Tepsi: Stiller (Styles)", checked: prefs.showDefaultTray && prefs.openTraySections.includes("styles"), onSelect: () => onOpenTraySection("styles") },
{ kind: "action", id: "win-tags", label: "Tepsi: Etiketler (Tags / Layers)", checked: prefs.showDefaultTray && prefs.openTraySections.includes("tags"), onSelect: () => onOpenTraySection("tags") },
{ kind: "action", id: "win-shadows", label: "Tepsi: Gölgeler & Güneş (Shadows)", checked: prefs.showDefaultTray && prefs.openTraySections.includes("shadows"), onSelect: () => onOpenTraySection("shadows") },
{ kind: "action", id: "win-scenes", label: "Tepsi: Sahneler (Scenes)", checked: prefs.showDefaultTray && prefs.openTraySections.includes("scenes"), onSelect: () => onOpenTraySection("scenes") },
{ kind: "action", id: "win-inst", label: "Tepsi: Eğitmen (Instructor)", checked: prefs.showDefaultTray && prefs.openTraySections.includes("instructor"), onSelect: () => onOpenTraySection("instructor") },
{ kind: "separator" },
{
kind: "action",
id: "win-keymap-skp",
label: "Kısayol Profili: SketchUp Klasik (L, R, C, P, M, Q, S, F, O, H, Z, E)",
checked: prefs.keymapProfile === "classic-sketchup",
onSelect: () => onUpdatePrefs({ keymapProfile: "classic-sketchup" }),
},
{
kind: "action",
id: "win-keymap-std",
label: "Kısayol Profili: SnapCAD Erişilebilir Klasik (İ, V, K, Q Yardım, F Sıfırla)",
checked: prefs.keymapProfile === "snapcad-standard",
onSelect: () => onUpdatePrefs({ keymapProfile: "snapcad-standard" }),
},
{ kind: "separator" },
{ kind: "action", id: "win-settings", label: "Tercihler & Birim Ayarları…", onSelect: props.onOpenWorkspaceSettings },
...(props.onOpenA11ySettings
? [{ kind: "action" as const, id: "win-a11y", label: "Erişilebilirlik & NVDA Sesli Asistan…", onSelect: () => props.onOpenA11ySettings?.() }]
: []),
],
},
{
id: "help",
label: "Yardım",
items: [
{ kind: "action", id: "help-audit", label: "3B Sahne Denetçisi (Erişilebilir Rapor)", shortcut: "İ / F2", onSelect: props.onOpenAudit },
{ kind: "action", id: "help-voice", label: "Sesli / Metin CAD Komut Konsolu", shortcut: "/ veya V", onSelect: props.onOpenVoiceCad },
{ kind: "action", id: "help-radar", label: "Sesli 3B Radar Taraması", shortcut: prefs.keymapProfile === "classic-sketchup" ? "F8 / Alt+K" : "K / F8", onSelect: props.onRadarScan },
{ kind: "action", id: "help-keys", label: "Kısayol Rehberini Seslendir & Göster", shortcut: "?", onSelect: props.onReadShortcutHelp },
{ kind: "separator" },
{ kind: "action", id: "help-tut", label: "SnapCAD Akademi İnteraktif Eğitimi…", onSelect: props.onOpenTutorial },
{ kind: "action", id: "help-chal", label: "Günün Mimari Görevleri…", onSelect: props.onOpenDailyChallenges },
],
},
];
const handleMenuBarKeyDown = (e: ReactKeyboardEvent<HTMLButtonElement>, idx: number) => {
if (e.key === "ArrowRight") {
e.preventDefault();
const next = menus[(idx + 1) % menus.length];
triggerRefs.current[next.id]?.focus();
if (openMenuId) setOpenMenuId(next.id);
} else if (e.key === "ArrowLeft") {
e.preventDefault();
const prev = menus[(idx - 1 + menus.length) % menus.length];
triggerRefs.current[prev.id]?.focus();
if (openMenuId) setOpenMenuId(prev.id);
} else if (e.key === "Escape") {
e.preventDefault();
setOpenMenuId(null);
}
};
return (
<div
ref={barRef}
className="sketchup-menubar"
role="menubar"
aria-label="SketchUp Klasik Menü Çubuğu"
>
<div className="sketchup-menubar-items">
{menus.map((menu, idx) => {
const isOpen = openMenuId === menu.id;
return (
<div
key={menu.id}
className="sketchup-menu-slot"
onMouseEnter={() => {
if (openMenuId && openMenuId !== menu.id) {
setOpenMenuId(menu.id);
}
}}
>
<button
ref={(el) => {
triggerRefs.current[menu.id] = el;
}}
type="button"
role="menuitem"
aria-haspopup="menu"
aria-expanded={isOpen}
className={`sketchup-menu-trigger ${isOpen ? "open" : ""}`}
onClick={() => setOpenMenuId((cur) => (cur === menu.id ? null : menu.id))}
onKeyDown={(e) => handleMenuBarKeyDown(e, idx)}
>
{menu.label}
</button>
{isOpen ? (
<div className="sketchup-menu-dropdown" role="menu" aria-label={`${menu.label} alt menüsü`}>
{menu.items.map((item, itemIdx) =>
item.kind === "separator" ? (
<div key={`${menu.id}-sep-${itemIdx}`} className="sketchup-menu-sep" role="separator" />
) : (
<button
key={item.id}
type="button"
role="menuitemcheckbox"
aria-checked={Boolean(item.checked)}
disabled={item.disabled}
className={`sketchup-menu-item ${item.checked ? "checked" : ""}`}
onClick={() => {
setOpenMenuId(null);
item.onSelect();
}}
>
<span className="sketchup-menu-check" aria-hidden="true">
{item.checked ? <Check size={12} /> : null}
</span>
<span className="sketchup-menu-label">{item.label}</span>
{item.shortcut ? (
<kbd className="sketchup-menu-shortcut">{item.shortcut}</kbd>
) : null}
</button>
),
)}
</div>
) : null}
</div>
);
})}
</div>
{/* Sağ taraf: hızlı görünüm & kısayol profili anahtarları */}
<div className="sketchup-menubar-right">
<button
type="button"
className={`sketchup-quick-chip ${prefs.showLeftToolset ? "active" : ""}`}
onClick={() => onUpdatePrefs({ showLeftToolset: !prefs.showLeftToolset })}
title="Sol Büyük Araç Setini Aç/Kapa"
aria-pressed={prefs.showLeftToolset}
>
<LayoutPanelLeft size={12} aria-hidden="true" />
<span className="hidden md:inline">Araç Seti</span>
</button>
<button
type="button"
className={`sketchup-quick-chip ${prefs.showSecondaryRibbon ? "active" : ""}`}
onClick={() => onUpdatePrefs({ showSecondaryRibbon: !prefs.showSecondaryRibbon })}
title="SnapCAD Şekil Ekleme Şeridini Aç/Kapa"
aria-pressed={prefs.showSecondaryRibbon}
>
<LayoutPanelTop size={12} aria-hidden="true" />
<span className="hidden md:inline">Üst Şerit</span>
</button>
<button
type="button"
className={`sketchup-quick-chip ${prefs.showDefaultTray ? "active" : ""}`}
onClick={() => onUpdatePrefs({ showDefaultTray: !prefs.showDefaultTray })}
title="Sağ Varsayılan Tepsiyi (Default Tray) Aç/Kapa"
aria-pressed={prefs.showDefaultTray}
>
<PanelRight size={12} aria-hidden="true" />
<span className="hidden md:inline">Varsayılan Tepsi</span>
</button>
<button
type="button"
className="sketchup-quick-chip keymap-chip"
onClick={() =>
onUpdatePrefs({
keymapProfile:
prefs.keymapProfile === "classic-sketchup" ? "snapcad-standard" : "classic-sketchup",
})
}
title="Kısayol Profilini Değiştir: SketchUp Klasik <-> SnapCAD Standart"
>
<Keyboard size={12} aria-hidden="true" />
<span>
{prefs.keymapProfile === "classic-sketchup" ? "SketchUp Klasik" : "SnapCAD Klasik"}
</span>
<ChevronRight size={11} aria-hidden="true" />
</button>
</div>
</div>
);
}
@@ -0,0 +1,251 @@
"use client";
import {
ArrowUpDown,
Axis3d,
Box,
Circle,
Compass,
Eraser,
Eye,
Focus,
Hand,
Hexagon,
Highlighter,
Layers,
Maximize2,
MousePointer2,
Move,
PaintBucket,
PenTool,
Pencil,
RotateCcw,
RotateCw,
Ruler,
Scaling,
Scissors,
Spline,
Square,
SplinePointer,
Type,
Waypoints,
ZoomIn,
Footprints,
CopyPlus,
} from "lucide-react";
import { SKETCHUP_TOOLS, type SketchUpToolId, type VisualStyleMode } from "@/lib/sketchupInterface";
export interface SketchUpToolsetProps {
activeTool: SketchUpToolId;
onSelectTool: (tool: SketchUpToolId) => void;
visualStyle: VisualStyleMode;
onSelectVisualStyle: (style: VisualStyleMode) => void;
xRayMode: boolean;
onToggleXRay: () => void;
backEdgesEnabled: boolean;
onToggleBackEdges: () => void;
onCameraPreset: (view: "isometric" | "top" | "front" | "right" | "back" | "left") => void;
}
type ToolButtonSpec = {
id: SketchUpToolId;
icon: typeof MousePointer2;
};
const TOOL_GROUPS: Array<{ label: string; items: ToolButtonSpec[] }> = [
{
label: "Temel",
items: [
{ id: "select", icon: MousePointer2 },
{ id: "make-component", icon: Box },
{ id: "paint", icon: PaintBucket },
{ id: "eraser", icon: Eraser },
],
},
{
label: "Çizim",
items: [
{ id: "line", icon: PenTool },
{ id: "freehand", icon: Pencil },
{ id: "rectangle", icon: Square },
{ id: "polygon", icon: Hexagon },
{ id: "circle", icon: Circle },
{ id: "arc", icon: Spline },
],
},
{
label: "Düzenle",
items: [
{ id: "move", icon: Move },
{ id: "push-pull", icon: ArrowUpDown },
{ id: "rotate", icon: RotateCw },
{ id: "follow-me", icon: Waypoints },
{ id: "scale", icon: Scaling },
{ id: "offset", icon: CopyPlus },
],
},
{
label: "Ölçüm",
items: [
{ id: "tape", icon: Ruler },
{ id: "protractor", icon: Compass },
{ id: "axes", icon: Axis3d },
{ id: "3d-text", icon: Type },
],
},
{
label: "Kamera",
items: [
{ id: "orbit", icon: RotateCcw },
{ id: "pan", icon: Hand },
{ id: "zoom", icon: ZoomIn },
{ id: "zoom-extents", icon: Maximize2 },
{ id: "zoom-selection", icon: Focus },
{ id: "zoom-previous", icon: SplinePointer },
{ id: "section", icon: Scissors },
{ id: "walk", icon: Footprints },
{ id: "xray", icon: Eye },
],
},
];
export function SketchUpToolset({
activeTool,
onSelectTool,
visualStyle,
onSelectVisualStyle,
xRayMode,
onToggleXRay,
backEdgesEnabled,
onToggleBackEdges,
onCameraPreset,
}: SketchUpToolsetProps) {
return (
<aside
className="sketchup-large-toolset"
role="toolbar"
aria-label="SketchUp Büyük Araç Seti (Large Tool Set)"
aria-orientation="vertical"
>
{TOOL_GROUPS.map((group) => (
<div key={group.label} className="sketchup-tool-group">
<div className="sketchup-tool-grid">
{group.items.map(({ id, icon: Icon }) => {
const meta = SKETCHUP_TOOLS[id];
const isActive = activeTool === id || (id === "xray" && xRayMode);
return (
<button
key={id}
type="button"
className={`sketchup-tool-btn ${isActive ? "active" : ""}`}
aria-label={`${meta.name} (${meta.englishName})${meta.shortcut ? ` - Kısayol: ${meta.shortcut}` : ""}`}
aria-pressed={isActive}
title={`${meta.name} (${meta.englishName})${meta.shortcut ? ` [${meta.shortcut}]` : ""}`}
onClick={() => {
if (id === "xray") {
onToggleXRay();
} else {
onSelectTool(id);
}
}}
>
<Icon size={16} strokeWidth={2} aria-hidden="true" />
{meta.shortcut ? (
<span className="sketchup-tool-key" aria-hidden="true">
{meta.shortcut === "Space" ? "␣" : meta.shortcut.replace("Shift+", "⇧").replace("Alt+", "⌥")}
</span>
) : null}
</button>
);
})}
</div>
</div>
))}
{/* Hızlı Standart Görünümler (Standard Views - Iso/Top/Front/Right/Back/Left) */}
<div className="sketchup-tool-group" role="group" aria-label="Hızlı Standart Kamera Görünümleri">
<span className="sketchup-tool-sublabel">Bakış</span>
<div className="sketchup-mini-view-grid">
{(
[
{ id: "isometric", short: "ISO", label: "İzometrik Görünüm (Home)" },
{ id: "top", short: "ÜST", label: "Üst Görünüm (5)" },
{ id: "front", short: "ÖN", label: "Ön Görünüm (1)" },
{ id: "right", short: "SAĞ", label: "Sağ Görünüm (4)" },
{ id: "back", short: "ARK", label: "Arka Görünüm (2)" },
{ id: "left", short: "SOL", label: "Sol Görünüm (3)" },
] as const
).map((v) => (
<button
key={v.id}
type="button"
className="sketchup-mini-pill"
onClick={() => onCameraPreset(v.id)}
title={v.label}
aria-label={v.label}
>
{v.short}
</button>
))}
</div>
</div>
{/* Hızlı Yüz Stilleri (Face Styles) */}
<div className="sketchup-tool-group" role="group" aria-label="Hızlı Yüz Stilleri">
<span className="sketchup-tool-sublabel">Stil</span>
<div className="sketchup-mini-view-grid">
<button
type="button"
className={`sketchup-mini-pill ${visualStyle === "wireframe" ? "active" : ""}`}
onClick={() => onSelectVisualStyle("wireframe")}
title="Tel Kafes (Wireframe)"
>
TEL
</button>
<button
type="button"
className={`sketchup-mini-pill ${visualStyle === "hidden-line" ? "active" : ""}`}
onClick={() => onSelectVisualStyle("hidden-line")}
title="Gizli Çizgi (Hidden Line)"
>
GİZ
</button>
<button
type="button"
className={`sketchup-mini-pill ${visualStyle === "shaded" ? "active" : ""}`}
onClick={() => onSelectVisualStyle("shaded")}
title="Dokulu & Gölgeli (Shaded)"
>
GÖL
</button>
<button
type="button"
className={`sketchup-mini-pill ${visualStyle === "monochrome" ? "active" : ""}`}
onClick={() => onSelectVisualStyle("monochrome")}
title="Monokrom (Monochrome)"
>
MON
</button>
<button
type="button"
className={`sketchup-mini-pill ${backEdgesEnabled ? "active" : ""}`}
onClick={onToggleBackEdges}
title="Arka Kenarları Göster/Gizle (Back Edges - K)"
aria-pressed={backEdgesEnabled}
>
<Highlighter size={11} aria-hidden="true" />
</button>
<button
type="button"
className={`sketchup-mini-pill ${xRayMode ? "active" : ""}`}
onClick={onToggleXRay}
title="X-Ray (Röntgen - X)"
aria-pressed={xRayMode}
>
<Layers size={11} aria-hidden="true" />
</button>
</div>
</div>
</aside>
);
}
+356
View File
@@ -0,0 +1,356 @@
import { createLocalId } from "@/lib/localIds";
import { normalizeSketchUpPrefs, type SketchUpWorkspacePrefs } from "@/lib/sketchupInterface";
import type { WorkplaneShape } from "@/types/sketchforge";
export interface CloudComponentSummary {
component_uid: string;
author_name: string;
title: string;
category: string;
description: string;
shapes_count: number;
is_public: boolean;
downloads_count: number;
is_owner: boolean;
updated_at: string;
}
export interface CloudComponentDetail extends CloudComponentSummary {
shapes: WorkplaneShape[];
}
export interface CloudComponentPublishInput {
component_uid?: string;
title: string;
category: string;
description?: string;
is_public?: boolean;
shapes: WorkplaneShape[];
}
export const CLOUD_COMPONENT_CATEGORIES: readonly string[] = [
"Mimari Yapı",
"Kapı & Pencere",
"Mobilya & İç Mekan",
"Mekanik & Bağlantı",
"Elektronik & Maker",
"Peyzaj & Çevre",
"Genel 3B Bileşen",
];
function cloneShapeDeep(
shape: WorkplaneShape,
makeId: (prefix: string) => string,
componentDefId?: string,
componentName?: string,
): WorkplaneShape {
const nextGrouped = shape.groupedShapes?.map((child) =>
cloneShapeDeep(child, makeId, undefined, undefined),
);
const nextSketch = shape.sketchProfile
? {
points: shape.sketchProfile.points.map((pt) => ({
...pt,
handleIn: pt.handleIn ? { ...pt.handleIn } : undefined,
handleOut: pt.handleOut ? { ...pt.handleOut } : undefined,
})),
segments: shape.sketchProfile.segments.map((seg) => ({ ...seg })),
images: shape.sketchProfile.images?.map((img) => ({ ...img })),
}
: undefined;
return {
...shape,
id: makeId("cmp"),
componentDefId: componentDefId ?? shape.componentDefId,
componentName: componentName ?? shape.componentName,
groupedShapes: nextGrouped,
sketchProfile: nextSketch,
followMe: shape.followMe ? { ...shape.followMe } : undefined,
sketchRevolve: shape.sketchRevolve ? { ...shape.sketchRevolve } : undefined,
};
}
/**
* Instantiates a set of shapes as fresh component instances shifted as a rigid
* unit so their footprint center aligns on `targetOffset` (keeping relative
* elevations and offsets between sub-parts intact).
*/
export function instantiateComponentShapes(
sourceShapes: WorkplaneShape[],
options?: {
componentDefId?: string;
componentName?: string;
targetOffset?: { x: number; z: number; elevation?: number };
createId?: (prefix: string) => string;
},
): WorkplaneShape[] {
if (!Array.isArray(sourceShapes) || sourceShapes.length === 0) {
return [];
}
const makeId = options?.createId ?? createLocalId;
const target = options?.targetOffset ?? { x: 0, z: 0, elevation: 0 };
const targetElev = target.elevation ?? 0;
let minX = Number.POSITIVE_INFINITY;
let maxX = Number.NEGATIVE_INFINITY;
let minZ = Number.POSITIVE_INFINITY;
let maxZ = Number.NEGATIVE_INFINITY;
let minY = Number.POSITIVE_INFINITY;
for (const s of sourceShapes) {
const hw = Math.max(0.5, Number(s.width || s.size || 20)) / 2;
const hd = Math.max(0.5, Number(s.depth || s.size || 20)) / 2;
const x = Number(s.x || 0);
const z = Number(s.z || 0);
const elev = Number(s.elevation || 0);
minX = Math.min(minX, x - hw);
maxX = Math.max(maxX, x + hw);
minZ = Math.min(minZ, z - hd);
maxZ = Math.max(maxZ, z + hd);
minY = Math.min(minY, elev);
}
const centerX = Number.isFinite(minX) && Number.isFinite(maxX) ? (minX + maxX) / 2 : 0;
const centerZ = Number.isFinite(minZ) && Number.isFinite(maxZ) ? (minZ + maxZ) / 2 : 0;
const baseY = Number.isFinite(minY) ? minY : 0;
const dx = target.x - centerX;
const dz = target.z - centerZ;
const dy = targetElev - baseY;
const sharedDefId =
options?.componentDefId ??
(sourceShapes.length === 1 ? sourceShapes[0].componentDefId : undefined);
return sourceShapes.map((shape) => {
const cloned = cloneShapeDeep(
shape,
makeId,
sharedDefId,
options?.componentName ?? shape.componentName,
);
return {
...cloned,
x: Number((Number(cloned.x || 0) + dx).toFixed(2)),
z: Number((Number(cloned.z || 0) + dz).toFixed(2)),
elevation: Number((Number(cloned.elevation || 0) + dy).toFixed(2)),
};
});
}
/**
* SketchUp "Make Unique" (Benzersiz Yap): splits selected instances onto a
* fresh `componentDefId` so further edits do not affect sibling instances.
*/
export function detachComponentInstance(
shapes: WorkplaneShape[],
selectedIds: string[],
makeDefId: () => string = () => createLocalId("compdef"),
): WorkplaneShape[] {
const selectedSet = new Set(selectedIds);
const newDefId = makeDefId();
return shapes.map((shape) => {
if (!selectedSet.has(shape.id) || !shape.componentDefId) {
return shape;
}
return {
...shape,
componentDefId: newDefId,
componentName: shape.componentName ? `${shape.componentName} (Benzersiz)` : undefined,
};
});
}
export async function listCloudComponents(params?: {
category?: string;
q?: string;
}): Promise<{
ok: boolean;
schema_ready?: boolean;
components: CloudComponentSummary[];
error?: string;
}> {
try {
const search = new URLSearchParams({ action: "component_list" });
if (params?.category && params.category !== "Tümü") {
search.set("category", params.category);
}
if (params?.q && params.q.trim()) {
search.set("q", params.q.trim());
}
const res = await fetch(`/cloud-api.php?${search.toString()}`, {
method: "GET",
cache: "no-store",
});
const data = (await res.json()) as {
ok?: boolean;
schema_ready?: boolean;
components?: CloudComponentSummary[];
error?: string;
};
if (!res.ok || !data.ok) {
return {
ok: false,
components: [],
error: data.error || "Bileşen listesi alınamadı.",
};
}
return {
ok: true,
schema_ready: data.schema_ready !== false,
components: Array.isArray(data.components) ? data.components : [],
};
} catch {
return {
ok: false,
components: [],
error: "YakNet 3B Bileşen Havuzuna bağlanılamadı.",
};
}
}
export async function getCloudComponent(componentUid: string): Promise<{
ok: boolean;
component?: CloudComponentDetail;
error?: string;
}> {
try {
const search = new URLSearchParams({
action: "component_get",
component_uid: componentUid,
});
const res = await fetch(`/cloud-api.php?${search.toString()}`, {
method: "GET",
cache: "no-store",
});
const data = (await res.json()) as {
ok?: boolean;
component?: CloudComponentDetail;
error?: string;
};
if (!res.ok || !data.ok || !data.component) {
return { ok: false, error: data.error || "Bileşen yüklenemedi." };
}
return { ok: true, component: data.component };
} catch {
return { ok: false, error: "Bileşen sunucudan indirilemedi." };
}
}
export async function publishCloudComponent(
input: CloudComponentPublishInput,
): Promise<{
ok: boolean;
component_uid?: string;
message?: string;
error?: string;
}> {
try {
const res = await fetch("/cloud-api.php?action=component_publish", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
action: "component_publish",
component_uid: input.component_uid,
title: input.title,
category: input.category,
description: input.description ?? "",
is_public: input.is_public ?? true,
shapes: input.shapes,
}),
});
const data = (await res.json()) as {
ok?: boolean;
component_uid?: string;
message?: string;
error?: string;
};
if (!res.ok || !data.ok) {
return { ok: false, error: data.error || "Bileşen yayınlanamadı." };
}
return {
ok: true,
component_uid: data.component_uid,
message: data.message,
};
} catch {
return { ok: false, error: "YakNet sunucusuna gönderilemedi." };
}
}
export async function deleteCloudComponent(componentUid: string): Promise<{
ok: boolean;
deleted?: boolean;
error?: string;
}> {
try {
const res = await fetch("/cloud-api.php?action=component_delete", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
action: "component_delete",
component_uid: componentUid,
}),
});
const data = (await res.json()) as {
ok?: boolean;
deleted?: boolean;
error?: string;
};
if (!res.ok || !data.ok) {
return { ok: false, error: data.error || "Bileşen silinemedi." };
}
return { ok: true, deleted: Boolean(data.deleted) };
} catch {
return { ok: false, error: "Silme isteği gönderilemedi." };
}
}
export async function getCloudUserPrefs(): Promise<{
ok: boolean;
authenticated: boolean;
prefs: SketchUpWorkspacePrefs | null;
}> {
try {
const res = await fetch("/cloud-api.php?action=prefs_get", {
method: "GET",
cache: "no-store",
});
const data = (await res.json()) as {
ok?: boolean;
authenticated?: boolean;
prefs?: unknown;
};
if (!res.ok || !data.ok) {
return { ok: false, authenticated: false, prefs: null };
}
return {
ok: true,
authenticated: Boolean(data.authenticated),
prefs: data.prefs ? normalizeSketchUpPrefs(data.prefs) : null,
};
} catch {
return { ok: false, authenticated: false, prefs: null };
}
}
export async function saveCloudUserPrefs(
prefs: SketchUpWorkspacePrefs,
): Promise<{ ok: boolean; error?: string }> {
try {
const res = await fetch("/cloud-api.php?action=prefs_save", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
action: "prefs_save",
prefs,
}),
});
const data = (await res.json()) as { ok?: boolean; error?: string };
return { ok: Boolean(res.ok && data.ok), error: data.error };
} catch {
return { ok: false, error: "Ayarlar buluta kaydedilemedi." };
}
}
+4
View File
@@ -122,6 +122,10 @@ export function sceneShape(shape: Partial<WorkplaneShape> & Pick<WorkplaneShape,
groupedBaseDepth: shape.groupedBaseDepth,
groupedBaseHeight: shape.groupedBaseHeight,
groupOperation: shape.groupOperation,
texture: shape.texture,
tag: shape.tag,
componentDefId: shape.componentDefId,
componentName: shape.componentName,
locked: shape.locked ?? false,
hidden: shape.hidden ?? false,
});
+725
View File
@@ -0,0 +1,725 @@
export type SketchUpToolId =
| "select"
| "make-component"
| "paint"
| "eraser"
| "line"
| "freehand"
| "rectangle"
| "circle"
| "polygon"
| "arc"
| "move"
| "push-pull"
| "rotate"
| "follow-me"
| "scale"
| "offset"
| "tape"
| "protractor"
| "axes"
| "3d-text"
| "orbit"
| "pan"
| "zoom"
| "zoom-extents"
| "zoom-selection"
| "zoom-previous"
| "section"
| "walk"
| "xray";
export type ViewportCursorMode =
| "select"
| "move"
| "rotate"
| "scale"
| "push-pull"
| "paint"
| "eraser"
| "orbit"
| "pan"
| "zoom"
| "tape"
| "line"
| "rectangle"
| "circle"
| "polygon"
| "arc"
| "freehand"
| "offset"
| "axes";
export type VisualStyleMode =
| "shaded"
| "wireframe"
| "hidden-line"
| "monochrome"
| "blueprint"
| "cyberpunk"
| "clay";
export type UiKeymapProfile = "classic-sketchup" | "snapcad-standard";
export type UiLayoutMode = "classic-sketchup" | "compact-modern";
export type DefaultTraySectionId =
| "entity-info"
| "outliner"
| "components"
| "materials"
| "styles"
| "tags"
| "shadows"
| "scenes"
| "instructor";
export interface SketchUpWorkspacePrefs {
layoutMode: UiLayoutMode;
keymapProfile: UiKeymapProfile;
showLeftToolset: boolean;
showDefaultTray: boolean;
showSecondaryRibbon: boolean;
skyGroundEnabled: boolean;
backEdgesEnabled: boolean;
openTraySections: DefaultTraySectionId[];
}
export const SKETCHUP_PREFS_STORAGE_KEY = "snapcad.sketchup.workspace.prefs.v1";
export const DEFAULT_SKETCHUP_PREFS: SketchUpWorkspacePrefs = {
layoutMode: "classic-sketchup",
keymapProfile: "classic-sketchup",
showLeftToolset: true,
showDefaultTray: true,
showSecondaryRibbon: false,
skyGroundEnabled: false,
backEdgesEnabled: false,
openTraySections: ["entity-info", "outliner", "styles", "materials", "instructor"],
};
export function normalizeSketchUpPrefs(raw: unknown): SketchUpWorkspacePrefs {
if (!raw || typeof raw !== "object") {
return { ...DEFAULT_SKETCHUP_PREFS, openTraySections: [...DEFAULT_SKETCHUP_PREFS.openTraySections] };
}
const src = raw as Partial<SketchUpWorkspacePrefs>;
const layoutMode: UiLayoutMode =
src.layoutMode === "compact-modern" ? "compact-modern" : "classic-sketchup";
const keymapProfile: UiKeymapProfile =
src.keymapProfile === "snapcad-standard" ? "snapcad-standard" : "classic-sketchup";
const validSections = new Set<DefaultTraySectionId>([
"entity-info",
"outliner",
"components",
"materials",
"styles",
"tags",
"shadows",
"scenes",
"instructor",
]);
const openTraySections = Array.isArray(src.openTraySections)
? Array.from(
new Set(src.openTraySections.filter((s): s is DefaultTraySectionId => validSections.has(s))),
)
: [...DEFAULT_SKETCHUP_PREFS.openTraySections];
return {
layoutMode,
keymapProfile,
showLeftToolset: typeof src.showLeftToolset === "boolean" ? src.showLeftToolset : true,
showDefaultTray: typeof src.showDefaultTray === "boolean" ? src.showDefaultTray : true,
showSecondaryRibbon:
typeof src.showSecondaryRibbon === "boolean" ? src.showSecondaryRibbon : layoutMode === "compact-modern",
skyGroundEnabled: typeof src.skyGroundEnabled === "boolean" ? src.skyGroundEnabled : false,
backEdgesEnabled: typeof src.backEdgesEnabled === "boolean" ? src.backEdgesEnabled : false,
openTraySections: openTraySections.length > 0 ? openTraySections : ["entity-info", "instructor"],
};
}
export interface SketchUpToolMeta {
id: SketchUpToolId;
name: string;
englishName: string;
shortcut: string;
vcbLabel: string;
hint: string;
instructorSteps: string[];
category: "Ana" | "Çizim" | "Düzenle" | "Ölçüm" | "Kamera";
}
export const SKETCHUP_TOOLS: Record<SketchUpToolId, SketchUpToolMeta> = {
select: {
id: "select",
name: "Seçim",
englishName: "Select",
shortcut: "Space",
vcbLabel: "Ölçü",
hint: "Nesne seçmek için tıklayın. Çoklu seçim için Shift basılı tutun veya boşlukta sürükleyin.",
instructorSteps: [
"Tek tık: Nesneyi seçer ve Öğe Bilgisi panelini açar.",
"Shift + Tık: Seçime ekle veya çıkar.",
"Ekran okuyucu (NVDA): [ ve ] tuşlarıyla nesneler arasında gezin.",
],
category: "Ana",
},
"make-component": {
id: "make-component",
name: "Bileşen Oluştur",
englishName: "Make Component",
shortcut: "G",
vcbLabel: "Ad",
hint: "Seçili nesneleri ortak güncellenen akıllı bileşene dönüştürür (G). Birini değiştirince tüm kopyalar güncellenir.",
instructorSteps: [
"En az 1 nesne seçip G tuşuna basın.",
"Çoğaltılan bileşen kopyaları aynı boyut ve malzemeyi paylaşır.",
"Buluta yüklemek için Bileşenler tepsisinden 'Havuzu Paylaş'ı kullanın.",
],
category: "Ana",
},
paint: {
id: "paint",
name: "Boya Kovası",
englishName: "Paint Bucket",
shortcut: "B",
vcbLabel: "Doku",
hint: "Malzeme veya mimari doku uygulamak için nesneye tıklayın. Damlalık (örnekleme) için Alt + Tık.",
instructorSteps: [
"Sağdaki Malzemeler panelinden doku (Tuğla, Ahşap, Cam, Beton vb.) ve renk seçin.",
"Boya uygulamak istediğiniz 3B nesneye tıklayın.",
"Alt basılı tutup tıklayarak mevcut nesnenin malzemesini kopyalayın.",
],
category: "Ana",
},
eraser: {
id: "eraser",
name: "Silgi",
englishName: "Eraser",
shortcut: "E",
vcbLabel: "Sil",
hint: "Silmek istediğiniz 3B nesneye sol tıklayın (Ctrl+Z ile geri alınabilir).",
instructorSteps: [
"Kaldırmak istediğiniz şeklin üzerine tıklayın.",
"Yanlışlıkla sildiyseniz Ctrl+Z ile hemen geri alın.",
],
category: "Ana",
},
line: {
id: "line",
name: "Çizgi (Kalem)",
englishName: "Line",
shortcut: "L",
vcbLabel: "Uzunluk",
hint: "2B/3B profil çizimi başlatır. Kapalı şekil çizip tek tıkla katı 3B hacme dönüştürün.",
instructorSteps: [
"Noktalara tıklayarak sürekli çizgi segmentleri oluşturun.",
"Sağ Ok: X Ekseni (Kırmızı), Sol Ok: Z Ekseni (Yeşil) kilidi.",
"Profili kapatıp 'Çizimi 3B'ye Dönüştür' butonuna basın.",
],
category: "Çizim",
},
freehand: {
id: "freehand",
name: "Serbest / Eğri",
englishName: "Freehand / Curve",
shortcut: "",
vcbLabel: "Eğri",
hint: "Akıcı Bezier ve organik profiller çizmek için 2B eskiz stüdyosunu açar.",
instructorSteps: [
"Eğri kontrol noktalarını tıklayarak serbest form oluşturun.",
"Tamamlandığında otomatik olarak katı veya döndürülmüş 3B modele çevrilir.",
],
category: "Çizim",
},
rectangle: {
id: "rectangle",
name: "Dikdörtgen",
englishName: "Rectangle",
shortcut: "R",
vcbLabel: "Boyutlar (G,D)",
hint: "Çalışma düzleminde iki köşeyi sürükleyin; ardından ölçü kutusuna '100,60' yazıp Enter'a basın.",
instructorSteps: [
"Zeminde ilk köşeye basılı tutup ikinci köşeye sürükleyin ve bırakın.",
"Alt ölçü kutusuna (VCB) '100,60' yazıp Enter ile tam milimetre boyut verin.",
"Ardından İt/Çek (P) ile yüksekliğini ayarlayın.",
],
category: "Çizim",
},
circle: {
id: "circle",
name: "Daire",
englishName: "Circle",
shortcut: "C",
vcbLabel: "Yarıçap",
hint: "Merkezi tıklayıp dışa sürükleyerek daire/silindir oluşturun. Yarıçap için VCB'ye sayı yazın.",
instructorSteps: [
"Merkez noktadan kenara doğru sürükleyin.",
"Ölçü kutusuna yarıçapı (örn. '25') yazıp Enter tuşuna basın.",
],
category: "Çizim",
},
polygon: {
id: "polygon",
name: "Çokgen",
englishName: "Polygon",
shortcut: "",
vcbLabel: "Yarıçap",
hint: "6 kenarlı çokgen prizma çizmek için merkezden dışa sürükleyin.",
instructorSteps: [
"Merkez noktadan sürükleyerek altıgen prizmayı yerleştirin.",
"Sonrasında Ölçü kutusuna yarıçap girerek tam boyutlandırın.",
],
category: "Çizim",
},
arc: {
id: "arc",
name: "Yay (Arc)",
englishName: "2-Point Arc",
shortcut: "A",
vcbLabel: "Çıkıntı",
hint: "Kemer ve yumuşak geçişler için eğri eskiz modunu açar.",
instructorSteps: [
"Başlangıç, bitiş ve bombelik noktalarını tıklayın.",
"Yay kapandığında kemer/tonoz hacmi olarak ekstrüde edilebilir.",
],
category: "Çizim",
},
move: {
id: "move",
name: "Taşı",
englishName: "Move",
shortcut: "M",
vcbLabel: "Mesafe / *N / /N",
hint: "Seçili nesneyi sürükleyin. Kopya dizisi için hemen VCB'ye '*5' (çoğalt) veya '/4' (böl) yazın!",
instructorSteps: [
"Nesneyi tutup çalışma düzleminde istediğiniz konuma sürükleyin.",
"Doğrusal Kopya: Taşıma sonrası Ölçü kutusuna '*5' yazıp Enter = 5 eşit kopya!",
"Eşit Bölme: İki uç arası kopyalamadan sonra '/4' yazıp Enter = araya 4 parça!",
],
category: "Düzenle",
},
"push-pull": {
id: "push-pull",
name: "İt / Çek",
englishName: "Push/Pull",
shortcut: "P",
vcbLabel: "Uzatma",
hint: "Herhangi bir 3B yüzeye tıklayıp yukarı/dışa sürükleyin. Tam ölçü için VCB'ye '80' yazıp Enter'a basın.",
instructorSteps: [
"3B şeklin üst veya yan yüzeyine sol tıklayıp sürükleyin.",
"Fareyi bırakmadan veya hemen ardından Ölçü kutusuna mesafe girip Enter'a basın.",
],
category: "Düzenle",
},
rotate: {
id: "rotate",
name: "Döndür",
englishName: "Rotate",
shortcut: "Q",
vcbLabel: "Açı (°)",
hint: "Açıölçer tekerleğini çevirin veya VCB kutusuna '45' yazıp Enter ile döndürün (Dairesel dizi: '*6').",
instructorSteps: [
"Seçili nesnenin dönme halkalarını sürükleyin.",
"Ölçü kutusuna '45' veya '90' yazarak hassas açı döndürmesi uygulayın.",
],
category: "Düzenle",
},
"follow-me": {
id: "follow-me",
name: "Beni Takip Et",
englishName: "Follow Me",
shortcut: "",
vcbLabel: "Süpürme",
hint: "Bir kesiti seçili yol boyunca süpürerek korkuluk, boru veya çatı kornişi üretir.",
instructorSteps: [
"Açılan panelden profil şeklini (Daire/Dikdörtgen/L) ve yolu seçin.",
"Tek tıkla parametrik süpürülmüş 3B model oluşturun.",
],
category: "Düzenle",
},
scale: {
id: "scale",
name: "Ölçekle",
englishName: "Scale",
shortcut: "S",
vcbLabel: "Ölçek Katsayısı",
hint: "Tutmaçları sürükleyin veya VCB'ye '1.5' (büyüt) / '0.5' (yarıya indir) yazıp Enter'a basın.",
instructorSteps: [
"Beyaz köşe tutmaçlarıyla nesneyi oranlı/oransız ölçekleyin.",
"VCB kutusuna oran çarpanı (örn. '2' veya '0.75') girin.",
],
category: "Düzenle",
},
offset: {
id: "offset",
name: "Ofset",
englishName: "Offset",
shortcut: "F",
vcbLabel: "İç / Dış Ofset",
hint: "Seçili nesneden duvar kalınlığı/çerçeve kopyası çıkarır (veya 2B eskizde konturu içe/dışa kaydırır).",
instructorSteps: [
"Bir kutu veya eskiz seçip Ofset (F) aracına basın.",
"Ölçü kutusuna duvar kalınlığı (örn. '15' veya '-15') yazarak iç/dış çerçeve oluşturun.",
],
category: "Düzenle",
},
tape: {
id: "tape",
name: "Şerit Metre",
englishName: "Tape Measure",
shortcut: "T",
vcbLabel: "Mesafe",
hint: "İki nokta arası mesafe ölçer ve mimari hizalama kılavuz çizgisi (Guide) ekler.",
instructorSteps: [
"Sahne üzerinde iki noktayı seçerek hassas mm mesafesi okuyun.",
"Sürekli hizalama çizgisi eklemek için kılavuz araçlarını kullanın.",
],
category: "Ölçüm",
},
protractor: {
id: "protractor",
name: "İletki (Açı)",
englishName: "Protractor",
shortcut: "",
vcbLabel: "Eğim Açısı",
hint: "Çatı eğimi ve rampa için 30° / 45° / 60° açılı kılavuz çizgisi ekler.",
instructorSteps: [
"Her tıklamada sırasıyla 30°, 45°, 60° açılı mimari kılavuz ekler.",
"Hassas açı için VCB'ye değer (örn. '22.5') girip Enter'a basın.",
],
category: "Ölçüm",
},
axes: {
id: "axes",
name: "Eksenler",
englishName: "Axes",
shortcut: "W",
vcbLabel: "Çalışma Düzlemi",
hint: "Herhangi bir eğimli veya dik yüzeyi geçici çalışma düzlemi (X/Y/Z ekseni) olarak ayarlar.",
instructorSteps: [
"Üzerine yeni şekil koymak istediğiniz 3B yüzeyin üstüne tıklayın.",
"Zemine sıfırlamak için boşluğa tıklayın veya ESC'ye basın.",
],
category: "Ölçüm",
},
"3d-text": {
id: "3d-text",
name: "3B Metin",
englishName: "3D Text",
shortcut: "",
vcbLabel: "Yükseklik",
hint: "Çalışma düzlemine kabartmalı 3B mimari tabela/yazı ekler.",
instructorSteps: [
"Sağ denetçiden yazı içeriğini ve yazı tipini (Sans, Serif, Monospace) özelleştirin.",
],
category: "Çizim",
},
orbit: {
id: "orbit",
name: "Yörünge (Orbit)",
englishName: "Orbit",
shortcut: "O",
vcbLabel: "Kamera",
hint: "Sol fare tuşunu sürükleyerek model etrafında 360° dönün. (Sağ veya Orta tuş her araçta da çalışır)",
instructorSteps: [
"Sol tuşa basılı tutarak sahne etrafında yörünge dönüşü yapın.",
"Shift + Sürükle ile geçici Kaydırma (Pan) yapabilirsiniz.",
],
category: "Kamera",
},
pan: {
id: "pan",
name: "Kaydır (Pan)",
englishName: "Pan",
shortcut: "H",
vcbLabel: "Kaydırma",
hint: "Sol fare tuşunu sürükleyerek kamerayı yatay/dikey kaydırın.",
instructorSteps: [
"Görüş açısını bozmadan çalışma alanını sağa/sola/yukarı kaydırır.",
],
category: "Kamera",
},
zoom: {
id: "zoom",
name: "Yakınlaştır",
englishName: "Zoom",
shortcut: "Z",
vcbLabel: "Görüş Açısı",
hint: "Yukarı/aşağı sürükleyerek yakınlaştırın veya uzaklaştırın (Fare tekerleği her an çalışır).",
instructorSteps: [
"Sol tuşla yukarı sürükleyin: Yaklaş. Aşağı sürükleyin: Uzaklaş.",
],
category: "Kamera",
},
"zoom-extents": {
id: "zoom-extents",
name: "Ekrana Sığdır",
englishName: "Zoom Extents",
shortcut: "Shift+Z",
vcbLabel: "Sığdır",
hint: "Tüm modeli tek tıkla tam ekranın ortasına odaklar.",
instructorSteps: ["Tüm sahnedeki görünür nesneleri çerçeveler."],
category: "Kamera",
},
"zoom-selection": {
id: "zoom-selection",
name: "Seçileni Çerçevele",
englishName: "Zoom Selection",
shortcut: "Alt+Z",
vcbLabel: "Odak",
hint: "Sadece seçili nesneyi yakınlaştırarak odaklar.",
instructorSteps: ["Seçili nesne(ler)in detaylarına kamerayı yumuşakça uçurur."],
category: "Kamera",
},
"zoom-previous": {
id: "zoom-previous",
name: "Önceki Görünüm",
englishName: "Previous View",
shortcut: "Alt+P",
vcbLabel: "Önceki",
hint: "Son kamera açısına geri döner.",
instructorSteps: ["Kamera geçmişinde bir adım geriye gider."],
category: "Kamera",
},
section: {
id: "section",
name: "Kesit Düzlemi",
englishName: "Section Plane",
shortcut: "",
vcbLabel: "Kesit",
hint: "Binanın iç planını görmek için canlı yatay/dikey mimari kesit düzlemini açar.",
instructorSteps: [
"Aktif olduğunda bina yüksekliği boyunca sürgüyü kaydırarak kat planlarını inceleyin.",
],
category: "Kamera",
},
walk: {
id: "walk",
name: "İçinde Yürü",
englishName: "Walk",
shortcut: "",
vcbLabel: "Yürüyüş",
hint: "1. şahıs insan gözü seviyesinde (1.68m) WASD tuşlarıyla bina içinde yürüyün.",
instructorSteps: [
"W/A/S/D ile yürüyün, fareyi sürükleyerek etrafa bakın, ESC ile çıkın.",
],
category: "Kamera",
},
xray: {
id: "xray",
name: "Röntgen (X-Ray)",
englishName: "X-Ray",
shortcut: "X",
vcbLabel: "X-Ray",
hint: "Katı duvarları yarı saydam yaparak iç tesisat ve taşıyıcı kolonları görmenizi sağlar.",
instructorSteps: ["X tuşu veya simgesi ile açıp kapatabilirsiniz."],
category: "Kamera",
},
};
export type VcbCommand =
| { kind: "empty" }
| { kind: "invalid"; raw: string }
| { kind: "array-multiply"; count: number }
| { kind: "array-divide"; count: number }
| { kind: "dimensions-2d"; width: number; depth: number }
| { kind: "dimensions-3d"; width: number; depth: number; height: number }
| { kind: "angle"; degrees: number }
| { kind: "single-number"; value: number };
/**
* Parses SketchUp-style Measurements Box (VCB) input strings.
* Supports:
* - `*5`, `x5`, `5x`, `5*` -> linear/polar array repeat copy (array-multiply)
* - `/5` -> divide interval into N copies (array-divide)
* - `100,50` or `100;50` or `100x50` -> 2D rectangle/size (dimensions-2d)
* - `100,50,30` or `100;50;30` -> 3D box (dimensions-3d)
* - `45°` or `45deg` -> explicit angle
* - `50`, `12.5`, `-15`, `2.5cm` -> single signed number (in mm)
*/
export function parseVcbInput(
rawInput: string,
options?: { prefer2dDimensions?: boolean },
): VcbCommand {
const raw = rawInput.trim();
if (!raw) return { kind: "empty" };
// Array multiply: *5, x5, X5, 5x, 5*
const mulPrefix = raw.match(/^[xX*]\s*(\d+)$/);
if (mulPrefix) {
const count = parseInt(mulPrefix[1], 10);
if (count >= 1 && count <= 100) return { kind: "array-multiply", count };
}
const mulSuffix = raw.match(/^(\d+)\s*[xX*]$/);
if (mulSuffix) {
const count = parseInt(mulSuffix[1], 10);
if (count >= 1 && count <= 100) return { kind: "array-multiply", count };
}
// Array divide: /5
const divMatch = raw.match(/^\/\s*(\d+)$/);
if (divMatch) {
const count = parseInt(divMatch[1], 10);
if (count >= 1 && count <= 100) return { kind: "array-divide", count };
}
// Angle suffix: 45° or 45deg or 45derece
const angleMatch = raw.match(/^([+-]?\d+(?:[.,]\d+)?)\s*(?:°|deg|derece)$/i);
if (angleMatch) {
const degrees = parseFloat(angleMatch[1].replace(",", "."));
if (Number.isFinite(degrees)) return { kind: "angle", degrees };
}
// 3D / 2D dimensions with x: `100x50` or `100 x 50 x 30`
const xSplit = raw.match(/^([+-]?\d+(?:[.,]\d+)?)\s*[xX]\s*([+-]?\d+(?:[.,]\d+)?)(?:\s*[xX]\s*([+-]?\d+(?:[.,]\d+)?))?$/);
if (xSplit) {
const w = parseFloat(xSplit[1].replace(",", "."));
const d = parseFloat(xSplit[2].replace(",", "."));
if (xSplit[3]) {
const h = parseFloat(xSplit[3].replace(",", "."));
if (w > 0 && d > 0 && h > 0) return { kind: "dimensions-3d", width: w, depth: d, height: h };
} else if (w > 0 && d > 0) {
return { kind: "dimensions-2d", width: w, depth: d };
}
}
// Semicolon separator (SketchUp TR/EU standard): `100;50` or `100;50;30`
const semiParts = raw.split(";").map((s) => s.trim()).filter(Boolean);
if (semiParts.length >= 2 && semiParts.length <= 3) {
const nums = semiParts.map((p) => parseFloat(p.replace(",", ".")));
if (nums.every((n) => Number.isFinite(n) && n > 0)) {
if (nums.length === 3) return { kind: "dimensions-3d", width: nums[0], depth: nums[1], height: nums[2] };
return { kind: "dimensions-2d", width: nums[0], depth: nums[1] };
}
}
// Comma + space separator (always two/three dims): `100, 50` or `100, 50, 30`
const commaSpaceParts = raw.split(/,\s+/).map((s) => s.trim()).filter(Boolean);
if (commaSpaceParts.length >= 2 && commaSpaceParts.length <= 3) {
const nums = commaSpaceParts.map((p) => parseFloat(p));
if (nums.every((n) => Number.isFinite(n) && n > 0)) {
if (nums.length === 3) return { kind: "dimensions-3d", width: nums[0], depth: nums[1], height: nums[2] };
return { kind: "dimensions-2d", width: nums[0], depth: nums[1] };
}
}
const allCommaParts = raw.split(",").map((s) => s.trim()).filter(Boolean);
if (allCommaParts.length === 3) {
const nums = allCommaParts.map((p) => parseFloat(p));
if (nums.every((n) => Number.isFinite(n) && n > 0)) {
return { kind: "dimensions-3d", width: nums[0], depth: nums[1], height: nums[2] };
}
}
if (options?.prefer2dDimensions && allCommaParts.length === 2) {
const w = parseFloat(allCommaParts[0]);
const d = parseFloat(allCommaParts[1]);
if (Number.isFinite(w) && Number.isFinite(d) && w > 0 && d > 0) {
return { kind: "dimensions-2d", width: w, depth: d };
}
}
// Unit conversion helper: `2m` -> 2000mm, `50cm` -> 500mm, `50mm` -> 50mm
const unitMatch = raw.match(/^([+-]?\d+(?:[.,]\d+)?)\s*(mm|cm|m)?$/i);
if (unitMatch) {
const base = parseFloat(unitMatch[1].replace(",", "."));
const unit = (unitMatch[2] ?? "mm").toLowerCase();
const factor = unit === "m" ? 1000 : unit === "cm" ? 10 : 1;
if (Number.isFinite(base)) {
return { kind: "single-number", value: Number((base * factor).toFixed(4)) };
}
}
return { kind: "invalid", raw };
}
export function mapToolToCursorMode(tool: SketchUpToolId): ViewportCursorMode {
switch (tool) {
case "orbit":
return "orbit";
case "pan":
return "pan";
case "zoom":
return "zoom";
case "eraser":
return "eraser";
case "paint":
return "paint";
case "push-pull":
return "push-pull";
case "move":
return "move";
case "rotate":
return "rotate";
case "scale":
return "scale";
case "offset":
return "offset";
case "tape":
return "tape";
case "line":
return "line";
case "rectangle":
return "rectangle";
case "circle":
return "circle";
case "polygon":
return "polygon";
case "arc":
return "arc";
case "freehand":
return "freehand";
case "axes":
return "axes";
default:
return "select";
}
}
export const VISUAL_STYLE_OPTIONS: Array<{
id: VisualStyleMode;
label: string;
description: string;
swatch: string;
}> = [
{
id: "shaded",
label: "Dokulu & Gölgeli (Shaded with Textures)",
description: "Gerçekçi malzemeler, renkler ve güneş gölgesi",
swatch: "linear-gradient(135deg, #38bdf8, #b45309)",
},
{
id: "monochrome",
label: "Monokrom (Monochrome)",
description: "Saf beyaz/alçı yüzeylerle saf form ve yüzey kontrolü",
swatch: "linear-gradient(135deg, #f8fafc, #cbd5e1)",
},
{
id: "hidden-line",
label: "Gizli Çizgi (Hidden Line)",
description: "Mimari pafta görünümlü keskin siyah konturlar ve beyaz yüzeyler",
swatch: "linear-gradient(135deg, #ffffff 70%, #0f172a 100%)",
},
{
id: "wireframe",
label: "Tel Kafes (Wireframe)",
description: "Tüm yüzeyleri gizler, sadece yapısal tel kafesi gösterir",
swatch: "repeating-linear-gradient(45deg, #0f172a, #0f172a 2px, transparent 2px, transparent 6px)",
},
{
id: "blueprint",
label: "Mimari Ozalit (Blueprint)",
description: "Klasik lacivert teknik çizim kağıdı & camgöbeği çizgiler",
swatch: "#0a2540",
},
{
id: "clay",
label: "Sıcak Kil (Clay Render)",
description: "Stüdyo maket kili görünümü",
swatch: "#d6c8b4",
},
{
id: "cyberpunk",
label: "Matrix (Cyberpunk)",
description: "Yüksek kontrast karanlık neon tel mod",
swatch: "#050914",
},
];
+4
View File
@@ -298,6 +298,10 @@ export function workplaneShapesEqual(a: WorkplaneShape, b: WorkplaneShape) {
a.groupedBaseDepth === b.groupedBaseDepth &&
a.groupedBaseHeight === b.groupedBaseHeight &&
a.groupOperation === b.groupOperation &&
a.texture === b.texture &&
a.tag === b.tag &&
a.componentDefId === b.componentDefId &&
a.componentName === b.componentName &&
a.locked === b.locked &&
a.hidden === b.hidden
);