ldr 0.27.2 → 0.28.0

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.
@@ -3,18 +3,50 @@ import type { Compiler, Compiled } from "./compile.js";
3
3
  export declare const LOW_DETAIL_STEPS: readonly (readonly [err: number, ratio: number])[];
4
4
  /** Raster size of the see-through gate (per view). */
5
5
  export declare const LOW_DETAIL_RES = 128;
6
- /** Simplify a stride-9 triangle soup with rgba-per-vertex colours, welding and simplifying each colour separately. */
7
- export declare function simplifyBody(pos: ArrayLike<number>, col: ArrayLike<number>, err: number, ratio: number, lockBorder?: boolean): {
6
+ /** Seam closing tolerance (LDU) for `closeSeams`: well under a pixel at any phone zoom (1 LDU = 0.4 mm). */
7
+ export declare const SEAM_EPS = 0.01;
8
+ /** Steps for the seam-closed candidates: caps up to 0.5 LDU only, more finely spaced. Coarser, with the borders closed the simplifier
9
+ * collapses across thin walls (pin slits, beam ends) and folds them: still closed, so the see-through gate passes it, but visibly crumpled. */
10
+ export declare const SEAM_STEPS: readonly (readonly [err: number, ratio: number])[];
11
+ type Group = {
12
+ c: number[];
13
+ idx: Uint32Array;
14
+ pos: Float32Array;
15
+ };
16
+ /** A stride-9 triangle soup with rgba-per-vertex colours, welded per colour (one indexed mesh each), optionally with `closeSeams` applied. */
17
+ export declare function weldBody(pos: ArrayLike<number>, col: ArrayLike<number>, seams?: boolean): Group[];
18
+ /** Simplify welded colour groups (`weldBody`) at absolute error cap `err` (LDU) and target triangle fraction `ratio`; back to a stride-9 soup. */
19
+ export declare function simplifyGroups(groups: Group[], err: number, ratio: number, lockBorder?: boolean): {
20
+ pos: number[];
21
+ col: number[];
22
+ };
23
+ /** Simplify a stride-9 triangle soup with rgba-per-vertex colours, welding and simplifying each colour separately (`seams`: close its seams first). */
24
+ export declare function simplifyBody(pos: ArrayLike<number>, col: ArrayLike<number>, err: number, ratio: number, lockBorder?: boolean, seams?: boolean): {
8
25
  pos: number[];
9
26
  col: number[];
10
27
  };
28
+ /** Candidate name: `s<cap>`, `L` = locked borders, `S` = seams closed first (`closeSeams`, Round 54). */
29
+ export type LowDetailLevel = `s${number}` | `s${number}L` | `s${number}S` | `s${number}LS`;
11
30
  export interface LowDetailResult {
12
31
  compiled: Compiled;
13
- level: "full" | `s${number}` | `s${number}L`;
32
+ level: "full" | LowDetailLevel;
14
33
  fullTris: number;
15
34
  tris: number;
16
35
  fullSee: number;
17
36
  see: number;
18
37
  }
19
- /** The phone-tier version of compiled part `c` (compiled by `comp`, whose stud kinds it places for the gate). Textured bodies stay full. */
20
- export declare function lowDetail(comp: Compiler, c: Compiled): LowDetailResult;
38
+ /** The phone-tier version of compiled part `c`. `comp` compiles (or looks up) its stud kinds, placed for the gate. Textured bodies stay full. */
39
+ export declare function lowDetail(comp: Compiler | ((kind: string) => Compiled), c: Compiled, o?: {
40
+ seams?: boolean;
41
+ }): LowDetailResult;
42
+ /** Round 54: close the cracks LDraw leaves between sub-files before simplifying (one colour's welded mesh, indexed). LDraw parts join
43
+ * primitives to hand-placed geometry with coordinates a few thousandths of an LDU apart (pins: 3.061 vs 3.062) and with T-junctions
44
+ * (a vertex of one side lying inside an edge of the other). The simplifier sees both as open borders. Here (1) boundary vertices within
45
+ * `eps` of an earlier boundary vertex snap to it (greedy, in index order; interior vertices never move) and triangles that collapse are
46
+ * dropped, then (2) every open edge with boundary vertices lying on it (within `eps`, not at its ends) is split there, the triangle
47
+ * re-triangulated (fan from the opposite corner; a centroid fan when more than one edge splits). Deterministic. */
48
+ export declare function closeSeams(idx: ArrayLike<number>, p: number[], eps?: number): {
49
+ idx: Uint32Array;
50
+ pos: number[];
51
+ };
52
+ export {};
@@ -1,8 +1,9 @@
1
1
  import type { Compiler, Compiled } from "./compile.js";
2
2
  /** Part-space triangles (stride 9) of a compiled part with its separated studs placed: everything a viewer draws for it. */
3
3
  export declare function partTris(c: Compiler, key: string): number[];
4
- /** `partTris` of an already compiled part, optionally with `body` (stride-9 positions) drawn instead of its own body. */
5
- export declare function placedTris(c: Compiler, out: Compiled, body?: ArrayLike<number>): number[];
4
+ /** `partTris` of an already compiled part, optionally with `body` (stride-9 positions) drawn instead of its own body. `c` compiles the
5
+ * stud kinds (or is a lookup of already compiled ones). */
6
+ export declare function placedTris(c: Compiler | ((kind: string) => Compiled), out: Compiled, body?: ArrayLike<number>): number[];
6
7
  /** { see, cover }: pixels covered by triangles of one orientation only (see-through when back faces are culled), and covered pixels,
7
8
  * summed over 42 orthographic views at `res`² each, the part's bounding sphere filling the view. With `limit`, stops after the first
8
9
  * view that takes `see` past it (`see` is then only known to exceed `limit`; `cover` is partial). */
package/dist/spec.d.ts CHANGED
@@ -209,9 +209,10 @@ export declare const colorToken: (c: number) => string;
209
209
  /** Name of the synthetic part holding a model file's own geometry in local step `step`: `<file>#<step>`. */
210
210
  export declare const loosePartName: (file: string, step: number) => string;
211
211
  /**
212
- * The synthetic part for a model file's own type 2-5 lines in local step `step`, as a file: every `0 BFC` line of the file
213
- * (winding / certification state, in order), the step's `!TEXMAP` and `0 !:` lines, and the step's type 2-5 lines. Type-1 lines
214
- * are dropped (they are instances), together with a `!TEXMAP NEXT` that applied to one. Commands are shared with `f`.
212
+ * The synthetic part for a model file's own type 2-5 lines in local step `step`, as a file: every `0 BFC` and `0 !COLOUR` line of
213
+ * the file (winding / certification state and the file's own colour definitions, in order), the step's `!TEXMAP` and `0 !:` lines,
214
+ * and the step's type 2-5 lines. Type-1 lines are dropped (they are instances), together with a `!TEXMAP NEXT` that applied to one.
215
+ * Commands are shared with `f`.
215
216
  */
216
217
  export declare function looseFile(f: LFile, step: number): LFile;
217
218
  /** LDraw source text of `looseFile(f, step)`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ldr",
3
- "version": "0.27.2",
3
+ "version": "0.28.0",
4
4
  "description": "High-performance LEGO (LDraw) rendering for three.js: instanced parts packs, hidden stud/tube culling, low-detail studs, indexed edges, build steps.",
5
5
  "license": "MIT",
6
6
  "author": "Evan Bacon",