Skip to content

GlyphCamera

<GlyphCamera> (alias for <GlyphOrthographicCamera>) is the outermost element in a glyphcss tree. Wrap <GlyphScene> inside it. The renderer and the hit layer both read from the same camera state — mutating rotY updates both simultaneously.

Props — orthographic (GlyphCamera / GlyphOrthographicCamera)

Section titled “Props — orthographic (GlyphCamera / GlyphOrthographicCamera)”
PropTypeDefaultDescription
rotXnumber (degrees)65Tilt around X axis
rotYnumber (degrees)45Spin around Y axis
zoomnumber0.65CSS pixels per world unit

Props — perspective (GlyphPerspectiveCamera)

Section titled “Props — perspective (GlyphPerspectiveCamera)”
PropTypeDefaultDescription
rotXnumber (degrees)65Tilt around X axis
rotYnumber (degrees)45Spin around Y axis
zoomnumber0.65CSS pixels per world unit
distancenumber0Camera pull-back. CSS pixels with CSS perspective; world units only in legacy perspective={0} mode
perspectivenumber32000CSS-perspective distance in virtual pixels (matches voxcss). Larger = flatter foreshortening; set 0 for legacy orbit projection
stretchnumber1.0Extra X scale on top of cellAspect
import {
GlyphPerspectiveCamera,
GlyphOrthographicCamera,
GlyphScene,
GlyphMesh,
GlyphOrbitControls,
} from "@glyphcss/react";
import { octahedronPolygons } from "@glyphcss/core";
const octa = octahedronPolygons({ center: [0, 0, 0], size: 1, color: "#ffcc44" });
// Perspective (foreshortened)
export function PerspectiveExample() {
return (
<GlyphPerspectiveCamera rotX={22} zoom={50} distance={3} stretch={0.95}>
<GlyphScene mode="solid" cols={100} rows={30}>
<GlyphOrbitControls />
<GlyphMesh polygons={octa} />
</GlyphScene>
</GlyphPerspectiveCamera>
);
}
// Orthographic — parallel lines stay parallel (isometric style)
export function OrthoExample() {
return (
<GlyphOrthographicCamera rotX={35} zoom={50}>
<GlyphScene mode="solid" cols={100} rows={30}>
<GlyphOrbitControls />
<GlyphMesh polygons={octa} />
</GlyphScene>
</GlyphOrthographicCamera>
);
}
  • The default perspective camera matches polycss/voxcss: distance: 0, perspective: 32000, zoom: 0.65.
  • rotX: 0 looks straight down the Z axis. Try 22 (degrees) for a slight downward tilt that gives the mesh visual weight.
  • stretch: 0.95 counteracts over-stretching from cellAspect ≈ 2 on typical monospace fonts. Leave at 1.0 if you tighten line-height instead.
  • Orthographic cameras ignore distance — use zoom to scale the mesh instead.
  • GlyphCamera is the ergonomic default alias for GlyphOrthographicCamera. Use it for iso/diagrammatic scenes; use GlyphPerspectiveCamera explicitly for character or walkthrough scenes.
  • Rotation units are degrees, matching voxcss/three.js. rotX=65, rotY=45 is the classic isometric-ish viewpoint. zoom is CSS pixels per world unit.