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)0Tilt around X axis
rotYnumber (degrees)0Spin around Y axis
zoomnumber50Camera zoom — pixels per world unit (zoom=50 → 50 px per world unit at BASE_TILE)

Props — perspective (GlyphPerspectiveCamera)

Section titled “Props — perspective (GlyphPerspectiveCamera)”
PropTypeDefaultDescription
rotXnumber (degrees)0Tilt around X axis
rotYnumber (degrees)0Spin around Y axis
zoomnumber50Camera zoom — pixels per world unit (zoom=50 → 50 px per world unit at BASE_TILE)
distancenumber3Camera distance — smaller = more perspective foreshortening
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>
);
}
  • Distance ranges that work well: 1.6 (strong perspective) → 5.0 (nearly flat).
  • 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 pixels per world unitzoom=50 means one world unit maps to 50 px.