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

grid

BackgroundsAlso inScroll scenes

@dioramajs/backgrounds/gridSource

A grid floor in perspective running toward the viewer under a glowing horizon: neon synthwave, a blueprint or plain thin lines.

View as Markdown
On this page

Live, one night only

Neon Nights at the Arcade Hall

Date
Mar 14
Doors
22:00
Tickets
€25

Three synthwave sets, a retro game corner and a light show until 4 am.

Live preview needs WebGPU or WebGL 2. An event card for a synthwave night, with a neon grid floor running toward a striped sun beside the date and ticket price.

This example failed to draw.

Switch style to blueprint or minimal, and set the colors to your brand.
Params of grid
style

neon glowing lines and a striped sun, for gaming, music events and synthwave looks.

Usage

Put it on an empty decorative element behind the content, such as an aria-hidden div filling a hero; its CSS background is the look without WebGL. start() registers grid, so the attribute alone puts it on an element. The tabs below are the example above, with the values you set.

To change its code, copy the source into your effects folder; the copy replaces the built-in.

Terminal window
npx @dioramajs/diorama add grid
<article class="gr-gig">
<div class="gr-floor" aria-hidden="true" data-dio="grid"></div>
<div class="gr-info">
<p class="gr-kicker">Live, one night only</p>
<h2>Neon Nights at the Arcade Hall</h2>
<dl>
<div><dt>Date</dt><dd>Mar 14</dd></div>
<div><dt>Doors</dt><dd>22:00</dd></div>
<div><dt>Tickets</dt><dd>€25</dd></div>
</dl>
<p>Three synthwave sets, a retro game corner and a light show until 4 am.</p>
</div>
</article>
import { start } from '@dioramajs/diorama'
const app = start()
app.attach('.gr-floor', 'grid', {
style: 'neon',
color: '#ff4fd8',
background: '#0d0221',
accent: '#ff8a3d',
cells: 14,
horizon: 0.5,
speed: 0.4,
sun: 0.5,
thickness: 1.2,
depth: 0.2,
scroll: 0.3,
fps: 30,
})
import { start } from '@dioramajs/diorama'
import grid from '@dioramajs/backgrounds/grid'
const app = start()
app.attach('.gr-floor', grid({
style: 'neon',
color: '#ff4fd8',
background: '#0d0221',
accent: '#ff8a3d',
cells: 14,
horizon: 0.5,
speed: 0.4,
sun: 0.5,
thickness: 1.2,
depth: 0.2,
scroll: 0.3,
fps: 30,
}))

Page transitions

Fades with the page transition. How a flight flies.

Params

Every param is also an attribute, and both app.attach() and the handle take it by name.

ParamTypeDefaultDescription
stylerebuildsdata-dio-style'neon' | 'blueprint' | 'minimal''neon'
  • neon glowing lines and a striped sun, for gaming, music events and synthwave looks.
  • blueprint pale lines on blue paper with heavier major lines, for engineering, hardware and developer tools.
  • minimal thin lines fading into a flat color, for calm tech and SaaS pages.
colordata-dio-colorcolor'#ff4fd8'Color of the lines, any CSS color.
backgrounddata-dio-backgroundcolor'#0d0221'Color of the floor and the sky.
accentdata-dio-accentcolor'#ff8a3d'Color of the horizon glow and the sun; with minimal, of the sun only; with blueprint, of the haze.
cellsdata-dio-cellsnumber2 to 6014Cells across the bottom edge: more makes a finer grid.
horizondata-dio-horizonnumber0.1 to 0.90.5Height of the horizon from the top, as a share of the element.
speeddata-dio-speednumber0 to 20.4How fast the floor runs toward the viewer; 0 holds it.
sundata-dio-sunnumber0 to 10.5Size of the sun on the horizon; 0 hides it.
thicknessdata-dio-thicknessnumber0.5 to 4 px1.2Width of the lines in CSS pixels.
depthdata-dio-depthnumber0 to 10.2How far the view turns with the pointer; 0 ignores the pointer.
scrolldata-dio-scrollnumber0 to 10.3How far the floor moves forward while the element crosses the viewport; 0 keeps it.
fpsdata-dio-fpsnumber0 to 6030Most frames a second the floor draws while it runs; 0 holds it still.At most low 15, medium 24 by quality tier.

Params marked rebuilds re-run the effect's setup when they change, so set them before the element shows.

Inputs and frames

It reads delta, hover, pointer, progress, reducedMotion and size . Draws at a steady rate while it is on screen and stops when it leaves. Up to fps frames a second while on screen, none off screen or at fps 0; pointer and scroll draw at full rate. How a frame is decided.

Reduced motion and touch

With reduced motion it shows a still frame: motion inputs are zero and time stands still. A still floor: it does not run, and neither the pointer nor scroll moves it.

Runs on every device. The view turns with a finger while it is on the screen; scrolling works as usual.

To change what reduced motion does, patch it in start().

import { start } from '@dioramajs/diorama'
start({ effects: { grid: { reducedMotion: 'off' } } })

Cost and quality

Download
1.9 KB min+gzip the first time a page uses it
GPU
One pass over the element with a little math per pixel, no textures.
Memory
None beyond the shared plane.
Frames
Draws while on screen

It runs from the low tier up. Each tier changes this: The quality plugin picks the tier for each device.

TierWhat changes
lowAt most 15 frames a second.
mediumAt most 24 frames a second.

Recipes

A synthwave hero for a music night

Put the grid on an empty aria-hidden element that fills the hero and start the app with canvas: 'behind'. Keep the heading in the sky above the horizon, where the background is darkest.

<header class="hero">
<div
class="hero-bg"
aria-hidden="true"
data-dio="grid"
data-dio-horizon="0.62"
></div>
<h1>Neon Nights, Friday 22:00</h1>
<a class="cta" href="/tickets">Get tickets</a>
</header>
.hero {
position: relative;
isolation: isolate;
min-height: 80vh;
color: #fff;
}
.hero-bg {
position: absolute;
inset: 0;
z-index: -1;
background: linear-gradient(180deg, #0d0221 0 40%, #ff8a3d 62%, #0d0221 62%);
}
src/main.ts
import { start } from '@dioramajs/diorama'
export const app = start({ canvas: 'behind' })

A blueprint for a hardware page

blueprint draws pale lines on blue paper with every fifth line heavier and the sun as a drawn circle. The colors below work well together.

Live preview needs WebGPU or WebGL 2. Pale blue grid lines on a deep blue floor running to a hazy horizon, with a thin circle for the sun.

This example failed to draw.

Params of grid
<div
class="gr-print"
aria-hidden="true"
data-dio="grid"
data-dio-style="blueprint"
data-dio-color="#d6e6ff"
data-dio-background="#0d3b8c"
data-dio-accent="#9cc3ff"
data-dio-cells="24"
data-dio-sun="0.4"
data-dio-speed="0.2"
></div>

Calm lines for a developer tool

minimal draws thin lines that fade out toward the horizon over a flat color, without glow. A gray line color on a near-black background, sun at 0 and a slow speed give a quiet tech backdrop.

<div
class="bg"
aria-hidden="true"
data-dio="grid"
data-dio-style="minimal"
data-dio-color="#9aa4b2"
data-dio-background="#0b0d12"
data-dio-sun="0"
data-dio-speed="0.2"
></div>

Readable text

  • neon: white text in the sky above the horizon; set horizon to 0.55 or more for room. Over the floor, put text on a card.
  • blueprint: white or #eaf2ff text over the deep blue; the lines are pale, so keep thickness at 1.2 or below under body text.
  • minimal: light text such as #e6e8ec; the lines stay faint enough for text anywhere.

Notes

The docs canvas sits above the page, so the examples here keep text beside the grid. Put text over it with canvas: 'behind', as in the first recipe.

Lines keep their width in CSS pixels at any distance and blend into an even, fading tone where they crowd near the horizon, so the floor never shimmers. The grid draws without textures.

It draws up to fps frames a second while it is on screen and none off screen; the pointer and scroll draw at full rate while they move the floor. With depth at 0 the pointer draws nothing. On the low tier it draws at most 15 frames a second.

style rebuilds the effect when it changes. Colors, cell count, horizon, speed, sun and line width change live.