@layoutit/polycss 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,7 +69,7 @@ export default function App() {
69
69
  ### PolyScene
70
70
 
71
71
  - `polygons` renders a static `Polygon[]` directly.
72
- - `directionalLight` and `ambientLight` control scene lighting.
72
+ - `directionalLight`, `pointLights` (direction-only, baked mode; optional per-light `castShadow`), and `ambientLight` control scene lighting.
73
73
  - `textureLighting` chooses `"baked"` or `"dynamic"`.
74
74
  - `textureQuality` controls atlas raster budget.
75
75
  - `strategies` can disable selected render strategies for diagnostics.
@@ -84,7 +84,6 @@ export default function App() {
84
84
  - `autoCenter` shifts the mesh bbox center to local origin.
85
85
  - `meshResolution` chooses `"lossy"` (default) or `"lossless"` optimization. STL imports use the conservative lossless path in both modes.
86
86
  - `castShadow` emits CSS-projected shadows in dynamic lighting mode.
87
- - Tooling can reuse `buildPolyMeshTransform`, `buildPolySceneTransform`, `worldPositionToPolyCss`, `worldDirectionToPolyCss`, `worldDirectionalLightToPolyCss`, `worldDistanceToPolyCss`, `polyCssDistanceToWorld`, and `polyCssPositionToWorld` for renderer-compatible transforms and world/CSS conversions.
88
87
 
89
88
  ### Controls
90
89
 
@@ -1,4 +1,4 @@
1
- import { CameraHandle, Vec3, Polygon, MeshResolution, ParseResult, PolyDirectionalLight, PolyAmbientLight, PolyTextureLightingMode, TextureQuality, PolyTextureLeafSizing, PolyTextureImageRendering, PolyTextureBackend, PolyTextureProjection, PolySeamBleed, PolyRenderStrategiesOption } from '@layoutit/polycss-core';
1
+ import { CameraHandle, Vec3, Polygon, MeshResolution, ParseResult, PolyDirectionalLight, PolyPointLight, PolyAmbientLight, PolyTextureLightingMode, TextureQuality, PolyTextureLeafSizing, PolyTextureImageRendering, PolyTextureBackend, PolyTextureProjection, PolySeamBleed, PolyRenderStrategiesOption } from '@layoutit/polycss-core';
2
2
 
3
3
  interface PolyCameraOptions {
4
4
  zoom?: number;
@@ -61,6 +61,9 @@ interface PolySceneOptions {
61
61
  */
62
62
  camera: PolyPerspectiveCameraHandle | PolyOrthographicCameraHandle;
63
63
  directionalLight?: PolyDirectionalLight;
64
+ /** Point lights (world-space positions). Direction-only per-face Lambert
65
+ * shading (no distance falloff). Baked-mode only. */
66
+ pointLights?: PolyPointLight[];
64
67
  ambientLight?: PolyAmbientLight;
65
68
  /** Textured polygon lighting mode. Defaults to "baked". */
66
69
  textureLighting?: PolyTextureLightingMode;
@@ -123,6 +126,50 @@ interface PolySceneOptions {
123
126
  * very large number (e.g. `Infinity`) to disable the cap entirely.
124
127
  */
125
128
  maxExtend?: number;
129
+ /**
130
+ * Experimental: cast a single low-resolution parametric **silhouette**
131
+ * outline per caster instead of projecting its full geometry. Lighter DOM
132
+ * + cheaper projection, at the cost of an approximate (convex) outline.
133
+ * Casts onto every receiver through the normal pipeline. Default: `false`.
134
+ */
135
+ parametric?: boolean;
136
+ /**
137
+ * Parametric-shadow detail: the max number of points in the silhouette
138
+ * outline. Lower → blobbier + lighter; higher → closer to the exact convex
139
+ * outline. Only used when `parametric` is true. Default: `16`.
140
+ *
141
+ * Can be overridden per mesh via `PolyMeshTransform.shadowDefinition`.
142
+ */
143
+ definition?: number;
144
+ /**
145
+ * Progressive refinement: the definition used WHILE the directional light
146
+ * is actively changing (a drag). When set (and `parametric` is true), each
147
+ * light-direction change emits at `min(definition, dragDefinition)` for a
148
+ * laggless drag, then a debounced pass re-emits at full `definition` once
149
+ * the light settles — mirroring the atlas-rebake-at-rest escape hatch.
150
+ * Self-shadow recompute is O(faces × bands), so dropping detail during
151
+ * motion is the only way to keep a complex mesh smooth. Unset → no
152
+ * progressive pass (every change renders at full `definition`).
153
+ */
154
+ dragDefinition?: number;
155
+ /**
156
+ * Parametric-shadow render style (only used when `parametric` is true):
157
+ * - `"vector"` (default) — smooth concave contour outline.
158
+ * - `"pixel"` — the coverage is greedy-meshed into axis-aligned rectangles,
159
+ * giving a blocky/voxel shadow. Holes (courtyards, the coliseum arena)
160
+ * come free as absent cells. `definition` is the pixel-grid resolution
161
+ * (lower → chunkier); the block size is the aesthetic.
162
+ */
163
+ style?: "vector" | "pixel";
164
+ /**
165
+ * Re-emit shadows while a mesh is animating (skeletal/GLB deformation), so
166
+ * the shadow follows the pose instead of freezing at the rest pose. Each
167
+ * `setPolygons` from the animation loop triggers a re-projection, throttled
168
+ * internally (~12fps) so it stays affordable. Strongly recommended only
169
+ * with `parametric: true` (a low-res silhouette is cheap to reproject every
170
+ * few frames; the exact path is not). Default: `false`.
171
+ */
172
+ followAnimation?: boolean;
126
173
  };
127
174
  /**
128
175
  * When `true`, emit `data-poly-shadow-*` attribution attributes on every
@@ -182,6 +229,14 @@ interface PolyMeshTransform {
182
229
  * Defaults to `false`.
183
230
  */
184
231
  receiveShadow?: boolean;
232
+ /**
233
+ * Per-mesh parametric-shadow detail (overrides the scene's
234
+ * `shadow.definition` for THIS mesh's cast/self shadow). Lets a detailed
235
+ * caster stay high-resolution while a simple prop runs cheap in the same
236
+ * scene. Only used when `shadow.parametric` is true. Unset → inherit the
237
+ * scene definition.
238
+ */
239
+ shadowDefinition?: number;
185
240
  }
186
241
  interface PolyMeshHandle {
187
242
  /** The polygons that were loaded after normalization and automatic merge. */
@@ -1,4 +1,4 @@
1
- import { CameraHandle, Vec3, Polygon, MeshResolution, ParseResult, PolyDirectionalLight, PolyAmbientLight, PolyTextureLightingMode, TextureQuality, PolyTextureLeafSizing, PolyTextureImageRendering, PolyTextureBackend, PolyTextureProjection, PolySeamBleed, PolyRenderStrategiesOption } from '@layoutit/polycss-core';
1
+ import { CameraHandle, Vec3, Polygon, MeshResolution, ParseResult, PolyDirectionalLight, PolyPointLight, PolyAmbientLight, PolyTextureLightingMode, TextureQuality, PolyTextureLeafSizing, PolyTextureImageRendering, PolyTextureBackend, PolyTextureProjection, PolySeamBleed, PolyRenderStrategiesOption } from '@layoutit/polycss-core';
2
2
 
3
3
  interface PolyCameraOptions {
4
4
  zoom?: number;
@@ -61,6 +61,9 @@ interface PolySceneOptions {
61
61
  */
62
62
  camera: PolyPerspectiveCameraHandle | PolyOrthographicCameraHandle;
63
63
  directionalLight?: PolyDirectionalLight;
64
+ /** Point lights (world-space positions). Direction-only per-face Lambert
65
+ * shading (no distance falloff). Baked-mode only. */
66
+ pointLights?: PolyPointLight[];
64
67
  ambientLight?: PolyAmbientLight;
65
68
  /** Textured polygon lighting mode. Defaults to "baked". */
66
69
  textureLighting?: PolyTextureLightingMode;
@@ -123,6 +126,50 @@ interface PolySceneOptions {
123
126
  * very large number (e.g. `Infinity`) to disable the cap entirely.
124
127
  */
125
128
  maxExtend?: number;
129
+ /**
130
+ * Experimental: cast a single low-resolution parametric **silhouette**
131
+ * outline per caster instead of projecting its full geometry. Lighter DOM
132
+ * + cheaper projection, at the cost of an approximate (convex) outline.
133
+ * Casts onto every receiver through the normal pipeline. Default: `false`.
134
+ */
135
+ parametric?: boolean;
136
+ /**
137
+ * Parametric-shadow detail: the max number of points in the silhouette
138
+ * outline. Lower → blobbier + lighter; higher → closer to the exact convex
139
+ * outline. Only used when `parametric` is true. Default: `16`.
140
+ *
141
+ * Can be overridden per mesh via `PolyMeshTransform.shadowDefinition`.
142
+ */
143
+ definition?: number;
144
+ /**
145
+ * Progressive refinement: the definition used WHILE the directional light
146
+ * is actively changing (a drag). When set (and `parametric` is true), each
147
+ * light-direction change emits at `min(definition, dragDefinition)` for a
148
+ * laggless drag, then a debounced pass re-emits at full `definition` once
149
+ * the light settles — mirroring the atlas-rebake-at-rest escape hatch.
150
+ * Self-shadow recompute is O(faces × bands), so dropping detail during
151
+ * motion is the only way to keep a complex mesh smooth. Unset → no
152
+ * progressive pass (every change renders at full `definition`).
153
+ */
154
+ dragDefinition?: number;
155
+ /**
156
+ * Parametric-shadow render style (only used when `parametric` is true):
157
+ * - `"vector"` (default) — smooth concave contour outline.
158
+ * - `"pixel"` — the coverage is greedy-meshed into axis-aligned rectangles,
159
+ * giving a blocky/voxel shadow. Holes (courtyards, the coliseum arena)
160
+ * come free as absent cells. `definition` is the pixel-grid resolution
161
+ * (lower → chunkier); the block size is the aesthetic.
162
+ */
163
+ style?: "vector" | "pixel";
164
+ /**
165
+ * Re-emit shadows while a mesh is animating (skeletal/GLB deformation), so
166
+ * the shadow follows the pose instead of freezing at the rest pose. Each
167
+ * `setPolygons` from the animation loop triggers a re-projection, throttled
168
+ * internally (~12fps) so it stays affordable. Strongly recommended only
169
+ * with `parametric: true` (a low-res silhouette is cheap to reproject every
170
+ * few frames; the exact path is not). Default: `false`.
171
+ */
172
+ followAnimation?: boolean;
126
173
  };
127
174
  /**
128
175
  * When `true`, emit `data-poly-shadow-*` attribution attributes on every
@@ -182,6 +229,14 @@ interface PolyMeshTransform {
182
229
  * Defaults to `false`.
183
230
  */
184
231
  receiveShadow?: boolean;
232
+ /**
233
+ * Per-mesh parametric-shadow detail (overrides the scene's
234
+ * `shadow.definition` for THIS mesh's cast/self shadow). Lets a detailed
235
+ * caster stay high-resolution while a simple prop runs cheap in the same
236
+ * scene. Only used when `shadow.parametric` is true. Unset → inherit the
237
+ * scene definition.
238
+ */
239
+ shadowDefinition?: number;
185
240
  }
186
241
  interface PolyMeshHandle {
187
242
  /** The polygons that were loaded after normalization and automatic merge. */