Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
release: SnapCAD Studio 1.0.11 (Mimari BIM & Metraj Studyosu, IFC4 ihraci, canli guncelleme ilerlemesi, YakNet SSO iyilestirmesi)
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
Build and Push Docker Images / build (push) Canceled after 0s
Desktop Release / Build linux desktop (push) Canceled after 0s
Desktop Release / Build windows desktop (push) Canceled after 0s
Desktop Release / Attach packages to release (push) Canceled after 0s
CI / Typecheck and unit tests (push) Canceled after 0s
Desktop Release / Build macos desktop (push) Canceled after 0s
This commit is contained in:
+291
-18
@@ -48,6 +48,8 @@ let updateCheckInFlight = false;
|
||||
let manualUpdateCheck = false;
|
||||
let downloadedUpdateReady = false;
|
||||
let updateInstallRequested = false;
|
||||
let updatePrepareInFlight = null;
|
||||
let pendingUpdateInstallAfterSave = false;
|
||||
let lastUpdateCheckResult = null;
|
||||
let lastUpdateCheckError = "";
|
||||
let pendingOpenFilePath = null;
|
||||
@@ -58,6 +60,24 @@ const desktopCloudCookies = new Map();
|
||||
let pendingOAuthServer = null;
|
||||
let pendingOAuthTimeout = null;
|
||||
let desktopMenuBuilt = false;
|
||||
const VALID_ACTIVE_WORK_KINDS = new Set([
|
||||
"none",
|
||||
"3d-project",
|
||||
"drawing-studio",
|
||||
"circuits-studio",
|
||||
"codeblocks-studio",
|
||||
]);
|
||||
let activeWorkState = {
|
||||
hasOpenWork: false,
|
||||
workKind: "none",
|
||||
projectName: null,
|
||||
shapeCount: 0,
|
||||
hasDiskFile: false,
|
||||
diskFileName: null,
|
||||
hasUnsavedDiskChanges: false,
|
||||
pendingLocalSaveCount: 0,
|
||||
};
|
||||
const pendingUpdatePrepareResolvers = new Map();
|
||||
const VALID_VISUAL_STYLES = new Set([
|
||||
"shaded",
|
||||
"wireframe",
|
||||
@@ -644,6 +664,14 @@ function setUpdateState(patch = {}) {
|
||||
};
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send("snapcad:update-state", { ...updateState });
|
||||
if (updateState.status === "downloading") {
|
||||
const pct = Math.max(0, Math.min(100, Number(updateState.progressPercent || 0)));
|
||||
mainWindow.setProgressBar(pct / 100);
|
||||
} else if (updateState.status === "checking" && updateInstallRequested) {
|
||||
mainWindow.setProgressBar(2);
|
||||
} else {
|
||||
mainWindow.setProgressBar(-1);
|
||||
}
|
||||
}
|
||||
return { ...updateState };
|
||||
}
|
||||
@@ -666,10 +694,101 @@ function desktopUpdatePayload(result = lastUpdateCheckResult, errorMessage = las
|
||||
};
|
||||
}
|
||||
|
||||
function sanitizeActiveWorkState(raw) {
|
||||
const input = raw && typeof raw === "object" ? raw : {};
|
||||
const workKind =
|
||||
typeof input.workKind === "string" && VALID_ACTIVE_WORK_KINDS.has(input.workKind)
|
||||
? input.workKind
|
||||
: "none";
|
||||
const projectName =
|
||||
typeof input.projectName === "string" && input.projectName.trim()
|
||||
? input.projectName.replace(/[\r\n\t\u0000-\u001f\u007f]+/g, " ").trim().slice(0, 140)
|
||||
: null;
|
||||
const diskFileName =
|
||||
typeof input.diskFileName === "string" && input.diskFileName.trim()
|
||||
? input.diskFileName.replace(/[\r\n\t\u0000-\u001f\u007f]+/g, " ").trim().slice(0, 140)
|
||||
: null;
|
||||
const shapeCount = Number.isFinite(Number(input.shapeCount)) ? Math.max(0, Math.round(Number(input.shapeCount))) : 0;
|
||||
const pendingLocalSaveCount = Number.isFinite(Number(input.pendingLocalSaveCount))
|
||||
? Math.max(0, Math.round(Number(input.pendingLocalSaveCount)))
|
||||
: 0;
|
||||
return {
|
||||
hasOpenWork: Boolean(input.hasOpenWork) && workKind !== "none",
|
||||
workKind,
|
||||
projectName,
|
||||
shapeCount,
|
||||
hasDiskFile: Boolean(input.hasDiskFile),
|
||||
diskFileName,
|
||||
hasUnsavedDiskChanges: Boolean(input.hasUnsavedDiskChanges),
|
||||
pendingLocalSaveCount,
|
||||
};
|
||||
}
|
||||
|
||||
function sanitizePrepareBeforeUpdateResult(raw) {
|
||||
const base = sanitizeActiveWorkState(raw);
|
||||
const input = raw && typeof raw === "object" ? raw : {};
|
||||
const cloudStatusText =
|
||||
typeof input.cloudStatusText === "string" && input.cloudStatusText.trim()
|
||||
? input.cloudStatusText.trim().slice(0, 220)
|
||||
: desktopAuthSession?.user
|
||||
? "YakNet Bulut senkronizasyonu tamamlanamadı."
|
||||
: "YakNet oturumu açık değil (yalnızca yerel depolamaya kaydedilir).";
|
||||
return {
|
||||
...base,
|
||||
localSaved: typeof input.localSaved === "boolean" ? input.localSaved : base.pendingLocalSaveCount === 0,
|
||||
cloudAttempted: Boolean(input.cloudAttempted),
|
||||
cloudSynced: Boolean(input.cloudSynced),
|
||||
cloudStatusText,
|
||||
};
|
||||
}
|
||||
|
||||
async function requestRendererPrepareBeforeUpdate(timeoutMs = 8500) {
|
||||
const fallback = sanitizePrepareBeforeUpdateResult({
|
||||
...activeWorkState,
|
||||
localSaved: !isDocumentDirty && activeWorkState.pendingLocalSaveCount === 0,
|
||||
cloudAttempted: false,
|
||||
cloudSynced: false,
|
||||
cloudStatusText: desktopAuthSession?.user
|
||||
? "Yerel değişiklikler kuyruklandı; YakNet Bulut durumu doğrulanamadı."
|
||||
: "YakNet oturumu açık değil (yalnızca yerel depolamaya kaydedilir).",
|
||||
});
|
||||
|
||||
if (!mainWindow || mainWindow.isDestroyed() || mainWindow.webContents.isLoadingMainFrame()) {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
const requestId = crypto.randomBytes(12).toString("hex");
|
||||
return new Promise((resolve) => {
|
||||
const timer = setTimeout(() => {
|
||||
pendingUpdatePrepareResolvers.delete(requestId);
|
||||
resolve(fallback);
|
||||
}, timeoutMs);
|
||||
timer.unref?.();
|
||||
|
||||
pendingUpdatePrepareResolvers.set(requestId, (result) => {
|
||||
clearTimeout(timer);
|
||||
pendingUpdatePrepareResolvers.delete(requestId);
|
||||
resolve(result);
|
||||
});
|
||||
|
||||
try {
|
||||
mainWindow.webContents.send("snapcad:prepare-before-update", requestId);
|
||||
} catch {
|
||||
clearTimeout(timer);
|
||||
pendingUpdatePrepareResolvers.delete(requestId);
|
||||
resolve(fallback);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function installDownloadedUpdate() {
|
||||
if (!downloadedUpdateReady) return;
|
||||
pendingUpdateInstallAfterSave = false;
|
||||
explicitQuit = true;
|
||||
isQuitting = true;
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.setProgressBar(-1);
|
||||
}
|
||||
stopPackagedWebServer();
|
||||
if (tray) {
|
||||
try {
|
||||
@@ -682,6 +801,98 @@ function installDownloadedUpdate() {
|
||||
setImmediate(() => autoUpdater.quitAndInstall(false, true));
|
||||
}
|
||||
|
||||
async function prepareAndInstallDownloadedUpdate() {
|
||||
if (!downloadedUpdateReady) return { started: false };
|
||||
if (updatePrepareInFlight) return updatePrepareInFlight;
|
||||
|
||||
updatePrepareInFlight = (async () => {
|
||||
const prep = await requestRendererPrepareBeforeUpdate();
|
||||
const has3dProject = prep.workKind === "3d-project";
|
||||
const isSecondaryStudio =
|
||||
prep.workKind === "drawing-studio" ||
|
||||
prep.workKind === "circuits-studio" ||
|
||||
prep.workKind === "codeblocks-studio";
|
||||
|
||||
if (!has3dProject && !isSecondaryStudio && !isDocumentDirty) {
|
||||
installDownloadedUpdate();
|
||||
return { started: true };
|
||||
}
|
||||
|
||||
showMainWindow();
|
||||
|
||||
if (isSecondaryStudio) {
|
||||
const studioLabel =
|
||||
prep.workKind === "drawing-studio"
|
||||
? "Teknik Çizim Stüdyosu"
|
||||
: prep.workKind === "circuits-studio"
|
||||
? "Elektronik Devreler Stüdyosu"
|
||||
: "Kod Blokları Stüdyosu";
|
||||
const { response } = await dialog.showMessageBox(visibleDialogParent(), {
|
||||
type: "warning",
|
||||
buttons: ["İptal (Önce Çalışmamı Dışa Aktarayım)", "Yine de Güncelle ve Yeniden Başlat"],
|
||||
defaultId: 0,
|
||||
cancelId: 0,
|
||||
noLink: true,
|
||||
title: `Açık Çalışma Uyarısı — ${APP_DISPLAY_NAME}`,
|
||||
message: `${studioLabel} içinde açık bir çalışma var.`,
|
||||
detail: [
|
||||
"Teknik Çizim, Devreler ve Kod Blokları çalışma alanları buluta otomatik olarak anlık yedeklenmez.",
|
||||
"Güncelleme için uygulama yeniden başlatılmadan önce çalışmanızı dışa aktarmanız önerilir.",
|
||||
].join("\n"),
|
||||
});
|
||||
if (response === 1) {
|
||||
isDocumentDirty = false;
|
||||
installDownloadedUpdate();
|
||||
return { started: true };
|
||||
}
|
||||
updateInstallRequested = false;
|
||||
return { started: false, canceled: true };
|
||||
}
|
||||
|
||||
const label = prep.projectName || "Açık 3B Proje";
|
||||
const detailLines = [
|
||||
`• Yerel uygulama depolaması (IndexedDB): ${prep.localSaved ? "Son değişiklikler kaydedildi." : "Bekleyen yerel yazma tamamlanamadı."}`,
|
||||
`• YakNet Bulut: ${prep.cloudStatusText}`,
|
||||
prep.hasDiskFile && prep.hasUnsavedDiskChanges
|
||||
? `• "${prep.diskFileName || label}" dosyasında henüz diske yazılmamış değişiklikler var.`
|
||||
: "• İsterseniz yeni sürüm kurulmadan önce çalışmanızı .skf proje dosyası olarak da kaydedebilirsiniz.",
|
||||
"",
|
||||
"Güncelleme kurulmadan önce projenizi .skf dosyasına kaydetmek ister misiniz?",
|
||||
];
|
||||
|
||||
const { response } = await dialog.showMessageBox(visibleDialogParent(), {
|
||||
type: "question",
|
||||
buttons: ["Kaydet (.skf) ve Güncelle", "Kaydetmeden Güncelle ve Yeniden Başlat", "İptal (Daha Sonra Kur)"],
|
||||
defaultId: 0,
|
||||
cancelId: 2,
|
||||
noLink: true,
|
||||
title: `Güncellemeden Önce Kaydet — ${APP_DISPLAY_NAME}`,
|
||||
message: `"${label}" çalışması şu anda açık.`,
|
||||
detail: detailLines.join("\n"),
|
||||
});
|
||||
|
||||
if (response === 0) {
|
||||
pendingUpdateInstallAfterSave = true;
|
||||
sendMenuCommand("file:save-and-update");
|
||||
return { started: true, awaitingSave: true };
|
||||
}
|
||||
if (response === 1) {
|
||||
pendingUpdateInstallAfterSave = false;
|
||||
isDocumentDirty = false;
|
||||
installDownloadedUpdate();
|
||||
return { started: true };
|
||||
}
|
||||
|
||||
pendingUpdateInstallAfterSave = false;
|
||||
updateInstallRequested = false;
|
||||
return { started: false, canceled: true };
|
||||
})().finally(() => {
|
||||
updatePrepareInFlight = null;
|
||||
});
|
||||
|
||||
return updatePrepareInFlight;
|
||||
}
|
||||
|
||||
async function downloadAndInstallDesktopUpdate() {
|
||||
if (!app.isPackaged) {
|
||||
return desktopUpdatePayload(
|
||||
@@ -692,7 +903,7 @@ async function downloadAndInstallDesktopUpdate() {
|
||||
}
|
||||
|
||||
if (downloadedUpdateReady) {
|
||||
installDownloadedUpdate();
|
||||
void prepareAndInstallDownloadedUpdate();
|
||||
return desktopUpdatePayload(lastUpdateCheckResult, "", { status: "downloaded", progressPercent: 100 });
|
||||
}
|
||||
|
||||
@@ -700,11 +911,13 @@ async function downloadAndInstallDesktopUpdate() {
|
||||
try {
|
||||
let result = lastUpdateCheckResult;
|
||||
if (!result?.isUpdateAvailable) {
|
||||
updateInstallRequested = true;
|
||||
setUpdateState({ status: "checking", checkedAt: new Date().toISOString(), error: undefined });
|
||||
result = await autoUpdater.checkForUpdates();
|
||||
lastUpdateCheckResult = result;
|
||||
}
|
||||
if (!result?.isUpdateAvailable) {
|
||||
updateInstallRequested = false;
|
||||
setUpdateState({
|
||||
status: "not-available",
|
||||
latestVersion: result?.updateInfo?.version || null,
|
||||
@@ -717,11 +930,15 @@ async function downloadAndInstallDesktopUpdate() {
|
||||
}
|
||||
|
||||
updateInstallRequested = true;
|
||||
const expectedTotal = Number(result?.updateInfo?.files?.[0]?.size || 0);
|
||||
setUpdateState({
|
||||
status: "downloading",
|
||||
latestVersion: result?.updateInfo?.version || null,
|
||||
updateAvailable: true,
|
||||
progressPercent: 0,
|
||||
transferred: 0,
|
||||
total: Number.isFinite(expectedTotal) && expectedTotal > 0 ? expectedTotal : 0,
|
||||
bytesPerSecond: 0,
|
||||
error: undefined,
|
||||
});
|
||||
await autoUpdater.downloadUpdate();
|
||||
@@ -764,19 +981,7 @@ async function checkForDesktopUpdates(manual = false) {
|
||||
}
|
||||
if (downloadedUpdateReady) {
|
||||
if (manual) {
|
||||
const choice = await dialog.showMessageBox(visibleDialogParent(), {
|
||||
type: "info",
|
||||
title: `${APP_DISPLAY_NAME} Güncellemesi Hazır`,
|
||||
buttons: ["Şimdi Yeniden Başlat ve Kur", "Daha Sonra"],
|
||||
defaultId: 0,
|
||||
cancelId: 1,
|
||||
noLink: true,
|
||||
message: `${APP_DISPLAY_NAME} ${updateState.latestVersion || ""} kurulumu tamamlanmaya hazır.`,
|
||||
detail: "Uygulama kapatılıp yeni sürüm kurulacak ve ardından yeniden başlatılacaktır.",
|
||||
});
|
||||
if (choice.response === 0) {
|
||||
installDownloadedUpdate();
|
||||
}
|
||||
void prepareAndInstallDownloadedUpdate();
|
||||
}
|
||||
return desktopUpdatePayload();
|
||||
}
|
||||
@@ -1358,6 +1563,7 @@ function buildNativeApplicationMenu() {
|
||||
{ label: "STL 3B Yazıcı Modeli (.stl)…", click: () => sendMenuCommand("file:export-stl") },
|
||||
{ label: "3MF Baskı Paketi (.3mf)…", click: () => sendMenuCommand("file:export-3mf") },
|
||||
{ label: "STEP B-Rep Katı Model (.step)…", click: () => sendMenuCommand("file:export-step") },
|
||||
{ label: "IFC4 Mimari BIM Modeli (.ifc)…", click: () => sendMenuCommand("file:export-ifc") },
|
||||
{ label: "Wavefront 3B Mesh (.obj)…", click: () => sendMenuCommand("file:export-obj") },
|
||||
{ label: "Binary glTF 3B Model (.glb)…", click: () => sendMenuCommand("file:export-glb") },
|
||||
{ label: "AutoCAD 2B/3B DXF (.dxf)…", click: () => sendMenuCommand("file:export-dxf") },
|
||||
@@ -1642,6 +1848,10 @@ function buildNativeApplicationMenu() {
|
||||
{ type: "separator" },
|
||||
{ label: "Duvar Kapı / Pencere Boşluğu Aç…", click: () => sendMenuCommand("tool:wall-opening") },
|
||||
{ label: "Arazi & Yükselti Üreticisi…", click: () => sendMenuCommand("tool:terrain") },
|
||||
{ label: "Mimari BIM, Kat & Metraj Stüdyosu…", accelerator: "Alt+M", registerAccelerator: false, click: () => sendMenuCommand("tool:bim-studio") },
|
||||
{ label: "Çok Katlı Bina & Kot Yöneticisi…", click: () => sendMenuCommand("tool:bim-storeys") },
|
||||
{ label: "Otomatik Metraj, Mahal Alanı & Keşif (BOQ)…", click: () => sendMenuCommand("tool:bim-boq") },
|
||||
{ label: "İmar Yönetmeliği & TS 9111 Denetçisi…", click: () => sendMenuCommand("tool:bim-code-audit") },
|
||||
{ label: "Statik & Deprem Dayanım Testi…", click: () => sendMenuCommand("tool:structural-test") },
|
||||
{ label: "Masamda Gör (AR Ön İzleme)…", click: () => sendMenuCommand("tool:ar-preview") },
|
||||
{ type: "separator" },
|
||||
@@ -1784,6 +1994,18 @@ function setupDesktopIpc() {
|
||||
return true;
|
||||
});
|
||||
|
||||
ipcMain.on("snapcad:get-auth-state-sync", (event) => {
|
||||
event.returnValue = {
|
||||
authenticated: Boolean(desktopAuthSession?.user),
|
||||
user: desktopAuthSession?.user ? { ...desktopAuthSession.user } : null,
|
||||
};
|
||||
});
|
||||
|
||||
ipcMain.handle("snapcad:get-auth-state", () => ({
|
||||
authenticated: Boolean(desktopAuthSession?.user),
|
||||
user: desktopAuthSession?.user ? { ...desktopAuthSession.user } : null,
|
||||
}));
|
||||
|
||||
ipcMain.handle("snapcad:yaknet-login", () => startYakNetDesktopLogin());
|
||||
ipcMain.handle("snapcad:yaknet-logout", () => logoutYakNetDesktop());
|
||||
ipcMain.handle("snapcad:cloud-request", (_event, options) => proxyDesktopCloudRequest(options));
|
||||
@@ -1889,6 +2111,18 @@ function setupDesktopIpc() {
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("snapcad:set-active-work-state", (_event, rawState) => {
|
||||
activeWorkState = sanitizeActiveWorkState(rawState);
|
||||
});
|
||||
|
||||
ipcMain.handle("snapcad:prepare-before-update-result", (_event, payload) => {
|
||||
const requestId = typeof payload?.requestId === "string" ? payload.requestId : "";
|
||||
const resolver = pendingUpdatePrepareResolvers.get(requestId);
|
||||
if (resolver) {
|
||||
resolver(sanitizePrepareBeforeUpdateResult(payload?.result));
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle("snapcad:confirm-close-after-save", () => {
|
||||
isDocumentDirty = false;
|
||||
explicitQuit = true;
|
||||
@@ -1900,6 +2134,19 @@ function setupDesktopIpc() {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
ipcMain.handle("snapcad:confirm-update-after-save", () => {
|
||||
if (!pendingUpdateInstallAfterSave) return false;
|
||||
pendingUpdateInstallAfterSave = false;
|
||||
isDocumentDirty = false;
|
||||
installDownloadedUpdate();
|
||||
return true;
|
||||
});
|
||||
|
||||
ipcMain.handle("snapcad:cancel-pending-update-install", () => {
|
||||
pendingUpdateInstallAfterSave = false;
|
||||
updateInstallRequested = false;
|
||||
});
|
||||
|
||||
ipcMain.handle("snapcad:open-external", (_event, rawUrl) => {
|
||||
if (!isAllowedExternalUrl(rawUrl)) return false;
|
||||
void shell.openExternal(String(rawUrl));
|
||||
@@ -1960,6 +2207,21 @@ function setupDesktopUpdater() {
|
||||
.then(({ response }) => {
|
||||
if (response === 0) {
|
||||
showMainWindow();
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
const expectedTotal = Number(info?.files?.[0]?.size || 0);
|
||||
mainWindow.webContents.send(
|
||||
"snapcad:open-update-progress",
|
||||
desktopUpdatePayload(null, "", {
|
||||
status: "downloading",
|
||||
latestVersion: info?.version || updateState.latestVersion || null,
|
||||
updateAvailable: true,
|
||||
progressPercent: 0,
|
||||
transferred: 0,
|
||||
total: Number.isFinite(expectedTotal) && expectedTotal > 0 ? expectedTotal : 0,
|
||||
bytesPerSecond: 0,
|
||||
}),
|
||||
);
|
||||
}
|
||||
void downloadAndInstallDesktopUpdate();
|
||||
} else if (response === 1) {
|
||||
sendMenuCommand("window:settings");
|
||||
@@ -2011,7 +2273,8 @@ function setupDesktopUpdater() {
|
||||
error: undefined,
|
||||
});
|
||||
if (updateInstallRequested) {
|
||||
installDownloadedUpdate();
|
||||
updateInstallRequested = false;
|
||||
void prepareAndInstallDownloadedUpdate();
|
||||
return;
|
||||
}
|
||||
void dialog
|
||||
@@ -2027,12 +2290,14 @@ function setupDesktopUpdater() {
|
||||
})
|
||||
.then(({ response }) => {
|
||||
if (response === 0) {
|
||||
installDownloadedUpdate();
|
||||
void prepareAndInstallDownloadedUpdate();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
autoUpdater.on("error", (error) => {
|
||||
updateInstallRequested = false;
|
||||
pendingUpdateInstallAfterSave = false;
|
||||
const friendly = formatFriendlyUpdateError(error);
|
||||
lastUpdateCheckError = friendly;
|
||||
if (tray) tray.setToolTip(APP_DISPLAY_NAME);
|
||||
@@ -2077,7 +2342,7 @@ function updateTrayMenu() {
|
||||
downloadedUpdateReady
|
||||
? {
|
||||
label: "Güncellemeyi Kur ve Yeniden Başlat",
|
||||
click: installDownloadedUpdate,
|
||||
click: () => void prepareAndInstallDownloadedUpdate(),
|
||||
}
|
||||
: {
|
||||
label: "Güncellemeleri Denetle…",
|
||||
@@ -2088,7 +2353,7 @@ function updateTrayMenu() {
|
||||
label: "Tamamen Çıkış Yap",
|
||||
click: () => {
|
||||
if (downloadedUpdateReady) {
|
||||
installDownloadedUpdate();
|
||||
void prepareAndInstallDownloadedUpdate();
|
||||
return;
|
||||
}
|
||||
requestForceQuit();
|
||||
@@ -2314,6 +2579,14 @@ function createMainWindow(url) {
|
||||
});
|
||||
|
||||
mainWindow.on("closed", () => {
|
||||
for (const resolvePending of pendingUpdatePrepareResolvers.values()) {
|
||||
try {
|
||||
resolvePending(sanitizePrepareBeforeUpdateResult({ ...activeWorkState, localSaved: false }));
|
||||
} catch {
|
||||
// Ignore resolver cleanup failures.
|
||||
}
|
||||
}
|
||||
pendingUpdatePrepareResolvers.clear();
|
||||
mainWindow = null;
|
||||
updateTrayMenu();
|
||||
});
|
||||
|
||||
@@ -41,11 +41,27 @@ const desktopBridge = Object.freeze({
|
||||
installUpdate: () => ipcRenderer.invoke("sketchforge:install-update"),
|
||||
getUpdateState: () => ipcRenderer.invoke("snapcad:get-update-state"),
|
||||
onUpdateState: subscribeChannel("snapcad:update-state"),
|
||||
onOpenUpdateProgress: subscribeChannel("snapcad:open-update-progress"),
|
||||
getDesktopPrefs: () => ipcRenderer.invoke("snapcad:get-desktop-prefs"),
|
||||
setDesktopPrefs: (patch) =>
|
||||
ipcRenderer.invoke("snapcad:set-desktop-prefs", patch && typeof patch === "object" ? patch : {}),
|
||||
hideToTray: () => ipcRenderer.invoke("snapcad:hide-to-tray"),
|
||||
onDesktopPrefsChanged: subscribeChannel("snapcad:prefs-changed"),
|
||||
getAuthStateSync: () => {
|
||||
try {
|
||||
const result = ipcRenderer.sendSync("snapcad:get-auth-state-sync");
|
||||
if (result && typeof result === "object") {
|
||||
return {
|
||||
authenticated: Boolean(result.authenticated && result.user),
|
||||
user: result.user || null,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// Fallback cleanly when synchronous auth read fails.
|
||||
}
|
||||
return { authenticated: false, user: null };
|
||||
},
|
||||
getAuthState: () => ipcRenderer.invoke("snapcad:get-auth-state"),
|
||||
startYakNetLogin: () => ipcRenderer.invoke("snapcad:yaknet-login"),
|
||||
logoutYakNet: () => ipcRenderer.invoke("snapcad:yaknet-logout"),
|
||||
cloudRequest: (options) =>
|
||||
@@ -73,7 +89,17 @@ const desktopBridge = Object.freeze({
|
||||
ipcRenderer.invoke("snapcad:set-menu-state", state && typeof state === "object" ? state : {}),
|
||||
setDirty: (dirty) => ipcRenderer.invoke("snapcad:set-dirty", Boolean(dirty)),
|
||||
setWindowTitle: (title) => ipcRenderer.invoke("snapcad:set-window-title", String(title ?? "")),
|
||||
setActiveWorkState: (state) =>
|
||||
ipcRenderer.invoke("snapcad:set-active-work-state", state && typeof state === "object" ? state : {}),
|
||||
onPrepareBeforeUpdate: subscribeChannel("snapcad:prepare-before-update"),
|
||||
sendPrepareBeforeUpdateResult: (requestId, result) =>
|
||||
ipcRenderer.invoke("snapcad:prepare-before-update-result", {
|
||||
requestId: String(requestId ?? ""),
|
||||
result: result && typeof result === "object" ? result : {},
|
||||
}),
|
||||
confirmCloseAfterSave: () => ipcRenderer.invoke("snapcad:confirm-close-after-save"),
|
||||
confirmUpdateAfterSave: () => ipcRenderer.invoke("snapcad:confirm-update-after-save"),
|
||||
cancelPendingUpdateInstall: () => ipcRenderer.invoke("snapcad:cancel-pending-update-install"),
|
||||
openExternal: (url) => ipcRenderer.invoke("snapcad:open-external", String(url ?? "")),
|
||||
});
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ function readRootAppVersion(): string {
|
||||
// Ignore missing or unreadable package.json candidate.
|
||||
}
|
||||
}
|
||||
return "1.0.10";
|
||||
return "1.0.11";
|
||||
}
|
||||
|
||||
const isStaticExport = process.env.STATIC_EXPORT === "true";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SnapCAD Studio Progressive Web App (PWA) Service Worker
|
||||
const CACHE_NAME = "snapcad-v1.2.1";
|
||||
const CACHE_NAME = "snapcad-v1.2.2";
|
||||
const PRECACHE_ASSETS = [
|
||||
"/",
|
||||
"/manifest.json",
|
||||
|
||||
@@ -1450,9 +1450,36 @@ button {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.dashboard-update-overlay {
|
||||
z-index: 10050;
|
||||
}
|
||||
|
||||
.dashboard-update-progress-block {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.dashboard-update-progress-meta,
|
||||
.dashboard-update-transfer-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #365066;
|
||||
}
|
||||
|
||||
.dashboard-update-transfer-meta {
|
||||
font-size: 11.5px;
|
||||
font-weight: 600;
|
||||
color: #5b7285;
|
||||
}
|
||||
|
||||
.dashboard-update-progress-track {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 7px;
|
||||
height: 8px;
|
||||
overflow: hidden;
|
||||
border-radius: 999px;
|
||||
background: #dce5ec;
|
||||
@@ -1465,6 +1492,125 @@ button {
|
||||
transition: width 180ms ease;
|
||||
}
|
||||
|
||||
.dashboard-update-progress-fill.indeterminate {
|
||||
position: absolute;
|
||||
inset: 0 auto 0 0;
|
||||
width: 38%;
|
||||
animation: dashboard-update-indeterminate 1.25s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes dashboard-update-indeterminate {
|
||||
0% {
|
||||
transform: translateX(-110%);
|
||||
}
|
||||
100% {
|
||||
transform: translateX(310%);
|
||||
}
|
||||
}
|
||||
|
||||
.snapcad-floating-update-progress {
|
||||
position: fixed;
|
||||
right: 18px;
|
||||
bottom: 76px;
|
||||
z-index: 460;
|
||||
display: grid;
|
||||
gap: 9px;
|
||||
width: min(340px, calc(100vw - 36px));
|
||||
padding: 12px 14px;
|
||||
color: #20374c;
|
||||
background: rgba(255, 255, 255, 0.97);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid #c7d8e5;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
|
||||
}
|
||||
|
||||
.snapcad-floating-update-head,
|
||||
.snapcad-floating-update-foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.snapcad-floating-update-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
font-size: 13px;
|
||||
color: #163047;
|
||||
}
|
||||
|
||||
.snapcad-floating-update-title .spin-subtle {
|
||||
color: #0e69f1;
|
||||
}
|
||||
|
||||
.snapcad-floating-update-close {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 6px;
|
||||
color: #556f84;
|
||||
background: #edf3f7;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.snapcad-floating-update-foot {
|
||||
font-size: 11.5px;
|
||||
font-weight: 600;
|
||||
color: #546c80;
|
||||
}
|
||||
|
||||
.snapcad-floating-update-foot > span {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.snapcad-floating-update-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.snapcad-floating-update-secondary,
|
||||
.snapcad-floating-update-primary {
|
||||
height: 28px;
|
||||
padding: 0 10px;
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 750;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.snapcad-floating-update-secondary {
|
||||
color: #2a475f;
|
||||
background: #eef4f8;
|
||||
border: 1px solid #cbd9e3;
|
||||
}
|
||||
|
||||
.snapcad-floating-update-primary {
|
||||
color: #ffffff;
|
||||
background: #0e69f1;
|
||||
border: 1px solid #0e69f1;
|
||||
}
|
||||
|
||||
.yaknet-widget-skeleton > span {
|
||||
animation: yaknet-skeleton-pulse 1.2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes yaknet-skeleton-pulse {
|
||||
0%, 100% {
|
||||
opacity: 0.45;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.9;
|
||||
}
|
||||
}
|
||||
|
||||
.dashboard-desktop-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -7283,6 +7429,40 @@ html[data-theme="dark"] .dashboard-update-progress-track {
|
||||
background: #233442;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .dashboard-update-progress-meta {
|
||||
color: #d6e4ef;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .dashboard-update-transfer-meta {
|
||||
color: #9bb1c3;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .snapcad-floating-update-progress {
|
||||
color: #e1edf5;
|
||||
background: rgba(20, 31, 41, 0.96);
|
||||
border-color: #344a5a;
|
||||
box-shadow: 0 16px 38px rgba(0, 0, 0, 0.42);
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .snapcad-floating-update-title {
|
||||
color: #f1f7fc;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .snapcad-floating-update-close {
|
||||
color: #b7cad9;
|
||||
background: #1d2d3b;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .snapcad-floating-update-foot {
|
||||
color: #9cb1c2;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .snapcad-floating-update-secondary {
|
||||
color: #d8e6f1;
|
||||
background: #1b2a35;
|
||||
border-color: #3a4e5d;
|
||||
}
|
||||
|
||||
html[data-theme="dark"] .dashboard-desktop-toggle {
|
||||
color: #e1edf5;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
|
||||
import NextTopLoader from "nextjs-toploader";
|
||||
import { AppErrorBoundary } from "@/components/snapcad/AppErrorBoundary";
|
||||
import { WebRuntimeChrome } from "@/components/snapcad/WebRuntimeChrome";
|
||||
import { YAKNET_ACCOUNT_CDN_URL, YAKNET_ACCOUNT_SCRIPT_ID, YAKNET_AUTH_BASE, YAKNET_CDN_ORIGIN } from "@/lib/yaknetWidgetHelpers";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
@@ -49,6 +50,10 @@ export default function RootLayout({
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="apple-mobile-web-app-title" content="SnapCAD" />
|
||||
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png" />
|
||||
<link rel="preconnect" href={YAKNET_CDN_ORIGIN} crossOrigin="anonymous" />
|
||||
<link rel="dns-prefetch" href={YAKNET_CDN_ORIGIN} />
|
||||
<link rel="preconnect" href={YAKNET_AUTH_BASE} crossOrigin="anonymous" />
|
||||
<link rel="dns-prefetch" href={YAKNET_AUTH_BASE} />
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `(function(){
|
||||
@@ -57,13 +62,25 @@ export default function RootLayout({
|
||||
var isDark = theme === "dark" || (theme === "system" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches);
|
||||
document.documentElement.setAttribute("data-theme", isDark ? "dark" : "light");
|
||||
document.documentElement.style.backgroundColor = isDark ? "#060810" : "#fafafa";
|
||||
if (window.snapcadDesktop || window.sketchforgeDesktop || /\bElectron\//i.test(navigator.userAgent || "")) {
|
||||
var isDesktop = Boolean(window.snapcadDesktop || window.sketchforgeDesktop || /\\bElectron\\//i.test(navigator.userAgent || ""));
|
||||
if (isDesktop) {
|
||||
document.documentElement.setAttribute("data-desktop-runtime", "true");
|
||||
} else if (typeof fetch === "function") {
|
||||
window.__snapcadInitialSessionPromise = fetch("/cloud-api.php?action=session", {
|
||||
method: "GET",
|
||||
cache: "no-store",
|
||||
credentials: "same-origin"
|
||||
}).then(function(res){
|
||||
return res && res.ok ? res.json() : null;
|
||||
}).catch(function(){
|
||||
return null;
|
||||
});
|
||||
}
|
||||
} catch(e) {}
|
||||
})()`,
|
||||
}}
|
||||
/>
|
||||
<script id={YAKNET_ACCOUNT_SCRIPT_ID} async src={YAKNET_ACCOUNT_CDN_URL} />
|
||||
</head>
|
||||
<body suppressHydrationWarning>
|
||||
<NextTopLoader
|
||||
|
||||
+811
-371
File diff suppressed because it is too large
Load Diff
@@ -93,6 +93,11 @@ import { TerrainGeneratorModal } from "./snapcad/TerrainGeneratorModal";
|
||||
import { PaintBucketHUD } from "./snapcad/PaintBucketHUD";
|
||||
import { InteractiveTutorialModal } from "./snapcad/InteractiveTutorialModal";
|
||||
import { WallOpeningModal, type WallCutoutConfig } from "./snapcad/WallOpeningModal";
|
||||
import {
|
||||
ArchitecturalBimStudioModal,
|
||||
type ArchitecturalBimStudioTab,
|
||||
} from "./snapcad/ArchitecturalBimStudioModal";
|
||||
import { exportShapesToIfc4 } from "@/lib/ifcExport";
|
||||
import { audit3DScene, type Scene3DAuditReport } from "@/lib/cadAuditor";
|
||||
import { CadAuditModal } from "./snapcad/CadAuditModal";
|
||||
import { VoiceCadModal } from "./snapcad/VoiceCadModal";
|
||||
@@ -210,7 +215,7 @@ import type { AlignAxis, AlignHandleStatus, AlignTarget, ArchitecturalTextureId,
|
||||
export { importedShapeFromObj, importedShapeFromStl, importedShapeFromSvg, importedShapeFromDxf, importedShapeFromGlb };
|
||||
|
||||
type TopPanel = "import" | "export" | "profile" | "settings" | null;
|
||||
type ExportFormat = "3mf" | "stl" | "obj" | "step" | "dxf" | "svg" | "glb" | "skf";
|
||||
type ExportFormat = "3mf" | "stl" | "obj" | "step" | "ifc" | "dxf" | "svg" | "glb" | "skf";
|
||||
type DirectExportFormat = Exclude<ExportFormat, "step" | "skf">;
|
||||
type SkfHistoryLimit = EditorHistoryExportLimit;
|
||||
type SkfExportTarget = "download" | "shared";
|
||||
@@ -5748,6 +5753,8 @@ export function SketchForgeEditor({
|
||||
const [isInteractiveTutorialOpen, setIsInteractiveTutorialOpen] = useState(false);
|
||||
const [isDailyChallengesOpen, setIsDailyChallengesOpen] = useState(false);
|
||||
const [isWallOpeningModalOpen, setIsWallOpeningModalOpen] = useState(false);
|
||||
const [isBimStudioModalOpen, setIsBimStudioModalOpen] = useState(false);
|
||||
const [bimStudioTab, setBimStudioTab] = useState<ArchitecturalBimStudioTab>("elements");
|
||||
const [targetWallIdForOpening, setTargetWallIdForOpening] = useState<string | null>(null);
|
||||
const [isCadAuditModalOpen, setIsCadAuditModalOpen] = useState(false);
|
||||
const [isVoiceCadModalOpen, setIsVoiceCadModalOpen] = useState(false);
|
||||
@@ -9597,6 +9604,24 @@ export function SketchForgeEditor({
|
||||
const failNotice = (label: string, error: unknown) => {
|
||||
setNotice(error instanceof Error ? error.message : `Could not export ${label}`);
|
||||
};
|
||||
if (format === "ifc") {
|
||||
setNotice("IFC4 BIM modeli (Kat, Duvar, Döşeme, Metraj) oluşturuluyor…");
|
||||
try {
|
||||
const res = exportShapesToIfc4(exportable, {
|
||||
projectName: exportName.trim() || projectName,
|
||||
});
|
||||
void downloadTextFile(
|
||||
projectExportFileName(exportName, "ifc"),
|
||||
res.ifcText,
|
||||
"application/x-step;charset=utf-8",
|
||||
)
|
||||
.then((result) => finishNotice("IFC4 BIM", result))
|
||||
.catch((error: unknown) => failNotice("IFC4 BIM", error));
|
||||
} catch (error) {
|
||||
failNotice("IFC4 BIM", error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (format === "svg") {
|
||||
setNotice("Building SVG top-view projection…");
|
||||
void toSvg(exportable, exportName.trim() || projectName)
|
||||
@@ -11109,6 +11134,9 @@ export function SketchForgeEditor({
|
||||
case "file:export-step":
|
||||
void exportStepDesign(projectName);
|
||||
break;
|
||||
case "file:export-ifc":
|
||||
exportDesign("ifc", projectName);
|
||||
break;
|
||||
case "file:export-obj":
|
||||
exportDesign("obj", projectName);
|
||||
break;
|
||||
@@ -11346,6 +11374,22 @@ export function SketchForgeEditor({
|
||||
case "tool:terrain":
|
||||
setIsTerrainModalOpen(true);
|
||||
break;
|
||||
case "tool:bim-studio":
|
||||
setBimStudioTab("elements");
|
||||
setIsBimStudioModalOpen(true);
|
||||
break;
|
||||
case "tool:bim-storeys":
|
||||
setBimStudioTab("storeys");
|
||||
setIsBimStudioModalOpen(true);
|
||||
break;
|
||||
case "tool:bim-boq":
|
||||
setBimStudioTab("boq");
|
||||
setIsBimStudioModalOpen(true);
|
||||
break;
|
||||
case "tool:bim-code-audit":
|
||||
setBimStudioTab("code-audit");
|
||||
setIsBimStudioModalOpen(true);
|
||||
break;
|
||||
case "tool:structural-test":
|
||||
handleRunStructuralTest();
|
||||
break;
|
||||
@@ -11563,6 +11607,10 @@ export function SketchForgeEditor({
|
||||
onOpenFollowMe={() => setIsFollowMeModalOpen(true)}
|
||||
onOpenTerrain={() => setIsTerrainModalOpen(true)}
|
||||
onOpenWallOpening={() => setIsWallOpeningModalOpen(true)}
|
||||
onOpenBimStudio={() => {
|
||||
setBimStudioTab("elements");
|
||||
setIsBimStudioModalOpen(true);
|
||||
}}
|
||||
onRunStructuralTest={handleRunStructuralTest}
|
||||
onOpenAudit={handleOpenAudit}
|
||||
onOpenVoiceCad={() => setIsVoiceCadModalOpen(true)}
|
||||
@@ -12244,6 +12292,26 @@ export function SketchForgeEditor({
|
||||
selectedShapeId={targetWallIdForOpening || selectedIds[0] || null}
|
||||
onApplyCutout={handleApplyWallCutout}
|
||||
/>
|
||||
<ArchitecturalBimStudioModal
|
||||
isOpen={isBimStudioModalOpen}
|
||||
initialTab={bimStudioTab}
|
||||
onClose={() => setIsBimStudioModalOpen(false)}
|
||||
shapes={shapes}
|
||||
projectName={projectName}
|
||||
solarSettings={solarSettings}
|
||||
onChangeSolarSettings={setSolarSettings}
|
||||
onAddShapes={(newShapes, noticeMsg) => {
|
||||
commitShapes(
|
||||
[...shapesRef.current, ...newShapes],
|
||||
newShapes.map((s) => s.id),
|
||||
noticeMsg,
|
||||
);
|
||||
}}
|
||||
onUpdateShapes={(nextShapes, noticeMsg) => {
|
||||
commitShapes(nextShapes, selectedIds, noticeMsg);
|
||||
}}
|
||||
onExportIfcFile={(name) => exportDesign("ifc", name)}
|
||||
/>
|
||||
<input
|
||||
ref={sketchImageInputRef}
|
||||
className="hidden-file-input"
|
||||
@@ -13193,6 +13261,11 @@ function TopActionPanel({
|
||||
description: "Mühendislik CAD / B-Rep",
|
||||
note: "Desteklenen kutu, silindir, küre ve konileri hassas B-Rep CAD geometrisi olarak dışa aktarır.",
|
||||
},
|
||||
ifc: {
|
||||
label: "IFC",
|
||||
description: "Mimari BIM (IFC4 Standart)",
|
||||
note: "Katları (IfcBuildingStorey), duvar, döşeme, kolon, kiriş, çatı, doğrama ve metraj verilerini Revit / ArchiCAD uyumlu IFC4 formatında dışa aktarır.",
|
||||
},
|
||||
dxf: {
|
||||
label: "DXF",
|
||||
description: "2B/3B CAD & Lazer Kesim",
|
||||
@@ -13354,7 +13427,7 @@ function TopActionPanel({
|
||||
<span className="export-scope-badge">{exportFormat === "skf" ? "Tam proje" : `${shapeCount} ${scopeLabel === "selected" ? "seçili" : "toplam"}`}</span>
|
||||
</div>
|
||||
<div className="export-format-slider" data-format={exportFormat} role="radiogroup" aria-label="Export format">
|
||||
{(["3mf", "stl", "obj", "step", "dxf", "svg", "glb", "skf"] as const).map((format) => (
|
||||
{(["3mf", "stl", "obj", "step", "ifc", "dxf", "svg", "glb", "skf"] as const).map((format) => (
|
||||
<button
|
||||
key={format}
|
||||
type="button"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from "react";
|
||||
import { Check, ChevronRight, Keyboard, LayoutPanelLeft, LayoutPanelTop, PanelRight } from "lucide-react";
|
||||
import { Building2, Check, ChevronRight, Keyboard, LayoutPanelLeft, LayoutPanelTop, PanelRight } from "lucide-react";
|
||||
import type {
|
||||
DefaultTraySectionId,
|
||||
SketchUpToolId,
|
||||
@@ -52,6 +52,7 @@ export interface SketchUpMenuBarProps {
|
||||
onOpenFollowMe: () => void;
|
||||
onOpenTerrain: () => void;
|
||||
onOpenWallOpening: () => void;
|
||||
onOpenBimStudio?: () => void;
|
||||
onRunStructuralTest: () => void;
|
||||
onOpenAudit: () => void;
|
||||
onOpenVoiceCad: () => void;
|
||||
@@ -334,6 +335,17 @@ export function SketchUpMenuBar(props: SketchUpMenuBarProps) {
|
||||
{ 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 },
|
||||
...(props.onOpenBimStudio
|
||||
? [
|
||||
{
|
||||
kind: "action" as const,
|
||||
id: "tool-bim-studio",
|
||||
label: "Mimari BIM, Kat, Metraj (BOQ) & İmar Stüdyosu…",
|
||||
shortcut: "Alt+M",
|
||||
onSelect: () => props.onOpenBimStudio?.(),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{ kind: "action", id: "tool-static", label: "Statik & Deprem Dayanım Testi…", onSelect: props.onRunStructuralTest },
|
||||
],
|
||||
},
|
||||
@@ -476,6 +488,18 @@ export function SketchUpMenuBar(props: SketchUpMenuBarProps) {
|
||||
|
||||
{/* Sağ taraf: hızlı görünüm & kısayol profili anahtarları */}
|
||||
<div className="sketchup-menubar-right" role="group" aria-label="Hızlı Panel ve Kısayol Ayarları">
|
||||
{props.onOpenBimStudio ? (
|
||||
<button
|
||||
type="button"
|
||||
className="sketchup-quick-chip active"
|
||||
onClick={() => props.onOpenBimStudio?.()}
|
||||
title="Mimari BIM, Kat Yöneticisi, Otomatik Metraj (BOQ), IFC4 Çıktısı ve İmar Denetçisini Aç"
|
||||
>
|
||||
<Building2 size={12} aria-hidden="true" />
|
||||
<span>BIM & Metraj</span>
|
||||
</button>
|
||||
) : null}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className={`sketchup-quick-chip ${prefs.showLeftToolset ? "active" : ""}`}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import {
|
||||
calculateSunPosition,
|
||||
calculateDailySolarSweep,
|
||||
SOLAR_LOCATIONS,
|
||||
type SolarStudySettings,
|
||||
} from "@/lib/solarSystem";
|
||||
@@ -52,6 +53,7 @@ export const SolarStudyModal: React.FC<SolarStudyModalProps> = ({
|
||||
};
|
||||
|
||||
const sunData = calculateSunPosition(settings);
|
||||
const sweepData = calculateDailySolarSweep(settings);
|
||||
|
||||
const formatHour = (val: number) => {
|
||||
const h = Math.floor(val);
|
||||
@@ -266,6 +268,48 @@ export const SolarStudyModal: React.FC<SolarStudyModalProps> = ({
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Daily Solar Sweep & TS 825 Summary */}
|
||||
<div
|
||||
style={{
|
||||
background: "#1e293b",
|
||||
border: "1px solid #334155",
|
||||
borderRadius: "10px",
|
||||
padding: "12px",
|
||||
fontSize: "12px",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "8px",
|
||||
}}
|
||||
>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
||||
<strong style={{ color: "#38bdf8" }}>{sweepData.ts825Standard.label}</strong>
|
||||
<span style={{ color: "#facc15", fontWeight: 600 }}>
|
||||
🌅 {sweepData.sunriseTime} — 🌇 {sweepData.sunsetTime} ({sweepData.daylightDurationHours} sa)
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: "6px", textAlign: "center" }}>
|
||||
<div style={{ background: "#0f172a", padding: "6px", borderRadius: "6px" }}>
|
||||
<span style={{ color: "#94a3b8", fontSize: "10px", display: "block" }}>Güney Cephe</span>
|
||||
<strong style={{ color: "#4ade80" }}>{sweepData.southHours} sa</strong>
|
||||
</div>
|
||||
<div style={{ background: "#0f172a", padding: "6px", borderRadius: "6px" }}>
|
||||
<span style={{ color: "#94a3b8", fontSize: "10px", display: "block" }}>Doğu Cephe</span>
|
||||
<strong style={{ color: "#38bdf8" }}>{sweepData.eastHours} sa</strong>
|
||||
</div>
|
||||
<div style={{ background: "#0f172a", padding: "6px", borderRadius: "6px" }}>
|
||||
<span style={{ color: "#94a3b8", fontSize: "10px", display: "block" }}>Batı Cephe</span>
|
||||
<strong style={{ color: "#f59e0b" }}>{sweepData.westHours} sa</strong>
|
||||
</div>
|
||||
<div style={{ background: "#0f172a", padding: "6px", borderRadius: "6px" }}>
|
||||
<span style={{ color: "#94a3b8", fontSize: "10px", display: "block" }}>Kuzey Cephe</span>
|
||||
<strong style={{ color: "#cbd5e1" }}>{sweepData.northHours} sa</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ color: "#94a3b8", fontSize: "11px", lineHeight: 1.35 }}>
|
||||
<strong style={{ color: "#e2e8f0" }}>TS 825 Önerisi:</strong> Duvar U ≤ {sweepData.ts825Standard.recommendedWallU} W/m²K, Çatı U ≤ {sweepData.ts825Standard.recommendedRoofU} W/m²K (Min. {sweepData.ts825Standard.minInsulationThicknessMm} mm yalıtım). {sweepData.shadingRecommendation}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import React, { useState, useId } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { Mountain, X, Sparkles } from "lucide-react";
|
||||
import {
|
||||
Mountain,
|
||||
X,
|
||||
Sparkles,
|
||||
Layers,
|
||||
Check,
|
||||
Sliders,
|
||||
} from "lucide-react";
|
||||
import { createLocalId } from "@/lib/localIds";
|
||||
generateAdvancedTerrainWithPad,
|
||||
type TerrainTopographyPreset,
|
||||
} from "@/lib/architecturalBimEngine";
|
||||
import type { WorkplaneShape, ArchitecturalTextureId } from "@/types/sketchforge";
|
||||
|
||||
export interface TerrainGeneratorModalProps {
|
||||
@@ -18,131 +14,35 @@ export interface TerrainGeneratorModalProps {
|
||||
onAddShape: (shape: WorkplaneShape) => void;
|
||||
}
|
||||
|
||||
type TerrainPreset = "hills" | "slope" | "terrace" | "valley";
|
||||
|
||||
export const TerrainGeneratorModal: React.FC<TerrainGeneratorModalProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onAddShape,
|
||||
}) => {
|
||||
const baseId = useId();
|
||||
const [preset, setPreset] = useState<TerrainPreset>("hills");
|
||||
const [preset, setPreset] = useState<TerrainTopographyPreset>("hills");
|
||||
const [width, setWidth] = useState(200);
|
||||
const [depth, setDepth] = useState(200);
|
||||
const [maxHeight, setMaxHeight] = useState(18);
|
||||
const [texture, setTexture] = useState<ArchitecturalTextureId>("grass");
|
||||
const [includeBuildingPad, setIncludeBuildingPad] = useState(true);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
const handleGenerate = () => {
|
||||
// Generate grid vertices (e.g. 16x16 grid for clean performance)
|
||||
const segments = 16;
|
||||
const halfW = width / 2;
|
||||
const halfD = depth / 2;
|
||||
const positions: number[] = [];
|
||||
const normals: number[] = [];
|
||||
|
||||
// Height function based on preset
|
||||
const getHeight = (u: number, v: number) => {
|
||||
// u, v in [0, 1]
|
||||
if (preset === "hills") {
|
||||
return (
|
||||
Math.sin(u * Math.PI * 2) * Math.cos(v * Math.PI * 2) * maxHeight * 0.5 +
|
||||
Math.sin(u * Math.PI * 4 + v * 2) * (maxHeight * 0.25) +
|
||||
maxHeight * 0.5
|
||||
);
|
||||
}
|
||||
if (preset === "slope") {
|
||||
return u * maxHeight + Math.sin(v * Math.PI * 3) * (maxHeight * 0.15);
|
||||
}
|
||||
if (preset === "valley") {
|
||||
const distFromCenter = Math.abs(u - 0.5) * 2;
|
||||
return distFromCenter * distFromCenter * maxHeight;
|
||||
}
|
||||
// terrace
|
||||
const stepped = Math.floor(u * 4) / 4;
|
||||
return stepped * maxHeight;
|
||||
};
|
||||
|
||||
const getNormal = (u: number, v: number) => {
|
||||
const eps = 0.01;
|
||||
const hL = getHeight(Math.max(0, u - eps), v);
|
||||
const hR = getHeight(Math.min(1, u + eps), v);
|
||||
const hD = getHeight(u, Math.max(0, v - eps));
|
||||
const hU = getHeight(u, Math.min(1, v + eps));
|
||||
const dx = (hR - hL) / (2 * eps * width);
|
||||
const dz = (hU - hD) / (2 * eps * depth);
|
||||
const len = Math.sqrt(dx * dx + 1 + dz * dz);
|
||||
return [-dx / len, 1 / len, -dz / len];
|
||||
};
|
||||
|
||||
// Build triangles
|
||||
for (let i = 0; i < segments; i++) {
|
||||
for (let j = 0; j < segments; j++) {
|
||||
const u0 = i / segments;
|
||||
const u1 = (i + 1) / segments;
|
||||
const v0 = j / segments;
|
||||
const v1 = (j + 1) / segments;
|
||||
|
||||
const x0 = -halfW + u0 * width;
|
||||
const x1 = -halfW + u1 * width;
|
||||
const z0 = -halfD + v0 * depth;
|
||||
const z1 = -halfD + v1 * depth;
|
||||
|
||||
const y00 = getHeight(u0, v0);
|
||||
const y10 = getHeight(u1, v0);
|
||||
const y01 = getHeight(u0, v1);
|
||||
const y11 = getHeight(u1, v1);
|
||||
|
||||
const n00 = getNormal(u0, v0);
|
||||
const n10 = getNormal(u1, v0);
|
||||
const n01 = getNormal(u0, v1);
|
||||
const n11 = getNormal(u1, v1);
|
||||
|
||||
// Triangle 1: (0,0), (1,0), (0,1)
|
||||
positions.push(x0, y00, z0, x1, y10, z0, x0, y01, z1);
|
||||
normals.push(...n00, ...n10, ...n01);
|
||||
|
||||
// Triangle 2: (1,0), (1,1), (0,1)
|
||||
positions.push(x1, y10, z0, x1, y11, z1, x0, y01, z1);
|
||||
normals.push(...n10, ...n11, ...n01);
|
||||
}
|
||||
}
|
||||
|
||||
const terrainShape: WorkplaneShape = {
|
||||
id: createLocalId("terrain"),
|
||||
name:
|
||||
preset === "hills"
|
||||
? "Dalgalı Tepe Arazisi"
|
||||
: preset === "slope"
|
||||
? "Eğimli Arsa"
|
||||
: preset === "valley"
|
||||
? "Vadi Arazisi"
|
||||
: "Teraslı Arsa",
|
||||
kind: "mesh",
|
||||
color: texture === "grass" ? "#22c55e" : "#64748b",
|
||||
texture,
|
||||
tag: "Arazi / Topoğrafya",
|
||||
x: 0,
|
||||
z: 0,
|
||||
elevation: 0,
|
||||
size: Math.max(width, depth),
|
||||
const previewResult = generateAdvancedTerrainWithPad({
|
||||
preset,
|
||||
width,
|
||||
depth,
|
||||
height: Math.max(5, maxHeight),
|
||||
rotation: 0,
|
||||
importedMesh: {
|
||||
positions,
|
||||
normals,
|
||||
baseWidth: width,
|
||||
baseDepth: depth,
|
||||
baseHeight: maxHeight,
|
||||
triangleCount: positions.length / 9,
|
||||
sourceFormat: "json",
|
||||
},
|
||||
};
|
||||
maxHeight,
|
||||
gridResolution: 16,
|
||||
texture,
|
||||
includeBuildingPad,
|
||||
});
|
||||
|
||||
onAddShape(terrainShape);
|
||||
const handleGenerate = () => {
|
||||
onAddShape(previewResult.terrainShape);
|
||||
if (previewResult.padShape) {
|
||||
onAddShape(previewResult.padShape);
|
||||
}
|
||||
onClose();
|
||||
};
|
||||
|
||||
@@ -168,7 +68,7 @@ export const TerrainGeneratorModal: React.FC<TerrainGeneratorModalProps> = ({
|
||||
Arazi & Topoğrafya Oluşturucu
|
||||
</h2>
|
||||
<p className="text-xs text-slate-500 dark:text-slate-400">
|
||||
Binanızı kot farkı ve eğimli araziye oturtun
|
||||
Simplex-Noise + Delaunator üçgenleme ve bina oturum hafriyat hesabı
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -191,15 +91,16 @@ export const TerrainGeneratorModal: React.FC<TerrainGeneratorModalProps> = ({
|
||||
</label>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
{[
|
||||
{ id: "hills", label: "Dalgalı Tepe", desc: "Doğal yükseltiler" },
|
||||
{ id: "hills", label: "Dalgalı Tepe", desc: "Simplex doğal yükseltiler" },
|
||||
{ id: "slope", label: "Eğimli Arsa", desc: "Tek yöne meyil" },
|
||||
{ id: "terrace", label: "Teraslı Plato", desc: "Kademeli kotlar" },
|
||||
{ id: "valley", label: "Vadi / Çukur", desc: "Ortası alçak" },
|
||||
{ id: "terrace", label: "Teraslı Plato", desc: "Eşyükselti kademeli kotlar" },
|
||||
{ id: "valley", label: "Vadi / Çukur", desc: "Ortası alçak vadi" },
|
||||
{ id: "coastal-ridge", label: "Kıyı Sırtı", desc: "Yamaç ve sırt hattı" },
|
||||
].map((item) => (
|
||||
<button
|
||||
key={item.id}
|
||||
type="button"
|
||||
onClick={() => setPreset(item.id as TerrainPreset)}
|
||||
onClick={() => setPreset(item.id as TerrainTopographyPreset)}
|
||||
className={`flex flex-col items-start rounded-xl border p-2.5 text-left transition-all ${
|
||||
preset === item.id
|
||||
? "border-emerald-500 bg-emerald-50/70 text-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-200"
|
||||
@@ -246,6 +147,32 @@ export const TerrainGeneratorModal: React.FC<TerrainGeneratorModalProps> = ({
|
||||
onChange={(e) => setMaxHeight(Number(e.target.value))}
|
||||
className="w-full accent-emerald-600"
|
||||
/>
|
||||
|
||||
<label className="flex items-center justify-between pt-2 text-xs font-medium text-slate-700 dark:text-slate-200 cursor-pointer">
|
||||
<span>Bina Oturum Düzlüğü (Tesviye Kotu & Hafriyat)</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={includeBuildingPad}
|
||||
onChange={(e) => setIncludeBuildingPad(e.target.checked)}
|
||||
className="h-4 w-4 accent-emerald-600"
|
||||
/>
|
||||
</label>
|
||||
{includeBuildingPad ? (
|
||||
<div className="grid grid-cols-3 gap-2 pt-1 text-center text-[11px]">
|
||||
<div className="rounded-lg bg-white p-1.5 dark:bg-slate-800">
|
||||
<span className="block text-slate-400">Kazı (Hafriyat)</span>
|
||||
<strong className="text-amber-600 dark:text-amber-400">{previewResult.excavationCutVolumeM3} m³</strong>
|
||||
</div>
|
||||
<div className="rounded-lg bg-white p-1.5 dark:bg-slate-800">
|
||||
<span className="block text-slate-400">Dolgu Hacmi</span>
|
||||
<strong className="text-sky-600 dark:text-sky-400">{previewResult.embankmentFillVolumeM3} m³</strong>
|
||||
</div>
|
||||
<div className="rounded-lg bg-white p-1.5 dark:bg-slate-800">
|
||||
<span className="block text-slate-400">Delaunay Ağ</span>
|
||||
<strong className="text-emerald-600 dark:text-emerald-400">{previewResult.triangleCount} üçgen</strong>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{/* Texture */}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -9,12 +9,14 @@ const VALID_DESKTOP_MENU_ACTIONS = new Set<DesktopMenuAction>([
|
||||
"file:save",
|
||||
"file:save-as",
|
||||
"file:save-and-quit",
|
||||
"file:save-and-update",
|
||||
"file:import",
|
||||
"file:export-panel",
|
||||
"file:export-skf",
|
||||
"file:export-stl",
|
||||
"file:export-3mf",
|
||||
"file:export-step",
|
||||
"file:export-ifc",
|
||||
"file:export-obj",
|
||||
"file:export-glb",
|
||||
"file:export-dxf",
|
||||
@@ -115,6 +117,10 @@ const VALID_DESKTOP_MENU_ACTIONS = new Set<DesktopMenuAction>([
|
||||
"tool:walk",
|
||||
"tool:wall-opening",
|
||||
"tool:terrain",
|
||||
"tool:bim-studio",
|
||||
"tool:bim-storeys",
|
||||
"tool:bim-boq",
|
||||
"tool:bim-code-audit",
|
||||
"tool:structural-test",
|
||||
"tool:ar-preview",
|
||||
"tool:physics-toggle",
|
||||
@@ -160,6 +166,7 @@ const GLOBAL_DESKTOP_MENU_ACTIONS = new Set<DesktopMenuAction>([
|
||||
"file:save",
|
||||
"file:save-as",
|
||||
"file:save-and-quit",
|
||||
"file:save-and-update",
|
||||
"file:import",
|
||||
"file:dashboard",
|
||||
"window:drawing",
|
||||
@@ -290,6 +297,44 @@ export function formatFriendlyUpdateError(rawMessage?: unknown): string {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats byte counts into compact Turkish size strings (KB / MB / GB).
|
||||
*/
|
||||
export function formatUpdateBytes(rawBytes: number): string {
|
||||
const bytes = Number.isFinite(rawBytes) && rawBytes > 0 ? rawBytes : 0;
|
||||
if (bytes < 1024) return `${Math.round(bytes)} B`;
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(bytes < 10 * 1024 ? 1 : 0)} KB`;
|
||||
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
||||
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats live updater download transfer progress and throughput telemetry.
|
||||
*/
|
||||
export function formatUpdateTransferSummary(
|
||||
state?: {
|
||||
transferred?: number;
|
||||
total?: number;
|
||||
bytesPerSecond?: number;
|
||||
} | null,
|
||||
): string {
|
||||
if (!state) return "";
|
||||
const transferred = Number(state.transferred ?? 0);
|
||||
const total = Number(state.total ?? 0);
|
||||
const bytesPerSecond = Number(state.bytesPerSecond ?? 0);
|
||||
const parts: string[] = [];
|
||||
if (total > 0) {
|
||||
const clampedTransferred = Math.min(Math.max(0, transferred), total);
|
||||
parts.push(`${formatUpdateBytes(clampedTransferred)} / ${formatUpdateBytes(total)}`);
|
||||
} else if (transferred > 0) {
|
||||
parts.push(`${formatUpdateBytes(transferred)} indirildi`);
|
||||
}
|
||||
if (bytesPerSecond > 0) {
|
||||
parts.push(`${formatUpdateBytes(bytesPerSecond)}/sn`);
|
||||
}
|
||||
return parts.join(" • ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds Electron file-dialog extension filters from a suggested filename.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type ProjectExportFormat = "3mf" | "stl" | "obj" | "step" | "dxf" | "svg" | "glb" | "skf";
|
||||
export type ProjectExportFormat = "3mf" | "stl" | "obj" | "step" | "ifc" | "dxf" | "svg" | "glb" | "skf";
|
||||
|
||||
export function projectExportFileName(projectName: string, format: ProjectExportFormat) {
|
||||
const safeProjectName = projectName
|
||||
|
||||
@@ -0,0 +1,550 @@
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
export type IfcBimEntityClass =
|
||||
| "IFCWALL"
|
||||
| "IFCSLAB"
|
||||
| "IFCCOLUMN"
|
||||
| "IFCBEAM"
|
||||
| "IFCROOF"
|
||||
| "IFCSTAIR"
|
||||
| "IFCRAILING"
|
||||
| "IFCWINDOW"
|
||||
| "IFCDOOR"
|
||||
| "IFCFURNISHINGELEMENT"
|
||||
| "IFCBUILDINGELEMENTPROXY";
|
||||
|
||||
export interface IfcExportOptions {
|
||||
projectName?: string;
|
||||
authorName?: string;
|
||||
organizationName?: string;
|
||||
siteName?: string;
|
||||
buildingName?: string;
|
||||
scaleFactorToMm?: number;
|
||||
}
|
||||
|
||||
export interface IfcExportSummary {
|
||||
ifcText: string;
|
||||
bytes: Uint8Array;
|
||||
productCount: number;
|
||||
storeyCount: number;
|
||||
entityBreakdown: Record<IfcBimEntityClass, number>;
|
||||
}
|
||||
|
||||
const IFC_GUID_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$";
|
||||
|
||||
/**
|
||||
* Generates a deterministic 22-character IFC GloballyUniqueId (Base64-64) from a seed string.
|
||||
*/
|
||||
export function makeIfcGuid(seed: string): string {
|
||||
let h1 = 0x811c9dc5;
|
||||
let h2 = 0x01000193;
|
||||
for (let i = 0; i < seed.length; i++) {
|
||||
const code = seed.charCodeAt(i);
|
||||
h1 ^= code;
|
||||
h1 = Math.imul(h1, 0x01000193);
|
||||
h2 ^= code + i * 31;
|
||||
h2 = Math.imul(h2, 0x85ebca6b);
|
||||
}
|
||||
const chars: string[] = [];
|
||||
for (let i = 0; i < 22; i++) {
|
||||
const mixed = Math.abs(Math.imul(h1 ^ (h2 >>> (i % 16)), i + 17) + i * 97);
|
||||
const idx = i === 0 ? mixed % 4 : mixed % 64;
|
||||
chars.push(IFC_GUID_CHARS[idx]);
|
||||
}
|
||||
return chars.join("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes text for STEP ISO-10303-21 strings (ASCII-safe with Turkish character transliteration fallback).
|
||||
*/
|
||||
function escapeStepString(input: string): string {
|
||||
return input
|
||||
.replace(/\\/g, "\\\\")
|
||||
.replace(/'/g, "''")
|
||||
.replace(/ğ/g, "g")
|
||||
.replace(/Ğ/g, "G")
|
||||
.replace(/ü/g, "u")
|
||||
.replace(/Ü/g, "U")
|
||||
.replace(/ş/g, "s")
|
||||
.replace(/Ş/g, "S")
|
||||
.replace(/ı/g, "i")
|
||||
.replace(/İ/g, "I")
|
||||
.replace(/ö/g, "o")
|
||||
.replace(/Ö/g, "O")
|
||||
.replace(/ç/g, "c")
|
||||
.replace(/Ç/g, "C");
|
||||
}
|
||||
|
||||
function fmtNum(val: number): string {
|
||||
if (!Number.isFinite(val)) return "0.";
|
||||
const rounded = Number(val.toFixed(4));
|
||||
if (Number.isInteger(rounded)) return `${rounded}.`;
|
||||
return String(rounded);
|
||||
}
|
||||
|
||||
function hexToRgb01(hex: string | undefined): [number, number, number] {
|
||||
const clean = (hex || "#94a3b8").replace("#", "").trim();
|
||||
if (clean.length !== 6) return [0.58, 0.64, 0.72];
|
||||
const r = parseInt(clean.slice(0, 2), 16);
|
||||
const g = parseInt(clean.slice(2, 4), 16);
|
||||
const b = parseInt(clean.slice(4, 6), 16);
|
||||
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
||||
return [0.58, 0.64, 0.72];
|
||||
}
|
||||
return [
|
||||
Number((r / 255).toFixed(3)),
|
||||
Number((g / 255).toFixed(3)),
|
||||
Number((b / 255).toFixed(3)),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Classifies a WorkplaneShape into an IFC4 BIM Entity Class based on its tag, name, and geometry.
|
||||
*/
|
||||
export function classifyShapeForIfc(shape: WorkplaneShape): IfcBimEntityClass {
|
||||
const haystack = `${shape.tag || ""} ${shape.name || ""} ${shape.kind || ""}`.toLocaleLowerCase("tr-TR");
|
||||
|
||||
if (haystack.includes("duvar") || haystack.includes("wall") || haystack.includes("parapet") || haystack.includes("bölme")) {
|
||||
return "IFCWALL";
|
||||
}
|
||||
if (haystack.includes("çatı") || haystack.includes("cati") || haystack.includes("roof") || shape.kind === "roundRoof") {
|
||||
return "IFCROOF";
|
||||
}
|
||||
if (
|
||||
haystack.includes("döşeme") ||
|
||||
haystack.includes("doseme") ||
|
||||
haystack.includes("zemin") ||
|
||||
haystack.includes("tabliye") ||
|
||||
haystack.includes("slab") ||
|
||||
haystack.includes("teras") ||
|
||||
haystack.includes("sahanlık")
|
||||
) {
|
||||
return "IFCSLAB";
|
||||
}
|
||||
if (haystack.includes("kolon") || haystack.includes("column") || haystack.includes("dikme") || haystack.includes("pilon")) {
|
||||
return "IFCCOLUMN";
|
||||
}
|
||||
if (haystack.includes("kiriş") || haystack.includes("kiris") || haystack.includes("beam") || haystack.includes("makas") || haystack.includes("truss") || haystack.includes("lento")) {
|
||||
return "IFCBEAM";
|
||||
}
|
||||
if (haystack.includes("merdiven") || haystack.includes("basamak") || haystack.includes("stair") || haystack.includes("rampa")) {
|
||||
return "IFCSTAIR";
|
||||
}
|
||||
if (haystack.includes("korkuluk") || haystack.includes("küpeşte") || haystack.includes("kupeste") || haystack.includes("railing") || haystack.includes("balustrade")) {
|
||||
return "IFCRAILING";
|
||||
}
|
||||
if (haystack.includes("pencere") || haystack.includes("window") || haystack.includes("cam") || haystack.includes("doğrama")) {
|
||||
return "IFCWINDOW";
|
||||
}
|
||||
if (haystack.includes("kapı") || haystack.includes("kapi") || haystack.includes("door")) {
|
||||
return "IFCDOOR";
|
||||
}
|
||||
if (
|
||||
haystack.includes("mobilya") ||
|
||||
haystack.includes("tefriş") ||
|
||||
haystack.includes("koltuk") ||
|
||||
haystack.includes("masa") ||
|
||||
haystack.includes("sandalye") ||
|
||||
haystack.includes("yatak") ||
|
||||
haystack.includes("dolap") ||
|
||||
haystack.includes("mutfak") ||
|
||||
haystack.includes("banyo")
|
||||
) {
|
||||
return "IFCFURNISHINGELEMENT";
|
||||
}
|
||||
|
||||
// Heuristic fallback for untagged architectural slabs vs walls
|
||||
const w = Math.max(1, shape.width);
|
||||
const d = Math.max(1, shape.depth);
|
||||
const h = Math.max(1, shape.height);
|
||||
if (shape.kind === "box") {
|
||||
if (h <= Math.min(w, d) * 0.2 && Math.max(w, d) >= 40) {
|
||||
return "IFCSLAB";
|
||||
}
|
||||
if (Math.min(w, d) <= Math.max(w, d) * 0.25 && h >= Math.min(w, d) * 2) {
|
||||
return "IFCWALL";
|
||||
}
|
||||
}
|
||||
if (shape.kind === "cylinder" && h >= Math.max(w, d) * 2.5) {
|
||||
return "IFCCOLUMN";
|
||||
}
|
||||
|
||||
return "IFCBUILDINGELEMENTPROXY";
|
||||
}
|
||||
|
||||
function inferStoreyInfo(shape: WorkplaneShape, scaleFactorToMm: number): { key: string; name: string; elevationMm: number } {
|
||||
const tag = (shape.tag || "").trim();
|
||||
const tagLower = tag.toLocaleLowerCase("tr-TR");
|
||||
const elevMm = Math.round((shape.elevation || 0) * scaleFactorToMm);
|
||||
|
||||
if (tagLower.includes("bodrum")) {
|
||||
return { key: "storey-basement", name: "Bodrum Kat", elevationMm: Math.min(0, elevMm) };
|
||||
}
|
||||
if (tagLower.includes("zemin")) {
|
||||
return { key: "storey-ground", name: "Zemin Kat", elevationMm: 0 };
|
||||
}
|
||||
const floorMatch = tag.match(/(\d+)\.\s*(normal\s*)?kat/i);
|
||||
if (floorMatch) {
|
||||
const floorNum = parseInt(floorMatch[1], 10);
|
||||
return {
|
||||
key: `storey-${floorNum}`,
|
||||
name: `${floorNum}. Normal Kat`,
|
||||
elevationMm: floorNum * 3000,
|
||||
};
|
||||
}
|
||||
if (tagLower.includes("çatı kat") || tagLower.includes("teras kat")) {
|
||||
return { key: "storey-roof", name: "Cati Kati", elevationMm: Math.max(3000, elevMm) };
|
||||
}
|
||||
|
||||
// Group by elevation bands (every 3000 mm in 1:1 scale, or 36 units in 1:100 maket scale)
|
||||
const rawElev = shape.elevation || 0;
|
||||
if (rawElev < -1) {
|
||||
return { key: "storey-basement", name: "Bodrum Kat", elevationMm: elevMm };
|
||||
}
|
||||
const bandHeight = scaleFactorToMm > 10 ? 32 : 3000;
|
||||
const floorIdx = Math.max(0, Math.floor(rawElev / bandHeight));
|
||||
if (floorIdx === 0) {
|
||||
return { key: "storey-ground", name: "Zemin Kat", elevationMm: 0 };
|
||||
}
|
||||
return {
|
||||
key: `storey-${floorIdx}`,
|
||||
name: `${floorIdx}. Normal Kat`,
|
||||
elevationMm: Math.round(floorIdx * bandHeight * scaleFactorToMm),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports active 3D shapes into a standards-compliant ISO-10303-21 IFC4 BIM model.
|
||||
* Compatible with web-ifc, Autodesk Revit, Graphisoft ArchiCAD, Tekla, FreeCAD, and BlenderBIM.
|
||||
*/
|
||||
export function exportShapesToIfc4(
|
||||
shapes: WorkplaneShape[],
|
||||
options: IfcExportOptions = {},
|
||||
): IfcExportSummary {
|
||||
const solidShapes = shapes.filter((s) => !s.hole && !s.hidden);
|
||||
if (solidShapes.length === 0) {
|
||||
throw new Error("IFC4 dışa aktarımı için sahnede en az bir görünür katı (solid) nesne bulunmalıdır.");
|
||||
}
|
||||
|
||||
const projectName = escapeStepString(options.projectName?.trim() || "SnapCAD Mimari BIM Projesi");
|
||||
const authorName = escapeStepString(options.authorName?.trim() || "SnapCAD Architect");
|
||||
const organizationName = escapeStepString(options.organizationName?.trim() || "SnapCAD Studio");
|
||||
const siteName = escapeStepString(options.siteName?.trim() || "Proje Arsasi");
|
||||
const buildingName = escapeStepString(options.buildingName?.trim() || "Ana Bina");
|
||||
const scale = options.scaleFactorToMm && options.scaleFactorToMm > 0 ? options.scaleFactorToMm : 1;
|
||||
|
||||
let nextId = 1;
|
||||
const lines: string[] = [];
|
||||
const addEntity = (definition: string): number => {
|
||||
const id = nextId++;
|
||||
lines.push(`#${id}=${definition};`);
|
||||
return id;
|
||||
};
|
||||
|
||||
// 1. Ownership & Context
|
||||
const personId = addEntity(`IFCPERSON($,$,'${authorName}',$,$,$,$,$)`);
|
||||
const orgId = addEntity(`IFCORGANIZATION($,'${organizationName}',$,$,$)`);
|
||||
const personOrgId = addEntity(`IFCPERSONANDORGANIZATION(#${personId},#${orgId},$)`);
|
||||
const appId = addEntity(`IFCAPPLICATION(#${orgId},'1.0.11','SnapCAD Studio','SnapCAD_IFC4')`);
|
||||
const ownerHistoryId = addEntity(`IFCOWNERHISTORY(#${personOrgId},#${appId},$,.NOCHANGE.,$,$,$,1700000000)`);
|
||||
|
||||
const origin3dId = addEntity(`IFCCARTESIANPOINT((0.,0.,0.))`);
|
||||
const dirZId = addEntity(`IFCDIRECTION((0.,0.,1.))`);
|
||||
const dirXId = addEntity(`IFCDIRECTION((1.,0.,0.))`);
|
||||
const dirYId = addEntity(`IFCDIRECTION((0.,1.,0.))`);
|
||||
const worldPlacement3dId = addEntity(`IFCAXIS2PLACEMENT3D(#${origin3dId},#${dirZId},#${dirXId})`);
|
||||
const origin2dId = addEntity(`IFCCARTESIANPOINT((0.,0.))`);
|
||||
const placement2dId = addEntity(`IFCAXIS2PLACEMENT2D(#${origin2dId},$)`);
|
||||
|
||||
const geomContextId = addEntity(
|
||||
`IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,1.E-05,#${worldPlacement3dId},$)`,
|
||||
);
|
||||
|
||||
// Units: Millimetre, Square Metre, Cubic Metre, Radian
|
||||
const lengthUnitId = addEntity(`IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.)`);
|
||||
const areaUnitId = addEntity(`IFCSIUNIT(*,.AREAUNIT.,$,.SQUARE_METRE.)`);
|
||||
const volumeUnitId = addEntity(`IFCSIUNIT(*,.VOLUMEUNIT.,$,.CUBIC_METRE.)`);
|
||||
const angleUnitId = addEntity(`IFCSIUNIT(*,.PLANEANGLEUNIT.,$,.RADIAN.)`);
|
||||
const unitAssignmentId = addEntity(
|
||||
`IFCUNITASSIGNMENT((#${lengthUnitId},#${areaUnitId},#${volumeUnitId},#${angleUnitId}))`,
|
||||
);
|
||||
|
||||
const projectId = addEntity(
|
||||
`IFCPROJECT('${makeIfcGuid(`project:${projectName}`)}',#${ownerHistoryId},'${projectName}','SnapCAD Studio IFC4 BIM Export',$,$,$,(#${geomContextId}),#${unitAssignmentId})`,
|
||||
);
|
||||
|
||||
// Spatial Hierarchy: Project -> Site -> Building -> Storeys
|
||||
const sitePlacementId = addEntity(`IFCLOCALPLACEMENT($,#${worldPlacement3dId})`);
|
||||
const siteId = addEntity(
|
||||
`IFCSITE('${makeIfcGuid(`site:${siteName}`)}',#${ownerHistoryId},'${siteName}',$,$,#${sitePlacementId},$,$,.ELEMENT.,$,$,$,$,$)`,
|
||||
);
|
||||
|
||||
const buildingPlacementId = addEntity(`IFCLOCALPLACEMENT(#${sitePlacementId},#${worldPlacement3dId})`);
|
||||
const buildingId = addEntity(
|
||||
`IFCBUILDING('${makeIfcGuid(`building:${buildingName}`)}',#${ownerHistoryId},'${buildingName}',$,$,#${buildingPlacementId},$,$,.ELEMENT.,$,$,$)`,
|
||||
);
|
||||
|
||||
addEntity(
|
||||
`IFCRELAGGREGATES('${makeIfcGuid("rel:project-site")}',#${ownerHistoryId},'ProjectToSite',$,#${projectId},(#${siteId}))`,
|
||||
);
|
||||
addEntity(
|
||||
`IFCRELAGGREGATES('${makeIfcGuid("rel:site-building")}',#${ownerHistoryId},'SiteToBuilding',$,#${siteId},(#${buildingId}))`,
|
||||
);
|
||||
|
||||
// Group shapes by storey
|
||||
const storeyMap = new Map<
|
||||
string,
|
||||
{ key: string; name: string; elevationMm: number; productIds: number[]; storeyEntityId?: number }
|
||||
>();
|
||||
|
||||
const entityBreakdown: Record<IfcBimEntityClass, number> = {
|
||||
IFCWALL: 0,
|
||||
IFCSLAB: 0,
|
||||
IFCCOLUMN: 0,
|
||||
IFCBEAM: 0,
|
||||
IFCROOF: 0,
|
||||
IFCSTAIR: 0,
|
||||
IFCRAILING: 0,
|
||||
IFCWINDOW: 0,
|
||||
IFCDOOR: 0,
|
||||
IFCFURNISHINGELEMENT: 0,
|
||||
IFCBUILDINGELEMENTPROXY: 0,
|
||||
};
|
||||
|
||||
for (let idx = 0; idx < solidShapes.length; idx++) {
|
||||
const shape = solidShapes[idx];
|
||||
const ifcClass = classifyShapeForIfc(shape);
|
||||
entityBreakdown[ifcClass] += 1;
|
||||
|
||||
const storeyInfo = inferStoreyInfo(shape, scale);
|
||||
let storeyRecord = storeyMap.get(storeyInfo.key);
|
||||
if (!storeyRecord) {
|
||||
storeyRecord = {
|
||||
...storeyInfo,
|
||||
productIds: [],
|
||||
};
|
||||
storeyMap.set(storeyInfo.key, storeyRecord);
|
||||
}
|
||||
|
||||
const widthMm = Math.max(1, shape.width * scale);
|
||||
const depthMm = Math.max(1, shape.depth * scale);
|
||||
const heightMm = Math.max(1, shape.height * scale);
|
||||
const centerXMm = (shape.x || 0) * scale;
|
||||
// Note: in IFC, X-Y is ground plane and +Z is vertical elevation!
|
||||
// In SketchForge, X-Z is ground plane and +Y (elevation) is vertical!
|
||||
const centerYMm = -(shape.z || 0) * scale;
|
||||
const baseElevationMm = (shape.elevation || 0) * scale;
|
||||
|
||||
const rotDeg = shape.rotation || 0;
|
||||
const rotRad = (-rotDeg * Math.PI) / 180;
|
||||
const cosR = Math.cos(rotRad);
|
||||
const sinR = Math.sin(rotRad);
|
||||
|
||||
const locPointId = addEntity(
|
||||
`IFCCARTESIANPOINT((${fmtNum(centerXMm)},${fmtNum(centerYMm)},${fmtNum(baseElevationMm)}))`,
|
||||
);
|
||||
const refDirId =
|
||||
Math.abs(rotDeg) > 0.001
|
||||
? addEntity(`IFCDIRECTION((${fmtNum(cosR)},${fmtNum(sinR)},0.))`)
|
||||
: dirXId;
|
||||
const axis3dId = addEntity(`IFCAXIS2PLACEMENT3D(#${locPointId},#${dirZId},#${refDirId})`);
|
||||
const localPlacementId = addEntity(`IFCLOCALPLACEMENT(#${buildingPlacementId},#${axis3dId})`);
|
||||
|
||||
// Build Solid Representation:
|
||||
// Use CircleProfileDef for cylinders, or FacetedBrep for custom imported meshes ( up to 400 triangles ), or RectangleProfileDef
|
||||
let solidItemId: number;
|
||||
let representationType = "SweptSolid";
|
||||
|
||||
const meshPositions = shape.importedMesh?.positions;
|
||||
if (
|
||||
meshPositions &&
|
||||
meshPositions.length >= 9 &&
|
||||
meshPositions.length <= 3600 &&
|
||||
meshPositions.length % 9 === 0
|
||||
) {
|
||||
// Export as IFCFACETEDBREP for exact custom mesh topology (e.g., roofs, terrain, custom extrusions)
|
||||
const faceIds: number[] = [];
|
||||
const scaleX = (shape.width / Math.max(1e-3, shape.importedMesh?.baseWidth || shape.width)) * scale;
|
||||
const scaleY = (shape.depth / Math.max(1e-3, shape.importedMesh?.baseDepth || shape.depth)) * scale;
|
||||
const scaleZ = (shape.height / Math.max(1e-3, shape.importedMesh?.baseHeight || shape.height)) * scale;
|
||||
|
||||
for (let t = 0; t < meshPositions.length; t += 9) {
|
||||
// Convert local SketchForge (x, y=up, z) -> IFC local (x, -z, y=up)
|
||||
const p1Id = addEntity(
|
||||
`IFCCARTESIANPOINT((${fmtNum(meshPositions[t] * scaleX)},${fmtNum(-meshPositions[t + 2] * scaleY)},${fmtNum(meshPositions[t + 1] * scaleZ)}))`,
|
||||
);
|
||||
const p2Id = addEntity(
|
||||
`IFCCARTESIANPOINT((${fmtNum(meshPositions[t + 3] * scaleX)},${fmtNum(-meshPositions[t + 5] * scaleY)},${fmtNum(meshPositions[t + 4] * scaleZ)}))`,
|
||||
);
|
||||
const p3Id = addEntity(
|
||||
`IFCCARTESIANPOINT((${fmtNum(meshPositions[t + 6] * scaleX)},${fmtNum(-meshPositions[t + 8] * scaleY)},${fmtNum(meshPositions[t + 7] * scaleZ)}))`,
|
||||
);
|
||||
const loopId = addEntity(`IFCPOLYLOOP((#${p1Id},#${p2Id},#${p3Id}))`);
|
||||
const boundId = addEntity(`IFCFACEOUTERBOUND(#${loopId},.T.)`);
|
||||
const faceId = addEntity(`IFCFACE((#${boundId}))`);
|
||||
faceIds.push(faceId);
|
||||
}
|
||||
const shellId = addEntity(`IFCCLOSEDSHELL((${faceIds.map((id) => `#${id}`).join(",")}))`);
|
||||
solidItemId = addEntity(`IFCFACETEDBREP(#${shellId})`);
|
||||
representationType = "Brep";
|
||||
} else if (shape.kind === "cylinder" || shape.kind === "cone" || shape.kind === "sphere") {
|
||||
const radiusMm = Math.max(0.5, Math.min(widthMm, depthMm) / 2);
|
||||
const profileId = addEntity(`IFCCIRCLEPROFILEDEF(.AREA.,$,#${placement2dId},${fmtNum(radiusMm)})`);
|
||||
solidItemId = addEntity(
|
||||
`IFCEXTRUDEDAREASOLID(#${profileId},#${worldPlacement3dId},#${dirZId},${fmtNum(heightMm)})`,
|
||||
);
|
||||
} else {
|
||||
const profileId = addEntity(
|
||||
`IFCRECTANGLEPROFILEDEF(.AREA.,$,#${placement2dId},${fmtNum(widthMm)},${fmtNum(depthMm)})`,
|
||||
);
|
||||
solidItemId = addEntity(
|
||||
`IFCEXTRUDEDAREASOLID(#${profileId},#${worldPlacement3dId},#${dirZId},${fmtNum(heightMm)})`,
|
||||
);
|
||||
}
|
||||
|
||||
// Surface color style
|
||||
const [r, g, b] = hexToRgb01(shape.color);
|
||||
const colId = addEntity(`IFCCOLOURRGB($,${fmtNum(r)},${fmtNum(g)},${fmtNum(b)})`);
|
||||
const renderingId = addEntity(
|
||||
`IFCSURFACESTYLERENDERING(#${colId},0.,$,$,$,$,$,$,.NOTDEFINED.)`,
|
||||
);
|
||||
const surfStyleId = addEntity(`IFCSURFACESTYLE('${escapeStepString(shape.name || "Style")}',.BOTH.,(#${renderingId}))`);
|
||||
addEntity(`IFCSTYLEDITEM(#${solidItemId},(#${surfStyleId}),$)`);
|
||||
|
||||
const shapeRepId = addEntity(
|
||||
`IFCSHAPEREPRESENTATION(#${geomContextId},'Body','${representationType}',(#${solidItemId}))`,
|
||||
);
|
||||
const prodDefShapeId = addEntity(`IFCPRODUCTDEFINITIONSHAPE($,$,(#${shapeRepId}))`);
|
||||
|
||||
const safeName = escapeStepString(shape.name || `Eleman_${idx + 1}`);
|
||||
const safeTag = escapeStepString(shape.tag || "Genel");
|
||||
const guid = makeIfcGuid(`shape:${shape.id || idx}:${safeName}`);
|
||||
|
||||
let productId: number;
|
||||
switch (ifcClass) {
|
||||
case "IFCWALL":
|
||||
productId = addEntity(
|
||||
`IFCWALL('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',.STANDARD.)`,
|
||||
);
|
||||
break;
|
||||
case "IFCSLAB":
|
||||
productId = addEntity(
|
||||
`IFCSLAB('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',.FLOOR.)`,
|
||||
);
|
||||
break;
|
||||
case "IFCCOLUMN":
|
||||
productId = addEntity(
|
||||
`IFCCOLUMN('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',.COLUMN.)`,
|
||||
);
|
||||
break;
|
||||
case "IFCBEAM":
|
||||
productId = addEntity(
|
||||
`IFCBEAM('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',.BEAM.)`,
|
||||
);
|
||||
break;
|
||||
case "IFCROOF":
|
||||
productId = addEntity(
|
||||
`IFCROOF('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',.GABLE_ROOF.)`,
|
||||
);
|
||||
break;
|
||||
case "IFCSTAIR":
|
||||
productId = addEntity(
|
||||
`IFCSTAIR('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',.STRAIGHT_RUN_STAIR.)`,
|
||||
);
|
||||
break;
|
||||
case "IFCRAILING":
|
||||
productId = addEntity(
|
||||
`IFCRAILING('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',.BALUSTRADE.)`,
|
||||
);
|
||||
break;
|
||||
case "IFCWINDOW":
|
||||
productId = addEntity(
|
||||
`IFCWINDOW('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',${fmtNum(heightMm)},${fmtNum(widthMm)},.WINDOW.,.SINGLE_PANEL.,$)`,
|
||||
);
|
||||
break;
|
||||
case "IFCDOOR":
|
||||
productId = addEntity(
|
||||
`IFCDOOR('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',${fmtNum(heightMm)},${fmtNum(widthMm)},.DOOR.,.SINGLE_SWING_LEFT.,$)`,
|
||||
);
|
||||
break;
|
||||
case "IFCFURNISHINGELEMENT":
|
||||
productId = addEntity(
|
||||
`IFCFURNISHINGELEMENT('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}')`,
|
||||
);
|
||||
break;
|
||||
default:
|
||||
productId = addEntity(
|
||||
`IFCBUILDINGELEMENTPROXY('${guid}',#${ownerHistoryId},'${safeName}','${safeTag}',$,#${localPlacementId},#${prodDefShapeId},'${shape.id}',.ELEMENT.)`,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
// Attach Base Quantities (BIM 5D Metraj: Area m², Volume m³, Length mm)
|
||||
const footprintAreaM2 = (widthMm * depthMm) / 1_000_000;
|
||||
const sideAreaM2 = (Math.max(widthMm, depthMm) * heightMm) / 1_000_000;
|
||||
const volumeM3 = (widthMm * depthMm * heightMm) / 1_000_000_000;
|
||||
|
||||
const qLenId = addEntity(`IFCQUANTITYLENGTH('Length',$,$,${fmtNum(Math.max(widthMm, depthMm))},$)`);
|
||||
const qHeightId = addEntity(`IFCQUANTITYLENGTH('Height',$,$,${fmtNum(heightMm)},$)`);
|
||||
const qAreaId = addEntity(
|
||||
`IFCQUANTITYAREA('${ifcClass === "IFCWALL" ? "NetSideArea" : "GrossFloorArea"}',$,$,${fmtNum(ifcClass === "IFCWALL" ? sideAreaM2 : footprintAreaM2)},$)`,
|
||||
);
|
||||
const qVolId = addEntity(`IFCQUANTITYVOLUME('NetVolume',$,$,${fmtNum(volumeM3)},$)`);
|
||||
const elemQtyId = addEntity(
|
||||
`IFCELEMENTQUANTITY('${makeIfcGuid(`qto:${shape.id || idx}`)}',#${ownerHistoryId},'BaseQuantities',$,'SnapCAD_BOQ',(#${qLenId},#${qHeightId},#${qAreaId},#${qVolId}))`,
|
||||
);
|
||||
addEntity(
|
||||
`IFCRELDEFINESBYPROPERTIES('${makeIfcGuid(`relqto:${shape.id || idx}`)}',#${ownerHistoryId},'QuantityLink',$,(#${productId}),#${elemQtyId})`,
|
||||
);
|
||||
|
||||
storeyRecord.productIds.push(productId);
|
||||
}
|
||||
|
||||
// Emit IfcBuildingStorey entities and link products
|
||||
const storeyEntityIds: number[] = [];
|
||||
const sortedStoreys = Array.from(storeyMap.values()).sort((a, b) => a.elevationMm - b.elevationMm);
|
||||
for (const st of sortedStoreys) {
|
||||
const stPointId = addEntity(`IFCCARTESIANPOINT((0.,0.,${fmtNum(st.elevationMm)}))`);
|
||||
const stAxisId = addEntity(`IFCAXIS2PLACEMENT3D(#${stPointId},#${dirZId},#${dirXId})`);
|
||||
const stPlacementId = addEntity(`IFCLOCALPLACEMENT(#${buildingPlacementId},#${stAxisId})`);
|
||||
const stEntityId = addEntity(
|
||||
`IFCBUILDINGSTOREY('${makeIfcGuid(`storey:${st.key}`)}',#${ownerHistoryId},'${escapeStepString(st.name)}',$,$,#${stPlacementId},$,$,.ELEMENT.,${fmtNum(st.elevationMm)})`,
|
||||
);
|
||||
storeyEntityIds.push(stEntityId);
|
||||
|
||||
if (st.productIds.length > 0) {
|
||||
addEntity(
|
||||
`IFCRELCONTAINEDINSPATIALSTRUCTURE('${makeIfcGuid(`relspatial:${st.key}`)}',#${ownerHistoryId},'StoreyContainer',$,(${st.productIds.map((id) => `#${id}`).join(",")}),#${stEntityId})`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (storeyEntityIds.length > 0) {
|
||||
addEntity(
|
||||
`IFCRELAGGREGATES('${makeIfcGuid("rel:building-storeys")}',#${ownerHistoryId},'BuildingToStoreys',$,#${buildingId},(${storeyEntityIds.map((id) => `#${id}`).join(",")}))`,
|
||||
);
|
||||
}
|
||||
|
||||
const timestampIso = new Date().toISOString().slice(0, 19);
|
||||
const header = [
|
||||
"ISO-10303-21;",
|
||||
"HEADER;",
|
||||
"FILE_DESCRIPTION(('ViewDefinition [CoordinationView_V2.0]'),'2;1');",
|
||||
`FILE_NAME('${projectName}.ifc','${timestampIso}',('${authorName}'),('${organizationName}'),'SnapCAD Studio 1.0.11','SnapCAD IFC4 BIM Engine','');`,
|
||||
"FILE_SCHEMA(('IFC4'));",
|
||||
"ENDSEC;",
|
||||
"DATA;",
|
||||
];
|
||||
|
||||
const footer = ["ENDSEC;", "END-ISO-10303-21;", ""];
|
||||
const ifcText = [...header, ...lines, ...footer].join("\n");
|
||||
const bytes = new TextEncoder().encode(ifcText);
|
||||
|
||||
return {
|
||||
ifcText,
|
||||
bytes,
|
||||
productCount: solidShapes.length,
|
||||
storeyCount: sortedStoreys.length,
|
||||
entityBreakdown,
|
||||
};
|
||||
}
|
||||
@@ -8,5 +8,5 @@
|
||||
*
|
||||
* `apps/web/public/sw.js` içindeki CACHE_NAME ile birlikte artırılmalıdır.
|
||||
*/
|
||||
export const SERVICE_WORKER_VERSION = "1.2.1";
|
||||
export const SERVICE_WORKER_VERSION = "1.2.2";
|
||||
export const SERVICE_WORKER_URL = `/sw.js?v=${SERVICE_WORKER_VERSION}`;
|
||||
@@ -12,7 +12,7 @@ import type { GridSize, ProjectAsset, ProjectAssetSourceFormat, SketchOperation,
|
||||
export const SKF_SCHEMA_ID = "com.sketchforge.project";
|
||||
export const SKF_FORMAT_VERSION = 2;
|
||||
export const SKF_MINIMUM_READER_VERSION = 2;
|
||||
export const SKF_CREATED_WITH_VERSION = process.env.NEXT_PUBLIC_APP_VERSION?.trim() || "1.0.10";
|
||||
export const SKF_CREATED_WITH_VERSION = process.env.NEXT_PUBLIC_APP_VERSION?.trim() || "1.0.11";
|
||||
export const SKF_MEDIA_TYPE = "application/vnd.sketchforge.project+zip";
|
||||
|
||||
export const SKF_LIMITS = {
|
||||
|
||||
@@ -1232,4 +1232,420 @@ export const SNAPCAD_PREFABS: SnapCadPrefabItem[] = [
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "arch-l-sofa-living-set",
|
||||
title: "Modern L-Koltuk & Orta Sehpa Salon Tefrişi",
|
||||
category: "architecture",
|
||||
categoryLabel: "Mimari Tefrişat",
|
||||
description: "Salon ve yaşam alanları için ölçekli L-köşe koltuk grubu, sırt minderleri ve mermer orta sehpa.",
|
||||
badge: "Salon Tefrişi",
|
||||
accentColor: "#8b5cf6",
|
||||
buildShapes: () => [
|
||||
makePrimitive("box", {
|
||||
name: "L-Koltuk Ana Oturum Modülü",
|
||||
color: "#475569",
|
||||
width: 30,
|
||||
depth: 10,
|
||||
height: 4.5,
|
||||
x: 0,
|
||||
z: -5,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "L-Koltuk Uzanma (Chaise) Modülü",
|
||||
color: "#475569",
|
||||
width: 10,
|
||||
depth: 20,
|
||||
height: 4.5,
|
||||
x: 10,
|
||||
z: 0,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Koltuk Sırt Dayama Gövdesi",
|
||||
color: "#334155",
|
||||
width: 30,
|
||||
depth: 2.5,
|
||||
height: 8.5,
|
||||
x: 0,
|
||||
z: -8.8,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Mermer Salon Orta Sehpası",
|
||||
color: "#e2e8f0",
|
||||
texture: "marble",
|
||||
width: 12,
|
||||
depth: 7,
|
||||
height: 3.8,
|
||||
x: -4,
|
||||
z: 5,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "arch-kitchen-island-set",
|
||||
title: "Ada Mutfak Tezgahı, Evye & Bar Tabureleri",
|
||||
category: "architecture",
|
||||
categoryLabel: "Mimari Tefrişat",
|
||||
description: "Mermer tablalı mutfak adası, evye oyuğu, ankastre bazası ve 3 adet yüksek bar taburesi.",
|
||||
badge: "Mutfak Tefrişi",
|
||||
accentColor: "#0ea5e9",
|
||||
buildShapes: () => [
|
||||
makePrimitive("box", {
|
||||
name: "Ada Mutfak Dolap Gövdesi",
|
||||
color: "#1e293b",
|
||||
width: 28,
|
||||
depth: 11,
|
||||
height: 8.5,
|
||||
x: 0,
|
||||
z: 0,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Mermer Ada Mutfak Tezgahı",
|
||||
color: "#f8fafc",
|
||||
texture: "marble",
|
||||
width: 30,
|
||||
depth: 13,
|
||||
height: 1.0,
|
||||
x: 0,
|
||||
z: 0.5,
|
||||
elevation: 8.5,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Çelik Mutfak Evyesi Boşluğu",
|
||||
color: "#64748b",
|
||||
hole: true,
|
||||
width: 7,
|
||||
depth: 5,
|
||||
height: 3.5,
|
||||
x: -6,
|
||||
z: -0.5,
|
||||
elevation: 7.0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("cylinder", {
|
||||
name: "Bar Taburesi 1",
|
||||
color: "#d97706",
|
||||
width: 4,
|
||||
depth: 4,
|
||||
height: 6.5,
|
||||
x: -8,
|
||||
z: 9,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("cylinder", {
|
||||
name: "Bar Taburesi 2",
|
||||
color: "#d97706",
|
||||
width: 4,
|
||||
depth: 4,
|
||||
height: 6.5,
|
||||
x: 0,
|
||||
z: 9,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("cylinder", {
|
||||
name: "Bar Taburesi 3",
|
||||
color: "#d97706",
|
||||
width: 4,
|
||||
depth: 4,
|
||||
height: 6.5,
|
||||
x: 8,
|
||||
z: 9,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "arch-master-bedroom-suite",
|
||||
title: "Çift Kişilik Yatak, Komodin & Sürgülü Gardırop",
|
||||
category: "architecture",
|
||||
categoryLabel: "Mimari Tefrişat",
|
||||
description: "Ebeveyn yatak odası için yatak karyolası, başlık, iki yan komodin ve boy gardırop modülü.",
|
||||
badge: "Yatak Odası",
|
||||
accentColor: "#ec4899",
|
||||
buildShapes: () => [
|
||||
makePrimitive("box", {
|
||||
name: "Çift Kişilik Yatak Bazası",
|
||||
color: "#78350f",
|
||||
texture: "wood",
|
||||
width: 18,
|
||||
depth: 21,
|
||||
height: 3.5,
|
||||
x: -6,
|
||||
z: 0,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Ortopedik Yatak Şiltesi",
|
||||
color: "#f8fafc",
|
||||
width: 16.5,
|
||||
depth: 19.5,
|
||||
height: 2.2,
|
||||
x: -6,
|
||||
z: 0.4,
|
||||
elevation: 3.5,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Kapitone Yatak Başlığı",
|
||||
color: "#334155",
|
||||
width: 18.5,
|
||||
depth: 1.6,
|
||||
height: 11.5,
|
||||
x: -6,
|
||||
z: -10,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Sol Komodin",
|
||||
color: "#78350f",
|
||||
texture: "wood",
|
||||
width: 5,
|
||||
depth: 4.5,
|
||||
height: 5,
|
||||
x: -18.5,
|
||||
z: -8.5,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Sağ Komodin",
|
||||
color: "#78350f",
|
||||
texture: "wood",
|
||||
width: 5,
|
||||
depth: 4.5,
|
||||
height: 5,
|
||||
x: 6.5,
|
||||
z: -8.5,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Sürgülü Boy Gardırop",
|
||||
color: "#e2e8f0",
|
||||
width: 24,
|
||||
depth: 6.5,
|
||||
height: 22,
|
||||
x: 18,
|
||||
z: -6,
|
||||
elevation: 0,
|
||||
tag: "Mobilyalar",
|
||||
}),
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "arch-bioclimatic-pergola",
|
||||
title: "Biyoklimatik Teras Pergola & Güneş Kırıcı Veranda",
|
||||
category: "architecture",
|
||||
categoryLabel: "Mimari & Peyzaj",
|
||||
description: "Alüminyum taşıyıcı kolonlar, çevre kirişleri ve döner güneş kırıcı lamel tavanlı modern pergola.",
|
||||
badge: "Pergola & Veranda",
|
||||
accentColor: "#f59e0b",
|
||||
buildShapes: () => {
|
||||
const shapes: WorkplaneShape[] = [
|
||||
makePrimitive("box", {
|
||||
name: "Pergola Kolon Sol-Ön",
|
||||
color: "#1e293b",
|
||||
width: 2.5,
|
||||
depth: 2.5,
|
||||
height: 26,
|
||||
x: -20,
|
||||
z: 14,
|
||||
elevation: 0,
|
||||
tag: "Kolon",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Pergola Kolon Sağ-Ön",
|
||||
color: "#1e293b",
|
||||
width: 2.5,
|
||||
depth: 2.5,
|
||||
height: 26,
|
||||
x: 20,
|
||||
z: 14,
|
||||
elevation: 0,
|
||||
tag: "Kolon",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Pergola Kolon Sol-Arka",
|
||||
color: "#1e293b",
|
||||
width: 2.5,
|
||||
depth: 2.5,
|
||||
height: 26,
|
||||
x: -20,
|
||||
z: -14,
|
||||
elevation: 0,
|
||||
tag: "Kolon",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Pergola Kolon Sağ-Arka",
|
||||
color: "#1e293b",
|
||||
width: 2.5,
|
||||
depth: 2.5,
|
||||
height: 26,
|
||||
x: 20,
|
||||
z: -14,
|
||||
elevation: 0,
|
||||
tag: "Kolon",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Pergola Ön Kiriş",
|
||||
color: "#334155",
|
||||
width: 42.5,
|
||||
depth: 2.5,
|
||||
height: 2.8,
|
||||
x: 0,
|
||||
z: 14,
|
||||
elevation: 25,
|
||||
tag: "Kiriş",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Pergola Arka Kiriş",
|
||||
color: "#334155",
|
||||
width: 42.5,
|
||||
depth: 2.5,
|
||||
height: 2.8,
|
||||
x: 0,
|
||||
z: -14,
|
||||
elevation: 25,
|
||||
tag: "Kiriş",
|
||||
}),
|
||||
];
|
||||
for (let i = -3; i <= 3; i++) {
|
||||
shapes.push(
|
||||
makePrimitive("box", {
|
||||
name: `Biyoklimatik Lamel ${i + 4}`,
|
||||
color: "#d97706",
|
||||
texture: "wood",
|
||||
width: 39,
|
||||
depth: 2.4,
|
||||
height: 0.9,
|
||||
x: 0,
|
||||
z: i * 3.8,
|
||||
elevation: 26.2,
|
||||
tag: "Çatı",
|
||||
}),
|
||||
);
|
||||
}
|
||||
return shapes;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "arch-landscape-trees-park",
|
||||
title: "Mimari Peyzaj Seti (Çam Ağacı, Yapraklı Ağaç & Aydınlatma)",
|
||||
category: "architecture",
|
||||
categoryLabel: "Mimari & Peyzaj",
|
||||
description: "Vaziyet planı ve dış mekan maketleri için ağaçlar, peyzaj aydınlatma direği ve bahçe oturma bankı.",
|
||||
badge: "Vaziyet & Peyzaj",
|
||||
accentColor: "#16a34a",
|
||||
buildShapes: () => [
|
||||
makePrimitive("cylinder", {
|
||||
name: "Yapraklı Ağaç Gövdesi",
|
||||
color: "#78350f",
|
||||
texture: "wood",
|
||||
width: 3.5,
|
||||
depth: 3.5,
|
||||
height: 14,
|
||||
x: -16,
|
||||
z: 0,
|
||||
elevation: 0,
|
||||
tag: "Peyzaj",
|
||||
}),
|
||||
makePrimitive("sphere", {
|
||||
name: "Yapraklı Ağaç Taç Kısmı",
|
||||
color: "#16a34a",
|
||||
texture: "grass",
|
||||
width: 18,
|
||||
depth: 18,
|
||||
height: 16,
|
||||
x: -16,
|
||||
z: 0,
|
||||
elevation: 11,
|
||||
tag: "Peyzaj",
|
||||
}),
|
||||
makePrimitive("cylinder", {
|
||||
name: "Çam Ağacı Gövdesi",
|
||||
color: "#78350f",
|
||||
texture: "wood",
|
||||
width: 3,
|
||||
depth: 3,
|
||||
height: 10,
|
||||
x: 16,
|
||||
z: -4,
|
||||
elevation: 0,
|
||||
tag: "Peyzaj",
|
||||
}),
|
||||
makePrimitive("cone", {
|
||||
name: "Çam Ağacı Alt İğne Yaprak",
|
||||
color: "#15803d",
|
||||
texture: "grass",
|
||||
width: 16,
|
||||
depth: 16,
|
||||
height: 18,
|
||||
x: 16,
|
||||
z: -4,
|
||||
elevation: 8,
|
||||
tag: "Peyzaj",
|
||||
}),
|
||||
makePrimitive("cone", {
|
||||
name: "Çam Ağacı Üst İğne Yaprak",
|
||||
color: "#22c55e",
|
||||
texture: "grass",
|
||||
width: 11,
|
||||
depth: 11,
|
||||
height: 14,
|
||||
x: 16,
|
||||
z: -4,
|
||||
elevation: 18,
|
||||
tag: "Peyzaj",
|
||||
}),
|
||||
makePrimitive("box", {
|
||||
name: "Ahşap Bahçe Bankı",
|
||||
color: "#b45309",
|
||||
texture: "wood",
|
||||
width: 14,
|
||||
depth: 4.5,
|
||||
height: 4.5,
|
||||
x: 0,
|
||||
z: 8,
|
||||
elevation: 0,
|
||||
tag: "Peyzaj",
|
||||
}),
|
||||
makePrimitive("cylinder", {
|
||||
name: "Peyzaj Sokak Lambası Direği",
|
||||
color: "#334155",
|
||||
width: 1.4,
|
||||
depth: 1.4,
|
||||
height: 24,
|
||||
x: 0,
|
||||
z: -8,
|
||||
elevation: 0,
|
||||
tag: "Peyzaj",
|
||||
}),
|
||||
makePrimitive("sphere", {
|
||||
name: "LED Armatür Küresi",
|
||||
color: "#fef08a",
|
||||
width: 4,
|
||||
depth: 4,
|
||||
height: 4,
|
||||
x: 0,
|
||||
z: -8,
|
||||
elevation: 23,
|
||||
tag: "Peyzaj",
|
||||
}),
|
||||
],
|
||||
},
|
||||
];
|
||||
+280
-11
@@ -1,21 +1,173 @@
|
||||
import * as suncalcModule from "suncalc";
|
||||
import { getPosition, getTimes } from "suncalc";
|
||||
|
||||
const SunCalc = (suncalcModule as any).getPosition ? suncalcModule : (suncalcModule as any).default;
|
||||
export type Ts825ThermalZone = 1 | 2 | 3 | 4 | 5;
|
||||
|
||||
export interface Ts825ZoneStandard {
|
||||
zone: Ts825ThermalZone;
|
||||
label: string;
|
||||
climateSummary: string;
|
||||
recommendedWallU: number; // W/(m²·K)
|
||||
recommendedRoofU: number; // W/(m²·K)
|
||||
recommendedFloorU: number; // W/(m²·K)
|
||||
recommendedWindowU: number; // W/(m²·K)
|
||||
minInsulationThicknessMm: number;
|
||||
}
|
||||
|
||||
export const TS825_ZONE_STANDARDS: Record<Ts825ThermalZone, Ts825ZoneStandard> = {
|
||||
1: {
|
||||
zone: 1,
|
||||
label: "1. Derece Gün Bölgesi (Akdeniz & Güney Kıyı)",
|
||||
climateSummary: "Kışları ılık, yazları sıcak; güneş kontrolü ve gölgeleme önceliklidir.",
|
||||
recommendedWallU: 0.66,
|
||||
recommendedRoofU: 0.43,
|
||||
recommendedFloorU: 0.66,
|
||||
recommendedWindowU: 1.8,
|
||||
minInsulationThicknessMm: 50,
|
||||
},
|
||||
2: {
|
||||
zone: 2,
|
||||
label: "2. Derece Gün Bölgesi (Marmara, Ege & Karadeniz Kıyı)",
|
||||
climateSummary: "Ilıman geçiş iklimi; ısı yalıtımı ve batı/güney güneş kırıcı dengesi önemlidir.",
|
||||
recommendedWallU: 0.57,
|
||||
recommendedRoofU: 0.38,
|
||||
recommendedFloorU: 0.57,
|
||||
recommendedWindowU: 1.8,
|
||||
minInsulationThicknessMm: 60,
|
||||
},
|
||||
3: {
|
||||
zone: 3,
|
||||
label: "3. Derece Gün Bölgesi (İç Anadolu & Geçiş Kuşağı)",
|
||||
climateSummary: "Karasal iklim; kış ısı kaybını azaltan güney yönelim ve orta-kalın manto gerekir.",
|
||||
recommendedWallU: 0.48,
|
||||
recommendedRoofU: 0.28,
|
||||
recommendedFloorU: 0.43,
|
||||
recommendedWindowU: 1.8,
|
||||
minInsulationThicknessMm: 80,
|
||||
},
|
||||
4: {
|
||||
zone: 4,
|
||||
label: "4. Derece Gün Bölgesi (Soğuk Karasal & Yüksek Rakım)",
|
||||
climateSummary: "Sert kış koşulları; yüksek performanslı dış cephe mantolama ve üçlü cam önerilir.",
|
||||
recommendedWallU: 0.38,
|
||||
recommendedRoofU: 0.23,
|
||||
recommendedFloorU: 0.38,
|
||||
recommendedWindowU: 1.6,
|
||||
minInsulationThicknessMm: 100,
|
||||
},
|
||||
5: {
|
||||
zone: 5,
|
||||
label: "5. Derece Gün Bölgesi (Doğu Anadolu Sert Kış Bölgesi)",
|
||||
climateSummary: "Çok soğuk kış iklimi; kompakt bina formu, ısı köprüsüz detay ve maksimum yalıtım şarttır.",
|
||||
recommendedWallU: 0.36,
|
||||
recommendedRoofU: 0.21,
|
||||
recommendedFloorU: 0.36,
|
||||
recommendedWindowU: 1.4,
|
||||
minInsulationThicknessMm: 120,
|
||||
},
|
||||
};
|
||||
|
||||
export interface SolarLocation {
|
||||
name: string;
|
||||
lat: number;
|
||||
lng: number;
|
||||
plateCode?: string;
|
||||
ts825Zone?: Ts825ThermalZone;
|
||||
utcOffsetHours?: number;
|
||||
}
|
||||
|
||||
export const TURKEY_81_PROVINCES_SOLAR_LOCATIONS: SolarLocation[] = [
|
||||
{ plateCode: "01", name: "01 Adana, Türkiye (37.0° K)", lat: 37.0, lng: 35.3213, ts825Zone: 1, utcOffsetHours: 3 },
|
||||
{ plateCode: "02", name: "02 Adıyaman, Türkiye (37.8° K)", lat: 37.7648, lng: 38.2786, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "03", name: "03 Afyonkarahisar, Türkiye (38.8° K)", lat: 38.7507, lng: 30.5567, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "04", name: "04 Ağrı, Türkiye (39.7° K)", lat: 39.7191, lng: 43.0503, ts825Zone: 5, utcOffsetHours: 3 },
|
||||
{ plateCode: "05", name: "05 Amasya, Türkiye (40.7° K)", lat: 40.6499, lng: 35.8353, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "06", name: "06 Ankara, Türkiye (39.9° K)", lat: 39.9334, lng: 32.8597, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "07", name: "07 Antalya, Türkiye (36.9° K)", lat: 36.8969, lng: 30.7133, ts825Zone: 1, utcOffsetHours: 3 },
|
||||
{ plateCode: "08", name: "08 Artvin, Türkiye (41.2° K)", lat: 41.1828, lng: 41.8183, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "09", name: "09 Aydın, Türkiye (37.8° K)", lat: 37.856, lng: 27.8416, ts825Zone: 1, utcOffsetHours: 3 },
|
||||
{ plateCode: "10", name: "10 Balıkesir, Türkiye (39.6° K)", lat: 39.6484, lng: 27.8826, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "11", name: "11 Bilecik, Türkiye (40.1° K)", lat: 40.1451, lng: 29.9799, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "12", name: "12 Bingöl, Türkiye (38.9° K)", lat: 38.8854, lng: 40.498, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "13", name: "13 Bitlis, Türkiye (38.4° K)", lat: 38.4006, lng: 42.1095, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "14", name: "14 Bolu, Türkiye (40.7° K)", lat: 40.7392, lng: 31.6089, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "15", name: "15 Burdur, Türkiye (37.7° K)", lat: 37.7203, lng: 30.2908, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "16", name: "16 Bursa, Türkiye (40.2° K)", lat: 40.1885, lng: 29.061, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "17", name: "17 Çanakkale, Türkiye (40.2° K)", lat: 40.1553, lng: 26.4142, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "18", name: "18 Çankırı, Türkiye (40.6° K)", lat: 40.6013, lng: 33.6134, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "19", name: "19 Çorum, Türkiye (40.5° K)", lat: 40.5506, lng: 34.9556, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "20", name: "20 Denizli, Türkiye (37.8° K)", lat: 37.7765, lng: 29.0864, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "21", name: "21 Diyarbakır, Türkiye (37.9° K)", lat: 37.9144, lng: 40.2306, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "22", name: "22 Edirne, Türkiye (41.7° K)", lat: 41.6818, lng: 26.5623, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "23", name: "23 Elazığ, Türkiye (38.7° K)", lat: 38.681, lng: 39.2264, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "24", name: "24 Erzincan, Türkiye (39.7° K)", lat: 39.75, lng: 39.5, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "25", name: "25 Erzurum, Türkiye (39.9° K)", lat: 39.9, lng: 41.27, ts825Zone: 5, utcOffsetHours: 3 },
|
||||
{ plateCode: "26", name: "26 Eskişehir, Türkiye (39.8° K)", lat: 39.7767, lng: 30.5206, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "27", name: "27 Gaziantep, Türkiye (37.1° K)", lat: 37.0662, lng: 37.3833, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "28", name: "28 Giresun, Türkiye (40.9° K)", lat: 40.9128, lng: 38.3895, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "29", name: "29 Gümüşhane, Türkiye (40.5° K)", lat: 40.4603, lng: 39.4814, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "30", name: "30 Hakkari, Türkiye (37.6° K)", lat: 37.5833, lng: 43.7333, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "31", name: "31 Hatay, Türkiye (36.2° K)", lat: 36.2021, lng: 36.1606, ts825Zone: 1, utcOffsetHours: 3 },
|
||||
{ plateCode: "32", name: "32 Isparta, Türkiye (37.8° K)", lat: 37.7648, lng: 30.5566, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "33", name: "33 Mersin, Türkiye (36.8° K)", lat: 36.8, lng: 34.6333, ts825Zone: 1, utcOffsetHours: 3 },
|
||||
{ plateCode: "34", name: "34 İstanbul, Türkiye (41.0° K)", lat: 41.0082, lng: 28.9784, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "35", name: "35 İzmir, Türkiye (38.4° K)", lat: 38.4237, lng: 27.1428, ts825Zone: 1, utcOffsetHours: 3 },
|
||||
{ plateCode: "36", name: "36 Kars, Türkiye (40.6° K)", lat: 40.6013, lng: 43.0975, ts825Zone: 5, utcOffsetHours: 3 },
|
||||
{ plateCode: "37", name: "37 Kastamonu, Türkiye (41.4° K)", lat: 41.3887, lng: 33.7827, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "38", name: "38 Kayseri, Türkiye (38.7° K)", lat: 38.7312, lng: 35.4787, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "39", name: "39 Kırklareli, Türkiye (41.7° K)", lat: 41.7333, lng: 27.2167, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "40", name: "40 Kırşehir, Türkiye (39.1° K)", lat: 39.1425, lng: 34.1709, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "41", name: "41 Kocaeli, Türkiye (40.8° K)", lat: 40.7654, lng: 29.9408, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "42", name: "42 Konya, Türkiye (37.9° K)", lat: 37.8667, lng: 32.4833, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "43", name: "43 Kütahya, Türkiye (39.4° K)", lat: 39.4167, lng: 29.9833, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "44", name: "44 Malatya, Türkiye (38.4° K)", lat: 38.3552, lng: 38.3095, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "45", name: "45 Manisa, Türkiye (38.6° K)", lat: 38.6191, lng: 27.4289, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "46", name: "46 Kahramanmaraş, Türkiye (37.6° K)", lat: 37.5858, lng: 36.9371, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "47", name: "47 Mardin, Türkiye (37.3° K)", lat: 37.3212, lng: 40.7245, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "48", name: "48 Muğla, Türkiye (37.2° K)", lat: 37.2153, lng: 28.3636, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "49", name: "49 Muş, Türkiye (38.7° K)", lat: 38.7432, lng: 41.5065, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "50", name: "50 Nevşehir, Türkiye (38.6° K)", lat: 38.6244, lng: 34.7239, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "51", name: "51 Niğde, Türkiye (38.0° K)", lat: 37.9667, lng: 34.6833, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "52", name: "52 Ordu, Türkiye (41.0° K)", lat: 40.9839, lng: 37.8764, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "53", name: "53 Rize, Türkiye (41.0° K)", lat: 41.0201, lng: 40.5234, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "54", name: "54 Sakarya, Türkiye (40.8° K)", lat: 40.7569, lng: 30.3783, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "55", name: "55 Samsun, Türkiye (41.3° K)", lat: 41.2867, lng: 36.33, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "56", name: "56 Siirt, Türkiye (37.9° K)", lat: 37.9333, lng: 41.95, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "57", name: "57 Sinop, Türkiye (42.0° K)", lat: 42.0231, lng: 35.1531, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "58", name: "58 Sivas, Türkiye (39.7° K)", lat: 39.7477, lng: 37.0179, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "59", name: "59 Tekirdağ, Türkiye (41.0° K)", lat: 40.9833, lng: 27.5167, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "60", name: "60 Tokat, Türkiye (40.3° K)", lat: 40.3167, lng: 36.55, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "61", name: "61 Trabzon, Türkiye (41.0° K)", lat: 41.0015, lng: 39.7178, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "62", name: "62 Tunceli, Türkiye (39.1° K)", lat: 39.1079, lng: 39.5401, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "63", name: "63 Şanlıurfa, Türkiye (37.2° K)", lat: 37.1591, lng: 38.7969, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "64", name: "64 Uşak, Türkiye (38.7° K)", lat: 38.6823, lng: 29.4082, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "65", name: "65 Van, Türkiye (38.5° K)", lat: 38.4891, lng: 43.4089, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "66", name: "66 Yozgat, Türkiye (39.8° K)", lat: 39.8181, lng: 34.8147, ts825Zone: 4, utcOffsetHours: 3 },
|
||||
{ plateCode: "67", name: "67 Zonguldak, Türkiye (41.5° K)", lat: 41.4564, lng: 31.7987, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "68", name: "68 Aksaray, Türkiye (38.4° K)", lat: 38.3687, lng: 34.037, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "69", name: "69 Bayburt, Türkiye (40.3° K)", lat: 40.2552, lng: 40.2249, ts825Zone: 5, utcOffsetHours: 3 },
|
||||
{ plateCode: "70", name: "70 Karaman, Türkiye (37.2° K)", lat: 37.1759, lng: 33.2287, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "71", name: "71 Kırıkkale, Türkiye (39.8° K)", lat: 39.8468, lng: 33.5153, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "72", name: "72 Batman, Türkiye (37.9° K)", lat: 37.8812, lng: 41.1351, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "73", name: "73 Şırnak, Türkiye (37.5° K)", lat: 37.5164, lng: 42.4611, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "74", name: "74 Bartın, Türkiye (41.6° K)", lat: 41.6344, lng: 32.3375, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "75", name: "75 Ardahan, Türkiye (41.1° K)", lat: 41.1105, lng: 42.7022, ts825Zone: 5, utcOffsetHours: 3 },
|
||||
{ plateCode: "76", name: "76 Iğdır, Türkiye (39.9° K)", lat: 39.9167, lng: 44.0333, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "77", name: "77 Yalova, Türkiye (40.7° K)", lat: 40.65, lng: 29.2667, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ plateCode: "78", name: "78 Karabük, Türkiye (41.2° K)", lat: 41.2061, lng: 32.6204, ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ plateCode: "79", name: "79 Kilis, Türkiye (36.7° K)", lat: 36.7184, lng: 37.1212, ts825Zone: 1, utcOffsetHours: 3 },
|
||||
{ plateCode: "80", name: "80 Osmaniye, Türkiye (37.1° K)", lat: 37.0742, lng: 36.2478, ts825Zone: 1, utcOffsetHours: 3 },
|
||||
{ plateCode: "81", name: "81 Düzce, Türkiye (40.8° K)", lat: 40.8438, lng: 31.1565, ts825Zone: 2, utcOffsetHours: 3 },
|
||||
];
|
||||
|
||||
export const SOLAR_LOCATIONS: SolarLocation[] = [
|
||||
{ name: "İstanbul, Türkiye (41.0° K)", lat: 41.0082, lng: 28.9784 },
|
||||
{ name: "Ankara, Türkiye (39.9° K)", lat: 39.9334, lng: 32.8597 },
|
||||
{ name: "İzmir, Türkiye (38.4° K)", lat: 38.4237, lng: 27.1428 },
|
||||
{ name: "Londra, İngiltere (51.5° K)", lat: 51.5074, lng: -0.1278 },
|
||||
{ name: "New York, ABD (40.7° K)", lat: 40.7128, lng: -74.006 },
|
||||
{ name: "Tokyo, Japonya (35.7° K)", lat: 35.6762, lng: 139.6503 },
|
||||
{ name: "Dubai, BAE (25.2° K)", lat: 25.2048, lng: 55.2708 },
|
||||
{ name: "İstanbul, Türkiye (41.0° K)", lat: 41.0082, lng: 28.9784, plateCode: "34", ts825Zone: 2, utcOffsetHours: 3 },
|
||||
{ name: "Ankara, Türkiye (39.9° K)", lat: 39.9334, lng: 32.8597, plateCode: "06", ts825Zone: 3, utcOffsetHours: 3 },
|
||||
{ name: "İzmir, Türkiye (38.4° K)", lat: 38.4237, lng: 27.1428, plateCode: "35", ts825Zone: 1, utcOffsetHours: 3 },
|
||||
{ name: "Londra, İngiltere (51.5° K)", lat: 51.5074, lng: -0.1278, utcOffsetHours: 0 },
|
||||
{ name: "New York, ABD (40.7° K)", lat: 40.7128, lng: -74.006, utcOffsetHours: -5 },
|
||||
{ name: "Tokyo, Japonya (35.7° K)", lat: 35.6762, lng: 139.6503, utcOffsetHours: 9 },
|
||||
{ name: "Dubai, BAE (25.2° K)", lat: 25.2048, lng: 55.2708, utcOffsetHours: 4 },
|
||||
...TURKEY_81_PROVINCES_SOLAR_LOCATIONS,
|
||||
];
|
||||
|
||||
export interface SolarStudySettings {
|
||||
@@ -48,6 +200,38 @@ export interface CalculatedSunPosition {
|
||||
intensity: number;
|
||||
}
|
||||
|
||||
export interface DailySolarSweepPoint {
|
||||
hour: number;
|
||||
timeLabel: string;
|
||||
altitudeDegrees: number;
|
||||
azimuthDegrees: number;
|
||||
isDaylight: boolean;
|
||||
lightVector: [number, number, number];
|
||||
}
|
||||
|
||||
export interface FacadeInsolationSummary {
|
||||
northHours: number;
|
||||
eastHours: number;
|
||||
southHours: number;
|
||||
westHours: number;
|
||||
peakAltitudeDegrees: number;
|
||||
sunriseTime: string;
|
||||
solarNoonTime: string;
|
||||
sunsetTime: string;
|
||||
daylightDurationHours: number;
|
||||
shadingRecommendation: string;
|
||||
ts825Standard: Ts825ZoneStandard;
|
||||
hourlyPoints: DailySolarSweepPoint[];
|
||||
}
|
||||
|
||||
function formatUtcDateAtOffset(date: Date | null | undefined, utcOffsetHours: number): string {
|
||||
if (!date || Number.isNaN(date.getTime())) return "--:--";
|
||||
const shifted = new Date(date.getTime() + utcOffsetHours * 3600_000);
|
||||
const hh = String(shifted.getUTCHours()).padStart(2, "0");
|
||||
const mm = String(shifted.getUTCMinutes()).padStart(2, "0");
|
||||
return `${hh}:${mm}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates real-world solar angles, color temperature, and 3D light vector.
|
||||
*/
|
||||
@@ -57,10 +241,10 @@ export function calculateSunPosition(settings: SolarStudySettings): CalculatedSu
|
||||
const hourInt = Math.floor(settings.hour);
|
||||
const minute = Math.round((settings.hour - hourInt) * 60);
|
||||
|
||||
// UTC approx: Turkey is UTC+3
|
||||
// UTC approx: default Turkey UTC+3
|
||||
const date = new Date(Date.UTC(year, settings.month, settings.day, hourInt - 3, minute));
|
||||
|
||||
const sunPos = SunCalc.getPosition(date, loc.lat, loc.lng);
|
||||
const sunPos = getPosition(date, loc.lat, loc.lng);
|
||||
const altitudeDegrees = Number(sunPos.altitude.toFixed(1));
|
||||
const azimuthDegrees = Number((((sunPos.azimuth % 360) + 360) % 360).toFixed(1));
|
||||
|
||||
@@ -110,3 +294,88 @@ export function calculateSunPosition(settings: SolarStudySettings): CalculatedSu
|
||||
intensity,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Full-day solar trajectory sweep & facade direct sunlight (N/E/S/W) + TS 825 thermal evaluation.
|
||||
*/
|
||||
export function calculateDailySolarSweep(
|
||||
settings: SolarStudySettings,
|
||||
stepMinutes = 30,
|
||||
): FacadeInsolationSummary {
|
||||
const loc = SOLAR_LOCATIONS[settings.locationIndex] ?? SOLAR_LOCATIONS[0];
|
||||
const utcOffsetHours = loc.utcOffsetHours ?? 3;
|
||||
const ts825Zone: Ts825ThermalZone = loc.ts825Zone ?? 2;
|
||||
const ts825Standard = TS825_ZONE_STANDARDS[ts825Zone];
|
||||
|
||||
const refDate = new Date(Date.UTC(2026, settings.month, settings.day, 12 - utcOffsetHours, 0));
|
||||
const times = getTimes(refDate, loc.lat, loc.lng);
|
||||
|
||||
const stepHours = Math.max(0.25, stepMinutes / 60);
|
||||
let northHours = 0;
|
||||
let eastHours = 0;
|
||||
let southHours = 0;
|
||||
let westHours = 0;
|
||||
let daylightDurationHours = 0;
|
||||
let peakAltitudeDegrees = -90;
|
||||
|
||||
const hourlyPoints: DailySolarSweepPoint[] = [];
|
||||
|
||||
for (let hour = 5.0; hour <= 21.0 + 1e-6; hour += stepHours) {
|
||||
const pos = calculateSunPosition({ ...settings, hour });
|
||||
const hInt = Math.floor(hour);
|
||||
const mInt = Math.round((hour - hInt) * 60);
|
||||
const timeLabel = `${String(hInt).padStart(2, "0")}:${String(mInt).padStart(2, "0")}`;
|
||||
|
||||
if (pos.altitudeDegrees > peakAltitudeDegrees) {
|
||||
peakAltitudeDegrees = pos.altitudeDegrees;
|
||||
}
|
||||
|
||||
if (Math.abs(hour - Math.round(hour)) < 0.01) {
|
||||
hourlyPoints.push({
|
||||
hour: Number(hour.toFixed(2)),
|
||||
timeLabel,
|
||||
altitudeDegrees: pos.altitudeDegrees,
|
||||
azimuthDegrees: pos.azimuthDegrees,
|
||||
isDaylight: pos.isDaylight,
|
||||
lightVector: pos.lightVector,
|
||||
});
|
||||
}
|
||||
|
||||
if (pos.altitudeDegrees > 2) {
|
||||
daylightDurationHours += stepHours;
|
||||
// Azimuth in SunCalc v2: 0=North, 90=East, 180=South, 270=West
|
||||
const azRad = (pos.azimuthDegrees * Math.PI) / 180;
|
||||
const dirNorth = Math.cos(azRad);
|
||||
const dirEast = Math.sin(azRad);
|
||||
const dirSouth = -Math.cos(azRad);
|
||||
const dirWest = -Math.sin(azRad);
|
||||
|
||||
if (dirNorth > 0.15) northHours += stepHours;
|
||||
if (dirEast > 0.15) eastHours += stepHours;
|
||||
if (dirSouth > 0.15) southHours += stepHours;
|
||||
if (dirWest > 0.15) westHours += stepHours;
|
||||
}
|
||||
}
|
||||
|
||||
const shadingRecommendation =
|
||||
peakAltitudeDegrees >= 60
|
||||
? "Güney cephede yatay güneş kırıcı (brise-soleil / saçak), Batı ve Doğu cephelerde dikey hareketli panjur önerilir."
|
||||
: peakAltitudeDegrees >= 40
|
||||
? "Mevsim geçişi açısı: Güney pencerelerde kış güneş kazancını koruyan orta derinlikli saçak (60-80 cm) idealdir."
|
||||
: "Düşük kış güneşi açısı: Güney cephede maksimum pasif güneş kazancı sağlanmalı, Kuzey cephe açıklıkları minimize edilmelidir.";
|
||||
|
||||
return {
|
||||
northHours: Number(northHours.toFixed(1)),
|
||||
eastHours: Number(eastHours.toFixed(1)),
|
||||
southHours: Number(southHours.toFixed(1)),
|
||||
westHours: Number(westHours.toFixed(1)),
|
||||
peakAltitudeDegrees: Number(peakAltitudeDegrees.toFixed(1)),
|
||||
sunriseTime: formatUtcDateAtOffset(times.sunrise, utcOffsetHours),
|
||||
solarNoonTime: formatUtcDateAtOffset(times.solarNoon, utcOffsetHours),
|
||||
sunsetTime: formatUtcDateAtOffset(times.sunset, utcOffsetHours),
|
||||
daylightDurationHours: Number(daylightDurationHours.toFixed(1)),
|
||||
shadingRecommendation,
|
||||
ts825Standard,
|
||||
hourlyPoints,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
export interface YakNetWidgetUser {
|
||||
id: number;
|
||||
name: string;
|
||||
email: string;
|
||||
avatar?: string | null;
|
||||
auth_source?: string;
|
||||
}
|
||||
|
||||
export const YAKNET_OAUTH_CLIENT_ID = "01a1315f-9db9-70ee-9983-0d3397773ecd";
|
||||
export const YAKNET_CALLBACK_URI = "https://snap.yakhub.com.tr/callback.php";
|
||||
export const YAKNET_AUTH_BASE = "https://developer-console.yakhub.com.tr";
|
||||
export const YAKNET_CDN_ORIGIN = "https://cdnjs.yakhub.com.tr";
|
||||
export const YAKNET_ACCOUNT_CDN_URL = `${YAKNET_CDN_ORIGIN}/ajax/libs/yaknet-account/latest/yaknet-account.js`;
|
||||
export const YAKNET_ACCOUNT_SCRIPT_ID = "yaknet-account-cdn-script";
|
||||
export const YAKNET_SSO_IFRAME_ID = "yaknet-sso-iframe-instance";
|
||||
export const YAKNET_WEB_SESSION_HINT_KEY = "snapcad.yaknet.sessionHint.v1";
|
||||
|
||||
export function sanitizeYakNetWidgetUser(raw: unknown): YakNetWidgetUser | null {
|
||||
if (!raw || typeof raw !== "object") return null;
|
||||
const candidate = raw as Record<string, unknown>;
|
||||
const id = Number(candidate.id ?? 0);
|
||||
const name = typeof candidate.name === "string" ? candidate.name.trim() : "";
|
||||
const email = typeof candidate.email === "string" ? candidate.email.trim() : "";
|
||||
if (!Number.isFinite(id) || id <= 0 || !name) return null;
|
||||
return {
|
||||
id: Math.round(id),
|
||||
name: name.slice(0, 255),
|
||||
email: email.slice(0, 255),
|
||||
avatar: typeof candidate.avatar === "string" ? candidate.avatar.slice(0, 512) : null,
|
||||
auth_source: typeof candidate.auth_source === "string" ? candidate.auth_source.slice(0, 64) : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function computeUserInitials(rawName?: string | null): string {
|
||||
const parts = String(rawName ?? "")
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.filter(Boolean);
|
||||
if (parts.length === 0) return "YN";
|
||||
const first = parts[0].slice(0, 1).toUpperCase();
|
||||
const second = parts.length > 1 ? parts[parts.length - 1].slice(0, 1).toUpperCase() : "";
|
||||
return `${first}${second}` || "YN";
|
||||
}
|
||||
|
||||
export function resolveYakNetWidgetAttributes({
|
||||
user,
|
||||
sessionResolved,
|
||||
theme = "light",
|
||||
}: {
|
||||
user: YakNetWidgetUser | null;
|
||||
sessionResolved: boolean;
|
||||
theme?: "light" | "dark" | "auto";
|
||||
}): Record<string, string | null> {
|
||||
return {
|
||||
"base-url": YAKNET_AUTH_BASE,
|
||||
"client-id": YAKNET_OAUTH_CLIENT_ID,
|
||||
"redirect-uri": YAKNET_CALLBACK_URI,
|
||||
"login-url": "/login.php",
|
||||
"logout-url": "/logout.php",
|
||||
theme,
|
||||
authenticated: user ? "true" : sessionResolved ? "false" : null,
|
||||
"user-name": user ? user.name : null,
|
||||
"user-email": user ? user.email || "" : null,
|
||||
};
|
||||
}
|
||||
|
||||
export function shouldSuppressUnauthenticatedSsoMessage({
|
||||
isDesktop,
|
||||
sessionResolved,
|
||||
hasAuthenticatedUser,
|
||||
ssoFrameHadAuthenticated,
|
||||
}: {
|
||||
isDesktop: boolean;
|
||||
sessionResolved: boolean;
|
||||
hasAuthenticatedUser: boolean;
|
||||
ssoFrameHadAuthenticated: boolean;
|
||||
}): boolean {
|
||||
if (isDesktop) return true;
|
||||
if (!sessionResolved) return true;
|
||||
if (hasAuthenticatedUser && !ssoFrameHadAuthenticated) return true;
|
||||
return false;
|
||||
}
|
||||
Vendored
+45
@@ -47,6 +47,36 @@ export type DesktopYakNetAuthEvent = {
|
||||
error?: string;
|
||||
};
|
||||
|
||||
export type DesktopAuthStateSnapshot = {
|
||||
authenticated: boolean;
|
||||
user: DesktopYakNetUser | null;
|
||||
};
|
||||
|
||||
export type DesktopActiveWorkKind =
|
||||
| "none"
|
||||
| "3d-project"
|
||||
| "drawing-studio"
|
||||
| "circuits-studio"
|
||||
| "codeblocks-studio";
|
||||
|
||||
export type DesktopActiveWorkState = {
|
||||
hasOpenWork: boolean;
|
||||
workKind: DesktopActiveWorkKind;
|
||||
projectName: string | null;
|
||||
shapeCount: number;
|
||||
hasDiskFile: boolean;
|
||||
diskFileName: string | null;
|
||||
hasUnsavedDiskChanges: boolean;
|
||||
pendingLocalSaveCount: number;
|
||||
};
|
||||
|
||||
export type DesktopPreUpdatePrepareResult = DesktopActiveWorkState & {
|
||||
localSaved: boolean;
|
||||
cloudAttempted: boolean;
|
||||
cloudSynced: boolean;
|
||||
cloudStatusText: string;
|
||||
};
|
||||
|
||||
export type DesktopCloudRequestOptions = {
|
||||
path: string;
|
||||
method?: string;
|
||||
@@ -68,12 +98,14 @@ export type DesktopMenuAction =
|
||||
| "file:save"
|
||||
| "file:save-as"
|
||||
| "file:save-and-quit"
|
||||
| "file:save-and-update"
|
||||
| "file:import"
|
||||
| "file:export-panel"
|
||||
| "file:export-skf"
|
||||
| "file:export-stl"
|
||||
| "file:export-3mf"
|
||||
| "file:export-step"
|
||||
| "file:export-ifc"
|
||||
| "file:export-obj"
|
||||
| "file:export-glb"
|
||||
| "file:export-dxf"
|
||||
@@ -174,6 +206,10 @@ export type DesktopMenuAction =
|
||||
| "tool:walk"
|
||||
| "tool:wall-opening"
|
||||
| "tool:terrain"
|
||||
| "tool:bim-studio"
|
||||
| "tool:bim-storeys"
|
||||
| "tool:bim-boq"
|
||||
| "tool:bim-code-audit"
|
||||
| "tool:structural-test"
|
||||
| "tool:ar-preview"
|
||||
| "tool:physics-toggle"
|
||||
@@ -251,10 +287,13 @@ export type SnapCadDesktopBridge = {
|
||||
installUpdate: () => Promise<DesktopUpdateResult>;
|
||||
getUpdateState?: () => Promise<DesktopUpdateResult>;
|
||||
onUpdateState?: (listener: (state: DesktopUpdateResult) => void) => () => void;
|
||||
onOpenUpdateProgress?: (listener: (state: DesktopUpdateResult) => void) => () => void;
|
||||
getDesktopPrefs?: () => Promise<DesktopPreferences>;
|
||||
setDesktopPrefs?: (patch: Partial<DesktopPreferences>) => Promise<DesktopPreferences>;
|
||||
hideToTray?: () => Promise<boolean>;
|
||||
onDesktopPrefsChanged?: (listener: (prefs: DesktopPreferences) => void) => () => void;
|
||||
getAuthStateSync?: () => DesktopAuthStateSnapshot;
|
||||
getAuthState?: () => Promise<DesktopAuthStateSnapshot>;
|
||||
startYakNetLogin?: () => Promise<{ started: boolean; error?: string }>;
|
||||
logoutYakNet?: () => Promise<{ ok: boolean; error?: string }>;
|
||||
cloudRequest?: (options: DesktopCloudRequestOptions) => Promise<DesktopCloudResponse>;
|
||||
@@ -277,7 +316,12 @@ export type SnapCadDesktopBridge = {
|
||||
setMenuState?: (state: Partial<DesktopMenuUiState>) => Promise<void>;
|
||||
setDirty?: (dirty: boolean) => Promise<void>;
|
||||
setWindowTitle?: (title: string) => Promise<void>;
|
||||
setActiveWorkState?: (state: DesktopActiveWorkState) => Promise<void>;
|
||||
onPrepareBeforeUpdate?: (listener: (requestId: string) => void) => () => void;
|
||||
sendPrepareBeforeUpdateResult?: (requestId: string, result: DesktopPreUpdatePrepareResult) => Promise<void>;
|
||||
confirmCloseAfterSave?: () => Promise<void>;
|
||||
confirmUpdateAfterSave?: () => Promise<boolean>;
|
||||
cancelPendingUpdateInstall?: () => Promise<void>;
|
||||
openExternal?: (url: string) => Promise<boolean>;
|
||||
};
|
||||
|
||||
@@ -285,5 +329,6 @@ declare global {
|
||||
interface Window {
|
||||
snapcadDesktop?: SnapCadDesktopBridge;
|
||||
sketchforgeDesktop?: SnapCadDesktopBridge;
|
||||
__snapcadInitialSessionPromise?: Promise<unknown>;
|
||||
}
|
||||
}
|
||||
Generated
+36
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "sketchforge",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.11",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sketchforge",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.11",
|
||||
"license": "AGPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@mlightcad/libredwg-web": "^0.8.2",
|
||||
@@ -48,13 +48,16 @@
|
||||
"devDependencies": {
|
||||
"@types/bezier-js": "^4.1.3",
|
||||
"@types/canvas-confetti": "^1.9.0",
|
||||
"@types/delaunator": "^5.0.3",
|
||||
"@types/node": "^22.15.18",
|
||||
"@types/react": "^19.1.4",
|
||||
"@types/react-dom": "^19.1.5",
|
||||
"delaunator": "^5.1.0",
|
||||
"electron": "^43.4.0",
|
||||
"electron-builder": "^26.15.3",
|
||||
"js-yaml": "^4.3.1",
|
||||
"playwright": "^1.64.1",
|
||||
"simplex-noise": "^4.0.3",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^4.1.8"
|
||||
}
|
||||
@@ -2105,6 +2108,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/delaunator": {
|
||||
"version": "5.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/delaunator/-/delaunator-5.0.3.tgz",
|
||||
"integrity": "sha512-6tTLP8NX0OwtB/fmW9bXp4EWPptawTSsrSGjboWRuzqkxNEEJGyzRPHbr8wnV2DBWfAZ+EPTOvW3B/KysJrl2g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz",
|
||||
@@ -3382,6 +3392,16 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/delaunator": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.1.0.tgz",
|
||||
"integrity": "sha512-AGrQ4QSgssa1NGmWmLPqN5NY2KajF5MqxetNEO+o0n3ZwZZeTmt7bBnvzHWrmkZFxGgr4HdyFgelzgi06otLuQ==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"robust-predicates": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
@@ -6357,6 +6377,13 @@
|
||||
"node": ">=8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/robust-predicates": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.3.tgz",
|
||||
"integrity": "sha512-NS3levdsRIUOmiJ8FZWCP7LG3QpJyrs/TE0Zpf1yvZu8cAJJ6QMW92H1c7kWpdIHo8RvmLxN/o2JXTKHp74lUA==",
|
||||
"dev": true,
|
||||
"license": "Unlicense"
|
||||
},
|
||||
"node_modules/rolldown": {
|
||||
"version": "1.2.18",
|
||||
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.18.tgz",
|
||||
@@ -6575,6 +6602,13 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/simplex-noise": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/simplex-noise/-/simplex-noise-4.0.3.tgz",
|
||||
"integrity": "sha512-qSE2I4AngLQG7BXqoZj51jokT4WUXe8mOBrvfOXpci8+6Yu44+/dD5zqDpOx3Ux792eamTd2lLcI8jqFntk/lg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
|
||||
+4
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sketchforge",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.11",
|
||||
"private": true,
|
||||
"description": "SnapCAD Studio — YakHub local-first 3D CAD, architecture and circuits platform.",
|
||||
"author": {
|
||||
@@ -86,13 +86,16 @@
|
||||
"devDependencies": {
|
||||
"@types/bezier-js": "^4.1.3",
|
||||
"@types/canvas-confetti": "^1.9.0",
|
||||
"@types/delaunator": "^5.0.3",
|
||||
"@types/node": "^22.15.18",
|
||||
"@types/react": "^19.1.4",
|
||||
"@types/react-dom": "^19.1.5",
|
||||
"delaunator": "^5.1.0",
|
||||
"electron": "^43.4.0",
|
||||
"electron-builder": "^26.15.3",
|
||||
"js-yaml": "^4.3.1",
|
||||
"playwright": "^1.64.1",
|
||||
"simplex-noise": "^4.0.3",
|
||||
"typescript": "^5.8.3",
|
||||
"vitest": "^4.1.8"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { exportShapesToIfc4, classifyShapeForIfc } from "@/lib/ifcExport";
|
||||
import { importedShapeWithDetailsFromIfc } from "@/lib/ifcImport";
|
||||
import {
|
||||
DEFAULT_BUILDING_STOREYS,
|
||||
calculateArchitecturalBoq,
|
||||
exportBoqToCsv,
|
||||
exportBoqToPdfBytes,
|
||||
auditArchitecturalCodeCompliance,
|
||||
isolateStoreyVisibility,
|
||||
duplicateStoreyToLevel,
|
||||
generateParametricStair,
|
||||
generateParametricRoof,
|
||||
generateParametricOpeningUnit,
|
||||
generateStructuralFrameGrid,
|
||||
generateAdvancedTerrainWithPad,
|
||||
} from "@/lib/architecturalBimEngine";
|
||||
import {
|
||||
TURKEY_81_PROVINCES_SOLAR_LOCATIONS,
|
||||
SOLAR_LOCATIONS,
|
||||
DEFAULT_SOLAR_SETTINGS,
|
||||
calculateDailySolarSweep,
|
||||
} from "@/lib/solarSystem";
|
||||
import { SNAPCAD_PREFABS } from "@/lib/snapcadPrefabs";
|
||||
|
||||
describe("Architectural BIM Engine, IFC4 Export, BOQ Metraj & Code Auditor", () => {
|
||||
it("exports 3D architectural shapes to IFC4 and round-trips through web-ifc WASM", async () => {
|
||||
const villaPrefab = SNAPCAD_PREFABS.find((p) => p.id === "modern-terrace-villa");
|
||||
expect(villaPrefab).toBeDefined();
|
||||
const shapes = villaPrefab!.buildShapes();
|
||||
|
||||
const exported = exportShapesToIfc4(shapes, {
|
||||
projectName: "Modern Terasli Villa",
|
||||
scaleFactorToMm: 100, // 1:100 architectural scale -> real millimeters
|
||||
});
|
||||
|
||||
expect(exported.ifcText).toContain("FILE_SCHEMA(('IFC4'));");
|
||||
expect(exported.ifcText).toContain("IFCPROJECT(");
|
||||
expect(exported.ifcText).toContain("IFCBUILDINGSTOREY(");
|
||||
expect(exported.ifcText).toContain("IFCELEMENTQUANTITY(");
|
||||
expect(exported.productCount).toBeGreaterThanOrEqual(5);
|
||||
expect(exported.storeyCount).toBeGreaterThanOrEqual(1);
|
||||
|
||||
// Round-trip parse with web-ifc WASM
|
||||
const reimported = await importedShapeWithDetailsFromIfc("villa_bim.ifc", exported.bytes);
|
||||
expect(reimported.schema).toBe("IFC4");
|
||||
expect(reimported.productCount).toBeGreaterThanOrEqual(5);
|
||||
expect(reimported.triangleCount).toBeGreaterThanOrEqual(24);
|
||||
});
|
||||
|
||||
it("classifies BIM entities and calculates BOQ (Metraj & Keşif) with CSV and PDF export", () => {
|
||||
const frameShapes = generateStructuralFrameGrid({
|
||||
baysX: 2,
|
||||
baysZ: 2,
|
||||
spanX: 40,
|
||||
spanZ: 40,
|
||||
storeyHeight: 32,
|
||||
includeFoundationSlab: true,
|
||||
includeCeilingSlab: true,
|
||||
});
|
||||
const roofShapes = generateParametricRoof({
|
||||
kind: "gable",
|
||||
width: 84,
|
||||
depth: 84,
|
||||
ridgeHeight: 18,
|
||||
baseElevation: 64,
|
||||
});
|
||||
const openingShapes = [
|
||||
...generateParametricOpeningUnit({ kind: "double-window", width: 18, height: 15 }),
|
||||
...generateParametricOpeningUnit({ kind: "steel-entrance-door", width: 12, height: 21 }),
|
||||
];
|
||||
|
||||
const allShapes = [...frameShapes, ...roofShapes, ...openingShapes];
|
||||
expect(classifyShapeForIfc(roofShapes[0])).toBe("IFCROOF");
|
||||
|
||||
const boq = calculateArchitecturalBoq(allShapes, {
|
||||
projectName: "Test Mimari Bina",
|
||||
scaleMode: "1:100",
|
||||
});
|
||||
|
||||
expect(boq.grossFloorAreaM2).toBeGreaterThan(50);
|
||||
expect(boq.totalStructuralConcreteM3).toBeGreaterThan(5);
|
||||
expect(boq.totalRoofAreaM2).toBeGreaterThan(50);
|
||||
expect(boq.windowCount).toBeGreaterThanOrEqual(1);
|
||||
expect(boq.doorCount).toBeGreaterThanOrEqual(1);
|
||||
expect(boq.totalEstimatedCostTry).toBeGreaterThan(50_000);
|
||||
expect(boq.items.length).toBeGreaterThanOrEqual(4);
|
||||
|
||||
const csv = exportBoqToCsv(boq);
|
||||
expect(csv.startsWith("\uFEFF")).toBe(true);
|
||||
expect(csv).toContain("15.150.1005");
|
||||
expect(csv).toContain("Test Mimari Bina");
|
||||
|
||||
const pdfBytes = exportBoqToPdfBytes(boq);
|
||||
expect(pdfBytes.byteLength).toBeGreaterThan(500);
|
||||
const pdfHeader = new TextDecoder().decode(pdfBytes.slice(0, 5));
|
||||
expect(pdfHeader).toBe("%PDF-");
|
||||
});
|
||||
|
||||
it("manages multi-storey isolation and duplicates a storey to an upper floor level", () => {
|
||||
const groundStorey = DEFAULT_BUILDING_STOREYS[1]; // Zemin Kat (elevation 0)
|
||||
const firstStorey = DEFAULT_BUILDING_STOREYS[2]; // 1. Normal Kat (elevation 32)
|
||||
|
||||
const gridShapes = generateStructuralFrameGrid({
|
||||
baysX: 1,
|
||||
baysZ: 1,
|
||||
spanX: 40,
|
||||
spanZ: 40,
|
||||
baseElevation: groundStorey.elevation,
|
||||
storeyTag: groundStorey.tag,
|
||||
});
|
||||
|
||||
const duplicated = duplicateStoreyToLevel(
|
||||
gridShapes,
|
||||
groundStorey,
|
||||
firstStorey,
|
||||
DEFAULT_BUILDING_STOREYS,
|
||||
);
|
||||
|
||||
expect(duplicated.clonedShapes.length).toBe(gridShapes.length);
|
||||
expect(duplicated.nextShapes.length).toBe(gridShapes.length * 2);
|
||||
expect(duplicated.clonedShapes[0].elevation).toBeCloseTo(
|
||||
(gridShapes[0].elevation || 0) + (firstStorey.elevation - groundStorey.elevation),
|
||||
2,
|
||||
);
|
||||
|
||||
const isolated = isolateStoreyVisibility(
|
||||
duplicated.nextShapes,
|
||||
firstStorey,
|
||||
DEFAULT_BUILDING_STOREYS,
|
||||
);
|
||||
const visibleCount = isolated.filter((s) => !s.hidden).length;
|
||||
expect(visibleCount).toBe(duplicated.clonedShapes.length);
|
||||
});
|
||||
|
||||
it("generates parametric stairs (straight, L, U, spiral) and audits Turkish building code compliance", () => {
|
||||
const straightStairs = generateParametricStair({ kind: "straight", stepCount: 18, totalHeight: 31 });
|
||||
const lStairs = generateParametricStair({ kind: "l-shaped", stepCount: 18, totalHeight: 31 });
|
||||
const uStairs = generateParametricStair({ kind: "u-shaped", stepCount: 18, totalHeight: 31 });
|
||||
const spiralStairs = generateParametricStair({ kind: "spiral", stepCount: 16, totalHeight: 32 });
|
||||
|
||||
expect(straightStairs.length).toBeGreaterThanOrEqual(18);
|
||||
expect(lStairs.length).toBeGreaterThanOrEqual(18);
|
||||
expect(uStairs.length).toBeGreaterThanOrEqual(18);
|
||||
expect(spiralStairs.length).toBeGreaterThanOrEqual(16);
|
||||
|
||||
const audit = auditArchitecturalCodeCompliance(uStairs, "1:100");
|
||||
expect(audit.score).toBeGreaterThanOrEqual(50);
|
||||
expect(audit.checks.some((c) => c.id === "stair-blondel")).toBe(true);
|
||||
});
|
||||
|
||||
it("triangulates 3D site topography using simplex-noise + delaunator and computes cut/fill earthwork", () => {
|
||||
const terrain = generateAdvancedTerrainWithPad({
|
||||
preset: "hills",
|
||||
width: 220,
|
||||
depth: 220,
|
||||
maxHeight: 22,
|
||||
gridResolution: 14,
|
||||
includeBuildingPad: true,
|
||||
});
|
||||
|
||||
expect(terrain.triangleCount).toBeGreaterThanOrEqual(300);
|
||||
expect(terrain.terrainShape.importedMesh?.positions.length).toBe(terrain.triangleCount * 9);
|
||||
expect(terrain.padShape).not.toBeNull();
|
||||
expect(terrain.excavationCutVolumeM3 + terrain.embankmentFillVolumeM3).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("includes all 81 Turkish provinces with TS 825 zones and computes daily facade solar sweep", () => {
|
||||
expect(TURKEY_81_PROVINCES_SOLAR_LOCATIONS).toHaveLength(81);
|
||||
expect(TURKEY_81_PROVINCES_SOLAR_LOCATIONS[0].plateCode).toBe("01");
|
||||
expect(TURKEY_81_PROVINCES_SOLAR_LOCATIONS[80].plateCode).toBe("81");
|
||||
expect(SOLAR_LOCATIONS.length).toBeGreaterThanOrEqual(88);
|
||||
|
||||
const sweep = calculateDailySolarSweep({
|
||||
...DEFAULT_SOLAR_SETTINGS,
|
||||
locationIndex: 0, // İstanbul
|
||||
month: 5, // Haziran
|
||||
day: 21,
|
||||
});
|
||||
|
||||
expect(sweep.daylightDurationHours).toBeGreaterThan(12);
|
||||
expect(sweep.southHours).toBeGreaterThan(4);
|
||||
expect(sweep.eastHours).toBeGreaterThan(2);
|
||||
expect(sweep.westHours).toBeGreaterThan(2);
|
||||
expect(sweep.ts825Standard.zone).toBe(2);
|
||||
expect(sweep.hourlyPoints.length).toBeGreaterThanOrEqual(15);
|
||||
});
|
||||
});
|
||||
@@ -4,6 +4,8 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
exportFiltersForFilename,
|
||||
formatFriendlyUpdateError,
|
||||
formatUpdateBytes,
|
||||
formatUpdateTransferSummary,
|
||||
getDesktopBridge,
|
||||
isAllowedExternalUrl,
|
||||
isDesktopRuntime,
|
||||
@@ -61,7 +63,9 @@ describe("desktopBridge", () => {
|
||||
it("distinguishes global vs 3D-editor-only menu commands", () => {
|
||||
expect(isEditorOnlyMenuAction("file:new")).toBe(false);
|
||||
expect(isEditorOnlyMenuAction("file:open")).toBe(false);
|
||||
expect(isEditorOnlyMenuAction("file:save-and-update")).toBe(false);
|
||||
expect(isEditorOnlyMenuAction("file:dashboard")).toBe(false);
|
||||
expect(parseMenuAction("file:save-and-update")).toBe("file:save-and-update");
|
||||
expect(isEditorOnlyMenuAction("window:drawing")).toBe(false);
|
||||
expect(isEditorOnlyMenuAction("window:classrooms")).toBe(false);
|
||||
expect(isEditorOnlyMenuAction("window:shared")).toBe(false);
|
||||
@@ -128,6 +132,58 @@ describe("desktopBridge", () => {
|
||||
expect(formatFriendlyUpdateError("Özel sunucu mesajı")).toBe("Özel sunucu mesajı");
|
||||
});
|
||||
|
||||
it("formats live update download byte sizes and transfer summaries", () => {
|
||||
expect(formatUpdateBytes(0)).toBe("0 B");
|
||||
expect(formatUpdateBytes(512 * 1024)).toBe("512 KB");
|
||||
expect(formatUpdateBytes(25.4 * 1024 * 1024)).toBe("25.4 MB");
|
||||
|
||||
expect(formatUpdateTransferSummary(null)).toBe("");
|
||||
expect(
|
||||
formatUpdateTransferSummary({
|
||||
transferred: 12 * 1024 * 1024,
|
||||
total: 0,
|
||||
bytesPerSecond: 0,
|
||||
}),
|
||||
).toBe("12.0 MB indirildi");
|
||||
expect(
|
||||
formatUpdateTransferSummary({
|
||||
currentVersion: "1.0.10",
|
||||
latestVersion: "1.0.11",
|
||||
updateAvailable: true,
|
||||
downloaded: false,
|
||||
checkedAt: "2026-01-01T00:00:00.000Z",
|
||||
status: "downloading",
|
||||
progressPercent: 45,
|
||||
transferred: 45 * 1024 * 1024,
|
||||
total: 100 * 1024 * 1024,
|
||||
bytesPerSecond: 5.2 * 1024 * 1024,
|
||||
}),
|
||||
).toBe("45.0 MB / 100.0 MB • 5.2 MB/sn");
|
||||
});
|
||||
|
||||
it("keeps desktop update safeguard and auth sync IPC channels in parity", () => {
|
||||
const repoRoot = path.resolve(__dirname, "../..");
|
||||
const mainSource = fs.readFileSync(path.join(repoRoot, "apps/desktop/main.cjs"), "utf8");
|
||||
const preloadSource = fs.readFileSync(path.join(repoRoot, "apps/desktop/preload.cjs"), "utf8");
|
||||
const pageSource = fs.readFileSync(path.join(repoRoot, "apps/web/src/app/page.tsx"), "utf8");
|
||||
|
||||
const requiredChannels = [
|
||||
"snapcad:get-auth-state-sync",
|
||||
"snapcad:get-auth-state",
|
||||
"snapcad:open-update-progress",
|
||||
"snapcad:set-active-work-state",
|
||||
"snapcad:prepare-before-update",
|
||||
"snapcad:prepare-before-update-result",
|
||||
"snapcad:confirm-update-after-save",
|
||||
"snapcad:cancel-pending-update-install",
|
||||
];
|
||||
for (const channel of requiredChannels) {
|
||||
expect(mainSource, `Missing in main.cjs: ${channel}`).toContain(channel);
|
||||
expect(preloadSource, `Missing in preload.cjs: ${channel}`).toContain(channel);
|
||||
}
|
||||
expect(pageSource).toContain(`case "file:save-and-update":`);
|
||||
});
|
||||
|
||||
it("allows only http and https external URLs", () => {
|
||||
expect(isAllowedExternalUrl("https://snap.yakhub.com.tr")).toBe(true);
|
||||
expect(isAllowedExternalUrl("http://127.0.0.1:62158")).toBe(true);
|
||||
@@ -191,7 +247,7 @@ describe("desktopBridge", () => {
|
||||
};
|
||||
const swSource = fs.readFileSync(path.join(repoRoot, "apps/web/public/sw.js"), "utf8");
|
||||
|
||||
expect(pkg.version).toBe("1.0.10");
|
||||
expect(pkg.version).toBe("1.0.11");
|
||||
expect(lock.version).toBe(pkg.version);
|
||||
expect(lock.packages[""]?.version).toBe(pkg.version);
|
||||
expect(SKF_CREATED_WITH_VERSION).toBe(pkg.version);
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
computeUserInitials,
|
||||
resolveYakNetWidgetAttributes,
|
||||
sanitizeYakNetWidgetUser,
|
||||
shouldSuppressUnauthenticatedSsoMessage,
|
||||
YAKNET_ACCOUNT_CDN_URL,
|
||||
YAKNET_AUTH_BASE,
|
||||
YAKNET_SSO_IFRAME_ID,
|
||||
} from "../../apps/web/src/lib/yaknetWidgetHelpers";
|
||||
|
||||
describe("YakNet SSO Cross-Subdomain Real-Time Session Synchronization", () => {
|
||||
it("validates incoming YAKNET_SSO_STATUS message payload structure", () => {
|
||||
@@ -80,10 +91,97 @@ describe("YakNet SSO Cross-Subdomain Real-Time Session Synchronization", () => {
|
||||
});
|
||||
|
||||
it("ensures correct auth base URL for YakNet developer console SSO frame", () => {
|
||||
const YAKNET_AUTH_BASE = "https://developer-console.yakhub.com.tr";
|
||||
const ssoFrameUrl = `${YAKNET_AUTH_BASE}/sdk/sso-frame`;
|
||||
|
||||
expect(ssoFrameUrl).toBe("https://developer-console.yakhub.com.tr/sdk/sso-frame");
|
||||
expect(ssoFrameUrl.startsWith("https://developer-console.yakhub.com.tr")).toBe(true);
|
||||
});
|
||||
|
||||
it("omits authenticated attribute until session resolves to prevent login-button flash", () => {
|
||||
const unresolvedAttrs = resolveYakNetWidgetAttributes({
|
||||
user: null,
|
||||
sessionResolved: false,
|
||||
theme: "light",
|
||||
});
|
||||
expect(unresolvedAttrs.authenticated).toBeNull();
|
||||
expect(unresolvedAttrs["user-name"]).toBeNull();
|
||||
|
||||
const signedOutAttrs = resolveYakNetWidgetAttributes({
|
||||
user: null,
|
||||
sessionResolved: true,
|
||||
});
|
||||
expect(signedOutAttrs.authenticated).toBe("false");
|
||||
|
||||
const signedInAttrs = resolveYakNetWidgetAttributes({
|
||||
user: { id: 7, name: "Yakup İpek", email: "[email protected]" },
|
||||
sessionResolved: true,
|
||||
});
|
||||
expect(signedInAttrs.authenticated).toBe("true");
|
||||
expect(signedInAttrs["user-name"]).toBe("Yakup İpek");
|
||||
expect(signedInAttrs["user-email"]).toBe("[email protected]");
|
||||
});
|
||||
|
||||
it("suppresses stale or cookie-less unauthenticated SSO frame messages safely", () => {
|
||||
expect(
|
||||
shouldSuppressUnauthenticatedSsoMessage({
|
||||
isDesktop: true,
|
||||
sessionResolved: true,
|
||||
hasAuthenticatedUser: true,
|
||||
ssoFrameHadAuthenticated: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldSuppressUnauthenticatedSsoMessage({
|
||||
isDesktop: false,
|
||||
sessionResolved: false,
|
||||
hasAuthenticatedUser: false,
|
||||
ssoFrameHadAuthenticated: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldSuppressUnauthenticatedSsoMessage({
|
||||
isDesktop: false,
|
||||
sessionResolved: true,
|
||||
hasAuthenticatedUser: true,
|
||||
ssoFrameHadAuthenticated: false,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
shouldSuppressUnauthenticatedSsoMessage({
|
||||
isDesktop: false,
|
||||
sessionResolved: true,
|
||||
hasAuthenticatedUser: true,
|
||||
ssoFrameHadAuthenticated: true,
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("sanitizes YakNet widget users and computes avatar initials", () => {
|
||||
expect(sanitizeYakNetWidgetUser({ id: 0, name: "Invalid" })).toBeNull();
|
||||
expect(sanitizeYakNetWidgetUser({ id: 12, name: " Yakup İpek ", email: " [email protected] " })).toEqual({
|
||||
id: 12,
|
||||
name: "Yakup İpek",
|
||||
email: "[email protected]",
|
||||
avatar: null,
|
||||
auth_source: undefined,
|
||||
});
|
||||
expect(computeUserInitials("Yakup İpek")).toBe("Yİ");
|
||||
expect(computeUserInitials("Tekisim")).toBe("T");
|
||||
expect(computeUserInitials("")).toBe("YN");
|
||||
});
|
||||
|
||||
it("keeps yaknet-account widget dynamically loaded from CDN without vendoring", () => {
|
||||
const repoRoot = path.resolve(__dirname, "../..");
|
||||
const layoutSource = fs.readFileSync(path.join(repoRoot, "apps/web/src/app/layout.tsx"), "utf8");
|
||||
const cloudBarSource = fs.readFileSync(path.join(repoRoot, "apps/web/src/components/snapcad/YakNetCloudBar.tsx"), "utf8");
|
||||
|
||||
expect(YAKNET_ACCOUNT_CDN_URL).toBe("https://cdnjs.yakhub.com.tr/ajax/libs/yaknet-account/latest/yaknet-account.js");
|
||||
expect(layoutSource).toContain("YAKNET_ACCOUNT_CDN_URL");
|
||||
expect(cloudBarSource).toContain("YAKNET_SSO_IFRAME_ID");
|
||||
expect(YAKNET_SSO_IFRAME_ID).toBe("yaknet-sso-iframe-instance");
|
||||
expect(fs.existsSync(path.join(repoRoot, "apps/web/public/yaknet-account.js"))).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user