minerender 2.1.0-alpha.2 → 2.1.0-alpha.21
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.
- package/README.md +2 -0
- package/dist/browser/index.d.mts +212 -141
- package/dist/browser/index.d.ts +212 -141
- package/dist/browser/index.js +2007 -1669
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +1990 -1652
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +3789 -5036
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +211 -140
- package/dist/node/index.d.ts +211 -140
- package/dist/node/index.js +2034 -1624
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +1660 -1253
- package/dist/node/index.mjs.map +1 -1
- package/package.json +7 -9
package/dist/browser/index.d.ts
CHANGED
|
@@ -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, WebGLRenderer, EventDispatcher, Raycaster, Intersection, CanvasTexture,
|
|
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, 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
|
|
|
@@ -17,7 +14,7 @@ interface AnimatorFunction {
|
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
declare enum Axis {
|
|
20
|
-
X = "
|
|
17
|
+
X = "x",
|
|
21
18
|
Y = "y",
|
|
22
19
|
Z = "z"
|
|
23
20
|
}
|
|
@@ -62,10 +59,11 @@ declare function createCanvas(width: number, height: number): CompatCanvas;
|
|
|
62
59
|
declare abstract class PersistentCache<B = unknown> {
|
|
63
60
|
readonly backing: B;
|
|
64
61
|
/** Bump to invalidate every persisted entry. */
|
|
65
|
-
static readonly VERSION =
|
|
62
|
+
static readonly VERSION = 2;
|
|
66
63
|
static open(name: string): PersistentCache;
|
|
67
64
|
protected constructor(backing: B);
|
|
68
65
|
abstract get<T>(key: string): Promise<T>;
|
|
66
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
69
67
|
getOrLoad<T>(key: string, loader: (key: string) => Promise<T>): Promise<T>;
|
|
70
68
|
abstract put<T>(key: string, value: T): Promise<T>;
|
|
71
69
|
abstract delete<T>(key: string): Promise<void>;
|
|
@@ -175,6 +173,7 @@ declare class AssetKey extends BasicAssetKey {
|
|
|
175
173
|
rootType: "assets" | "data" | string;
|
|
176
174
|
extension: ".json" | ".png" | string;
|
|
177
175
|
root?: string | undefined;
|
|
176
|
+
readonly isAssetKey: true;
|
|
178
177
|
constructor(namespace: string, path: string, assetType?: AssetType | undefined, type?: string | undefined, rootType?: "assets" | "data" | string, extension?: ".json" | ".png" | string, root?: string | undefined);
|
|
179
178
|
static parse(assetType: AssetType, str: string, origin?: AssetKey): AssetKey;
|
|
180
179
|
toString(): string;
|
|
@@ -256,6 +255,46 @@ declare enum GuiLight {
|
|
|
256
255
|
SIDE = "side"
|
|
257
256
|
}
|
|
258
257
|
|
|
258
|
+
interface RequestConfig extends RequestInit {
|
|
259
|
+
url: string;
|
|
260
|
+
/** Prepended to relative URLs, preserving any path in the base URL. */
|
|
261
|
+
baseURL?: string;
|
|
262
|
+
/** Timeout per attempt in milliseconds, including body reading. Defaults to 5000; 0 disables it. */
|
|
263
|
+
timeout?: number;
|
|
264
|
+
responseType?: "json" | "arraybuffer";
|
|
265
|
+
}
|
|
266
|
+
interface RequestResponse<T = any> {
|
|
267
|
+
data: T;
|
|
268
|
+
status: number;
|
|
269
|
+
statusText: string;
|
|
270
|
+
headers: Headers;
|
|
271
|
+
/** Final URL after redirects. */
|
|
272
|
+
url: string;
|
|
273
|
+
}
|
|
274
|
+
declare class RequestError extends Error {
|
|
275
|
+
readonly response?: RequestResponse<undefined> | undefined;
|
|
276
|
+
readonly cause?: unknown;
|
|
277
|
+
constructor(message: string, response?: RequestResponse<undefined> | undefined, cause?: unknown);
|
|
278
|
+
}
|
|
279
|
+
declare class Requests {
|
|
280
|
+
private static genericQueue;
|
|
281
|
+
private static mcAssetRequestQueue;
|
|
282
|
+
static genericRequest(request: RequestConfig): Promise<RequestResponse>;
|
|
283
|
+
static mcAssetRequest(request: RequestConfig): Promise<RequestResponse>;
|
|
284
|
+
static setMcAssetRoot(root: string): void;
|
|
285
|
+
/** Counts unsettled calls, including retry delays and requests still running after shutdown. */
|
|
286
|
+
static get queueSizes(): {
|
|
287
|
+
generic: number;
|
|
288
|
+
mcAsset: number;
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Permanently stops both queues and rejects waiting, retrying, and future requests.
|
|
292
|
+
* Requests already running can finish. Idle queues hold no timer, so Node can exit without
|
|
293
|
+
* this cleanup. See {@link shutdown}.
|
|
294
|
+
*/
|
|
295
|
+
static end(): void;
|
|
296
|
+
}
|
|
297
|
+
|
|
259
298
|
declare class WrappedImage {
|
|
260
299
|
readonly dta: ExtractableImageData;
|
|
261
300
|
constructor(dta: ExtractableImageData);
|
|
@@ -291,7 +330,7 @@ declare class ImageLoader {
|
|
|
291
330
|
static infoToData(info: ImageInfo): Promise<ImageData>;
|
|
292
331
|
static getData(src: string): Promise<ImageData>;
|
|
293
332
|
static getCanvasData(src: string): Promise<ExtractableImageData>;
|
|
294
|
-
static processResponse(response:
|
|
333
|
+
static processResponse(response: Pick<RequestResponse<ArrayBuffer>, "data" | "url">): Promise<ImageInfo>;
|
|
295
334
|
static loadInfo(src: string): Promise<ImageInfo>;
|
|
296
335
|
static getInfo(src: string): Promise<ImageInfo>;
|
|
297
336
|
static loadWrapped(src: string): Promise<WrappedImage>;
|
|
@@ -431,7 +470,7 @@ interface Transformable {
|
|
|
431
470
|
declare function isTransformable(obj: any): obj is Transformable;
|
|
432
471
|
|
|
433
472
|
declare const changeEvent: {
|
|
434
|
-
type:
|
|
473
|
+
type: "change";
|
|
435
474
|
};
|
|
436
475
|
type Maybe<T> = T | undefined;
|
|
437
476
|
declare function md5(str: string): string;
|
|
@@ -515,6 +554,7 @@ declare class UVMapper {
|
|
|
515
554
|
static setCubeUvs(geometry: BoxGeometry, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray, faces: ModelFaces): void;
|
|
516
555
|
static facesToUvArray(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): number[];
|
|
517
556
|
static facesToUv(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): Float32BufferAttribute;
|
|
557
|
+
static lockUvs(geometry: BoxGeometry, faces: ModelFaces, atlas: TextureAtlas, rotation: Euler): void;
|
|
518
558
|
static getAtlas(model: Model): Promise<Maybe<TextureAtlas>>;
|
|
519
559
|
static fillMissingTextureKeys<T>(textures: ModelTextures, target: {
|
|
520
560
|
[k: string]: T;
|
|
@@ -536,14 +576,13 @@ declare class MinecraftFaceUV {
|
|
|
536
576
|
}
|
|
537
577
|
|
|
538
578
|
/**
|
|
539
|
-
*
|
|
579
|
+
* Stops the shared Ticker and request queues, and clears the in-memory caches.
|
|
540
580
|
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
* the library is loaded. Browsers don't care, but anything headless - a render server, a CLI, a
|
|
544
|
-
* test run - has to call this when it's done.
|
|
581
|
+
* Idle Node processes can exit without calling this: cache and Ticker timers are unref'd,
|
|
582
|
+
* and idle request queues hold no timer. Pending requests keep their normal timer references.
|
|
545
583
|
*
|
|
546
|
-
*
|
|
584
|
+
* Call this only when finished with MineRender. Queued, retrying, and future requests reject;
|
|
585
|
+
* HTTP requests already running can finish. Queue shutdown is permanent, and cache expiry timers do not restart.
|
|
547
586
|
*/
|
|
548
587
|
declare function shutdown(): void;
|
|
549
588
|
|
|
@@ -616,6 +655,14 @@ declare abstract class AssetSource {
|
|
|
616
655
|
protected constructor();
|
|
617
656
|
abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
|
|
618
657
|
}
|
|
658
|
+
/** A source failed to load or parse an asset; cause retains the original failure. */
|
|
659
|
+
declare class AssetLoadError extends Error {
|
|
660
|
+
readonly source: AssetSource;
|
|
661
|
+
readonly key: AssetKey;
|
|
662
|
+
readonly path: string;
|
|
663
|
+
readonly cause: unknown;
|
|
664
|
+
constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
|
|
665
|
+
}
|
|
619
666
|
|
|
620
667
|
declare class AssetLoader {
|
|
621
668
|
static ROOT: string;
|
|
@@ -623,7 +670,13 @@ declare class AssetLoader {
|
|
|
623
670
|
static addSource(key: string, source: AssetSource, override?: boolean): void;
|
|
624
671
|
static removeSource(key: string): Maybe<AssetSource>;
|
|
625
672
|
static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
|
|
673
|
+
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
626
674
|
static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
|
|
675
|
+
/** Tries each path within a source before considering lower-priority sources. */
|
|
676
|
+
static getFirst<T extends MinecraftAsset>(keys: readonly AssetKey[], parser: AssetParser | string): Promise<Maybe<{
|
|
677
|
+
key: AssetKey;
|
|
678
|
+
asset: T;
|
|
679
|
+
}>>;
|
|
627
680
|
}
|
|
628
681
|
|
|
629
682
|
interface BlockState extends MinecraftAsset {
|
|
@@ -638,18 +691,19 @@ interface BlockStateVariant {
|
|
|
638
691
|
y?: number;
|
|
639
692
|
x?: number;
|
|
640
693
|
uvlock?: boolean;
|
|
694
|
+
weight?: number;
|
|
641
695
|
}
|
|
642
696
|
interface BlockStateMultipart {
|
|
643
|
-
when?: MultipartCondition
|
|
644
|
-
|
|
645
|
-
};
|
|
646
|
-
apply?: BlockStateVariant;
|
|
647
|
-
}
|
|
648
|
-
interface MultipartCondition {
|
|
649
|
-
[key: string]: string;
|
|
697
|
+
when?: MultipartCondition;
|
|
698
|
+
apply?: BlockStateVariant | BlockStateVariant[];
|
|
650
699
|
}
|
|
700
|
+
type MultipartCondition = Record<string, string> | {
|
|
701
|
+
OR: MultipartCondition[];
|
|
702
|
+
} | {
|
|
703
|
+
AND: MultipartCondition[];
|
|
704
|
+
};
|
|
651
705
|
|
|
652
|
-
declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.
|
|
706
|
+
declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.21.11";
|
|
653
707
|
declare const DEFAULT_NAMESPACE = "minecraft";
|
|
654
708
|
declare class Assets {
|
|
655
709
|
/**
|
|
@@ -714,6 +768,8 @@ declare class Models {
|
|
|
714
768
|
private static get PERSISTENT_CACHE();
|
|
715
769
|
static getItemList(): Promise<string[]>;
|
|
716
770
|
static loadAndMerge(key: AssetKey): Promise<Maybe<Model>>;
|
|
771
|
+
private static getItemModel;
|
|
772
|
+
private static defaultItemModel;
|
|
717
773
|
static getRaw(key: AssetKey): Promise<Maybe<Model>>;
|
|
718
774
|
static getMerged(key: AssetKey): Promise<Maybe<Model>>;
|
|
719
775
|
static get(key: AssetKey): Promise<Maybe<Model>>;
|
|
@@ -736,6 +792,12 @@ interface Block {
|
|
|
736
792
|
nbt?: any;
|
|
737
793
|
}
|
|
738
794
|
|
|
795
|
+
declare class BlockTints {
|
|
796
|
+
/** Resolves block preview colors without biome context; explicit tints take precedence. */
|
|
797
|
+
static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
|
|
798
|
+
private static grassColor;
|
|
799
|
+
}
|
|
800
|
+
|
|
739
801
|
interface Instanceable {
|
|
740
802
|
nextInstance(): InstanceReference<SceneObject>;
|
|
741
803
|
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
@@ -792,6 +854,10 @@ declare class ModelObject extends SceneObject {
|
|
|
792
854
|
protected applyTextures(): void;
|
|
793
855
|
}
|
|
794
856
|
interface ModelObjectOptions extends SceneObjectOptions {
|
|
857
|
+
/** Quarter-turn block rotation in radians to compensate when locking UVs. */
|
|
858
|
+
uvLockRotation?: TripleArray;
|
|
859
|
+
/** sRGB 0xRRGGBB colors by face tint index; omitted indices stay white. */
|
|
860
|
+
tints?: Record<number, number>;
|
|
795
861
|
}
|
|
796
862
|
declare function isModelObject(obj: any): obj is ModelObject;
|
|
797
863
|
|
|
@@ -854,6 +920,7 @@ declare class EntityObject extends SceneObject {
|
|
|
854
920
|
constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
|
|
855
921
|
init(): Promise<void>;
|
|
856
922
|
dispose(): void;
|
|
923
|
+
private get textureKey();
|
|
857
924
|
protected loadTextures(): Promise<void>;
|
|
858
925
|
protected createMeshes(force?: boolean): void;
|
|
859
926
|
protected applyTextures(): Promise<void>;
|
|
@@ -886,7 +953,9 @@ interface MineRenderSceneOptions {
|
|
|
886
953
|
}
|
|
887
954
|
declare function isMineRenderScene(obj: any): obj is MineRenderScene;
|
|
888
955
|
|
|
889
|
-
declare class SceneObject extends Object3D
|
|
956
|
+
declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
957
|
+
change: {};
|
|
958
|
+
}> implements Disposable, Instanceable, Transformable {
|
|
890
959
|
readonly isSceneObject: true;
|
|
891
960
|
static readonly DEFAULT_OPTIONS: SceneObjectOptions;
|
|
892
961
|
readonly options: SceneObjectOptions;
|
|
@@ -912,9 +981,9 @@ declare class SceneObject extends Object3D implements Disposable, Instanceable,
|
|
|
912
981
|
*/
|
|
913
982
|
toggleGroupVisibility(name: string, visible?: boolean): boolean;
|
|
914
983
|
protected addOrReplaceMesh(mesh: Mesh, parent: Object3D, name?: string): void;
|
|
915
|
-
protected createAndAddMesh(name?: string, group?: Object3D, geometry?: BufferGeometry, material?: Material
|
|
916
|
-
protected createMesh(name?: string, geometry?: BufferGeometry, material?: Material
|
|
917
|
-
protected createInstancedMesh(name: Maybe<string>, geometry: BufferGeometry, material: Material
|
|
984
|
+
protected createAndAddMesh(name?: string, group?: Object3D, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
|
|
985
|
+
protected createMesh(name?: string, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
|
|
986
|
+
protected createInstancedMesh(name: Maybe<string>, geometry: BufferGeometry, material: Material | Material[], count: number): InstancedMesh;
|
|
918
987
|
/**
|
|
919
988
|
* Get a mesh by its name
|
|
920
989
|
*/
|
|
@@ -1083,8 +1152,8 @@ interface NBTAsset extends MinecraftAsset, NBT {
|
|
|
1083
1152
|
}
|
|
1084
1153
|
|
|
1085
1154
|
interface ResponseParser<T extends MinecraftAsset> {
|
|
1086
|
-
config(request:
|
|
1087
|
-
parse(response:
|
|
1155
|
+
config(request: RequestConfig): any;
|
|
1156
|
+
parse(response: RequestResponse): Maybe<T> | Promise<Maybe<T>>;
|
|
1088
1157
|
}
|
|
1089
1158
|
|
|
1090
1159
|
declare class HostedAssetSource extends AssetSource {
|
|
@@ -1212,14 +1281,19 @@ declare class Caching {
|
|
|
1212
1281
|
static readonly mergedModelCache: AsyncLoadingCache<CacheKey, Model>;
|
|
1213
1282
|
static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
|
|
1214
1283
|
static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
|
|
1284
|
+
static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
|
|
1285
|
+
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
1286
|
+
static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
|
|
1287
|
+
static readonly entityModelsCache: AsyncLoadingCache<CacheKey, EntityModels>;
|
|
1288
|
+
private static createAssetCache;
|
|
1215
1289
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1216
1290
|
private static get all();
|
|
1217
1291
|
static clear(): void;
|
|
1218
1292
|
/**
|
|
1219
1293
|
* Clears every cache and stops its expiry timer.
|
|
1220
1294
|
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1295
|
+
* Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
|
|
1296
|
+
* Use {@link shutdown} to also stop requests and the shared Ticker.
|
|
1223
1297
|
*/
|
|
1224
1298
|
static end(): void;
|
|
1225
1299
|
static get cacheSizes(): {};
|
|
@@ -1235,6 +1309,83 @@ declare class GuiObject extends SceneObject {
|
|
|
1235
1309
|
interface GuiObjectOptions extends SceneObjectOptions {
|
|
1236
1310
|
}
|
|
1237
1311
|
|
|
1312
|
+
declare class OrbitControls {
|
|
1313
|
+
constructor(object: Camera, domElement?: HTMLElement);
|
|
1314
|
+
|
|
1315
|
+
object: Camera;
|
|
1316
|
+
domElement: HTMLElement | HTMLDocument;
|
|
1317
|
+
|
|
1318
|
+
// API
|
|
1319
|
+
enabled: boolean;
|
|
1320
|
+
target: Vector3;
|
|
1321
|
+
|
|
1322
|
+
// deprecated
|
|
1323
|
+
center: Vector3;
|
|
1324
|
+
|
|
1325
|
+
minDistance: number;
|
|
1326
|
+
maxDistance: number;
|
|
1327
|
+
|
|
1328
|
+
minZoom: number;
|
|
1329
|
+
maxZoom: number;
|
|
1330
|
+
|
|
1331
|
+
minPolarAngle: number;
|
|
1332
|
+
maxPolarAngle: number;
|
|
1333
|
+
|
|
1334
|
+
minAzimuthAngle: number;
|
|
1335
|
+
maxAzimuthAngle: number;
|
|
1336
|
+
|
|
1337
|
+
enableDamping: boolean;
|
|
1338
|
+
dampingFactor: number;
|
|
1339
|
+
|
|
1340
|
+
enableZoom: boolean;
|
|
1341
|
+
zoomSpeed: number;
|
|
1342
|
+
|
|
1343
|
+
enableRotate: boolean;
|
|
1344
|
+
rotateSpeed: number;
|
|
1345
|
+
|
|
1346
|
+
enablePan: boolean;
|
|
1347
|
+
panSpeed: number;
|
|
1348
|
+
screenSpacePanning: boolean;
|
|
1349
|
+
keyPanSpeed: number;
|
|
1350
|
+
|
|
1351
|
+
autoRotate: boolean;
|
|
1352
|
+
autoRotateSpeed: number;
|
|
1353
|
+
|
|
1354
|
+
enableKeys: boolean;
|
|
1355
|
+
keys: { LEFT: string; UP: string; RIGHT: string; BOTTOM: string };
|
|
1356
|
+
mouseButtons: { LEFT: MOUSE; MIDDLE: MOUSE; RIGHT: MOUSE };
|
|
1357
|
+
touches: { ONE: TOUCH; TWO: TOUCH };
|
|
1358
|
+
|
|
1359
|
+
update(): boolean;
|
|
1360
|
+
|
|
1361
|
+
listenToKeyEvents(domElement: HTMLElement): void;
|
|
1362
|
+
|
|
1363
|
+
saveState(): void;
|
|
1364
|
+
|
|
1365
|
+
reset(): void;
|
|
1366
|
+
|
|
1367
|
+
dispose(): void;
|
|
1368
|
+
|
|
1369
|
+
getPolarAngle(): number;
|
|
1370
|
+
|
|
1371
|
+
getAzimuthalAngle(): number;
|
|
1372
|
+
|
|
1373
|
+
getDistance(): number;
|
|
1374
|
+
|
|
1375
|
+
// EventDispatcher mixins
|
|
1376
|
+
addEventListener(type: string, listener: (event: any) => void): void;
|
|
1377
|
+
|
|
1378
|
+
hasEventListener(type: string, listener: (event: any) => void): boolean;
|
|
1379
|
+
|
|
1380
|
+
removeEventListener(type: string, listener: (event: any) => void): void;
|
|
1381
|
+
|
|
1382
|
+
dispatchEvent(event: { type: string; target: any }): void;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
declare class MapControls extends OrbitControls {
|
|
1386
|
+
constructor(object: Camera, domElement?: HTMLElement);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1238
1389
|
declare class Renderer implements Disposable {
|
|
1239
1390
|
static readonly DEFAULT_OPTIONS: RendererOptions;
|
|
1240
1391
|
readonly options: RendererOptions;
|
|
@@ -1242,14 +1393,14 @@ declare class Renderer implements Disposable {
|
|
|
1242
1393
|
protected _scene: MineRenderScene;
|
|
1243
1394
|
protected _camera: Camera;
|
|
1244
1395
|
protected _renderer: WebGLRenderer;
|
|
1245
|
-
protected _composer
|
|
1396
|
+
protected _composer?: EffectComposer;
|
|
1397
|
+
protected _controls?: OrbitControls;
|
|
1246
1398
|
protected _stats?: Stats;
|
|
1247
1399
|
protected _dirty: boolean;
|
|
1248
1400
|
protected _animationLoop: any;
|
|
1249
|
-
protected
|
|
1250
|
-
protected _animationTimer?: NodeJS.Timeout;
|
|
1251
|
-
protected _animationFrame?: number;
|
|
1401
|
+
protected _frameInterval?: number;
|
|
1252
1402
|
protected _resizeListener?: () => void;
|
|
1403
|
+
private _nextFrameTime?;
|
|
1253
1404
|
private _disposed;
|
|
1254
1405
|
private readonly _debugHelpers;
|
|
1255
1406
|
private readonly _eventDispatchers;
|
|
@@ -1258,7 +1409,8 @@ declare class Renderer implements Disposable {
|
|
|
1258
1409
|
protected createScene(): MineRenderScene;
|
|
1259
1410
|
protected createCamera(): Camera;
|
|
1260
1411
|
protected createRenderer(): WebGLRenderer;
|
|
1261
|
-
protected createComposer(): EffectComposer
|
|
1412
|
+
protected createComposer(): Maybe<EffectComposer>;
|
|
1413
|
+
protected createControls(): Maybe<OrbitControls>;
|
|
1262
1414
|
init(): void;
|
|
1263
1415
|
get element(): Maybe<HTMLElement>;
|
|
1264
1416
|
appendTo(element: HTMLElement): void;
|
|
@@ -1266,7 +1418,7 @@ declare class Renderer implements Disposable {
|
|
|
1266
1418
|
* Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
|
|
1267
1419
|
* The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
|
|
1268
1420
|
*/
|
|
1269
|
-
registerEventDispatcher(dispatcher: EventDispatcher
|
|
1421
|
+
registerEventDispatcher(dispatcher: EventDispatcher<any>, changeEvent?: string): void;
|
|
1270
1422
|
resize(width: number, height: number): void;
|
|
1271
1423
|
get dirty(): boolean;
|
|
1272
1424
|
set dirty(dirty: boolean);
|
|
@@ -1286,12 +1438,15 @@ declare class Renderer implements Disposable {
|
|
|
1286
1438
|
get scene(): MineRenderScene;
|
|
1287
1439
|
get camera(): Camera;
|
|
1288
1440
|
get renderer(): WebGLRenderer;
|
|
1289
|
-
get composer(): EffectComposer
|
|
1441
|
+
get composer(): Maybe<EffectComposer>;
|
|
1442
|
+
/** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
|
|
1443
|
+
get controls(): Maybe<OrbitControls>;
|
|
1290
1444
|
}
|
|
1291
1445
|
interface RendererOptions {
|
|
1292
1446
|
camera: CameraOptions;
|
|
1293
1447
|
render: RenderOptions;
|
|
1294
1448
|
composer: ComposerOptions;
|
|
1449
|
+
controls?: ControlsOptions;
|
|
1295
1450
|
debug: DebugOptions;
|
|
1296
1451
|
}
|
|
1297
1452
|
interface CameraOptions {
|
|
@@ -1312,6 +1467,7 @@ interface CameraOptions {
|
|
|
1312
1467
|
lookingAt: Vector3 | TripleArray;
|
|
1313
1468
|
}
|
|
1314
1469
|
interface RenderOptions {
|
|
1470
|
+
/** Maximum draw rate (60 by default); zero or a negative value disables the limit. */
|
|
1315
1471
|
fpsLimit: number;
|
|
1316
1472
|
stats: boolean;
|
|
1317
1473
|
antialias: boolean;
|
|
@@ -1322,6 +1478,9 @@ interface RenderOptions {
|
|
|
1322
1478
|
interface ComposerOptions {
|
|
1323
1479
|
enabled: boolean;
|
|
1324
1480
|
}
|
|
1481
|
+
interface ControlsOptions {
|
|
1482
|
+
enabled: boolean;
|
|
1483
|
+
}
|
|
1325
1484
|
interface DebugOptions {
|
|
1326
1485
|
grid: boolean;
|
|
1327
1486
|
axes: boolean;
|
|
@@ -1336,7 +1495,7 @@ declare class SceneInspector {
|
|
|
1336
1495
|
private selectedObject?;
|
|
1337
1496
|
constructor(renderer: Renderer);
|
|
1338
1497
|
protected init(): void;
|
|
1339
|
-
findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry
|
|
1498
|
+
findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[], three.Object3DEventMap>[];
|
|
1340
1499
|
onClick(event: any): void;
|
|
1341
1500
|
appendTo(el: HTMLElement): void;
|
|
1342
1501
|
protected handleRaycasterObjects(intersections: Intersection[]): void;
|
|
@@ -1373,26 +1532,6 @@ declare class StatLine {
|
|
|
1373
1532
|
update(): void;
|
|
1374
1533
|
}
|
|
1375
1534
|
|
|
1376
|
-
declare class Requests {
|
|
1377
|
-
private static axiosInstance;
|
|
1378
|
-
private static mcAssetInstance;
|
|
1379
|
-
private static genericQueue;
|
|
1380
|
-
private static mcAssetRequestQueue;
|
|
1381
|
-
static genericRequest(request: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
1382
|
-
static mcAssetRequest(request: AxiosRequestConfig): Promise<AxiosResponse>;
|
|
1383
|
-
private static shouldRetry;
|
|
1384
|
-
static setMcAssetRoot(root: string): void;
|
|
1385
|
-
static get queueSizes(): {
|
|
1386
|
-
generic: number;
|
|
1387
|
-
mcAsset: number;
|
|
1388
|
-
};
|
|
1389
|
-
/**
|
|
1390
|
-
* Stops both queue timers. jobqu reschedules itself indefinitely, so a Node process will not
|
|
1391
|
-
* exit until this is called - see {@link shutdown}.
|
|
1392
|
-
*/
|
|
1393
|
-
static end(): void;
|
|
1394
|
-
}
|
|
1395
|
-
|
|
1396
1535
|
type SkinGeometries = Record<SkinPart, TripleArray>;
|
|
1397
1536
|
declare const classicSkinGeometries: SkinGeometries;
|
|
1398
1537
|
declare const slimSkinGeometries: SkinGeometries;
|
|
@@ -1411,6 +1550,8 @@ declare class Skins {
|
|
|
1411
1550
|
static capeFromUsername(username: string): Promise<Maybe<string>>;
|
|
1412
1551
|
static capeFromCapesDev(uuid: string, capeType?: string): Promise<Maybe<string>>;
|
|
1413
1552
|
private static usernameToUuid;
|
|
1553
|
+
private static usernameToUuidMcProxy;
|
|
1554
|
+
/** @deprecated **/
|
|
1414
1555
|
private static usernameToUuidSkinProxy;
|
|
1415
1556
|
private static usernameToUuidMineTools;
|
|
1416
1557
|
private static getProfileFromMinetools;
|
|
@@ -1420,11 +1561,18 @@ declare class Skins {
|
|
|
1420
1561
|
private static getCrafatarCapeUrl;
|
|
1421
1562
|
private static getMcHeadsSkinUrl;
|
|
1422
1563
|
private static getMineSkinPlayerSkinUrl;
|
|
1564
|
+
/** @deprecated **/
|
|
1423
1565
|
private static getSkinProxySkinUrl;
|
|
1566
|
+
/** @deprecated **/
|
|
1424
1567
|
private static getSkinProxyCapeUrl;
|
|
1568
|
+
private static getMcProxySkinUrl;
|
|
1569
|
+
private static getMcProxyCapeUrl;
|
|
1425
1570
|
}
|
|
1426
1571
|
|
|
1427
1572
|
declare class TextureLoader {
|
|
1573
|
+
private static readonly failedTextures;
|
|
1574
|
+
/** Reports whether image loading failed, so cached textures can be retried. */
|
|
1575
|
+
static hasFailed(texture: Texture): boolean;
|
|
1428
1576
|
protected static createTexture(): Texture;
|
|
1429
1577
|
static loadInBackground(src: string, format?: PixelFormat, rotation?: number): Texture;
|
|
1430
1578
|
static load(src: string, format?: PixelFormat, rotation?: number): Texture;
|
|
@@ -1438,91 +1586,14 @@ declare class Textures {
|
|
|
1438
1586
|
static getImage(key: TextureKey): Texture;
|
|
1439
1587
|
}
|
|
1440
1588
|
|
|
1441
|
-
declare function mergeBufferGeometries(geometries: BufferGeometry
|
|
1589
|
+
declare function mergeBufferGeometries(geometries: BufferGeometry[], useGroups?: boolean): BufferGeometry;
|
|
1442
1590
|
declare function mergeBufferAttributes(attributes: BufferAttribute[]): BufferAttribute;
|
|
1443
1591
|
declare function interleaveAttributes(attributes: BufferAttribute[]): InterleavedBufferAttribute;
|
|
1444
|
-
declare function estimateBytesUsed(geometry: BufferGeometry
|
|
1445
|
-
declare function mergeVertices(geometry: BufferGeometry
|
|
1446
|
-
declare function toTrianglesDrawMode(geometry: BufferGeometry
|
|
1592
|
+
declare function estimateBytesUsed(geometry: BufferGeometry): number;
|
|
1593
|
+
declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): BufferGeometry;
|
|
1594
|
+
declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
|
|
1447
1595
|
declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
|
|
1448
1596
|
|
|
1449
|
-
declare class OrbitControls {
|
|
1450
|
-
constructor(object: Camera, domElement?: HTMLElement);
|
|
1451
|
-
|
|
1452
|
-
object: Camera;
|
|
1453
|
-
domElement: HTMLElement | HTMLDocument;
|
|
1454
|
-
|
|
1455
|
-
// API
|
|
1456
|
-
enabled: boolean;
|
|
1457
|
-
target: Vector3;
|
|
1458
|
-
|
|
1459
|
-
// deprecated
|
|
1460
|
-
center: Vector3;
|
|
1461
|
-
|
|
1462
|
-
minDistance: number;
|
|
1463
|
-
maxDistance: number;
|
|
1464
|
-
|
|
1465
|
-
minZoom: number;
|
|
1466
|
-
maxZoom: number;
|
|
1467
|
-
|
|
1468
|
-
minPolarAngle: number;
|
|
1469
|
-
maxPolarAngle: number;
|
|
1470
|
-
|
|
1471
|
-
minAzimuthAngle: number;
|
|
1472
|
-
maxAzimuthAngle: number;
|
|
1473
|
-
|
|
1474
|
-
enableDamping: boolean;
|
|
1475
|
-
dampingFactor: number;
|
|
1476
|
-
|
|
1477
|
-
enableZoom: boolean;
|
|
1478
|
-
zoomSpeed: number;
|
|
1479
|
-
|
|
1480
|
-
enableRotate: boolean;
|
|
1481
|
-
rotateSpeed: number;
|
|
1482
|
-
|
|
1483
|
-
enablePan: boolean;
|
|
1484
|
-
panSpeed: number;
|
|
1485
|
-
screenSpacePanning: boolean;
|
|
1486
|
-
keyPanSpeed: number;
|
|
1487
|
-
|
|
1488
|
-
autoRotate: boolean;
|
|
1489
|
-
autoRotateSpeed: number;
|
|
1490
|
-
|
|
1491
|
-
enableKeys: boolean;
|
|
1492
|
-
keys: { LEFT: string; UP: string; RIGHT: string; BOTTOM: string };
|
|
1493
|
-
mouseButtons: { LEFT: MOUSE; MIDDLE: MOUSE; RIGHT: MOUSE };
|
|
1494
|
-
touches: { ONE: TOUCH; TWO: TOUCH };
|
|
1495
|
-
|
|
1496
|
-
update(): boolean;
|
|
1497
|
-
|
|
1498
|
-
listenToKeyEvents(domElement: HTMLElement): void;
|
|
1499
|
-
|
|
1500
|
-
saveState(): void;
|
|
1501
|
-
|
|
1502
|
-
reset(): void;
|
|
1503
|
-
|
|
1504
|
-
dispose(): void;
|
|
1505
|
-
|
|
1506
|
-
getPolarAngle(): number;
|
|
1507
|
-
|
|
1508
|
-
getAzimuthalAngle(): number;
|
|
1509
|
-
|
|
1510
|
-
getDistance(): number;
|
|
1511
|
-
|
|
1512
|
-
// EventDispatcher mixins
|
|
1513
|
-
addEventListener(type: string, listener: (event: any) => void): void;
|
|
1514
|
-
|
|
1515
|
-
hasEventListener(type: string, listener: (event: any) => void): boolean;
|
|
1516
|
-
|
|
1517
|
-
removeEventListener(type: string, listener: (event: any) => void): void;
|
|
1518
|
-
|
|
1519
|
-
dispatchEvent(event: { type: string; target: any }): void;
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
declare class MapControls extends OrbitControls {
|
|
1523
|
-
constructor(object: Camera, domElement?: HTMLElement);
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
1597
|
interface BlockInfo {
|
|
1527
1598
|
block: Block;
|
|
1528
1599
|
object: BlockObject;
|
|
@@ -1611,8 +1682,8 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
1611
1682
|
*
|
|
1612
1683
|
* `image-size` pulls in `fs`/`path` at module scope, so it can only live in the Node build.
|
|
1613
1684
|
* Everything MineRender loads is a PNG in practice; GIF and JPEG are handled as a courtesy and
|
|
1614
|
-
* anything else falls through to an empty result
|
|
1685
|
+
* anything else falls through to an empty result, which ImageLoader rejects.
|
|
1615
1686
|
*/
|
|
1616
1687
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
1617
1688
|
|
|
1618
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, BlockEntityModels, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, type BlockStateVariant, type BlockStateVariants, BlockStates, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type Cube, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityModel, EntityModels, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, type ModelPart, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, Requests, type ResponseParser, SKIN_PARTS, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, type Serializable, type SkinGeometries, SkinObject, type SkinObjectOptions, SkinPart, type SkinTextureCoordinates, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, applyModelPartRotation, axisToVec3, base64decode, base64encode, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|
|
1689
|
+
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, 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, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, type CacheKey, Caching, type CameraOptions, CanvasImage, Chunk, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, type Cube, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityModel, EntityModels, EntityObject, type EntityObjectOptions, Env, type EnvProvider, type ExtractableImageData, type FromTo, Geometries, GuiLight, GuiObject, type GuiObjectOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, type ModelPart, ModelTextures, Models, type MultiBlockBlock, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererOptions, 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 SkinTextureCoordinates, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, applyModelPartRotation, axisToVec3, base64decode, base64encode, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createImage, estimateBytesUsed, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode };
|