@layoutit/polycss 0.2.7 → 0.2.8

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
@@ -21,7 +21,6 @@ npm install @layoutit/polycss-vue
21
21
 
22
22
  ```
23
23
 
24
-
25
24
  You can also load PolyCSS directly from a CDN. Here is a minimal custom-element scene:
26
25
 
27
26
  ```html
@@ -39,7 +38,7 @@ You can also load PolyCSS directly from a CDN. Here is a minimal custom-element
39
38
 
40
39
  ## Framework Components
41
40
 
42
- React and Vue expose the same component model. `<PolyCamera>` owns the viewpoint, `<PolyScene>` owns lighting and atlas options, and `<PolyMesh>` loads or receives polygon data.
41
+ React and Vue expose the same component model. `<PolyCamera>` owns the viewpoint, `<PolyScene>` owns lighting and options, and `<PolyMesh>` loads or receives polygon data.
43
42
 
44
43
  ```tsx
45
44
  import { PolyCamera, PolyScene, PolyOrbitControls, PolyMesh } from "@layoutit/polycss-react";
@@ -56,6 +55,54 @@ export default function App() {
56
55
  }
57
56
  ```
58
57
 
58
+ ## Three.js Parity API
59
+
60
+ When porting Three.js scenes or generating code with an agent, use the explicit
61
+ `*/three` subpaths:
62
+
63
+ - `@layoutit/polycss-core/three`
64
+ - `@layoutit/polycss/three`
65
+ - `@layoutit/polycss-react/three`
66
+ - `@layoutit/polycss-vue/three`
67
+
68
+ They expose Three-like `PerspectiveCamera`, `OrthographicCamera`, `Object3D`,
69
+ `Vector3`, `DirectionalLight`, `PointLight`, `AmbientLight`, radians for object
70
+ rotations, Y-up authoring coordinates, and `camera.position` + `camera.lookAt(...)`
71
+ framing. The adapters convert into native PolyCSS coordinates with a right-handed
72
+ axis map, so the apparent object size, projection, orientation, depth ordering,
73
+ and light direction line up with Three.js scene math while still rendering
74
+ through the DOM.
75
+
76
+ ```tsx
77
+ import { PolyScene } from "@layoutit/polycss-react";
78
+ import {
79
+ DirectionalLight,
80
+ PolyThreeMesh,
81
+ PolyThreePerspectiveCamera,
82
+ } from "@layoutit/polycss-react/three";
83
+
84
+ const sun = new DirectionalLight("#ffffff", 1);
85
+ sun.position.set(3, 5, 4);
86
+ sun.target.position.set(0, 0, 0);
87
+
88
+ export function App() {
89
+ return (
90
+ <PolyThreePerspectiveCamera
91
+ fov={50}
92
+ aspect={16 / 9}
93
+ position={[3, 2, 5]}
94
+ lookAt={[0, 0, 0]}
95
+ >
96
+ <PolyScene directionalLight={sun.toPolyDirectionalLight()}>
97
+ <PolyThreeMesh src="/models/cube.glb" rotation={[0, Math.PI / 4, 0]} />
98
+ </PolyScene>
99
+ </PolyThreePerspectiveCamera>
100
+ );
101
+ }
102
+ ```
103
+
104
+ Full reference: [polycss.com/api/three-parity](https://polycss.com/api/three-parity).
105
+
59
106
  ## API Reference
60
107
 
61
108
  ### PolyCamera
@@ -187,10 +234,11 @@ Each visible polygon is emitted as one leaf element; the renderer chooses the le
187
234
 
188
235
  ## Made with PolyCSS
189
236
 
190
- [Layoutit Voxels](https://voxels.layoutit.com)
191
- -> A CSS Voxel editor
237
+ [cssQuake](https://cssquake.com)
238
+ -> A CSS port of Quake (1996)
239
+
240
+ <img width="1280" height="720" alt="quake" src="https://github.com/user-attachments/assets/6d9d809c-857a-4a39-b5cf-733ead2661ec" />
192
241
 
193
- <img width="1000" height="600" alt="layoutit-voxels" src="https://polycss.com/layoutit-voxels.png" />
194
242
 
195
243
  [Layoutit Terra](https://terra.layoutit.com)
196
244
  -> A CSS Terrain Generator
@@ -0,0 +1,371 @@
1
+ import { P as PolySceneHandle, a as PolyMeshHandle, f as PolyPerspectiveCameraHandle, d as PolyOrthographicCameraHandle } from './types-CfRKEj2z.cjs';
2
+ import { Vec3, Polygon } from '@layoutit/polycss-core';
3
+
4
+ /**
5
+ * Shared types, constants, and utilities for orbit/map controls factories.
6
+ * Not part of the public API surface — use createPolyOrbitControls or
7
+ * createPolyMapControls.
8
+ */
9
+
10
+ interface PolyControlsAnimateOptions {
11
+ /**
12
+ * Rotation rate in degrees per 60 Hz-equivalent frame. The tick is
13
+ * dt-clamped so 0.3 deg/frame ≈ 18 deg/sec on every refresh rate.
14
+ * Default: 0.3.
15
+ */
16
+ speed?: number;
17
+ /** Rotation axis. Default: "y" (yaw, rotates around vertical world Z). */
18
+ axis?: "x" | "y";
19
+ /** Halt the loop while a pointer drag is in progress. Default: true. */
20
+ pauseOnInteraction?: boolean;
21
+ }
22
+ interface PolyControlsBaseOptions {
23
+ /** Pointer-drag. Default: true. */
24
+ drag?: boolean;
25
+ /** Wheel / pinch zoom. Default: true. */
26
+ wheel?: boolean;
27
+ /**
28
+ * When `true`, wheel events change `distance` (camera pull-back in CSS px)
29
+ * instead of `zoom`. Mirrors Three.js OrbitControls dolly behaviour.
30
+ * Default: false (zoom mode).
31
+ */
32
+ dolly?: boolean;
33
+ /**
34
+ * Drag-direction inversion. `false` = natural, `true` = invert (×-1),
35
+ * a number multiplies sensitivity (negative inverts). Default: false.
36
+ */
37
+ invert?: boolean | number;
38
+ /** Minimum CSS zoom. Default: 0.1. */
39
+ minZoom?: number;
40
+ /** Maximum CSS zoom. Default: 10. */
41
+ maxZoom?: number;
42
+ /** Minimum dolly distance in CSS pixels. Default: 0. Only used when `dolly: true`. */
43
+ minDistance?: number;
44
+ /** Maximum dolly distance in CSS pixels. Default: Infinity. Only used when `dolly: true`. */
45
+ maxDistance?: number;
46
+ /** Auto-rotate. Pass false (or omit) to disable. */
47
+ animate?: false | PolyControlsAnimateOptions;
48
+ }
49
+ interface PolyControlsCamera {
50
+ rotX: number;
51
+ rotY: number;
52
+ zoom: number;
53
+ target: Vec3;
54
+ distance: number;
55
+ }
56
+ interface PolyControlsChangeEvent {
57
+ type: "change";
58
+ camera: PolyControlsCamera;
59
+ }
60
+ interface PolyControlsInteractionEvent {
61
+ type: "start" | "end";
62
+ camera: PolyControlsCamera;
63
+ }
64
+ type PolyControlsEvent = PolyControlsChangeEvent | PolyControlsInteractionEvent;
65
+ type PolyControlsListener<E extends PolyControlsEvent = PolyControlsEvent> = (event: E) => void;
66
+ interface PolyControlsHandle {
67
+ update(partial: PolyControlsBaseOptions): void;
68
+ resume(): void;
69
+ pause(): void;
70
+ destroy(): void;
71
+ addEventListener<T extends PolyControlsEvent["type"]>(type: T, listener: PolyControlsListener<Extract<PolyControlsEvent, {
72
+ type: T;
73
+ }>>): void;
74
+ removeEventListener<T extends PolyControlsEvent["type"]>(type: T, listener: PolyControlsListener<Extract<PolyControlsEvent, {
75
+ type: T;
76
+ }>>): void;
77
+ hasEventListener<T extends PolyControlsEvent["type"]>(type: T, listener: PolyControlsListener<Extract<PolyControlsEvent, {
78
+ type: T;
79
+ }>>): boolean;
80
+ }
81
+
82
+ /**
83
+ * createPolyOrbitControls — orbit-mode camera input for a PolyScene.
84
+ *
85
+ * Left-drag rotates rotX / rotY around the target (orbit). Wheel zooms or
86
+ * dollies. Mirrors Three.js OrbitControls semantics.
87
+ *
88
+ * For map/pan semantics (left-drag pans, right-drag orbits) use
89
+ * `createPolyMapControls` instead.
90
+ */
91
+
92
+ type PolyOrbitControlsOptions = PolyControlsBaseOptions;
93
+ type PolyOrbitControlsHandle = PolyControlsHandle;
94
+ declare function createPolyOrbitControls(scene: PolySceneHandle, options?: PolyOrbitControlsOptions): PolyOrbitControlsHandle;
95
+
96
+ declare const ELEMENT_BASE$b: typeof HTMLElement;
97
+ declare class PolySceneElement extends ELEMENT_BASE$b {
98
+ static get observedAttributes(): string[];
99
+ private _scene;
100
+ private _implicitCamera;
101
+ /**
102
+ * Returns the underlying PolySceneHandle. Children call this during their own
103
+ * connectedCallback to register meshes.
104
+ */
105
+ getScene(): PolySceneHandle | null;
106
+ private _findAncestorCamera;
107
+ private _buildImplicitCamera;
108
+ private _readNonCameraOptions;
109
+ private _readDirectionalLight;
110
+ private _readAmbientLight;
111
+ connectedCallback(): void;
112
+ disconnectedCallback(): void;
113
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
114
+ }
115
+
116
+ declare const ELEMENT_BASE$a: typeof HTMLElement;
117
+ declare class PolyMeshElement extends ELEMENT_BASE$a {
118
+ static get observedAttributes(): string[];
119
+ private _handle;
120
+ private _parseResult;
121
+ private _loadToken;
122
+ /** Returns the current mesh handle, or null if not yet loaded. */
123
+ getMeshHandle(): PolyMeshHandle | null;
124
+ connectedCallback(): void;
125
+ disconnectedCallback(): void;
126
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
127
+ private _tearDown;
128
+ private _maybeLoad;
129
+ }
130
+
131
+ declare const ELEMENT_BASE$9: typeof HTMLElement;
132
+ declare class PolyIframeElement extends ELEMENT_BASE$9 {
133
+ static get observedAttributes(): string[];
134
+ private _wrapper;
135
+ private _iframe;
136
+ /** The iframe element this <poly-iframe> mounted, or null when detached. */
137
+ getIframeElement(): HTMLIFrameElement | null;
138
+ connectedCallback(): void;
139
+ disconnectedCallback(): void;
140
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
141
+ private _mount;
142
+ private _applyGeometry;
143
+ private _teardown;
144
+ }
145
+
146
+ declare const ELEMENT_BASE$8: typeof HTMLElement;
147
+ declare class PolyPolygonElement extends ELEMENT_BASE$8 {
148
+ static get observedAttributes(): string[];
149
+ private _handle;
150
+ connectedCallback(): void;
151
+ disconnectedCallback(): void;
152
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
153
+ private _tearDown;
154
+ private _mount;
155
+ }
156
+
157
+ declare const ELEMENT_BASE$7: typeof HTMLElement;
158
+ declare class PolyOrbitControlsElement extends ELEMENT_BASE$7 {
159
+ static get observedAttributes(): string[];
160
+ private _controls;
161
+ /** Returns the wrapped PolyOrbitControlsHandle once the element has
162
+ * connected to its `<poly-scene>` ancestor. Lets external callers attach
163
+ * `change` listeners (or call `update()` / `pause()`) the same way they
164
+ * would on a vanilla `createPolyOrbitControls(scene, ...)` handle. */
165
+ getControls(): PolyOrbitControlsHandle | null;
166
+ private _readAnimate;
167
+ private _readOptions;
168
+ private _findScene;
169
+ private _attach;
170
+ connectedCallback(): void;
171
+ disconnectedCallback(): void;
172
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
173
+ }
174
+
175
+ declare const ELEMENT_BASE$6: typeof HTMLElement;
176
+ declare class PolyMapControlsElement extends ELEMENT_BASE$6 {
177
+ static get observedAttributes(): string[];
178
+ private _controls;
179
+ private _readAnimate;
180
+ private _readOptions;
181
+ private _findScene;
182
+ private _attach;
183
+ connectedCallback(): void;
184
+ disconnectedCallback(): void;
185
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
186
+ }
187
+
188
+ declare const ELEMENT_BASE$5: typeof HTMLElement;
189
+ declare class PolyFirstPersonControlsElement extends ELEMENT_BASE$5 {
190
+ static get observedAttributes(): string[];
191
+ private _controls;
192
+ private _readOptions;
193
+ private _findScene;
194
+ private _attach;
195
+ connectedCallback(): void;
196
+ disconnectedCallback(): void;
197
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
198
+ }
199
+
200
+ /**
201
+ * <poly-perspective-camera> — standalone perspective camera element.
202
+ *
203
+ * Wraps `createPolyPerspectiveCamera`. Unlike <poly-scene> which owns the
204
+ * scene DOM, this element provides a camera context that child controls can
205
+ * read. It creates a `<div class="polycss-camera">` wrapper with the
206
+ * CSS `perspective` property set.
207
+ *
208
+ * Attributes (all optional):
209
+ * perspective — number, CSS perspective in pixels (default 32000)
210
+ * zoom — number
211
+ * rot-x — number, degrees (default 65)
212
+ * rot-y — number, degrees (default 45)
213
+ * target — "x,y,z" comma-separated world coordinates
214
+ * distance — number, camera pull-back in CSS pixels
215
+ */
216
+
217
+ declare const ELEMENT_BASE$4: typeof HTMLElement;
218
+ declare class PolyPerspectiveCameraElement extends ELEMENT_BASE$4 {
219
+ static get observedAttributes(): string[];
220
+ private _camera;
221
+ private _wrapper;
222
+ /** Returns the camera handle, or null if not yet connected. */
223
+ getCamera(): PolyPerspectiveCameraHandle | null;
224
+ private _readOptions;
225
+ private _mount;
226
+ private _teardown;
227
+ connectedCallback(): void;
228
+ disconnectedCallback(): void;
229
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
230
+ }
231
+
232
+ /**
233
+ * <poly-orthographic-camera> — standalone orthographic camera element.
234
+ *
235
+ * Wraps `createPolyOrthographicCamera`. Sets CSS `perspective: none` on the
236
+ * camera wrapper, disabling perspective projection.
237
+ *
238
+ * Attributes (all optional):
239
+ * zoom — number
240
+ * rot-x — number, degrees (default 65)
241
+ * rot-y — number, degrees (default 45)
242
+ * target — "x,y,z" comma-separated world coordinates
243
+ * distance — number, camera pull-back in CSS pixels
244
+ */
245
+
246
+ declare const ELEMENT_BASE$3: typeof HTMLElement;
247
+ declare class PolyOrthographicCameraElement extends ELEMENT_BASE$3 {
248
+ static get observedAttributes(): string[];
249
+ private _camera;
250
+ private _wrapper;
251
+ /** Returns the camera handle, or null if not yet connected. */
252
+ getCamera(): PolyOrthographicCameraHandle | null;
253
+ private _readOptions;
254
+ private _mount;
255
+ private _teardown;
256
+ connectedCallback(): void;
257
+ disconnectedCallback(): void;
258
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
259
+ }
260
+
261
+ /**
262
+ * <poly-camera> — ergonomic alias for <poly-orthographic-camera>.
263
+ *
264
+ * The default camera in PolyCSS is orthographic. `<poly-camera>` maps to
265
+ * `PolyOrthographicCameraElement` so the canonical tree shape works without
266
+ * spelling out "orthographic" when it isn't relevant to the scene being built.
267
+ *
268
+ * Use <poly-perspective-camera> when depth foreshortening is needed.
269
+ */
270
+
271
+ declare class PolyCameraElement extends PolyOrthographicCameraElement {
272
+ }
273
+
274
+ declare const ELEMENT_BASE$2: typeof HTMLElement;
275
+ declare class PolyTransformControlsElement extends ELEMENT_BASE$2 {
276
+ static get observedAttributes(): string[];
277
+ private _tc;
278
+ private _findScene;
279
+ private _findTargetMesh;
280
+ private _readOptions;
281
+ private _attach;
282
+ connectedCallback(): void;
283
+ disconnectedCallback(): void;
284
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
285
+ }
286
+
287
+ declare const ELEMENT_BASE$1: typeof HTMLElement;
288
+ declare class PolySelectElement extends ELEMENT_BASE$1 {
289
+ static get observedAttributes(): string[];
290
+ private _selection;
291
+ private _findScene;
292
+ private _readOptions;
293
+ private _attach;
294
+ connectedCallback(): void;
295
+ disconnectedCallback(): void;
296
+ attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void;
297
+ }
298
+
299
+ /**
300
+ * Primitive shape custom elements — <poly-box>, <poly-plane>, <poly-ring>,
301
+ * <poly-octahedron>, <poly-tetrahedron>, <poly-icosahedron>, <poly-dodecahedron>,
302
+ * <poly-cylinder>, <poly-cone>, <poly-torus>.
303
+ *
304
+ * Each element reads shape-specific attributes, calls the matching polygon
305
+ * generator from @layoutit/polycss-core, then registers the result with the
306
+ * nearest <poly-scene> ancestor using the same mechanism as <poly-mesh>.
307
+ *
308
+ * Attribute naming follows kebab-case conventions: `radial-segments`,
309
+ * `tubular-segments`, `radius-top`, `half-thickness`, etc.
310
+ */
311
+
312
+ declare const ELEMENT_BASE: typeof HTMLElement;
313
+ /**
314
+ * Base class for all primitive shape elements. Subclasses implement
315
+ * `buildPolygons()` which returns a Polygon[] from this element's attributes.
316
+ */
317
+ declare abstract class PolyShapeElement extends ELEMENT_BASE {
318
+ private _handle;
319
+ abstract buildPolygons(): Polygon[];
320
+ connectedCallback(): void;
321
+ disconnectedCallback(): void;
322
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
323
+ private _tearDown;
324
+ private _mount;
325
+ }
326
+ declare class PolyBoxElement extends PolyShapeElement {
327
+ static get observedAttributes(): string[];
328
+ buildPolygons(): Polygon[];
329
+ }
330
+ declare class PolyPlaneElement extends PolyShapeElement {
331
+ static get observedAttributes(): string[];
332
+ buildPolygons(): Polygon[];
333
+ }
334
+ declare class PolyRingElement extends PolyShapeElement {
335
+ static get observedAttributes(): string[];
336
+ buildPolygons(): Polygon[];
337
+ }
338
+ declare class PolyOctahedronElement extends PolyShapeElement {
339
+ static get observedAttributes(): string[];
340
+ buildPolygons(): Polygon[];
341
+ }
342
+ declare class PolyTetrahedronElement extends PolyShapeElement {
343
+ static get observedAttributes(): string[];
344
+ buildPolygons(): Polygon[];
345
+ }
346
+ declare class PolyIcosahedronElement extends PolyShapeElement {
347
+ static get observedAttributes(): string[];
348
+ buildPolygons(): Polygon[];
349
+ }
350
+ declare class PolyDodecahedronElement extends PolyShapeElement {
351
+ static get observedAttributes(): string[];
352
+ buildPolygons(): Polygon[];
353
+ }
354
+ declare class PolySphereElement extends PolyShapeElement {
355
+ static get observedAttributes(): string[];
356
+ buildPolygons(): Polygon[];
357
+ }
358
+ declare class PolyCylinderElement extends PolyShapeElement {
359
+ static get observedAttributes(): string[];
360
+ buildPolygons(): Polygon[];
361
+ }
362
+ declare class PolyConeElement extends PolyShapeElement {
363
+ static get observedAttributes(): string[];
364
+ buildPolygons(): Polygon[];
365
+ }
366
+ declare class PolyTorusElement extends PolyShapeElement {
367
+ static get observedAttributes(): string[];
368
+ buildPolygons(): Polygon[];
369
+ }
370
+
371
+ export { PolySceneElement as A, PolySelectElement as B, PolySphereElement as C, PolyTetrahedronElement as D, PolyTorusElement as E, PolyTransformControlsElement as F, createPolyOrbitControls as G, type PolyControlsHandle as P, type PolyControlsBaseOptions as a, type PolyControlsEvent as b, type PolyControlsListener as c, PolyBoxElement as d, PolyCameraElement as e, PolyConeElement as f, type PolyControlsAnimateOptions as g, type PolyControlsCamera as h, type PolyControlsChangeEvent as i, type PolyControlsInteractionEvent as j, PolyCylinderElement as k, PolyDodecahedronElement as l, PolyFirstPersonControlsElement as m, PolyIcosahedronElement as n, PolyIframeElement as o, PolyMapControlsElement as p, PolyMeshElement as q, PolyOctahedronElement as r, PolyOrbitControlsElement as s, type PolyOrbitControlsHandle as t, type PolyOrbitControlsOptions as u, PolyOrthographicCameraElement as v, PolyPerspectiveCameraElement as w, PolyPlaneElement as x, PolyPolygonElement as y, PolyRingElement as z };