minerender 2.1.0-beta.0 → 2.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import * as three from 'three';
2
- import { Vector3, PixelFormat, BoxGeometry, Material, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points, Group } from 'three';
2
+ import { Vector3, PixelFormat, BoxGeometry, Material, ColorRepresentation, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, Group, DataTexture, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
3
3
  import * as nodeCanvas from 'canvas';
4
4
  import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
5
5
  import { Buffer } from 'buffer';
@@ -11,6 +11,7 @@ export { PLYExporterOptions } from 'three/examples/jsm/exporters/PLYExporter.js'
11
11
  import Stats from 'stats.js';
12
12
  import { EffectComposer } from 'postprocessing';
13
13
 
14
+ /** Advances a texture animation by one tick. Return `false` when its pixels have not changed. */
14
15
  interface AnimatorFunction {
15
16
  (): boolean | void;
16
17
  }
@@ -42,6 +43,7 @@ declare enum CubeFaceIndex {
42
43
  declare const CUBE_FACES: CubeFace[];
43
44
  declare const CUBE_FACE_OFFSETS: readonly [readonly [1, 0, 0], readonly [-1, 0, 0], readonly [0, 1, 0], readonly [0, -1, 0], readonly [0, 0, 1], readonly [0, 0, -1]];
44
45
 
46
+ /** An object that can release the resources it owns. */
45
47
  interface Disposable {
46
48
  dispose(): void;
47
49
  }
@@ -49,7 +51,9 @@ declare function isDisposable(obj: any): obj is Disposable;
49
51
 
50
52
  type CompatImage = HTMLImageElement | nodeCanvas.Image;
51
53
  type CompatCanvas = HTMLCanvasElement | nodeCanvas.Canvas;
54
+ /** Creates an image through the active environment provider. Dimensions are in pixels. */
52
55
  declare function createImage(width?: number, height?: number): CompatImage;
56
+ /** Creates a browser or Node canvas through the active environment provider, sized in pixels. */
53
57
  declare function createCanvas(width: number, height: number): CompatCanvas;
54
58
 
55
59
  /**
@@ -63,6 +67,7 @@ declare abstract class PersistentCache<B = unknown> {
63
67
  readonly backing: B;
64
68
  /** Bump to invalidate every persisted entry. */
65
69
  static readonly VERSION = 2;
70
+ /** Opens a named store in the active environment using the current cache schema version. */
66
71
  static open(name: string): PersistentCache;
67
72
  protected constructor(backing: B);
68
73
  abstract get<T>(key: string): Promise<T>;
@@ -115,6 +120,7 @@ declare class Env {
115
120
  static get provider(): EnvProvider;
116
121
  }
117
122
 
123
+ /** A canvas-backed image with dimensions and a context for reading pixel regions. */
118
124
  interface ExtractableImageData {
119
125
  readonly data: CanvasImageData;
120
126
  readonly width: number;
@@ -122,10 +128,12 @@ interface ExtractableImageData {
122
128
  }
123
129
 
124
130
  type CacheKey = string;
131
+ /** Source URL used to identify cached image bytes and pixels. */
125
132
  interface RawImageKey {
126
133
  src: string;
127
134
  }
128
135
  declare function serializeImageKey(key: RawImageKey): string;
136
+ /** Box dimensions in scene units and optional normalized UVs in Three.js face order. */
129
137
  interface BoxGeometryKey {
130
138
  width: number;
131
139
  height: number;
@@ -133,32 +141,39 @@ interface BoxGeometryKey {
133
141
  uv?: number[];
134
142
  }
135
143
  declare function serializeBoxGeometryKey(key: BoxGeometryKey): string;
144
+ /** Settings passed to {@link Textures.getImage}. Texture rotation uses radians. */
136
145
  interface TextureKey extends RawImageKey {
137
146
  format?: PixelFormat;
138
147
  rotation?: number;
139
148
  }
140
149
  declare function serializeTextureKey(key: TextureKey): string;
150
+ /** Texture and transparency settings passed to {@link Materials.getImage}. */
141
151
  interface MaterialKey {
142
152
  texture: TextureKey;
143
153
  transparent?: boolean;
144
154
  }
145
155
  declare function serializeMaterialKey(key: MaterialKey): string;
156
+ /** Geometry and material settings passed to {@link Meshes.createBox} or {@link Meshes.getBox}. */
146
157
  interface MeshKey {
147
158
  geometry: BoxGeometryKey;
148
159
  material: MaterialKey;
149
160
  }
150
161
  declare function serializeMeshKey(key: MeshKey): string;
151
162
 
163
+ /** Creates box geometry with optional face UVs and caches it by dimensions and UV values. */
152
164
  declare class Geometries {
153
165
  static createBox(key: BoxGeometryKey): BoxGeometry;
166
+ /** Returns shared geometry. Use {@link createBox} when the caller needs to modify or dispose it independently. */
154
167
  static getBox(key: BoxGeometryKey): BoxGeometry;
155
168
  }
156
169
 
170
+ /** Produces a string representation, such as an asset cache key. */
157
171
  interface Serializable {
158
172
  serialize(): string;
159
173
  }
160
174
 
161
175
  type AssetType = "models" | "textures" | "blockstates" | string;
176
+ /** A Minecraft namespace and path, such as `minecraft` and `zombie`. */
162
177
  declare class BasicAssetKey implements Serializable {
163
178
  readonly namespace: string;
164
179
  readonly path: string;
@@ -168,6 +183,7 @@ declare class BasicAssetKey implements Serializable {
168
183
  toString(): string;
169
184
  serialize(): string;
170
185
  }
186
+ /** Locates an asset by namespace, directory, extension, and optional asset root. */
171
187
  declare class AssetKey extends BasicAssetKey {
172
188
  readonly namespace: string;
173
189
  readonly path: string;
@@ -177,44 +193,167 @@ declare class AssetKey extends BasicAssetKey {
177
193
  extension: ".json" | ".png" | string;
178
194
  root?: string | undefined;
179
195
  readonly isAssetKey: true;
196
+ /**
197
+ * Creates a key from separate path components. Use {@link parse} for a combined reference.
198
+ *
199
+ * @param assetType - Asset directory, such as `models`, `textures`, or `blockstates`.
200
+ * @param type - Subdirectory, such as `block` or `item`.
201
+ * @param rootType - Top-level directory, usually `assets` or `data`.
202
+ * @param root - Base URL override for hosted asset sources.
203
+ */
180
204
  constructor(namespace: string, path: string, assetType?: AssetType | undefined, type?: string | undefined, rootType?: "assets" | "data" | string, extension?: ".json" | ".png" | string, root?: string | undefined);
205
+ /**
206
+ * Parses an asset reference such as `minecraft:block/stone`.
207
+ * A missing namespace defaults to the origin's namespace or `minecraft`.
208
+ *
209
+ * @param assetType - Asset category, such as `models` or `textures`.
210
+ * @param str - Path with an optional namespace and file extension.
211
+ * @param origin - Supplies the asset root, default namespace, and non-texture extension.
212
+ * @returns A key with the matching extension removed from its path. Textures use `.png`;
213
+ * other assets use the origin's extension or `.json`.
214
+ */
181
215
  static parse(assetType: AssetType, str: string, origin?: AssetKey): AssetKey;
182
216
  toString(): string;
217
+ /** Joins the type subdirectory and path without adding a namespace or file extension. */
183
218
  getFullPath(): string;
184
219
  toNamespacedString(): string;
220
+ /** Returns a cache identifier that includes the explicit root or {@link AssetLoader.ROOT}. */
185
221
  serialize(): string;
186
222
  }
187
223
  declare function isBasicAssetKey(obj: any): obj is BasicAssetKey;
188
224
  declare function isAssetKey(obj: any): obj is AssetKey;
189
225
 
226
+ /** Loaded data with an optional namespace-and-path identity. */
190
227
  interface BasicMinecraftAsset {
191
228
  key?: BasicAssetKey;
192
229
  }
230
+ /** Loaded data that can retain its full source key for related asset lookups. */
193
231
  interface MinecraftAsset extends BasicMinecraftAsset {
194
232
  key?: AssetKey;
195
233
  }
196
234
 
235
+ /** A hosted `_list.json` directory index used by asset-listing APIs. */
197
236
  interface ListAsset extends MinecraftAsset {
198
237
  directories: string[];
199
238
  files: string[];
200
239
  }
201
240
 
241
+ /** One selected draw, combining geometry, texture, and material settings. */
242
+ interface EntityLayer {
243
+ key: BasicAssetKey;
244
+ texture?: AssetKey;
245
+ layer: EntityModelLayer;
246
+ /** How this draw is rendered; defaults to the geometry layer's own mode, then `cutout`. */
247
+ render?: EntityRenderMode;
248
+ /** Label of the state colour that multiplies the texture, from the pass that selected this draw. */
249
+ tint?: string;
250
+ }
251
+ /** Selected entity data returned by {@link Entities.getEntity} for rendering. */
252
+ interface EntityModel extends EntityLayer {
253
+ id: string;
254
+ /** Root transform from the dataset; see {@link EntityTransformOp}. */
255
+ transform?: EntityTransformOp[];
256
+ /**
257
+ * Selected draws in draw order; the top-level fields describe the first selection.
258
+ * A key is the geometry layer's name; a further draw of the same geometry (a pass with another texture) is keyed `<layer>#<n>`, from 2.
259
+ */
260
+ layers?: Record<string, EntityLayer>;
261
+ }
262
+ /** Dataset file containing all geometry layers and optional extra render passes. */
263
+ interface EntityModelFile extends MinecraftAsset {
264
+ id: string;
265
+ transform?: EntityTransformOp[];
266
+ layers: Record<string, EntityModelLayer>;
267
+ /** Extra draws vanilla adds on top of `main`, in draw order. */
268
+ passes?: EntityModelPass[];
269
+ }
270
+ /** Vanilla render type of a draw; see the dataset README for the mode table. */
271
+ type EntityRenderMode = "cutout" | "cutout_cull" | "cutout_z_offset" | "solid" | "translucent" | "translucent_emissive" | "eyes" | "energy_swirl" | "breeze_wind" | "water_mask" | "no_outline";
272
+ /** An extra draw of a geometry layer, optionally enabled by an entity-state label. */
273
+ interface EntityModelPass {
274
+ /** Geometry layer of the same file; a pass on `main` draws that geometry again. */
275
+ layer: string;
276
+ /** Present only when it differs from the layer's own. */
277
+ textureLocation?: string;
278
+ /** Present only when it differs from the layer's own. */
279
+ render?: EntityRenderMode;
280
+ /** Entity state that enables the draw, e.g. `powered`; without it the pass is always drawn. */
281
+ when?: string;
282
+ /** State colour that multiplies the texture, e.g. `wool_color`. */
283
+ tint?: string;
284
+ }
285
+ /**
286
+ * One operation vanilla's renderer applies before drawing a model, in call order:
287
+ * each one is applied on top of the previous, so the last reaches the vertices first.
288
+ * Translations use model units and rotations use radians, like part poses.
289
+ */
290
+ type EntityTransformOp = {
291
+ scale: [number, number, number];
292
+ } | {
293
+ translate: [number, number, number];
294
+ } | {
295
+ rotate: [number, number, number];
296
+ };
297
+ /** A named geometry tree with texture dimensions in pixels and an optional default texture path. */
298
+ interface EntityModelLayer {
299
+ texture: [number, number];
300
+ textureLocation?: string;
301
+ /** Omitted for `cutout`. */
302
+ render?: EntityRenderMode;
303
+ root: EntityModelPart;
304
+ }
305
+ /** A named part's baked pose and children. Offsets use model units and rotations use radians. */
306
+ interface EntityModelPart {
307
+ pose: {
308
+ offset: [number, number, number];
309
+ rotation: [number, number, number];
310
+ scale?: [number, number, number];
311
+ };
312
+ texture?: [number, number];
313
+ cubes: EntityModelCube[];
314
+ children: Record<string, EntityModelPart>;
315
+ }
316
+ /** A part's cuboid in model units, with a texture origin in pixels and optional per-axis growth. */
317
+ interface EntityModelCube {
318
+ origin: [number, number, number];
319
+ size: [number, number, number];
320
+ uv: [number, number];
321
+ grow?: [number, number, number];
322
+ mirror?: boolean;
323
+ }
324
+
325
+ /** Creates Minecraft model, entity, and GUI materials, with shared caches for image materials. */
202
326
  declare class Materials {
203
- private static readonly MISSING_TEXTURE_SRC;
327
+ /** Shared checkerboard material, created on first access. */
204
328
  static get MISSING_TEXTURE(): Material;
205
329
  static createImage(key: MaterialKey): Material;
206
330
  static createBasicCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
331
+ /** Whether vanilla's render type for the mode culls back faces. */
332
+ static entityModeCulls(mode?: EntityRenderMode): boolean;
333
+ /** UV offset per tick of entity age for the scrolling modes, as vanilla's texture matrix applies it. */
334
+ static entityModeScroll(mode?: EntityRenderMode): [number, number] | undefined;
335
+ /**
336
+ * Entity material for one of vanilla's render types. Entities are unlit here, so the lit and full-bright modes
337
+ * differ only in blending and depth state. Culling is not a material property: {@link entityModeCulls} decides
338
+ * whether the geometry gets inward faces.
339
+ */
340
+ static createEntityCanvasMaterial(canvas: HTMLCanvasElement, mode?: EntityRenderMode, tint?: ColorRepresentation): MeshBasicMaterial;
341
+ /** Creates an unlit, transparent GUI material without depth writes or tone mapping. */
207
342
  static createGuiCanvasMaterial(canvas: HTMLCanvasElement): MeshBasicMaterial;
208
- static createShadedCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
343
+ static createShadedCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean, boundUvs?: boolean): Material;
344
+ /** Returns a shared image material. Use {@link createImage} for a separate material instance. */
209
345
  static getImage(key: MaterialKey): Material;
210
346
  static needsUpdate(mat: Material): void;
211
347
  }
212
348
 
349
+ /** Creates box meshes from shared geometry and image materials. */
213
350
  declare class Meshes {
214
351
  static createBox(key: MeshKey): Mesh;
352
+ /** Returns a shared Mesh object. Use {@link createBox} for a mesh with its own transform and parent. */
215
353
  static getBox(key: MeshKey): Mesh;
216
354
  }
217
355
 
356
+ /** Texture and culling settings for one cuboid face. Java model UVs use Minecraft's 0–16 texture space. */
218
357
  interface ElementFace {
219
358
  uv: QuadArray;
220
359
  mappedUv?: QuadArray;
@@ -228,6 +367,7 @@ interface FromTo {
228
367
  from: TripleArray;
229
368
  to: TripleArray;
230
369
  }
370
+ /** A cuboid in model units, where 16 units equal one block. */
231
371
  interface ModelElement extends FromTo {
232
372
  rotation?: ElementRotation;
233
373
  shade?: boolean;
@@ -235,6 +375,7 @@ interface ModelElement extends FromTo {
235
375
  mappedUv?: number[];
236
376
  }
237
377
  type ModelFaces = Partial<Record<CubeFace, Partial<ElementFace>>>;
378
+ /** Rotates one cuboid around an origin in model units, using an angle in degrees. */
238
379
  interface ElementRotation {
239
380
  origin: TripleArray;
240
381
  axis: Axis;
@@ -260,14 +401,17 @@ declare enum GuiLight {
260
401
  SIDE = "side"
261
402
  }
262
403
 
404
+ /** Fetch settings passed to {@link Requests.genericRequest} or {@link Requests.mcAssetRequest}. */
263
405
  interface RequestConfig extends RequestInit {
264
406
  url: string;
265
407
  /** Prepended to relative URLs, preserving any path in the base URL. */
266
408
  baseURL?: string;
267
409
  /** Timeout per attempt in milliseconds, including body reading. Defaults to 5000; 0 disables it. */
268
410
  timeout?: number;
411
+ /** Response-body decoding. Defaults to `json`. */
269
412
  responseType?: "json" | "arraybuffer";
270
413
  }
414
+ /** A decoded response body with the HTTP status, native headers, and final URL. */
271
415
  interface RequestResponse<T = any> {
272
416
  data: T;
273
417
  status: number;
@@ -276,16 +420,21 @@ interface RequestResponse<T = any> {
276
420
  /** Final URL after redirects. */
277
421
  url: string;
278
422
  }
423
+ /** An HTTP or network failure, with response details or an underlying cause when available. */
279
424
  declare class RequestError extends Error {
280
425
  readonly response?: RequestResponse<undefined> | undefined;
281
426
  readonly cause?: unknown;
282
427
  constructor(message: string, response?: RequestResponse<undefined> | undefined, cause?: unknown);
283
428
  }
429
+ /** Shared Fetch queues with concurrency limits, cancellation, timeouts, and bounded retries for GET requests. */
284
430
  declare class Requests {
285
431
  private static genericQueue;
286
432
  private static mcAssetRequestQueue;
433
+ /** Queues a general request. Set `request.signal` to cancel it and `request.timeout` to limit each attempt. */
287
434
  static genericRequest(request: RequestConfig): Promise<RequestResponse>;
435
+ /** Queues a request separately from general traffic, using the configured asset base URL for relative paths. */
288
436
  static mcAssetRequest(request: RequestConfig): Promise<RequestResponse>;
437
+ /** Sets the base URL for relative asset requests. Use {@link AssetLoader.setVersion} to change Minecraft versions. */
289
438
  static setMcAssetRoot(root: string): void;
290
439
  /** Counts unsettled calls, including retry delays and requests still running after shutdown. */
291
440
  static get queueSizes(): {
@@ -300,6 +449,7 @@ declare class Requests {
300
449
  static end(): void;
301
450
  }
302
451
 
452
+ /** Provides pixel and frame access to a canvas-backed image. Simple frame helpers assume a vertical strip of squares. */
303
453
  declare class WrappedImage {
304
454
  readonly dta: ExtractableImageData;
305
455
  constructor(dta: ExtractableImageData);
@@ -308,6 +458,7 @@ declare class WrappedImage {
308
458
  get width(): number;
309
459
  get height(): number;
310
460
  get hasTransparency(): boolean;
461
+ /** Whether the dimensions form a vertical strip of square frames, without consulting `.mcmeta`. */
311
462
  get animated(): boolean;
312
463
  get frameWidth(): number;
313
464
  get frameHeight(): number;
@@ -318,6 +469,7 @@ declare class WrappedImage {
318
469
  getFrameSectionData(frame: number): ImageData$1;
319
470
  }
320
471
 
472
+ /** Encoded image bytes with dimensions and format detected from the file header. */
321
473
  interface ImageInfo {
322
474
  src?: string;
323
475
  width: number;
@@ -325,15 +477,21 @@ interface ImageInfo {
325
477
  type?: string;
326
478
  data: Buffer;
327
479
  }
480
+ /** Fetches and decodes images through the active browser or Node environment provider. */
328
481
  declare class ImageLoader {
329
482
  protected static _createImage(): CompatImage;
483
+ /** Resolves when an image URL has decoded, or rejects if decoding fails. */
330
484
  static loadAsync(src: string): Promise<CompatImage>;
485
+ /** Returns an image immediately. Use the callbacks to observe loading, or await {@link loadAsync}. */
331
486
  static loadElement(src: string, onload?: () => void, onerr?: (err: Error) => void): CompatImage;
332
487
  static loadData(src: string): Promise<ImageData>;
333
488
  static loadCanvasData(src: string): Promise<ExtractableImageData>;
489
+ /** Decodes the supplied bytes into a canvas without fetching the source URL again. */
334
490
  static infoToCanvasData(info: ImageInfo): Promise<ExtractableImageData>;
335
491
  static infoToData(info: ImageInfo): Promise<ImageData>;
492
+ /** Returns cached RGBA pixels for an image URL or data URL. Failed loads can be retried. */
336
493
  static getData(src: string): Promise<ImageData>;
494
+ /** Returns a cached canvas context and dimensions for an image URL or data URL. */
337
495
  static getCanvasData(src: string): Promise<ExtractableImageData>;
338
496
  static processResponse(response: Pick<RequestResponse<ArrayBuffer>, "data" | "url">): Promise<ImageInfo>;
339
497
  static loadInfo(src: string): Promise<ImageInfo>;
@@ -342,10 +500,51 @@ declare class ImageLoader {
342
500
  static getWrapped(src: string): Promise<WrappedImage>;
343
501
  }
344
502
 
503
+ /** Vanilla dye colors used by banner and shield textures, as sRGB packed values. */
504
+ declare const DYE_COLORS: Readonly<{
505
+ readonly white: 16383998;
506
+ readonly orange: 16351261;
507
+ readonly magenta: 13061821;
508
+ readonly light_blue: 3847130;
509
+ readonly yellow: 16701501;
510
+ readonly lime: 8439583;
511
+ readonly pink: 15961002;
512
+ readonly gray: 4673362;
513
+ readonly light_gray: 10329495;
514
+ readonly cyan: 1481884;
515
+ readonly purple: 8991416;
516
+ readonly blue: 3949738;
517
+ readonly brown: 8606770;
518
+ readonly green: 6192150;
519
+ readonly red: 11546150;
520
+ readonly black: 1908001;
521
+ }>;
522
+ type DyeColor = keyof typeof DYE_COLORS;
523
+ /** A registry banner pattern or an inline value in a `banner_patterns` component. */
524
+ interface BannerPattern extends MinecraftAsset {
525
+ asset_id: string;
526
+ translation_key: string;
527
+ }
528
+ interface BannerPatternDraw {
529
+ texture: AssetKey;
530
+ color: number;
531
+ }
532
+ /** Loads banner-pattern registry entries and resolves their banner or shield textures. */
533
+ declare class BannerPatterns {
534
+ /** Lists namespaced pattern IDs from the selected namespace's data directory. */
535
+ static getList(namespace?: string, root?: string): Promise<string[]>;
536
+ /** Returns the named dye's sRGB value, rejecting unknown colors. */
537
+ static getColor(color: unknown): number;
538
+ /** Resolves the first 16 layers of a `banner_patterns` component, preserving their order. */
539
+ static getLayers(value: unknown, target: "banner" | "shield", root?: string): Promise<BannerPatternDraw[]>;
540
+ private static identifier;
541
+ }
542
+
345
543
  declare const ITEM_GENERATED = "item/generated";
346
544
  declare const BUILTIN_GENERATED = "builtin/generated";
347
545
  declare const BUILTIN_ENTITY = "builtin/entity";
348
546
  declare const DEFAULT_ELEMENTS: ModelElement[];
547
+ /** A Java model definition. {@link Models.getMerged} resolves its parent, textures, and elements. */
349
548
  interface Model extends MinecraftAsset {
350
549
  textures?: IModelTextures;
351
550
  parent?: string;
@@ -353,16 +552,69 @@ interface Model extends MinecraftAsset {
353
552
  elements?: ModelElement[];
354
553
  hierarchy?: string[];
355
554
  }
555
+ /** Java block-model data, including the ambient-occlusion flag. */
356
556
  interface BlockModel extends Model {
357
557
  textures?: BlockModelTextures;
358
558
  ambientocclusion?: boolean;
359
559
  }
560
+ /** Item preview data, including GUI lighting, tint sources, and supported special renderers. */
360
561
  interface ItemModel extends Model {
361
562
  textures?: ItemModelTextures;
362
563
  gui_light?: GuiLight;
363
- }
564
+ special?: SpecialItemRenderer;
565
+ tints?: ItemTintSource[];
566
+ /** Stack-component snapshot with namespaced IDs, used by tint sources and special renderers. */
567
+ components?: Record<string, unknown>;
568
+ /** Ordered composite children, each with its own textures, display pose, and tint sources. */
569
+ parts?: ItemModel[];
570
+ }
571
+ /** An sRGB packed `0xRRGGBB` value or an RGB triple with components from 0 to 1. */
572
+ type ItemTintColor = number | TripleArray;
573
+ /** A vanilla item color source. Missing component values and unsupported gameplay state use the declared default. */
574
+ type ItemTintSource = {
575
+ type: "constant" | "minecraft:constant";
576
+ value: ItemTintColor;
577
+ } | {
578
+ type: "grass" | "minecraft:grass";
579
+ temperature: number;
580
+ downfall: number;
581
+ } | {
582
+ type: "dye" | "minecraft:dye" | "potion" | "minecraft:potion" | "map_color" | "minecraft:map_color" | "firework" | "minecraft:firework" | "team" | "minecraft:team";
583
+ default: ItemTintColor;
584
+ } | {
585
+ type: "custom_model_data" | "minecraft:custom_model_data";
586
+ index?: number;
587
+ default: ItemTintColor;
588
+ };
589
+ /** Supported item definitions that draw entity geometry instead of ordinary model elements. */
590
+ type SpecialItemRenderer = {
591
+ type: "banner" | "minecraft:banner";
592
+ color: DyeColor;
593
+ } | {
594
+ type: "shield" | "minecraft:shield";
595
+ } | {
596
+ type: "trident" | "minecraft:trident" | "conduit" | "minecraft:conduit";
597
+ } | {
598
+ type: "chest" | "minecraft:chest";
599
+ texture: string;
600
+ openness?: number;
601
+ } | {
602
+ type: "shulker_box" | "minecraft:shulker_box";
603
+ texture: string;
604
+ openness?: number;
605
+ orientation?: "down" | "up" | "north" | "south" | "west" | "east";
606
+ } | {
607
+ type: "bed" | "minecraft:bed";
608
+ texture: string;
609
+ } | {
610
+ type: "head" | "minecraft:head";
611
+ kind: string;
612
+ texture?: string;
613
+ animation?: number;
614
+ };
364
615
  interface TextureAsset extends MinecraftAsset, ImageInfo {
365
616
  }
617
+ /** A model display pose: translation in model units, rotation in degrees, and scale factors. */
366
618
  interface ModelDisplay {
367
619
  translation?: TripleArray;
368
620
  rotation?: TripleArray;
@@ -402,9 +654,33 @@ declare class MinecraftCubeTexture {
402
654
  toUvArray(w: number, h: number, l: number, mirror?: boolean): number[];
403
655
  }
404
656
 
657
+ /** Texture animation and GUI scaling metadata read from a `.png.mcmeta` file. */
405
658
  interface MinecraftTextureMeta extends MinecraftAsset {
406
- animation: AnimationMeta;
659
+ animation?: AnimationMeta;
660
+ gui?: {
661
+ scaling?: GuiSpriteScaling;
662
+ };
407
663
  }
664
+ /** GUI sprite scaling rules. Dimensions and borders use logical GUI pixels, independent of PNG resolution. */
665
+ type GuiSpriteScaling = {
666
+ type: "stretch";
667
+ } | {
668
+ type: "tile";
669
+ width: number;
670
+ height: number;
671
+ } | {
672
+ type: "nine_slice";
673
+ width: number;
674
+ height: number;
675
+ border: number | {
676
+ left: number;
677
+ top: number;
678
+ right: number;
679
+ bottom: number;
680
+ };
681
+ stretch_inner?: boolean;
682
+ };
683
+ /** Texture frame-grid and playback settings. Frame durations use ticks at 20 ticks per second. */
408
684
  interface AnimationMeta {
409
685
  interpolate: boolean;
410
686
  width: number;
@@ -412,17 +688,20 @@ interface AnimationMeta {
412
688
  frametime: number;
413
689
  frames: Array<number | AnimationFrame>;
414
690
  }
691
+ /** A zero-based frame index and its duration in ticks, overriding the animation's default frame time. */
415
692
  interface AnimationFrame {
416
693
  index: number;
417
694
  time: number;
418
695
  }
419
696
 
697
+ /** Counts direct scene children, Minecraft scene objects, and live instance placements. */
420
698
  declare class SceneStats {
421
699
  objectCount: number;
422
700
  sceneObjectCount: number;
423
701
  instanceCount: number;
424
702
  }
425
703
 
704
+ /** A synchronous callback registered with {@link Ticker.add}. */
426
705
  interface TickerFunction {
427
706
  (): void;
428
707
  }
@@ -444,18 +723,24 @@ declare class Ticker {
444
723
  private static fiveSecondTps;
445
724
  private static fiveSecondTicks;
446
725
  private static schedule;
726
+ /** Starts or resumes the shared tick loop. Repeated calls have no effect. */
447
727
  static start(): void;
728
+ /** Pauses the loop while retaining callbacks for a later {@link start}. */
448
729
  static stop(): void;
730
+ /** Registers a callback, starts the loop if needed, and returns an ID for {@link remove}. */
449
731
  static add(tick: TickerFunction): number;
732
+ /** Removes a callback by ID and stops the timers when no callbacks remain. */
450
733
  static remove(c?: number): void;
451
734
  static get tickers(): Map<number, TickerFunction>;
452
735
  static get tpsOneSecond(): number;
453
736
  static get tpsFiveSeconds(): number;
737
+ /** Stops the loop and removes all registered callbacks. */
454
738
  static dispose(): void;
455
739
  }
456
740
 
457
741
  declare const TintColors: never[];
458
742
 
743
+ /** Transform access shared by scene objects and instance references. Positions use scene units and rotations use radians. */
459
744
  interface Transformable {
460
745
  setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
461
746
  setPosition(position: Vector3): void;
@@ -479,22 +764,30 @@ declare function base64encode(str: string): string;
479
764
  declare function base64decode(str: string): string;
480
765
  declare function toRadians(degrees: number): number;
481
766
  declare function toDegrees(radians: number): number;
767
+ /** Resolves after a delay in milliseconds. */
482
768
  declare function sleep(timeout: number): Promise<void>;
769
+ /** Reduces an angle modulo 360, retaining a negative sign for negative inputs. */
483
770
  declare function clampRotationDegrees(deg: number): number;
484
771
  declare function isVector3(obj: any): obj is Vector3;
485
772
  type DeepPartial<T> = {
486
773
  [P in keyof T]?: DeepPartial<T[P]>;
487
774
  };
488
775
 
776
+ /** Loads texture pixels and `.mcmeta` files through the active asset sources. */
489
777
  declare class ModelTextures {
490
778
  private static _persistentMetaCache;
491
779
  private static get PERSISTENT_META_CACHE();
780
+ /** Loads and decodes a texture into a readable canvas, or returns `undefined` when missing. */
492
781
  static get(key: AssetKey): Promise<Maybe<ExtractableImageData>>;
782
+ /** Fetches and caches encoded texture bytes without decoding the pixels. */
493
783
  static preload(key: AssetKey): Promise<Maybe<TextureAsset>>;
784
+ /** Loads a texture's `.mcmeta` file, or returns `undefined` when no metadata file exists. */
494
785
  static getMeta(key: AssetKey): Promise<Maybe<MinecraftTextureMeta>>;
786
+ /** Clears persisted texture metadata. Use {@link Caching.clear} to discard in-memory textures and metadata. */
495
787
  static clearCache(): Promise<void>;
496
788
  }
497
789
 
790
+ /** Wraps a browser or Node canvas for pixel reads and writes. All coordinates and dimensions use pixels. */
498
791
  declare class CanvasImage implements Disposable {
499
792
  readonly canvas: CompatCanvas;
500
793
  readonly context: CanvasRenderingContext2D;
@@ -512,6 +805,7 @@ declare class CanvasImage implements Disposable {
512
805
  dispose(): void;
513
806
  }
514
807
 
808
+ /** A model's combined texture canvas, per-texture rectangles, and shared animation subscriptions. */
515
809
  declare class TextureAtlas implements Disposable {
516
810
  readonly model: Model;
517
811
  readonly image: CanvasImage;
@@ -537,11 +831,13 @@ declare class TextureAtlas implements Disposable {
537
831
  }, hasTransparency: boolean);
538
832
  /** Calls subscribers when an animation frame changes; unused atlases do not tick. */
539
833
  subscribe(callback: () => void): () => void;
834
+ /** Copies pixels for a texture variable from its current atlas rectangle. */
540
835
  getData(texture: string): ImageData$1;
541
836
  dispose(): void;
542
837
  }
543
838
 
544
839
  declare const DEFAULT_UV: QuadArray;
840
+ /** Maps Minecraft face coordinates to Three.js UVs and builds per-model texture atlases. */
545
841
  declare class UVMapper {
546
842
  protected static makeUv(uvCoord: number, originalTextureSize: number, actualTextureSize: number): number;
547
843
  protected static makeUvCoords([originalTextureWidth, originalTextureHeight]: DoubleArray, [actualTextureWidth, actualTextureHeight]: DoubleArray, [x1, y1, x2, y2]: QuadArray): QuadArray;
@@ -555,7 +851,10 @@ declare class UVMapper {
555
851
  static setCubeUvs(geometry: BoxGeometry, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray, faces: ModelFaces): void;
556
852
  static facesToUvArray(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): number[];
557
853
  static facesToUv(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): Float32BufferAttribute;
854
+ /** Bounds texture sampling to texel centres without changing cropped face UVs. */
855
+ static setAtlasUvBounds(geometry: BoxGeometry, faces: ModelFaces, atlas: TextureAtlas): void;
558
856
  static lockUvs(geometry: BoxGeometry, faces: ModelFaces, atlas: TextureAtlas, rotation: Euler): void;
857
+ /** Returns the shared atlas for a keyed, merged model, creating it on first use. */
559
858
  static getAtlas(model: Model): Promise<Maybe<TextureAtlas>>;
560
859
  static fillMissingTextureKeys<T>(textures: ModelTextures, target: {
561
860
  [k: string]: T;
@@ -564,8 +863,14 @@ declare class UVMapper {
564
863
  };
565
864
  protected static getFallbackUv(element: ModelElement, faceName: CubeFace): QuadArray;
566
865
  protected static expandAndRotateMcUvs([u1, v1, u2, v2]: QuadArray, rotation: number | undefined, actualWidth: number, actualHeight: number): QuadArray<Vector2>;
866
+ /**
867
+ * Combines model textures and animation metadata into an atlas.
868
+ * Mapped UVs are stored on copies of the model's elements, available through the returned atlas.
869
+ * Returns `undefined` for models without a texture map.
870
+ */
567
871
  static createAtlas(originalModel: Model): Promise<Maybe<TextureAtlas>>;
568
872
  }
873
+ /** Stores a Minecraft face's UV rectangle and its rotation in degrees. */
569
874
  declare class MinecraftFaceUV {
570
875
  readonly uv: QuadArray;
571
876
  readonly rotation: number;
@@ -587,23 +892,33 @@ declare class MinecraftFaceUV {
587
892
  */
588
893
  declare function shutdown(): void;
589
894
 
895
+ /** Runs queued tasks in bounded batches. Idle executors do not keep a timer running. */
590
896
  declare class BatchedExecutor {
591
897
  readonly interval: number;
592
898
  readonly batch: number;
593
899
  private readonly queue;
900
+ /**
901
+ * @param interval - Delay between queue runs, in milliseconds.
902
+ * @param batch - Maximum tasks started per run and maximum tasks active at once.
903
+ */
594
904
  constructor(interval?: number, batch?: number);
905
+ /** Queues a task and resolves with its result, or rejects with its error. */
595
906
  submit<T>(task: Task<T>): Promise<T>;
907
+ /** Rejects queued and future tasks. Tasks already running are allowed to finish. */
596
908
  stop(): void;
597
909
  }
598
910
  type Task<T = unknown> = () => T | Promise<T>;
599
911
 
600
912
  declare function prefix(prefix?: string): string;
601
913
 
914
+ /** Rotates geometry in place around the element's origin. The supplied angle is in degrees. */
602
915
  declare function applyElementRotation(rotation: ElementRotation, geometry: BufferGeometry): void;
916
+ /** Rotates an object around a local axis by an angle in degrees. */
603
917
  declare function applyGenericRotation(axis: Axis, rotation: number, obj: Object3D): void;
604
918
  declare function addBox3WireframeToObject(box: Box3, obj: Object3D, color?: number, w?: number): void;
605
919
  declare function addWireframeToObject(obj: Object3D, color?: number, w?: number): void;
606
- declare function addWireframeToMesh(geo: BufferGeometry, mesh: Mesh, color?: number, w?: number): void;
920
+ /** Adds edge and axis helpers to a mesh and returns a function that disposes their resources. */
921
+ declare function addWireframeToMesh(geo: BufferGeometry, mesh: Mesh, color?: number, w?: number): () => void;
607
922
 
608
923
  declare function captureException(e: any, ...extra: any[]): void;
609
924
  declare function timingStart(marker: string): void;
@@ -625,9 +940,13 @@ declare enum AssetParser {
625
940
  JSON = "json"
626
941
  }
627
942
 
943
+ /** An asset provider registered with {@link AssetLoader.addSource}. */
628
944
  declare abstract class AssetSource {
629
945
  protected constructor();
946
+ /** Returns a parsed asset, or `undefined` to allow fallback. Load and parse failures should reject. */
630
947
  abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
948
+ /** Whether this source prevents lower-priority sources from supplying the key. Its own assets remain available. */
949
+ blocks(key: AssetKey): boolean | Promise<boolean>;
631
950
  /**
632
951
  * Identifies this source's content across sessions for persistent caching. Sources that
633
952
  * cannot tell whether their content changed (an unnamed archive, for example) return
@@ -644,12 +963,15 @@ declare class AssetLoadError extends Error {
644
963
  constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
645
964
  }
646
965
 
966
+ /** Loads assets from a shared, ordered registry of hosted sources and resource packs. */
647
967
  declare class AssetLoader {
968
+ /** Default asset base URL. Use {@link setVersion} to select a Minecraft version. */
648
969
  static ROOT: string;
649
970
  private static _SOURCES;
650
971
  /** Used when a registered source cannot identify its content, so nothing persists past this session. */
651
972
  private static readonly SESSION_SCOPE;
652
973
  static get version(): string;
974
+ /** Selects an mcasset.cloud version, updates the vanilla source, and clears in-memory caches. */
653
975
  static setVersion(version: string): void;
654
976
  /**
655
977
  * Scope for persistent cache keys. Empty with only the default vanilla sources, so their
@@ -659,8 +981,17 @@ declare class AssetLoader {
659
981
  static get persistentScope(): string;
660
982
  /** Prefixes a persistent cache key with the current source scope. */
661
983
  static persistentKey(key: string): string;
984
+ /**
985
+ * Registers a source at the highest priority.
986
+ * Call {@link Caching.clear} after changing sources to discard previously loaded assets.
987
+ *
988
+ * @param key - Name used to replace or remove this source.
989
+ * @param override - Removes the first source with this name before adding the new one.
990
+ */
662
991
  static addSource(key: string, source: AssetSource, override?: boolean): void;
992
+ /** Removes and returns the first source with this name. Call {@link Caching.clear} to reload assets. */
663
993
  static removeSource(key: string): Maybe<AssetSource>;
994
+ /** Loads from all sources and returns defined results in priority order. Any source failure rejects the call. */
664
995
  static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
665
996
  /** Returns the first defined result in source-priority order, without merging assets. */
666
997
  static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
@@ -671,6 +1002,7 @@ declare class AssetLoader {
671
1002
  }>>;
672
1003
  }
673
1004
 
1005
+ /** A Java blockstate file that selects models through variants or multipart conditions. */
674
1006
  interface BlockState extends MinecraftAsset {
675
1007
  variants?: BlockStateVariants;
676
1008
  multipart?: BlockStateMultipart[];
@@ -678,6 +1010,7 @@ interface BlockState extends MinecraftAsset {
678
1010
  type BlockStateVariants = {
679
1011
  [key: string]: BlockStateVariant | BlockStateVariant[];
680
1012
  };
1013
+ /** A model selection with optional x/y rotations in degrees, UV locking, and random-selection weight. */
681
1014
  interface BlockStateVariant {
682
1015
  model?: string;
683
1016
  y?: number;
@@ -689,6 +1022,7 @@ interface BlockStateMultipart {
689
1022
  when?: MultipartCondition;
690
1023
  apply?: BlockStateVariant | BlockStateVariant[];
691
1024
  }
1025
+ /** Property tests combined with AND or OR. A property value such as `north|south` accepts either value. */
692
1026
  type MultipartCondition = Record<string, string> | {
693
1027
  OR: MultipartCondition[];
694
1028
  } | {
@@ -697,16 +1031,20 @@ type MultipartCondition = Record<string, string> | {
697
1031
 
698
1032
  declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.21.11";
699
1033
  declare const DEFAULT_NAMESPACE = "minecraft";
1034
+ /** Convenience accessors for model and blockstate loading. */
700
1035
  declare class Assets {
701
1036
  /**
702
1037
  * @deprecated
703
1038
  */
704
1039
  static parseAssetKey(assetType: AssetType, str: string, origin?: AssetKey): AssetKey;
1040
+ /** Loads a model with its parent chain resolved. See {@link Models.getMerged}. */
705
1041
  static getModel(key: AssetKey): Promise<Maybe<Model>>;
1042
+ /** Loads a blockstate definition. See {@link BlockStates.get}. */
706
1043
  static getBlockState(key: AssetKey): Promise<Maybe<BlockState>>;
707
1044
  }
708
1045
 
709
1046
  type BlockStatePropertyValue = string | boolean | number;
1047
+ /** A vanilla block property's default and allowed values, loaded through {@link BlockStates.getDefaultState}. */
710
1048
  interface BlockStateProperty {
711
1049
  default: BlockStatePropertyValue;
712
1050
  type: "boolean" | "int" | "enum";
@@ -716,106 +1054,267 @@ interface BlockStateProperty {
716
1054
  type BlockStatePropertyDefaults = {
717
1055
  [key: string]: BlockStateProperty;
718
1056
  };
1057
+ /** Block property values, such as `{ facing: "north", waterlogged: "false" }`. */
719
1058
  type BlockStateProperties = {
720
1059
  [key: string]: string;
721
1060
  };
722
1061
 
1062
+ /** One model drawn by a block-entity renderer. */
1063
+ interface BlockEntityPart {
1064
+ model: string;
1065
+ /** Model layer; defaults to "main". */
1066
+ layer?: string;
1067
+ /** Set only when the texture differs from the layer's default. */
1068
+ textureLocation?: string;
1069
+ /** Blockstate multipart syntax: every property must match, and "a|b" matches either value. */
1070
+ when?: Record<string, string>;
1071
+ }
1072
+ /** Degrees per property value, or degrees per unit of a numeric property. */
1073
+ type BlockEntityRotation = {
1074
+ property: string;
1075
+ degrees: Record<string, number>;
1076
+ } | {
1077
+ property: string;
1078
+ step: number;
1079
+ };
1080
+ /** Models and state-dependent placement for one block ID in the block-entity index. */
1081
+ interface BlockEntityEntry {
1082
+ parts: BlockEntityPart[];
1083
+ rotation?: BlockEntityRotation;
1084
+ /** Offset in model units, applied before the rotation. */
1085
+ translation?: TripleArray;
1086
+ }
1087
+ /** The dataset's `blocks.json`: block ID to the models its block-entity renderer draws. */
1088
+ type BlockEntityIndex = MinecraftAsset & {
1089
+ [block: string]: BlockEntityEntry;
1090
+ };
1091
+ /** Parts and placement selected by {@link BlockEntities.resolve} for a block's properties. */
1092
+ interface ResolvedBlockEntity {
1093
+ parts: BlockEntityPart[];
1094
+ /** Degrees counter-clockwise seen from above, about the block's vertical centre axis. */
1095
+ rotation: number;
1096
+ translation: TripleArray;
1097
+ }
1098
+ /** Resolves blockstate properties into the entity models used to draw chests, beds, and other block entities. */
1099
+ declare class BlockEntities {
1100
+ /**
1101
+ * Loads the block index of a version. Versions and sources without one yield an empty index, and so does
1102
+ * a failed load: the index is optional, and blocks must not retry or fail with it one by one. The empty
1103
+ * result is cached like any other; `Caching.clear()` or `AssetLoader.setVersion()` forces a new attempt.
1104
+ */
1105
+ static getIndex(root?: string): Promise<BlockEntityIndex>;
1106
+ /** The index entry of a block ID such as `minecraft:chest`. */
1107
+ static entry(index: BlockEntityIndex, block: string): Maybe<BlockEntityEntry>;
1108
+ /** Selects the parts and placement for a block ID such as `minecraft:chest`; undefined when nothing is drawn. */
1109
+ static resolve(index: BlockEntityIndex, block: string, state?: BlockStateProperties): Maybe<ResolvedBlockEntity>;
1110
+ /** Placement in block space (0..16 per axis), applied on top of the model's own transform. */
1111
+ static matrix(resolved: ResolvedBlockEntity, matrix?: Matrix4): Matrix4;
1112
+ }
1113
+
1114
+ /** Loads blockstate definitions and the property defaults used to select block models. */
723
1115
  declare class BlockStates {
724
1116
  private static _persistentCache;
725
1117
  private static get PERSISTENT_CACHE();
1118
+ /** Returns blockstate filenames from the selected version's `_list.json`, or an empty list. */
726
1119
  static getList(): Promise<string[]>;
727
1120
  static getDefaultStates(): Promise<Maybe<DefaultBlockStates>>;
1121
+ /** Looks up vanilla property definitions for the key's block path, or returns `undefined`. */
728
1122
  static getDefaultState(key: AssetKey): Promise<Maybe<BlockStatePropertyDefaults>>;
1123
+ /** Loads a cached blockstate definition for {@link MineRenderScene.addBlock}, or returns `undefined`. */
729
1124
  static get(key: AssetKey): Promise<Maybe<BlockState>>;
730
1125
  static getAll(keys: AssetKey[] | Iterable<AssetKey>): Promise<Maybe<BlockState>[]>;
1126
+ /** Clears persisted blockstates. Use {@link Caching.clear} to also discard in-memory assets. */
731
1127
  static clearCache(): Promise<void>;
732
1128
  }
733
1129
  declare class DefaultBlockStates implements MinecraftAsset {
734
1130
  [k: string]: BlockStatePropertyDefaults;
735
1131
  }
736
1132
 
737
- interface EntityLayer {
738
- key: BasicAssetKey;
739
- texture?: AssetKey;
740
- layer: EntityModelLayer;
741
- }
742
- interface EntityModel extends EntityLayer {
1133
+ /** `entity-models/animations/<namespace>/<model id>.json`: native and sampled vanilla animation clips. */
1134
+ interface EntityAnimationFile extends MinecraftAsset {
743
1135
  id: string;
744
- /** Selected layers; the top-level fields describe the first selection. */
745
- layers?: Record<string, EntityLayer>;
746
- }
747
- interface EntityModelFile extends MinecraftAsset {
748
- id: string;
749
- layers: Record<string, EntityModelLayer>;
750
- }
751
- interface EntityModelLayer {
752
- texture: [number, number];
753
- textureLocation?: string;
754
- root: EntityModelPart;
755
- }
756
- interface EntityModelPart {
757
- pose: {
758
- offset: [number, number, number];
759
- rotation: [number, number, number];
760
- scale?: [number, number, number];
761
- };
762
- texture?: [number, number];
763
- cubes: EntityModelCube[];
764
- children: Record<string, EntityModelPart>;
765
- }
766
- interface EntityModelCube {
767
- origin: [number, number, number];
768
- size: [number, number, number];
769
- uv: [number, number];
770
- grow?: [number, number, number];
771
- mirror?: boolean;
772
- }
1136
+ animations: Record<string, EntityAnimation>;
1137
+ }
1138
+ /** A clip of pose offsets, played with {@link EntityObject.playAnimation} or sampled directly. */
1139
+ interface EntityAnimation {
1140
+ /** Seconds. */
1141
+ length: number;
1142
+ loop: boolean;
1143
+ /** Geometry layer targeted by this clip; defaults to `main`. */
1144
+ layer?: string;
1145
+ /** Part name anywhere in a layer; `root` is the layer's root part. */
1146
+ bones: Record<string, EntityAnimationBone>;
1147
+ }
1148
+ type EntityAnimationChannel = "position" | "rotation" | "scale";
1149
+ /** Keyframes in time order per channel. */
1150
+ type EntityAnimationBone = Partial<Record<EntityAnimationChannel, EntityAnimationKeyframe[]>>;
1151
+ /** One timed offset for a part's position, rotation, or scale channel. */
1152
+ interface EntityAnimationKeyframe {
1153
+ /** Seconds. */
1154
+ time: number;
1155
+ /** Offset from the default pose: model units, radians, or scale minus one. */
1156
+ value: TripleArray;
1157
+ /** Value to arrive at when it differs from `value`; linear interpolation only. */
1158
+ pre?: TripleArray;
1159
+ /** Applies between the previous keyframe and this one. */
1160
+ interpolation: "linear" | "catmullrom";
1161
+ }
1162
+ /** Sampled offsets from the default pose, per bone and channel. */
1163
+ type EntityAnimationPose = Record<string, Partial<Record<EntityAnimationChannel, TripleArray>>>;
1164
+ declare const ENTITY_ANIMATION_CHANNELS: readonly EntityAnimationChannel[];
1165
+ /**
1166
+ * Samples one channel like vanilla's `KeyframeAnimation.Entry`: the first value holds before the
1167
+ * first keyframe and the last value after the last one; in between, the later keyframe selects the interpolation.
1168
+ */
1169
+ declare function sampleEntityKeyframes(keyframes: readonly EntityAnimationKeyframe[], time: number): TripleArray;
1170
+ /** Elapsed seconds within the animation: modulo `length` when looping, as vanilla does. */
1171
+ declare function entityAnimationTime(animation: EntityAnimation, time: number, loop?: boolean): number;
1172
+ /** Samples every bone and channel of an animation at `time` seconds. */
1173
+ declare function sampleEntityAnimation(animation: EntityAnimation, time: number, loop?: boolean): EntityAnimationPose;
773
1174
 
1175
+ /** Loads entity and block-entity geometry, texture selections, and animation clips from the dataset. */
774
1176
  declare class Entities {
1177
+ /** Lists model paths in the `minecraft` namespace, including subdirectories and excluding `.json`. */
775
1178
  static getEntityList(): Promise<string[]>;
776
1179
  private static getModelFile;
1180
+ /** Returns selectable geometry-layer names, or an empty list when the model is missing. */
777
1181
  static getLayerList(modelKey: BasicAssetKey): Promise<string[]>;
1182
+ /** The dataset's extra draws on top of `main`; their `when` labels are the states `EntityModelOptions.when` can enable. */
1183
+ static getPassList(modelKey: BasicAssetKey): Promise<EntityModelPass[]>;
1184
+ /**
1185
+ * Loads the layers and textures to pass to {@link MineRenderScene.addEntity}.
1186
+ * By default, selects `main`, unconditional passes, and passes enabled by `options.when`.
1187
+ *
1188
+ * @param modelKey - Dataset model, such as `new BasicAssetKey("minecraft", "zombie")`.
1189
+ * @param textureKey - Texture override for the first selected layer.
1190
+ * @param options - Layer selection, conditional passes, and per-layer texture overrides.
1191
+ * @returns The selected model, or `undefined` when its dataset file is missing.
1192
+ */
778
1193
  static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
1194
+ /**
1195
+ * Native and sampled vanilla clips by name, or undefined when the model or selected version has none.
1196
+ */
1197
+ static getAnimations(modelKey: BasicAssetKey): Promise<Maybe<Record<string, EntityAnimation>>>;
1198
+ /** Finds a fallback texture using the model path, its directory, and vanilla variant data. */
779
1199
  static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
780
1200
  /** @deprecated Use getEntityList(); block entities share the entity dataset. */
781
1201
  static getBlockList(): Promise<string[]>;
782
1202
  /** @deprecated Use getEntity(); block entities share the entity dataset. */
783
1203
  static getBlock(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
784
1204
  }
1205
+ /** Selection settings passed as the third argument to {@link Entities.getEntity}. */
785
1206
  interface EntityModelOptions {
1207
+ /** Selects one geometry layer without dataset passes. `layers` takes precedence when supplied. */
786
1208
  layer?: string;
787
- /** Layer names in draw order; defaults to layer or "main". */
1209
+ /** Layer names in draw order; an explicit selection draws exactly these layers and no dataset passes. */
788
1210
  layers?: string[];
789
- /** Per-layer texture overrides. The positional texture key applies to the first selected layer. */
1211
+ /**
1212
+ * Entity states that enable the dataset's conditional passes, e.g. `["powered"]` for a charged creeper.
1213
+ * Without `layer`/`layers`, `main` and every unconditional pass are always drawn.
1214
+ */
1215
+ when?: string[];
1216
+ /** Per-layer texture overrides, keyed like `EntityModel.layers`. The positional texture key applies to the first selected layer. */
790
1217
  textures?: Record<string, BasicAssetKey>;
791
1218
  }
792
1219
 
1220
+ /** A glyph's source pixels and layout metrics. Glyphs without an image contribute spacing only. */
1221
+ interface BitmapGlyph {
1222
+ image?: CompatCanvas;
1223
+ /** Source rectangle in the bitmap sheet, before applying scale. */
1224
+ x: number;
1225
+ y: number;
1226
+ width: number;
1227
+ height: number;
1228
+ scale: number;
1229
+ ascent: number;
1230
+ advance: number;
1231
+ }
1232
+ /** Character-to-glyph lookup assembled from the active resource-pack fonts. */
1233
+ interface BitmapFont {
1234
+ glyphs: Map<string, BitmapGlyph>;
1235
+ }
1236
+ /** Loads Minecraft bitmap, space, and reference font providers for GUI text. */
1237
+ declare class Fonts {
1238
+ /** Combines font definitions in source-priority order. Unsupported Unihex and TrueType providers are skipped. */
1239
+ static get(key?: AssetKey | string): Promise<BitmapFont>;
1240
+ private static relatedKey;
1241
+ private static load;
1242
+ private static bitmap;
1243
+ }
1244
+
1245
+ /** Caller-supplied item-preview state passed to {@link Models.getMerged}. */
1246
+ interface ItemModelContext {
1247
+ /** Context used by display-context selectors, overriding `properties`. Defaults to GUI. */
1248
+ displayContext?: DisplayPosition | "none";
1249
+ /** Explicit property overrides. Nodes with the same ID share one override, regardless of their parameters. */
1250
+ properties?: Record<string, boolean | string | number>;
1251
+ /** Supplied component JSON by ID. Item-registry defaults are not added; component selectors compare structural JSON values. */
1252
+ components?: Record<string, unknown>;
1253
+ /** Stack count, as a nonnegative integer. Defaults to 1; absent `max_stack_size` also defaults to 1. */
1254
+ count?: number;
1255
+ /** Item-model keys by reference-node ID, such as `minecraft:bundle/selected_item`. Unset references draw nothing. */
1256
+ itemReferences?: Record<string, AssetKey>;
1257
+ }
1258
+ /** Loads and caches Java block/item models, including inherited geometry and textures. */
793
1259
  declare class Models {
794
1260
  private static _persistentCache;
795
1261
  private static get PERSISTENT_CACHE();
1262
+ /** Lists item filenames from the asset source's `_list.json`, with a legacy model-directory fallback. */
796
1263
  static getItemList(): Promise<string[]>;
797
- static loadAndMerge(key: AssetKey): Promise<Maybe<Model>>;
1264
+ static loadAndMerge(key: AssetKey, context?: ItemModelContext): Promise<Maybe<Model>>;
798
1265
  private static getItemModel;
799
- private static defaultItemModel;
1266
+ private static contextIdentifier;
1267
+ private static snapshotContext;
1268
+ private static contextKey;
1269
+ private static snapshotJson;
1270
+ private static propertyValue;
1271
+ private static selectItemModel;
1272
+ /** Loads one model file without resolving its parents. Returns `undefined` when the file is missing. */
800
1273
  static getRaw(key: AssetKey): Promise<Maybe<Model>>;
801
- static getMerged(key: AssetKey): Promise<Maybe<Model>>;
802
- static get(key: AssetKey): Promise<Maybe<Model>>;
1274
+ /**
1275
+ * Loads a model and resolves its parent chain. Returns `undefined` when the model is missing.
1276
+ * Item keys default to GUI context and a stack count of 1. Unresolved conditions are false and numeric properties are zero.
1277
+ * Pass `context` to supply component values, property overrides, and item references for a preview.
1278
+ * Composite items retain independently merged children in `ItemModel.parts`.
1279
+ *
1280
+ * @param key - Model key, for example `AssetKey.parse("models", "minecraft:item/diamond_sword")`.
1281
+ */
1282
+ static getMerged(key: AssetKey, context?: ItemModelContext): Promise<Maybe<Model>>;
1283
+ /** Alias for {@link getMerged}. */
1284
+ static get(key: AssetKey, context?: ItemModelContext): Promise<Maybe<Model>>;
1285
+ /** Clears persisted models. Use {@link Caching.clear} to also discard in-memory assets. */
803
1286
  static clearCache(): Promise<void>;
804
1287
  }
805
1288
 
1289
+ /** Resolves Minecraft display poses and applies them to model geometry. */
806
1290
  declare class DisplayTransforms {
807
1291
  /** Resolve hand fallbacks within one model, before inheriting parent display entries. */
808
1292
  static withHandFallbacks(display: Model["display"]): Model["display"];
809
1293
  /** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
810
1294
  static getMatrix(display: Model["display"], position: DisplayPosition): Matrix4;
1295
+ /** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
811
1296
  static apply(geometry: BufferGeometry, matrix: Matrix4): void;
812
1297
  }
813
1298
 
1299
+ /** Resolves item-preview colors from vanilla tint definitions, stack components, and caller overrides. */
1300
+ declare class ItemTints {
1301
+ /** Resolves preview colors from item definitions; explicit per-index colors take precedence. */
1302
+ static get(model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
1303
+ private static componentField;
1304
+ private static colorOrDefault;
1305
+ private static componentColor;
1306
+ private static rgb;
1307
+ }
1308
+
1309
+ /** Identifies fully opaque cubes and maps neighbor visibility to model-local face masks. */
814
1310
  declare class ModelCulling {
1311
+ /** Rotates a world-direction bit mask into model space. Bits follow {@link CUBE_FACES}. */
815
1312
  static toLocalMask(worldMask: number, rotation: Euler): number;
1313
+ /** Whether a model fills one block with opaque faces and can hide adjacent block faces. */
816
1314
  static isOpaqueFullCube(atlas: Maybe<TextureAtlas>): boolean;
817
1315
  }
818
1316
 
1317
+ /** Builds extruded item-model elements from sprite pixels, including edges around transparent regions. */
819
1318
  declare class ModelGenerator {
820
1319
  static readonly ITEM_LAYERS: string[];
821
1320
  /**
@@ -825,37 +1324,66 @@ declare class ModelGenerator {
825
1324
  static generateItemModel(imageData: Pick<ImageData$1, "width" | "height" | "data">, layer: string): ModelElement[];
826
1325
  }
827
1326
 
1327
+ /** Resolves Java model inheritance, with child elements and display poses overriding their parents. */
828
1328
  declare class ModelMerger {
1329
+ /** Loads the parent chain and returns a merged model without modifying the supplied definition. */
829
1330
  static mergeWithParents(model: Model): Promise<Model>;
830
1331
  protected static collectAllParents(model: Model): Promise<Model[]>;
831
1332
  }
832
1333
 
1334
+ /** Entity geometry and placement for a special item preview. Named part rotations use radians. */
1335
+ interface SpecialItemPart {
1336
+ model: EntityModel;
1337
+ transform: Matrix4;
1338
+ rotations: Record<string, TripleArray>;
1339
+ /** Absolute named-part positions in the entity model's coordinate system. */
1340
+ positions?: Record<string, TripleArray>;
1341
+ /** Colors for the entity model's named texture passes. */
1342
+ tints?: Record<string, number>;
1343
+ }
1344
+ /** Loads entity geometry and texture passes for supported special item previews. */
1345
+ declare class SpecialItems {
1346
+ /** Resolves the static entity parts drawn by a special item renderer, in model units. */
1347
+ static getParts(special: SpecialItemRenderer, root?: string, components?: Record<string, unknown>): Promise<SpecialItemPart[]>;
1348
+ /** An owned material with model-preview shading; its entity texture remains shared. */
1349
+ static createMaterial(source: MeshBasicMaterial, shade: boolean): MeshBasicMaterial;
1350
+ }
1351
+
1352
+ /** Block data passed to world setters. `type` is a namespaced ID such as `minecraft:oak_log`. */
833
1353
  interface Block {
834
1354
  type: string;
835
1355
  properties?: BlockStateProperties;
836
1356
  nbt?: any;
837
1357
  }
838
1358
 
1359
+ /** Selects block models from property values, including multipart conditions and weighted alternatives. */
839
1360
  declare class BlockStateResolver {
1361
+ /** Loads vanilla property defaults, falling back to preview values inferred from the blockstate file. */
840
1362
  static defaults(blockState: BlockState): Promise<BlockStateProperties>;
1363
+ /** Selects matching models. Supply `choose` to control selection within each alternatives array. */
841
1364
  static select(blockState: BlockState, state: BlockStateProperties, choose?: (variants: BlockStateVariant | BlockStateVariant[]) => BlockStateVariant): BlockStateVariant[];
1365
+ /** Returns matching model groups before choosing weighted alternatives. */
842
1366
  static matching(blockState: BlockState, state: BlockStateProperties): (BlockStateVariant | BlockStateVariant[])[];
1367
+ /** Selects a random alternative using positive integer weights, each defaulting to 1. */
843
1368
  static choose(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
1369
+ /** Converts blockstate rotations in degrees into the Euler rotation used by model rendering. */
844
1370
  static rotation(variant: BlockStateVariant): Euler;
845
1371
  }
846
1372
 
1373
+ /** Supplies block-preview tint colors from block properties and the active resource pack. */
847
1374
  declare class BlockTints {
848
1375
  /** Resolves block preview colors without biome context; explicit tints take precedence. */
849
1376
  static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
850
- private static grassColor;
851
1377
  }
852
1378
 
1379
+ /** A model that owns reusable instance slots and exposes per-slot transforms to {@link InstanceReference}. */
853
1380
  interface Instanceable {
854
1381
  nextInstance(): InstanceReference<SceneObject>;
855
1382
  removeInstanceAt(index: number): void;
856
1383
  isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
857
1384
  getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
858
1385
  setMatrixAt(index: number, matrix: Matrix4): void;
1386
+ setInstanceVisibleAt(index: number, visible: boolean): void;
859
1387
  setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
860
1388
  setPositionAt(index: number, position: Vector3): void;
861
1389
  getPositionAt(index: number, vector?: Vector3): Vector3;
@@ -866,6 +1394,10 @@ interface Instanceable {
866
1394
  }
867
1395
  declare function isInstanceable(obj: any): obj is Instanceable;
868
1396
 
1397
+ /**
1398
+ * Controls one placement of a shared model. Transform methods affect only this instance.
1399
+ * After {@link removeFromScene} or {@link dispose}, accessing its transforms throws.
1400
+ */
869
1401
  declare class InstanceReference<T extends Instanceable> implements Transformable, Disposable {
870
1402
  readonly instanceable: T;
871
1403
  readonly index: number;
@@ -873,10 +1405,14 @@ declare class InstanceReference<T extends Instanceable> implements Transformable
873
1405
  constructor(instanceable: T, index: number);
874
1406
  nextInstance(): InstanceReference<SceneObject>;
875
1407
  private get activeInstanceable();
1408
+ /** Releases this placement's slot for reuse. Repeated calls have no effect. */
876
1409
  removeFromScene(): void;
877
1410
  dispose(): void;
878
1411
  getMatrix(matrix?: Matrix4): Matrix4;
879
1412
  setMatrix(matrix: Matrix4): void;
1413
+ /** Hides or restores this placement while preserving its transform and allocated slot. */
1414
+ setVisible(visible: boolean): void;
1415
+ /** Updates the supplied transform components. Positions use scene units and rotations use radians. */
880
1416
  setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
881
1417
  setPosition(position: Vector3): void;
882
1418
  getPosition(): Vector3;
@@ -887,13 +1423,18 @@ declare class InstanceReference<T extends Instanceable> implements Transformable
887
1423
  }
888
1424
  declare function isInstanceReference(obj: any): obj is InstanceReference<any>;
889
1425
 
1426
+ /** Shared settings passed to scene-object constructors or the scene's `addModel` and `addBlock` methods. */
890
1427
  interface SceneObjectOptions {
891
1428
  wireframe: boolean;
1429
+ /** Combines compatible model elements into one geometry. */
892
1430
  mergeMeshes: boolean;
1431
+ /** Allows compatible models to share geometry through instance references. */
893
1432
  instanceMeshes: boolean;
1433
+ /** Initial instance capacity. Buffers grow when more placements are added. */
894
1434
  maxInstanceCount: number;
895
1435
  }
896
1436
 
1437
+ /** Builds render geometry from a merged Java model. Create it through {@link MineRenderScene.addModel}. */
897
1438
  declare class ModelObject extends SceneObject {
898
1439
  readonly originalModel: Model;
899
1440
  readonly isModelObject: true;
@@ -903,6 +1444,8 @@ declare class ModelObject extends SceneObject {
903
1444
  private atlasMaterial?;
904
1445
  private atlasTexture?;
905
1446
  private unsubscribeAtlas?;
1447
+ private readonly specialMaterials;
1448
+ private readonly geometries;
906
1449
  blockParent: Maybe<BlockObject>;
907
1450
  private meshesCreated;
908
1451
  constructor(originalModel: Model, options?: Partial<ModelObjectOptions>);
@@ -917,26 +1460,31 @@ declare class ModelObject extends SceneObject {
917
1460
  removeInstanceAt(index: number): void;
918
1461
  disposeAndRemoveAllChildren(): void;
919
1462
  }
1463
+ /** Model settings passed to `scene.addModel(model, options)` or the ModelObject constructor. */
920
1464
  interface ModelObjectOptions extends SceneObjectOptions {
921
1465
  /** Minecraft display pose applied around the model center, before scene transforms. */
922
1466
  displayPosition?: DisplayPosition;
923
1467
  /** Quarter-turn block rotation in radians to compensate when locking UVs. */
924
1468
  uvLockRotation?: TripleArray;
925
- /** sRGB 0xRRGGBB colors by face tint index; omitted indices stay white. */
1469
+ /** sRGB 0xRRGGBB colors by face tint index, overriding automatic item or block preview colors. */
926
1470
  tints?: Record<number, number>;
927
1471
  /** Hidden neighbor directions in CUBE_FACES order, before the model's block rotation. */
928
1472
  cullMask?: number;
929
1473
  }
930
1474
  declare function isModelObject(obj: any): obj is ModelObject;
931
1475
 
1476
+ /** Shares initialized model objects by cache key and allocates references to their placements. */
932
1477
  declare class InstanceManager {
933
1478
  readonly isInstanceManager: true;
934
1479
  protected readonly instanceCache: {
935
1480
  [key: string]: Promise<InstanceReference<SceneObject>>;
936
1481
  };
937
1482
  constructor();
1483
+ /** Allocates a new placement of a cached model, or returns `undefined` if the key is unknown. */
938
1484
  get<T extends SceneObject>(key: string): Promise<Maybe<InstanceReference<T>>>;
1485
+ /** Allocates a placement, calling the supplier once when the shared model is first needed. */
939
1486
  getOrCreate<T extends SceneObject>(key: string, supplier: () => T | Promise<T>): Promise<InstanceReference<T>>;
1487
+ /** Forgets cached models without disposing them or releasing their existing placements. */
940
1488
  reset(): void;
941
1489
  }
942
1490
  declare function isInstanceManager(obj: any): obj is InstanceManager;
@@ -974,6 +1522,14 @@ declare class SkinObject extends SceneObject {
974
1522
  init(): Promise<void>;
975
1523
  protected removeMeshes(): void;
976
1524
  protected createMeshes(): void;
1525
+ /**
1526
+ * Loads a skin texture, detecting slim arms and legacy layouts by default.
1527
+ * To override detection, set `slim` or `legacy` in the options passed to
1528
+ * `new SkinObject(options)` or `scene.addSkin(src, options)`.
1529
+ * Use {@link setSlim} or {@link setLegacy} to change these settings later.
1530
+ *
1531
+ * @param src - URL of the skin texture.
1532
+ */
977
1533
  setSkinTexture(src: string): Promise<void>;
978
1534
  /** Load a cape texture in the selected layout, or pass undefined to remove the cape. */
979
1535
  setCapeTexture(src?: string, layout?: CapeLayout): Promise<void>;
@@ -985,22 +1541,101 @@ declare class SkinObject extends SceneObject {
985
1541
  dispose(): void;
986
1542
  protected getBoxGeometry(part: SkinPart): BoxGeometry;
987
1543
  }
1544
+ /** Player settings passed to `new SkinObject(options)` or `scene.addSkin(src, options)`. */
988
1545
  interface SkinObjectOptions extends SceneObjectOptions {
1546
+ /** Forces slim (`true`) or classic (`false`) arms. Omit it to detect the model from the texture. */
989
1547
  slim?: boolean;
1548
+ /** Forces the legacy (`true`) or modern (`false`) texture layout. Omit it to detect the layout. */
990
1549
  legacy?: boolean;
991
1550
  }
992
1551
 
1552
+ /** Playback settings passed to {@link EntityObject.playAnimation}, {@link EntityObject.playAnimations}, or {@link EntityAnimationPlayer.play}. */
1553
+ interface EntityAnimationOptions {
1554
+ /** Overrides the animation's own `loop` flag. */
1555
+ loop?: boolean;
1556
+ /** Playback rate applied to advanced time; defaults to 1. */
1557
+ speed?: number;
1558
+ /** Start time in seconds; defaults to 0. */
1559
+ time?: number;
1560
+ }
1561
+ /**
1562
+ * Poses part groups from a keyframe animation the way vanilla does: every update restores the
1563
+ * default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.
1564
+ * It owns no timer; the owner advances it.
1565
+ */
1566
+ declare class EntityAnimationPlayer {
1567
+ private parts;
1568
+ private _animation?;
1569
+ private _time;
1570
+ private loop;
1571
+ private speed;
1572
+ get animation(): EntityAnimation | undefined;
1573
+ get time(): number;
1574
+ /**
1575
+ * Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
1576
+ * without them, the current pose is used. Stopping restores the pose from before playback.
1577
+ */
1578
+ play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
1579
+ /** Restores the poses from before playback. Returns whether an animation was active. */
1580
+ stop(): boolean;
1581
+ /** Forgets the animation without touching the parts, for parts that no longer exist. */
1582
+ clear(): void;
1583
+ /** Applies the pose at an absolute playback time. Returns `false` when no clip is active. */
1584
+ setTime(seconds: number): boolean;
1585
+ /** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */
1586
+ advance(deltaSeconds: number): boolean;
1587
+ private apply;
1588
+ }
1589
+
1590
+ /** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */
993
1591
  declare class EntityObject extends SceneObject {
994
1592
  readonly entity: EntityModel;
995
1593
  readonly isEntityObject: true;
996
1594
  static readonly DEFAULT_OPTIONS: EntityObjectOptions;
997
1595
  readonly options: EntityObjectOptions;
998
1596
  private meshesCreated;
1597
+ private readonly geometries;
1598
+ private readonly disposeWireframes;
1599
+ /** Scrolling materials are owned: their texture offset follows this entity's age. */
1600
+ private readonly scrollMaterials;
1601
+ private scrollTicker;
1602
+ /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
1603
+ age: number;
1604
+ private readonly animationPlayers;
1605
+ private readonly partPoses;
999
1606
  constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
1000
1607
  init(): Promise<void>;
1001
1608
  dispose(): void;
1609
+ disposeAndRemoveAllChildren(): void;
1610
+ private clearScrollMaterials;
1611
+ private updateScrollSubscription;
1612
+ /** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
1613
+ private updateScroll;
1614
+ /** The first active clip, until playback is stopped or the object is disposed. */
1615
+ get animation(): Maybe<EntityAnimation>;
1616
+ /** Clips playing together, each targeting a separate geometry layer. */
1617
+ get activeAnimations(): readonly EntityAnimation[];
1618
+ /** Seconds since the animation started, before looping. */
1619
+ get animationTime(): number;
1620
+ /**
1621
+ * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
1622
+ * Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
1623
+ * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1624
+ */
1625
+ playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1626
+ /** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
1627
+ playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
1628
+ /** Stops all clips and restores the poses from before playback. */
1629
+ stopAnimation(): void;
1630
+ /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
1631
+ setAnimationTime(seconds: number): void;
1632
+ /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
1633
+ advanceAnimation(deltaSeconds: number): void;
1634
+ /** Finds a selected draw by its layer key, such as `main` or `main#2`, or returns `undefined`. */
1002
1635
  getLayerGroup(name: string): Maybe<Object3D>;
1636
+ /** Finds a part name without `group:`. Supply `layerName` to restrict the search to one draw. */
1003
1637
  getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
1638
+ /** Finds a mesh name without `mesh:`. Supply `layerName` to restrict the search to one draw. */
1004
1639
  getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
1005
1640
  private get entityLayers();
1006
1641
  private getTextureKey;
@@ -1009,23 +1644,99 @@ declare class EntityObject extends SceneObject {
1009
1644
  private createPart;
1010
1645
  protected applyTextures(): Promise<void>;
1011
1646
  }
1647
+ /** Render settings passed to `scene.addEntity(entity, options)` or the EntityObject constructor. */
1012
1648
  interface EntityObjectOptions extends SceneObjectOptions {
1649
+ /**
1650
+ * `true` applies only vanilla's entity flip, scale (-1, -1, 1); `false` keeps raw model space.
1651
+ * By default the model's dataset transform is used, or the flip for models without one.
1652
+ */
1013
1653
  flip?: boolean;
1654
+ /** Colours for the dataset's tint labels, e.g. `{ wool_color: 0xf9801d }`; a pass whose label is absent stays untinted. */
1655
+ tints?: Record<string, ColorRepresentation>;
1014
1656
  }
1015
1657
  declare function isEntityObject(obj: any): obj is EntityObject;
1016
1658
 
1017
- /** A texture layer in GUI pixels. Later layers draw above earlier layers. */
1018
- interface GuiLayer {
1659
+ /** Text appearance set on a GUI text layer or overridden by an individual text run. */
1660
+ interface GuiTextStyle {
1661
+ /** sRGB 0xRRGGBB; defaults to white. */
1662
+ color?: number;
1663
+ bold?: boolean;
1664
+ italic?: boolean;
1665
+ }
1666
+ /** A text segment with optional style overrides within {@link GuiText}. */
1667
+ interface GuiTextRun extends GuiTextStyle {
1668
+ text: string;
1669
+ }
1670
+ /** Literal text, or styled runs. Newlines are preserved. */
1671
+ type GuiText = string | readonly GuiTextRun[];
1672
+ /** Text layout settings set on a GUI text layer or passed to {@link layoutGuiText}. */
1673
+ interface GuiTextOptions extends GuiTextStyle {
1674
+ /** Font resource ID; defaults to minecraft:default. */
1675
+ font?: AssetKey | string;
1676
+ /** Draws a one-pixel shadow; defaults to true. */
1677
+ shadow?: boolean;
1678
+ /** Wrap width in GUI pixels. Long words break at glyph boundaries. */
1679
+ maxWidth?: number;
1680
+ /** Distance between line origins; defaults to 9 GUI pixels. */
1681
+ lineHeight?: number;
1682
+ }
1683
+ /** One measured glyph and its position in GUI pixels, produced by {@link layoutGuiText}. */
1684
+ interface PositionedGuiGlyph {
1685
+ character: string;
1686
+ glyph?: BitmapGlyph;
1687
+ x: number;
1688
+ y: number;
1689
+ advance: number;
1690
+ style: Required<GuiTextStyle>;
1691
+ }
1692
+ /** Measured glyphs, line widths, and overall dimensions in GUI pixels. */
1693
+ interface GuiTextLayout {
1694
+ glyphs: PositionedGuiGlyph[];
1695
+ lineWidths: number[];
1696
+ width: number;
1697
+ height: number;
1698
+ }
1699
+ /** Measures and wraps text using the same glyph advances used for rendering. */
1700
+ declare function layoutGuiText(text: GuiText, options?: GuiTextOptions): Promise<GuiTextLayout>;
1701
+ /** Creates glyph batches in painter order. Unsupported characters use an outlined missing glyph. */
1702
+ declare function createGuiTextGeometry(layout: GuiTextLayout, shadow?: boolean): {
1703
+ image?: CompatCanvas;
1704
+ geometry: BufferGeometry;
1705
+ }[];
1706
+
1707
+ /** GUI layers use pixel coordinates. Later layers draw above earlier layers. */
1708
+ type GuiLayer = GuiTextureLayer | GuiItemLayer | GuiTextLayer;
1709
+ interface GuiLayerLayout {
1019
1710
  name?: string;
1020
- texture: AssetKey | string;
1021
- /** Source-image pixels: [x, y, width, height], measured from the top left. */
1022
- crop?: [number, number, number, number];
1023
1711
  /** Top-left position; x grows right and y grows down. Defaults to [0, 0]. */
1024
1712
  position?: [number, number];
1025
- /** Output width and height. Defaults to the crop or full image size. */
1713
+ /** Output size; defaults to native texture/text dimensions, and [16, 16] for items. */
1026
1714
  size?: [number, number];
1027
1715
  }
1716
+ /** A texture layer for {@link MineRenderScene.addGui}. Uncropped textures use their `.mcmeta` scaling rules. */
1717
+ interface GuiTextureLayer extends GuiLayerLayout {
1718
+ texture: AssetKey | string;
1719
+ /** Source-image pixels: [x, y, width, height], measured from the top left. Crops ignore sprite scaling. */
1720
+ crop?: [number, number, number, number];
1721
+ }
1722
+ /** An item preview in a 16×16 GUI slot by default, with optional tint overrides. */
1723
+ interface GuiItemLayer extends GuiLayerLayout {
1724
+ /** Model key, such as minecraft:item/stone; uses the model's GUI display pose. */
1725
+ item: AssetKey | string;
1726
+ /** Supplied item state. GUI layers always select models in the GUI display context. */
1727
+ context?: Omit<ItemModelContext, "displayContext">;
1728
+ /** sRGB 0xRRGGBB colors by face tint index, overriding the item's automatic preview colors. */
1729
+ tints?: Record<number, number>;
1730
+ }
1731
+ /** A bitmap-text layer. Set font, wrapping, and style directly on the layer object. */
1732
+ interface GuiTextLayer extends GuiLayerLayout, GuiTextOptions {
1733
+ text: GuiText;
1734
+ }
1028
1735
 
1736
+ /**
1737
+ * Renders ordered texture, item, and text layers. Create it through {@link MineRenderScene.addGui}.
1738
+ * GUI coordinates grow right and down, with one pixel equal to one scene unit.
1739
+ */
1029
1740
  declare class GuiObject extends SceneObject {
1030
1741
  readonly textureLayers: readonly GuiLayer[];
1031
1742
  readonly isGuiObject: true;
@@ -1033,16 +1744,20 @@ declare class GuiObject extends SceneObject {
1033
1744
  readonly bounds: Box2;
1034
1745
  private readonly geometries;
1035
1746
  private readonly ownedMaterials;
1747
+ private readonly textMaterials;
1036
1748
  private initialized;
1037
1749
  constructor(textureLayers: readonly GuiLayer[], options?: Partial<GuiObjectOptions>);
1038
1750
  init(): Promise<void>;
1751
+ private createItem;
1039
1752
  private loadMaterial;
1040
1753
  disposeAndRemoveAllChildren(): void;
1041
1754
  }
1755
+ /** Scene-object settings for `scene.addGui(layers, options)`. GUI objects disable instancing and mesh merging. */
1042
1756
  interface GuiObjectOptions extends SceneObjectOptions {
1043
1757
  }
1044
1758
  declare function isGuiObject(obj: any): obj is GuiObject;
1045
1759
 
1760
+ /** A Three.js scene that initializes Minecraft objects and tracks changes that need a redraw. */
1046
1761
  declare class MineRenderScene extends Scene {
1047
1762
  readonly isMineRenderScene: true;
1048
1763
  static readonly DEFAULT_OPTIONS: MineRenderSceneOptions;
@@ -1056,18 +1771,48 @@ declare class MineRenderScene extends Scene {
1056
1771
  add(...objects: Object3D[]): this;
1057
1772
  remove(...objects: Object3D[]): this;
1058
1773
  private updateObjectRegistration;
1774
+ /** Initializes each object before attaching it to the scene. */
1059
1775
  initAndAdd(...object: SceneObject[]): Promise<this>;
1060
1776
  addSceneObject<A extends BasicMinecraftAsset, T extends SceneObject, O extends SceneObjectOptions>(asset: A, objectSupplier: () => T | Promise<T>, _options?: Partial<O>, parent?: Object3D): Promise<T | InstanceReference<T>>;
1777
+ /**
1778
+ * Adds a model loaded with {@link Models.getMerged}.
1779
+ * Set `options.instanceMeshes` to `false` to create a separate ModelObject.
1780
+ *
1781
+ * @param parent - Object to attach the model to. Defaults to this scene.
1782
+ * @returns The model, or a reference to one placement of a shared model.
1783
+ */
1061
1784
  addModel(model: Model, options?: Partial<ModelObjectOptions>, parent?: Object3D): Promise<ModelObject | InstanceReference<ModelObject>>;
1785
+ /**
1786
+ * Adds the models selected by a blockstate loaded with {@link BlockStates.get}.
1787
+ * Set `options.initialState` to choose block properties such as `facing` or `axis`.
1788
+ * Use the returned object's `setPosition` method to move all of its model parts.
1789
+ */
1062
1790
  addBlock(blockState: BlockState, options?: Partial<BlockObjectOptions>, parent?: Object3D): Promise<BlockObject | InstanceReference<BlockObject>>;
1791
+ /**
1792
+ * Loads a skin and adds an initialized player model.
1793
+ *
1794
+ * @param skin - Texture URL, such as one returned by {@link Skins.fromUuidOrUsername}.
1795
+ * Omit it to assign a texture later with {@link SkinObject.setSkinTexture}.
1796
+ * @param options - Player settings, including `slim` and `legacy` detection overrides.
1797
+ * @param parent - Object to attach the player to. Defaults to this scene.
1798
+ */
1063
1799
  addSkin(skin?: string, options?: Partial<SkinObjectOptions>, parent?: Object3D): Promise<SkinObject>;
1800
+ /** Adds an entity loaded with {@link Entities.getEntity}, using its selected layers and textures. */
1064
1801
  addEntity(entity: EntityModel, options?: Partial<EntityObjectOptions>, parent?: Object3D): Promise<EntityObject | InstanceReference<EntityObject>>;
1802
+ /**
1803
+ * Adds GUI layers in draw order. One GUI pixel equals one scene unit.
1804
+ * Layer positions start at the top left, with positive GUI y pointing down.
1805
+ */
1065
1806
  addGui(layers: readonly GuiLayer[], options?: Partial<GuiObjectOptions>, parent?: Object3D): Promise<GuiObject>;
1066
1807
  }
1067
1808
  interface MineRenderSceneOptions {
1068
1809
  }
1069
1810
  declare function isMineRenderScene(obj: any): obj is MineRenderScene;
1070
1811
 
1812
+ /**
1813
+ * Base for renderable Minecraft objects, with named parts and optional shared instances.
1814
+ * Use {@link notifyDirty} after changing a part directly so the renderer redraws it.
1815
+ */
1071
1816
  declare class SceneObject extends Object3D<Object3DEventMap & {
1072
1817
  change: {};
1073
1818
  }> implements Disposable, Instanceable, Transformable {
@@ -1081,21 +1826,25 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
1081
1826
  protected instanceMesh?: InstancedMesh;
1082
1827
  private readonly instanceReferences;
1083
1828
  private readonly freeInstanceIndices;
1829
+ private readonly hiddenInstanceMatrices;
1084
1830
  constructor(options?: Partial<SceneObjectOptions>);
1085
1831
  set scene(scene: MineRenderScene);
1086
1832
  get scene(): MineRenderScene;
1087
1833
  init(): Promise<void>;
1834
+ /** Marks ancestor scenes for redraw and emits a `change` event. */
1088
1835
  notifyDirty(): void;
1089
1836
  protected createAndAddGroup(name?: string, x?: number, y?: number, z?: number, offsetAxis?: Axis, offset?: number): Object3D;
1090
1837
  protected createGroup(name?: string, x?: number, y?: number, z?: number, offsetAxis?: Axis, offset?: number): Object3D;
1091
1838
  /**
1092
- * Get a group by its name
1839
+ * Finds a named part, such as `head`, without the internal `group:` prefix.
1840
+ * Returns `undefined` when the group does not exist.
1093
1841
  */
1094
1842
  getGroupByName(name: string): Maybe<Object3D>;
1095
1843
  /**
1096
- * Toggle visibility of a group
1097
- * @param name name of the group
1098
- * @param visible set the visibility directly, if not set toggles it
1844
+ * Changes a named group's visibility and requests a redraw.
1845
+ * @param name - Part name without the `group:` prefix.
1846
+ * @param visible - Visibility to assign. Omit it to toggle the current value.
1847
+ * @returns The resulting visibility, or `false` if the group does not exist.
1099
1848
  */
1100
1849
  toggleGroupVisibility(name: string, visible?: boolean): boolean;
1101
1850
  protected addOrReplaceMesh(mesh: Mesh, parent: Object3D, name?: string): void;
@@ -1103,13 +1852,14 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
1103
1852
  protected createMesh(name?: string, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
1104
1853
  protected createInstancedMesh(name: Maybe<string>, geometry: BufferGeometry, material: Material | Material[], count: number): InstancedMesh;
1105
1854
  /**
1106
- * Get a mesh by its name
1855
+ * Finds a named mesh without the internal `mesh:` prefix, or returns `undefined`.
1107
1856
  */
1108
1857
  getMeshByName(name: string): Maybe<Mesh>;
1109
1858
  /**
1110
- * Toggle visibility of a mesh
1111
- * @param name name of the mesh
1112
- * @param visible set the visibility directly, if not set toggles it
1859
+ * Changes a named mesh's visibility and requests a redraw.
1860
+ * @param name - Mesh name without the `mesh:` prefix.
1861
+ * @param visible - Visibility to assign. Omit it to toggle the current value.
1862
+ * @returns The resulting visibility, or `false` if the mesh does not exist.
1113
1863
  */
1114
1864
  toggleMeshVisibility(name: string, visible?: boolean): boolean;
1115
1865
  iterateAllMeshes(cb: (mesh: Mesh) => void): void;
@@ -1117,8 +1867,10 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
1117
1867
  protected _getBoxGeometryFromElement(element: ModelElement): BoxGeometry;
1118
1868
  protected _getBoxGeometryForDimensionsAndUv(width: number, height: number, depth: number, uv: number[]): BoxGeometry;
1119
1869
  get isInstanced(): boolean;
1870
+ /** Number of live placements, excluding released instance slots. */
1120
1871
  get instanceCounter(): number;
1121
1872
  protected constructInstanceReference(i: number): InstanceReference<SceneObject>;
1873
+ /** Allocates a placement of this instanced object, reusing a released slot when available. */
1122
1874
  nextInstance(): InstanceReference<SceneObject>;
1123
1875
  /** Returns the live reference for a raycast hit on this object's instance mesh. */
1124
1876
  getInstanceReference(mesh: Object3D, index: number): Maybe<InstanceReference<SceneObject>>;
@@ -1128,6 +1880,7 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
1128
1880
  protected activeInstanceIndices(): Iterable<number>;
1129
1881
  getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
1130
1882
  setMatrixAt(index: number, matrix: Matrix4): void;
1883
+ setInstanceVisibleAt(index: number, visible: boolean): void;
1131
1884
  setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
1132
1885
  setPositionAt(index: number, position: Vector3): void;
1133
1886
  getPositionAt(index: number, vector?: Vector3): Vector3;
@@ -1135,37 +1888,48 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
1135
1888
  getRotationAt(index: number, euler?: Euler): Euler;
1136
1889
  setScaleAt(index: number, scale: Vector3): void;
1137
1890
  getScaleAt(index: number, vector?: Vector3): Vector3;
1891
+ /** Updates supplied transform components. For a shared model, affects every live instance. */
1138
1892
  setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
1893
+ /** Sets position in scene units. For a shared model, updates every live instance. */
1139
1894
  setPosition(position: Vector3): void;
1140
1895
  getPosition(): Vector3;
1896
+ /** Sets rotation in radians. For a shared model, updates every live instance. */
1141
1897
  setRotation(rotation: Euler): void;
1142
1898
  getRotation(): Euler;
1899
+ /** Sets scale factors. For a shared model, updates every live instance. */
1143
1900
  setScale(scale: Vector3): void;
1144
1901
  getScale(): Vector3;
1145
1902
  protected toggleObjectVisibility(object?: Object3D, visible?: boolean): boolean;
1146
1903
  dispose(): void;
1904
+ /** Releases instance slots and removes children, disposing children that implement Disposable. */
1147
1905
  disposeAndRemoveAllChildren(): void;
1906
+ /** Detaches the object from its parent and requests a redraw. */
1148
1907
  removeFromScene(): void;
1149
1908
  }
1150
1909
  declare function isSceneObject(obj: any): obj is SceneObject;
1151
1910
 
1152
1911
  type FluidKind = "water" | "lava";
1912
+ /** Fluid contained in a block and whether the block's ordinary model is also drawn. */
1153
1913
  interface BlockFluidState {
1154
1914
  kind: FluidKind;
1155
1915
  level: number;
1156
1916
  renderModel: boolean;
1157
1917
  }
1918
+ /** Finds water or lava from the block ID and properties, including waterlogged blocks and aquatic plants. */
1158
1919
  declare function getBlockFluidState(key?: AssetKey, state?: BlockStateProperties): BlockFluidState | undefined;
1159
1920
  declare function getFluidKind(key?: AssetKey, state?: BlockStateProperties): FluidKind | undefined;
1921
+ /** A neighboring cell's fluid level and full-cube occlusion state. */
1160
1922
  interface FluidSample {
1161
1923
  fluid?: FluidKind;
1162
1924
  level?: number;
1163
1925
  solid?: boolean;
1164
1926
  }
1927
+ /** Reads cells at integer block offsets relative to the fluid being rendered, with `(0, 0, 0)` as the center. */
1165
1928
  type FluidSampler = (x: number, y: number, z: number) => FluidSample;
1166
1929
  /** Builds centered fluid faces with material groups 0 (still) and 1 (flowing). */
1167
1930
  declare function createFluidGeometry(kind: FluidKind, sample: FluidSampler): BufferGeometry;
1168
1931
 
1932
+ /** Controls the model parts selected by a blockstate. Create it through {@link MineRenderScene.addBlock}. */
1169
1933
  declare class BlockObject extends SceneObject {
1170
1934
  readonly blockState: BlockState;
1171
1935
  readonly isBlockObject: true;
@@ -1183,16 +1947,31 @@ declare class BlockObject extends SceneObject {
1183
1947
  private _fluidKey?;
1184
1948
  private _fluidSampler?;
1185
1949
  private _fluidModel?;
1950
+ private _entities;
1951
+ private _entityPlacement;
1952
+ private _entityGeneration;
1186
1953
  constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
1187
1954
  init(): Promise<void>;
1188
1955
  dispose(): void;
1189
1956
  removeFromScene(): void;
1190
1957
  private clearModels;
1191
1958
  private removeModels;
1959
+ private removeEntities;
1960
+ /** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
1961
+ get blockEntities(): readonly EntityObject[];
1962
+ /** Sets visibility for this block's model instances and block entities. */
1963
+ setVisible(visible: boolean): void;
1964
+ /**
1965
+ * Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
1966
+ * when the block is not listed or one of its models cannot be loaded.
1967
+ */
1968
+ private createBlockEntities;
1969
+ private placeEntities;
1192
1970
  get isOccluding(): boolean;
1193
1971
  private getModelMatrix;
1194
1972
  private getModelCullMask;
1195
1973
  setCullMask(worldMask: number): Promise<void>;
1974
+ /** Selected property values. Use {@link setState} to change properties and rebuild the rendered models. */
1196
1975
  get state(): {
1197
1976
  [key: string]: string;
1198
1977
  };
@@ -1203,10 +1982,17 @@ declare class BlockObject extends SceneObject {
1203
1982
  nextInstance(): InstanceReference<SceneObject>;
1204
1983
  protected mapStateToVariant(state: BlockStateProperties): Promise<BlockStateVariant[]>;
1205
1984
  recreateModels(): Promise<void>;
1985
+ private hasGeometry;
1206
1986
  protected getSingleVariant(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
1207
1987
  protected createAVariant(variants: BlockStateVariant | BlockStateVariant[], instanceInfo: Matrix4[]): Promise<void>;
1208
1988
  protected createVariant(variant: BlockStateVariant): Promise<ModelObject | InstanceReference<ModelObject>>;
1989
+ /** Clears selected properties and rebuilds models without reapplying property defaults. */
1209
1990
  resetState(): Promise<void>;
1991
+ /**
1992
+ * Updates properties and rebuilds the selected models.
1993
+ * Accepts `"facing=north,open=true"`, a property object, or a key and value.
1994
+ * Properties omitted from the call keep their current values.
1995
+ */
1210
1996
  setState(string: string): any;
1211
1997
  setState(state: BlockStateProperties): any;
1212
1998
  setState(key: string, value: string): any;
@@ -1216,7 +2002,9 @@ declare class BlockObject extends SceneObject {
1216
2002
  setMatrixAt(index: number, matrix: Matrix4): void;
1217
2003
  setPosition(position: Vector3): void;
1218
2004
  }
2005
+ /** Block settings passed to `scene.addBlock(blockState, options)` or the BlockObject constructor. */
1219
2006
  interface BlockObjectOptions extends ModelObjectOptions {
2007
+ /** Loads vanilla property defaults before applying `initialState`. Defaults to `true`. */
1220
2008
  applyDefaultState: boolean;
1221
2009
  /** Properties applied before model creation, overriding defaults when applyDefaultState is enabled. */
1222
2010
  initialState?: BlockStateProperties;
@@ -1228,6 +2016,7 @@ declare function sampleFluid(kind: FluidKind, sample: FluidSampler): {
1228
2016
  key: string;
1229
2017
  sample: FluidSampler;
1230
2018
  };
2019
+ /** Renders water or lava with neighbor-dependent surfaces and animated still/flow textures. */
1231
2020
  declare class FluidModelObject extends ModelObject {
1232
2021
  readonly kind: FluidKind;
1233
2022
  private readonly sample;
@@ -1238,28 +2027,50 @@ declare class FluidModelObject extends ModelObject {
1238
2027
  disposeAndRemoveAllChildren(): void;
1239
2028
  }
1240
2029
 
2030
+ /** Parsed blocks and entity data for {@link MineRenderWorld.placeMultiBlock}. Dimensions and positions use blocks. */
1241
2031
  interface MultiBlockStructure {
1242
2032
  readonly size: TripleArray;
1243
2033
  readonly blocks: MultiBlockBlock[];
1244
2034
  readonly dataVersion?: number;
1245
2035
  readonly entities?: MultiBlockEntity[];
1246
2036
  }
2037
+ /** Preserved entity position and NBT. World placement does not create a render object for it. */
1247
2038
  interface MultiBlockEntity {
1248
2039
  position: TripleArray;
1249
2040
  blockPosition?: TripleArray;
1250
2041
  nbt: unknown;
1251
2042
  }
2043
+ /** Block data and its position within a parsed structure. */
1252
2044
  interface MultiBlockBlock extends Block {
1253
2045
  position: TripleArray;
1254
2046
  }
1255
2047
 
2048
+ /** Converts legacy Alpha `.schematic` NBT with numeric block IDs into modern block names and properties. */
1256
2049
  declare class SchematicParser {
1257
- static parse(nbt: NBT): Promise<MultiBlockStructure>;
2050
+ /**
2051
+ * Parses a legacy schematic using custom mappings before the bundled defaults.
2052
+ * Keys are `id:metadata`; values are block states such as `minecraft:oak_log[axis=x]`.
2053
+ */
2054
+ static parse(nbt: NBT, customMappings?: Readonly<Record<string, string>>, options?: SchematicParserOptions): Promise<MultiBlockStructure>;
2055
+ }
2056
+ interface SchematicParserOptions {
2057
+ /**
2058
+ * Ignores Materials, tries metadata 0 for unmapped states, and skips unknown IDs. Defaults to false.
2059
+ * Dimensions, arrays, and entity data remain validated.
2060
+ */
2061
+ lenient?: boolean;
1258
2062
  }
1259
2063
 
2064
+ /** Converts Java structure NBT into blocks and preserved entity data for world placement. */
1260
2065
  declare class StructureParser {
2066
+ /**
2067
+ * Parses decoded NBT, omitting air blocks.
2068
+ * @param _nbt - Structure data decoded by {@link NBTHelper.fromBuffer}.
2069
+ * @param paletteIndex - Palette to select when the structure has several. Defaults to 0.
2070
+ */
1261
2071
  static parse(_nbt: NBT, paletteIndex?: number): Promise<MultiBlockStructure>;
1262
2072
  }
2073
+ /** Tagged NBT fields used by Java structure files. */
1263
2074
  interface StructureNBT {
1264
2075
  DataVersion?: {
1265
2076
  type: "int";
@@ -1355,20 +2166,27 @@ interface BlockEntry {
1355
2166
  };
1356
2167
  }
1357
2168
 
2169
+ /** Decodes Named Binary Tag (NBT) data for structure and world parsers. */
1358
2170
  declare class NBTHelper {
2171
+ /** Parses NBT bytes and preserves format and compression metadata. Omit `format` for automatic detection. */
1359
2172
  static fromBuffer(data: Uint8Array | ArrayBuffer, format?: NBTFormat): Promise<NBTAsset>;
1360
2173
  }
2174
+ /** Decoded NBT with the source format and parser metadata attached. */
1361
2175
  interface NBTAsset extends MinecraftAsset, NBT {
1362
2176
  format?: NBTFormat;
1363
2177
  metadata?: Metadata;
1364
2178
  compression?: "gzip" | "none";
1365
2179
  }
1366
2180
 
2181
+ /** Configures a hosted asset request and converts its response into an asset. */
1367
2182
  interface ResponseParser<T extends MinecraftAsset> {
2183
+ /** Sets response decoding or other request options before the request starts. */
1368
2184
  config(request: RequestConfig): any;
2185
+ /** Returns `undefined` to permit source fallback, or throws to report a parse failure. */
1369
2186
  parse(response: RequestResponse): Maybe<T> | Promise<Maybe<T>>;
1370
2187
  }
1371
2188
 
2189
+ /** Loads assets over HTTP from a Minecraft directory tree rooted at the constructor's URL. */
1372
2190
  declare class HostedAssetSource extends AssetSource {
1373
2191
  static readonly MODEL: ResponseParser<Model>;
1374
2192
  static readonly BLOCKSTATE: ResponseParser<BlockState>;
@@ -1378,11 +2196,16 @@ declare class HostedAssetSource extends AssetSource {
1378
2196
  static readonly LIST: ResponseParser<ListAsset>;
1379
2197
  static readonly JSON: ResponseParser<any>;
1380
2198
  static readonly PARSER_MAP: Map<AssetParser, ResponseParser<any>>;
2199
+ /** Retries missing assets with the `minecraft` namespace and default root. Other failures reject. */
1381
2200
  loadOrRetryWithDefaults<T extends MinecraftAsset>(key: AssetKey, parser: ResponseParser<T>): Promise<Maybe<T>>;
1382
2201
  protected load<T extends MinecraftAsset>(key: AssetKey, parser: ResponseParser<T>): Promise<Maybe<T>>;
1383
2202
  assetBasePath(key: AssetKey): string;
1384
2203
  private readonly _root;
1385
2204
  private readonly _options;
2205
+ /**
2206
+ * Creates a hosted source for {@link AssetLoader.addSource}.
2207
+ * Set `options.retryDefaults` to `false` to restrict lookups to the requested namespace and root.
2208
+ */
1386
2209
  constructor(root: string, options?: Partial<HostedAssetSourceOptions>);
1387
2210
  get root(): string;
1388
2211
  get cacheId(): string;
@@ -1393,38 +2216,80 @@ interface HostedAssetSourceOptions {
1393
2216
  retryDefaults: boolean;
1394
2217
  }
1395
2218
 
2219
+ /** A resource-pack ZIP entry, with its archive-relative path and lazily extracted bytes. */
1396
2220
  interface ArchiveEntry {
1397
2221
  filename: string;
1398
2222
  directory: boolean;
1399
2223
  getData(): Promise<Blob>;
1400
2224
  }
1401
2225
 
2226
+ /** Supplies resource-pack entries to {@link ArchiveAssetSource}. */
1402
2227
  interface ArchiveProxy {
1403
2228
  /** Identifies the archive's content across sessions; undefined when it cannot be identified. */
1404
2229
  readonly id?: string;
1405
2230
  getEntries(): Promise<ArchiveEntry[]>;
1406
2231
  }
1407
2232
 
2233
+ /** A resource-pack format; a number selects minor version zero. */
2234
+ type PackFormat = number | readonly [number, number];
2235
+ declare class PackMetadata {
2236
+ private readonly overlays;
2237
+ private readonly filters;
2238
+ readonly hasOverlays: boolean;
2239
+ private constructor();
2240
+ static parse(value: unknown): PackMetadata;
2241
+ /** Returns applicable directories in lookup order, with the last declared overlay first. */
2242
+ overlayDirectories(target: PackFormat): string[];
2243
+ blocks(namespace: string, path: string): boolean;
2244
+ }
2245
+
2246
+ interface ArchiveAssetSourceOptions {
2247
+ /** Target resource-pack format. Omit to look up the version selected by AssetLoader.setVersion. */
2248
+ resourcePackFormat?: PackFormat;
2249
+ /** Target data-pack format, used for assets under data/. Omit to look up the selected version. */
2250
+ dataPackFormat?: PackFormat;
2251
+ }
2252
+ /** Loads assets from resource-pack ZIP entries. Register it with {@link AssetLoader.addSource}. */
1408
2253
  declare class ArchiveAssetSource extends AssetSource implements ArchiveProxy {
1409
2254
  readonly _archiveProxy: ArchiveProxy;
1410
- constructor(archiveProxy: ArchiveProxy);
1411
- static blob(blob: Blob): ArchiveAssetSource;
2255
+ private readonly options;
2256
+ private entries?;
2257
+ private metadata?;
2258
+ constructor(archiveProxy: ArchiveProxy, options?: ArchiveAssetSourceOptions);
2259
+ /** Creates a browser ZIP source from a Blob or File. */
2260
+ static blob(blob: Blob, options?: ArchiveAssetSourceOptions): ArchiveAssetSource;
1412
2261
  get cacheId(): Maybe<string>;
1413
2262
  getEntries(): Promise<ArchiveEntry[]>;
1414
2263
  getEntry(path: string): Promise<Maybe<ArchiveEntry>>;
2264
+ private getMetadata;
2265
+ blocks(key: AssetKey): Promise<boolean>;
1415
2266
  get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
1416
2267
  protected load<T extends MinecraftAsset>(key: AssetKey, parser: ResponseParser<T>): Promise<Maybe<T>>;
1417
2268
  assetBasePath(key: AssetKey): string;
1418
2269
  }
1419
2270
 
2271
+ /** Reads a resource-pack ZIP from a browser Blob or File for {@link ArchiveAssetSource}. */
1420
2272
  declare class BrowserArchiveProxy implements ArchiveProxy {
1421
2273
  readonly _blob: Blob;
1422
2274
  readonly _reader: ZipReader<Blob>;
1423
2275
  readonly id?: string;
2276
+ /**
2277
+ * Opens a ZIP for asset lookup.
2278
+ * @param id - Cache identity for this content. Change it when the pack changes.
2279
+ * A File supplies an identity from its name, size, and modification time when omitted.
2280
+ */
1424
2281
  constructor(blob: Blob, id?: string);
1425
2282
  getEntries(): Promise<ArchiveEntry[]>;
1426
2283
  }
1427
2284
 
2285
+ declare class PackFormats {
2286
+ private static readonly versions;
2287
+ /** Resolves pack formats from Mojang's client metadata hosted on assets.mcasset.cloud. */
2288
+ static get(version: string, type: "assets" | "data"): Promise<PackFormat>;
2289
+ private static load;
2290
+ }
2291
+
2292
+ /** Bedrock client-entity resource references. This schema does not provide a Bedrock renderer. */
1428
2293
  interface BedrockEntityDescription {
1429
2294
  identifier: string;
1430
2295
  materials: {
@@ -1445,6 +2310,7 @@ interface BedrockEntityDescription {
1445
2310
  enable_attachables?: boolean;
1446
2311
  }
1447
2312
 
2313
+ /** Bedrock client-entity JSON schema, provided for typing only. */
1448
2314
  interface BedrockEntityFile {
1449
2315
  format_version: string;
1450
2316
  "minecraft:client_entity": {
@@ -1452,6 +2318,7 @@ interface BedrockEntityFile {
1452
2318
  };
1453
2319
  }
1454
2320
 
2321
+ /** Bedrock bone-and-cube geometry schema, provided for typing only. */
1455
2322
  interface BedrockGeometry {
1456
2323
  visible_bounds_width: number;
1457
2324
  visible_bounds_height: number;
@@ -1479,11 +2346,13 @@ interface BedrockCube {
1479
2346
  inflate?: number;
1480
2347
  }
1481
2348
 
2349
+ /** A versioned Bedrock JSON container for named geometry definitions. */
1482
2350
  interface BedrockGeometryFile {
1483
2351
  format_version: string;
1484
2352
  [key: string]: BedrockGeometry | any;
1485
2353
  }
1486
2354
 
2355
+ /** Shared in-memory caches for loaded assets and render resources. Persistent stores are managed separately. */
1487
2356
  declare class Caching {
1488
2357
  static readonly rawImageCache: AsyncLoadingCache<CacheKey, ImageInfo>;
1489
2358
  static readonly imageDataCache: AsyncLoadingCache<CacheKey, ImageData>;
@@ -1504,9 +2373,14 @@ declare class Caching {
1504
2373
  static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
1505
2374
  static readonly entityModelCache: AsyncLoadingCache<CacheKey, EntityModelFile>;
1506
2375
  static readonly entityTextureCache: AsyncLoadingCache<CacheKey, AssetKey>;
2376
+ static readonly entityAnimationCache: AsyncLoadingCache<CacheKey, EntityAnimationFile>;
2377
+ static readonly blockEntityIndexCache: AsyncLoadingCache<CacheKey, BlockEntityIndex>;
2378
+ static readonly fontCache: AsyncLoadingCache<CacheKey, BitmapFont>;
2379
+ static readonly bannerPatternCache: AsyncLoadingCache<CacheKey, BannerPattern>;
1507
2380
  private static createAssetCache;
1508
2381
  /** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
1509
2382
  private static get all();
2383
+ /** Invalidates in-memory entries so later lookups reload them. Persisted entries are retained. */
1510
2384
  static clear(): void;
1511
2385
  /**
1512
2386
  * Clears every cache and stops its expiry timer.
@@ -1521,11 +2395,13 @@ declare class Caching {
1521
2395
  /** Copies the nontransparent bounds without resizing the source; empty images become one transparent pixel. */
1522
2396
  declare function trimCanvas(source: CompatCanvas): CompatCanvas;
1523
2397
 
2398
+ /** Reports invalid Minecraft data or an unsupported rendering operation. */
1524
2399
  declare class MineRenderError extends Error {
1525
2400
  constructor(msg: any);
1526
2401
  get name(): string;
1527
2402
  }
1528
2403
 
2404
+ /** Settings passed to {@link Renderer.toGLTF} or {@link SceneExporter.toGLTF}. */
1529
2405
  interface SceneGLTFExportOptions {
1530
2406
  /** Returns a GLB ArrayBuffer instead of a glTF object. */
1531
2407
  binary?: boolean;
@@ -1545,10 +2421,116 @@ declare class SceneExporter {
1545
2421
  static toGLTF(root: Object3D, options?: SceneGLTFExportOptions): Promise<Record<string, any> | ArrayBuffer>;
1546
2422
  }
1547
2423
 
2424
+ /** Container coordinates in GUI pixels. Crops refer to vanilla's 256×256 sheets; {@link GuiHelper.container} scales them for resource packs. */
2425
+ declare const GUI_CONTAINER_LAYOUTS: {
2426
+ readonly generic_54: {
2427
+ readonly texture: "minecraft:gui/container/generic_54";
2428
+ readonly crop: readonly [0, 0, 176, 222];
2429
+ readonly slotOrigin: readonly [8, 18];
2430
+ readonly slotOffset: readonly [18, 18];
2431
+ readonly rowSize: 9;
2432
+ readonly slotCount: 54;
2433
+ };
2434
+ readonly crafting_table: {
2435
+ readonly texture: "minecraft:gui/container/crafting_table";
2436
+ readonly crop: readonly [0, 0, 176, 166];
2437
+ readonly slotOrigin: readonly [30, 17];
2438
+ readonly slotOffset: readonly [18, 18];
2439
+ readonly rowSize: 3;
2440
+ readonly slotCount: 9;
2441
+ readonly resultPosition: readonly [124, 35];
2442
+ };
2443
+ };
2444
+ type GuiContainerType = keyof typeof GUI_CONTAINER_LAYOUTS;
2445
+ type GuiBossBarColor = "pink" | "blue" | "red" | "green" | "yellow" | "purple" | "white";
2446
+ type GuiBookButtonState = "hidden" | "normal" | "hover";
2447
+ /** Creates GUI positions and layer lists for {@link MineRenderScene.addGui}. */
1548
2448
  declare class GuiHelper {
1549
- static inventorySlot(slot: number | [number, number], origin?: [number, number], offset?: [number, number], rowSize?: number): [number, number];
2449
+ /**
2450
+ * Creates a 182×5 boss bar using the active resource pack. Finite progress is clamped to 0–1.
2451
+ * The fill crops the source image; explicit crops do not apply `.mcmeta` sprite scaling.
2452
+ */
2453
+ static bossBar(options?: GuiBossBarOptions): Promise<GuiLayer[]>;
2454
+ /**
2455
+ * Creates a 192×192 book page with optional arrows and supplied text. Buttons are hidden by default.
2456
+ * Callers choose the page content and button states; this helper does not paginate or handle clicks.
2457
+ */
2458
+ static book(options?: GuiBookOptions): Promise<GuiLayer[]>;
2459
+ /** Creates a container background. Use {@link GUI_CONTAINER_LAYOUTS} with {@link inventorySlot} to place its items. */
2460
+ static container(type: GuiContainerType, position?: [number, number]): Promise<GuiLayer[]>;
2461
+ private static validatePosition;
2462
+ private static cropTexture;
2463
+ /** Sizes a tooltip around supplied text; the first entry is its title. */
2464
+ static tooltip(lines: readonly GuiText[], options?: GuiTooltipOptions): Promise<GuiLayer[]>;
2465
+ /**
2466
+ * Calculates a slot's top-left position in GUI pixels.
2467
+ * @param slot - Zero-based slot index, or `[column, row]`.
2468
+ * @param origin - Position of the first slot.
2469
+ * @param offset - Horizontal and vertical spacing between slot origins, in pixels.
2470
+ * @param rowSize - Slots per row when `slot` is an index.
2471
+ */
2472
+ static inventorySlot(slot: number | readonly [number, number], origin?: readonly [number, number], offset?: readonly [number, number], rowSize?: number): [number, number];
2473
+ /** Creates crafting-table layers for ingredients and the result; stack counts are not drawn. */
2474
+ static recipe(recipe: GuiRecipe, options?: GuiRecipeOptions): GuiLayer[];
2475
+ }
2476
+ /** Settings passed to {@link GuiHelper.bossBar}. */
2477
+ interface GuiBossBarOptions {
2478
+ /** Vanilla sprite color. Defaults to `pink`. */
2479
+ color?: GuiBossBarColor;
2480
+ /** Fill from 0 to 1, rounded to vanilla's discrete pixel width. Defaults to 1. */
2481
+ progress?: number;
2482
+ /** Top-left position in GUI pixels. Defaults to `[0, 0]`. */
2483
+ position?: [number, number];
2484
+ }
2485
+ /** Settings passed to {@link GuiHelper.book}. Text defaults to black, unshadowed, and wrapped at 114 pixels. */
2486
+ interface GuiBookOptions extends GuiTextOptions {
2487
+ /** Top-left position of the book background in GUI pixels. Defaults to `[0, 0]`. */
2488
+ position?: [number, number];
2489
+ previous?: GuiBookButtonState;
2490
+ next?: GuiBookButtonState;
2491
+ /** Content for one page. The caller keeps it within the 128-pixel text height. */
2492
+ text?: GuiText;
2493
+ }
2494
+ /** Settings passed to {@link GuiHelper.tooltip}. Its default `lineHeight` is 10 GUI pixels. */
2495
+ interface GuiTooltipOptions extends GuiTextOptions {
2496
+ /** Top-left text position, inside the tooltip's padding. */
2497
+ position?: [number, number];
2498
+ /** Extra space after the title, in pixels. Defaults to 2. */
2499
+ titleGap?: number;
2500
+ }
2501
+ type GuiRecipeIngredientValue = string | {
2502
+ item: string;
2503
+ } | {
2504
+ tag: string;
2505
+ };
2506
+ /** An item, tag, or alternatives list. Tags and alternatives need `GuiRecipeOptions.resolveIngredient`. */
2507
+ type GuiRecipeIngredient = GuiRecipeIngredientValue | readonly GuiRecipeIngredientValue[];
2508
+ /** Shaped or shapeless crafting data accepted by {@link GuiHelper.recipe}. */
2509
+ type GuiRecipe = ({
2510
+ type: "minecraft:crafting_shaped" | "crafting_shaped";
2511
+ pattern: readonly string[];
2512
+ key: Readonly<Record<string, GuiRecipeIngredient>>;
2513
+ } | {
2514
+ type: "minecraft:crafting_shapeless" | "crafting_shapeless";
2515
+ ingredients: readonly GuiRecipeIngredient[];
2516
+ }) & {
2517
+ result: {
2518
+ id: string;
2519
+ count?: number;
2520
+ } | {
2521
+ item: string;
2522
+ count?: number;
2523
+ };
2524
+ };
2525
+ /** Settings passed as the second argument to {@link GuiHelper.recipe}. */
2526
+ interface GuiRecipeOptions {
2527
+ /** Selects a concrete item ID or model AssetKey for a tag or alternatives array. */
2528
+ resolveIngredient?: (ingredient: GuiRecipeIngredient) => string | AssetKey;
1550
2529
  }
1551
2530
 
2531
+ /** Builds one centered mesh; explicit source-pixel crops always stretch. */
2532
+ declare function createGuiTextureGeometry(width: number, height: number, imageWidth: number, imageHeight: number, crop?: [number, number, number, number], scaling?: GuiSpriteScaling): BufferGeometry;
2533
+
1552
2534
  declare class OrbitControls {
1553
2535
  constructor(object: Camera, domElement?: HTMLElement);
1554
2536
 
@@ -1626,6 +2608,11 @@ declare class MapControls extends OrbitControls {
1626
2608
  constructor(object: Camera, domElement?: HTMLElement);
1627
2609
  }
1628
2610
 
2611
+ /**
2612
+ * Renders a Minecraft scene with a camera and an optional effects composer.
2613
+ * Requires a browser DOM and WebGL. Call {@link appendTo} to attach the canvas,
2614
+ * then {@link start} to render scene changes.
2615
+ */
1629
2616
  declare class Renderer implements Disposable {
1630
2617
  static readonly DEFAULT_OPTIONS: RendererOptions;
1631
2618
  readonly options: RendererOptions;
@@ -1641,7 +2628,10 @@ declare class Renderer implements Disposable {
1641
2628
  protected _frameInterval?: number;
1642
2629
  protected _resizeListener?: () => void;
1643
2630
  private _nextFrameTime?;
2631
+ private _running;
2632
+ private _inAnimationLoop;
1644
2633
  private _disposed;
2634
+ private readonly _frameCallbacks;
1645
2635
  private readonly _debugHelpers;
1646
2636
  private readonly _eventDispatchers;
1647
2637
  private readonly _changeListener;
@@ -1653,16 +2643,26 @@ declare class Renderer implements Disposable {
1653
2643
  protected createControls(): Maybe<OrbitControls>;
1654
2644
  init(): void;
1655
2645
  get element(): Maybe<HTMLElement>;
2646
+ /** Attaches the canvas to an element and sizes it to that element's dimensions. */
1656
2647
  appendTo(element: HTMLElement): void;
1657
2648
  /**
1658
2649
  * Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
1659
2650
  * The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
1660
2651
  */
1661
2652
  registerEventDispatcher(dispatcher: EventDispatcher<any>, changeEvent?: string): void;
2653
+ /** Updates the camera and canvas size. Width and height are in CSS pixels. */
1662
2654
  resize(width: number, height: number): void;
1663
2655
  get dirty(): boolean;
1664
2656
  set dirty(dirty: boolean);
2657
+ /**
2658
+ * Calls a synchronous animation update before each FPS-limited draw while started.
2659
+ * Subscriptions keep the scene drawing without manual dirty flags. Returns an unsubscribe function.
2660
+ * Registering the same callback twice has no effect. Image exports do not invoke callbacks.
2661
+ */
2662
+ onFrame(callback: FrameCallback): () => void;
2663
+ /** Starts or resumes the animation loop and registered frame callbacks. */
1665
2664
  start(): void;
2665
+ /** Pauses rendering and frame callbacks. Call {@link start} to resume. */
1666
2666
  stop(): void;
1667
2667
  /**
1668
2668
  * Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
@@ -1678,8 +2678,11 @@ declare class Renderer implements Disposable {
1678
2678
  * MIME type support and lossy quality (0–1) follow the canvas encoder.
1679
2679
  */
1680
2680
  toImage(trim?: boolean, mime?: string, quality?: number): string;
2681
+ /** Exports visible scene meshes as OBJ text, without texture images. */
1681
2682
  toObj(): string;
2683
+ /** Exports visible scene meshes as PLY. Set `options.binary` for an ArrayBuffer. */
1682
2684
  toPLY(options?: PLYExporterOptions): string | ArrayBuffer;
2685
+ /** Exports a static textured scene in the browser. Set `options.binary` for GLB output. */
1683
2686
  toGLTF(options?: SceneGLTFExportOptions): Promise<Record<string, any> | ArrayBuffer>;
1684
2687
  protected get attachedToBody(): boolean;
1685
2688
  protected get viewWidth(): number;
@@ -1691,6 +2694,16 @@ declare class Renderer implements Disposable {
1691
2694
  /** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
1692
2695
  get controls(): Maybe<OrbitControls>;
1693
2696
  }
2697
+ /** Timing passed to callbacks registered with {@link Renderer.onFrame}. */
2698
+ interface RendererFrame {
2699
+ /** Animation-loop timestamp in seconds, relative to the browser's performance time origin. */
2700
+ readonly time: number;
2701
+ /** Seconds since this callback's previous update; zero on its first update after subscribing or starting. */
2702
+ readonly delta: number;
2703
+ }
2704
+ /** A synchronous scene update registered with {@link Renderer.onFrame}. */
2705
+ type FrameCallback = (frame: RendererFrame) => void;
2706
+ /** Settings for `new Renderer(options)`. Omitted values use {@link Renderer.DEFAULT_OPTIONS}. */
1694
2707
  interface RendererOptions {
1695
2708
  camera: CameraOptions;
1696
2709
  render: RenderOptions;
@@ -1698,12 +2711,14 @@ interface RendererOptions {
1698
2711
  controls?: ControlsOptions;
1699
2712
  debug: DebugOptions;
1700
2713
  }
2714
+ /** Camera settings passed as `camera` in the Renderer constructor options. Positions use scene units. */
1701
2715
  interface CameraOptions {
1702
2716
  type: "perspective" | "orthographic";
1703
2717
  near: number;
1704
2718
  far: number;
1705
2719
  perspective: {
1706
2720
  aspect: undefined | number;
2721
+ /** Vertical field of view in degrees. */
1707
2722
  fov: number;
1708
2723
  };
1709
2724
  orthographic: {
@@ -1715,6 +2730,7 @@ interface CameraOptions {
1715
2730
  position: Vector3 | TripleArray;
1716
2731
  lookingAt: Vector3 | TripleArray;
1717
2732
  }
2733
+ /** Canvas and draw-loop settings passed as `render` in the Renderer constructor options. */
1718
2734
  interface RenderOptions {
1719
2735
  /** Maximum draw rate (60 by default); zero or a negative value disables the limit. */
1720
2736
  fpsLimit: number;
@@ -1723,20 +2739,29 @@ interface RenderOptions {
1723
2739
  stats: boolean;
1724
2740
  antialias: boolean;
1725
2741
  shade: boolean;
2742
+ /** Resizes to the attached element when the browser window resizes. */
1726
2743
  autoResize: boolean;
2744
+ /** Draws even when the scene is unchanged, while still respecting `fpsLimit`. */
1727
2745
  renderAlways: boolean;
1728
2746
  }
2747
+ /** Effects settings passed as `composer` in the Renderer constructor options. */
1729
2748
  interface ComposerOptions {
1730
2749
  enabled: boolean;
1731
2750
  }
2751
+ /** Set `controls: { enabled: true }` in the Renderer constructor to create owned OrbitControls. */
1732
2752
  interface ControlsOptions {
1733
2753
  enabled: boolean;
1734
2754
  }
2755
+ /** Scene helpers enabled through `debug` in the Renderer constructor options. */
1735
2756
  interface DebugOptions {
1736
2757
  grid: boolean;
1737
2758
  axes: boolean;
1738
2759
  }
1739
2760
 
2761
+ /**
2762
+ * Browser controls for inspecting and editing scene objects with Ctrl/Cmd-click selection.
2763
+ * Construct it with a renderer, attach its panels with {@link appendTo}, and call {@link dispose} when finished.
2764
+ */
1740
2765
  declare class SceneInspector {
1741
2766
  readonly renderer: Renderer;
1742
2767
  readonly objectInfoContainer: HTMLDivElement;
@@ -1749,7 +2774,7 @@ declare class SceneInspector {
1749
2774
  constructor(renderer: Renderer);
1750
2775
  protected init(): void;
1751
2776
  dispose(): void;
1752
- findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[], three.Object3DEventMap>[];
2777
+ findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry<three.NormalBufferAttributes, three.BufferGeometryEventMap>, three.Material<three.MaterialEventMap> | three.Material<three.MaterialEventMap>[], three.Object3DEventMap>[];
1753
2778
  onClick(event: MouseEvent): void;
1754
2779
  appendTo(el: HTMLElement): void;
1755
2780
  protected handleRaycasterObjects(intersections: Intersection[]): void;
@@ -1766,13 +2791,17 @@ declare class SceneInspector {
1766
2791
  protected separator(name?: string): HTMLElement;
1767
2792
  }
1768
2793
 
1769
- declare class SceneStatsDisplay {
2794
+ /** A browser statistics panel refreshed once per second. Dispose it separately from its renderer. */
2795
+ declare class SceneStatsDisplay implements Disposable {
1770
2796
  readonly renderer: Renderer;
1771
2797
  readonly statsContainer: HTMLDivElement;
1772
2798
  private readonly lines;
2799
+ private interval?;
1773
2800
  constructor(renderer: Renderer);
1774
2801
  protected init(): void;
1775
2802
  appendTo(el: HTMLElement): void;
2803
+ /** Stops the refresh timer and removes the panel from the page. */
2804
+ dispose(): void;
1776
2805
  add(line?: StatLine): void;
1777
2806
  }
1778
2807
  declare class StatLine {
@@ -1787,10 +2816,130 @@ declare class StatLine {
1787
2816
  update(): void;
1788
2817
  }
1789
2818
 
2819
+ /** Portable scene setup. Positions use model units (16 per block); rotations use radians. */
2820
+ interface SceneDocument {
2821
+ format: "minerender-scene";
2822
+ version: 1;
2823
+ minecraftVersion?: string;
2824
+ camera?: {
2825
+ position: TripleArray;
2826
+ target: TripleArray;
2827
+ };
2828
+ objects: SceneObjectDefinition[];
2829
+ }
2830
+ interface SceneObjectDefinitionBase {
2831
+ id: string;
2832
+ name?: string;
2833
+ position?: TripleArray;
2834
+ rotation?: TripleArray;
2835
+ scale?: TripleArray;
2836
+ visible?: boolean;
2837
+ }
2838
+ type SceneSkinPosePart = "head" | "body" | "rightArm" | "leftArm" | "rightLeg" | "leftLeg" | "cape";
2839
+ interface SceneSkinDefinition extends SceneObjectDefinitionBase {
2840
+ type: "skin";
2841
+ /** Texture URL, Minecraft username, or UUID. Omit for Steve, or Alex with slim: true, from the active asset version. */
2842
+ skin?: string;
2843
+ cape?: {
2844
+ texture: string;
2845
+ layout?: CapeLayout;
2846
+ };
2847
+ options?: {
2848
+ slim?: boolean;
2849
+ legacy?: boolean;
2850
+ };
2851
+ /** Mesh names from SkinPart; hiding a base part does not hide its overlay. */
2852
+ hiddenParts?: string[];
2853
+ /** Absolute local XYZ joint rotations in radians; omitted joints keep their default pose. */
2854
+ pose?: Partial<Record<SceneSkinPosePart, TripleArray>>;
2855
+ }
2856
+ interface SceneBlockDefinition extends SceneObjectDefinitionBase {
2857
+ type: "block";
2858
+ asset: string;
2859
+ state?: Record<string, string>;
2860
+ options?: {
2861
+ wireframe?: boolean;
2862
+ tints?: Record<number, number>;
2863
+ };
2864
+ }
2865
+ interface SceneModelDefinition extends SceneObjectDefinitionBase {
2866
+ type: "item" | "model";
2867
+ asset: string;
2868
+ options?: {
2869
+ wireframe?: boolean;
2870
+ displayPosition?: DisplayPosition;
2871
+ tints?: Record<number, number>;
2872
+ };
2873
+ }
2874
+ interface SceneEntityDefinition extends SceneObjectDefinitionBase {
2875
+ type: "entity";
2876
+ asset: string;
2877
+ texture?: string;
2878
+ layers?: string[];
2879
+ when?: string[];
2880
+ textures?: Record<string, string>;
2881
+ options?: {
2882
+ flip?: boolean;
2883
+ wireframe?: boolean;
2884
+ tints?: Record<string, string | number>;
2885
+ };
2886
+ animation?: {
2887
+ name: string;
2888
+ loop?: boolean;
2889
+ speed?: number;
2890
+ time?: number;
2891
+ paused?: boolean;
2892
+ };
2893
+ }
2894
+ type SceneGuiLayer = (Omit<GuiTextureLayer, "texture"> & {
2895
+ texture: string;
2896
+ }) | (Omit<GuiItemLayer, "item"> & {
2897
+ item: string;
2898
+ }) | (Omit<GuiTextLayer, "font"> & {
2899
+ font?: string;
2900
+ });
2901
+ interface SceneGuiDefinition extends SceneObjectDefinitionBase {
2902
+ type: "gui";
2903
+ layers: SceneGuiLayer[];
2904
+ }
2905
+ type SceneObjectDefinition = SceneSkinDefinition | SceneBlockDefinition | SceneModelDefinition | SceneEntityDefinition | SceneGuiDefinition;
2906
+ /** Validates and copies a scene document without requesting assets or changing the active asset version. */
2907
+ declare function parseSceneDocument(value: unknown): SceneDocument;
2908
+
2909
+ interface LoadedSceneObject {
2910
+ readonly root: Group;
2911
+ readonly object: SceneObject;
2912
+ readonly definition: SceneObjectDefinition;
2913
+ /** Advances entity playback in seconds unless the definition has paused it. */
2914
+ advanceAnimation(delta: number): void;
2915
+ /** Removes this object and releases its owned resources. Safe to call more than once. */
2916
+ dispose(): void;
2917
+ }
2918
+ interface LoadedSceneDocument {
2919
+ readonly root: Group;
2920
+ readonly objects: LoadedSceneObject[];
2921
+ readonly definition: SceneDocument;
2922
+ advanceAnimations(delta: number): void;
2923
+ dispose(): void;
2924
+ }
2925
+ /** Loads portable scene documents using the asset sources already configured by the caller. */
2926
+ declare class SceneDocumentLoader {
2927
+ static parse(value: unknown): SceneDocument;
2928
+ /**
2929
+ * Loads objects concurrently and attaches them in document order after every load succeeds.
2930
+ * A failure waits for all loads, disposes staged objects, and reports the first error in document order.
2931
+ */
2932
+ static load(scene: MineRenderScene, value: unknown, parent?: Object3D): Promise<LoadedSceneDocument>;
2933
+ /** Loads an independently editable object. Its root owns the document's position, rotation, and scale. */
2934
+ static loadObject(scene: MineRenderScene, value: SceneObjectDefinition, parent?: Object3D): Promise<LoadedSceneObject>;
2935
+ private static loadValidatedObject;
2936
+ }
2937
+
1790
2938
  type SkinGeometries = Record<SkinPart, TripleArray>;
1791
2939
  declare const classicSkinGeometries: SkinGeometries;
1792
2940
  declare const slimSkinGeometries: SkinGeometries;
1793
2941
 
2942
+ /** Decodes skin pixels while preserving hidden RGB values in transparent PNG pixels. */
1794
2943
  declare class SkinImage {
1795
2944
  static getData(src: string): Promise<ImageData>;
1796
2945
  private static decodePng;
@@ -1800,12 +2949,15 @@ type SkinTextureCoordinates = Record<SkinPart, ModelFaces>;
1800
2949
  declare const classicSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
1801
2950
  declare const slimSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
1802
2951
 
2952
+ /** A prepared shared skin material with detected arm-model and texture-layout flags. */
1803
2953
  interface SkinTexture {
1804
2954
  material: MeshBasicMaterial;
1805
2955
  slim: boolean;
1806
2956
  legacy: boolean;
1807
2957
  }
2958
+ /** Prepares shared skin and cape materials, including legacy layout conversion and base-layer opacity. */
1808
2959
  declare class SkinTextures {
2960
+ /** Loads a skin URL. Pass `legacy` to override layout detection from the image dimensions. */
1809
2961
  static get(src: string, legacy?: boolean): Promise<SkinTexture>;
1810
2962
  static getCape(src: string, layout?: CapeLayout): Promise<MeshBasicMaterial>;
1811
2963
  private static createMaterial;
@@ -1814,12 +2966,18 @@ declare class SkinTextures {
1814
2966
  private static makeBaseOpaque;
1815
2967
  }
1816
2968
 
2969
+ /** Resolves player names, UUIDs, and service IDs to skin or cape texture URLs. */
1817
2970
  declare class Skins {
2971
+ /** Returns a skin URL for {@link MineRenderScene.addSkin}, or `undefined` if name lookup fails. */
1818
2972
  static fromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
2973
+ /** Builds a proxy URL for a UUID without downloading or checking the skin. */
1819
2974
  static fromUuid(uuid: string): Promise<Maybe<string>>;
1820
2975
  static fromUsername(username: string): Promise<Maybe<string>>;
2976
+ /** Looks up a saved MineSkin skin and returns its texture URL, or `undefined` on lookup failure. */
1821
2977
  static fromMineSkin(mineskinId: string): Promise<Maybe<string>>;
2978
+ /** Resolves a player's Minecraft cape URL for {@link SkinObject.setCapeTexture}. */
1822
2979
  static capeFromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
2980
+ /** Builds a proxy URL without checking whether the player has a cape. */
1823
2981
  static capeFromUuid(uuid: string): Promise<Maybe<string>>;
1824
2982
  static capeFromUsername(username: string): Promise<Maybe<string>>;
1825
2983
  /** Returns a full static cape texture for a username or UUID. */
@@ -1844,20 +3002,34 @@ declare class Skins {
1844
3002
  private static getMcProxyCapeUrl;
1845
3003
  }
1846
3004
 
3005
+ /** Samples resource-pack colormaps to produce packed sRGB tint colors. */
3006
+ declare class Colormaps {
3007
+ /** Samples the selected resource pack's grass colormap using Minecraft's climate coordinates. */
3008
+ static grassColor(origin?: AssetKey, temperature?: number, downfall?: number): Promise<number>;
3009
+ }
3010
+
3011
+ /** Creates sRGB textures immediately and fills their pixels after asynchronous image loading. */
1847
3012
  declare class TextureLoader {
1848
3013
  private static readonly failedTextures;
1849
3014
  /** Reports whether image loading failed, so cached textures can be retried. */
1850
3015
  static hasFailed(texture: Texture): boolean;
1851
3016
  protected static createTexture(): Texture;
1852
3017
  static loadInBackground(src: string, format?: PixelFormat, rotation?: number): Texture;
3018
+ /** Loads image pixels in the background. `rotation` is in radians. Check {@link hasFailed} for load failures. */
1853
3019
  static load(src: string, format?: PixelFormat, rotation?: number): Texture;
1854
3020
  }
1855
3021
 
3022
+ /** Creates and caches Three.js textures with nearest-neighbor sampling for Minecraft artwork. */
1856
3023
  declare class Textures {
3024
+ /** Creates the shared checkerboard from pixels without fetching or decoding an image. */
3025
+ static getMissing(): DataTexture;
3026
+ /** Sets nearest-neighbor filters without changing the texture's color space. Returns the same texture. */
1857
3027
  static initTextureProps<T extends Texture>(texture: T): T;
1858
3028
  static createImage(key: TextureKey): Texture;
1859
3029
  static createAsset(key: AssetKey): Texture;
3030
+ /** Creates an sRGB color texture from a canvas. */
1860
3031
  static createCanvasTexture(canvas: HTMLCanvasElement): CanvasTexture;
3032
+ /** Returns a shared texture immediately and loads its image asynchronously. Failed cached loads are retried. */
1861
3033
  static getImage(key: TextureKey): Texture;
1862
3034
  }
1863
3035
 
@@ -1869,14 +3041,18 @@ declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): Bu
1869
3041
  declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
1870
3042
  declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
1871
3043
 
3044
+ /** Stores 4,096 block cells in a shared state palette, with separate NBT for each cell. */
1872
3045
  declare class ChunkData {
1873
3046
  private readonly indices;
1874
3047
  private readonly palette;
1875
3048
  private readonly paletteIds;
1876
3049
  private readonly freeIds;
1877
3050
  private readonly nbt;
3051
+ /** Returns a detached copy of a cell, or `undefined` for air. Indices range from 0 to 4095. */
1878
3052
  get(index: number): Maybe<Block>;
3053
+ /** Captures a cell's data and returns a copy-producing reader that survives later cell changes. */
1879
3054
  snapshot(index: number): Maybe<() => Block>;
3055
+ /** Copies block data into a cell. An omitted block or an air block clears the cell. */
1880
3056
  set(index: number, block?: Block): void;
1881
3057
  clear(): void;
1882
3058
  static isAir(block: Maybe<Block>): boolean;
@@ -1885,9 +3061,11 @@ declare class ChunkData {
1885
3061
  }
1886
3062
 
1887
3063
  type RegionInput = Uint8Array | ArrayBuffer;
3064
+ /** Chunk columns decoded from an Anvil region file. */
1888
3065
  interface AnvilRegion {
1889
3066
  chunks: AnvilChunk[];
1890
3067
  }
3068
+ /** A decoded chunk column. `x` and `z` are absolute chunk coordinates, and section `y` is a section coordinate. */
1891
3069
  interface AnvilChunk {
1892
3070
  x: number;
1893
3071
  z: number;
@@ -1898,12 +3076,21 @@ interface AnvilChunk {
1898
3076
  }[];
1899
3077
  entities?: MultiBlockEntity[];
1900
3078
  }
3079
+ /** Reads Java 1.13+ paletted `.mca` regions. Entity NBT is preserved without data-version migration. */
1901
3080
  declare class AnvilParser {
3081
+ /** Lists occupied chunk positions within the region, using local coordinates from 0 to 31. */
1902
3082
  static getChunkList(data: RegionInput): {
1903
3083
  x: number;
1904
3084
  z: number;
1905
3085
  }[];
3086
+ /** Decodes all stored chunks. Gzip, zlib, and uncompressed payloads are supported. */
1906
3087
  static parse(data: RegionInput): Promise<AnvilRegion>;
3088
+ /**
3089
+ * Decodes one chunk for {@link MineRenderWorld.placeChunk}.
3090
+ * @param localX - Chunk x within the region, from 0 to 31.
3091
+ * @param localZ - Chunk z within the region, from 0 to 31.
3092
+ * @returns The chunk with absolute coordinates, or `undefined` if the region has no chunk there.
3093
+ */
1907
3094
  static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
1908
3095
  private static bytes;
1909
3096
  private static locations;
@@ -1914,6 +3101,7 @@ declare class AnvilParser {
1914
3101
  private static unpack;
1915
3102
  }
1916
3103
 
3104
+ /** A placed block's data snapshot and optional render object, returned by world and chunk accessors. */
1917
3105
  interface BlockInfo<SectionMeshing extends boolean = false> {
1918
3106
  /** Detached block data; use world or chunk setters to update stored blocks. */
1919
3107
  readonly block: Block;
@@ -1921,33 +3109,45 @@ interface BlockInfo<SectionMeshing extends boolean = false> {
1921
3109
  object: SectionMeshing extends false ? BlockObject : BlockObject | undefined;
1922
3110
  }
1923
3111
 
3112
+ /** Shared cube geometry and atlas data prepared for section merging. */
1924
3113
  interface SectionMeshTemplate {
1925
3114
  geometry: BufferGeometry;
1926
3115
  atlas: TextureAtlas;
1927
3116
  cullFaces: readonly number[];
1928
3117
  }
3118
+ /** One block placement in a section, with its storage index and hidden-face mask. */
1929
3119
  interface SectionMeshEntry {
1930
3120
  index: number;
1931
3121
  template: SectionMeshTemplate;
1932
3122
  cullMask: number;
1933
3123
  }
3124
+ /** Merged terrain geometry and atlas pages for one 16×16×16 section. Owns its generated render resources. */
1934
3125
  declare class SectionMesh extends Group {
1935
3126
  private readonly ownedMeshes;
3127
+ /** Builds section-local meshes from visible cube faces. `maxAtlasSize` limits each atlas dimension in pixels. */
1936
3128
  static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
1937
3129
  dispose(): void;
1938
3130
  }
1939
3131
 
3132
+ /** Prepares and caches static opaque cube geometry for merged world sections. */
1940
3133
  declare class SectionModels {
1941
3134
  readonly maxAtlasSize: number;
1942
3135
  private states;
1943
3136
  private models;
1944
3137
  private readonly templates;
1945
3138
  constructor(maxAtlasSize?: number);
3139
+ /** Returns a cube template, or `undefined` when the block requires an individual render object. */
1946
3140
  get(blockState: BlockState, properties?: BlockStateProperties): Promise<SectionMeshTemplate | undefined>;
1947
3141
  private prepare;
3142
+ /** Disposes prepared geometry and clears this world's template caches. */
1948
3143
  clear(): void;
1949
3144
  }
1950
3145
 
3146
+ /**
3147
+ * A 16×16×16 block section and its render objects.
3148
+ * Constructor coordinates identify the section. Block accessors use world block coordinates
3149
+ * unless their name explicitly refers to positions within the chunk.
3150
+ */
1951
3151
  declare class Chunk<SectionMeshing extends boolean = false> {
1952
3152
  private readonly onBlocksChanged?;
1953
3153
  private readonly sectionModels?;
@@ -1958,6 +3158,7 @@ declare class Chunk<SectionMeshing extends boolean = false> {
1958
3158
  private readonly data;
1959
3159
  private readonly renderedBlocks;
1960
3160
  private readonly sectionBlocks;
3161
+ private readonly hiddenBlocks;
1961
3162
  private sectionMesh?;
1962
3163
  private meshDirty;
1963
3164
  constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
@@ -1965,26 +3166,36 @@ declare class Chunk<SectionMeshing extends boolean = false> {
1965
3166
  getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
1966
3167
  getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
1967
3168
  /**
1968
- * Set block at a _world_ position
3169
+ * Places a block at integer world block coordinates. Pass `undefined` to remove it.
1969
3170
  */
1970
3171
  setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1971
3172
  setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1972
3173
  setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1973
3174
  /**
1974
- * Set a block at integer chunk-local coordinates from 0 to 15.
3175
+ * Places a block at integer chunk-local coordinates from 0 to 15.
1975
3176
  */
1976
3177
  setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
3178
+ /** Changes visibility at world block coordinates while preserving the block's data. */
3179
+ setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
3180
+ isBlockVisibleAt(pos: Vector3): boolean;
1977
3181
  isOccludingAt(pos: Vector3): boolean;
1978
3182
  setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
1979
3183
  rebuildSectionMesh(): void;
3184
+ /** Removes stored blocks and their render objects, then notifies the owning world of changed positions. */
1980
3185
  clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
1981
3186
  dispose(): Promise<void>;
1982
3187
  static isAir(block: Maybe<Block>): boolean;
3188
+ /** Maps chunk-local coordinates from 0 to 15 to a storage index, with x varying fastest, then z, then y. */
1983
3189
  static chunkPosToBlockIndex(pos: Vector3): number;
1984
3190
  worldPosToChunkPos(pos: Vector3): Vector3;
1985
3191
  chunkPosToWorldPos(pos: Vector3): Vector3;
1986
3192
  }
1987
3193
 
3194
+ /**
3195
+ * Stores and renders blocks in sparse 16×16×16 chunks.
3196
+ * Positions use integer block coordinates, including negatives. One block is 16 scene units.
3197
+ * Set `options.sectionMeshing` in `new MineRenderWorld(scene, options)` to merge compatible terrain.
3198
+ */
1988
3199
  declare class MineRenderWorld<SectionMeshing extends boolean = false> {
1989
3200
  readonly scene: MineRenderScene;
1990
3201
  private readonly _chunks;
@@ -1992,26 +3203,56 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
1992
3203
  private readonly pendingCulling;
1993
3204
  private culling?;
1994
3205
  constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
3206
+ /** Returns a placed block at world block coordinates, or `undefined` for an empty position. */
1995
3207
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
1996
3208
  getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
1997
3209
  getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
3210
+ /**
3211
+ * Places or replaces a block and refreshes neighboring faces.
3212
+ * Pass `undefined` or an air block to remove the block at these world block coordinates.
3213
+ */
1998
3214
  setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
1999
3215
  setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
2000
3216
  setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
2001
3217
  private placeBlock;
3218
+ /**
3219
+ * Shows or hides a placed block without changing its data. Hidden blocks do not occlude neighbors.
3220
+ * Missing blocks are ignored; replacing or removing a block resets its visibility.
3221
+ */
3222
+ setBlockVisibleAt(x: number, y: number, z: number, visible: boolean): Promise<void>;
3223
+ setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
3224
+ setBlockVisibleAt(pos: TripleArray, visible: boolean): Promise<void>;
3225
+ /**
3226
+ * Places a structure's blocks at their stored positions, then refreshes neighboring faces.
3227
+ * Entity NBT is retained by the structure but is not rendered.
3228
+ *
3229
+ * @param useBatches - Uses bounded batches by default. Set to `false` for sequential placement.
3230
+ * @param executor - Optional queue for batched placement. The caller remains responsible for stopping it.
3231
+ */
2002
3232
  placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
2003
3233
  private placeBlocks;
2004
3234
  /** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
2005
3235
  placeChunk(chunk: AnvilChunk, executor?: BatchedExecutor): Promise<void>;
3236
+ /**
3237
+ * Removes all sections at integer chunk-column coordinates, then refreshes neighboring faces and fluids.
3238
+ * Coordinates match AnvilChunk.x/z, not block positions. Missing columns are ignored.
3239
+ */
3240
+ unloadChunkColumn(x: number, z: number): Promise<void>;
3241
+ private clearChunkColumn;
3242
+ /** Removes all chunks and releases their block placements and section meshes. */
2006
3243
  clear(): Promise<void>;
2007
3244
  private updateCulling;
2008
3245
  private getOrCreateChunkAt;
3246
+ /** Returns the loaded chunk containing a world block position, without creating a chunk. */
2009
3247
  getChunkAt(pos: Vector3): Maybe<Chunk<SectionMeshing>>;
3248
+ /** Converts block coordinates to scene units by multiplying each component by 16. */
2010
3249
  static worldToScenePosition(pos: Vector3): Vector3;
3250
+ /** Converts scene units to block coordinates without rounding to an integer block. */
2011
3251
  static sceneToWorldPosition(pos: Vector3): Vector3;
2012
3252
  worldPosToChunkKey(pos: Vector3): string;
2013
3253
  validatePosBounds(pos: Vector3): void;
2014
3254
  }
3255
+ /** Settings passed as the second argument to `new MineRenderWorld(scene, options)`. */
2015
3256
  interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
2016
3257
  /** Merge static opaque cubes into section meshes. Merged blocks have no individual object. */
2017
3258
  sectionMeshing?: SectionMeshing;
@@ -2030,6 +3271,7 @@ declare class BrowserEnv implements EnvProvider {
2030
3271
  imageSize(data: Uint8Array): ImageSizeInfo;
2031
3272
  openCache(name: string, version: number): PersistentCache;
2032
3273
  }
3274
+ /** Installs the browser provider. The browser package entry calls this automatically. */
2033
3275
  declare function registerBrowserEnv(): BrowserEnv;
2034
3276
 
2035
3277
  /**
@@ -2055,4 +3297,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
2055
3297
  */
2056
3298
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
2057
3299
 
2058
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, type FromTo, Geometries, GuiHelper, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createImage, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
3300
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };