@layoutit/polycss-core 0.2.1 → 0.2.2

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
@@ -1,6 +1,6 @@
1
1
  # PolyCSS
2
2
 
3
- A CSS polygon mesh library. A 3D engine for the DOM. Renders OBJ/MTL, GLB and VOX as real HTML elements transformed with CSS `matrix3d(...)`. Supports colors, textures, lighting, shadows, shapes and animations. Works with React, Vue or plain JavaScript.
3
+ A CSS polygon mesh library. A 3D engine for the DOM. Renders OBJ/MTL, STL, glTF/GLB, and VOX as real HTML elements transformed with CSS `matrix3d(...)`. Supports colors, textures, lighting, shadows, shapes and animations. Works with React, Vue or plain JavaScript.
4
4
 
5
5
  Visit [polycss.com](https://polycss.com) for docs and model examples.
6
6
 
@@ -72,7 +72,6 @@ export default function App() {
72
72
  - `directionalLight` and `ambientLight` control scene lighting.
73
73
  - `textureLighting` chooses `"baked"` or `"dynamic"`.
74
74
  - `textureQuality` controls atlas raster budget.
75
- - Solid seam bleed is automatic on detected shared solid edges.
76
75
  - `strategies` can disable selected render strategies for diagnostics.
77
76
  - `autoCenter` rotates around the rendered mesh bounds instead of world origin.
78
77
 
@@ -83,7 +82,7 @@ export default function App() {
83
82
  - `polygons` accepts pre-parsed geometry.
84
83
  - `position`, `scale`, and `rotation` transform the mesh wrapper.
85
84
  - `autoCenter` shifts the mesh bbox center to local origin.
86
- - `meshResolution` chooses `"lossy"` (default) or `"lossless"` optimization.
85
+ - `meshResolution` chooses `"lossy"` (default) or `"lossless"` optimization. STL imports use the conservative lossless path in both modes.
87
86
  - `castShadow` emits CSS-projected shadows in dynamic lighting mode.
88
87
 
89
88
  ### Controls
@@ -93,6 +92,18 @@ export default function App() {
93
92
  - `<PolyFirstPersonControls>` provides keyboard and pointer-look navigation.
94
93
  - `<PolyTransformControls>` adds translate/rotate gizmos for selected mesh handles.
95
94
 
95
+ ### Snapshot Export
96
+
97
+ The vanilla package exports `exportPolySceneSnapshot(target)`. It clones the current rendered `.polycss-camera` / `.polycss-scene` DOM, injects only the PolyCSS CSS needed by that snapshot, inlines CSS `url(...)` image assets as `data:image/...;base64,...`, strips scripts and inline event handlers, and returns a standalone HTML document string with no PolyCSS runtime import. It works with rendered React/Vue scenes too; import it from `@layoutit/polycss` and pass the rendered camera or scene element.
98
+
99
+ ```ts
100
+ import { exportPolySceneSnapshot } from "@layoutit/polycss";
101
+
102
+ const html = await exportPolySceneSnapshot(scene.host);
103
+ ```
104
+
105
+ If any referenced asset cannot be inlined, the function throws `PolySceneSnapshotError` with `code: "ASSET_INLINE_FAILED"`.
106
+
96
107
  ### Polygon Data Model
97
108
 
98
109
  Each polygon describes one renderable face:
@@ -149,22 +160,14 @@ scene.add(mesh);
149
160
  Supported formats:
150
161
 
151
162
  - OBJ + MTL, including `map_Kd` textures and UV coordinates.
163
+ - STL triangle meshes, including binary Magics face colors. STL has no standard units, textures, UVs, or hierarchy, so imports skip lossy simplification and ray-based interior culling.
152
164
  - glTF / GLB, including embedded images and `TEXCOORD_0`.
153
165
  - MagicaVoxel `.vox`, with direct voxel fast paths when eligible.
154
166
  - Generated primitives: box, plane, ring, sphere, torus, cylinder, cone, and Platonic solids.
155
167
 
156
168
  ## Performance
157
169
 
158
- PolyCSS renders in the DOM, so performance is mostly determined by how many polygons are mounted and how much texture atlas area they consume. The renderer uses several CSS strategies so simple surfaces stay cheap and textured or irregular surfaces fall back to atlas slices.
159
-
160
- - One visible polygon becomes one leaf DOM element.
161
- - Flat rectangles and stable quads use solid CSS leaves.
162
- - Textured polygons are packed into generated texture atlases.
163
- - Dynamic lighting runs through CSS custom properties instead of per-frame JavaScript.
164
- - Voxel-shaped meshes mount only camera-facing leaves when the mesh is eligible.
165
- - `meshResolution: "lossy"` merges compatible polygons, then may spend a small split budget to repair high-risk seams.
166
-
167
- Renderer internals:
170
+ PolyCSS renders through the DOM, so performance is mostly shaped by two things: the number of mounted leaves, and the amount of texture atlas area the browser has to paint. The renderer tries to keep the common cases cheap. Simple surfaces stay as solid CSS elements, while textured, irregular, or high-detail geometry falls back to atlas-backed slices only when needed.
168
171
 
169
172
  Each visible polygon is emitted as one leaf element; the renderer chooses the least expensive CSS primitive that can represent the polygon, then uses `matrix3d(...)` to place that primitive in 3D space.
170
173