Skip to content

Commit 6442f2c

Browse files
authored
docs: document parametric shadows (definition, style, point lights, dragDefinition, followAnimation) (#73)
1 parent b84e15d commit 6442f2c

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

website/src/content/docs/components/poly-scene.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The React/Vue components and `createPolyScene()` support the full table. The `<p
2626
| `strategies` | `{ disable?: ("b" \| "i" \| "u")[] }` | None | Diagnostic override for render strategy selection. Disabled solid strategies fall through to `<s>` atlas slices; `<s>` cannot be disabled. |
2727
| `autoCenter` | `boolean` | `false` | Rotate around the content bbox center instead of world origin. Polygon data is not mutated. |
2828
| `centerPolygons` | `Polygon[]` | None | (Framework only.) Bbox source for `autoCenter` when renderable polygons live inside child meshes. |
29-
| `shadow` | `{ color?, opacity?, lift?, maxExtend? }` | `{ color:"#000000", opacity:0.25, lift:0.05, maxExtend:2000 }` | Appearance and SVG extent cap for cast shadows emitted by meshes with `castShadow`. |
29+
| `shadow` | `{ color?, opacity?, lift?, maxExtend?, parametric?, definition?, style?, dragDefinition?, followAnimation? }` | `{ color:"#000000", opacity:0.25, lift:0.05, maxExtend:2000 }` | Appearance + SVG extent cap for cast shadows. `parametric` swaps to a cheap low-res silhouette (`definition` = detail, `style: "vector" \| "pixel"`); `dragDefinition` (vanilla) and `followAnimation` cover light-drag and animated meshes. See [Parametric shadows](/guides/lighting/#parametric-shadows). |
3030
| `polygons` | `Polygon[]` | None | (Framework only.) Flat array of polygon objects rendered as direct children. Composes with JSX/slot children. |
3131
| `children` | None | None | Meshes, polygons, controls, helpers, selection wrappers, and transform controls. |
3232

@@ -54,6 +54,7 @@ React/Vue `<PolyMesh>` supports the full table. The `<poly-mesh>` custom element
5454
| `parseOptions` | `UseMeshOptions` | Parser options forwarded to `loadMesh`; `meshResolution` defaults to `"lossy"`. |
5555
| `meshResolution` | `"lossless" \| "lossy"` | Top-level optimizer intent. Wins over `parseOptions.meshResolution`; defaults to `"lossy"`. |
5656
| `castShadow` | `boolean` | Emit SVG cast shadows in both lighting modes; projections update when light, ground, or mesh geometry changes. |
57+
| `shadowDefinition` | `number` | Per-mesh parametric-shadow detail, overriding the scene's `shadow.definition` (only when `shadow.parametric`). |
5758
| `fallback` | `ReactNode` | Rendered while `src` is loading. (React / Vue only.) |
5859
| `errorFallback` | `(error: Error) => ReactNode` | Rendered if parse fails. (React / Vue only.) |
5960
| `children` | `(polygon, index) => ReactNode` | Per-polygon render prop / scoped slot. (React / Vue only.) |

website/src/content/docs/guides/lighting.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,31 @@ What to expect:
175175
- **Colored multi-light shadows.** Each light's shadow is filled with the receiver lit by every *other* light, so a spot blocked from one colored light still shows the others' color. Where two shadows overlap, the region composites to the both-blocked color (ambient only) — not a doubled-up black smear.
176176
- **`shadow.lift`** floats the shadow a hair above the receiver to avoid z-fighting; the default is fine, just don't set it to exactly `0` on a coplanar floor.
177177

178+
## Parametric shadows
179+
180+
By default a shadow projects every casting polygon. Set `shadow: { parametric: true }` and PolyCSS instead casts one low-resolution **coverage silhouette** per caster — far fewer DOM/SVG vertices and a cheaper projection, at the cost of an approximate (but concave- and hole-aware) outline. The exact path stays the default; parametric is purely opt-in and works in all three renderers.
181+
182+
```js
183+
// vanilla
184+
scene.setOptions({ shadow: { parametric: true, definition: 32 } });
185+
```
186+
187+
```jsx
188+
// React
189+
<PolyScene shadow={{ parametric: true, definition: 32 }}>
190+
```
191+
192+
```vue
193+
<!-- Vue -->
194+
<PolyScene :shadow="{ parametric: true, definition: 32 }">
195+
```
196+
197+
- **`definition`** (default `16`) — silhouette detail. Higher → closer to the exact outline and sharper holes, but more vertices. Override it per mesh with **`shadowDefinition`** (`PolyMeshTransform.shadowDefinition` in vanilla, `<PolyMesh shadowDefinition>` in React, `shadow-definition` in Vue) so a detailed hero caster stays crisp while simple props run cheap in the same scene.
198+
- **`style: "vector" | "pixel"`**`"vector"` (default) traces a smooth concave contour; `"pixel"` greedy-meshes the coverage into blocky **voxel** rectangles, where `definition` becomes the pixel-grid resolution (lower → chunkier). Holes (courtyards, an arena) come through in both.
199+
- **Point lights** are supported — each casting point light gets its own radial silhouette.
200+
- **`dragDefinition`** *(vanilla `createPolyScene` only)* — progressive refinement. While the directional light is being dragged the shadow renders at this lower definition for a smooth drag, then a debounced pass re-emits at full `definition` once the light settles. React/Vue get the same effect by lowering `definition` in component state during a drag.
201+
- **`followAnimation`** — by default a deforming/animated caster's shadow **freezes** at the last pose (re-projecting it every frame is expensive). Set `followAnimation: true` to make the shadow track the animation; pair it with `parametric` + a modest `definition` so the per-frame reprojection stays cheap.
202+
178203
## Live & animated lights
179204

180205
- **Animating the directional light:** use **dynamic** mode — moving the light is a single CSS-variable write per frame, no JS in the paint loop, and shadows re-project automatically.

0 commit comments

Comments
 (0)