ldr 0.24.2 → 0.26.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.
package/dist/render.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import * as THREE from 'three';
2
2
  import { decodePack, type Pack } from './pack-io.js';
3
- import { type ColourSurface } from './model.js';
3
+ import { type ColourSurface, type LDrawColor } from './model.js';
4
4
  export { decodePack, type Pack };
5
5
  /** `edges`: LDraw edge lines, welded + indexed and sharing each batch's instance matrices (`'idx'` is the same as `true`).
6
6
  * `cond`: draw type-5 conditional lines when the pack carries them (pack v2, built with `cond: true`) and edges are on. Default true.
7
7
  * `condStuds`: also draw them on stud batches (stud silhouettes). Default true. Uncertified (no BFC) parts are always double-sided. */
8
8
  export type LdrParams = {
9
9
  cull?: CullResult;
10
+ /** Colours of instance colour keys that aren't table codes: model-level `0 !COLOUR` definitions (see `sceneInstances`). */
11
+ localColours?: Map<string, LDrawColor>;
10
12
  cullStuds: boolean;
11
13
  cullUnder: boolean;
12
14
  edges?: boolean | 'idx';
package/dist/scene.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as THREE from "three";
2
2
  import { type Pack } from "./render.js";
3
3
  import { type CullResult } from "./cull.js";
4
- import type { PartInstance, LDrawColor } from "./model.js";
4
+ import { type PartInstance, type LDrawColor } from "./model.js";
5
5
  import type { StepView } from "./spec.js";
6
6
  export type ColorSource = Map<number, string | LDrawColor> | Record<number | string, string | LDrawColor> | ((code: number) => THREE.ColorRepresentation | undefined);
7
7
  export interface LdrObjectOptions {
package/dist/spec.d.ts CHANGED
@@ -87,7 +87,19 @@ export interface Doc {
87
87
  data?: Map<string, DataBlock>;
88
88
  }
89
89
  export declare const norm: (s: string) => string;
90
- /** Parse LDraw color token: decimal code, or direct color 0x2RRGGBB (and related 0xN…… forms). */
90
+ /** `!COLOUR` identifier (article 299, "Syntax"): a-zA-Z0-9_, first character alphabetic; case-insensitive. */
91
+ export declare const COLOUR_ID_RE: RegExp;
92
+ /**
93
+ * Number for a named colour code: `0 !COLOUR name CODE x` where x is an identifier instead of 0-511 ("if strict LDraw compatibility
94
+ * is not required, x is any identifier recognized by a rendering program as a color code", article 299). Identifiers are
95
+ * case-insensitive, so `MyRed` and `myred` are one code. The number is negative (-1 - 30-bit FNV-1a of the lower-case text), so it
96
+ * never collides with a real code (0-511, direct colours 0x2RRGGBB...) and is the same in every thread / worker. `colorToken`
97
+ * turns it back into the identifier.
98
+ */
99
+ export declare function namedColorCode(id: string): number;
100
+ /** True for a named colour code from `namedColorCode` (negative), not a numeric LDraw code. */
101
+ export declare const isNamedColor: (c: number) => boolean;
102
+ /** Parse LDraw color token: decimal code, direct color 0x2RRGGBB (and related 0xN…… forms), or a `!COLOUR` identifier (see `namedColorCode`). */
91
103
  export declare function parseColor(tok: string): number;
92
104
  /** Parse the tail of `0 !TEXMAP START|NEXT <method> <params> <png> [GLOSSMAP <png>]`. Returns null when malformed. */
93
105
  export declare function parseTexMap(tail: string, next?: boolean): TexMap | null;
@@ -192,7 +204,7 @@ export type FileKind = "part" | "model";
192
204
  export declare function fileKind(doc: Doc, name: string): FileKind;
193
205
  /** Local steps (as counted by `flatten`) in which a file has its own type 2-5 lines or `0 !:` geometry, ascending. */
194
206
  export declare function looseSteps(f: LFile): number[];
195
- /** LDraw colour token for a colour code: decimal, or `0x2RRGGBB` for direct colours. */
207
+ /** LDraw colour token for a colour code: decimal, `0x2RRGGBB` for direct colours, or the (lower-case) identifier of a named code. */
196
208
  export declare const colorToken: (c: number) => string;
197
209
  /** Name of the synthetic part holding a model file's own geometry in local step `step`: `<file>#<step>`. */
198
210
  export declare const loosePartName: (file: string, step: number) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ldr",
3
- "version": "0.24.2",
3
+ "version": "0.26.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",