@layoutit/polycss-core 0.0.1 → 0.2.1
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 +169 -82
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +1189 -15
- package/dist/index.d.ts +1189 -15
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -11,13 +11,21 @@ declare const DEFAULT_PROJECTION: "cubic";
|
|
|
11
11
|
* variables, no JS work, no atlas re-rasterization.
|
|
12
12
|
*/
|
|
13
13
|
type PolyTextureLightingMode = "baked" | "dynamic";
|
|
14
|
+
/**
|
|
15
|
+
* Mesh post-processing intent.
|
|
16
|
+
* - "lossless": preserve the authored surface while applying exact
|
|
17
|
+
* reductions such as interior culling and coplanar merge.
|
|
18
|
+
* - "lossy": allow bounded geometric approximation when it reduces the
|
|
19
|
+
* rendered polygon/DOM count.
|
|
20
|
+
*/
|
|
21
|
+
type MeshResolution = "lossless" | "lossy";
|
|
14
22
|
/**
|
|
15
23
|
* 3D point/vector, stored as a `[x, y, z]` tuple. Tuple (rather than
|
|
16
24
|
* `{x, y, z}`) for compact JSON: meshes serialize to thousands of vertices
|
|
17
25
|
* and the difference adds up. Destructure with `const [x, y, z] = v` when
|
|
18
26
|
* you need named axes.
|
|
19
27
|
*
|
|
20
|
-
*
|
|
28
|
+
* PolyCSS world space convention: +X right, +Y forward, +Z up.
|
|
21
29
|
*/
|
|
22
30
|
type Vec3 = [number, number, number];
|
|
23
31
|
/**
|
|
@@ -31,6 +39,12 @@ interface TextureTriangle {
|
|
|
31
39
|
vertices: [Vec3, Vec3, Vec3];
|
|
32
40
|
uvs: [Vec2, Vec2, Vec2];
|
|
33
41
|
}
|
|
42
|
+
type PolyTextureWrapMode = "repeat" | "clamp-to-edge" | "mirrored-repeat";
|
|
43
|
+
interface PolyTextureWrap {
|
|
44
|
+
s: PolyTextureWrapMode;
|
|
45
|
+
t: PolyTextureWrapMode;
|
|
46
|
+
}
|
|
47
|
+
type PolyTextureAlphaMode = "opaque" | "mask" | "blend";
|
|
34
48
|
/**
|
|
35
49
|
* Directional light — simulates a single distant source (sun, key light).
|
|
36
50
|
* Contributes Lambert shading scaled by `intensity`. `direction` is in
|
|
@@ -62,7 +76,7 @@ interface PolyAmbientLight {
|
|
|
62
76
|
*
|
|
63
77
|
* In CSS terms, a material bundles the `background-image` source plus paint
|
|
64
78
|
* config. When a polygon references a material AND its UVs form an
|
|
65
|
-
* axis-aligned rectangle,
|
|
79
|
+
* axis-aligned rectangle, PolyCSS renders the polygon as an <i> with
|
|
66
80
|
* `background-image: url(material.texture)` directly — no per-polygon canvas
|
|
67
81
|
* rasterization, browser-cached texture, mounting / unmounting one polygon
|
|
68
82
|
* does not affect any other.
|
|
@@ -74,7 +88,7 @@ interface PolyAmbientLight {
|
|
|
74
88
|
interface PolyMaterial {
|
|
75
89
|
/** Image source. Anything `background-image: url(...)` can use. */
|
|
76
90
|
texture: string;
|
|
77
|
-
/** Optional unique key (used by
|
|
91
|
+
/** Optional unique key (used by PolyCSS to dedupe / cache). Caller can
|
|
78
92
|
* pass a stable string; if omitted, the material's identity is its object
|
|
79
93
|
* reference. */
|
|
80
94
|
key?: string;
|
|
@@ -99,10 +113,24 @@ interface Polygon {
|
|
|
99
113
|
* `color` (or default gray).
|
|
100
114
|
*/
|
|
101
115
|
texture?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Texture sampler wrap mode for UVs outside [0, 1]. glTF imports preserve
|
|
118
|
+
* sampler.wrapS / wrapT here so the atlas rasterizer can tile repeated UVs.
|
|
119
|
+
* When unset, renderers keep the historical single-image behavior.
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
textureWrap?: PolyTextureWrap;
|
|
123
|
+
/**
|
|
124
|
+
* Texture alpha interpretation imported from glTF `material.alphaMode`.
|
|
125
|
+
* Opaque textures can use transparent PNG padding without cutting holes in
|
|
126
|
+
* the rendered polygon.
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
textureAlphaMode?: PolyTextureAlphaMode;
|
|
102
130
|
/**
|
|
103
131
|
* Shared material. When set, `material.texture` takes precedence over the
|
|
104
132
|
* inline `texture` field. If the polygon's UVs form an axis-aligned
|
|
105
|
-
* rectangle,
|
|
133
|
+
* rectangle, PolyCSS uses the direct CSS background-image path (no per-
|
|
106
134
|
* polygon canvas rasterization). Falls back to the atlas path otherwise.
|
|
107
135
|
*/
|
|
108
136
|
material?: PolyMaterial;
|
|
@@ -119,6 +147,12 @@ interface Polygon {
|
|
|
119
147
|
* @internal
|
|
120
148
|
*/
|
|
121
149
|
textureTriangles?: TextureTriangle[];
|
|
150
|
+
/**
|
|
151
|
+
* Source material requested two-sided rendering. Importers use this so
|
|
152
|
+
* optimization passes do not collapse intentional reverse-wound faces.
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
doubleSided?: boolean;
|
|
122
156
|
/**
|
|
123
157
|
* User-controlled metadata. Reflected to DOM as `data-*` attributes via
|
|
124
158
|
* stringification by the framework wrappers. Only string|number|boolean
|
|
@@ -254,7 +288,7 @@ declare function computeTexturePaintMetrics(polygons: Polygon[], options?: Textu
|
|
|
254
288
|
|
|
255
289
|
/**
|
|
256
290
|
* Apply CSS-style chained `rotateX(rx) rotateY(ry) rotateZ(rz)` rotation
|
|
257
|
-
* to a 3D vector. Matches the matrix composition used by
|
|
291
|
+
* to a 3D vector. Matches the matrix composition used by PolyCSS mesh
|
|
258
292
|
* wrapper transforms (see `buildTransform` in each PolyMesh implementation).
|
|
259
293
|
*
|
|
260
294
|
* CSS composes `transform: rotateX(rx) rotateY(ry) rotateZ(rz)` as the
|
|
@@ -281,7 +315,52 @@ declare function rotateVec3(v: Vec3, rxDeg: number, ryDeg: number, rzDeg: number
|
|
|
281
315
|
declare function inverseRotateVec3(v: Vec3, rot: Vec3): Vec3;
|
|
282
316
|
|
|
283
317
|
/**
|
|
284
|
-
*
|
|
318
|
+
* Minimal quaternion helpers for composing rotations.
|
|
319
|
+
*
|
|
320
|
+
* Why we need quaternions: the public PolyMesh API exposes rotation as a
|
|
321
|
+
* Euler triple `[rx, ry, rz]` in degrees (drives CSS `rotateX rotateY
|
|
322
|
+
* rotateZ`, applied right-to-left). Euler triples don't compose by
|
|
323
|
+
* component addition — rotating Y after X must happen around the mesh's
|
|
324
|
+
* NEW local-Y axis, not world-Y. The transform-controls ring drag handler
|
|
325
|
+
* uses these helpers to compose around the mesh's local axis correctly:
|
|
326
|
+
*
|
|
327
|
+
* q_start = quatFromEulerXYZ(currentRotationDeg)
|
|
328
|
+
* q_delta = quatFromAxisAngle(localAxis, deltaRadians)
|
|
329
|
+
* q_new = quatMultiply(q_start, q_delta) // RIGHT-multiply = local frame
|
|
330
|
+
* next = eulerXYZFromQuat(q_new)
|
|
331
|
+
*
|
|
332
|
+
* Convention: "XYZ" Euler means the composed rotation matrix is
|
|
333
|
+
* `Rx(rx) · Ry(ry) · Rz(rz)`, which matches CSS `rotateX rotateY rotateZ`
|
|
334
|
+
* (right-to-left application to a point ⇒ Z first, then Y, then X).
|
|
335
|
+
*
|
|
336
|
+
* Quaternion format: `[w, x, y, z]` (real-first, like three.js's internal
|
|
337
|
+
* `_x/_y/_z/_w` reordered). Stored as plain tuples — no constructor or
|
|
338
|
+
* runtime allocations per drag.
|
|
339
|
+
*/
|
|
340
|
+
|
|
341
|
+
/** Quaternion `[w, x, y, z]`, real component first. Unit-length is not
|
|
342
|
+
* enforced by the type — callers normalize when needed. */
|
|
343
|
+
type Quat = [number, number, number, number];
|
|
344
|
+
/** Identity quaternion. */
|
|
345
|
+
declare const QUAT_IDENTITY: Quat;
|
|
346
|
+
/** Hamilton product `q1 * q2`. Apply to a vector as `q v q⁻¹`. Right-
|
|
347
|
+
* multiplication composes the second rotation in the LOCAL frame of the
|
|
348
|
+
* first — that's the property the gizmo relies on for local-axis drag. */
|
|
349
|
+
declare function quatMultiply(q1: Quat, q2: Quat): Quat;
|
|
350
|
+
/** Quaternion from axis-angle. `axis` must be unit length (caller's
|
|
351
|
+
* responsibility — typically a CSS basis vector). `angleRad` in radians. */
|
|
352
|
+
declare function quatFromAxisAngle(axis: Vec3, angleRad: number): Quat;
|
|
353
|
+
/** Quaternion from Euler XYZ degrees — the order CSS `rotateX rotateY
|
|
354
|
+
* rotateZ` applies. Matches the composed matrix `Rx(rx)·Ry(ry)·Rz(rz)`. */
|
|
355
|
+
declare function quatFromEulerXYZ(eulerDeg: Vec3): Quat;
|
|
356
|
+
/** Euler XYZ degrees from a quaternion — inverse of `quatFromEulerXYZ`.
|
|
357
|
+
* Handles gimbal lock (|ry| → 90°) by collapsing rz onto rx. The output
|
|
358
|
+
* matches the convention used by CSS `rotateX rotateY rotateZ` so it can
|
|
359
|
+
* be written straight back into a PolyMesh rotation prop. */
|
|
360
|
+
declare function eulerXYZFromQuat(q: Quat): Vec3;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Base tile size in CSS pixels. One PolyCSS world unit = BASE_TILE CSS
|
|
285
364
|
* pixels (pre-scale). Used to convert world-coordinate target values to
|
|
286
365
|
* CSS translations in the transform string.
|
|
287
366
|
*/
|
|
@@ -296,7 +375,7 @@ type AutoRotateOption = boolean | number | AutoRotateConfig;
|
|
|
296
375
|
* World-coordinate camera state (Three.js-style).
|
|
297
376
|
*
|
|
298
377
|
* `target` is the world point that should appear at the viewport centre.
|
|
299
|
-
*
|
|
378
|
+
* PolyCSS world axes: [0]=X (rows/south), [1]=Y (cols/east), [2]=Z (up).
|
|
300
379
|
*
|
|
301
380
|
* `pan`, `tilt`, and `depthOffset` are gone. Translations now live inside
|
|
302
381
|
* `target` so they happen BEFORE rotations — enabling correct world-space
|
|
@@ -394,6 +473,86 @@ declare function computeShapeLighting(normal: Vec3, baseColor: string, direction
|
|
|
394
473
|
|
|
395
474
|
declare function mergePolygons(input: Polygon[]): Polygon[];
|
|
396
475
|
|
|
476
|
+
/**
|
|
477
|
+
* dedupeOverlappingPolygons — drop polygons whose 3D footprint coincides
|
|
478
|
+
* with another polygon's, within an epsilon tolerance.
|
|
479
|
+
*
|
|
480
|
+
* Why this exists: modelers (and importers) often emit redundant geometry
|
|
481
|
+
* for the same visible surface — a doubled face on a wall, an inner shell
|
|
482
|
+
* coincident with an outer shell, or two N-gons that fan-triangulate the
|
|
483
|
+
* same region. Each duplicate is a real `<i>` element at render time:
|
|
484
|
+
* it costs DOM, Lambert math, atlas budget, AND it produces stacked
|
|
485
|
+
* shadow leaves that visibly multiply on the receiver (overlapping dark
|
|
486
|
+
* patches on the ground).
|
|
487
|
+
*
|
|
488
|
+
* This is a separate concern from `cullInteriorPolygons` (which removes
|
|
489
|
+
* polygons fully *enclosed* by other geometry, conservative against
|
|
490
|
+
* false positives) and from `mergePolygons` (which joins same-color
|
|
491
|
+
* coplanar polygons that share an edge). A polygon's exact twin
|
|
492
|
+
* doesn't share an edge with itself and isn't enclosed by anything —
|
|
493
|
+
* it slips through both passes.
|
|
494
|
+
*
|
|
495
|
+
* Algorithm:
|
|
496
|
+
* 1. Compute each polygon's plane (normal + signed offset along
|
|
497
|
+
* normal) and centroid.
|
|
498
|
+
* 2. Bucket polygons by quantized plane key (rounded normal direction
|
|
499
|
+
* with sign-folding so anti-parallel faces share a bucket, and
|
|
500
|
+
* rounded distance from origin along the unsigned normal axis).
|
|
501
|
+
* Polygons in different buckets cannot overlap.
|
|
502
|
+
* 3. Within each bucket, do an O(K²) pairwise check on at most K
|
|
503
|
+
* polygons. Two polygons overlap if their 2D projections onto
|
|
504
|
+
* the shared plane share a significant area fraction.
|
|
505
|
+
* 4. When a pair overlaps, drop one: prefer keeping the one whose
|
|
506
|
+
* normal points *away* from the mesh centroid (the "outward"
|
|
507
|
+
* face). For ties (truly identical orientation), keep the one
|
|
508
|
+
* with greater 2D area.
|
|
509
|
+
*
|
|
510
|
+
* Runs once at parse time in the same pipeline as mergePolygons. Zero
|
|
511
|
+
* cost at runtime — once it returns the polygon array is final and the
|
|
512
|
+
* dedup logic never executes again.
|
|
513
|
+
*/
|
|
514
|
+
|
|
515
|
+
/** Tunable thresholds. Default values are conservative — only catch
|
|
516
|
+
* duplicates that are visually identical surfaces (exact twins,
|
|
517
|
+
* back-to-back winding flips, nested polys on the same plane).
|
|
518
|
+
* Looser values are appropriate for shadow-casting purposes, where
|
|
519
|
+
* any polygons whose projections land in the same place can share a
|
|
520
|
+
* shadow without affecting the rendered model. */
|
|
521
|
+
interface DedupeOverlappingPolygonsOptions {
|
|
522
|
+
/** Maximum 1 - |dot(n_a, n_b)| for normals to count as "parallel".
|
|
523
|
+
* Default 1e-3 (strict — must be near-identical orientation).
|
|
524
|
+
* Looser values (~5e-2 ≈ 18° off) treat near-parallel normals as
|
|
525
|
+
* duplicates, useful for shadow dedup where small orientation
|
|
526
|
+
* differences project to nearly the same shadow shape. */
|
|
527
|
+
normalTolerance?: number;
|
|
528
|
+
/** Maximum signed-distance difference between two polygons' plane
|
|
529
|
+
* offsets (along their shared normal) to count as coplanar.
|
|
530
|
+
* Default 0.05 (world units). Looser values treat distinct
|
|
531
|
+
* parallel shells (e.g. an inner cavity wall behind an outer
|
|
532
|
+
* wall) as shadow-duplicates. */
|
|
533
|
+
distanceTolerance?: number;
|
|
534
|
+
/** Minimum overlap fraction (max of A-in-B and B-in-A vertex
|
|
535
|
+
* containment ratios) for a pair to count as a duplicate.
|
|
536
|
+
* Default 0.7. Lower (~0.4) is liberal; higher (~0.9) is strict. */
|
|
537
|
+
overlapFraction?: number;
|
|
538
|
+
/** Preserve reverse-wound faces from authored double-sided materials.
|
|
539
|
+
* Geometry dedupe keeps these by default; shadow dedupe can disable it
|
|
540
|
+
* because coincident front/back casters produce stacked shadows. */
|
|
541
|
+
preserveDoubleSidedBackfaces?: boolean;
|
|
542
|
+
}
|
|
543
|
+
/** Identify polygons that are duplicates within tolerance. Returns the
|
|
544
|
+
* set of indices into the input array that should be dropped (the
|
|
545
|
+
* losers of duplicate pairs). The "winner" of a pair is the polygon
|
|
546
|
+
* whose normal faces away from the mesh centroid (outward), with
|
|
547
|
+
* larger area as a tiebreaker.
|
|
548
|
+
*
|
|
549
|
+
* Exposed for callers that want to act on the index set directly —
|
|
550
|
+
* e.g. shadow casting can use a looser tolerance to skip shadow leaves
|
|
551
|
+
* for redundant casters without removing them from the renderable
|
|
552
|
+
* polygon set. */
|
|
553
|
+
declare function findOverlappingPolygonDuplicates(input: Polygon[], options?: DedupeOverlappingPolygonsOptions): Set<number>;
|
|
554
|
+
declare function dedupeOverlappingPolygons(input: Polygon[], options?: DedupeOverlappingPolygonsOptions): Polygon[];
|
|
555
|
+
|
|
397
556
|
interface CoverPlanarPolygonsOptions {
|
|
398
557
|
/** Smallest connected coplanar group worth attempting. Default 4. */
|
|
399
558
|
minGroupPolygons?: number;
|
|
@@ -413,6 +572,106 @@ interface CoverPlanarPolygonsOptions {
|
|
|
413
572
|
*/
|
|
414
573
|
declare function coverPlanarPolygons(input: Polygon[], options?: CoverPlanarPolygonsOptions): Polygon[];
|
|
415
574
|
|
|
575
|
+
interface OptimizeMeshPolygonsOptions {
|
|
576
|
+
/** Public quality/resolution intent. Defaults to "lossy". */
|
|
577
|
+
meshResolution?: MeshResolution;
|
|
578
|
+
/**
|
|
579
|
+
* Run the planar cover pass as an exact candidate for untextured coplanar
|
|
580
|
+
* regions. Defaults to true.
|
|
581
|
+
*/
|
|
582
|
+
rectCover?: boolean | CoverPlanarPolygonsOptions;
|
|
583
|
+
}
|
|
584
|
+
declare function optimizeMeshPolygons(polygons: Polygon[], options?: OptimizeMeshPolygonsOptions): Polygon[];
|
|
585
|
+
|
|
586
|
+
type SeamOverlapCandidateKind = "true-gap" | "connected-facet" | "material-boundary";
|
|
587
|
+
interface SeamOverlapCandidate {
|
|
588
|
+
kind: SeamOverlapCandidateKind;
|
|
589
|
+
aPolygon: number;
|
|
590
|
+
aEdge: number;
|
|
591
|
+
bPolygon: number;
|
|
592
|
+
bEdge: number;
|
|
593
|
+
aColor?: string;
|
|
594
|
+
bColor?: string;
|
|
595
|
+
aMaterialKey: string;
|
|
596
|
+
bMaterialKey: string;
|
|
597
|
+
gapPx: number;
|
|
598
|
+
spanPx: number;
|
|
599
|
+
aStartPx: number;
|
|
600
|
+
aEndPx: number;
|
|
601
|
+
bStartPx: number;
|
|
602
|
+
bEndPx: number;
|
|
603
|
+
targetClosurePx: number;
|
|
604
|
+
appliedClosurePx: number;
|
|
605
|
+
residualGapPx: number;
|
|
606
|
+
residualTargetPx: number;
|
|
607
|
+
}
|
|
608
|
+
interface SeamOverlapDiagnostics {
|
|
609
|
+
exactPairs: number;
|
|
610
|
+
nearPairs: number;
|
|
611
|
+
patchedPolygons: number;
|
|
612
|
+
patchedEdges: number;
|
|
613
|
+
maxMeasuredGapPx: number;
|
|
614
|
+
maxAppliedAmountPx: number;
|
|
615
|
+
unclosedPairs: number;
|
|
616
|
+
maxResidualGapPx: number;
|
|
617
|
+
}
|
|
618
|
+
interface SeamOverlapOptions {
|
|
619
|
+
overlapPx?: number;
|
|
620
|
+
maxGapPx?: number;
|
|
621
|
+
capacityScale?: number;
|
|
622
|
+
}
|
|
623
|
+
interface SeamFacetSplitOptions {
|
|
624
|
+
rotX?: number;
|
|
625
|
+
rotY?: number;
|
|
626
|
+
viewAware?: boolean;
|
|
627
|
+
passes?: number;
|
|
628
|
+
budget?: number;
|
|
629
|
+
}
|
|
630
|
+
type SeamFacetSplitCandidateReason = "component-anchor" | "global-outlier" | "local-follow-up" | "shared-polygon" | "below-threshold";
|
|
631
|
+
interface SeamFacetSplitCandidate {
|
|
632
|
+
key: string;
|
|
633
|
+
aPolygon: number;
|
|
634
|
+
aEdge: number;
|
|
635
|
+
bPolygon: number;
|
|
636
|
+
bEdge: number;
|
|
637
|
+
color?: string;
|
|
638
|
+
materialKey: string;
|
|
639
|
+
lengthPx: number;
|
|
640
|
+
projectedLengthPx: number;
|
|
641
|
+
score: number;
|
|
642
|
+
normalRisk: number;
|
|
643
|
+
shapeRisk: number;
|
|
644
|
+
viewRisk: number;
|
|
645
|
+
component: number;
|
|
646
|
+
marginalCost: number;
|
|
647
|
+
selected: boolean;
|
|
648
|
+
reason: SeamFacetSplitCandidateReason;
|
|
649
|
+
}
|
|
650
|
+
interface SeamFacetSplitReport {
|
|
651
|
+
candidates: SeamFacetSplitCandidate[];
|
|
652
|
+
selectedPolygons: number;
|
|
653
|
+
selectedEdges: number;
|
|
654
|
+
addedPolygons: number;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
declare const DEFAULT_SEAM_OVERLAP_OPTIONS: {
|
|
658
|
+
readonly overlapPx: 1.25;
|
|
659
|
+
readonly maxGapPx: 14;
|
|
660
|
+
readonly capacityScale: 1;
|
|
661
|
+
};
|
|
662
|
+
declare const DEFAULT_SEAM_FACET_SPLIT_OPTIONS: {
|
|
663
|
+
readonly budget: 40;
|
|
664
|
+
};
|
|
665
|
+
declare function seamFacetSplitPolygons(polygons: Polygon[], seamOptions?: number | SeamOverlapOptions, splitOptions?: SeamFacetSplitOptions): Polygon[];
|
|
666
|
+
declare function seamFacetSplitReport(polygons: Polygon[], seamOptions?: number | SeamOverlapOptions, splitOptions?: SeamFacetSplitOptions): SeamFacetSplitReport;
|
|
667
|
+
declare function seamOverlapPolygons(polygons: Polygon[], options?: number | SeamOverlapOptions): Polygon[];
|
|
668
|
+
declare function repairMeshSeams(polygons: Polygon[], seamOptions?: number | SeamOverlapOptions, splitOptions?: SeamFacetSplitOptions): Polygon[];
|
|
669
|
+
declare function seamOverlapDiagnostics(polygons: Polygon[], options?: number | SeamOverlapOptions): SeamOverlapDiagnostics;
|
|
670
|
+
declare function seamOverlapReport(polygons: Polygon[], options?: number | SeamOverlapOptions): {
|
|
671
|
+
diagnostics: SeamOverlapDiagnostics;
|
|
672
|
+
candidates: SeamOverlapCandidate[];
|
|
673
|
+
};
|
|
674
|
+
|
|
416
675
|
/**
|
|
417
676
|
* cullInteriorPolygons — remove polygons that are fully enclosed by other
|
|
418
677
|
* polygons of the same mesh and therefore never visible from any external
|
|
@@ -435,17 +694,40 @@ declare function coverPlanarPolygons(input: Polygon[], options?: CoverPlanarPoly
|
|
|
435
694
|
*/
|
|
436
695
|
|
|
437
696
|
interface CullInteriorOptions {
|
|
438
|
-
/** Hemisphere ray samples per polygon. Higher = fewer false positives, slower. Default
|
|
697
|
+
/** Hemisphere ray samples per polygon. Higher = fewer false positives, slower. Default 8. */
|
|
439
698
|
samples?: number;
|
|
440
699
|
}
|
|
441
700
|
declare function cullInteriorPolygons(polygons: Polygon[], options?: CullInteriorOptions): Polygon[];
|
|
442
701
|
|
|
702
|
+
declare const CAMERA_BACKFACE_CULL_EPS = 0.00001;
|
|
703
|
+
declare const VOXEL_CAMERA_CULL_AXIS_EPS = 0.001;
|
|
704
|
+
declare const VOXEL_CAMERA_CULL_NORMAL_LIMIT = 6;
|
|
705
|
+
interface CameraCullRotation {
|
|
706
|
+
rotX: number;
|
|
707
|
+
rotY: number;
|
|
708
|
+
meshRotation?: Vec3;
|
|
709
|
+
}
|
|
710
|
+
interface CameraCullNormalGroup {
|
|
711
|
+
key: string;
|
|
712
|
+
normal: Vec3;
|
|
713
|
+
}
|
|
714
|
+
declare function polygonCssSurfaceNormal(polygon: Polygon): Vec3 | null;
|
|
715
|
+
declare function cameraFacingDepth(normal: Vec3, rotation: CameraCullRotation): number;
|
|
716
|
+
declare function normalFacesCamera(normal: Vec3, rotation: CameraCullRotation, depthThreshold?: number): boolean;
|
|
717
|
+
declare function polygonFacesCamera(polygon: Polygon, rotation: CameraCullRotation, depthThreshold?: number): boolean;
|
|
718
|
+
declare function cameraCullNormalKey(normal: Vec3): string;
|
|
719
|
+
declare function cameraCullNormalGroups(normals: Iterable<Vec3 | null | undefined>): CameraCullNormalGroup[];
|
|
720
|
+
declare function cameraCullNormalGroupsFromPolygons(polygons: readonly Polygon[]): CameraCullNormalGroup[];
|
|
721
|
+
declare function isAxisAlignedSurfaceNormal(normal: Vec3, axisEpsilon?: number): boolean;
|
|
722
|
+
declare function isVoxelCameraCullableNormalGroups(groups: readonly CameraCullNormalGroup[]): boolean;
|
|
723
|
+
declare function cameraCullVisibleSignature(groups: readonly CameraCullNormalGroup[], rotation: CameraCullRotation, depthThreshold?: number): string;
|
|
724
|
+
|
|
443
725
|
/**
|
|
444
726
|
* Geometry for the three.js-style debug axes gizmo: three thin colored
|
|
445
727
|
* cuboids stretching along world-X, world-Y and world-Z. Mirrors the
|
|
446
728
|
* convention `red=X, green=Y, blue=Z`.
|
|
447
729
|
*
|
|
448
|
-
* Returned polygons are in the standard
|
|
730
|
+
* Returned polygons are in the standard PolyCSS world-space convention
|
|
449
731
|
* (`+X right, +Y forward, +Z up`). Wrap with the framework's PolyMesh /
|
|
450
732
|
* PolyScene equivalent to render.
|
|
451
733
|
*/
|
|
@@ -471,6 +753,30 @@ interface AxesHelperOptions {
|
|
|
471
753
|
*/
|
|
472
754
|
declare function axesHelperPolygons(options?: AxesHelperOptions): Polygon[];
|
|
473
755
|
|
|
756
|
+
/**
|
|
757
|
+
* Axis-aligned box/cuboid geometry as six quad polygons.
|
|
758
|
+
*
|
|
759
|
+
* Returned polygons are in standard PolyCSS world space:
|
|
760
|
+
* +X = right, +Y = front/forward, +Z = top/up.
|
|
761
|
+
*/
|
|
762
|
+
|
|
763
|
+
type BoxFace = "right" | "left" | "front" | "back" | "top" | "bottom";
|
|
764
|
+
type BoxFaceOptions = Pick<Polygon, "color" | "texture" | "material" | "uvs" | "data">;
|
|
765
|
+
interface BoxPolygonsOptions extends BoxFaceOptions {
|
|
766
|
+
/** Size along the world X/Y/Z axes. Defaults to a 1×1×1 cube. */
|
|
767
|
+
size?: number | Vec3;
|
|
768
|
+
/** Center used with `size`. Defaults to the origin. */
|
|
769
|
+
center?: Vec3;
|
|
770
|
+
/** Explicit minimum world-space corner. When set with `max`, bounds win over size/center. */
|
|
771
|
+
min?: Vec3;
|
|
772
|
+
/** Explicit maximum world-space corner. When set with `min`, bounds win over size/center. */
|
|
773
|
+
max?: Vec3;
|
|
774
|
+
/** Per-face material/data overrides. Set a face to `false` to omit it. */
|
|
775
|
+
faces?: Partial<Record<BoxFace, BoxFaceOptions | false>>;
|
|
776
|
+
}
|
|
777
|
+
/** Build the polygons for one axis-aligned box/cuboid. */
|
|
778
|
+
declare function boxPolygons(options?: BoxPolygonsOptions): Polygon[];
|
|
779
|
+
|
|
474
780
|
/**
|
|
475
781
|
* Geometry for a single 3D arrow: a thin axis-aligned cuboid shaft
|
|
476
782
|
* stretching from the origin along one signed axis, capped with a
|
|
@@ -478,7 +784,7 @@ declare function axesHelperPolygons(options?: AxesHelperOptions): Polygon[];
|
|
|
478
784
|
* drag handle for `<TransformControls>` — same primitive recipe as
|
|
479
785
|
* `axesHelperPolygons`, plus an arrowhead.
|
|
480
786
|
*
|
|
481
|
-
* Returned polygons are in standard
|
|
787
|
+
* Returned polygons are in standard PolyCSS world space and intended
|
|
482
788
|
* to be wrapped in the framework's PolyMesh equivalent for rendering.
|
|
483
789
|
*/
|
|
484
790
|
|
|
@@ -497,6 +803,11 @@ interface ArrowPolygonsOptions {
|
|
|
497
803
|
headHalfThickness?: number;
|
|
498
804
|
/** Fill color. */
|
|
499
805
|
color?: string;
|
|
806
|
+
/** Emit the rectangular shaft polygons. Default `true`. Set `false` to
|
|
807
|
+
* render just the pyramid head — used by transform-control gizmos to
|
|
808
|
+
* declutter back-facing axes (only the head still identifies direction
|
|
809
|
+
* while the shaft would visually overlap the front-facing arrow). */
|
|
810
|
+
shaft?: boolean;
|
|
500
811
|
}
|
|
501
812
|
/** Build the polygons for one signed-axis arrow. */
|
|
502
813
|
declare function arrowPolygons(options: ArrowPolygonsOptions): Polygon[];
|
|
@@ -512,7 +823,7 @@ declare function arrowPolygons(options: ArrowPolygonsOptions): Polygon[];
|
|
|
512
823
|
* "rotation circle" and keeps the polygon count proportional to the
|
|
513
824
|
* `segments` knob.
|
|
514
825
|
*
|
|
515
|
-
* Returned polygons are in standard
|
|
826
|
+
* Returned polygons are in standard PolyCSS world space and intended
|
|
516
827
|
* to be wrapped in the framework's PolyMesh equivalent for rendering.
|
|
517
828
|
*/
|
|
518
829
|
|
|
@@ -534,6 +845,66 @@ interface RingPolygonsOptions {
|
|
|
534
845
|
/** Build the polygons for a flat ring (annulus). */
|
|
535
846
|
declare function ringPolygons(options: RingPolygonsOptions): Polygon[];
|
|
536
847
|
|
|
848
|
+
/**
|
|
849
|
+
* One square quad covering the bounding box of a ring (annulus) in the
|
|
850
|
+
* plane perpendicular to a chosen axis. Used by `<PolyTransformControls
|
|
851
|
+
* mode="rotate">` together with a CSS `mask: radial-gradient(...)` to
|
|
852
|
+
* render the visible donut, replacing the segmented quad-strip approach
|
|
853
|
+
* of `ringPolygons` with a single DOM element per ring.
|
|
854
|
+
*
|
|
855
|
+
* The caller is responsible for applying the mask CSS and using a donut-
|
|
856
|
+
* shaped hit-test (the quad's bounding rect alone would over-hit the
|
|
857
|
+
* inner hole). The recommended setup is to set the CSS custom property
|
|
858
|
+
* `--ring-inner-ratio` on the mesh element so the mask scales with the
|
|
859
|
+
* caller's chosen thickness ratio.
|
|
860
|
+
*/
|
|
861
|
+
|
|
862
|
+
interface RingQuadPolygonsOptions {
|
|
863
|
+
/** World axis the ring is perpendicular to: 0=X, 1=Y, 2=Z. The quad
|
|
864
|
+
* lies in the plane spanned by the other two axes. */
|
|
865
|
+
axis: 0 | 1 | 2;
|
|
866
|
+
/** Outer radius of the ring. The quad spans ±outerRadius in both
|
|
867
|
+
* in-plane axes. */
|
|
868
|
+
outerRadius: number;
|
|
869
|
+
/** Fill color. */
|
|
870
|
+
color?: string;
|
|
871
|
+
}
|
|
872
|
+
/** Build a single 4-vertex polygon (a square) bounding the ring's outer
|
|
873
|
+
* circle. CSS `mask` is expected to clip this to the donut shape at
|
|
874
|
+
* render time. */
|
|
875
|
+
declare function ringQuadPolygons(options: RingQuadPolygonsOptions): Polygon[];
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* A flat quad on one of the three axis-aligned planes, offset diagonally
|
|
879
|
+
* along the two in-plane axes. Used as a planar drag handle in
|
|
880
|
+
* `<PolyTransformControls>` — clicking and dragging this handle moves the
|
|
881
|
+
* attached mesh along two axes simultaneously (XY, XZ, or YZ), instead of
|
|
882
|
+
* the single-axis motion the arrow shafts provide.
|
|
883
|
+
*
|
|
884
|
+
* The polygon lives in standard PolyCSS world space; wrap it in the
|
|
885
|
+
* framework's PolyMesh equivalent for rendering.
|
|
886
|
+
*/
|
|
887
|
+
|
|
888
|
+
interface PlanePolygonsOptions {
|
|
889
|
+
/** Axis perpendicular to the plane: 0 = YZ plane, 1 = XZ plane,
|
|
890
|
+
* 2 = XY plane. The quad lies on the OTHER two axes. */
|
|
891
|
+
axis: 0 | 1 | 2;
|
|
892
|
+
/** Half-extent of the quad along each in-plane axis. Default `0.4`. */
|
|
893
|
+
size?: number;
|
|
894
|
+
/** Center of the quad along the two in-plane axes. Pass a single number
|
|
895
|
+
* to use the same offset on both (positive places the handle in the
|
|
896
|
+
* +A/+B corner). Pass `[offsetA, offsetB]` to control each
|
|
897
|
+
* independently — sign flips move the handle to a different octant.
|
|
898
|
+
* `A = (axis+1)%3`, `B = (axis+2)%3`. Default `size * 2`. */
|
|
899
|
+
offset?: number | [number, number];
|
|
900
|
+
/** Position along the perpendicular axis. Default `0` (on the plane). */
|
|
901
|
+
along?: number;
|
|
902
|
+
/** Fill color. */
|
|
903
|
+
color?: string;
|
|
904
|
+
}
|
|
905
|
+
/** Build the polygons for one axis-aligned planar drag handle. */
|
|
906
|
+
declare function planePolygons(options: PlanePolygonsOptions): Polygon[];
|
|
907
|
+
|
|
537
908
|
/**
|
|
538
909
|
* Geometry for a small solid-color octahedron — the marker shape used by
|
|
539
910
|
* `PolyDirectionalLightHelper` to indicate where a directional light is
|
|
@@ -551,6 +922,249 @@ interface OctahedronPolygonsOptions {
|
|
|
551
922
|
}
|
|
552
923
|
declare function octahedronPolygons(options: OctahedronPolygonsOptions): Polygon[];
|
|
553
924
|
|
|
925
|
+
/**
|
|
926
|
+
* Icosphere (subdivided icosahedron) geometry — approximates a sphere with
|
|
927
|
+
* triangular faces. Each subdivision step quadruples the face count:
|
|
928
|
+
* subdivisions 0 → 20, 1 → 80, 2 → 320, 3 → 1280 (capped).
|
|
929
|
+
*
|
|
930
|
+
* Vertex coordinates use PolyCSS world space: +X right, +Y forward, +Z up.
|
|
931
|
+
* The sphere is centered at the origin; all vertices sit at distance `radius`.
|
|
932
|
+
* Faces wind CCW from the outside (outward normal = away from origin).
|
|
933
|
+
*/
|
|
934
|
+
|
|
935
|
+
interface SpherePolygonsOptions {
|
|
936
|
+
/** Radius of the sphere. Default 50. */
|
|
937
|
+
radius?: number;
|
|
938
|
+
/** Subdivision level (0 = bare icosahedron, 20 triangles; each +1 quadruples count). Default 1 → 80 triangles. Cap at 3 (1280 triangles). */
|
|
939
|
+
subdivisions?: number;
|
|
940
|
+
/** Fill color applied to all faces. */
|
|
941
|
+
color?: string;
|
|
942
|
+
}
|
|
943
|
+
declare function spherePolygons(options?: SpherePolygonsOptions): Polygon[];
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Regular tetrahedron geometry — four equilateral triangular faces.
|
|
947
|
+
*
|
|
948
|
+
* Vertices are placed so the tetrahedron is centered at the origin.
|
|
949
|
+
* Faces wind CCW from the outside.
|
|
950
|
+
*
|
|
951
|
+
* PolyCSS world space: +X right, +Y forward, +Z up.
|
|
952
|
+
*/
|
|
953
|
+
|
|
954
|
+
interface TetrahedronPolygonsOptions {
|
|
955
|
+
/** Circumradius: distance from center to each vertex. Default 100. */
|
|
956
|
+
size?: number;
|
|
957
|
+
/** Fill color applied to all four faces. */
|
|
958
|
+
color?: string;
|
|
959
|
+
}
|
|
960
|
+
declare function tetrahedronPolygons(options?: TetrahedronPolygonsOptions): Polygon[];
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* Regular icosahedron geometry — 20 equilateral triangular faces.
|
|
964
|
+
*
|
|
965
|
+
* Vertices are placed on a sphere of radius `size` centered at the origin.
|
|
966
|
+
* Faces wind CCW from the outside.
|
|
967
|
+
*
|
|
968
|
+
* PolyCSS world space: +X right, +Y forward, +Z up.
|
|
969
|
+
*/
|
|
970
|
+
|
|
971
|
+
interface IcosahedronPolygonsOptions {
|
|
972
|
+
/** Circumradius: distance from center to each vertex. Default 100. */
|
|
973
|
+
size?: number;
|
|
974
|
+
/** Fill color applied to all 20 faces. */
|
|
975
|
+
color?: string;
|
|
976
|
+
}
|
|
977
|
+
declare function icosahedronPolygons(options?: IcosahedronPolygonsOptions): Polygon[];
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Regular dodecahedron geometry — 12 regular pentagonal faces.
|
|
981
|
+
*
|
|
982
|
+
* Vertices are placed on a sphere of radius `size` centered at the origin.
|
|
983
|
+
* Each face is a pentagon (5 vertices) wound CCW from the outside.
|
|
984
|
+
*
|
|
985
|
+
* All 12 pentagonal faces of a regular dodecahedron are truly planar — each
|
|
986
|
+
* lies on a single tangent plane. No triangulation is needed. The renderer
|
|
987
|
+
* uses <i> (border-shape) on Chromium and <s> elsewhere for non-quad polygons.
|
|
988
|
+
*
|
|
989
|
+
* PolyCSS world space: +X right, +Y forward, +Z up.
|
|
990
|
+
*/
|
|
991
|
+
|
|
992
|
+
interface DodecahedronPolygonsOptions {
|
|
993
|
+
/** Circumradius: distance from center to each vertex. Default 100. */
|
|
994
|
+
size?: number;
|
|
995
|
+
/** Fill color applied to all 12 faces. */
|
|
996
|
+
color?: string;
|
|
997
|
+
}
|
|
998
|
+
declare function dodecahedronPolygons(options?: DodecahedronPolygonsOptions): Polygon[];
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Z-axis cylinder geometry with optional radius taper.
|
|
1002
|
+
*
|
|
1003
|
+
* Geometry:
|
|
1004
|
+
* - `radialSegments` side faces (quads for cylinders/frustums, triangles
|
|
1005
|
+
* when one radius collapses to a cone tip).
|
|
1006
|
+
* - `radialSegments` bottom-cap triangles (fan from center).
|
|
1007
|
+
* - `radialSegments` top-cap triangles (fan from center), omitted when
|
|
1008
|
+
* radiusTop ≈ 0 (i.e. cone tip).
|
|
1009
|
+
*
|
|
1010
|
+
* The cylinder sits centered at the origin, spanning Z = −height/2 to
|
|
1011
|
+
* Z = +height/2. Side quads are axis-aligned in the cylinder's own local
|
|
1012
|
+
* frame, which maximises the chance of hitting the <b> quad fast-path.
|
|
1013
|
+
*
|
|
1014
|
+
* PolyCSS world space: +X right, +Y forward, +Z up. The cylinder axis is
|
|
1015
|
+
* the Z axis so a typical upright pillar stands without any extra rotation.
|
|
1016
|
+
*/
|
|
1017
|
+
|
|
1018
|
+
interface CylinderPolygonsOptions {
|
|
1019
|
+
/** Bottom-cap radius. Default 50. */
|
|
1020
|
+
radius?: number;
|
|
1021
|
+
/** Top-cap radius. Defaults to `radius` (straight cylinder).
|
|
1022
|
+
* Set to 0 (or near 0) for a cone. */
|
|
1023
|
+
radiusTop?: number;
|
|
1024
|
+
/** Height along the Z axis. Default 100. */
|
|
1025
|
+
height?: number;
|
|
1026
|
+
/** Number of radial segments. Default 12. */
|
|
1027
|
+
radialSegments?: number;
|
|
1028
|
+
/** Fill color applied to all polygons. */
|
|
1029
|
+
color?: string;
|
|
1030
|
+
}
|
|
1031
|
+
declare function cylinderPolygons(options?: CylinderPolygonsOptions): Polygon[];
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* Z-axis cone geometry — a cylinder with `radiusTop: 0`.
|
|
1035
|
+
*
|
|
1036
|
+
* This is a thin wrapper around `cylinderPolygons` with `radiusTop` forced
|
|
1037
|
+
* to zero. The top cap is omitted (no area at the tip), and side faces are
|
|
1038
|
+
* emitted as triangles.
|
|
1039
|
+
*
|
|
1040
|
+
* PolyCSS world space: +X right, +Y forward, +Z up. Cone axis is Z; the apex
|
|
1041
|
+
* is at Z = +height/2 and the base at Z = -height/2.
|
|
1042
|
+
*/
|
|
1043
|
+
|
|
1044
|
+
interface ConePolygonsOptions {
|
|
1045
|
+
/** Base radius. Default 50. */
|
|
1046
|
+
radius?: number;
|
|
1047
|
+
/** Height along the Z axis. Default 100. */
|
|
1048
|
+
height?: number;
|
|
1049
|
+
/** Number of radial segments. Default 12. */
|
|
1050
|
+
radialSegments?: number;
|
|
1051
|
+
/** Fill color applied to all polygons. */
|
|
1052
|
+
color?: string;
|
|
1053
|
+
}
|
|
1054
|
+
declare function conePolygons(options?: ConePolygonsOptions): Polygon[];
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Torus geometry — Z-axis ring plane.
|
|
1058
|
+
*
|
|
1059
|
+
* The torus is centered at the origin. The ring lies in the XY plane (the
|
|
1060
|
+
* ground plane in PolyCSS world space, where Z is up). The donut hole points
|
|
1061
|
+
* along the Z axis.
|
|
1062
|
+
*
|
|
1063
|
+
* Geometry: `radialSegments × tubularSegments` quads on the surface.
|
|
1064
|
+
*
|
|
1065
|
+
* DOM cost note: at default settings (12 × 16 = 192 quads) this is the
|
|
1066
|
+
* heaviest of the built-in primitives. Reduce radialSegments / tubularSegments
|
|
1067
|
+
* if render budget is tight.
|
|
1068
|
+
*
|
|
1069
|
+
* PolyCSS world space: +X right, +Y forward, +Z up.
|
|
1070
|
+
*/
|
|
1071
|
+
|
|
1072
|
+
interface TorusPolygonsOptions {
|
|
1073
|
+
/** Distance from center of tube to center of torus. Default 50. */
|
|
1074
|
+
radius?: number;
|
|
1075
|
+
/** Radius of the tube. Default 15. */
|
|
1076
|
+
tube?: number;
|
|
1077
|
+
/** Number of segments around the main ring. Default 12. */
|
|
1078
|
+
radialSegments?: number;
|
|
1079
|
+
/** Number of segments around the tube cross-section. Default 16. */
|
|
1080
|
+
tubularSegments?: number;
|
|
1081
|
+
/** Fill color applied to all polygons. */
|
|
1082
|
+
color?: string;
|
|
1083
|
+
}
|
|
1084
|
+
declare function torusPolygons(options?: TorusPolygonsOptions): Polygon[];
|
|
1085
|
+
|
|
1086
|
+
/** Tiny non-zero scale collapsed into the projection's Z column to keep
|
|
1087
|
+
* the matrix invertible. Chromium skips elements whose composed
|
|
1088
|
+
* transform is singular (m22 = 0 would make this a true projection
|
|
1089
|
+
* matrix, but Chromium would refuse to paint it), so we crush Z to 1%
|
|
1090
|
+
* of its input instead of exactly zero. The result still looks flat
|
|
1091
|
+
* to the eye — sub-pixel drift on any realistic scene size. */
|
|
1092
|
+
declare const BAKED_SHADOW_Z_SQUASH = 0.01;
|
|
1093
|
+
/** Minimum absolute value of the up-axis light component before the
|
|
1094
|
+
* projection blows up (we divide by it). Matches the --clz clamp in
|
|
1095
|
+
* the dynamic-mode applyDynamicLightVars helper so baked + dynamic
|
|
1096
|
+
* behave identically when the light is near-horizontal. */
|
|
1097
|
+
declare const BAKED_SHADOW_MIN_UP = 0.01;
|
|
1098
|
+
/**
|
|
1099
|
+
* Build the CSS-space shadow projection matrix for a fixed light + ground
|
|
1100
|
+
* plane. The 16-element output mirrors the matrix3d expression in the
|
|
1101
|
+
* dynamic-mode `--shadow-proj` CSS custom property, but with literal
|
|
1102
|
+
* numbers — ready to be formatted into a single `matrix3d(...)` per
|
|
1103
|
+
* shadow leaf.
|
|
1104
|
+
*
|
|
1105
|
+
* `lightDir` is the direction the light TRAVELS (e.g. `[0, 0, -1]` is
|
|
1106
|
+
* straight down). PolyCSS world Z is up, and the world→CSS axis swap
|
|
1107
|
+
* leaves Z alone — see styles.ts for the full convention.
|
|
1108
|
+
*
|
|
1109
|
+
* `groundCssZ` is the receiver plane in CSS-Z (= world-Z) coordinates,
|
|
1110
|
+
* already in unit-less form (matrix3d entries must be dimensionless).
|
|
1111
|
+
*/
|
|
1112
|
+
declare function buildBakedShadowProjectionMatrix(lightDir: Vec3, groundCssZ: number): number[];
|
|
1113
|
+
/**
|
|
1114
|
+
* Decides whether a polygon should cast a shadow given its outward
|
|
1115
|
+
* normal and the light's travel direction.
|
|
1116
|
+
*
|
|
1117
|
+
* True for polygons whose normals point in the same direction as the
|
|
1118
|
+
* light travels — i.e., on the far/dark side of the mesh from the
|
|
1119
|
+
* light's POV. Those define the silhouette of the cast shadow.
|
|
1120
|
+
*
|
|
1121
|
+
* False for front-facing polygons whose projection would land inside
|
|
1122
|
+
* the silhouette and only add overdraw. Dynamic mode hides these with
|
|
1123
|
+
* a Lambert opacity gate; baked mode skips the DOM emission entirely.
|
|
1124
|
+
*/
|
|
1125
|
+
declare function isBakedShadowCaster(normal: Vec3, lightDir: Vec3): boolean;
|
|
1126
|
+
/**
|
|
1127
|
+
* 2D convex hull (Andrew's monotone chain, O(n log n)). Returns the
|
|
1128
|
+
* hull vertices in CCW order. Used to compute a receiver mesh's XY
|
|
1129
|
+
* footprint when subtracting it from the global ground shadow.
|
|
1130
|
+
*/
|
|
1131
|
+
declare function convexHull2D(points: ReadonlyArray<readonly [number, number]>): Array<[number, number]>;
|
|
1132
|
+
/**
|
|
1133
|
+
* Signed area of a 2D polygon (positive for CCW vertex order, negative
|
|
1134
|
+
* for CW). Used by `ensureCcw2D` to normalize winding before concatenating
|
|
1135
|
+
* polygons into a compound SVG path under `fill-rule="nonzero"`: mixed
|
|
1136
|
+
* CCW/CW subpaths would cancel each other's winding in the overlap
|
|
1137
|
+
* region and paint an unintended hole.
|
|
1138
|
+
*/
|
|
1139
|
+
declare function polygonSignedArea2D(vertices: ReadonlyArray<readonly [number, number]>): number;
|
|
1140
|
+
/**
|
|
1141
|
+
* Returns the polygon's vertices in CCW order, reversing if necessary.
|
|
1142
|
+
* Operates on a copy — input is left unmodified.
|
|
1143
|
+
*/
|
|
1144
|
+
declare function ensureCcw2D(vertices: ReadonlyArray<readonly [number, number]>): Array<[number, number]>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Projects a single CSS-3D vertex onto the shadow ground plane, returning
|
|
1147
|
+
* the resulting 2D point in CSS coordinates. Mirrors the per-element
|
|
1148
|
+
* matrix3d that the dynamic-mode `--shadow-proj` builds, but evaluated on
|
|
1149
|
+
* the CPU for a fixed light + ground — handy when many projected vertices
|
|
1150
|
+
* are needed at once (e.g. rendering shadow outlines into a single SVG
|
|
1151
|
+
* per mesh instead of one DOM leaf per casting polygon).
|
|
1152
|
+
*
|
|
1153
|
+
* `cssVertex` is a 3D point that has already been through the world→CSS
|
|
1154
|
+
* axis swap and unit scale (so its components are dimensionless CSS-space
|
|
1155
|
+
* coordinates). `lightDir` follows the same `--clx/--cly/--clz` convention
|
|
1156
|
+
* as `buildBakedShadowProjectionMatrix`.
|
|
1157
|
+
*/
|
|
1158
|
+
declare function projectCssVertexToGround(cssVertex: Vec3, lightDir: Vec3, groundCssZ: number): [number, number];
|
|
1159
|
+
|
|
1160
|
+
type Pt = readonly [number, number];
|
|
1161
|
+
/**
|
|
1162
|
+
* Clips `subject` against the convex polygon `clip`. Both polygons are
|
|
1163
|
+
* 2D, given in CCW vertex order. Returns the clipped polygon as a new
|
|
1164
|
+
* array of points; an empty array means `subject` lies entirely outside.
|
|
1165
|
+
*/
|
|
1166
|
+
declare function clipPolygonToConvex2D(subject: ReadonlyArray<Pt>, clip: ReadonlyArray<Pt>): Array<[number, number]>;
|
|
1167
|
+
|
|
554
1168
|
/**
|
|
555
1169
|
* Unified parser return type. All polygon-emitting parsers (parseObj,
|
|
556
1170
|
* parseGltf, the loadMesh dispatcher) return this exact shape.
|
|
@@ -563,6 +1177,22 @@ declare function octahedronPolygons(options: OctahedronPolygonsOptions): Polygon
|
|
|
563
1177
|
* is empty (e.g. `parseObj`, where it's a no-op).
|
|
564
1178
|
*/
|
|
565
1179
|
|
|
1180
|
+
interface PolyVoxelCell {
|
|
1181
|
+
x: number;
|
|
1182
|
+
y: number;
|
|
1183
|
+
z: number;
|
|
1184
|
+
color: string;
|
|
1185
|
+
}
|
|
1186
|
+
interface PolyVoxelSource {
|
|
1187
|
+
kind: "magica-vox";
|
|
1188
|
+
cells: PolyVoxelCell[];
|
|
1189
|
+
rows: number;
|
|
1190
|
+
cols: number;
|
|
1191
|
+
depth: number;
|
|
1192
|
+
scale: number;
|
|
1193
|
+
gridShift: number;
|
|
1194
|
+
sourceBytes: number;
|
|
1195
|
+
}
|
|
566
1196
|
interface ParseAnimationClip {
|
|
567
1197
|
/** Stable numeric index in the source file's animation array. */
|
|
568
1198
|
index: number;
|
|
@@ -585,6 +1215,8 @@ interface ParseAnimationController {
|
|
|
585
1215
|
interface ParseResult {
|
|
586
1216
|
/** The mesh, as a flat polygon list. Already vertex-permuted to polycss space. */
|
|
587
1217
|
polygons: Polygon[];
|
|
1218
|
+
/** Optional raw voxel source for `.vox` fast paths; polygon fallback remains authoritative. */
|
|
1219
|
+
voxelSource?: PolyVoxelSource;
|
|
588
1220
|
/** Optional animation sampler for formats that carry timeline data. */
|
|
589
1221
|
animation?: ParseAnimationController;
|
|
590
1222
|
/**
|
|
@@ -616,6 +1248,8 @@ interface ParseResult {
|
|
|
616
1248
|
animations?: ParseAnimationClip[];
|
|
617
1249
|
/** Source file size in bytes (for diagnostics). */
|
|
618
1250
|
sourceBytes?: number;
|
|
1251
|
+
/** Voxel count for `.vox` sources. */
|
|
1252
|
+
voxelCount?: number;
|
|
619
1253
|
};
|
|
620
1254
|
}
|
|
621
1255
|
|
|
@@ -723,6 +1357,12 @@ interface PolyAnimationMixer {
|
|
|
723
1357
|
}
|
|
724
1358
|
declare function createPolyAnimationMixer(root: PolyAnimationTarget, controller: ParseAnimationController): PolyAnimationMixer;
|
|
725
1359
|
|
|
1360
|
+
interface OptimizeAnimatedMeshPolygonsOptions {
|
|
1361
|
+
/** Public quality/resolution intent. Defaults to "lossy". */
|
|
1362
|
+
meshResolution?: MeshResolution;
|
|
1363
|
+
}
|
|
1364
|
+
declare function optimizeAnimatedMeshPolygons(result: ParseResult, options?: OptimizeAnimatedMeshPolygonsOptions): ParseResult;
|
|
1365
|
+
|
|
726
1366
|
interface ObjParseOptions {
|
|
727
1367
|
/**
|
|
728
1368
|
* Largest mesh extent (in scene-space units). The mesh is uniformly
|
|
@@ -810,10 +1450,16 @@ interface GltfParseOptions {
|
|
|
810
1450
|
* material's `pbrMetallicRoughness.baseColorFactor` if not in this map.
|
|
811
1451
|
*/
|
|
812
1452
|
materialColors?: Record<string, string>;
|
|
1453
|
+
/**
|
|
1454
|
+
* Override map: glTF material name → texture image URL. Takes priority over
|
|
1455
|
+
* `pbrMetallicRoughness.baseColorTexture`; useful for GLB/GLTF exports that
|
|
1456
|
+
* preserved UVs but dropped external image references.
|
|
1457
|
+
*/
|
|
1458
|
+
materialTextures?: Record<string, string>;
|
|
813
1459
|
/**
|
|
814
1460
|
* Which axis is "up" in the source mesh.
|
|
815
1461
|
* - "y" (default, glTF spec): cyclic permutation (x,y,z) → (z,x,y) so
|
|
816
|
-
* +Y ends up on
|
|
1462
|
+
* +Y ends up on PolyCSS's +Z (elevation).
|
|
817
1463
|
* - "z" (Blender-style, FBX2glTF often emits this): identity, no swap.
|
|
818
1464
|
* Pick "z" if the model lands on its side / lies down instead of
|
|
819
1465
|
* standing.
|
|
@@ -851,8 +1497,9 @@ declare function bakeSolidTextureSamples(result: ParseResult, options?: SolidTex
|
|
|
851
1497
|
|
|
852
1498
|
interface VoxParseOptions {
|
|
853
1499
|
/**
|
|
854
|
-
* Largest mesh extent (in scene-space units).
|
|
855
|
-
*
|
|
1500
|
+
* Largest mesh extent (in scene-space units). For `.vox`, the requested
|
|
1501
|
+
* extent is snapped to the nearest integer CSS cell size to keep voxel
|
|
1502
|
+
* fast-path coordinates integral. Default: 60.
|
|
856
1503
|
*/
|
|
857
1504
|
targetSize?: number;
|
|
858
1505
|
/**
|
|
@@ -861,6 +1508,19 @@ interface VoxParseOptions {
|
|
|
861
1508
|
* non-negative integers so zero makes sensible default.
|
|
862
1509
|
*/
|
|
863
1510
|
gridShift?: number;
|
|
1511
|
+
/**
|
|
1512
|
+
* Optional lossy palette simplification. When > 0, opaque, hue-compatible
|
|
1513
|
+
* palette colors within this RGB distance are folded into the most-used
|
|
1514
|
+
* nearby color before greedy voxel meshing. Default: disabled.
|
|
1515
|
+
*/
|
|
1516
|
+
paletteMergeDistance?: number;
|
|
1517
|
+
/**
|
|
1518
|
+
* Optional lossy local cleanup. When > 0, small face-plane color islands
|
|
1519
|
+
* and thin streaks are recolored to a neighboring dominant hue-compatible
|
|
1520
|
+
* color within this RGB distance before greedy voxel meshing. Default:
|
|
1521
|
+
* disabled.
|
|
1522
|
+
*/
|
|
1523
|
+
colorRegionMergeDistance?: number;
|
|
864
1524
|
}
|
|
865
1525
|
declare function parseVox(buffer: ArrayBuffer, options?: VoxParseOptions): ParseResult;
|
|
866
1526
|
|
|
@@ -908,7 +1568,521 @@ interface LoadMeshOptions {
|
|
|
908
1568
|
* low-poly models that use texture atlases as color swatches.
|
|
909
1569
|
*/
|
|
910
1570
|
solidTextureSamples?: boolean | SolidTextureSampleOptions;
|
|
1571
|
+
/**
|
|
1572
|
+
* Mesh optimization intent. Defaults to "lossy"; set "lossless" to keep
|
|
1573
|
+
* exact planar candidates only.
|
|
1574
|
+
*/
|
|
1575
|
+
meshResolution?: MeshResolution;
|
|
911
1576
|
}
|
|
912
1577
|
declare function loadMesh(url: string, options?: LoadMeshOptions): Promise<ParseResult>;
|
|
913
1578
|
|
|
914
|
-
|
|
1579
|
+
declare const DEFAULT_TILE = 50;
|
|
1580
|
+
declare const DEFAULT_LIGHT_DIR: Vec3;
|
|
1581
|
+
declare const DEFAULT_LIGHT_COLOR = "#ffffff";
|
|
1582
|
+
declare const DEFAULT_LIGHT_INTENSITY = 1;
|
|
1583
|
+
declare const DEFAULT_AMBIENT_COLOR = "#ffffff";
|
|
1584
|
+
declare const DEFAULT_AMBIENT_INTENSITY = 0.4;
|
|
1585
|
+
declare const ATLAS_MAX_SIZE = 4096;
|
|
1586
|
+
declare const ATLAS_PADDING = 1;
|
|
1587
|
+
declare const MIN_ATLAS_SCALE = 0.1;
|
|
1588
|
+
declare const MAX_ATLAS_SCALE = 1;
|
|
1589
|
+
declare const AUTO_ATLAS_LOW_AREA: number;
|
|
1590
|
+
declare const AUTO_ATLAS_MEDIUM_AREA: number;
|
|
1591
|
+
declare const AUTO_ATLAS_MAX_BITMAP_SIDE = 2048;
|
|
1592
|
+
declare const AUTO_ATLAS_MAX_DECODED_BYTES_MOBILE: number;
|
|
1593
|
+
declare const AUTO_ATLAS_MAX_DECODED_BYTES_DESKTOP: number;
|
|
1594
|
+
declare const AUTO_ATLAS_SCALE_GUARD = 0.995;
|
|
1595
|
+
declare const COLOR_PARSE_CACHE_MAX = 512;
|
|
1596
|
+
declare const ASYNC_RENDER_BUDGET_MS = 12;
|
|
1597
|
+
declare const RECT_EPS = 0.001;
|
|
1598
|
+
declare const BASIS_EPS = 1e-9;
|
|
1599
|
+
declare const SURFACE_NORMAL_EPS = 0.0001;
|
|
1600
|
+
declare const SURFACE_DISTANCE_EPS = 0.1;
|
|
1601
|
+
declare const SEAM_LIGHT_EPS = 0.01;
|
|
1602
|
+
declare const TEXTURE_TRIANGLE_BLEED = 0.75;
|
|
1603
|
+
declare const TEXTURE_EDGE_REPAIR_ALPHA_MIN = 1;
|
|
1604
|
+
declare const TEXTURE_EDGE_REPAIR_SOURCE_ALPHA_MIN = 250;
|
|
1605
|
+
declare const TEXTURE_EDGE_REPAIR_RADIUS = 1.5;
|
|
1606
|
+
declare const SOLID_TRIANGLE_BLEED = 0.75;
|
|
1607
|
+
declare const DEFAULT_MATRIX_DECIMALS = 3;
|
|
1608
|
+
declare const DEFAULT_BORDER_SHAPE_DECIMALS = 2;
|
|
1609
|
+
declare const DEFAULT_ATLAS_CSS_DECIMALS = 4;
|
|
1610
|
+
declare const DECIMAL_SCALES: number[];
|
|
1611
|
+
declare const SOLID_QUAD_CANONICAL_SIZE = 64;
|
|
1612
|
+
declare const SOLID_TRIANGLE_CANONICAL_SIZE = 32;
|
|
1613
|
+
declare const SOLID_TRIANGLE_LARGE_BORDER_CANONICAL_SIZE = 96;
|
|
1614
|
+
declare const SOLID_TRIANGLE_CORNER_CLASS = "polycss-corner-triangle";
|
|
1615
|
+
declare const SOLID_TRIANGLE_LARGE_BORDER_CLASS = "polycss-large-border-triangle";
|
|
1616
|
+
declare const ATLAS_CANONICAL_SIZE_EXPLICIT = 64;
|
|
1617
|
+
declare const ATLAS_CANONICAL_SIZE_AUTO_DESKTOP = 128;
|
|
1618
|
+
declare const BORDER_SHAPE_CENTER_PERCENT = 50;
|
|
1619
|
+
declare const BORDER_SHAPE_POINT_EPS = 1e-7;
|
|
1620
|
+
declare const BORDER_SHAPE_CANONICAL_SIZE = 16;
|
|
1621
|
+
declare const BORDER_SHAPE_BLEED = 0.9;
|
|
1622
|
+
declare const CORNER_SHAPE_POINT_EPS = 0.75;
|
|
1623
|
+
declare const CORNER_SHAPE_DUPLICATE_EPS = 0.2;
|
|
1624
|
+
declare const PROJECTIVE_QUAD_DENOM_EPS = 0.05;
|
|
1625
|
+
declare const PROJECTIVE_QUAD_MAX_WEIGHT_RATIO = 256;
|
|
1626
|
+
declare const PROJECTIVE_QUAD_BLEED = 0.6;
|
|
1627
|
+
declare const DEFAULT_SEAM_BLEED = 1.5;
|
|
1628
|
+
|
|
1629
|
+
interface RGB {
|
|
1630
|
+
r: number;
|
|
1631
|
+
g: number;
|
|
1632
|
+
b: number;
|
|
1633
|
+
}
|
|
1634
|
+
interface RGBFactors {
|
|
1635
|
+
r: number;
|
|
1636
|
+
g: number;
|
|
1637
|
+
b: number;
|
|
1638
|
+
}
|
|
1639
|
+
interface UvAffine {
|
|
1640
|
+
a: number;
|
|
1641
|
+
b: number;
|
|
1642
|
+
c: number;
|
|
1643
|
+
d: number;
|
|
1644
|
+
e: number;
|
|
1645
|
+
f: number;
|
|
1646
|
+
}
|
|
1647
|
+
interface UvSampleRect {
|
|
1648
|
+
minU: number;
|
|
1649
|
+
minV: number;
|
|
1650
|
+
maxU: number;
|
|
1651
|
+
maxV: number;
|
|
1652
|
+
}
|
|
1653
|
+
interface TextureTrianglePlan {
|
|
1654
|
+
screenPts: number[];
|
|
1655
|
+
uvAffine: UvAffine | null;
|
|
1656
|
+
uvSampleRect: UvSampleRect | null;
|
|
1657
|
+
}
|
|
1658
|
+
interface TextureAtlasPlan {
|
|
1659
|
+
index: number;
|
|
1660
|
+
polygon: Polygon;
|
|
1661
|
+
texture?: string;
|
|
1662
|
+
tileSize: number;
|
|
1663
|
+
layerElevation: number;
|
|
1664
|
+
matrix: string;
|
|
1665
|
+
canonicalMatrix: string;
|
|
1666
|
+
atlasMatrix: string;
|
|
1667
|
+
atlasCanonicalSize?: number;
|
|
1668
|
+
projectiveMatrix: string | null;
|
|
1669
|
+
canvasW: number;
|
|
1670
|
+
canvasH: number;
|
|
1671
|
+
screenPts: number[];
|
|
1672
|
+
uvAffine: UvAffine | null;
|
|
1673
|
+
uvSampleRect: UvSampleRect | null;
|
|
1674
|
+
textureTriangles: TextureTrianglePlan[] | null;
|
|
1675
|
+
textureEdgeRepairEdges: Set<number> | null;
|
|
1676
|
+
textureEdgeRepair: boolean;
|
|
1677
|
+
seamBleed?: number;
|
|
1678
|
+
seamBleedEdges?: Set<number>;
|
|
1679
|
+
seamBleedEdgeAmounts?: Map<number, number>;
|
|
1680
|
+
seamBleedInsets?: SeamBleedInsets;
|
|
1681
|
+
/** World-space surface normal — stable across light changes, used by dynamic mode. */
|
|
1682
|
+
normal: Vec3;
|
|
1683
|
+
textureTint: RGBFactors;
|
|
1684
|
+
shadedColor: string;
|
|
1685
|
+
}
|
|
1686
|
+
interface BorderShapeBounds {
|
|
1687
|
+
minX: number;
|
|
1688
|
+
minY: number;
|
|
1689
|
+
width: number;
|
|
1690
|
+
height: number;
|
|
1691
|
+
}
|
|
1692
|
+
interface BorderShapeGeometry {
|
|
1693
|
+
bounds: BorderShapeBounds;
|
|
1694
|
+
points: Array<[number, number]>;
|
|
1695
|
+
}
|
|
1696
|
+
type CornerShapeCorner = "topLeft" | "topRight" | "bottomRight" | "bottomLeft";
|
|
1697
|
+
type CornerShapeSide = "left" | "right" | "top" | "bottom";
|
|
1698
|
+
interface CornerShapeRadius {
|
|
1699
|
+
x: number;
|
|
1700
|
+
y: number;
|
|
1701
|
+
}
|
|
1702
|
+
interface CornerShapeGeometry {
|
|
1703
|
+
bounds: BorderShapeBounds;
|
|
1704
|
+
radii: Partial<Record<CornerShapeCorner, CornerShapeRadius>>;
|
|
1705
|
+
}
|
|
1706
|
+
type TextureQuality = number | "auto";
|
|
1707
|
+
type PolySeamBleed = number | "auto";
|
|
1708
|
+
type PolySeamBleedEdgeValue = ReadonlySet<number> | ReadonlyMap<number, number>;
|
|
1709
|
+
type PolySeamBleedEdges = ReadonlyMap<number, PolySeamBleedEdgeValue> | readonly (PolySeamBleedEdgeValue | undefined)[];
|
|
1710
|
+
type PolyRenderStrategy = "b" | "i" | "u";
|
|
1711
|
+
type SolidTrianglePrimitive = "border" | "border-large" | "corner-bevel";
|
|
1712
|
+
interface PolyRenderStrategiesOption {
|
|
1713
|
+
/** Strategies to skip; polygons that would normally use them fall through
|
|
1714
|
+
* the chain (b → i → s, u → i → s, i → s). `<s>` is the universal
|
|
1715
|
+
* fallback and cannot be disabled — textured polys have no other path. */
|
|
1716
|
+
disable?: readonly PolyRenderStrategy[];
|
|
1717
|
+
}
|
|
1718
|
+
interface SeamBleedInsets {
|
|
1719
|
+
left: number;
|
|
1720
|
+
right: number;
|
|
1721
|
+
top: number;
|
|
1722
|
+
bottom: number;
|
|
1723
|
+
}
|
|
1724
|
+
interface PackedTextureAtlasEntry extends TextureAtlasPlan {
|
|
1725
|
+
pageIndex: number;
|
|
1726
|
+
x: number;
|
|
1727
|
+
y: number;
|
|
1728
|
+
}
|
|
1729
|
+
interface PackedPage {
|
|
1730
|
+
width: number;
|
|
1731
|
+
height: number;
|
|
1732
|
+
entries: PackedTextureAtlasEntry[];
|
|
1733
|
+
}
|
|
1734
|
+
interface PackingShelf {
|
|
1735
|
+
x: number;
|
|
1736
|
+
y: number;
|
|
1737
|
+
height: number;
|
|
1738
|
+
}
|
|
1739
|
+
interface PackingPage extends PackedPage {
|
|
1740
|
+
shelves: PackingShelf[];
|
|
1741
|
+
sealed?: boolean;
|
|
1742
|
+
}
|
|
1743
|
+
interface PackedAtlas {
|
|
1744
|
+
entries: Array<PackedTextureAtlasEntry | null>;
|
|
1745
|
+
pages: PackedPage[];
|
|
1746
|
+
}
|
|
1747
|
+
interface SolidTriangleBasis {
|
|
1748
|
+
a: number;
|
|
1749
|
+
b: number;
|
|
1750
|
+
c: number;
|
|
1751
|
+
}
|
|
1752
|
+
interface SolidTriangleColorPlan {
|
|
1753
|
+
index: number;
|
|
1754
|
+
polygon: Polygon;
|
|
1755
|
+
colorComputed: boolean;
|
|
1756
|
+
bakedColor?: string;
|
|
1757
|
+
bakedRgb?: RGB;
|
|
1758
|
+
bakedAlpha?: number;
|
|
1759
|
+
dynamicVars?: string;
|
|
1760
|
+
}
|
|
1761
|
+
interface SolidTrianglePlan extends SolidTriangleColorPlan {
|
|
1762
|
+
styleText: string;
|
|
1763
|
+
transformText: string;
|
|
1764
|
+
basis: SolidTriangleBasis;
|
|
1765
|
+
primitive: SolidTrianglePrimitive;
|
|
1766
|
+
}
|
|
1767
|
+
interface SolidTriangleComputeOptions {
|
|
1768
|
+
basis?: SolidTriangleBasis;
|
|
1769
|
+
includeColor?: boolean;
|
|
1770
|
+
matrixDecimals?: number;
|
|
1771
|
+
color?: string;
|
|
1772
|
+
primitive?: SolidTrianglePrimitive;
|
|
1773
|
+
/** Pre-resolved primitive used when `primitive` is not set — replaces the
|
|
1774
|
+
* browser-global resolution that formerly happened inside the function. */
|
|
1775
|
+
resolvedPrimitive?: SolidTrianglePrimitive | null;
|
|
1776
|
+
}
|
|
1777
|
+
interface StableTriangleColorState {
|
|
1778
|
+
updatesDisabled: boolean;
|
|
1779
|
+
freezeFrames: number;
|
|
1780
|
+
colorFrame: number;
|
|
1781
|
+
maxStep: number;
|
|
1782
|
+
}
|
|
1783
|
+
interface SolidTriangleFrame {
|
|
1784
|
+
polygonCount: number;
|
|
1785
|
+
vertices: ArrayLike<number>;
|
|
1786
|
+
colors?: readonly (string | undefined)[];
|
|
1787
|
+
}
|
|
1788
|
+
interface SolidPaintDefaults {
|
|
1789
|
+
paintColor?: string;
|
|
1790
|
+
dynamicColor?: {
|
|
1791
|
+
r: number;
|
|
1792
|
+
g: number;
|
|
1793
|
+
b: number;
|
|
1794
|
+
};
|
|
1795
|
+
dynamicColorKey?: string;
|
|
1796
|
+
}
|
|
1797
|
+
interface TextureAtlasPage {
|
|
1798
|
+
width: number;
|
|
1799
|
+
height: number;
|
|
1800
|
+
url: string | null;
|
|
1801
|
+
}
|
|
1802
|
+
interface RectBrush {
|
|
1803
|
+
left: number;
|
|
1804
|
+
top: number;
|
|
1805
|
+
width: number;
|
|
1806
|
+
height: number;
|
|
1807
|
+
}
|
|
1808
|
+
interface LocalBasis {
|
|
1809
|
+
xAxis: Vec3;
|
|
1810
|
+
yAxis: Vec3;
|
|
1811
|
+
local2D: Vec2[];
|
|
1812
|
+
shiftX: number;
|
|
1813
|
+
shiftY: number;
|
|
1814
|
+
canvasW: number;
|
|
1815
|
+
canvasH: number;
|
|
1816
|
+
pixelArea: number;
|
|
1817
|
+
rawArea: number;
|
|
1818
|
+
}
|
|
1819
|
+
interface BasisOptions {
|
|
1820
|
+
optimize: boolean;
|
|
1821
|
+
fixedXAxis?: Vec3;
|
|
1822
|
+
boundsOrigin?: Vec3;
|
|
1823
|
+
snapBounds?: boolean;
|
|
1824
|
+
seamEdges?: Set<number>;
|
|
1825
|
+
}
|
|
1826
|
+
interface BasisHint {
|
|
1827
|
+
xAxis?: Vec3;
|
|
1828
|
+
boundsOrigin?: Vec3;
|
|
1829
|
+
seamEdges: Set<number>;
|
|
1830
|
+
textureEdgeRepairEdges?: Set<number>;
|
|
1831
|
+
}
|
|
1832
|
+
interface PolygonBasisInfo {
|
|
1833
|
+
pts: Vec3[];
|
|
1834
|
+
normal: Vec3;
|
|
1835
|
+
planeD: number;
|
|
1836
|
+
optimizable: boolean;
|
|
1837
|
+
}
|
|
1838
|
+
interface ProjectiveQuadGuardSettings {
|
|
1839
|
+
denomEps: number;
|
|
1840
|
+
maxWeightRatio: number;
|
|
1841
|
+
bleed: number;
|
|
1842
|
+
disableGuards: boolean;
|
|
1843
|
+
}
|
|
1844
|
+
interface ProjectiveQuadGuardOverrides {
|
|
1845
|
+
denomEps?: number;
|
|
1846
|
+
maxWeightRatio?: number;
|
|
1847
|
+
bleed?: number;
|
|
1848
|
+
disableGuards?: boolean;
|
|
1849
|
+
}
|
|
1850
|
+
interface ProjectiveQuadGuardGlobal {
|
|
1851
|
+
__polycssProjectiveQuadGuards?: ProjectiveQuadGuardOverrides;
|
|
1852
|
+
}
|
|
1853
|
+
interface ProjectiveQuadCoefficients {
|
|
1854
|
+
g: number;
|
|
1855
|
+
h: number;
|
|
1856
|
+
w1: number;
|
|
1857
|
+
w3: number;
|
|
1858
|
+
}
|
|
1859
|
+
interface StablePlanBasis {
|
|
1860
|
+
normal: Vec3;
|
|
1861
|
+
xAxis: Vec3;
|
|
1862
|
+
yAxis: Vec3;
|
|
1863
|
+
tx: number;
|
|
1864
|
+
ty: number;
|
|
1865
|
+
tz: number;
|
|
1866
|
+
}
|
|
1867
|
+
/** Options for solidTrianglePlan computation — the pure-math subset of
|
|
1868
|
+
* RenderTextureAtlasOptions with no DOM reference. */
|
|
1869
|
+
interface SolidTrianglePlanOptions {
|
|
1870
|
+
tileSize?: number;
|
|
1871
|
+
layerElevation?: number;
|
|
1872
|
+
directionalLight?: PolyDirectionalLight;
|
|
1873
|
+
ambientLight?: PolyAmbientLight;
|
|
1874
|
+
textureLighting?: PolyTextureLightingMode;
|
|
1875
|
+
solidPaintDefaults?: SolidPaintDefaults;
|
|
1876
|
+
strategies?: PolyRenderStrategiesOption;
|
|
1877
|
+
seamBleed?: PolySeamBleed;
|
|
1878
|
+
seamEdges?: Set<number>;
|
|
1879
|
+
}
|
|
1880
|
+
/** Internal solid-triangle plan options (extends SolidTrianglePlanOptions). */
|
|
1881
|
+
interface InternalSolidTrianglePlanOptions extends SolidTrianglePlanOptions {
|
|
1882
|
+
optimizeStableTriangleStyle?: boolean;
|
|
1883
|
+
stableTriangleColorSteps?: number;
|
|
1884
|
+
stableTriangleMatrixDecimals?: number;
|
|
1885
|
+
}
|
|
1886
|
+
/** Options accepted by the public {@link computeTextureAtlasPlanPublic} wrapper. */
|
|
1887
|
+
interface ComputeTextureAtlasPlanOptions {
|
|
1888
|
+
tileSize?: number;
|
|
1889
|
+
layerElevation?: number;
|
|
1890
|
+
directionalLight?: PolyDirectionalLight;
|
|
1891
|
+
ambientLight?: PolyAmbientLight;
|
|
1892
|
+
/** Shared-edge set returned by {@link buildTextureEdgeRepairSets}. */
|
|
1893
|
+
textureEdgeRepairEdges?: Set<number>;
|
|
1894
|
+
seamBleed?: PolySeamBleed;
|
|
1895
|
+
seamEdges?: Set<number>;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
declare function roundDecimal(value: number, decimals: number): string;
|
|
1899
|
+
declare function formatCssLength(value: number, decimals?: number): string;
|
|
1900
|
+
declare function formatMatrix3dValues(values: readonly number[], decimals?: number): string;
|
|
1901
|
+
declare function formatAffineMatrix3dColumns(xCol: Vec3, yCol: Vec3, zCol: Vec3, txCol: Vec3, decimals?: number): string;
|
|
1902
|
+
declare function formatAffineMatrix3dScalars(x0: number, x1: number, x2: number, y0: number, y1: number, y2: number, z0: number, z1: number, z2: number, tx0: number, tx1: number, tx2: number, decimals?: number): string;
|
|
1903
|
+
declare function formatAffineMatrix3dTransformScalars(x0: number, x1: number, x2: number, y0: number, y1: number, y2: number, z0: number, z1: number, z2: number, tx0: number, tx1: number, tx2: number, decimals?: number): string;
|
|
1904
|
+
declare function formatScaledMatrixFromPlan(entry: TextureAtlasPlan, scaleX: number, scaleY: number, offsetX?: number, offsetY?: number): string;
|
|
1905
|
+
declare function formatBorderShapeMatrix(entry: TextureAtlasPlan, bounds: BorderShapeBounds): string;
|
|
1906
|
+
declare function formatSolidQuadMatrix(entry: TextureAtlasPlan): string;
|
|
1907
|
+
declare function formatAtlasMatrix(entry: TextureAtlasPlan, atlasCanonicalSize: number): string;
|
|
1908
|
+
declare function formatPercent(value: number, decimals?: number): string;
|
|
1909
|
+
/** Format a raw comma-separated matrix3d value string with rounded decimals. */
|
|
1910
|
+
declare function formatMatrix3d(matrix: string, decimals?: number): string;
|
|
1911
|
+
/** Format a pixel CSS length value. */
|
|
1912
|
+
declare function formatCssLengthPx(value: number, decimals?: number): string;
|
|
1913
|
+
/**
|
|
1914
|
+
* Produce the CSS matrix3d transform for a solid-quad (`<b>`) leaf, including
|
|
1915
|
+
* the canonical 64px primitive scale.
|
|
1916
|
+
*/
|
|
1917
|
+
declare function formatSolidQuadEntryMatrix(entry: TextureAtlasPlan): string;
|
|
1918
|
+
|
|
1919
|
+
declare function buildTextureEdgeRepairSets(polygons: Polygon[]): Array<Set<number> | undefined>;
|
|
1920
|
+
declare function resolveSeamBleed(value: unknown, fallback: number): number;
|
|
1921
|
+
declare function normalizedSeamBleed(value: unknown): number | undefined;
|
|
1922
|
+
declare function safePlanSeamBleedAmount(screenPts: number[], edgeIndex: number, requested: number): number;
|
|
1923
|
+
declare function computePlanSeamBleedEdgeAmounts(screenPts: number[], seamEdges: ReadonlySet<number> | undefined, seamBleed: number | undefined): Map<number, number> | undefined;
|
|
1924
|
+
declare function seamBleedAmountArray(vertexCount: number, edgeAmounts: ReadonlyMap<number, number> | undefined): number[] | null;
|
|
1925
|
+
declare function computeSeamBleedInsets(screenPts: number[], edgeAmounts: ReadonlyMap<number, number> | undefined): SeamBleedInsets | undefined;
|
|
1926
|
+
interface SeamBleedDetectionOptions {
|
|
1927
|
+
tileSize?: number;
|
|
1928
|
+
layerElevation?: number;
|
|
1929
|
+
directionalLight?: unknown;
|
|
1930
|
+
ambientLight?: unknown;
|
|
1931
|
+
}
|
|
1932
|
+
declare function buildSeamBleedPolygonSet(polygons: Polygon[], options?: SeamBleedDetectionOptions): Set<number>;
|
|
1933
|
+
declare function buildSeamBleedPolygonEdges(polygons: Polygon[], options?: SeamBleedDetectionOptions): Map<number, Set<number>>;
|
|
1934
|
+
|
|
1935
|
+
type PureColorParseResult = ReturnType<typeof parsePureColor>;
|
|
1936
|
+
declare function cachedParsePureColor(input: string): PureColorParseResult;
|
|
1937
|
+
declare function parseHex(hex: string): RGB;
|
|
1938
|
+
declare function rgbKey({ r, g, b }: RGB): string;
|
|
1939
|
+
/** Returns the parsed alpha for a color string (1.0 default). */
|
|
1940
|
+
declare function parseAlpha(input: string): number;
|
|
1941
|
+
declare function rgbToHex({ r, g, b }: RGB): string;
|
|
1942
|
+
declare function textureTintFactors(directScale: number, lightColor: string, ambientColor: string, ambientIntensity: number): RGBFactors;
|
|
1943
|
+
declare function tintToCss({ r, g, b }: RGBFactors): string;
|
|
1944
|
+
declare function shadePolygon(baseColor: string, directScale: number, lightColor: string, ambientColor: string, ambientIntensity: number): string;
|
|
1945
|
+
declare function quantizeCssColor(input: string, steps: number): string;
|
|
1946
|
+
declare function rgbEqual(a: RGB | undefined, b: RGB | undefined): boolean;
|
|
1947
|
+
declare function stepRgbToward(current: RGB, target: RGB, maxStep: number): RGB;
|
|
1948
|
+
declare function rgbToCss(rgb: RGB, alpha?: number): string;
|
|
1949
|
+
declare function colorErrorScore(current: string | undefined, next: string): number;
|
|
1950
|
+
|
|
1951
|
+
declare function fullRectBounds(entry: TextureAtlasPlan): {
|
|
1952
|
+
left: number;
|
|
1953
|
+
top: number;
|
|
1954
|
+
width: number;
|
|
1955
|
+
height: number;
|
|
1956
|
+
} | null;
|
|
1957
|
+
declare function isFullRectSolid(entry: TextureAtlasPlan): boolean;
|
|
1958
|
+
declare function isSolidTrianglePlan(entry: TextureAtlasPlan): boolean;
|
|
1959
|
+
declare function isProjectiveQuadPlan(entry: TextureAtlasPlan): entry is TextureAtlasPlan & {
|
|
1960
|
+
projectiveMatrix: string;
|
|
1961
|
+
};
|
|
1962
|
+
declare function safariCssProjectiveUnsupported(userAgent: string): boolean;
|
|
1963
|
+
declare function incrementCount(map: Map<string, number>, key: string): void;
|
|
1964
|
+
declare function dominantCountKey(map: Map<string, number>): string | undefined;
|
|
1965
|
+
interface FilterAtlasPlansEnv {
|
|
1966
|
+
solidTriangleSupported: boolean;
|
|
1967
|
+
borderShapeSupported: boolean;
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Filter a plan array to the subset that needs atlas packing, given the active
|
|
1971
|
+
* render strategies and texture-lighting mode. Plans excluded from the atlas
|
|
1972
|
+
* will be rendered via `<b>`, `<i>`, or `<u>` by the framework components.
|
|
1973
|
+
*/
|
|
1974
|
+
declare function filterAtlasPlans(plans: Array<TextureAtlasPlan | null>, textureLighting: PolyTextureLightingMode, disabled: ReadonlySet<PolyRenderStrategy>, env: FilterAtlasPlansEnv): Array<TextureAtlasPlan | null>;
|
|
1975
|
+
interface GetSolidPaintDefaultsEnv {
|
|
1976
|
+
solidTriangleSupported: boolean;
|
|
1977
|
+
projectiveQuadSupported: boolean;
|
|
1978
|
+
cornerShapeSupported: boolean;
|
|
1979
|
+
borderShapeSupported: boolean;
|
|
1980
|
+
}
|
|
1981
|
+
declare function getSolidPaintDefaultsForPlansCore(plans: Array<TextureAtlasPlan | null>, textureLighting: PolyTextureLightingMode, disabled: ReadonlySet<PolyRenderStrategy>, env: GetSolidPaintDefaultsEnv, parseHexFn: (color: string) => RGB, rgbKeyFn: (rgb: RGB) => string, cornerShapeGeometryForPlanFn?: (plan: TextureAtlasPlan) => unknown): {
|
|
1982
|
+
paintColor?: string;
|
|
1983
|
+
dynamicColorKey?: string;
|
|
1984
|
+
dynamicColor?: RGB;
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1987
|
+
declare function cssPoints(vertices: Vec3[], tile: number, elev: number): Vec3[];
|
|
1988
|
+
declare function computeSurfaceNormal(pts: Vec3[]): Vec3 | null;
|
|
1989
|
+
declare function isConvexPolygonPoints(points: Array<[number, number]>): boolean;
|
|
1990
|
+
declare function signedArea2D(points: Array<[number, number]>): number;
|
|
1991
|
+
declare function intersect2DLines(a0: [number, number], a1: [number, number], b0: [number, number], b1: [number, number]): [number, number] | null;
|
|
1992
|
+
declare function intersect2DLinesRaw(a0x: number, a0y: number, a1x: number, a1y: number, b0x: number, b0y: number, b1x: number, b1y: number): Vec2 | null;
|
|
1993
|
+
declare function expandClipPoints(points: number[], amount: number): number[];
|
|
1994
|
+
declare function offsetConvexPolygonPoints(points: number[], amount: number): number[];
|
|
1995
|
+
declare function offsetConvexPolygonPointsByEdgeAmounts(points: number[], amounts: readonly number[]): number[];
|
|
1996
|
+
declare function offsetTrianglePoints(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, amount: number): number[];
|
|
1997
|
+
declare function offsetStableTrianglePoints(left: number, right: number, height: number, amount: number): number[];
|
|
1998
|
+
declare function stableBasisFromPlan(source: TextureAtlasPlan, polygon: Polygon): StablePlanBasis | null;
|
|
1999
|
+
declare function stableTriangleMatrixDecimals(matrixDecimals: number | undefined): number;
|
|
2000
|
+
|
|
2001
|
+
declare function polygonContainsPoint(points: Array<[number, number]>, px?: number, py?: number): boolean;
|
|
2002
|
+
declare function borderShapeBoundsFromPoints(points: number[], fallbackWidth: number, fallbackHeight: number): BorderShapeBounds;
|
|
2003
|
+
declare function borderShapeGeometryForPlan(entry: TextureAtlasPlan): BorderShapeGeometry;
|
|
2004
|
+
declare function simplifyCornerShapePoints(points: Array<[number, number]>): Array<[number, number]>;
|
|
2005
|
+
declare function cornerShapePointSides([x, y]: [number, number]): Set<CornerShapeSide> | null;
|
|
2006
|
+
declare function sharedCornerShapeSide(a: Set<CornerShapeSide>, b: Set<CornerShapeSide>): boolean;
|
|
2007
|
+
declare function cornerShapeDiagonal(aPoint: [number, number], aSides: Set<CornerShapeSide>, bPoint: [number, number], bSides: Set<CornerShapeSide>): [CornerShapeCorner, CornerShapeRadius] | null;
|
|
2008
|
+
declare function cornerShapeGeometryForPlan(entry: TextureAtlasPlan): CornerShapeGeometry | null;
|
|
2009
|
+
declare function cssBorderShapeForGeometry(points: Array<[number, number]>): string;
|
|
2010
|
+
declare function cssBorderShapeForPlan(entry: TextureAtlasPlan): string;
|
|
2011
|
+
declare function formatBorderShapeEntryMatrix(entry: TextureAtlasPlan): string;
|
|
2012
|
+
declare function formatBorderShapeElementStyle(entry: TextureAtlasPlan): string;
|
|
2013
|
+
declare function formatCornerShapeElementStyle(entry: TextureAtlasPlan, geometry: CornerShapeGeometry): string;
|
|
2014
|
+
|
|
2015
|
+
declare function computeSolidTriangleColorPlanFromNormal(polygon: Polygon, index: number, nx: number, ny: number, nz: number, options: SolidTrianglePlanOptions, includeColor: boolean, colorOverride?: string): SolidTriangleColorPlan;
|
|
2016
|
+
declare function computeSolidTriangleColorPlan(polygon: Polygon, index: number, options: SolidTrianglePlanOptions): SolidTriangleColorPlan | null;
|
|
2017
|
+
declare function computeSolidTrianglePlan(polygon: Polygon, index: number, options: SolidTrianglePlanOptions, computeOptions?: SolidTriangleComputeOptions): SolidTrianglePlan | null;
|
|
2018
|
+
declare function computeSolidTrianglePlanFromCssPoints(polygon: Polygon, index: number, options: SolidTrianglePlanOptions, computeOptions: SolidTriangleComputeOptions, p0x: number, p0y: number, p0z: number, p1x: number, p1y: number, p1z: number, p2x: number, p2y: number, p2z: number): SolidTrianglePlan | null;
|
|
2019
|
+
|
|
2020
|
+
declare function resolveProjectiveQuadGuards(overrides: ProjectiveQuadGuardOverrides | undefined): ProjectiveQuadGuardSettings;
|
|
2021
|
+
declare function computeProjectiveQuadCoefficients(q: Array<[number, number]>, guards: ProjectiveQuadGuardSettings): ProjectiveQuadCoefficients | null;
|
|
2022
|
+
declare function computeProjectiveQuadMatrix(screenPts: number[], xAxis: Vec3, yAxis: Vec3, normal: Vec3, tx: number, ty: number, tz: number, guards: ProjectiveQuadGuardSettings, seamBleedEdgeAmounts?: ReadonlyMap<number, number>): string | null;
|
|
2023
|
+
declare function dotVec(a: Vec3, b: Vec3): number;
|
|
2024
|
+
declare function crossVec(a: Vec3, b: Vec3): Vec3;
|
|
2025
|
+
declare function isBasisOptimizable(polygon: Polygon): boolean;
|
|
2026
|
+
declare function getPolygonBasisInfo(polygon: Polygon, tile: number, elev: number): PolygonBasisInfo | null;
|
|
2027
|
+
declare function compatibleSurface(a: PolygonBasisInfo | null, b: PolygonBasisInfo | null): boolean;
|
|
2028
|
+
declare function compatibleBleedSurface(a: PolygonBasisInfo | null, b: PolygonBasisInfo | null): boolean;
|
|
2029
|
+
declare function seamLightBrightness(info: PolygonBasisInfo | null, options: SolidTrianglePlanOptions): number | null;
|
|
2030
|
+
declare function basisAxisKey(axis: Vec3): string;
|
|
2031
|
+
declare function makeLocalBasis(pts: Vec3[], origin: Vec3, normal: Vec3, rawXAxis: Vec3, options?: {
|
|
2032
|
+
boundsOrigin?: Vec3;
|
|
2033
|
+
snapBounds?: boolean;
|
|
2034
|
+
}): LocalBasis | null;
|
|
2035
|
+
declare function evaluateIslandAxis(component: number[], infos: Array<PolygonBasisInfo | null>, axis: Vec3, boundsOrigin: Vec3): {
|
|
2036
|
+
pixelArea: number;
|
|
2037
|
+
rawArea: number;
|
|
2038
|
+
} | null;
|
|
2039
|
+
declare function chooseIslandXAxis(component: number[], infos: Array<PolygonBasisInfo | null>): BasisHint | null;
|
|
2040
|
+
declare function buildBasisHints(polygons: Polygon[], options: SolidTrianglePlanOptions): Array<BasisHint | undefined>;
|
|
2041
|
+
declare function chooseLocalBasis(pts: Vec3[], origin: Vec3, normal: Vec3, options: BasisOptions): LocalBasis | null;
|
|
2042
|
+
declare function isFullRectBasis(basis: LocalBasis): boolean;
|
|
2043
|
+
declare function computeUvAffine(points: Vec2[], uvs: Vec2[]): UvAffine | null;
|
|
2044
|
+
declare function computeUvSampleRect(uvs: Vec2[]): UvSampleRect | null;
|
|
2045
|
+
declare function projectTextureTriangle(triangle: TextureTriangle, tile: number, elev: number, origin: Vec3, xAxis: Vec3, yAxis: Vec3, shiftX: number, shiftY: number): TextureTrianglePlan | null;
|
|
2046
|
+
declare function computeTextureAtlasPlan(polygon: Polygon, index: number, options: SolidTrianglePlanOptions, projectiveQuadGuards: ProjectiveQuadGuardSettings, basisHint?: BasisHint): TextureAtlasPlan | null;
|
|
2047
|
+
/**
|
|
2048
|
+
* Compute the per-polygon layout plan for one polygon in isolation.
|
|
2049
|
+
*
|
|
2050
|
+
* This is the public single-polygon variant used by React and Vue components.
|
|
2051
|
+
* It does not run the cross-polygon basis-optimisation or seam-detection that
|
|
2052
|
+
* the full `renderPolygonsWithTextureAtlas` pipeline performs, but the
|
|
2053
|
+
* strategy selection (projective-quad, rect, etc.) is identical to the
|
|
2054
|
+
* canonical renderer.
|
|
2055
|
+
*
|
|
2056
|
+
* The `projectiveQuadOverrides` parameter is the pre-resolved override bag
|
|
2057
|
+
* formerly obtained from `doc.defaultView.__polycssProjectiveQuadGuards`.
|
|
2058
|
+
* Callers that have a Document should extract it before calling; callers in
|
|
2059
|
+
* browser-free environments can pass `undefined` for the default guards.
|
|
2060
|
+
*/
|
|
2061
|
+
declare function computeTextureAtlasPlanPublic(polygon: Polygon, index: number, options?: ComputeTextureAtlasPlanOptions, projectiveQuadOverrides?: ProjectiveQuadGuardOverrides): TextureAtlasPlan | null;
|
|
2062
|
+
|
|
2063
|
+
declare function normalizeAtlasScale(scale: number | string | undefined): number;
|
|
2064
|
+
declare function atlasArea(pages: PackedPage[]): number;
|
|
2065
|
+
declare function autoAtlasScaleCap(pages: PackedPage[], maxDecodedBytes: number): number;
|
|
2066
|
+
declare function autoAtlasScale(pages: PackedPage[], maxDecodedBytes: number): number;
|
|
2067
|
+
declare function atlasBitmapMaxSide(pages: PackedPage[], atlasScale: number): number;
|
|
2068
|
+
declare function atlasDecodedBytes(pages: PackedPage[], atlasScale: number): number;
|
|
2069
|
+
declare function autoAtlasBudgetFactor(pages: PackedPage[], atlasScale: number, maxDecodedBytes: number): number;
|
|
2070
|
+
/** Returns the max decoded-bytes budget for the given device class. */
|
|
2071
|
+
declare function autoAtlasMaxDecodedBytes(isMobile: boolean): number;
|
|
2072
|
+
/** Returns the atlas canonical size for the given texture quality and device class. */
|
|
2073
|
+
declare function atlasCanonicalSizeForTextureQuality(textureQualityInput: TextureQuality | undefined, isMobile: boolean): number;
|
|
2074
|
+
declare function applyPackedAtlasCanonicalSize(packed: PackedAtlas, atlasCanonicalSize: number): PackedAtlas;
|
|
2075
|
+
declare function atlasCanonicalSizeForEntry(entry: TextureAtlasPlan): number;
|
|
2076
|
+
declare function atlasPadding(atlasScale: number): number;
|
|
2077
|
+
declare function packTextureAtlasPlans(plans: Array<TextureAtlasPlan | null>, atlasScale?: number): PackedAtlas;
|
|
2078
|
+
/**
|
|
2079
|
+
* Pack atlas plans and resolve atlas scale, accepting a pre-resolved isMobile
|
|
2080
|
+
* boolean instead of a Document reference.
|
|
2081
|
+
*/
|
|
2082
|
+
declare function packTextureAtlasPlansWithScaleCore(plans: Array<TextureAtlasPlan | null>, textureQualityInput: TextureQuality | undefined, isMobile: boolean): {
|
|
2083
|
+
packed: PackedAtlas;
|
|
2084
|
+
atlasScale: number;
|
|
2085
|
+
atlasCanonicalSize: number;
|
|
2086
|
+
};
|
|
2087
|
+
|
|
2088
|
+
export { ASYNC_RENDER_BUDGET_MS, ATLAS_CANONICAL_SIZE_AUTO_DESKTOP, ATLAS_CANONICAL_SIZE_EXPLICIT, ATLAS_MAX_SIZE, ATLAS_PADDING, AUTO_ATLAS_LOW_AREA, AUTO_ATLAS_MAX_BITMAP_SIDE, AUTO_ATLAS_MAX_DECODED_BYTES_DESKTOP, AUTO_ATLAS_MAX_DECODED_BYTES_MOBILE, AUTO_ATLAS_MEDIUM_AREA, AUTO_ATLAS_SCALE_GUARD, type ArrowPolygonsOptions, type AutoRotateConfig, type AutoRotateOption, type AxesHelperOptions, BAKED_SHADOW_MIN_UP, BAKED_SHADOW_Z_SQUASH, BASE_TILE, BASIS_EPS, BORDER_SHAPE_BLEED, BORDER_SHAPE_CANONICAL_SIZE, BORDER_SHAPE_CENTER_PERCENT, BORDER_SHAPE_POINT_EPS, type BasisHint, type BasisOptions, type BorderShapeBounds, type BorderShapeGeometry, type BoxFace, type BoxFaceOptions, type BoxPolygonsOptions, CAMERA_BACKFACE_CULL_EPS, COLOR_PARSE_CACHE_MAX, CORNER_SHAPE_DUPLICATE_EPS, CORNER_SHAPE_POINT_EPS, type CameraCullNormalGroup, type CameraCullRotation, type CameraHandle, type CameraState, type CameraStyleInput, type ComputeTextureAtlasPlanOptions, type ConePolygonsOptions, type CornerShapeCorner, type CornerShapeGeometry, type CornerShapeRadius, type CornerShapeSide, type CoverPlanarPolygonsOptions, type CullInteriorOptions, type CylinderPolygonsOptions, DECIMAL_SCALES, DEFAULT_AMBIENT_COLOR, DEFAULT_AMBIENT_INTENSITY, DEFAULT_ATLAS_CSS_DECIMALS, DEFAULT_BORDER_SHAPE_DECIMALS, DEFAULT_CAMERA_STATE, DEFAULT_LIGHT_COLOR, DEFAULT_LIGHT_DIR, DEFAULT_LIGHT_INTENSITY, DEFAULT_MATRIX_DECIMALS, DEFAULT_PROJECTION, DEFAULT_SEAM_BLEED, DEFAULT_SEAM_FACET_SPLIT_OPTIONS, DEFAULT_SEAM_OVERLAP_OPTIONS, DEFAULT_TILE, type DedupeOverlappingPolygonsOptions, type DodecahedronPolygonsOptions, type FilterAtlasPlansEnv, type GetSolidPaintDefaultsEnv, type GltfParseOptions, type IcosahedronPolygonsOptions, type InternalSolidTrianglePlanOptions, type LoadMeshOptions, type LocalBasis, type LoopMode, LoopOnce, LoopPingPong, LoopRepeat, MAX_ATLAS_SCALE, MIN_ATLAS_SCALE, type MeshResolution, type MtlParseResult, type NormalizeResult, type ObjParseOptions, type OctahedronPolygonsOptions, type OptimizeAnimatedMeshPolygonsOptions, type OptimizeMeshPolygonsOptions, PROJECTIVE_QUAD_BLEED, PROJECTIVE_QUAD_DENOM_EPS, PROJECTIVE_QUAD_MAX_WEIGHT_RATIO, type PackedAtlas, type PackedPage, type PackedTextureAtlasEntry, type PackingPage, type PackingShelf, type ParseAnimationClip, type ParseAnimationController, type ParseResult, type ParsedColor, type PlanePolygonsOptions, type PolyAmbientLight, type PolyAnimationAction, type ParseAnimationClip as PolyAnimationClip, type PolyAnimationMixer, type PolyAnimationTarget, type PolyDirectionalLight, type PolyMaterial, type PolyRenderStrategiesOption, type PolyRenderStrategy, type PolySeamBleed, type PolySeamBleedEdgeValue, type PolySeamBleedEdges, type PolyTextureAlphaMode, type PolyTextureLightingMode, type PolyTextureWrap, type PolyTextureWrapMode, type PolyVoxelCell, type PolyVoxelSource, type Polygon, type PolygonBasisInfo, type PolygonFace, type ProjectiveQuadCoefficients, type ProjectiveQuadGuardGlobal, type ProjectiveQuadGuardOverrides, type ProjectiveQuadGuardSettings, QUAT_IDENTITY, type Quat, RECT_EPS, type RGB, type RGBFactors, type RectBrush, type RingPolygonsOptions, type RingQuadPolygonsOptions, SEAM_LIGHT_EPS, SOLID_QUAD_CANONICAL_SIZE, SOLID_TRIANGLE_BLEED, SOLID_TRIANGLE_CANONICAL_SIZE, SOLID_TRIANGLE_CORNER_CLASS, SOLID_TRIANGLE_LARGE_BORDER_CANONICAL_SIZE, SOLID_TRIANGLE_LARGE_BORDER_CLASS, SURFACE_DISTANCE_EPS, SURFACE_NORMAL_EPS, type SceneBbox, type SceneContext, type SceneContextBuildArgs, type SceneContextBuildResult, type SeamBleedInsets, type SeamFacetSplitCandidate, type SeamFacetSplitCandidateReason, type SeamFacetSplitOptions, type SeamFacetSplitReport, type SeamOverlapCandidate, type SeamOverlapCandidateKind, type SeamOverlapDiagnostics, type SeamOverlapOptions, type SolidPaintDefaults, type SolidTextureSampleOptions, type SolidTriangleBasis, type SolidTriangleColorPlan, type SolidTriangleComputeOptions, type SolidTriangleFrame, type SolidTrianglePlan, type SolidTrianglePlanOptions, type SolidTrianglePrimitive, type SpherePolygonsOptions, type StablePlanBasis, type StableTriangleColorState, TEXTURE_EDGE_REPAIR_ALPHA_MIN, TEXTURE_EDGE_REPAIR_RADIUS, TEXTURE_EDGE_REPAIR_SOURCE_ALPHA_MIN, TEXTURE_TRIANGLE_BLEED, type TetrahedronPolygonsOptions, type TextureAtlasPage, type TextureAtlasPlan, type TexturePaintMetrics, type TexturePaintMetricsOptions, type TextureQuality, type TextureTriangle, type TextureTrianglePlan, type TorusPolygonsOptions, type UvAffine, type UvSampleRect, VOXEL_CAMERA_CULL_AXIS_EPS, VOXEL_CAMERA_CULL_NORMAL_LIMIT, type Vec2, type Vec3, type VoxParseOptions, applyPackedAtlasCanonicalSize, arrowPolygons, atlasArea, atlasBitmapMaxSide, atlasCanonicalSizeForEntry, atlasCanonicalSizeForTextureQuality, atlasDecodedBytes, atlasPadding, autoAtlasBudgetFactor, autoAtlasMaxDecodedBytes, autoAtlasScale, autoAtlasScaleCap, axesHelperPolygons, bakeSolidTextureSampledPolygons, bakeSolidTextureSamples, basisAxisKey, borderShapeBoundsFromPoints, borderShapeGeometryForPlan, boxPolygons, buildBakedShadowProjectionMatrix, buildBasisHints, buildSceneContext, buildSeamBleedPolygonEdges, buildSeamBleedPolygonSet, buildTextureEdgeRepairSets, cachedParsePureColor, cameraCullNormalGroups, cameraCullNormalGroupsFromPolygons, cameraCullNormalKey, cameraCullVisibleSignature, cameraFacingDepth, chooseIslandXAxis, chooseLocalBasis, clampChannel, clipPolygonToConvex2D, colorErrorScore, compatibleBleedSurface, compatibleSurface, computePlanSeamBleedEdgeAmounts, computeProjectiveQuadCoefficients, computeProjectiveQuadMatrix, computeSceneBbox, computeSeamBleedInsets, computeShapeLighting, computeSolidTriangleColorPlan, computeSolidTriangleColorPlanFromNormal, computeSolidTrianglePlan, computeSolidTrianglePlanFromCssPoints, computeSurfaceNormal, computeTextureAtlasPlan, computeTextureAtlasPlanPublic, computeTexturePaintMetrics, computeUvAffine, computeUvSampleRect, conePolygons, convexHull2D, cornerShapeDiagonal, cornerShapeGeometryForPlan, cornerShapePointSides, coverPlanarPolygons, createIsometricCamera, createPolyAnimationMixer, crossVec, cssBorderShapeForGeometry, cssBorderShapeForPlan, cssPoints, cullInteriorPolygons, cylinderPolygons, dedupeOverlappingPolygons, dodecahedronPolygons, dominantCountKey, dotVec, ensureCcw2D, eulerXYZFromQuat, evaluateIslandAxis, expandClipPoints, filterAtlasPlans, findOverlappingPolygonDuplicates, formatAffineMatrix3dColumns, formatAffineMatrix3dScalars, formatAffineMatrix3dTransformScalars, formatAtlasMatrix, formatBorderShapeElementStyle, formatBorderShapeEntryMatrix, formatBorderShapeMatrix, formatColor, formatCornerShapeElementStyle, formatCssLength, formatCssLengthPx, formatMatrix3d, formatMatrix3dValues, formatPercent, formatScaledMatrixFromPlan, formatSolidQuadEntryMatrix, formatSolidQuadMatrix, fullRectBounds, getPolygonBasisInfo, getSolidPaintDefaultsForPlansCore, icosahedronPolygons, incrementCount, intersect2DLines, intersect2DLinesRaw, inverseRotateVec3, isAxisAlignedSurfaceNormal, isBakedShadowCaster, isBasisOptimizable, isConvexPolygonPoints, isFullRectBasis, isFullRectSolid, isProjectiveQuadPlan, isSolidTrianglePlan, isVoxelCameraCullableNormalGroups, loadMesh, makeLocalBasis, mergePolygons, normalFacesCamera, normalizeAtlasScale, normalizeInvertMultiplier, normalizePolygons, normalizedSeamBleed, octahedronPolygons, offsetConvexPolygonPoints, offsetConvexPolygonPointsByEdgeAmounts, offsetStableTrianglePoints, offsetTrianglePoints, optimizeAnimatedMeshPolygons, optimizeMeshPolygons, packTextureAtlasPlans, packTextureAtlasPlansWithScaleCore, parseAlpha, parseColor, parseGltf, parseHex, parseHexColor, parseMtl, parseObj, parsePureColor, parseRgbColor, parseVox, planePolygons, polygonContainsPoint, polygonCssSurfaceNormal, polygonFaces, polygonFacesCamera, polygonSignedArea2D, projectCssVertexToGround, projectTextureTriangle, quantizeCssColor, quatFromAxisAngle, quatFromEulerXYZ, quatMultiply, repairMeshSeams, resolveProjectiveQuadGuards, resolveSeamBleed, rgbEqual, rgbKey, rgbToCss, rgbToHex, ringPolygons, ringQuadPolygons, rotateVec3, roundDecimal, safariCssProjectiveUnsupported, safePlanSeamBleedAmount, seamBleedAmountArray, seamFacetSplitPolygons, seamFacetSplitReport, seamLightBrightness, seamOverlapDiagnostics, seamOverlapPolygons, seamOverlapReport, shadeColor, shadePolygon, sharedCornerShapeSide, signedArea2D, simplifyCornerShapePoints, spherePolygons, stableBasisFromPlan, stableTriangleMatrixDecimals, stepRgbToward, tetrahedronPolygons, textureTintFactors, tintToCss, torusPolygons };
|