Skip to content

feat: point lights (direction-only shading + radial colored shadows)#71

Merged
apresmoi merged 21 commits into
mainfrom
feat/point-lights
Jun 20, 2026
Merged

feat: point lights (direction-only shading + radial colored shadows)#71
apresmoi merged 21 commits into
mainfrom
feat/point-lights

Conversation

@apresmoi

Copy link
Copy Markdown
Collaborator

Adds point lights to PolyCSS across core, vanilla, React, and Vue, and overhauls the shadow color model.

Lights

  • New PolyPointLight (position, color, intensity, castShadow). Direction-only — no distance falloff — emulating three.js PointLight(distance:0, decay:0). Flat-per-face Lambert; accumulates per-channel with the directional + ambient terms.
  • Point lights are baked-mode only (dynamic mode's zero-JS light move can't express a per-face direction); dynamic scenes ignore them for both shading and shadows.
  • pointLights scene option mirrored across all renderers (per-mesh local conversion + bake/re-bake wiring).

Shadows

  • Radial point-light cast shadows: each vertex projects along its own ray from the light; point passes project the caster silhouette (per-face back-faces leave the contact footprint unshadowed under radial divergence).
  • Shaded, not flat-black: each light's shadow shows the receiver lit by every other light, so a region blocked from one colored light keeps the others' color (Three.js colored shadows). A lone directional light reduces to the ambient-only fill (unchanged).
  • Correct overlap: all of a receiver face's lights merge into one SVG — multi-light solid faces paint a full-lit base + per-light mix-blend-mode: multiply layers, so the both-blocked region composites to ambient-only. Shared via core computeMergedReceiverShadows so vanilla/React/Vue are identical.
  • No directional shadow at zero/absent intensity (Three.js parity); dropped the implicit-sun fallback. setOptions now re-emits shadows on directional intensity/color change, not just direction.

Docs & bench

  • New Lighting & Shadows guide with an interactive lit-cube demo (light direction/intensity/ambient controls + cast shadow); PolyDemo gains light controls and an opt-in ground shadow.
  • Documented the baked rebake contract (vanilla explicit rebakeAtlas() vs React/Vue auto-rebake) and the dynamic point-light exclusion.
  • Bench: point-light oracle (vs three.js PointLight(decay=0)), shadow-color delta tool, and a 4-pane vanilla/React/Vue/three parity page.

All packages green (core 1087, polycss 747, react 435, vue 434, fonts 45) and pnpm build clean.

apresmoi added 21 commits June 19, 2026 02:42
… (core computeMergedReceiverShadows); colored overlap + dynamic + intensity gate in react/vue
…lor change (not just direction); parity bench rebakes vanilla surface on light change
…nsity/ambient/direction) + opt-in ground shadow; fix zoom
@apresmoi apresmoi merged commit 0d91822 into main Jun 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