Skip to content

Unified API: camera wraps scene, ortho default, 11 primitive components#17

Merged
apresmoi merged 55 commits into
mainfrom
implement/api-design-unification
May 20, 2026
Merged

Unified API: camera wraps scene, ortho default, 11 primitive components#17
apresmoi merged 55 commits into
mainfrom
implement/api-design-unification

Conversation

@apresmoi
Copy link
Copy Markdown
Collaborator

Unifies the polycss API shape across vanilla JS, custom elements, React, and Vue. Same tree, same names, same defaults — one mental model.

Highlights

  • <PolyCamera> is now orthographic (was perspective). polycss optimizes for iso/voxel/diagrammatic scenes; ortho is the better default. <PolyPerspectiveCamera> stays available for perspective.
  • Camera wraps scene, always. <poly-scene rot-x> and createPolyScene({ rotX }) are removed; the scene reads camera state from a wrapping camera component/element/handle.
  • 11 primitive shape components in all four paths: PolyBox, PolyPlane, PolyRing, PolyOctahedron, PolyTetrahedron, PolyIcosahedron, PolyDodecahedron, PolyCylinder, PolyCone, PolyTorus, PolySphere. Each wraps the matching *Polygons() core helper — no shape-specific logic in the framework layers.
  • meshResolution promoted to a top-level <PolyMesh> prop (was buried in parseOptions).
  • <poly-first-person-controls> registered (was missing).
  • Gallery has a Primitives bucket showing all 11 shapes.
  • Website docs + landing rewritten to the new shape. Generic snippets use varied primitives; cottage+mtl kept for texture-loading examples.
  • AGENTS.md / CLAUDE.md synced with the new defaults.

Test plan

  • pnpm test — 1691 tests across 4 packages
  • pnpm build:packages — clean DTS for all 4
  • pnpm build:website — clean
  • Manual: open /gallery and confirm Primitives bucket renders Box, Plane, Ring, Octahedron, Tetrahedron, Icosahedron, Dodecahedron, Cylinder, Cone, Torus, Sphere.
  • Manual: open landing and confirm apple auto-rotates.

apresmoi added 30 commits May 20, 2026 00:48
…nger owns camera state

createPolyScene now requires { camera } — a handle from createPolyCamera,
createPolyOrthographicCamera, or createPolyPerspectiveCamera. Camera fields
(rotX, rotY, zoom, distance, target, perspective) are removed from
PolySceneOptions. scene.camera exposes the handle; scene.applyCamera()
re-applies the transform after camera.update(). All controls and tests updated.

<poly-scene> walks up the DOM tree for a camera ancestor element; if none is
found it creates an implicit orthographic camera from its own camera attrs
for backward compatibility.
… API

- Three framework tabs: poly-camera > poly-scene > poly-box pattern (custom elements),
  PolyCamera > PolyScene > PolyBox (React, Vue)
- Hero script replaced: createPolyCamera + createPolyScene + boxPolygons cube,
  no /apple.glb fetch; camera.setOptions() drives the auto-rotate
- Getting-started lede updated to mention poly-camera / createPolyCamera
poly-camera.mdx: PolyCamera is now orthographic (not perspective alias);
rewrite perspective-vs-ortho table, prop tables, all examples; remove
perspective=false pattern; all vanilla examples use poly-camera > poly-scene.

poly-scene.mdx: drop camera-on-scene description; all vanilla tabs now show
poly-camera wrapping poly-scene; Scene with Camera and Lighting switches
PolyCamera perspective={1000} to PolyPerspectiveCamera.

poly-controls.mdx: prose updated to say camera owns state; imperative example
uses createPolyCamera + createPolyScene({camera}); all poly-scene rot-x=...
snippets replaced with poly-camera > poly-scene nesting.
…e API

introduction.mdx: quick-taste snippet uses poly-camera > poly-scene; mentions
poly-camera in custom elements list.

quickstart.mdx: explanation rewritten; all three tabs use camera-wraps-scene;
perspective removed from PolyCamera (PolyCamera is now ortho default).

core-concepts.mdx: Camera section rewritten; vanilla example uses poly-camera;
entry points mention createPolyCamera; PolyCamera is correctly described.

projections.mdx: intro sentence corrected; all vanilla poly-scene rot-x=...
examples replaced with poly-camera / poly-perspective-camera wrappers; React
tabs use PolyPerspectiveCamera for perspective examples; camera-angles section
uses poly-camera.

shapes.mdx: poly-polygon vanilla tab uses poly-camera wrapper; interactive
example uses poly-camera; two createPolyScene(host, {rotX}) calls updated to
createPolyCamera + createPolyScene(host, {camera}).
…ene API

textures.mdx: vanilla loading example uses poly-camera > poly-scene wrapper.
headless.mdx: createPolyOrbitControls example uses createPolyCamera + createPolyScene({camera});
custom elements section lists poly-camera and shows correct nesting.
…poly-tetrahedron, poly-icosahedron, poly-dodecahedron, poly-cylinder, poly-cone, poly-torus custom elements
…trahedron, PolyIcosahedron, PolyDodecahedron, PolyCylinder, PolyCone, PolyTorus shape components
…ahedron, PolyIcosahedron, PolyDodecahedron, PolyCylinder, PolyCone, PolyTorus shape components
apresmoi added 25 commits May 20, 2026 02:08
React/Vue snippets now wrap <PolyScene> in <PolyCamera> or
<PolyPerspectiveCamera>. Vanilla HTML uses <poly-camera> /
<poly-perspective-camera> wrapping <poly-scene>. Imperative generator
path uses createPolyCamera/createPolyPerspectiveCamera + passes {camera}
to createPolyScene — drops rotX/rotY/perspective from scene options.
Controls are emitted inside <PolyScene> when animate or interactive is on.
The old docs said controls used scene.setOptions({rotX,rotY,...}). The
real surface is scene.camera.update({...}) + scene.applyCamera().
textures.mdx: createPolyScene imperative example was missing createPolyCamera
and the required {camera} option. performance.mdx: poly-scene snippet was
bare without a wrapping poly-camera element.
@apresmoi apresmoi merged commit 6aeb4d6 into main May 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant