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.
The Vite plugin turns every file in src/effects/ into an effect that loads on demand and writes the types of those effects to src/diorama.gen.d.ts. It works with any framework that builds with Vite.
Starts Diorama on the page and returns the app at once. It finishes starting in the
background. A second call returns the same app, so a re-run module doesn't make another.
import { start } from '@dioramajs/diorama'
export const app = start()
start}from'@dioramajs/diorama'
exportconst
const app:App
app=
functionstart(options?:StartOptions):App
Starts Diorama on the page and returns the app at once. It finishes starting in the
background. A second call returns the same app, so a re-run module doesn't make another.
import { start } from '@dioramajs/diorama'
export const app = start()
start()
Put an effect on an image
Add data-dio with an effect name to an element. The ripple effect comes with start().
index.html
<!doctypehtml>
<htmllang="en">
<head>
<metacharset="utf-8"/>
<title>Diorama</title>
<scripttype="module"src="/src/main.ts"></script>
</head>
<body>
<img
src="/cover.jpg"
width="800"
height="450"
data-dio="ripple"
/>
</body>
</html>
Run the dev server and move the pointer over the image. Rings spread from the pointer, and the image keeps its place in the layout while you scroll.
Plugin options
Name
Type
Description
readonly dir?
string
The effects folder, relative to the Vite root. Default 'src/effects'.
readonly types?
string | false
The types file, relative to the root, or false for none. Default 'src/diorama.gen.d.ts'.