From c877fef490f30946a1f1eb6133257da6c131caf9 Mon Sep 17 00:00:00 2001 From: Yeicor <4929005+Yeicor@users.noreply.github.com> Date: Sat, 26 Jul 2025 17:01:42 +0200 Subject: [PATCH] Minor fixes and drag and drop models onto interface --- README.md | 4 +-- frontend/App.vue | 17 ++++++++++++ frontend/misc/gltf.ts | 31 ++++++++++++++++++++-- frontend/misc/network.ts | 30 +++++++++++++-------- frontend/misc/scene.ts | 7 +++-- frontend/misc/settings.ts | 8 +++++- frontend/tools/PlaygroundDialogContent.vue | 2 +- frontend/tools/Tools.vue | 1 + yacv_server/yacv.py | 1 - 9 files changed, 81 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 8e53584..72be8f3 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ in a web browser. The [example](example) is a fully working project that shows how to use the viewer. You can play with the latest -demo [here](https://yeicor-3d.github.io/yet-another-cad-viewer/?preload=logo.glb&preload=logo_hl.glb&preload=fox.glb&preload=img.jpg.glb&preload=location.glb) +demo [here](https://yeicor-3d.github.io/yet-another-cad-viewer/?preload=logo.glb&preload=logo_hl.glb&preload=logo_hl_tex.glb&preload=fox.glb&preload=img.jpg.glb&preload=location.glb) (or -[without animation](https://yeicor-3d.github.io/yet-another-cad-viewer/?autoplay=false&preload=logo.glb&preload=logo_hl.glb&preload=fox.glb&preload=img.jpg.glb&preload=location.glb)). +[without animation](https://yeicor-3d.github.io/yet-another-cad-viewer/?autoplay=false&preload=logo.glb&preload=logo_hl.glb&preload=logo_hl_tex.glb&preload=fox.glb&preload=img.jpg.glb&preload=location.glb)). ![Demo](assets/screenshot.png) diff --git a/frontend/App.vue b/frontend/App.vue index 130522e..a2d560f 100644 --- a/frontend/App.vue +++ b/frontend/App.vue @@ -108,6 +108,23 @@ async function loadModelManual() { const modelUrl = prompt("For an improved experience in viewing CAD/GLTF models with automatic updates, it's recommended to use the official yacv_server Python package. This ensures seamless serving of models and automatic updates.\n\nOtherwise, enter the URL of the model to load:"); if (modelUrl) await networkMgr.load(modelUrl); } + +// Detect dropped .glb files and load them manually +document.body.addEventListener("dragover", e => { + e.preventDefault(); // Allow drop +}); + +document.body.addEventListener("drop", async e => { + e.preventDefault(); + const file = e.dataTransfer?.files?.[0]; + if (!file) return; + + const ext = file.name.split('.').pop()?.toLowerCase(); + if (ext === 'glb' || ext === 'gltf') { + await networkMgr.load(file); + } +}); +