Skip to content

Quickstart

Get a 3D mesh rendering in your project in two steps.

Terminal window
npm install polycss

The scene element (<poly-scene> / PolyScene) sets up the 3D viewport — perspective, camera, lighting. The mesh element (<poly-mesh> / PolyMesh) loads an OBJ or GLB file and renders its polygons. Pass rot-x / rot-y to set the camera angle.

<script type="module" src="https://esm.sh/polycss/elements"></script>
<poly-scene perspective="1000" rot-x="65" rot-y="45">
<poly-mesh src="/cottage.glb"></poly-mesh>
</poly-scene>
Loading…

Every polygon in the loaded mesh becomes a real DOM element — an atlas-backed <div> for UV-textured and flat-color polygons, positioned with transform: matrix3d(...). You can:

  • Inspect individual polygons in DevTools.
  • Target them with CSS selectors.
  • Attach onClick, onMouseEnter, and other standard DOM event handlers.
  • Core Concepts — The mental model: PolyScene, PolyMesh, Poly, polygon data, pipeline.
  • PolyCamera — Camera props and usage reference.
  • PolyScene — Scene props and mesh options.
  • Loading Meshes — OBJ, GLB, MTL loading and UV textures.
  • Gallery — Browse mesh models for inspiration.