Skip to content
glyphcss

GlyphCamera

Loading…

Drag to orbit; change tilt, zoom, or distance. This perspective demo uses perspective: 8000 to make foreshortening easier to see.

import { GlyphCamera, GlyphPerspectiveCamera, GlyphScene, GlyphMesh, GlyphOrbitControls } from "@glyphcss/react";
export function Example() {
return (
<GlyphPerspectiveCamera rotX={35} rotY={45} zoom={50}>
<GlyphScene mode="solid">
<GlyphMesh geometry="cube" />
<GlyphOrbitControls drag wheel />
</GlyphScene>
</GlyphPerspectiveCamera>
);
}
// Replace GlyphPerspectiveCamera with GlyphCamera for orthographic projection.

GlyphCamera aliases GlyphOrthographicCamera: parallel lines stay parallel. GlyphPerspectiveCamera adds foreshortening. Wrap GlyphScene inside the camera in React/Vue; pass a camera handle to createGlyphScene in vanilla JS.

OptionDefaultMeaning
rotX65X rotation, degrees; 0 looks down Z
rotY45Y rotation, degrees
zoom0.65CSS pixels per world unit
distance0Perspective pull-back: CSS pixels; world units when perspective: 0
perspective32000Virtual-pixel perspective distance; larger looks flatter; 0 selects legacy orbit projection
stretch1Perspective-only extra horizontal scale

Orthographic cameras use rotX, rotY, and zoom; distance has no effect. The renderer and hit layer share camera state. After mutating a vanilla camera, call scene.rerender().