Diorama

Made for a big screen.

This site is one 3D scene, built for a computer: a wide window and a mouse. Open dioramajs.dev on a desktop or a laptop to see it.This site is one 3D scene, built for a wide window. Make this one wider, or open dioramajs.dev on a larger screen.

GitHub

DioramaDocs

Install with Astro

Add the Diorama integration to Astro and start the app once in the layout.

View as Markdown
On this page

Astro builds with Vite, so the integration adds the same plugin as the Vite setup. Effects go in src/effects/.

Install the packages

Terminal window
npm install @dioramajs/diorama three
Terminal window
pnpm add @dioramajs/diorama three
Terminal window
yarn add @dioramajs/diorama three
Terminal window
bun add @dioramajs/diorama three

Add the integration

astro.config.mjs
import diorama from '@dioramajs/diorama/astro'
export default { integrations: [diorama()] }

Start the app in the layout

Call start() in a <script> of the layout every page uses. Astro bundles the script and runs it once, so the app lives across pages.

src/layouts/Layout.astro
---
import { ClientRouter } from 'astro:transitions'
---
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Diorama</title>
<ClientRouter />
</head>
<body>
<slot />
<script>
import { start } from '@dioramajs/diorama'
start()
</script>
</body>
</html>

Put an effect on an image

src/pages/index.astro
---
import Layout from '../layouts/Layout.astro'
---
<Layout>
<img
src="/cover.jpg"
width="800"
height="450"
data-dio="ripple"
/>
</Layout>

With <ClientRouter /> in the layout, elements with the same data-dio-key fly between pages without more code. Your first page transition shows how.