minerender 2.1.0-alpha.4 → 2.1.0-alpha.40

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,14 +1,11 @@
1
1
  import * as three from 'three';
2
- import { Vector3, PixelFormat, BoxGeometry, Material, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Scene, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, CanvasTexture, BufferGeometry as BufferGeometry$1, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
2
+ import { Vector3, PixelFormat, BoxGeometry, Material, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, MeshBasicMaterial, 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
- import { AxiosResponse, AxiosRequestConfig } from 'axios';
6
- import { Buffer as Buffer$1 } from 'buffer';
7
- import { NBT } from 'prismarine-nbt';
5
+ import { Buffer } from 'buffer';
6
+ import { NBT, NBTFormat, Metadata } from 'prismarine-nbt';
8
7
  import { ZipReader } from '@zip.js/zip.js';
9
8
  import { AsyncLoadingCache, SimpleCache } from '@inventivetalent/loading-cache';
10
- import { BufferGeometry } from 'three/src/core/BufferGeometry';
11
- import { Material as Material$1 } from 'three/src/materials/Material';
12
9
  import Stats from 'stats.js';
13
10
  import { EffectComposer } from 'postprocessing';
14
11
 
@@ -17,7 +14,7 @@ interface AnimatorFunction {
17
14
  }
18
15
 
19
16
  declare enum Axis {
20
- X = "X",
17
+ X = "x",
21
18
  Y = "y",
22
19
  Z = "z"
23
20
  }
@@ -41,6 +38,7 @@ declare enum CubeFaceIndex {
41
38
  NORTH = 5
42
39
  }
43
40
  declare const CUBE_FACES: CubeFace[];
41
+ declare const CUBE_FACE_OFFSETS: readonly [readonly [1, 0, 0], readonly [-1, 0, 0], readonly [0, 1, 0], readonly [0, -1, 0], readonly [0, 0, 1], readonly [0, 0, -1]];
44
42
 
45
43
  interface Disposable {
46
44
  dispose(): void;
@@ -62,10 +60,11 @@ declare function createCanvas(width: number, height: number): CompatCanvas;
62
60
  declare abstract class PersistentCache<B = unknown> {
63
61
  readonly backing: B;
64
62
  /** Bump to invalidate every persisted entry. */
65
- static readonly VERSION = 1;
63
+ static readonly VERSION = 2;
66
64
  static open(name: string): PersistentCache;
67
65
  protected constructor(backing: B);
68
66
  abstract get<T>(key: string): Promise<T>;
67
+ /** Loads a missing entry and stores only non-nullish results. */
69
68
  getOrLoad<T>(key: string, loader: (key: string) => Promise<T>): Promise<T>;
70
69
  abstract put<T>(key: string, value: T): Promise<T>;
71
70
  abstract delete<T>(key: string): Promise<void>;
@@ -175,6 +174,7 @@ declare class AssetKey extends BasicAssetKey {
175
174
  rootType: "assets" | "data" | string;
176
175
  extension: ".json" | ".png" | string;
177
176
  root?: string | undefined;
177
+ readonly isAssetKey: true;
178
178
  constructor(namespace: string, path: string, assetType?: AssetType | undefined, type?: string | undefined, rootType?: "assets" | "data" | string, extension?: ".json" | ".png" | string, root?: string | undefined);
179
179
  static parse(assetType: AssetType, str: string, origin?: AssetKey): AssetKey;
180
180
  toString(): string;
@@ -247,7 +247,8 @@ declare enum DisplayPosition {
247
247
  GUI = "gui",
248
248
  HEAD = "head",
249
249
  GROUND = "ground",
250
- FIXED = "fixed"
250
+ FIXED = "fixed",
251
+ ON_SHELF = "on_shelf"
251
252
  }
252
253
  declare const DISPLAY_POSITIONS: DisplayPosition[];
253
254
 
@@ -256,6 +257,46 @@ declare enum GuiLight {
256
257
  SIDE = "side"
257
258
  }
258
259
 
260
+ interface RequestConfig extends RequestInit {
261
+ url: string;
262
+ /** Prepended to relative URLs, preserving any path in the base URL. */
263
+ baseURL?: string;
264
+ /** Timeout per attempt in milliseconds, including body reading. Defaults to 5000; 0 disables it. */
265
+ timeout?: number;
266
+ responseType?: "json" | "arraybuffer";
267
+ }
268
+ interface RequestResponse<T = any> {
269
+ data: T;
270
+ status: number;
271
+ statusText: string;
272
+ headers: Headers;
273
+ /** Final URL after redirects. */
274
+ url: string;
275
+ }
276
+ declare class RequestError extends Error {
277
+ readonly response?: RequestResponse<undefined> | undefined;
278
+ readonly cause?: unknown;
279
+ constructor(message: string, response?: RequestResponse<undefined> | undefined, cause?: unknown);
280
+ }
281
+ declare class Requests {
282
+ private static genericQueue;
283
+ private static mcAssetRequestQueue;
284
+ static genericRequest(request: RequestConfig): Promise<RequestResponse>;
285
+ static mcAssetRequest(request: RequestConfig): Promise<RequestResponse>;
286
+ static setMcAssetRoot(root: string): void;
287
+ /** Counts unsettled calls, including retry delays and requests still running after shutdown. */
288
+ static get queueSizes(): {
289
+ generic: number;
290
+ mcAsset: number;
291
+ };
292
+ /**
293
+ * Permanently stops both queues and rejects waiting, retrying, and future requests.
294
+ * Requests already running can finish. Idle queues hold no timer, so Node can exit without
295
+ * this cleanup. See {@link shutdown}.
296
+ */
297
+ static end(): void;
298
+ }
299
+
259
300
  declare class WrappedImage {
260
301
  readonly dta: ExtractableImageData;
261
302
  constructor(dta: ExtractableImageData);
@@ -279,7 +320,7 @@ interface ImageInfo {
279
320
  width: number;
280
321
  height: number;
281
322
  type?: string;
282
- data: Buffer$1;
323
+ data: Buffer;
283
324
  }
284
325
  declare class ImageLoader {
285
326
  protected static _createImage(): CompatImage;
@@ -291,7 +332,7 @@ declare class ImageLoader {
291
332
  static infoToData(info: ImageInfo): Promise<ImageData>;
292
333
  static getData(src: string): Promise<ImageData>;
293
334
  static getCanvasData(src: string): Promise<ExtractableImageData>;
294
- static processResponse(response: Partial<AxiosResponse>): Promise<ImageInfo>;
335
+ static processResponse(response: Pick<RequestResponse<ArrayBuffer>, "data" | "url">): Promise<ImageInfo>;
295
336
  static loadInfo(src: string): Promise<ImageInfo>;
296
337
  static getInfo(src: string): Promise<ImageInfo>;
297
338
  static loadWrapped(src: string): Promise<WrappedImage>;
@@ -305,7 +346,7 @@ declare const DEFAULT_ELEMENTS: ModelElement[];
305
346
  interface Model extends MinecraftAsset {
306
347
  textures?: IModelTextures;
307
348
  parent?: string;
308
- display?: ModelDisplay;
349
+ display?: Partial<Record<DisplayPosition, ModelDisplay>>;
309
350
  elements?: ModelElement[];
310
351
  hierarchy?: string[];
311
352
  }
@@ -320,7 +361,6 @@ interface ItemModel extends Model {
320
361
  interface TextureAsset extends MinecraftAsset, ImageInfo {
321
362
  }
322
363
  interface ModelDisplay {
323
- position?: DisplayPosition;
324
364
  translation?: TripleArray;
325
365
  rotation?: TripleArray;
326
366
  scale?: TripleArray;
@@ -340,13 +380,7 @@ declare function isDoubleArray(obj: any): obj is DoubleArray;
340
380
  declare function isTripleArray(obj: any): obj is TripleArray;
341
381
  declare function isQuadArray(obj: any): obj is QuadArray;
342
382
 
343
- /**
344
- * down up
345
- * east north west south
346
- *
347
- * bottom-left to top-right
348
- * [bl, br, tl, tr]
349
- */
383
+ /** Vanilla Minecraft cube UVs in Three.js BoxGeometry face and vertex order. */
350
384
  declare class MinecraftCubeTexture {
351
385
  readonly u: number;
352
386
  readonly v: number;
@@ -362,7 +396,7 @@ declare class MinecraftCubeTexture {
362
396
  getUvSouth(w: number, h: number, l: number): QuadArray<DoubleArray>;
363
397
  getUvNorth(w: number, h: number, l: number): QuadArray<DoubleArray>;
364
398
  getFaceUv(face: CubeFace, w: number, h: number, l: number): QuadArray<DoubleArray>;
365
- toUvArray(w: number, h: number, l: number): number[];
399
+ toUvArray(w: number, h: number, l: number, mirror?: boolean): number[];
366
400
  }
367
401
 
368
402
  interface MinecraftTextureMeta extends MinecraftAsset {
@@ -431,7 +465,7 @@ interface Transformable {
431
465
  declare function isTransformable(obj: any): obj is Transformable;
432
466
 
433
467
  declare const changeEvent: {
434
- type: string;
468
+ type: "change";
435
469
  };
436
470
  type Maybe<T> = T | undefined;
437
471
  declare function md5(str: string): string;
@@ -515,6 +549,7 @@ declare class UVMapper {
515
549
  static setCubeUvs(geometry: BoxGeometry, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray, faces: ModelFaces): void;
516
550
  static facesToUvArray(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): number[];
517
551
  static facesToUv(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): Float32BufferAttribute;
552
+ static lockUvs(geometry: BoxGeometry, faces: ModelFaces, atlas: TextureAtlas, rotation: Euler): void;
518
553
  static getAtlas(model: Model): Promise<Maybe<TextureAtlas>>;
519
554
  static fillMissingTextureKeys<T>(textures: ModelTextures, target: {
520
555
  [k: string]: T;
@@ -536,14 +571,13 @@ declare class MinecraftFaceUV {
536
571
  }
537
572
 
538
573
  /**
539
- * Releases every long-lived timer MineRender holds, so a Node process can exit.
574
+ * Stops the shared Ticker and request queues, and clears the in-memory caches.
540
575
  *
541
- * Both `@inventivetalent/loading-cache` (cache expiry) and `jobqu` (request queue draining) use
542
- * self-rescheduling timers that are not unref'd, which keeps the event loop alive for as long as
543
- * the library is loaded. Browsers don't care, but anything headless - a render server, a CLI, a
544
- * test run - has to call this when it's done.
576
+ * Idle Node processes can exit without calling this: cache and Ticker timers are unref'd,
577
+ * and idle request queues hold no timer. Pending requests keep their normal timer references.
545
578
  *
546
- * The library stays usable afterwards; the caches and queues simply start over.
579
+ * Call this only when finished with MineRender. Queued, retrying, and future requests reject;
580
+ * HTTP requests already running can finish. Queue shutdown is permanent, and cache expiry timers do not restart.
547
581
  */
548
582
  declare function shutdown(): void;
549
583
 
@@ -551,42 +585,15 @@ declare class BatchedExecutor {
551
585
  readonly interval: number;
552
586
  readonly batch: number;
553
587
  private readonly queue;
554
- private readonly task;
555
588
  constructor(interval?: number, batch?: number);
556
- submit(task: Task): void;
557
- private run;
558
- private runNext;
589
+ submit<T>(task: Task<T>): Promise<T>;
590
+ stop(): void;
559
591
  }
560
- type Task = () => any | Promise<any>;
592
+ type Task<T = unknown> = () => T | Promise<T>;
561
593
 
562
594
  declare function prefix(prefix?: string): string;
563
595
 
564
- interface ModelPart {
565
- textureWidth: number;
566
- textureHeight: number;
567
- textureOffsetU: number;
568
- textureOffsetV: number;
569
- pivotX: number;
570
- pivotY: number;
571
- pivotZ: number;
572
- pitch: number;
573
- yaw: number;
574
- roll: number;
575
- mirror: boolean;
576
- cubes: Cube[];
577
- children: ModelPart[];
578
- }
579
- interface Cube {
580
- minX: number;
581
- minY: number;
582
- minZ: number;
583
- maxX: number;
584
- maxY: number;
585
- maxZ: number;
586
- }
587
-
588
596
  declare function applyElementRotation(rotation: ElementRotation, geometry: BufferGeometry): void;
589
- declare function applyModelPartRotation(modelPart: ModelPart, geometry: BufferGeometry): void;
590
597
  declare function applyGenericRotation(axis: Axis, rotation: number, obj: Object3D): void;
591
598
  declare function addBox3WireframeToObject(box: Box3, obj: Object3D, color?: number, w?: number): void;
592
599
  declare function addWireframeToObject(obj: Object3D, color?: number, w?: number): void;
@@ -615,15 +622,47 @@ declare enum AssetParser {
615
622
  declare abstract class AssetSource {
616
623
  protected constructor();
617
624
  abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
625
+ /**
626
+ * Identifies this source's content across sessions for persistent caching. Sources that
627
+ * cannot tell whether their content changed (an unnamed archive, for example) return
628
+ * undefined, which keeps their results out of long-lived caches.
629
+ */
630
+ get cacheId(): Maybe<string>;
631
+ }
632
+ /** A source failed to load or parse an asset; cause retains the original failure. */
633
+ declare class AssetLoadError extends Error {
634
+ readonly source: AssetSource;
635
+ readonly key: AssetKey;
636
+ readonly path: string;
637
+ readonly cause: unknown;
638
+ constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
618
639
  }
619
640
 
620
641
  declare class AssetLoader {
621
642
  static ROOT: string;
622
643
  private static _SOURCES;
644
+ /** Used when a registered source cannot identify its content, so nothing persists past this session. */
645
+ private static readonly SESSION_SCOPE;
646
+ static get version(): string;
647
+ static setVersion(version: string): void;
648
+ /**
649
+ * Scope for persistent cache keys. Empty with only the default vanilla sources, so their
650
+ * entries stay valid across sessions; otherwise it names every added source (resource packs,
651
+ * mirrors) so their results never masquerade as vanilla assets after a reload.
652
+ */
653
+ static get persistentScope(): string;
654
+ /** Prefixes a persistent cache key with the current source scope. */
655
+ static persistentKey(key: string): string;
623
656
  static addSource(key: string, source: AssetSource, override?: boolean): void;
624
657
  static removeSource(key: string): Maybe<AssetSource>;
625
658
  static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
659
+ /** Returns the first defined result in source-priority order, without merging assets. */
626
660
  static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
661
+ /** Tries each path within a source before considering lower-priority sources. */
662
+ static getFirst<T extends MinecraftAsset>(keys: readonly AssetKey[], parser: AssetParser | string): Promise<Maybe<{
663
+ key: AssetKey;
664
+ asset: T;
665
+ }>>;
627
666
  }
628
667
 
629
668
  interface BlockState extends MinecraftAsset {
@@ -638,18 +677,19 @@ interface BlockStateVariant {
638
677
  y?: number;
639
678
  x?: number;
640
679
  uvlock?: boolean;
680
+ weight?: number;
641
681
  }
642
682
  interface BlockStateMultipart {
643
- when?: MultipartCondition | {
644
- OR: MultipartCondition[];
645
- };
646
- apply?: BlockStateVariant;
647
- }
648
- interface MultipartCondition {
649
- [key: string]: string;
683
+ when?: MultipartCondition;
684
+ apply?: BlockStateVariant | BlockStateVariant[];
650
685
  }
686
+ type MultipartCondition = Record<string, string> | {
687
+ OR: MultipartCondition[];
688
+ } | {
689
+ AND: MultipartCondition[];
690
+ };
651
691
 
652
- declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.17.1";
692
+ declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.21.11";
653
693
  declare const DEFAULT_NAMESPACE = "minecraft";
654
694
  declare class Assets {
655
695
  /**
@@ -688,25 +728,60 @@ declare class DefaultBlockStates implements MinecraftAsset {
688
728
  [k: string]: BlockStatePropertyDefaults;
689
729
  }
690
730
 
691
- interface EntityModel extends BasicMinecraftAsset {
692
- parts?: {
693
- [p: string]: ModelPart;
731
+ interface EntityLayer {
732
+ key: BasicAssetKey;
733
+ texture?: AssetKey;
734
+ layer: EntityModelLayer;
735
+ }
736
+ interface EntityModel extends EntityLayer {
737
+ id: string;
738
+ /** Selected layers; the top-level fields describe the first selection. */
739
+ layers?: Record<string, EntityLayer>;
740
+ }
741
+ interface EntityModelFile extends MinecraftAsset {
742
+ id: string;
743
+ layers: Record<string, EntityModelLayer>;
744
+ }
745
+ interface EntityModelLayer {
746
+ texture: [number, number];
747
+ textureLocation?: string;
748
+ root: EntityModelPart;
749
+ }
750
+ interface EntityModelPart {
751
+ pose: {
752
+ offset: [number, number, number];
753
+ rotation: [number, number, number];
754
+ scale?: [number, number, number];
694
755
  };
756
+ texture?: [number, number];
757
+ cubes: EntityModelCube[];
758
+ children: Record<string, EntityModelPart>;
759
+ }
760
+ interface EntityModelCube {
761
+ origin: [number, number, number];
762
+ size: [number, number, number];
763
+ uv: [number, number];
764
+ grow?: [number, number, number];
765
+ mirror?: boolean;
695
766
  }
696
767
 
697
768
  declare class Entities {
698
- static getBlockEntityModels(): Promise<Maybe<BlockEntityModels>>;
699
- static getEntityModels(): Promise<Maybe<EntityModels>>;
700
- static getBlockList(): Promise<string[]>;
701
769
  static getEntityList(): Promise<string[]>;
702
- static getBlock(modelKey: BasicAssetKey, textureKey?: BasicAssetKey): Promise<Maybe<EntityModel>>;
703
- static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey): Promise<Maybe<EntityModel>>;
704
- }
705
- declare class EntityModels implements MinecraftAsset {
706
- [k: string]: any;
770
+ private static getModelFile;
771
+ static getLayerList(modelKey: BasicAssetKey): Promise<string[]>;
772
+ static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
773
+ static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
774
+ /** @deprecated Use getEntityList(); block entities share the entity dataset. */
775
+ static getBlockList(): Promise<string[]>;
776
+ /** @deprecated Use getEntity(); block entities share the entity dataset. */
777
+ static getBlock(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
707
778
  }
708
- declare class BlockEntityModels implements MinecraftAsset {
709
- [k: string]: any;
779
+ interface EntityModelOptions {
780
+ layer?: string;
781
+ /** Layer names in draw order; defaults to layer or "main". */
782
+ layers?: string[];
783
+ /** Per-layer texture overrides. The positional texture key applies to the first selected layer. */
784
+ textures?: Record<string, BasicAssetKey>;
710
785
  }
711
786
 
712
787
  declare class Models {
@@ -714,12 +789,27 @@ declare class Models {
714
789
  private static get PERSISTENT_CACHE();
715
790
  static getItemList(): Promise<string[]>;
716
791
  static loadAndMerge(key: AssetKey): Promise<Maybe<Model>>;
792
+ private static getItemModel;
793
+ private static defaultItemModel;
717
794
  static getRaw(key: AssetKey): Promise<Maybe<Model>>;
718
795
  static getMerged(key: AssetKey): Promise<Maybe<Model>>;
719
796
  static get(key: AssetKey): Promise<Maybe<Model>>;
720
797
  static clearCache(): Promise<void>;
721
798
  }
722
799
 
800
+ declare class DisplayTransforms {
801
+ /** Resolve hand fallbacks within one model, before inheriting parent display entries. */
802
+ static withHandFallbacks(display: Model["display"]): Model["display"];
803
+ /** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
804
+ static getMatrix(display: Model["display"], position: DisplayPosition): Matrix4;
805
+ static apply(geometry: BufferGeometry, matrix: Matrix4): void;
806
+ }
807
+
808
+ declare class ModelCulling {
809
+ static toLocalMask(worldMask: number, rotation: Euler): number;
810
+ static isOpaqueFullCube(atlas: Maybe<TextureAtlas>): boolean;
811
+ }
812
+
723
813
  declare class ModelGenerator {
724
814
  static readonly ITEM_LAYERS: string[];
725
815
  static generateItemModel(imageData: ImageData$1, layer: string): ModelElement[];
@@ -736,8 +826,16 @@ interface Block {
736
826
  nbt?: any;
737
827
  }
738
828
 
829
+ declare class BlockTints {
830
+ /** Resolves block preview colors without biome context; explicit tints take precedence. */
831
+ static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
832
+ private static grassColor;
833
+ }
834
+
739
835
  interface Instanceable {
740
836
  nextInstance(): InstanceReference<SceneObject>;
837
+ removeInstanceAt(index: number): void;
838
+ isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
741
839
  getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
742
840
  setMatrixAt(index: number, matrix: Matrix4): void;
743
841
  setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
@@ -750,12 +848,15 @@ interface Instanceable {
750
848
  }
751
849
  declare function isInstanceable(obj: any): obj is Instanceable;
752
850
 
753
- declare class InstanceReference<T extends Instanceable> implements Transformable {
851
+ declare class InstanceReference<T extends Instanceable> implements Transformable, Disposable {
754
852
  readonly instanceable: T;
755
853
  readonly index: number;
756
854
  readonly isInstanceReference: true;
757
855
  constructor(instanceable: T, index: number);
758
856
  nextInstance(): InstanceReference<SceneObject>;
857
+ private get activeInstanceable();
858
+ removeFromScene(): void;
859
+ dispose(): void;
759
860
  getMatrix(matrix?: Matrix4): Matrix4;
760
861
  setMatrix(matrix: Matrix4): void;
761
862
  setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
@@ -785,13 +886,21 @@ declare class ModelObject extends SceneObject {
785
886
  private meshesCreated;
786
887
  constructor(originalModel: Model, options?: Partial<ModelObjectOptions>);
787
888
  init(): Promise<void>;
788
- dispose(): void;
789
889
  get textureAtlas(): Maybe<TextureAtlas>;
890
+ get isOpaqueFullCube(): boolean;
790
891
  protected loadTextures(): Promise<void>;
791
892
  protected createMeshes(force?: boolean): void;
792
893
  protected applyTextures(): void;
793
894
  }
794
895
  interface ModelObjectOptions extends SceneObjectOptions {
896
+ /** Minecraft display pose applied around the model center, before scene transforms. */
897
+ displayPosition?: DisplayPosition;
898
+ /** Quarter-turn block rotation in radians to compensate when locking UVs. */
899
+ uvLockRotation?: TripleArray;
900
+ /** sRGB 0xRRGGBB colors by face tint index; omitted indices stay white. */
901
+ tints?: Record<number, number>;
902
+ /** Hidden neighbor directions in CUBE_FACES order, before the model's block rotation. */
903
+ cullMask?: number;
795
904
  }
796
905
  declare function isModelObject(obj: any): obj is ModelObject;
797
906
 
@@ -824,24 +933,35 @@ declare enum SkinPart {
824
933
  }
825
934
  declare const SKIN_PARTS: SkinPart[];
826
935
 
936
+ type CapeLayout = "minecraft" | "optifine" | "labymod";
937
+ declare const capeTextureSizes: Record<CapeLayout, DoubleArray>;
938
+
827
939
  declare class SkinObject extends SceneObject {
828
940
  readonly options: SkinObjectOptions;
829
941
  private slim;
830
- private legacy;
942
+ private detectedSlim;
831
943
  private skinTextureSrc?;
832
- private skinTextureWidth;
833
- private skinTextureHeight;
834
- private capeTextureSrc?;
944
+ private skinMaterial?;
945
+ private skinLoad;
946
+ private capeLoad;
835
947
  constructor(options?: DeepPartial<SkinObjectOptions>);
836
948
  init(): Promise<void>;
837
949
  protected removeMeshes(): void;
838
950
  protected createMeshes(): void;
839
- setSkinTexture(src: string): void;
840
- setSlim(slim: boolean): void;
841
- setLegacy(legacy: boolean): void;
951
+ setSkinTexture(src: string): Promise<void>;
952
+ /** Load a cape texture in the selected layout, or pass undefined to remove the cape. */
953
+ setCapeTexture(src?: string, layout?: CapeLayout): Promise<void>;
954
+ /** Select the arm model, or pass undefined to use texture detection. */
955
+ setSlim(slim?: boolean): void;
956
+ private updateSlim;
957
+ /** Select the texture layout, or pass undefined to detect it from image dimensions. */
958
+ setLegacy(legacy?: boolean): Promise<void>;
959
+ dispose(): void;
842
960
  protected getBoxGeometry(part: SkinPart): BoxGeometry;
843
961
  }
844
962
  interface SkinObjectOptions extends SceneObjectOptions {
963
+ slim?: boolean;
964
+ legacy?: boolean;
845
965
  }
846
966
 
847
967
  declare class EntityObject extends SceneObject {
@@ -849,16 +969,22 @@ declare class EntityObject extends SceneObject {
849
969
  readonly isEntityObject: true;
850
970
  static readonly DEFAULT_OPTIONS: EntityObjectOptions;
851
971
  readonly options: EntityObjectOptions;
852
- private imageData?;
853
972
  private meshesCreated;
854
973
  constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
855
974
  init(): Promise<void>;
856
975
  dispose(): void;
857
- protected loadTextures(): Promise<void>;
976
+ getLayerGroup(name: string): Maybe<Object3D>;
977
+ getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
978
+ getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
979
+ private get entityLayers();
980
+ private getTextureKey;
981
+ protected loadTextures(layer?: EntityLayer): Promise<Maybe<ExtractableImageData>>;
858
982
  protected createMeshes(force?: boolean): void;
983
+ private createPart;
859
984
  protected applyTextures(): Promise<void>;
860
985
  }
861
986
  interface EntityObjectOptions extends SceneObjectOptions {
987
+ flip?: boolean;
862
988
  }
863
989
  declare function isEntityObject(obj: any): obj is EntityObject;
864
990
 
@@ -886,7 +1012,9 @@ interface MineRenderSceneOptions {
886
1012
  }
887
1013
  declare function isMineRenderScene(obj: any): obj is MineRenderScene;
888
1014
 
889
- declare class SceneObject extends Object3D implements Disposable, Instanceable, Transformable {
1015
+ declare class SceneObject extends Object3D<Object3DEventMap & {
1016
+ change: {};
1017
+ }> implements Disposable, Instanceable, Transformable {
890
1018
  readonly isSceneObject: true;
891
1019
  static readonly DEFAULT_OPTIONS: SceneObjectOptions;
892
1020
  readonly options: SceneObjectOptions;
@@ -894,6 +1022,9 @@ declare class SceneObject extends Object3D implements Disposable, Instanceable,
894
1022
  private materialCallbacks;
895
1023
  protected _isInstanced: boolean;
896
1024
  _instanceCounter: number;
1025
+ protected instanceMesh?: InstancedMesh;
1026
+ private readonly instanceReferences;
1027
+ private readonly freeInstanceIndices;
897
1028
  constructor(options?: Partial<SceneObjectOptions>);
898
1029
  set scene(scene: MineRenderScene);
899
1030
  get scene(): MineRenderScene;
@@ -912,9 +1043,9 @@ declare class SceneObject extends Object3D implements Disposable, Instanceable,
912
1043
  */
913
1044
  toggleGroupVisibility(name: string, visible?: boolean): boolean;
914
1045
  protected addOrReplaceMesh(mesh: Mesh, parent: Object3D, name?: string): void;
915
- protected createAndAddMesh(name?: string, group?: Object3D, geometry?: BufferGeometry, material?: Material$1 | Material$1[], offsetAxis?: Axis, offset?: number): Mesh;
916
- protected createMesh(name?: string, geometry?: BufferGeometry, material?: Material$1 | Material$1[], offsetAxis?: Axis, offset?: number): Mesh;
917
- protected createInstancedMesh(name: Maybe<string>, geometry: BufferGeometry, material: Material$1 | Material$1[], count: number): InstancedMesh;
1046
+ protected createAndAddMesh(name?: string, group?: Object3D, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
1047
+ protected createMesh(name?: string, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
1048
+ protected createInstancedMesh(name: Maybe<string>, geometry: BufferGeometry, material: Material | Material[], count: number): InstancedMesh;
918
1049
  /**
919
1050
  * Get a mesh by its name
920
1051
  */
@@ -933,6 +1064,10 @@ declare class SceneObject extends Object3D implements Disposable, Instanceable,
933
1064
  get instanceCounter(): number;
934
1065
  protected constructInstanceReference(i: number): InstanceReference<SceneObject>;
935
1066
  nextInstance(): InstanceReference<SceneObject>;
1067
+ isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
1068
+ removeInstanceAt(index: number): void;
1069
+ private growInstances;
1070
+ protected activeInstanceIndices(): Iterable<number>;
936
1071
  getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
937
1072
  setMatrixAt(index: number, matrix: Matrix4): void;
938
1073
  setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
@@ -969,10 +1104,17 @@ declare class BlockObject extends SceneObject {
969
1104
  private _instanceModel;
970
1105
  private _variants;
971
1106
  private _models;
1107
+ private _cullMask;
972
1108
  constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
973
1109
  init(): Promise<void>;
974
1110
  dispose(): void;
975
1111
  removeFromScene(): void;
1112
+ private clearModels;
1113
+ private removeModels;
1114
+ get isOccluding(): boolean;
1115
+ private getModelMatrix;
1116
+ private getModelCullMask;
1117
+ setCullMask(worldMask: number): Promise<void>;
976
1118
  get state(): {
977
1119
  [key: string]: string;
978
1120
  };
@@ -994,26 +1136,35 @@ declare class BlockObject extends SceneObject {
994
1136
  }
995
1137
  interface BlockObjectOptions extends ModelObjectOptions {
996
1138
  applyDefaultState: boolean;
1139
+ /** Properties applied before model creation, overriding defaults when applyDefaultState is enabled. */
1140
+ initialState?: BlockStateProperties;
997
1141
  }
998
1142
  declare function isBlockObject(obj: any): obj is BlockObject;
999
1143
 
1000
1144
  interface MultiBlockStructure {
1001
1145
  readonly size: TripleArray;
1002
1146
  readonly blocks: MultiBlockBlock[];
1147
+ readonly dataVersion?: number;
1148
+ readonly entities?: MultiBlockEntity[];
1149
+ }
1150
+ interface MultiBlockEntity {
1151
+ position: TripleArray;
1152
+ blockPosition?: TripleArray;
1153
+ nbt: unknown;
1003
1154
  }
1004
1155
  interface MultiBlockBlock extends Block {
1005
1156
  position: TripleArray;
1006
1157
  }
1007
1158
 
1008
1159
  declare class SchematicParser {
1009
- static parse(): Promise<MultiBlockStructure>;
1160
+ static parse(nbt: NBT): Promise<MultiBlockStructure>;
1010
1161
  }
1011
1162
 
1012
1163
  declare class StructureParser {
1013
1164
  static parse(_nbt: NBT, paletteIndex?: number): Promise<MultiBlockStructure>;
1014
1165
  }
1015
1166
  interface StructureNBT {
1016
- DataVersion: {
1167
+ DataVersion?: {
1017
1168
  type: "int";
1018
1169
  value: number;
1019
1170
  };
@@ -1025,7 +1176,13 @@ interface StructureNBT {
1025
1176
  };
1026
1177
  };
1027
1178
  palette?: Palette;
1028
- palettes?: Palette[];
1179
+ palettes?: {
1180
+ type: "list";
1181
+ value: {
1182
+ type: "list";
1183
+ value: Palette["value"][];
1184
+ };
1185
+ };
1029
1186
  blocks: {
1030
1187
  type: "list";
1031
1188
  value: {
@@ -1033,7 +1190,32 @@ interface StructureNBT {
1033
1190
  value: BlockEntry[];
1034
1191
  };
1035
1192
  };
1036
- entities: {};
1193
+ entities?: {
1194
+ type: "list";
1195
+ value: {
1196
+ type: "compound";
1197
+ value: {
1198
+ pos: {
1199
+ type: "list";
1200
+ value: {
1201
+ type: "double";
1202
+ value: TripleArray;
1203
+ };
1204
+ };
1205
+ blockPos: {
1206
+ type: "list";
1207
+ value: {
1208
+ type: "int";
1209
+ value: TripleArray;
1210
+ };
1211
+ };
1212
+ nbt: {
1213
+ type: "compound";
1214
+ value: any;
1215
+ };
1216
+ }[];
1217
+ };
1218
+ };
1037
1219
  }
1038
1220
  interface Palette {
1039
1221
  type: "list";
@@ -1077,14 +1259,17 @@ interface BlockEntry {
1077
1259
  }
1078
1260
 
1079
1261
  declare class NBTHelper {
1080
- static fromBuffer(buffer: Buffer): Promise<NBTAsset>;
1262
+ static fromBuffer(data: Uint8Array | ArrayBuffer, format?: NBTFormat): Promise<NBTAsset>;
1081
1263
  }
1082
1264
  interface NBTAsset extends MinecraftAsset, NBT {
1265
+ format?: NBTFormat;
1266
+ metadata?: Metadata;
1267
+ compression?: "gzip" | "none";
1083
1268
  }
1084
1269
 
1085
1270
  interface ResponseParser<T extends MinecraftAsset> {
1086
- config(request: AxiosRequestConfig): any;
1087
- parse(response: AxiosResponse): Maybe<T> | Promise<Maybe<T>>;
1271
+ config(request: RequestConfig): any;
1272
+ parse(response: RequestResponse): Maybe<T> | Promise<Maybe<T>>;
1088
1273
  }
1089
1274
 
1090
1275
  declare class HostedAssetSource extends AssetSource {
@@ -1103,6 +1288,7 @@ declare class HostedAssetSource extends AssetSource {
1103
1288
  private readonly _options;
1104
1289
  constructor(root: string, options?: Partial<HostedAssetSourceOptions>);
1105
1290
  get root(): string;
1291
+ get cacheId(): string;
1106
1292
  get options(): HostedAssetSourceOptions;
1107
1293
  get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser): Promise<Maybe<T>>;
1108
1294
  }
@@ -1117,6 +1303,8 @@ interface ArchiveEntry {
1117
1303
  }
1118
1304
 
1119
1305
  interface ArchiveProxy {
1306
+ /** Identifies the archive's content across sessions; undefined when it cannot be identified. */
1307
+ readonly id?: string;
1120
1308
  getEntries(): Promise<ArchiveEntry[]>;
1121
1309
  }
1122
1310
 
@@ -1124,6 +1312,7 @@ declare class ArchiveAssetSource extends AssetSource implements ArchiveProxy {
1124
1312
  readonly _archiveProxy: ArchiveProxy;
1125
1313
  constructor(archiveProxy: ArchiveProxy);
1126
1314
  static blob(blob: Blob): ArchiveAssetSource;
1315
+ get cacheId(): Maybe<string>;
1127
1316
  getEntries(): Promise<ArchiveEntry[]>;
1128
1317
  getEntry(path: string): Promise<Maybe<ArchiveEntry>>;
1129
1318
  get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
@@ -1134,7 +1323,8 @@ declare class ArchiveAssetSource extends AssetSource implements ArchiveProxy {
1134
1323
  declare class BrowserArchiveProxy implements ArchiveProxy {
1135
1324
  readonly _blob: Blob;
1136
1325
  readonly _reader: ZipReader<Blob>;
1137
- constructor(blob: Blob);
1326
+ readonly id?: string;
1327
+ constructor(blob: Blob, id?: string);
1138
1328
  getEntries(): Promise<ArchiveEntry[]>;
1139
1329
  }
1140
1330
 
@@ -1212,14 +1402,20 @@ declare class Caching {
1212
1402
  static readonly mergedModelCache: AsyncLoadingCache<CacheKey, Model>;
1213
1403
  static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
1214
1404
  static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
1405
+ static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
1406
+ static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
1407
+ static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
1408
+ static readonly entityModelCache: AsyncLoadingCache<CacheKey, EntityModelFile>;
1409
+ static readonly entityTextureCache: AsyncLoadingCache<CacheKey, AssetKey>;
1410
+ private static createAssetCache;
1215
1411
  /** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
1216
1412
  private static get all();
1217
1413
  static clear(): void;
1218
1414
  /**
1219
1415
  * Clears every cache and stops its expiry timer.
1220
1416
  *
1221
- * loading-cache reschedules that timer indefinitely, so a Node process will not exit until
1222
- * this is called - see {@link shutdown}.
1417
+ * Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
1418
+ * Use {@link shutdown} to also stop requests and the shared Ticker.
1223
1419
  */
1224
1420
  static end(): void;
1225
1421
  static get cacheSizes(): {};
@@ -1319,7 +1515,7 @@ declare class Renderer implements Disposable {
1319
1515
  protected _scene: MineRenderScene;
1320
1516
  protected _camera: Camera;
1321
1517
  protected _renderer: WebGLRenderer;
1322
- protected _composer: EffectComposer;
1518
+ protected _composer?: EffectComposer;
1323
1519
  protected _controls?: OrbitControls;
1324
1520
  protected _stats?: Stats;
1325
1521
  protected _dirty: boolean;
@@ -1335,7 +1531,7 @@ declare class Renderer implements Disposable {
1335
1531
  protected createScene(): MineRenderScene;
1336
1532
  protected createCamera(): Camera;
1337
1533
  protected createRenderer(): WebGLRenderer;
1338
- protected createComposer(): EffectComposer;
1534
+ protected createComposer(): Maybe<EffectComposer>;
1339
1535
  protected createControls(): Maybe<OrbitControls>;
1340
1536
  init(): void;
1341
1537
  get element(): Maybe<HTMLElement>;
@@ -1344,7 +1540,7 @@ declare class Renderer implements Disposable {
1344
1540
  * Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
1345
1541
  * The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
1346
1542
  */
1347
- registerEventDispatcher(dispatcher: EventDispatcher, changeEvent?: string): void;
1543
+ registerEventDispatcher(dispatcher: EventDispatcher<any>, changeEvent?: string): void;
1348
1544
  resize(width: number, height: number): void;
1349
1545
  get dirty(): boolean;
1350
1546
  set dirty(dirty: boolean);
@@ -1364,7 +1560,7 @@ declare class Renderer implements Disposable {
1364
1560
  get scene(): MineRenderScene;
1365
1561
  get camera(): Camera;
1366
1562
  get renderer(): WebGLRenderer;
1367
- get composer(): EffectComposer;
1563
+ get composer(): Maybe<EffectComposer>;
1368
1564
  /** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
1369
1565
  get controls(): Maybe<OrbitControls>;
1370
1566
  }
@@ -1421,7 +1617,7 @@ declare class SceneInspector {
1421
1617
  private selectedObject?;
1422
1618
  constructor(renderer: Renderer);
1423
1619
  protected init(): void;
1424
- findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry, three.Material | three.Material[]>[];
1620
+ findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[], three.Object3DEventMap>[];
1425
1621
  onClick(event: any): void;
1426
1622
  appendTo(el: HTMLElement): void;
1427
1623
  protected handleRaycasterObjects(intersections: Intersection[]): void;
@@ -1458,34 +1654,33 @@ declare class StatLine {
1458
1654
  update(): void;
1459
1655
  }
1460
1656
 
1461
- declare class Requests {
1462
- private static axiosInstance;
1463
- private static mcAssetInstance;
1464
- private static genericQueue;
1465
- private static mcAssetRequestQueue;
1466
- static genericRequest(request: AxiosRequestConfig): Promise<AxiosResponse>;
1467
- static mcAssetRequest(request: AxiosRequestConfig): Promise<AxiosResponse>;
1468
- private static shouldRetry;
1469
- static setMcAssetRoot(root: string): void;
1470
- static get queueSizes(): {
1471
- generic: number;
1472
- mcAsset: number;
1473
- };
1474
- /**
1475
- * Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
1476
- * exit until this is called - see {@link shutdown}.
1477
- */
1478
- static end(): void;
1479
- }
1480
-
1481
1657
  type SkinGeometries = Record<SkinPart, TripleArray>;
1482
1658
  declare const classicSkinGeometries: SkinGeometries;
1483
1659
  declare const slimSkinGeometries: SkinGeometries;
1484
1660
 
1661
+ declare class SkinImage {
1662
+ static getData(src: string): Promise<ImageData>;
1663
+ private static decodePng;
1664
+ }
1665
+
1485
1666
  type SkinTextureCoordinates = Record<SkinPart, ModelFaces>;
1486
1667
  declare const classicSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
1487
1668
  declare const slimSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
1488
1669
 
1670
+ interface SkinTexture {
1671
+ material: MeshBasicMaterial;
1672
+ slim: boolean;
1673
+ legacy: boolean;
1674
+ }
1675
+ declare class SkinTextures {
1676
+ static get(src: string, legacy?: boolean): Promise<SkinTexture>;
1677
+ static getCape(src: string, layout?: CapeLayout): Promise<MeshBasicMaterial>;
1678
+ private static createMaterial;
1679
+ private static isSlim;
1680
+ private static normalizeLegacy;
1681
+ private static makeBaseOpaque;
1682
+ }
1683
+
1489
1684
  declare class Skins {
1490
1685
  static fromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
1491
1686
  static fromUuid(uuid: string): Promise<Maybe<string>>;
@@ -1494,8 +1689,11 @@ declare class Skins {
1494
1689
  static capeFromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
1495
1690
  static capeFromUuid(uuid: string): Promise<Maybe<string>>;
1496
1691
  static capeFromUsername(username: string): Promise<Maybe<string>>;
1497
- static capeFromCapesDev(uuid: string, capeType?: string): Promise<Maybe<string>>;
1692
+ /** Returns a full static cape texture for a username or UUID. */
1693
+ static capeFromCapesDev(player: string, capeType?: string): Promise<Maybe<string>>;
1498
1694
  private static usernameToUuid;
1695
+ private static usernameToUuidMcProxy;
1696
+ /** @deprecated **/
1499
1697
  private static usernameToUuidSkinProxy;
1500
1698
  private static usernameToUuidMineTools;
1501
1699
  private static getProfileFromMinetools;
@@ -1505,11 +1703,18 @@ declare class Skins {
1505
1703
  private static getCrafatarCapeUrl;
1506
1704
  private static getMcHeadsSkinUrl;
1507
1705
  private static getMineSkinPlayerSkinUrl;
1706
+ /** @deprecated **/
1508
1707
  private static getSkinProxySkinUrl;
1708
+ /** @deprecated **/
1509
1709
  private static getSkinProxyCapeUrl;
1710
+ private static getMcProxySkinUrl;
1711
+ private static getMcProxyCapeUrl;
1510
1712
  }
1511
1713
 
1512
1714
  declare class TextureLoader {
1715
+ private static readonly failedTextures;
1716
+ /** Reports whether image loading failed, so cached textures can be retried. */
1717
+ static hasFailed(texture: Texture): boolean;
1513
1718
  protected static createTexture(): Texture;
1514
1719
  static loadInBackground(src: string, format?: PixelFormat, rotation?: number): Texture;
1515
1720
  static load(src: string, format?: PixelFormat, rotation?: number): Texture;
@@ -1523,27 +1728,74 @@ declare class Textures {
1523
1728
  static getImage(key: TextureKey): Texture;
1524
1729
  }
1525
1730
 
1526
- declare function mergeBufferGeometries(geometries: BufferGeometry$1[], useGroups?: boolean): BufferGeometry$1;
1731
+ declare function mergeBufferGeometries(geometries: BufferGeometry[], useGroups?: boolean): BufferGeometry;
1527
1732
  declare function mergeBufferAttributes(attributes: BufferAttribute[]): BufferAttribute;
1528
1733
  declare function interleaveAttributes(attributes: BufferAttribute[]): InterleavedBufferAttribute;
1529
- declare function estimateBytesUsed(geometry: BufferGeometry$1): number;
1530
- declare function mergeVertices(geometry: BufferGeometry$1, tolerance?: number): BufferGeometry$1;
1531
- declare function toTrianglesDrawMode(geometry: BufferGeometry$1, drawMode: TrianglesDrawModes): BufferGeometry$1;
1734
+ declare function estimateBytesUsed(geometry: BufferGeometry): number;
1735
+ declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): BufferGeometry;
1736
+ declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
1532
1737
  declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
1533
1738
 
1739
+ declare class ChunkData {
1740
+ private readonly indices;
1741
+ private readonly palette;
1742
+ private readonly paletteIds;
1743
+ private readonly freeIds;
1744
+ private readonly nbt;
1745
+ get(index: number): Maybe<Block>;
1746
+ snapshot(index: number): Maybe<() => Block>;
1747
+ set(index: number, block?: Block): void;
1748
+ clear(): void;
1749
+ static isAir(block: Maybe<Block>): boolean;
1750
+ private static copyBlock;
1751
+ private static validateIndex;
1752
+ }
1753
+
1754
+ type RegionInput = Uint8Array | ArrayBuffer;
1755
+ interface AnvilRegion {
1756
+ chunks: AnvilChunk[];
1757
+ }
1758
+ interface AnvilChunk {
1759
+ x: number;
1760
+ z: number;
1761
+ dataVersion?: number;
1762
+ sections: {
1763
+ y: number;
1764
+ data: ChunkData;
1765
+ }[];
1766
+ entities?: MultiBlockEntity[];
1767
+ }
1768
+ declare class AnvilParser {
1769
+ static getChunkList(data: RegionInput): {
1770
+ x: number;
1771
+ z: number;
1772
+ }[];
1773
+ static parse(data: RegionInput): Promise<AnvilRegion>;
1774
+ static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
1775
+ private static bytes;
1776
+ private static locations;
1777
+ private static readChunk;
1778
+ private static compounds;
1779
+ private static integer;
1780
+ private static block;
1781
+ private static unpack;
1782
+ }
1783
+
1534
1784
  interface BlockInfo {
1535
- block: Block;
1785
+ /** Detached block data; use world or chunk setters to update stored blocks. */
1786
+ readonly block: Block;
1536
1787
  object: BlockObject;
1537
1788
  }
1538
1789
 
1539
1790
  declare class Chunk {
1791
+ private readonly onBlocksChanged?;
1540
1792
  readonly scene: MineRenderScene;
1541
1793
  readonly x: number;
1542
1794
  readonly y: number;
1543
1795
  readonly z: number;
1544
- private readonly _blocks;
1545
- private readonly _anchor;
1546
- constructor(scene: MineRenderScene, x: number, y: number, z: number);
1796
+ private readonly data;
1797
+ private readonly renderedBlocks;
1798
+ constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined);
1547
1799
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1548
1800
  getBlockAt(pos: Vector3): Maybe<BlockInfo>;
1549
1801
  getBlockAt(pos: TripleArray): Maybe<BlockInfo>;
@@ -1554,11 +1806,12 @@ declare class Chunk {
1554
1806
  setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1555
1807
  setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1556
1808
  /**
1557
- * Set block at a _chunk_ position (0-16)
1809
+ * Set a block at integer chunk-local coordinates from 0 to 15.
1558
1810
  */
1559
- setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3): Promise<Maybe<BlockInfo>>;
1560
- clear(): Promise<void>;
1811
+ setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo>>;
1812
+ clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
1561
1813
  dispose(): Promise<void>;
1814
+ static isAir(block: Maybe<Block>): boolean;
1562
1815
  static chunkPosToBlockIndex(pos: Vector3): number;
1563
1816
  worldPosToChunkPos(pos: Vector3): Vector3;
1564
1817
  chunkPosToWorldPos(pos: Vector3): Vector3;
@@ -1566,23 +1819,27 @@ declare class Chunk {
1566
1819
 
1567
1820
  declare class MineRenderWorld {
1568
1821
  readonly scene: MineRenderScene;
1569
- private _size;
1570
- private _blockSize;
1571
1822
  private readonly _chunks;
1823
+ private readonly pendingCulling;
1824
+ private culling?;
1572
1825
  constructor(scene: MineRenderScene);
1573
1826
  getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo>;
1574
1827
  getBlockAt(pos: Vector3): Maybe<BlockInfo>;
1575
1828
  getBlockAt(pos: TripleArray): Maybe<BlockInfo>;
1576
- setBlockAt(x: number, y: number, z: number, block: Block): Promise<Maybe<BlockInfo>>;
1577
- setBlockAt(pos: Vector3, block: Block): Promise<Maybe<BlockInfo>>;
1578
- setBlockAt(pos: TripleArray, block: Block): Promise<Maybe<BlockInfo>>;
1829
+ setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1830
+ setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1831
+ setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo>>;
1832
+ private placeBlock;
1579
1833
  placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
1834
+ private placeBlocks;
1835
+ /** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
1836
+ placeChunk(chunk: AnvilChunk, executor?: BatchedExecutor): Promise<void>;
1580
1837
  clear(): Promise<void>;
1838
+ private updateCulling;
1581
1839
  private getOrCreateChunkAt;
1582
1840
  getChunkAt(pos: Vector3): Maybe<Chunk>;
1583
1841
  static worldToScenePosition(pos: Vector3): Vector3;
1584
1842
  static sceneToWorldPosition(pos: Vector3): Vector3;
1585
- worldPosToChunkIndex(pos: Vector3): number;
1586
1843
  worldPosToChunkKey(pos: Vector3): string;
1587
1844
  validatePosBounds(pos: Vector3): void;
1588
1845
  }
@@ -1619,8 +1876,8 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
1619
1876
  *
1620
1877
  * `image-size` pulls in `fs`/`path` at module scope, so it can only live in the Node build.
1621
1878
  * Everything MineRender loads is a PNG in practice; GIF and JPEG are handled as a courtesy and
1622
- * anything else falls through to an empty result (callers treat that as 0x0).
1879
+ * anything else falls through to an empty result, which ImageLoader rejects.
1623
1880
  */
1624
1881
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
1625
1882
 
1626
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, 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, BlockEntityModels, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, type Cube, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityModel, EntityModels, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, 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 MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, type ModelPart, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinObject, type SkinObjectOptions, SkinPart, type SkinTextureCoordinates, 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, applyModelPartRotation, axisToVec3, base64decode, base64encode, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
1883
+ 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 BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, 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 MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, 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, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };