Compare commits
7 Commits
72169c4e64
...
017d5ce458
| Author | SHA1 | Date | |
|---|---|---|---|
| 017d5ce458 | |||
| b4c669226f | |||
| ee6b9fcec1 | |||
| ff891bc164 | |||
| 0aec68eb8a | |||
| 527c2b438d | |||
| 5a5ae9901a |
@@ -2,6 +2,7 @@
|
|||||||
import Panel from '$lib/components/Panel.svelte';
|
import Panel from '$lib/components/Panel.svelte';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import Button from '$lib/components/Button.svelte';
|
import Button from '$lib/components/Button.svelte';
|
||||||
|
import type { ModelViewerElement } from '@google/model-viewer';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
@@ -24,31 +25,32 @@
|
|||||||
let yRotation = 0;
|
let yRotation = 0;
|
||||||
let zRotation = 0;
|
let zRotation = 0;
|
||||||
|
|
||||||
let modelViewer;
|
let modelViewer: ModelViewerElement | null = null;
|
||||||
|
|
||||||
$: style = `width: ${progress}%`;
|
$: style = `width: ${progress}%`;
|
||||||
|
|
||||||
const onProgress = ({ detail }) => {
|
const updateModelProgress = ({ detail }: { detail: { totalProgress: number } }) => {
|
||||||
progress = Math.ceil(detail.totalProgress * 100.0);
|
progress = Math.ceil(detail.totalProgress * 100.0);
|
||||||
if (progress == 100) {
|
if (progress == 100) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
hideProgressScreen = true;
|
hideProgressScreen = true;
|
||||||
}, 250);
|
}, 250);
|
||||||
} else hideProgressScreen = false;
|
} else hideProgressScreen = false;
|
||||||
}
|
};
|
||||||
|
|
||||||
function onResetView() {
|
function onResetView() {
|
||||||
cameraAzimuth = 0;
|
if (modelViewer) {
|
||||||
cameraPolar = 0;
|
cameraAzimuth = 0;
|
||||||
cameraZoom = 100;
|
cameraPolar = 0;
|
||||||
|
cameraZoom = 100;
|
||||||
modelViewer.cameraOrbit = cameraOrbit;
|
modelViewer.cameraOrbit = cameraOrbit;
|
||||||
modelViewer.cameraTarget = cameraTarget;
|
modelViewer.cameraTarget = cameraTarget;
|
||||||
modelViewer.fieldOfView = fieldOfView;
|
modelViewer.fieldOfView = fieldOfView;
|
||||||
cameraAzimuth = 0;
|
cameraAzimuth = 0;
|
||||||
cameraPolar = 0;
|
cameraPolar = 0;
|
||||||
cameraZoom = 100;
|
cameraZoom = 100;
|
||||||
fieldOfView = '10deg';
|
fieldOfView = '10deg';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateCameraOrbit(azimuth: number, polar: number, zoom: number) {
|
function updateCameraOrbit(azimuth: number, polar: number, zoom: number) {
|
||||||
@@ -58,10 +60,10 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="h-full model w-full bg-neutral-200 p-4 transition-all delay-250">
|
<div class="h-full w-full bg-neutral-200 p-4 transition-all delay-250">
|
||||||
<!-- xr-environment -->
|
<!-- xr-environment -->
|
||||||
<model-viewer
|
<model-viewer
|
||||||
ar
|
class="h-full w-full"
|
||||||
shadow-intensity="1"
|
shadow-intensity="1"
|
||||||
src={data.url}
|
src={data.url}
|
||||||
bind:this={modelViewer}
|
bind:this={modelViewer}
|
||||||
@@ -73,7 +75,7 @@
|
|||||||
orientation={`${xRotation}deg ${yRotation}deg ${zRotation}deg`}
|
orientation={`${xRotation}deg ${yRotation}deg ${zRotation}deg`}
|
||||||
camera-target="0m 0m 0m"
|
camera-target="0m 0m 0m"
|
||||||
camera-orbit={`${cameraAzimuth}deg ${cameraPolar}deg ${cameraZoom}%`}
|
camera-orbit={`${cameraAzimuth}deg ${cameraPolar}deg ${cameraZoom}%`}
|
||||||
on:progress={onProgress}
|
on:progress={updateModelProgress}
|
||||||
>
|
>
|
||||||
<!--Buttons zum Steuern-->
|
<!--Buttons zum Steuern-->
|
||||||
<div
|
<div
|
||||||
@@ -81,18 +83,7 @@
|
|||||||
class:opacity-0={!hideProgressScreen}
|
class:opacity-0={!hideProgressScreen}
|
||||||
class:hidden={!hideProgressScreen}
|
class:hidden={!hideProgressScreen}
|
||||||
>
|
>
|
||||||
<button slot="ar-button" id="ar-button"> 👋 Activate AR </button>
|
|
||||||
|
|
||||||
<div id="ar-prompt">AR-Prompt</div>
|
|
||||||
|
|
||||||
<button id="ar-failure"> AR is not tracking! </button>
|
|
||||||
<div class="flex flex-col bg-white/50">
|
<div class="flex flex-col bg-white/50">
|
||||||
<button
|
|
||||||
on:click={() => {
|
|
||||||
console.log(modelViewer.ar, modelViewer.getAttribute('ar-status'));
|
|
||||||
}}>Test</button
|
|
||||||
>
|
|
||||||
|
|
||||||
<!--3 Buttons-->
|
<!--3 Buttons-->
|
||||||
<div class="p-2">
|
<div class="p-2">
|
||||||
<Button
|
<Button
|
||||||
@@ -184,22 +175,4 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
model-viewer {
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* .vertical-slider {
|
|
||||||
writing-mode: bt-lr; /* Schreibt von unten nach oben (Vertikale Darstellung)
|
|
||||||
transform: rotate(270deg); /* Slider um 270° drehen
|
|
||||||
height: 200px;
|
|
||||||
} */
|
|
||||||
|
|
||||||
.model {
|
|
||||||
height: calc(100%-84px);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* .active-border {
|
|
||||||
border: 2px blue solid;
|
|
||||||
} */
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user