minerender 2.1.0-alpha.3 → 2.1.0-alpha.30

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
5
  import { Buffer as Buffer$1 } from 'buffer';
7
6
  import { NBT } 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
  }
@@ -63,10 +60,11 @@ declare function createCanvas(width: number, height: number): CompatCanvas;
63
60
  declare abstract class PersistentCache<B = unknown> {
64
61
  readonly backing: B;
65
62
  /** Bump to invalidate every persisted entry. */
66
- static readonly VERSION = 1;
63
+ static readonly VERSION = 2;
67
64
  static open(name: string): PersistentCache;
68
65
  protected constructor(backing: B);
69
66
  abstract get<T>(key: string): Promise<T>;
67
+ /** Loads a missing entry and stores only non-nullish results. */
70
68
  getOrLoad<T>(key: string, loader: (key: string) => Promise<T>): Promise<T>;
71
69
  abstract put<T>(key: string, value: T): Promise<T>;
72
70
  abstract delete<T>(key: string): Promise<void>;
@@ -176,6 +174,7 @@ declare class AssetKey extends BasicAssetKey {
176
174
  rootType: "assets" | "data" | string;
177
175
  extension: ".json" | ".png" | string;
178
176
  root?: string | undefined;
177
+ readonly isAssetKey: true;
179
178
  constructor(namespace: string, path: string, assetType?: AssetType | undefined, type?: string | undefined, rootType?: "assets" | "data" | string, extension?: ".json" | ".png" | string, root?: string | undefined);
180
179
  static parse(assetType: AssetType, str: string, origin?: AssetKey): AssetKey;
181
180
  toString(): string;
@@ -248,7 +247,8 @@ declare enum DisplayPosition {
248
247
  GUI = "gui",
249
248
  HEAD = "head",
250
249
  GROUND = "ground",
251
- FIXED = "fixed"
250
+ FIXED = "fixed",
251
+ ON_SHELF = "on_shelf"
252
252
  }
253
253
  declare const DISPLAY_POSITIONS: DisplayPosition[];
254
254
 
@@ -257,6 +257,46 @@ declare enum GuiLight {
257
257
  SIDE = "side"
258
258
  }
259
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
+
260
300
  declare class WrappedImage {
261
301
  readonly dta: ExtractableImageData;
262
302
  constructor(dta: ExtractableImageData);
@@ -292,7 +332,7 @@ declare class ImageLoader {
292
332
  static infoToData(info: ImageInfo): Promise<ImageData>;
293
333
  static getData(src: string): Promise<ImageData>;
294
334
  static getCanvasData(src: string): Promise<ExtractableImageData>;
295
- static processResponse(response: Partial<AxiosResponse>): Promise<ImageInfo>;
335
+ static processResponse(response: Pick<RequestResponse<ArrayBuffer>, "data" | "url">): Promise<ImageInfo>;
296
336
  static loadInfo(src: string): Promise<ImageInfo>;
297
337
  static getInfo(src: string): Promise<ImageInfo>;
298
338
  static loadWrapped(src: string): Promise<WrappedImage>;
@@ -306,7 +346,7 @@ declare const DEFAULT_ELEMENTS: ModelElement[];
306
346
  interface Model extends MinecraftAsset {
307
347
  textures?: IModelTextures;
308
348
  parent?: string;
309
- display?: ModelDisplay;
349
+ display?: Partial<Record<DisplayPosition, ModelDisplay>>;
310
350
  elements?: ModelElement[];
311
351
  hierarchy?: string[];
312
352
  }
@@ -321,7 +361,6 @@ interface ItemModel extends Model {
321
361
  interface TextureAsset extends MinecraftAsset, ImageInfo {
322
362
  }
323
363
  interface ModelDisplay {
324
- position?: DisplayPosition;
325
364
  translation?: TripleArray;
326
365
  rotation?: TripleArray;
327
366
  scale?: TripleArray;
@@ -341,13 +380,7 @@ declare function isDoubleArray(obj: any): obj is DoubleArray;
341
380
  declare function isTripleArray(obj: any): obj is TripleArray;
342
381
  declare function isQuadArray(obj: any): obj is QuadArray;
343
382
 
344
- /**
345
- * down up
346
- * east north west south
347
- *
348
- * bottom-left to top-right
349
- * [bl, br, tl, tr]
350
- */
383
+ /** Vanilla Minecraft cube UVs in Three.js BoxGeometry face and vertex order. */
351
384
  declare class MinecraftCubeTexture {
352
385
  readonly u: number;
353
386
  readonly v: number;
@@ -363,7 +396,7 @@ declare class MinecraftCubeTexture {
363
396
  getUvSouth(w: number, h: number, l: number): QuadArray<DoubleArray>;
364
397
  getUvNorth(w: number, h: number, l: number): QuadArray<DoubleArray>;
365
398
  getFaceUv(face: CubeFace, w: number, h: number, l: number): QuadArray<DoubleArray>;
366
- toUvArray(w: number, h: number, l: number): number[];
399
+ toUvArray(w: number, h: number, l: number, mirror?: boolean): number[];
367
400
  }
368
401
 
369
402
  interface MinecraftTextureMeta extends MinecraftAsset {
@@ -432,7 +465,7 @@ interface Transformable {
432
465
  declare function isTransformable(obj: any): obj is Transformable;
433
466
 
434
467
  declare const changeEvent: {
435
- type: string;
468
+ type: "change";
436
469
  };
437
470
  type Maybe<T> = T | undefined;
438
471
  declare function md5(str: string): string;
@@ -516,6 +549,7 @@ declare class UVMapper {
516
549
  static setCubeUvs(geometry: BoxGeometry, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray, faces: ModelFaces): void;
517
550
  static facesToUvArray(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): number[];
518
551
  static facesToUv(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): Float32BufferAttribute;
552
+ static lockUvs(geometry: BoxGeometry, faces: ModelFaces, atlas: TextureAtlas, rotation: Euler): void;
519
553
  static getAtlas(model: Model): Promise<Maybe<TextureAtlas>>;
520
554
  static fillMissingTextureKeys<T>(textures: ModelTextures, target: {
521
555
  [k: string]: T;
@@ -537,14 +571,13 @@ declare class MinecraftFaceUV {
537
571
  }
538
572
 
539
573
  /**
540
- * 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.
541
575
  *
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.
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.
546
578
  *
547
- * 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.
548
581
  */
549
582
  declare function shutdown(): void;
550
583
 
@@ -562,32 +595,7 @@ type Task = () => any | Promise<any>;
562
595
 
563
596
  declare function prefix(prefix?: string): string;
564
597
 
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
598
  declare function applyElementRotation(rotation: ElementRotation, geometry: BufferGeometry): void;
590
- declare function applyModelPartRotation(modelPart: ModelPart, geometry: BufferGeometry): void;
591
599
  declare function applyGenericRotation(axis: Axis, rotation: number, obj: Object3D): void;
592
600
  declare function addBox3WireframeToObject(box: Box3, obj: Object3D, color?: number, w?: number): void;
593
601
  declare function addWireframeToObject(obj: Object3D, color?: number, w?: number): void;
@@ -616,15 +624,47 @@ declare enum AssetParser {
616
624
  declare abstract class AssetSource {
617
625
  protected constructor();
618
626
  abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
627
+ /**
628
+ * Identifies this source's content across sessions for persistent caching. Sources that
629
+ * cannot tell whether their content changed (an unnamed archive, for example) return
630
+ * undefined, which keeps their results out of long-lived caches.
631
+ */
632
+ get cacheId(): Maybe<string>;
633
+ }
634
+ /** A source failed to load or parse an asset; cause retains the original failure. */
635
+ declare class AssetLoadError extends Error {
636
+ readonly source: AssetSource;
637
+ readonly key: AssetKey;
638
+ readonly path: string;
639
+ readonly cause: unknown;
640
+ constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
619
641
  }
620
642
 
621
643
  declare class AssetLoader {
622
644
  static ROOT: string;
623
645
  private static _SOURCES;
646
+ /** Used when a registered source cannot identify its content, so nothing persists past this session. */
647
+ private static readonly SESSION_SCOPE;
648
+ static get version(): string;
649
+ static setVersion(version: string): void;
650
+ /**
651
+ * Scope for persistent cache keys. Empty with only the default vanilla sources, so their
652
+ * entries stay valid across sessions; otherwise it names every added source (resource packs,
653
+ * mirrors) so their results never masquerade as vanilla assets after a reload.
654
+ */
655
+ static get persistentScope(): string;
656
+ /** Prefixes a persistent cache key with the current source scope. */
657
+ static persistentKey(key: string): string;
624
658
  static addSource(key: string, source: AssetSource, override?: boolean): void;
625
659
  static removeSource(key: string): Maybe<AssetSource>;
626
660
  static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
661
+ /** Returns the first defined result in source-priority order, without merging assets. */
627
662
  static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
663
+ /** Tries each path within a source before considering lower-priority sources. */
664
+ static getFirst<T extends MinecraftAsset>(keys: readonly AssetKey[], parser: AssetParser | string): Promise<Maybe<{
665
+ key: AssetKey;
666
+ asset: T;
667
+ }>>;
628
668
  }
629
669
 
630
670
  interface BlockState extends MinecraftAsset {
@@ -639,18 +679,19 @@ interface BlockStateVariant {
639
679
  y?: number;
640
680
  x?: number;
641
681
  uvlock?: boolean;
682
+ weight?: number;
642
683
  }
643
684
  interface BlockStateMultipart {
644
- when?: MultipartCondition | {
645
- OR: MultipartCondition[];
646
- };
647
- apply?: BlockStateVariant;
648
- }
649
- interface MultipartCondition {
650
- [key: string]: string;
685
+ when?: MultipartCondition;
686
+ apply?: BlockStateVariant | BlockStateVariant[];
651
687
  }
688
+ type MultipartCondition = Record<string, string> | {
689
+ OR: MultipartCondition[];
690
+ } | {
691
+ AND: MultipartCondition[];
692
+ };
652
693
 
653
- declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.17.1";
694
+ declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.21.11";
654
695
  declare const DEFAULT_NAMESPACE = "minecraft";
655
696
  declare class Assets {
656
697
  /**
@@ -689,25 +730,50 @@ declare class DefaultBlockStates implements MinecraftAsset {
689
730
  [k: string]: BlockStatePropertyDefaults;
690
731
  }
691
732
 
692
- interface EntityModel extends BasicMinecraftAsset {
693
- parts?: {
694
- [p: string]: ModelPart;
733
+ interface EntityModel {
734
+ key: BasicAssetKey;
735
+ texture?: AssetKey;
736
+ layer: EntityModelLayer;
737
+ id: string;
738
+ }
739
+ interface EntityModelFile extends MinecraftAsset {
740
+ id: string;
741
+ layers: Record<string, EntityModelLayer>;
742
+ }
743
+ interface EntityModelLayer {
744
+ texture: [number, number];
745
+ textureLocation?: string;
746
+ root: EntityModelPart;
747
+ }
748
+ interface EntityModelPart {
749
+ pose: {
750
+ offset: [number, number, number];
751
+ rotation: [number, number, number];
752
+ scale?: [number, number, number];
695
753
  };
754
+ texture?: [number, number];
755
+ cubes: EntityModelCube[];
756
+ children: Record<string, EntityModelPart>;
757
+ }
758
+ interface EntityModelCube {
759
+ origin: [number, number, number];
760
+ size: [number, number, number];
761
+ uv: [number, number];
762
+ grow?: [number, number, number];
763
+ mirror?: boolean;
696
764
  }
697
765
 
698
766
  declare class Entities {
699
- static getBlockEntityModels(): Promise<Maybe<BlockEntityModels>>;
700
- static getEntityModels(): Promise<Maybe<EntityModels>>;
701
- static getBlockList(): Promise<string[]>;
702
767
  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;
768
+ static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
769
+ static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
770
+ /** @deprecated Use getEntityList(); block entities share the entity dataset. */
771
+ static getBlockList(): Promise<string[]>;
772
+ /** @deprecated Use getEntity(); block entities share the entity dataset. */
773
+ static getBlock(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
708
774
  }
709
- declare class BlockEntityModels implements MinecraftAsset {
710
- [k: string]: any;
775
+ interface EntityModelOptions {
776
+ layer?: string;
711
777
  }
712
778
 
713
779
  declare class Models {
@@ -715,12 +781,22 @@ declare class Models {
715
781
  private static get PERSISTENT_CACHE();
716
782
  static getItemList(): Promise<string[]>;
717
783
  static loadAndMerge(key: AssetKey): Promise<Maybe<Model>>;
784
+ private static getItemModel;
785
+ private static defaultItemModel;
718
786
  static getRaw(key: AssetKey): Promise<Maybe<Model>>;
719
787
  static getMerged(key: AssetKey): Promise<Maybe<Model>>;
720
788
  static get(key: AssetKey): Promise<Maybe<Model>>;
721
789
  static clearCache(): Promise<void>;
722
790
  }
723
791
 
792
+ declare class DisplayTransforms {
793
+ /** Resolve hand fallbacks within one model, before inheriting parent display entries. */
794
+ static withHandFallbacks(display: Model["display"]): Model["display"];
795
+ /** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
796
+ static getMatrix(display: Model["display"], position: DisplayPosition): Matrix4;
797
+ static apply(geometry: BufferGeometry, matrix: Matrix4): void;
798
+ }
799
+
724
800
  declare class ModelGenerator {
725
801
  static readonly ITEM_LAYERS: string[];
726
802
  static generateItemModel(imageData: ImageData$1, layer: string): ModelElement[];
@@ -737,6 +813,12 @@ interface Block {
737
813
  nbt?: any;
738
814
  }
739
815
 
816
+ declare class BlockTints {
817
+ /** Resolves block preview colors without biome context; explicit tints take precedence. */
818
+ static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
819
+ private static grassColor;
820
+ }
821
+
740
822
  interface Instanceable {
741
823
  nextInstance(): InstanceReference<SceneObject>;
742
824
  getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
@@ -793,6 +875,12 @@ declare class ModelObject extends SceneObject {
793
875
  protected applyTextures(): void;
794
876
  }
795
877
  interface ModelObjectOptions extends SceneObjectOptions {
878
+ /** Minecraft display pose applied around the model center, before scene transforms. */
879
+ displayPosition?: DisplayPosition;
880
+ /** Quarter-turn block rotation in radians to compensate when locking UVs. */
881
+ uvLockRotation?: TripleArray;
882
+ /** sRGB 0xRRGGBB colors by face tint index; omitted indices stay white. */
883
+ tints?: Record<number, number>;
796
884
  }
797
885
  declare function isModelObject(obj: any): obj is ModelObject;
798
886
 
@@ -825,24 +913,35 @@ declare enum SkinPart {
825
913
  }
826
914
  declare const SKIN_PARTS: SkinPart[];
827
915
 
916
+ type CapeLayout = "minecraft" | "optifine" | "labymod";
917
+ declare const capeTextureSizes: Record<CapeLayout, DoubleArray>;
918
+
828
919
  declare class SkinObject extends SceneObject {
829
920
  readonly options: SkinObjectOptions;
830
921
  private slim;
831
- private legacy;
922
+ private detectedSlim;
832
923
  private skinTextureSrc?;
833
- private skinTextureWidth;
834
- private skinTextureHeight;
835
- private capeTextureSrc?;
924
+ private skinMaterial?;
925
+ private skinLoad;
926
+ private capeLoad;
836
927
  constructor(options?: DeepPartial<SkinObjectOptions>);
837
928
  init(): Promise<void>;
838
929
  protected removeMeshes(): void;
839
930
  protected createMeshes(): void;
840
- setSkinTexture(src: string): void;
841
- setSlim(slim: boolean): void;
842
- setLegacy(legacy: boolean): void;
931
+ setSkinTexture(src: string): Promise<void>;
932
+ /** Load a cape texture in the selected layout, or pass undefined to remove the cape. */
933
+ setCapeTexture(src?: string, layout?: CapeLayout): Promise<void>;
934
+ /** Select the arm model, or pass undefined to use texture detection. */
935
+ setSlim(slim?: boolean): void;
936
+ private updateSlim;
937
+ /** Select the texture layout, or pass undefined to detect it from image dimensions. */
938
+ setLegacy(legacy?: boolean): Promise<void>;
939
+ dispose(): void;
843
940
  protected getBoxGeometry(part: SkinPart): BoxGeometry;
844
941
  }
845
942
  interface SkinObjectOptions extends SceneObjectOptions {
943
+ slim?: boolean;
944
+ legacy?: boolean;
846
945
  }
847
946
 
848
947
  declare class EntityObject extends SceneObject {
@@ -855,11 +954,14 @@ declare class EntityObject extends SceneObject {
855
954
  constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
856
955
  init(): Promise<void>;
857
956
  dispose(): void;
957
+ private get textureKey();
858
958
  protected loadTextures(): Promise<void>;
859
959
  protected createMeshes(force?: boolean): void;
960
+ private createPart;
860
961
  protected applyTextures(): Promise<void>;
861
962
  }
862
963
  interface EntityObjectOptions extends SceneObjectOptions {
964
+ flip?: boolean;
863
965
  }
864
966
  declare function isEntityObject(obj: any): obj is EntityObject;
865
967
 
@@ -887,7 +989,9 @@ interface MineRenderSceneOptions {
887
989
  }
888
990
  declare function isMineRenderScene(obj: any): obj is MineRenderScene;
889
991
 
890
- declare class SceneObject extends Object3D implements Disposable, Instanceable, Transformable {
992
+ declare class SceneObject extends Object3D<Object3DEventMap & {
993
+ change: {};
994
+ }> implements Disposable, Instanceable, Transformable {
891
995
  readonly isSceneObject: true;
892
996
  static readonly DEFAULT_OPTIONS: SceneObjectOptions;
893
997
  readonly options: SceneObjectOptions;
@@ -913,9 +1017,9 @@ declare class SceneObject extends Object3D implements Disposable, Instanceable,
913
1017
  */
914
1018
  toggleGroupVisibility(name: string, visible?: boolean): boolean;
915
1019
  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;
1020
+ protected createAndAddMesh(name?: string, group?: Object3D, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
1021
+ protected createMesh(name?: string, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
1022
+ protected createInstancedMesh(name: Maybe<string>, geometry: BufferGeometry, material: Material | Material[], count: number): InstancedMesh;
919
1023
  /**
920
1024
  * Get a mesh by its name
921
1025
  */
@@ -1084,8 +1188,8 @@ interface NBTAsset extends MinecraftAsset, NBT {
1084
1188
  }
1085
1189
 
1086
1190
  interface ResponseParser<T extends MinecraftAsset> {
1087
- config(request: AxiosRequestConfig): any;
1088
- parse(response: AxiosResponse): Maybe<T> | Promise<Maybe<T>>;
1191
+ config(request: RequestConfig): any;
1192
+ parse(response: RequestResponse): Maybe<T> | Promise<Maybe<T>>;
1089
1193
  }
1090
1194
 
1091
1195
  declare class HostedAssetSource extends AssetSource {
@@ -1104,6 +1208,7 @@ declare class HostedAssetSource extends AssetSource {
1104
1208
  private readonly _options;
1105
1209
  constructor(root: string, options?: Partial<HostedAssetSourceOptions>);
1106
1210
  get root(): string;
1211
+ get cacheId(): string;
1107
1212
  get options(): HostedAssetSourceOptions;
1108
1213
  get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser): Promise<Maybe<T>>;
1109
1214
  }
@@ -1118,6 +1223,8 @@ interface ArchiveEntry {
1118
1223
  }
1119
1224
 
1120
1225
  interface ArchiveProxy {
1226
+ /** Identifies the archive's content across sessions; undefined when it cannot be identified. */
1227
+ readonly id?: string;
1121
1228
  getEntries(): Promise<ArchiveEntry[]>;
1122
1229
  }
1123
1230
 
@@ -1125,6 +1232,7 @@ declare class ArchiveAssetSource extends AssetSource implements ArchiveProxy {
1125
1232
  readonly _archiveProxy: ArchiveProxy;
1126
1233
  constructor(archiveProxy: ArchiveProxy);
1127
1234
  static blob(blob: Blob): ArchiveAssetSource;
1235
+ get cacheId(): Maybe<string>;
1128
1236
  getEntries(): Promise<ArchiveEntry[]>;
1129
1237
  getEntry(path: string): Promise<Maybe<ArchiveEntry>>;
1130
1238
  get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
@@ -1135,7 +1243,8 @@ declare class ArchiveAssetSource extends AssetSource implements ArchiveProxy {
1135
1243
  declare class BrowserArchiveProxy implements ArchiveProxy {
1136
1244
  readonly _blob: Blob;
1137
1245
  readonly _reader: ZipReader<Blob>;
1138
- constructor(blob: Blob);
1246
+ readonly id?: string;
1247
+ constructor(blob: Blob, id?: string);
1139
1248
  getEntries(): Promise<ArchiveEntry[]>;
1140
1249
  }
1141
1250
 
@@ -1213,14 +1322,20 @@ declare class Caching {
1213
1322
  static readonly mergedModelCache: AsyncLoadingCache<CacheKey, Model>;
1214
1323
  static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
1215
1324
  static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
1325
+ static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
1326
+ static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
1327
+ static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
1328
+ static readonly entityModelCache: AsyncLoadingCache<CacheKey, EntityModelFile>;
1329
+ static readonly entityTextureCache: AsyncLoadingCache<CacheKey, AssetKey>;
1330
+ private static createAssetCache;
1216
1331
  /** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
1217
1332
  private static get all();
1218
1333
  static clear(): void;
1219
1334
  /**
1220
1335
  * Clears every cache and stops its expiry timer.
1221
1336
  *
1222
- * loading-cache reschedules that timer indefinitely, so a Node process will not exit until
1223
- * this is called - see {@link shutdown}.
1337
+ * Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
1338
+ * Use {@link shutdown} to also stop requests and the shared Ticker.
1224
1339
  */
1225
1340
  static end(): void;
1226
1341
  static get cacheSizes(): {};
@@ -1320,15 +1435,14 @@ declare class Renderer implements Disposable {
1320
1435
  protected _scene: MineRenderScene;
1321
1436
  protected _camera: Camera;
1322
1437
  protected _renderer: WebGLRenderer;
1323
- protected _composer: EffectComposer;
1438
+ protected _composer?: EffectComposer;
1324
1439
  protected _controls?: OrbitControls;
1325
1440
  protected _stats?: Stats;
1326
1441
  protected _dirty: boolean;
1327
1442
  protected _animationLoop: any;
1328
- protected _fpsTimer: any;
1329
- protected _animationTimer?: NodeJS.Timeout;
1330
- protected _animationFrame?: number;
1443
+ protected _frameInterval?: number;
1331
1444
  protected _resizeListener?: () => void;
1445
+ private _nextFrameTime?;
1332
1446
  private _disposed;
1333
1447
  private readonly _debugHelpers;
1334
1448
  private readonly _eventDispatchers;
@@ -1337,7 +1451,7 @@ declare class Renderer implements Disposable {
1337
1451
  protected createScene(): MineRenderScene;
1338
1452
  protected createCamera(): Camera;
1339
1453
  protected createRenderer(): WebGLRenderer;
1340
- protected createComposer(): EffectComposer;
1454
+ protected createComposer(): Maybe<EffectComposer>;
1341
1455
  protected createControls(): Maybe<OrbitControls>;
1342
1456
  init(): void;
1343
1457
  get element(): Maybe<HTMLElement>;
@@ -1346,7 +1460,7 @@ declare class Renderer implements Disposable {
1346
1460
  * Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
1347
1461
  * The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
1348
1462
  */
1349
- registerEventDispatcher(dispatcher: EventDispatcher, changeEvent?: string): void;
1463
+ registerEventDispatcher(dispatcher: EventDispatcher<any>, changeEvent?: string): void;
1350
1464
  resize(width: number, height: number): void;
1351
1465
  get dirty(): boolean;
1352
1466
  set dirty(dirty: boolean);
@@ -1366,7 +1480,7 @@ declare class Renderer implements Disposable {
1366
1480
  get scene(): MineRenderScene;
1367
1481
  get camera(): Camera;
1368
1482
  get renderer(): WebGLRenderer;
1369
- get composer(): EffectComposer;
1483
+ get composer(): Maybe<EffectComposer>;
1370
1484
  /** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
1371
1485
  get controls(): Maybe<OrbitControls>;
1372
1486
  }
@@ -1395,6 +1509,7 @@ interface CameraOptions {
1395
1509
  lookingAt: Vector3 | TripleArray;
1396
1510
  }
1397
1511
  interface RenderOptions {
1512
+ /** Maximum draw rate (60 by default); zero or a negative value disables the limit. */
1398
1513
  fpsLimit: number;
1399
1514
  stats: boolean;
1400
1515
  antialias: boolean;
@@ -1422,7 +1537,7 @@ declare class SceneInspector {
1422
1537
  private selectedObject?;
1423
1538
  constructor(renderer: Renderer);
1424
1539
  protected init(): void;
1425
- findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry, three.Material | three.Material[]>[];
1540
+ findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[], three.Object3DEventMap>[];
1426
1541
  onClick(event: any): void;
1427
1542
  appendTo(el: HTMLElement): void;
1428
1543
  protected handleRaycasterObjects(intersections: Intersection[]): void;
@@ -1459,26 +1574,6 @@ declare class StatLine {
1459
1574
  update(): void;
1460
1575
  }
1461
1576
 
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
1577
  type SkinGeometries = Record<SkinPart, TripleArray>;
1483
1578
  declare const classicSkinGeometries: SkinGeometries;
1484
1579
  declare const slimSkinGeometries: SkinGeometries;
@@ -1487,6 +1582,19 @@ type SkinTextureCoordinates = Record<SkinPart, ModelFaces>;
1487
1582
  declare const classicSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
1488
1583
  declare const slimSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
1489
1584
 
1585
+ interface SkinTexture {
1586
+ material: MeshBasicMaterial;
1587
+ slim: boolean;
1588
+ legacy: boolean;
1589
+ }
1590
+ declare class SkinTextures {
1591
+ static get(src: string, legacy?: boolean): Promise<SkinTexture>;
1592
+ static getCape(src: string, layout?: CapeLayout): Promise<MeshBasicMaterial>;
1593
+ private static createMaterial;
1594
+ private static isSlim;
1595
+ private static normalizeLegacy;
1596
+ }
1597
+
1490
1598
  declare class Skins {
1491
1599
  static fromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
1492
1600
  static fromUuid(uuid: string): Promise<Maybe<string>>;
@@ -1495,8 +1603,11 @@ declare class Skins {
1495
1603
  static capeFromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
1496
1604
  static capeFromUuid(uuid: string): Promise<Maybe<string>>;
1497
1605
  static capeFromUsername(username: string): Promise<Maybe<string>>;
1498
- static capeFromCapesDev(uuid: string, capeType?: string): Promise<Maybe<string>>;
1606
+ /** Returns a full static cape texture for a username or UUID. */
1607
+ static capeFromCapesDev(player: string, capeType?: string): Promise<Maybe<string>>;
1499
1608
  private static usernameToUuid;
1609
+ private static usernameToUuidMcProxy;
1610
+ /** @deprecated **/
1500
1611
  private static usernameToUuidSkinProxy;
1501
1612
  private static usernameToUuidMineTools;
1502
1613
  private static getProfileFromMinetools;
@@ -1506,11 +1617,18 @@ declare class Skins {
1506
1617
  private static getCrafatarCapeUrl;
1507
1618
  private static getMcHeadsSkinUrl;
1508
1619
  private static getMineSkinPlayerSkinUrl;
1620
+ /** @deprecated **/
1509
1621
  private static getSkinProxySkinUrl;
1622
+ /** @deprecated **/
1510
1623
  private static getSkinProxyCapeUrl;
1624
+ private static getMcProxySkinUrl;
1625
+ private static getMcProxyCapeUrl;
1511
1626
  }
1512
1627
 
1513
1628
  declare class TextureLoader {
1629
+ private static readonly failedTextures;
1630
+ /** Reports whether image loading failed, so cached textures can be retried. */
1631
+ static hasFailed(texture: Texture): boolean;
1514
1632
  protected static createTexture(): Texture;
1515
1633
  static loadInBackground(src: string, format?: PixelFormat, rotation?: number): Texture;
1516
1634
  static load(src: string, format?: PixelFormat, rotation?: number): Texture;
@@ -1524,12 +1642,12 @@ declare class Textures {
1524
1642
  static getImage(key: TextureKey): Texture;
1525
1643
  }
1526
1644
 
1527
- declare function mergeBufferGeometries(geometries: BufferGeometry$1[], useGroups?: boolean): BufferGeometry$1;
1645
+ declare function mergeBufferGeometries(geometries: BufferGeometry[], useGroups?: boolean): BufferGeometry;
1528
1646
  declare function mergeBufferAttributes(attributes: BufferAttribute[]): BufferAttribute;
1529
1647
  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;
1648
+ declare function estimateBytesUsed(geometry: BufferGeometry): number;
1649
+ declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): BufferGeometry;
1650
+ declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
1533
1651
  declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
1534
1652
 
1535
1653
  interface BlockInfo {
@@ -1626,4 +1744,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
1626
1744
  forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
1627
1745
  }
1628
1746
 
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 };
1747
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, 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, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, 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 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, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, 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, 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 };