From 073d474bc3f06d064c45fe303ac46f922327cb19 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 25 Mar 2024 21:22:53 +0100 Subject: [PATCH] Refactoring --- .gitignore | 0 src/components/publics/PublicPreview.svelte | 15 +++++-- src/components/publics/XRayPreview.svelte | 14 +------ src/content/config.ts | 1 + src/content/publics/frostbite.json | 4 +- src/content/publics/ghostleviathan.json | 9 +++++ src/content/publics/lilith.json | 9 +++++ src/content/publics/warpedowl.json | 9 +++++ .../frostbite}/2024-03-24_20.59.03.png | Bin .../frostbite}/2024-03-24_20.59.59.png | Bin .../frostbite}/area_render_1_.png | Bin .../frostbite}/area_render_2_.png | Bin .../publics/ghostleviathan/area_render_9_.png | Bin 0 -> 1636798 bytes src/images/publics/lilith/area_render_11_.png | Bin 0 -> 1384475 bytes .../publics/warpedowl/area_render_12_.png | Bin 0 -> 1406174 bytes src/pages/publics/[schem].astro | 4 +- src/pages/publics/index.astro | 37 ++++++++++-------- 17 files changed, 66 insertions(+), 36 deletions(-) mode change 100755 => 100644 .gitignore create mode 100644 src/content/publics/ghostleviathan.json create mode 100644 src/content/publics/lilith.json create mode 100644 src/content/publics/warpedowl.json rename src/images/{ => publics/frostbite}/2024-03-24_20.59.03.png (100%) rename src/images/{ => publics/frostbite}/2024-03-24_20.59.59.png (100%) rename src/images/{ => publics/frostbite}/area_render_1_.png (100%) rename src/images/{ => publics/frostbite}/area_render_2_.png (100%) create mode 100644 src/images/publics/ghostleviathan/area_render_9_.png create mode 100644 src/images/publics/lilith/area_render_11_.png create mode 100644 src/images/publics/warpedowl/area_render_12_.png diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 diff --git a/src/components/publics/PublicPreview.svelte b/src/components/publics/PublicPreview.svelte index 503540c..8934b83 100644 --- a/src/components/publics/PublicPreview.svelte +++ b/src/components/publics/PublicPreview.svelte @@ -22,8 +22,9 @@ import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js"; import { OrbitControls } from "three/addons/controls/OrbitControls.js"; import {onDestroy, onMount} from "svelte"; + import { CollectionEntry } from "astro:content"; - export let file: string; + export let pub: CollectionEntry<"publics">; export let fov: number = 60; export let near: number = 1 export let far: number = 1000; @@ -40,6 +41,10 @@ let observer: ResizeObserver; onMount(() => { + if (!pub.data["3d"]) { + return; + } + scene = new THREE.Scene(); scene.background = new THREE.Color(0x171717); camera = new THREE.PerspectiveCamera(fov, 1, near, far); @@ -52,8 +57,8 @@ const loader = new GLTFLoader(); - loader.load(`/3d/${file}.glb`, (gltf) => { - let s = scene.add(gltf.scene); + loader.load(`/3d/${pub.id}.glb`, (gltf) => { + scene.add(gltf.scene); let cube_bbox = new THREE.Box3(); cube_bbox.setFromObject(gltf.scene); @@ -64,7 +69,9 @@ camera.position.set(0, center.y, distance); controls.update(); - }, undefined, console.log); + }, undefined, (e) => { + console.error(e); + }); div.append(renderer.domElement); diff --git a/src/components/publics/XRayPreview.svelte b/src/components/publics/XRayPreview.svelte index b458e98..1676343 100644 --- a/src/components/publics/XRayPreview.svelte +++ b/src/components/publics/XRayPreview.svelte @@ -20,29 +20,19 @@ -