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