Initial Code Commit

This commit is contained in:
2025-11-03 19:51:59 +00:00
parent cfd3ccbdbb
commit b84eb2db3d
45 changed files with 1078 additions and 138 deletions
+18
View File
@@ -0,0 +1,18 @@
import fs from 'fs';
/** @type {import('./$types').PageServerLoad} */
export async function load({ params }) {
let files = [];
const models = fs.readdirSync(`./static/models`).filter(file => file.endsWith('.glb'));
for(let model of models) {
let obj = {
path: "/models/" + model,
name: model.split('.')[0]
}
files.push(obj);
}
return { files };
}
+55
View File
@@ -0,0 +1,55 @@
<svelte:head>
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
</svelte:head>
<script lang="ts">
// @ts-nocheck
import { page } from '$app/stores';
import { onMount } from "svelte";
import { getModalStore } from '@skeletonlabs/skeleton';
const modalStore = getModalStore();
let container, row, modelViewer, modelViewerTitle, modelViewerBtn;
// const modal: ModalSettings = {
// type: 'alert',
// // Data
// title: 'Example Alert',
// body: 'This is an example modal.',
// image: 'https://i.imgur.com/WOgTG96.gif',
// };
// modalStore.trigger(modal);
onMount(() => {
modelViewerTitle = document.querySelector("#model-viewer-bts-title");
for(let i = 0; i < $page.data.files.length; i++) {
console.log($page.data.files[i]);
}
});
function download() {
modelViewerBtn.disabled = true;
modelViewerBtn.innerHTML = "Downloading...";
modelViewer.exportScene("glb").then((blob) => {
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = modelViewerTitle.innerText + ".glb";
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
modelViewerBtn.disabled = false;
modelViewerBtn.innerHTML = "Download";
});
}
</script>
<section class="h-full mx-auto justify-center p-10">
</section>