Astro + React islands + MDX with a theme system (terminal, concrete, nostromo, overgrowth), USMT Dash case study, work/log/sound/models/about/ contact pages, RSS, self-hosted contact form over SMTP, /media proxy to Nextcloud, Dockerfile for Coolify, and a GitHub Action that mirrors main to Gitea.
This commit is contained in:
64 files changed
+9066
No files matched your search
@@ -0,0 +1,80 @@
|
||||
---
|
||||
/**
|
||||
* Drop-in 3D viewer for .glb/.gltf files using <model-viewer> (three.js under
|
||||
* the hood). For custom scenes, write a React Three Fiber island instead.
|
||||
*/
|
||||
interface Props {
|
||||
src: string;
|
||||
alt: string;
|
||||
poster?: string;
|
||||
ratio?: string;
|
||||
}
|
||||
const { src, alt, poster, ratio = '16 / 10' } = Astro.props;
|
||||
---
|
||||
|
||||
<div class="viewer" style={`--ratio: ${ratio}`}>
|
||||
<model-viewer
|
||||
src={src}
|
||||
alt={alt}
|
||||
poster={poster}
|
||||
camera-controls
|
||||
auto-rotate
|
||||
auto-rotate-delay="2000"
|
||||
rotation-per-second="12deg"
|
||||
shadow-intensity="0.8"
|
||||
exposure="1.05"
|
||||
interaction-prompt="none"
|
||||
loading="lazy"
|
||||
reveal="interaction"
|
||||
>
|
||||
<button slot="poster" class="placeholder start">[ load model ]</button>
|
||||
<div slot="progress-bar" class="bar"></div>
|
||||
</model-viewer>
|
||||
<span class="label hud">Drag to orbit · scroll to zoom</span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
import '@google/model-viewer';
|
||||
document.addEventListener('astro:page-load', () => {
|
||||
document.querySelectorAll('model-viewer').forEach((mv) => {
|
||||
const el = mv as HTMLElement & { dismissPoster?: () => void };
|
||||
el.querySelector('.start')?.addEventListener('click', () => el.dismissPoster?.());
|
||||
el.addEventListener('error', () => {
|
||||
const btn = el.querySelector<HTMLElement>('.start');
|
||||
if (btn) btn.textContent = '[ signal lost — model not found ]';
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.viewer {
|
||||
position: relative;
|
||||
margin-bottom: var(--space-7);
|
||||
border: var(--border-w) solid var(--line-strong);
|
||||
background:
|
||||
radial-gradient(circle at 50% 60%, color-mix(in oklab, var(--accent) 12%, transparent), transparent 60%),
|
||||
var(--bg-sunken);
|
||||
}
|
||||
model-viewer {
|
||||
width: 100%;
|
||||
aspect-ratio: var(--ratio);
|
||||
height: auto;
|
||||
--poster-color: transparent;
|
||||
}
|
||||
.start {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.start:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
.hud {
|
||||
position: absolute;
|
||||
right: var(--space-3);
|
||||
bottom: var(--space-2);
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user