Initial Code Commit
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user