phoria2
Small, friendly 3D for the web. A WebGL 2 renderer with PBR materials, shadows, instancing, points,
lines, labels, picking, glTF models and particles, behind an API small enough to learn in an
afternoon - aimed at business apps: charts, labelled scenes, diagrams, dashboards, floor plans and
product viewers. The demo gallery.
- Small: about 90 KB gzipped for a lit, interactive scene. Charts, particles, glTF, motion and
editing are separate imports, and the heavier parts - shadows, HDR environments, area lights,
glass and advanced materials, labels, bloom, GPU picking - load only when a scene uses them.
- Interaction built in: tooltips, hover highlights, click and drag handlers, and HTML labels
that hide when they overlap or go behind something - each an option or a line of code, not a
layer to build.
- Idle when nothing changes: a view draws only when something in it changed, so a dashboard of
many views only updates when needed.
- Any number of views on a page: browsers allow about 16 WebGL contexts per page, so most
libraries need one big canvas and scissoring for a dashboard of tiles. phoria2 gives the first four
views their own context and draws the rest with one shared context, each still an ordinary canvas
in your layout. The chart lab demo runs over 100 live chart views.
- Tells you what to write: every option is checked, and a mistake throws an error that names
the fix - pass
colour and you get Material: use 'color'. Written to be easy for coding
agents too.
- Small shader hooks, not full shaders: a line or two of GLSL in
material.shader waves a flag,
dissolves a part or pulses a line, and lighting, shadows, picking and outlines keep working - the
hook runs inside phoria2's own shader. A hook that doesn't compile says which of its lines is wrong.
- Product viewer polish as options:
ambientOcclusion shades the creases, groundShadow sets
a soft shadow under the model with no light needed, and fxaa smooths edges - each one option,
loaded only when turned on.
- Studio quality if you need it: glass that refracts, dispersion, coloured shadows and caustics; clearcoat,
sheen, iridescence, brushed metal and translucency; rect-area lights with soft, contact-hardening
shadows; HDR environments, bloom and fog.
refine: true keeps drawing while nothing moves to
increase quality further and allow depth of field.
- Real-world glTF: models load as exporters and optimisers write them - Draco and meshopt
geometry, KTX2 textures transcoded to the GPU's own compressed formats, WebP and AVIF, and instanced
meshes - with their materials (their KHR_materials extensions' textures too), variants, skins, morph targets and animations. The decoders load only for the files that
need them.
- Render textures: a
RenderTexture is what a camera sees, as any material's texture - live
camera feeds on monitors, a minimap, a second view beside a product.
- Accessible:
keyboard: true lets users step through bars, points and parts with the
arrow keys while a screen reader says what each one is; motion follows the system's
reduced-motion setting.
- Integrates well: physics, solid modelling and path finding can be added using libraries best
for them - the gallery shows phoria2 rendering with Rapier, Manifold and recast-navigation.
- No runtime dependencies. ES modules, with TypeScript types.
New to phoria2? The getting started tutorial
builds a first 3D scene and then a live dashboard of 3D charts, step by step - each step running
beside its code, ready to copy as one HTML file.
Using a coding agent? Point it at llms-full.txt - the whole API
in one page (llms.txt is the short index). Both ship in the
package too, at node_modules/phoria2/llms-full.txt.
Claude Code: install the phoria2 plugin, and Claude reaches for phoria2 when asked for 3D charts,
diagrams, explainers or dashboards - with the reference to hand and a check that loads the page in
Chrome and reports what's wrong:
/plugin marketplace add kevinroast/phoria2
/plugin install phoria2@phoria2
The skill inside it (claude-plugin/skills/phoria2) follows the Agent
Skills standard, so other agents that read skills can use the folder as it is.
Install
npm install phoria2
Or straight from a CDN, with no build step (the latest version):
<script type="module">
import { View, Mesh, box } from 'https://cdn.jsdelivr.net/npm/phoria2/+esm'
</script>
To use more than the core - charts, particles, glTF, motion or editing - map each import to the package's own
files, so they share one copy of the core (the CDN's ready-made +esm builds each bundle their
own). Pin the version so a new release can't change your page: