minerender 2.1.0-alpha.2 → 2.1.0-alpha.20
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 +205 -141
- package/dist/browser/index.d.ts +205 -141
- package/dist/browser/index.js +1893 -1644
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +1901 -1652
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +3679 -5020
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +204 -140
- package/dist/node/index.d.ts +204 -140
- package/dist/node/index.js +1815 -1497
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +1569 -1253
- package/dist/node/index.mjs.map +1 -1
- package/package.json +7 -9
package/README.md
CHANGED
|
@@ -22,3 +22,5 @@ renderer.start();
|
|
|
22
22
|
The package provides ESM and CommonJS entries for browsers and Node.js, plus
|
|
23
23
|
`dist/bundle.js` for the `MineRender` browser global. Node imports require the optional
|
|
24
24
|
native `canvas` dependency; headless rendering is still in development.
|
|
25
|
+
|
|
26
|
+
Requires Node.js 22+ or a browser with Fetch, `AbortSignal.any()`, and `AbortSignal.timeout()`.
|
package/dist/browser/index.d.mts
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>>;
|
|
@@ -792,6 +848,10 @@ declare class ModelObject extends SceneObject {
|
|
|
792
848
|
protected applyTextures(): void;
|
|
793
849
|
}
|
|
794
850
|
interface ModelObjectOptions extends SceneObjectOptions {
|
|
851
|
+
/** Quarter-turn block rotation in radians to compensate when locking UVs. */
|
|
852
|
+
uvLockRotation?: TripleArray;
|
|
853
|
+
/** sRGB 0xRRGGBB colors by face tint index; omitted indices stay white. */
|
|
854
|
+
tints?: Record<number, number>;
|
|
795
855
|
}
|
|
796
856
|
declare function isModelObject(obj: any): obj is ModelObject;
|
|
797
857
|
|
|
@@ -854,6 +914,7 @@ declare class EntityObject extends SceneObject {
|
|
|
854
914
|
constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
|
|
855
915
|
init(): Promise<void>;
|
|
856
916
|
dispose(): void;
|
|
917
|
+
private get textureKey();
|
|
857
918
|
protected loadTextures(): Promise<void>;
|
|
858
919
|
protected createMeshes(force?: boolean): void;
|
|
859
920
|
protected applyTextures(): Promise<void>;
|
|
@@ -886,7 +947,9 @@ interface MineRenderSceneOptions {
|
|
|
886
947
|
}
|
|
887
948
|
declare function isMineRenderScene(obj: any): obj is MineRenderScene;
|
|
888
949
|
|
|
889
|
-
declare class SceneObject extends Object3D
|
|
950
|
+
declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
951
|
+
change: {};
|
|
952
|
+
}> implements Disposable, Instanceable, Transformable {
|
|
890
953
|
readonly isSceneObject: true;
|
|
891
954
|
static readonly DEFAULT_OPTIONS: SceneObjectOptions;
|
|
892
955
|
readonly options: SceneObjectOptions;
|
|
@@ -912,9 +975,9 @@ declare class SceneObject extends Object3D implements Disposable, Instanceable,
|
|
|
912
975
|
*/
|
|
913
976
|
toggleGroupVisibility(name: string, visible?: boolean): boolean;
|
|
914
977
|
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
|
|
978
|
+
protected createAndAddMesh(name?: string, group?: Object3D, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
|
|
979
|
+
protected createMesh(name?: string, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
|
|
980
|
+
protected createInstancedMesh(name: Maybe<string>, geometry: BufferGeometry, material: Material | Material[], count: number): InstancedMesh;
|
|
918
981
|
/**
|
|
919
982
|
* Get a mesh by its name
|
|
920
983
|
*/
|
|
@@ -1083,8 +1146,8 @@ interface NBTAsset extends MinecraftAsset, NBT {
|
|
|
1083
1146
|
}
|
|
1084
1147
|
|
|
1085
1148
|
interface ResponseParser<T extends MinecraftAsset> {
|
|
1086
|
-
config(request:
|
|
1087
|
-
parse(response:
|
|
1149
|
+
config(request: RequestConfig): any;
|
|
1150
|
+
parse(response: RequestResponse): Maybe<T> | Promise<Maybe<T>>;
|
|
1088
1151
|
}
|
|
1089
1152
|
|
|
1090
1153
|
declare class HostedAssetSource extends AssetSource {
|
|
@@ -1212,14 +1275,18 @@ declare class Caching {
|
|
|
1212
1275
|
static readonly mergedModelCache: AsyncLoadingCache<CacheKey, Model>;
|
|
1213
1276
|
static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
|
|
1214
1277
|
static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
|
|
1278
|
+
static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
|
|
1279
|
+
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
1280
|
+
static readonly entityModelsCache: AsyncLoadingCache<CacheKey, EntityModels>;
|
|
1281
|
+
private static createAssetCache;
|
|
1215
1282
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1216
1283
|
private static get all();
|
|
1217
1284
|
static clear(): void;
|
|
1218
1285
|
/**
|
|
1219
1286
|
* Clears every cache and stops its expiry timer.
|
|
1220
1287
|
*
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1288
|
+
* Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
|
|
1289
|
+
* Use {@link shutdown} to also stop requests and the shared Ticker.
|
|
1223
1290
|
*/
|
|
1224
1291
|
static end(): void;
|
|
1225
1292
|
static get cacheSizes(): {};
|
|
@@ -1235,6 +1302,83 @@ declare class GuiObject extends SceneObject {
|
|
|
1235
1302
|
interface GuiObjectOptions extends SceneObjectOptions {
|
|
1236
1303
|
}
|
|
1237
1304
|
|
|
1305
|
+
declare class OrbitControls {
|
|
1306
|
+
constructor(object: Camera, domElement?: HTMLElement);
|
|
1307
|
+
|
|
1308
|
+
object: Camera;
|
|
1309
|
+
domElement: HTMLElement | HTMLDocument;
|
|
1310
|
+
|
|
1311
|
+
// API
|
|
1312
|
+
enabled: boolean;
|
|
1313
|
+
target: Vector3;
|
|
1314
|
+
|
|
1315
|
+
// deprecated
|
|
1316
|
+
center: Vector3;
|
|
1317
|
+
|
|
1318
|
+
minDistance: number;
|
|
1319
|
+
maxDistance: number;
|
|
1320
|
+
|
|
1321
|
+
minZoom: number;
|
|
1322
|
+
maxZoom: number;
|
|
1323
|
+
|
|
1324
|
+
minPolarAngle: number;
|
|
1325
|
+
maxPolarAngle: number;
|
|
1326
|
+
|
|
1327
|
+
minAzimuthAngle: number;
|
|
1328
|
+
maxAzimuthAngle: number;
|
|
1329
|
+
|
|
1330
|
+
enableDamping: boolean;
|
|
1331
|
+
dampingFactor: number;
|
|
1332
|
+
|
|
1333
|
+
enableZoom: boolean;
|
|
1334
|
+
zoomSpeed: number;
|
|
1335
|
+
|
|
1336
|
+
enableRotate: boolean;
|
|
1337
|
+
rotateSpeed: number;
|
|
1338
|
+
|
|
1339
|
+
enablePan: boolean;
|
|
1340
|
+
panSpeed: number;
|
|
1341
|
+
screenSpacePanning: boolean;
|
|
1342
|
+
keyPanSpeed: number;
|
|
1343
|
+
|
|
1344
|
+
autoRotate: boolean;
|
|
1345
|
+
autoRotateSpeed: number;
|
|
1346
|
+
|
|
1347
|
+
enableKeys: boolean;
|
|
1348
|
+
keys: { LEFT: string; UP: string; RIGHT: string; BOTTOM: string };
|
|
1349
|
+
mouseButtons: { LEFT: MOUSE; MIDDLE: MOUSE; RIGHT: MOUSE };
|
|
1350
|
+
touches: { ONE: TOUCH; TWO: TOUCH };
|
|
1351
|
+
|
|
1352
|
+
update(): boolean;
|
|
1353
|
+
|
|
1354
|
+
listenToKeyEvents(domElement: HTMLElement): void;
|
|
1355
|
+
|
|
1356
|
+
saveState(): void;
|
|
1357
|
+
|
|
1358
|
+
reset(): void;
|
|
1359
|
+
|
|
1360
|
+
dispose(): void;
|
|
1361
|
+
|
|
1362
|
+
getPolarAngle(): number;
|
|
1363
|
+
|
|
1364
|
+
getAzimuthalAngle(): number;
|
|
1365
|
+
|
|
1366
|
+
getDistance(): number;
|
|
1367
|
+
|
|
1368
|
+
// EventDispatcher mixins
|
|
1369
|
+
addEventListener(type: string, listener: (event: any) => void): void;
|
|
1370
|
+
|
|
1371
|
+
hasEventListener(type: string, listener: (event: any) => void): boolean;
|
|
1372
|
+
|
|
1373
|
+
removeEventListener(type: string, listener: (event: any) => void): void;
|
|
1374
|
+
|
|
1375
|
+
dispatchEvent(event: { type: string; target: any }): void;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
declare class MapControls extends OrbitControls {
|
|
1379
|
+
constructor(object: Camera, domElement?: HTMLElement);
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1238
1382
|
declare class Renderer implements Disposable {
|
|
1239
1383
|
static readonly DEFAULT_OPTIONS: RendererOptions;
|
|
1240
1384
|
readonly options: RendererOptions;
|
|
@@ -1242,14 +1386,14 @@ declare class Renderer implements Disposable {
|
|
|
1242
1386
|
protected _scene: MineRenderScene;
|
|
1243
1387
|
protected _camera: Camera;
|
|
1244
1388
|
protected _renderer: WebGLRenderer;
|
|
1245
|
-
protected _composer
|
|
1389
|
+
protected _composer?: EffectComposer;
|
|
1390
|
+
protected _controls?: OrbitControls;
|
|
1246
1391
|
protected _stats?: Stats;
|
|
1247
1392
|
protected _dirty: boolean;
|
|
1248
1393
|
protected _animationLoop: any;
|
|
1249
|
-
protected
|
|
1250
|
-
protected _animationTimer?: NodeJS.Timeout;
|
|
1251
|
-
protected _animationFrame?: number;
|
|
1394
|
+
protected _frameInterval?: number;
|
|
1252
1395
|
protected _resizeListener?: () => void;
|
|
1396
|
+
private _nextFrameTime?;
|
|
1253
1397
|
private _disposed;
|
|
1254
1398
|
private readonly _debugHelpers;
|
|
1255
1399
|
private readonly _eventDispatchers;
|
|
@@ -1258,7 +1402,8 @@ declare class Renderer implements Disposable {
|
|
|
1258
1402
|
protected createScene(): MineRenderScene;
|
|
1259
1403
|
protected createCamera(): Camera;
|
|
1260
1404
|
protected createRenderer(): WebGLRenderer;
|
|
1261
|
-
protected createComposer(): EffectComposer
|
|
1405
|
+
protected createComposer(): Maybe<EffectComposer>;
|
|
1406
|
+
protected createControls(): Maybe<OrbitControls>;
|
|
1262
1407
|
init(): void;
|
|
1263
1408
|
get element(): Maybe<HTMLElement>;
|
|
1264
1409
|
appendTo(element: HTMLElement): void;
|
|
@@ -1266,7 +1411,7 @@ declare class Renderer implements Disposable {
|
|
|
1266
1411
|
* Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
|
|
1267
1412
|
* The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
|
|
1268
1413
|
*/
|
|
1269
|
-
registerEventDispatcher(dispatcher: EventDispatcher
|
|
1414
|
+
registerEventDispatcher(dispatcher: EventDispatcher<any>, changeEvent?: string): void;
|
|
1270
1415
|
resize(width: number, height: number): void;
|
|
1271
1416
|
get dirty(): boolean;
|
|
1272
1417
|
set dirty(dirty: boolean);
|
|
@@ -1286,12 +1431,15 @@ declare class Renderer implements Disposable {
|
|
|
1286
1431
|
get scene(): MineRenderScene;
|
|
1287
1432
|
get camera(): Camera;
|
|
1288
1433
|
get renderer(): WebGLRenderer;
|
|
1289
|
-
get composer(): EffectComposer
|
|
1434
|
+
get composer(): Maybe<EffectComposer>;
|
|
1435
|
+
/** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
|
|
1436
|
+
get controls(): Maybe<OrbitControls>;
|
|
1290
1437
|
}
|
|
1291
1438
|
interface RendererOptions {
|
|
1292
1439
|
camera: CameraOptions;
|
|
1293
1440
|
render: RenderOptions;
|
|
1294
1441
|
composer: ComposerOptions;
|
|
1442
|
+
controls?: ControlsOptions;
|
|
1295
1443
|
debug: DebugOptions;
|
|
1296
1444
|
}
|
|
1297
1445
|
interface CameraOptions {
|
|
@@ -1312,6 +1460,7 @@ interface CameraOptions {
|
|
|
1312
1460
|
lookingAt: Vector3 | TripleArray;
|
|
1313
1461
|
}
|
|
1314
1462
|
interface RenderOptions {
|
|
1463
|
+
/** Maximum draw rate (60 by default); zero or a negative value disables the limit. */
|
|
1315
1464
|
fpsLimit: number;
|
|
1316
1465
|
stats: boolean;
|
|
1317
1466
|
antialias: boolean;
|
|
@@ -1322,6 +1471,9 @@ interface RenderOptions {
|
|
|
1322
1471
|
interface ComposerOptions {
|
|
1323
1472
|
enabled: boolean;
|
|
1324
1473
|
}
|
|
1474
|
+
interface ControlsOptions {
|
|
1475
|
+
enabled: boolean;
|
|
1476
|
+
}
|
|
1325
1477
|
interface DebugOptions {
|
|
1326
1478
|
grid: boolean;
|
|
1327
1479
|
axes: boolean;
|
|
@@ -1336,7 +1488,7 @@ declare class SceneInspector {
|
|
|
1336
1488
|
private selectedObject?;
|
|
1337
1489
|
constructor(renderer: Renderer);
|
|
1338
1490
|
protected init(): void;
|
|
1339
|
-
findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry
|
|
1491
|
+
findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[], three.Object3DEventMap>[];
|
|
1340
1492
|
onClick(event: any): void;
|
|
1341
1493
|
appendTo(el: HTMLElement): void;
|
|
1342
1494
|
protected handleRaycasterObjects(intersections: Intersection[]): void;
|
|
@@ -1373,26 +1525,6 @@ declare class StatLine {
|
|
|
1373
1525
|
update(): void;
|
|
1374
1526
|
}
|
|
1375
1527
|
|
|
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
1528
|
type SkinGeometries = Record<SkinPart, TripleArray>;
|
|
1397
1529
|
declare const classicSkinGeometries: SkinGeometries;
|
|
1398
1530
|
declare const slimSkinGeometries: SkinGeometries;
|
|
@@ -1411,6 +1543,8 @@ declare class Skins {
|
|
|
1411
1543
|
static capeFromUsername(username: string): Promise<Maybe<string>>;
|
|
1412
1544
|
static capeFromCapesDev(uuid: string, capeType?: string): Promise<Maybe<string>>;
|
|
1413
1545
|
private static usernameToUuid;
|
|
1546
|
+
private static usernameToUuidMcProxy;
|
|
1547
|
+
/** @deprecated **/
|
|
1414
1548
|
private static usernameToUuidSkinProxy;
|
|
1415
1549
|
private static usernameToUuidMineTools;
|
|
1416
1550
|
private static getProfileFromMinetools;
|
|
@@ -1420,11 +1554,18 @@ declare class Skins {
|
|
|
1420
1554
|
private static getCrafatarCapeUrl;
|
|
1421
1555
|
private static getMcHeadsSkinUrl;
|
|
1422
1556
|
private static getMineSkinPlayerSkinUrl;
|
|
1557
|
+
/** @deprecated **/
|
|
1423
1558
|
private static getSkinProxySkinUrl;
|
|
1559
|
+
/** @deprecated **/
|
|
1424
1560
|
private static getSkinProxyCapeUrl;
|
|
1561
|
+
private static getMcProxySkinUrl;
|
|
1562
|
+
private static getMcProxyCapeUrl;
|
|
1425
1563
|
}
|
|
1426
1564
|
|
|
1427
1565
|
declare class TextureLoader {
|
|
1566
|
+
private static readonly failedTextures;
|
|
1567
|
+
/** Reports whether image loading failed, so cached textures can be retried. */
|
|
1568
|
+
static hasFailed(texture: Texture): boolean;
|
|
1428
1569
|
protected static createTexture(): Texture;
|
|
1429
1570
|
static loadInBackground(src: string, format?: PixelFormat, rotation?: number): Texture;
|
|
1430
1571
|
static load(src: string, format?: PixelFormat, rotation?: number): Texture;
|
|
@@ -1438,91 +1579,14 @@ declare class Textures {
|
|
|
1438
1579
|
static getImage(key: TextureKey): Texture;
|
|
1439
1580
|
}
|
|
1440
1581
|
|
|
1441
|
-
declare function mergeBufferGeometries(geometries: BufferGeometry
|
|
1582
|
+
declare function mergeBufferGeometries(geometries: BufferGeometry[], useGroups?: boolean): BufferGeometry;
|
|
1442
1583
|
declare function mergeBufferAttributes(attributes: BufferAttribute[]): BufferAttribute;
|
|
1443
1584
|
declare function interleaveAttributes(attributes: BufferAttribute[]): InterleavedBufferAttribute;
|
|
1444
|
-
declare function estimateBytesUsed(geometry: BufferGeometry
|
|
1445
|
-
declare function mergeVertices(geometry: BufferGeometry
|
|
1446
|
-
declare function toTrianglesDrawMode(geometry: BufferGeometry
|
|
1585
|
+
declare function estimateBytesUsed(geometry: BufferGeometry): number;
|
|
1586
|
+
declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): BufferGeometry;
|
|
1587
|
+
declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
|
|
1447
1588
|
declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
|
|
1448
1589
|
|
|
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
1590
|
interface BlockInfo {
|
|
1527
1591
|
block: Block;
|
|
1528
1592
|
object: BlockObject;
|
|
@@ -1611,8 +1675,8 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
1611
1675
|
*
|
|
1612
1676
|
* `image-size` pulls in `fs`/`path` at module scope, so it can only live in the Node build.
|
|
1613
1677
|
* 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
|
|
1678
|
+
* anything else falls through to an empty result, which ImageLoader rejects.
|
|
1615
1679
|
*/
|
|
1616
1680
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
1617
1681
|
|
|
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 };
|
|
1682
|
+
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, 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 };
|