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