@layoutit/polycss 0.2.0 → 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 +151 -149
- package/dist/PolyShapeElements-BNHvErQF.d.cts +654 -0
- package/dist/PolyShapeElements-BNHvErQF.d.ts +654 -0
- package/dist/elements.cjs +180 -49
- package/dist/elements.d.cts +1 -1
- package/dist/elements.d.ts +1 -1
- package/dist/elements.js +180 -49
- package/dist/index.cjs +461 -50
- package/dist/index.d.cts +144 -83
- package/dist/index.d.ts +144 -83
- package/dist/index.js +461 -50
- package/package.json +3 -3
- package/dist/PolySelectElement-Tvsmhx2m.d.cts +0 -419
- package/dist/PolySelectElement-Tvsmhx2m.d.ts +0 -419
package/dist/index.d.cts
CHANGED
|
@@ -1,99 +1,106 @@
|
|
|
1
|
-
import { P as
|
|
2
|
-
export {
|
|
3
|
-
import
|
|
1
|
+
import { P as PolySceneOptions, a as PolySceneHandle, b as PolyControlsHandle, c as PolyControlsBaseOptions, d as PolyControlsEvent, e as PolyControlsListener, f as PolyMeshHandle } from './PolyShapeElements-BNHvErQF.cjs';
|
|
2
|
+
export { g as PolyBoxElement, h as PolyCameraElement, i as PolyCameraOptions, j as PolyConeElement, k as PolyControlsAnimateOptions, l as PolyControlsCamera, m as PolyControlsChangeEvent, n as PolyControlsInteractionEvent, o as PolyCylinderElement, p as PolyDodecahedronElement, q as PolyFirstPersonControlsElement, r as PolyIcosahedronElement, s as PolyIframeElement, t as PolyMapControlsElement, u as PolyMeshElement, v as PolyMeshTransform, w as PolyOctahedronElement, x as PolyOrbitControlsElement, y as PolyOrbitControlsHandle, z as PolyOrbitControlsOptions, A as PolyOrthographicCameraElement, B as PolyOrthographicCameraHandle, C as PolyOrthographicCameraOptions, D as PolyPerspectiveCameraElement, E as PolyPerspectiveCameraHandle, F as PolyPerspectiveCameraOptions, G as PolyPlaneElement, H as PolyPolygonElement, I as PolyRingElement, J as PolySceneElement, K as PolySelectElement, L as PolySphereElement, M as PolyTetrahedronElement, N as PolyTorusElement, O as PolyTransformControlsElement, Q as createPolyCamera, R as createPolyOrbitControls, S as createPolyOrthographicCamera, T as createPolyPerspectiveCamera } from './PolyShapeElements-BNHvErQF.cjs';
|
|
3
|
+
import * as _layoutit_polycss_core from '@layoutit/polycss-core';
|
|
4
|
+
import { PolyDirectionalLight, PolyAmbientLight, PolyTextureLightingMode, TextureAtlasPlan, TextureQuality, PackedAtlas, PackedPage, TextureAtlasPage, PolyRenderStrategy, SolidPaintDefaults, Polygon, SolidTriangleFrame, Vec3, BoxPolygonsOptions, ParseResult, ConePolygonsOptions, CylinderPolygonsOptions, DodecahedronPolygonsOptions, IcosahedronPolygonsOptions, OctahedronPolygonsOptions, PlanePolygonsOptions, RingPolygonsOptions, SpherePolygonsOptions, TetrahedronPolygonsOptions, TorusPolygonsOptions } from '@layoutit/polycss-core';
|
|
4
5
|
export * from '@layoutit/polycss-core';
|
|
6
|
+
export { ComputeTextureAtlasPlanOptions, PackedAtlas, PackedPage, PackedTextureAtlasEntry, PolyRenderStrategiesOption, PolyRenderStrategy, ParseResult as PolyShapeResult, SolidPaintDefaults, SolidTriangleFrame, TextureAtlasPage, TextureAtlasPlan, TextureQuality, buildTextureEdgeRepairSets, computeTextureAtlasPlanPublic, cssBorderShapeForPlan, formatBorderShapeEntryMatrix, formatCssLengthPx, formatMatrix3d, formatSolidQuadEntryMatrix, isFullRectSolid, isProjectiveQuadPlan, isSolidTrianglePlan } from '@layoutit/polycss-core';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Rotation rate in degrees per 60 Hz-equivalent frame. The tick is
|
|
15
|
-
* dt-clamped so 0.3 deg/frame ≈ 18 deg/sec on every refresh rate.
|
|
16
|
-
* Default: 0.3.
|
|
17
|
-
*/
|
|
18
|
-
speed?: number;
|
|
19
|
-
/** Rotation axis. Default: "y" (yaw, rotates around vertical world Z). */
|
|
20
|
-
axis?: "x" | "y";
|
|
21
|
-
/** Halt the loop while a pointer drag is in progress. Default: true. */
|
|
22
|
-
pauseOnInteraction?: boolean;
|
|
23
|
-
}
|
|
24
|
-
interface PolyControlsBaseOptions {
|
|
25
|
-
/** Pointer-drag. Default: true. */
|
|
26
|
-
drag?: boolean;
|
|
27
|
-
/** Wheel / pinch zoom. Default: true. */
|
|
28
|
-
wheel?: boolean;
|
|
8
|
+
interface RenderTextureAtlasOptions {
|
|
9
|
+
doc?: Document;
|
|
10
|
+
tileSize?: number;
|
|
11
|
+
layerElevation?: number;
|
|
12
|
+
directionalLight?: PolyDirectionalLight;
|
|
13
|
+
ambientLight?: PolyAmbientLight;
|
|
14
|
+
textureLighting?: PolyTextureLightingMode;
|
|
29
15
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
16
|
+
* Atlas bitmap budget and CSS sprite size. Numeric values are clamped to
|
|
17
|
+
* 0.1..1 and keep the 64px sprite. Omitted / `"auto"` picks a raster scale
|
|
18
|
+
* from packed atlas area, caps oversized runtime bitmaps by side length and
|
|
19
|
+
* decoded-memory budget, and uses a 128px sprite on desktop-class documents
|
|
20
|
+
* or a 64px sprite on mobile-class documents.
|
|
33
21
|
*/
|
|
34
|
-
|
|
22
|
+
textureQuality?: _layoutit_polycss_core.TextureQuality;
|
|
23
|
+
solidPaintDefaults?: _layoutit_polycss_core.SolidPaintDefaults;
|
|
24
|
+
strategies?: _layoutit_polycss_core.PolyRenderStrategiesOption;
|
|
35
25
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
26
|
+
* Indices of polygons that the directional light cannot reach (precomputed
|
|
27
|
+
* by createPolyScene via {@link computeLightVisibility}). Atlas + solid
|
|
28
|
+
* planning forces directScale to 0 for these polys so they render with
|
|
29
|
+
* ambient-only color, matching what a shadow-map pass would output.
|
|
38
30
|
*/
|
|
39
|
-
|
|
40
|
-
/** Minimum CSS zoom. Default: 0.1. */
|
|
41
|
-
minZoom?: number;
|
|
42
|
-
/** Maximum CSS zoom. Default: 10. */
|
|
43
|
-
maxZoom?: number;
|
|
44
|
-
/** Minimum dolly distance in CSS pixels. Default: 0. Only used when `dolly: true`. */
|
|
45
|
-
minDistance?: number;
|
|
46
|
-
/** Maximum dolly distance in CSS pixels. Default: Infinity. Only used when `dolly: true`. */
|
|
47
|
-
maxDistance?: number;
|
|
48
|
-
/** Auto-rotate. Pass false (or omit) to disable. */
|
|
49
|
-
animate?: false | PolyControlsAnimateOptions;
|
|
31
|
+
lightOccludedPolyIndices?: ReadonlySet<number>;
|
|
50
32
|
}
|
|
51
|
-
interface
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
33
|
+
interface RenderedPoly {
|
|
34
|
+
polygonIndex: number;
|
|
35
|
+
element: HTMLElement;
|
|
36
|
+
kind?: "atlas" | "solid" | "border" | "corner" | "triangle";
|
|
37
|
+
plan?: _layoutit_polycss_core.TextureAtlasPlan;
|
|
38
|
+
dispose(): void;
|
|
57
39
|
}
|
|
58
|
-
interface
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
interface RenderTextureAtlasResult {
|
|
41
|
+
rendered: RenderedPoly[];
|
|
42
|
+
dispose(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Resolves once every textured `<s>` leaf has its `background-image`
|
|
45
|
+
* applied (i.e. the atlas canvas → Blob → URL chain has completed and
|
|
46
|
+
* the apply-bg pass has run). For meshes with no textured leaves this
|
|
47
|
+
* resolves immediately. Callers doing stale-while-revalidate swaps
|
|
48
|
+
* await this before disposing the previous render — without it, the
|
|
49
|
+
* fresh leaves mount with empty backgrounds and the prior frame's
|
|
50
|
+
* bitmaps would be needed underneath to avoid a transparent flash.
|
|
51
|
+
*/
|
|
52
|
+
pagesReady?: Promise<void>;
|
|
61
53
|
}
|
|
62
|
-
interface
|
|
63
|
-
|
|
64
|
-
camera: PolyControlsCamera;
|
|
65
|
-
}
|
|
66
|
-
type PolyControlsEvent = PolyControlsChangeEvent | PolyControlsInteractionEvent;
|
|
67
|
-
type PolyControlsListener<E extends PolyControlsEvent = PolyControlsEvent> = (event: E) => void;
|
|
68
|
-
interface PolyControlsHandle {
|
|
69
|
-
update(partial: PolyControlsBaseOptions): void;
|
|
70
|
-
resume(): void;
|
|
71
|
-
pause(): void;
|
|
72
|
-
destroy(): void;
|
|
73
|
-
addEventListener<T extends PolyControlsEvent["type"]>(type: T, listener: PolyControlsListener<Extract<PolyControlsEvent, {
|
|
74
|
-
type: T;
|
|
75
|
-
}>>): void;
|
|
76
|
-
removeEventListener<T extends PolyControlsEvent["type"]>(type: T, listener: PolyControlsListener<Extract<PolyControlsEvent, {
|
|
77
|
-
type: T;
|
|
78
|
-
}>>): void;
|
|
79
|
-
hasEventListener<T extends PolyControlsEvent["type"]>(type: T, listener: PolyControlsListener<Extract<PolyControlsEvent, {
|
|
80
|
-
type: T;
|
|
81
|
-
}>>): boolean;
|
|
54
|
+
interface RenderTextureAtlasAsyncResult extends RenderTextureAtlasResult {
|
|
55
|
+
solidPaintDefaults: _layoutit_polycss_core.SolidPaintDefaults;
|
|
82
56
|
}
|
|
83
57
|
|
|
58
|
+
declare function packTextureAtlasPlansWithScale(plans: Array<TextureAtlasPlan | null>, textureQualityInput: TextureQuality | undefined, doc: Document | null | undefined): {
|
|
59
|
+
packed: PackedAtlas;
|
|
60
|
+
atlasScale: number;
|
|
61
|
+
atlasCanonicalSize: number;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
declare function buildAtlasPages(pages: PackedPage[], textureLighting: PolyTextureLightingMode, doc: Document, atlasScale: number, isCancelled: () => boolean): Promise<TextureAtlasPage[]>;
|
|
65
|
+
|
|
84
66
|
/**
|
|
85
|
-
*
|
|
67
|
+
* Compute the dominant paint defaults from an already-computed array of plans.
|
|
86
68
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
|
|
69
|
+
* React and Vue compute plans first (to drive the atlas packing), then pass
|
|
70
|
+
* the plan array here so they don't need access to the raw polygon list.
|
|
71
|
+
* Requires access to a Document to check browser support for solid-triangle
|
|
72
|
+
* and border-shape strategies.
|
|
73
|
+
*/
|
|
74
|
+
declare function getSolidPaintDefaultsFromPlans(plans: Array<TextureAtlasPlan | null>, textureLighting: PolyTextureLightingMode, disabled?: ReadonlySet<PolyRenderStrategy>, doc?: Document | null): SolidPaintDefaults;
|
|
75
|
+
/**
|
|
76
|
+
* Returns true when the browser supports the `border-shape` CSS property and
|
|
77
|
+
* the pointer/hover media queries indicate a fine-pointer device (desktop-class).
|
|
78
|
+
* Falls back to a globalThis-based check when no Document is available.
|
|
79
|
+
*/
|
|
80
|
+
declare function isBorderShapeSupported(doc?: Document | null): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Returns true when the browser renders CSS border-trick triangles correctly.
|
|
83
|
+
* WebKit/Safari renders them incorrectly when transformed — this check gates
|
|
84
|
+
* the `<u>` strategy path.
|
|
85
|
+
*/
|
|
86
|
+
declare function isSolidTriangleSupported(doc?: Document | null): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Filter a plan array to the subset that needs atlas packing, given the active
|
|
89
|
+
* render strategies and texture-lighting mode. Plans excluded from the atlas
|
|
90
|
+
* will be rendered via `<b>`, `<i>`, or `<u>` by the framework components.
|
|
92
91
|
*/
|
|
92
|
+
declare function filterAtlasPlans(plans: Array<TextureAtlasPlan | null>, textureLighting: PolyTextureLightingMode, disabled: ReadonlySet<PolyRenderStrategy>, doc?: Document | null): Array<TextureAtlasPlan | null>;
|
|
93
|
+
|
|
94
|
+
declare function getSolidPaintDefaults(polygons: Polygon[], options?: RenderTextureAtlasOptions): SolidPaintDefaults;
|
|
95
|
+
declare function renderPolygonsWithTextureAtlas(polygons: Polygon[], options?: RenderTextureAtlasOptions): RenderTextureAtlasResult;
|
|
96
|
+
declare function renderPolygonsWithTextureAtlasAsync(polygons: Polygon[], options?: RenderTextureAtlasOptions, shouldCancel?: () => boolean): Promise<RenderTextureAtlasAsyncResult>;
|
|
97
|
+
declare function updateStableTriangleFrame(rendered: RenderedPoly[], polygons: Polygon[], frame: SolidTriangleFrame, options?: RenderTextureAtlasOptions): boolean;
|
|
98
|
+
declare function updatePolygonsWithStableTopology(rendered: RenderedPoly[], polygons: Polygon[], options?: RenderTextureAtlasOptions): boolean;
|
|
99
|
+
|
|
100
|
+
declare function renderPolygonsWithStableTriangles(polygons: Polygon[], options?: RenderTextureAtlasOptions): RenderTextureAtlasResult | null;
|
|
101
|
+
declare function updatePolygonsWithStableTriangles(rendered: RenderedPoly[], polygons: Polygon[], options?: RenderTextureAtlasOptions): RenderTextureAtlasResult | null;
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
type PolyOrbitControlsHandle = PolyControlsHandle;
|
|
96
|
-
declare function createPolyOrbitControls(scene: PolySceneHandle, options?: PolyOrbitControlsOptions): PolyOrbitControlsHandle;
|
|
103
|
+
declare function createPolyScene(host: HTMLElement, options: PolySceneOptions): PolySceneHandle;
|
|
97
104
|
|
|
98
105
|
/**
|
|
99
106
|
* createPolyMapControls — map/pan-mode camera input for a PolyScene.
|
|
@@ -191,7 +198,7 @@ interface PolyFirstPersonControlsHandle {
|
|
|
191
198
|
declare function createPolyFirstPersonControls(scene: PolySceneHandle, options?: PolyFirstPersonControlsOptions): PolyFirstPersonControlsHandle;
|
|
192
199
|
|
|
193
200
|
/**
|
|
194
|
-
* createSelect — additive selection layer for vanilla
|
|
201
|
+
* createSelect — additive selection layer for vanilla PolyCSS scenes.
|
|
195
202
|
* Mirrors the React `<Select>` API: tracks one or more selected
|
|
196
203
|
* meshes, fires `onChange` whenever the set changes, supports
|
|
197
204
|
* single-click toggle (re-clicking the selected mesh deselects it),
|
|
@@ -295,6 +302,60 @@ interface PolyTransformControlsHandle {
|
|
|
295
302
|
}
|
|
296
303
|
declare function createTransformControls(scene: PolySceneHandle, options?: PolyTransformControlsOptions): PolyTransformControlsHandle;
|
|
297
304
|
|
|
305
|
+
interface PolyRenderSurfaceLeafCounts {
|
|
306
|
+
quad: number;
|
|
307
|
+
clippedSolid: number;
|
|
308
|
+
atlas: number;
|
|
309
|
+
stableTriangle: number;
|
|
310
|
+
}
|
|
311
|
+
interface PolyRenderStats {
|
|
312
|
+
polygonCount: number;
|
|
313
|
+
mountedPolygonLeafCount: number;
|
|
314
|
+
shadowLeafCount: number;
|
|
315
|
+
surfaceLeafCounts: PolyRenderSurfaceLeafCounts;
|
|
316
|
+
bucketCount: number;
|
|
317
|
+
}
|
|
318
|
+
interface PolyRenderStatsOptions {
|
|
319
|
+
polygonCount?: number;
|
|
320
|
+
/**
|
|
321
|
+
* Optional subtree selector for diagnostics that only want model leaves and
|
|
322
|
+
* not helpers/floors/gizmos sharing the same scene root.
|
|
323
|
+
*/
|
|
324
|
+
scopeSelector?: string;
|
|
325
|
+
}
|
|
326
|
+
declare function collectPolyRenderStats(root: ParentNode | null | undefined, optionsOrPolygonCount?: number | PolyRenderStatsOptions): PolyRenderStats;
|
|
327
|
+
|
|
328
|
+
type PolySceneSnapshotErrorCode = "INVALID_TARGET" | "SCENE_NOT_FOUND" | "ASSET_INLINE_FAILED";
|
|
329
|
+
declare class PolySceneSnapshotError extends Error {
|
|
330
|
+
readonly code: PolySceneSnapshotErrorCode;
|
|
331
|
+
readonly url?: string;
|
|
332
|
+
constructor(code: PolySceneSnapshotErrorCode, message: string, url?: string);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Serialize the current rendered PolyCSS DOM into a standalone HTML document.
|
|
336
|
+
* The snapshot is intentionally static: it preserves the scene's current DOM,
|
|
337
|
+
* inlines CSS image assets, and emits no scripts or PolyCSS runtime imports.
|
|
338
|
+
*/
|
|
339
|
+
declare function exportPolySceneSnapshot(target: Element): Promise<string>;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Primitive shape factories — thin wrappers over the polygon generators in
|
|
343
|
+
* @layoutit/polycss-core. Each returns a `ParseResult`-compatible object so
|
|
344
|
+
* it composes directly with `scene.add(createPolyBox({ size: 100 }))`.
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
declare function createPolyBox(options?: BoxPolygonsOptions): ParseResult;
|
|
348
|
+
declare function createPolyPlane(options: PlanePolygonsOptions): ParseResult;
|
|
349
|
+
declare function createPolyRing(options: RingPolygonsOptions): ParseResult;
|
|
350
|
+
declare function createPolyOctahedron(options: OctahedronPolygonsOptions): ParseResult;
|
|
351
|
+
declare function createPolySphere(options?: SpherePolygonsOptions): ParseResult;
|
|
352
|
+
declare function createPolyTetrahedron(options?: TetrahedronPolygonsOptions): ParseResult;
|
|
353
|
+
declare function createPolyIcosahedron(options?: IcosahedronPolygonsOptions): ParseResult;
|
|
354
|
+
declare function createPolyDodecahedron(options?: DodecahedronPolygonsOptions): ParseResult;
|
|
355
|
+
declare function createPolyCylinder(options?: CylinderPolygonsOptions): ParseResult;
|
|
356
|
+
declare function createPolyCone(options?: ConePolygonsOptions): ParseResult;
|
|
357
|
+
declare function createPolyTorus(options?: TorusPolygonsOptions): ParseResult;
|
|
358
|
+
|
|
298
359
|
declare function injectPolyBaseStyles(doc?: Document): void;
|
|
299
360
|
|
|
300
|
-
export {
|
|
361
|
+
export { PolyControlsBaseOptions, PolyControlsEvent, PolyControlsHandle, PolyControlsListener, type PolyFirstPersonControlsHandle, type PolyFirstPersonControlsOptions, type PolyMapControlsHandle, type PolyMapControlsOptions, PolyMeshHandle, type PolyRenderStats, type PolyRenderStatsOptions, type PolyRenderSurfaceLeafCounts, PolySceneHandle, PolySceneOptions, PolySceneSnapshotError, type PolySceneSnapshotErrorCode, type PolySelectOptions, type PolySelectionHandle, type PolyTransformControlsHandle, type PolyTransformControlsObjectChangeEvent, type PolyTransformControlsOptions, type RenderTextureAtlasAsyncResult, type RenderTextureAtlasOptions, type RenderTextureAtlasResult, type RenderedPoly, buildAtlasPages, collectPolyRenderStats, createPolyBox, createPolyCone, createPolyCylinder, createPolyDodecahedron, createPolyFirstPersonControls, createPolyIcosahedron, createPolyMapControls, createPolyOctahedron, createPolyPlane, createPolyRing, createPolyScene, createPolySphere, createPolyTetrahedron, createPolyTorus, createSelect, createTransformControls, exportPolySceneSnapshot, filterAtlasPlans, getSolidPaintDefaults, getSolidPaintDefaultsFromPlans, injectPolyBaseStyles, isBorderShapeSupported, isSolidTriangleSupported, packTextureAtlasPlansWithScale, renderPolygonsWithStableTriangles, renderPolygonsWithTextureAtlas, renderPolygonsWithTextureAtlasAsync, updatePolygonsWithStableTopology, updatePolygonsWithStableTriangles, updateStableTriangleFrame };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,99 +1,106 @@
|
|
|
1
|
-
import { P as
|
|
2
|
-
export {
|
|
3
|
-
import
|
|
1
|
+
import { P as PolySceneOptions, a as PolySceneHandle, b as PolyControlsHandle, c as PolyControlsBaseOptions, d as PolyControlsEvent, e as PolyControlsListener, f as PolyMeshHandle } from './PolyShapeElements-BNHvErQF.js';
|
|
2
|
+
export { g as PolyBoxElement, h as PolyCameraElement, i as PolyCameraOptions, j as PolyConeElement, k as PolyControlsAnimateOptions, l as PolyControlsCamera, m as PolyControlsChangeEvent, n as PolyControlsInteractionEvent, o as PolyCylinderElement, p as PolyDodecahedronElement, q as PolyFirstPersonControlsElement, r as PolyIcosahedronElement, s as PolyIframeElement, t as PolyMapControlsElement, u as PolyMeshElement, v as PolyMeshTransform, w as PolyOctahedronElement, x as PolyOrbitControlsElement, y as PolyOrbitControlsHandle, z as PolyOrbitControlsOptions, A as PolyOrthographicCameraElement, B as PolyOrthographicCameraHandle, C as PolyOrthographicCameraOptions, D as PolyPerspectiveCameraElement, E as PolyPerspectiveCameraHandle, F as PolyPerspectiveCameraOptions, G as PolyPlaneElement, H as PolyPolygonElement, I as PolyRingElement, J as PolySceneElement, K as PolySelectElement, L as PolySphereElement, M as PolyTetrahedronElement, N as PolyTorusElement, O as PolyTransformControlsElement, Q as createPolyCamera, R as createPolyOrbitControls, S as createPolyOrthographicCamera, T as createPolyPerspectiveCamera } from './PolyShapeElements-BNHvErQF.js';
|
|
3
|
+
import * as _layoutit_polycss_core from '@layoutit/polycss-core';
|
|
4
|
+
import { PolyDirectionalLight, PolyAmbientLight, PolyTextureLightingMode, TextureAtlasPlan, TextureQuality, PackedAtlas, PackedPage, TextureAtlasPage, PolyRenderStrategy, SolidPaintDefaults, Polygon, SolidTriangleFrame, Vec3, BoxPolygonsOptions, ParseResult, ConePolygonsOptions, CylinderPolygonsOptions, DodecahedronPolygonsOptions, IcosahedronPolygonsOptions, OctahedronPolygonsOptions, PlanePolygonsOptions, RingPolygonsOptions, SpherePolygonsOptions, TetrahedronPolygonsOptions, TorusPolygonsOptions } from '@layoutit/polycss-core';
|
|
4
5
|
export * from '@layoutit/polycss-core';
|
|
6
|
+
export { ComputeTextureAtlasPlanOptions, PackedAtlas, PackedPage, PackedTextureAtlasEntry, PolyRenderStrategiesOption, PolyRenderStrategy, ParseResult as PolyShapeResult, SolidPaintDefaults, SolidTriangleFrame, TextureAtlasPage, TextureAtlasPlan, TextureQuality, buildTextureEdgeRepairSets, computeTextureAtlasPlanPublic, cssBorderShapeForPlan, formatBorderShapeEntryMatrix, formatCssLengthPx, formatMatrix3d, formatSolidQuadEntryMatrix, isFullRectSolid, isProjectiveQuadPlan, isSolidTrianglePlan } from '@layoutit/polycss-core';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Rotation rate in degrees per 60 Hz-equivalent frame. The tick is
|
|
15
|
-
* dt-clamped so 0.3 deg/frame ≈ 18 deg/sec on every refresh rate.
|
|
16
|
-
* Default: 0.3.
|
|
17
|
-
*/
|
|
18
|
-
speed?: number;
|
|
19
|
-
/** Rotation axis. Default: "y" (yaw, rotates around vertical world Z). */
|
|
20
|
-
axis?: "x" | "y";
|
|
21
|
-
/** Halt the loop while a pointer drag is in progress. Default: true. */
|
|
22
|
-
pauseOnInteraction?: boolean;
|
|
23
|
-
}
|
|
24
|
-
interface PolyControlsBaseOptions {
|
|
25
|
-
/** Pointer-drag. Default: true. */
|
|
26
|
-
drag?: boolean;
|
|
27
|
-
/** Wheel / pinch zoom. Default: true. */
|
|
28
|
-
wheel?: boolean;
|
|
8
|
+
interface RenderTextureAtlasOptions {
|
|
9
|
+
doc?: Document;
|
|
10
|
+
tileSize?: number;
|
|
11
|
+
layerElevation?: number;
|
|
12
|
+
directionalLight?: PolyDirectionalLight;
|
|
13
|
+
ambientLight?: PolyAmbientLight;
|
|
14
|
+
textureLighting?: PolyTextureLightingMode;
|
|
29
15
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
16
|
+
* Atlas bitmap budget and CSS sprite size. Numeric values are clamped to
|
|
17
|
+
* 0.1..1 and keep the 64px sprite. Omitted / `"auto"` picks a raster scale
|
|
18
|
+
* from packed atlas area, caps oversized runtime bitmaps by side length and
|
|
19
|
+
* decoded-memory budget, and uses a 128px sprite on desktop-class documents
|
|
20
|
+
* or a 64px sprite on mobile-class documents.
|
|
33
21
|
*/
|
|
34
|
-
|
|
22
|
+
textureQuality?: _layoutit_polycss_core.TextureQuality;
|
|
23
|
+
solidPaintDefaults?: _layoutit_polycss_core.SolidPaintDefaults;
|
|
24
|
+
strategies?: _layoutit_polycss_core.PolyRenderStrategiesOption;
|
|
35
25
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
26
|
+
* Indices of polygons that the directional light cannot reach (precomputed
|
|
27
|
+
* by createPolyScene via {@link computeLightVisibility}). Atlas + solid
|
|
28
|
+
* planning forces directScale to 0 for these polys so they render with
|
|
29
|
+
* ambient-only color, matching what a shadow-map pass would output.
|
|
38
30
|
*/
|
|
39
|
-
|
|
40
|
-
/** Minimum CSS zoom. Default: 0.1. */
|
|
41
|
-
minZoom?: number;
|
|
42
|
-
/** Maximum CSS zoom. Default: 10. */
|
|
43
|
-
maxZoom?: number;
|
|
44
|
-
/** Minimum dolly distance in CSS pixels. Default: 0. Only used when `dolly: true`. */
|
|
45
|
-
minDistance?: number;
|
|
46
|
-
/** Maximum dolly distance in CSS pixels. Default: Infinity. Only used when `dolly: true`. */
|
|
47
|
-
maxDistance?: number;
|
|
48
|
-
/** Auto-rotate. Pass false (or omit) to disable. */
|
|
49
|
-
animate?: false | PolyControlsAnimateOptions;
|
|
31
|
+
lightOccludedPolyIndices?: ReadonlySet<number>;
|
|
50
32
|
}
|
|
51
|
-
interface
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
33
|
+
interface RenderedPoly {
|
|
34
|
+
polygonIndex: number;
|
|
35
|
+
element: HTMLElement;
|
|
36
|
+
kind?: "atlas" | "solid" | "border" | "corner" | "triangle";
|
|
37
|
+
plan?: _layoutit_polycss_core.TextureAtlasPlan;
|
|
38
|
+
dispose(): void;
|
|
57
39
|
}
|
|
58
|
-
interface
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
interface RenderTextureAtlasResult {
|
|
41
|
+
rendered: RenderedPoly[];
|
|
42
|
+
dispose(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Resolves once every textured `<s>` leaf has its `background-image`
|
|
45
|
+
* applied (i.e. the atlas canvas → Blob → URL chain has completed and
|
|
46
|
+
* the apply-bg pass has run). For meshes with no textured leaves this
|
|
47
|
+
* resolves immediately. Callers doing stale-while-revalidate swaps
|
|
48
|
+
* await this before disposing the previous render — without it, the
|
|
49
|
+
* fresh leaves mount with empty backgrounds and the prior frame's
|
|
50
|
+
* bitmaps would be needed underneath to avoid a transparent flash.
|
|
51
|
+
*/
|
|
52
|
+
pagesReady?: Promise<void>;
|
|
61
53
|
}
|
|
62
|
-
interface
|
|
63
|
-
|
|
64
|
-
camera: PolyControlsCamera;
|
|
65
|
-
}
|
|
66
|
-
type PolyControlsEvent = PolyControlsChangeEvent | PolyControlsInteractionEvent;
|
|
67
|
-
type PolyControlsListener<E extends PolyControlsEvent = PolyControlsEvent> = (event: E) => void;
|
|
68
|
-
interface PolyControlsHandle {
|
|
69
|
-
update(partial: PolyControlsBaseOptions): void;
|
|
70
|
-
resume(): void;
|
|
71
|
-
pause(): void;
|
|
72
|
-
destroy(): void;
|
|
73
|
-
addEventListener<T extends PolyControlsEvent["type"]>(type: T, listener: PolyControlsListener<Extract<PolyControlsEvent, {
|
|
74
|
-
type: T;
|
|
75
|
-
}>>): void;
|
|
76
|
-
removeEventListener<T extends PolyControlsEvent["type"]>(type: T, listener: PolyControlsListener<Extract<PolyControlsEvent, {
|
|
77
|
-
type: T;
|
|
78
|
-
}>>): void;
|
|
79
|
-
hasEventListener<T extends PolyControlsEvent["type"]>(type: T, listener: PolyControlsListener<Extract<PolyControlsEvent, {
|
|
80
|
-
type: T;
|
|
81
|
-
}>>): boolean;
|
|
54
|
+
interface RenderTextureAtlasAsyncResult extends RenderTextureAtlasResult {
|
|
55
|
+
solidPaintDefaults: _layoutit_polycss_core.SolidPaintDefaults;
|
|
82
56
|
}
|
|
83
57
|
|
|
58
|
+
declare function packTextureAtlasPlansWithScale(plans: Array<TextureAtlasPlan | null>, textureQualityInput: TextureQuality | undefined, doc: Document | null | undefined): {
|
|
59
|
+
packed: PackedAtlas;
|
|
60
|
+
atlasScale: number;
|
|
61
|
+
atlasCanonicalSize: number;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
declare function buildAtlasPages(pages: PackedPage[], textureLighting: PolyTextureLightingMode, doc: Document, atlasScale: number, isCancelled: () => boolean): Promise<TextureAtlasPage[]>;
|
|
65
|
+
|
|
84
66
|
/**
|
|
85
|
-
*
|
|
67
|
+
* Compute the dominant paint defaults from an already-computed array of plans.
|
|
86
68
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
|
|
69
|
+
* React and Vue compute plans first (to drive the atlas packing), then pass
|
|
70
|
+
* the plan array here so they don't need access to the raw polygon list.
|
|
71
|
+
* Requires access to a Document to check browser support for solid-triangle
|
|
72
|
+
* and border-shape strategies.
|
|
73
|
+
*/
|
|
74
|
+
declare function getSolidPaintDefaultsFromPlans(plans: Array<TextureAtlasPlan | null>, textureLighting: PolyTextureLightingMode, disabled?: ReadonlySet<PolyRenderStrategy>, doc?: Document | null): SolidPaintDefaults;
|
|
75
|
+
/**
|
|
76
|
+
* Returns true when the browser supports the `border-shape` CSS property and
|
|
77
|
+
* the pointer/hover media queries indicate a fine-pointer device (desktop-class).
|
|
78
|
+
* Falls back to a globalThis-based check when no Document is available.
|
|
79
|
+
*/
|
|
80
|
+
declare function isBorderShapeSupported(doc?: Document | null): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Returns true when the browser renders CSS border-trick triangles correctly.
|
|
83
|
+
* WebKit/Safari renders them incorrectly when transformed — this check gates
|
|
84
|
+
* the `<u>` strategy path.
|
|
85
|
+
*/
|
|
86
|
+
declare function isSolidTriangleSupported(doc?: Document | null): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Filter a plan array to the subset that needs atlas packing, given the active
|
|
89
|
+
* render strategies and texture-lighting mode. Plans excluded from the atlas
|
|
90
|
+
* will be rendered via `<b>`, `<i>`, or `<u>` by the framework components.
|
|
92
91
|
*/
|
|
92
|
+
declare function filterAtlasPlans(plans: Array<TextureAtlasPlan | null>, textureLighting: PolyTextureLightingMode, disabled: ReadonlySet<PolyRenderStrategy>, doc?: Document | null): Array<TextureAtlasPlan | null>;
|
|
93
|
+
|
|
94
|
+
declare function getSolidPaintDefaults(polygons: Polygon[], options?: RenderTextureAtlasOptions): SolidPaintDefaults;
|
|
95
|
+
declare function renderPolygonsWithTextureAtlas(polygons: Polygon[], options?: RenderTextureAtlasOptions): RenderTextureAtlasResult;
|
|
96
|
+
declare function renderPolygonsWithTextureAtlasAsync(polygons: Polygon[], options?: RenderTextureAtlasOptions, shouldCancel?: () => boolean): Promise<RenderTextureAtlasAsyncResult>;
|
|
97
|
+
declare function updateStableTriangleFrame(rendered: RenderedPoly[], polygons: Polygon[], frame: SolidTriangleFrame, options?: RenderTextureAtlasOptions): boolean;
|
|
98
|
+
declare function updatePolygonsWithStableTopology(rendered: RenderedPoly[], polygons: Polygon[], options?: RenderTextureAtlasOptions): boolean;
|
|
99
|
+
|
|
100
|
+
declare function renderPolygonsWithStableTriangles(polygons: Polygon[], options?: RenderTextureAtlasOptions): RenderTextureAtlasResult | null;
|
|
101
|
+
declare function updatePolygonsWithStableTriangles(rendered: RenderedPoly[], polygons: Polygon[], options?: RenderTextureAtlasOptions): RenderTextureAtlasResult | null;
|
|
93
102
|
|
|
94
|
-
|
|
95
|
-
type PolyOrbitControlsHandle = PolyControlsHandle;
|
|
96
|
-
declare function createPolyOrbitControls(scene: PolySceneHandle, options?: PolyOrbitControlsOptions): PolyOrbitControlsHandle;
|
|
103
|
+
declare function createPolyScene(host: HTMLElement, options: PolySceneOptions): PolySceneHandle;
|
|
97
104
|
|
|
98
105
|
/**
|
|
99
106
|
* createPolyMapControls — map/pan-mode camera input for a PolyScene.
|
|
@@ -191,7 +198,7 @@ interface PolyFirstPersonControlsHandle {
|
|
|
191
198
|
declare function createPolyFirstPersonControls(scene: PolySceneHandle, options?: PolyFirstPersonControlsOptions): PolyFirstPersonControlsHandle;
|
|
192
199
|
|
|
193
200
|
/**
|
|
194
|
-
* createSelect — additive selection layer for vanilla
|
|
201
|
+
* createSelect — additive selection layer for vanilla PolyCSS scenes.
|
|
195
202
|
* Mirrors the React `<Select>` API: tracks one or more selected
|
|
196
203
|
* meshes, fires `onChange` whenever the set changes, supports
|
|
197
204
|
* single-click toggle (re-clicking the selected mesh deselects it),
|
|
@@ -295,6 +302,60 @@ interface PolyTransformControlsHandle {
|
|
|
295
302
|
}
|
|
296
303
|
declare function createTransformControls(scene: PolySceneHandle, options?: PolyTransformControlsOptions): PolyTransformControlsHandle;
|
|
297
304
|
|
|
305
|
+
interface PolyRenderSurfaceLeafCounts {
|
|
306
|
+
quad: number;
|
|
307
|
+
clippedSolid: number;
|
|
308
|
+
atlas: number;
|
|
309
|
+
stableTriangle: number;
|
|
310
|
+
}
|
|
311
|
+
interface PolyRenderStats {
|
|
312
|
+
polygonCount: number;
|
|
313
|
+
mountedPolygonLeafCount: number;
|
|
314
|
+
shadowLeafCount: number;
|
|
315
|
+
surfaceLeafCounts: PolyRenderSurfaceLeafCounts;
|
|
316
|
+
bucketCount: number;
|
|
317
|
+
}
|
|
318
|
+
interface PolyRenderStatsOptions {
|
|
319
|
+
polygonCount?: number;
|
|
320
|
+
/**
|
|
321
|
+
* Optional subtree selector for diagnostics that only want model leaves and
|
|
322
|
+
* not helpers/floors/gizmos sharing the same scene root.
|
|
323
|
+
*/
|
|
324
|
+
scopeSelector?: string;
|
|
325
|
+
}
|
|
326
|
+
declare function collectPolyRenderStats(root: ParentNode | null | undefined, optionsOrPolygonCount?: number | PolyRenderStatsOptions): PolyRenderStats;
|
|
327
|
+
|
|
328
|
+
type PolySceneSnapshotErrorCode = "INVALID_TARGET" | "SCENE_NOT_FOUND" | "ASSET_INLINE_FAILED";
|
|
329
|
+
declare class PolySceneSnapshotError extends Error {
|
|
330
|
+
readonly code: PolySceneSnapshotErrorCode;
|
|
331
|
+
readonly url?: string;
|
|
332
|
+
constructor(code: PolySceneSnapshotErrorCode, message: string, url?: string);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Serialize the current rendered PolyCSS DOM into a standalone HTML document.
|
|
336
|
+
* The snapshot is intentionally static: it preserves the scene's current DOM,
|
|
337
|
+
* inlines CSS image assets, and emits no scripts or PolyCSS runtime imports.
|
|
338
|
+
*/
|
|
339
|
+
declare function exportPolySceneSnapshot(target: Element): Promise<string>;
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Primitive shape factories — thin wrappers over the polygon generators in
|
|
343
|
+
* @layoutit/polycss-core. Each returns a `ParseResult`-compatible object so
|
|
344
|
+
* it composes directly with `scene.add(createPolyBox({ size: 100 }))`.
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
declare function createPolyBox(options?: BoxPolygonsOptions): ParseResult;
|
|
348
|
+
declare function createPolyPlane(options: PlanePolygonsOptions): ParseResult;
|
|
349
|
+
declare function createPolyRing(options: RingPolygonsOptions): ParseResult;
|
|
350
|
+
declare function createPolyOctahedron(options: OctahedronPolygonsOptions): ParseResult;
|
|
351
|
+
declare function createPolySphere(options?: SpherePolygonsOptions): ParseResult;
|
|
352
|
+
declare function createPolyTetrahedron(options?: TetrahedronPolygonsOptions): ParseResult;
|
|
353
|
+
declare function createPolyIcosahedron(options?: IcosahedronPolygonsOptions): ParseResult;
|
|
354
|
+
declare function createPolyDodecahedron(options?: DodecahedronPolygonsOptions): ParseResult;
|
|
355
|
+
declare function createPolyCylinder(options?: CylinderPolygonsOptions): ParseResult;
|
|
356
|
+
declare function createPolyCone(options?: ConePolygonsOptions): ParseResult;
|
|
357
|
+
declare function createPolyTorus(options?: TorusPolygonsOptions): ParseResult;
|
|
358
|
+
|
|
298
359
|
declare function injectPolyBaseStyles(doc?: Document): void;
|
|
299
360
|
|
|
300
|
-
export {
|
|
361
|
+
export { PolyControlsBaseOptions, PolyControlsEvent, PolyControlsHandle, PolyControlsListener, type PolyFirstPersonControlsHandle, type PolyFirstPersonControlsOptions, type PolyMapControlsHandle, type PolyMapControlsOptions, PolyMeshHandle, type PolyRenderStats, type PolyRenderStatsOptions, type PolyRenderSurfaceLeafCounts, PolySceneHandle, PolySceneOptions, PolySceneSnapshotError, type PolySceneSnapshotErrorCode, type PolySelectOptions, type PolySelectionHandle, type PolyTransformControlsHandle, type PolyTransformControlsObjectChangeEvent, type PolyTransformControlsOptions, type RenderTextureAtlasAsyncResult, type RenderTextureAtlasOptions, type RenderTextureAtlasResult, type RenderedPoly, buildAtlasPages, collectPolyRenderStats, createPolyBox, createPolyCone, createPolyCylinder, createPolyDodecahedron, createPolyFirstPersonControls, createPolyIcosahedron, createPolyMapControls, createPolyOctahedron, createPolyPlane, createPolyRing, createPolyScene, createPolySphere, createPolyTetrahedron, createPolyTorus, createSelect, createTransformControls, exportPolySceneSnapshot, filterAtlasPlans, getSolidPaintDefaults, getSolidPaintDefaultsFromPlans, injectPolyBaseStyles, isBorderShapeSupported, isSolidTriangleSupported, packTextureAtlasPlansWithScale, renderPolygonsWithStableTriangles, renderPolygonsWithTextureAtlas, renderPolygonsWithTextureAtlasAsync, updatePolygonsWithStableTopology, updatePolygonsWithStableTriangles, updateStableTriangleFrame };
|