minerender 2.1.0-alpha.6 → 2.1.0-alpha.61
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 +5 -3
- package/dist/browser/index.d.mts +936 -162
- package/dist/browser/index.d.ts +936 -162
- package/dist/browser/index.js +12169 -4454
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +11544 -3782
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +83050 -73721
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +935 -161
- package/dist/node/index.d.ts +935 -161
- package/dist/node/index.js +12208 -4390
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +11713 -3877
- package/dist/node/index.mjs.map +1 -1
- package/package.json +10 -9
package/dist/browser/index.d.mts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import * as three 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, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
|
|
2
|
+
import { Vector3, PixelFormat, BoxGeometry, Material, ColorRepresentation, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, Texture, Camera, MOUSE, TOUCH, WebGLRenderer, EventDispatcher, Raycaster, Intersection, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points, Group } from 'three';
|
|
3
3
|
import * as nodeCanvas from 'canvas';
|
|
4
4
|
import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { NBT } from 'prismarine-nbt';
|
|
5
|
+
import { Buffer } from 'buffer';
|
|
6
|
+
import { NBT, NBTFormat, Metadata } from 'prismarine-nbt';
|
|
8
7
|
import { ZipReader } from '@zip.js/zip.js';
|
|
9
8
|
import { AsyncLoadingCache, SimpleCache } from '@inventivetalent/loading-cache';
|
|
9
|
+
import { PLYExporterOptions } from 'three/examples/jsm/exporters/PLYExporter.js';
|
|
10
|
+
export { PLYExporterOptions } from 'three/examples/jsm/exporters/PLYExporter.js';
|
|
10
11
|
import Stats from 'stats.js';
|
|
11
12
|
import { EffectComposer } from 'postprocessing';
|
|
12
13
|
|
|
13
14
|
interface AnimatorFunction {
|
|
14
|
-
(): void;
|
|
15
|
+
(): boolean | void;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
declare enum Axis {
|
|
18
|
-
X = "
|
|
19
|
+
X = "x",
|
|
19
20
|
Y = "y",
|
|
20
21
|
Z = "z"
|
|
21
22
|
}
|
|
@@ -39,6 +40,7 @@ declare enum CubeFaceIndex {
|
|
|
39
40
|
NORTH = 5
|
|
40
41
|
}
|
|
41
42
|
declare const CUBE_FACES: CubeFace[];
|
|
43
|
+
declare const CUBE_FACE_OFFSETS: readonly [readonly [1, 0, 0], readonly [-1, 0, 0], readonly [0, 1, 0], readonly [0, -1, 0], readonly [0, 0, 1], readonly [0, 0, -1]];
|
|
42
44
|
|
|
43
45
|
interface Disposable {
|
|
44
46
|
dispose(): void;
|
|
@@ -64,6 +66,7 @@ declare abstract class PersistentCache<B = unknown> {
|
|
|
64
66
|
static open(name: string): PersistentCache;
|
|
65
67
|
protected constructor(backing: B);
|
|
66
68
|
abstract get<T>(key: string): Promise<T>;
|
|
69
|
+
/** Loads a missing entry and stores only non-nullish results. */
|
|
67
70
|
getOrLoad<T>(key: string, loader: (key: string) => Promise<T>): Promise<T>;
|
|
68
71
|
abstract put<T>(key: string, value: T): Promise<T>;
|
|
69
72
|
abstract delete<T>(key: string): Promise<void>;
|
|
@@ -173,6 +176,7 @@ declare class AssetKey extends BasicAssetKey {
|
|
|
173
176
|
rootType: "assets" | "data" | string;
|
|
174
177
|
extension: ".json" | ".png" | string;
|
|
175
178
|
root?: string | undefined;
|
|
179
|
+
readonly isAssetKey: true;
|
|
176
180
|
constructor(namespace: string, path: string, assetType?: AssetType | undefined, type?: string | undefined, rootType?: "assets" | "data" | string, extension?: ".json" | ".png" | string, root?: string | undefined);
|
|
177
181
|
static parse(assetType: AssetType, str: string, origin?: AssetKey): AssetKey;
|
|
178
182
|
toString(): string;
|
|
@@ -195,11 +199,99 @@ interface ListAsset extends MinecraftAsset {
|
|
|
195
199
|
files: string[];
|
|
196
200
|
}
|
|
197
201
|
|
|
202
|
+
interface EntityLayer {
|
|
203
|
+
key: BasicAssetKey;
|
|
204
|
+
texture?: AssetKey;
|
|
205
|
+
layer: EntityModelLayer;
|
|
206
|
+
/** How this draw is rendered; defaults to the geometry layer's own mode, then `cutout`. */
|
|
207
|
+
render?: EntityRenderMode;
|
|
208
|
+
/** Label of the state colour that multiplies the texture, from the pass that selected this draw. */
|
|
209
|
+
tint?: string;
|
|
210
|
+
}
|
|
211
|
+
interface EntityModel extends EntityLayer {
|
|
212
|
+
id: string;
|
|
213
|
+
/** Root transform from the dataset; see {@link EntityTransformOp}. */
|
|
214
|
+
transform?: EntityTransformOp[];
|
|
215
|
+
/**
|
|
216
|
+
* Selected draws in draw order; the top-level fields describe the first selection.
|
|
217
|
+
* A key is the geometry layer's name; a further draw of the same geometry (a pass with another texture) is keyed `<layer>#<n>`, from 2.
|
|
218
|
+
*/
|
|
219
|
+
layers?: Record<string, EntityLayer>;
|
|
220
|
+
}
|
|
221
|
+
interface EntityModelFile extends MinecraftAsset {
|
|
222
|
+
id: string;
|
|
223
|
+
transform?: EntityTransformOp[];
|
|
224
|
+
layers: Record<string, EntityModelLayer>;
|
|
225
|
+
/** Extra draws vanilla adds on top of `main`, in draw order. */
|
|
226
|
+
passes?: EntityModelPass[];
|
|
227
|
+
}
|
|
228
|
+
/** Vanilla render type of a draw; see the dataset README for the mode table. */
|
|
229
|
+
type EntityRenderMode = "cutout" | "cutout_cull" | "cutout_z_offset" | "solid" | "translucent" | "translucent_emissive" | "eyes" | "energy_swirl" | "breeze_wind" | "water_mask";
|
|
230
|
+
interface EntityModelPass {
|
|
231
|
+
/** Geometry layer of the same file; a pass on `main` draws that geometry again. */
|
|
232
|
+
layer: string;
|
|
233
|
+
/** Present only when it differs from the layer's own. */
|
|
234
|
+
textureLocation?: string;
|
|
235
|
+
/** Present only when it differs from the layer's own. */
|
|
236
|
+
render?: EntityRenderMode;
|
|
237
|
+
/** Entity state that enables the draw, e.g. `powered`; without it the pass is always drawn. */
|
|
238
|
+
when?: string;
|
|
239
|
+
/** State colour that multiplies the texture, e.g. `wool_color`. */
|
|
240
|
+
tint?: string;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* One operation vanilla's renderer applies before drawing a model, in call order:
|
|
244
|
+
* each one is applied on top of the previous, so the last reaches the vertices first.
|
|
245
|
+
* Translations use model units and rotations use radians, like part poses.
|
|
246
|
+
*/
|
|
247
|
+
type EntityTransformOp = {
|
|
248
|
+
scale: [number, number, number];
|
|
249
|
+
} | {
|
|
250
|
+
translate: [number, number, number];
|
|
251
|
+
} | {
|
|
252
|
+
rotate: [number, number, number];
|
|
253
|
+
};
|
|
254
|
+
interface EntityModelLayer {
|
|
255
|
+
texture: [number, number];
|
|
256
|
+
textureLocation?: string;
|
|
257
|
+
/** Omitted for `cutout`. */
|
|
258
|
+
render?: EntityRenderMode;
|
|
259
|
+
root: EntityModelPart;
|
|
260
|
+
}
|
|
261
|
+
interface EntityModelPart {
|
|
262
|
+
pose: {
|
|
263
|
+
offset: [number, number, number];
|
|
264
|
+
rotation: [number, number, number];
|
|
265
|
+
scale?: [number, number, number];
|
|
266
|
+
};
|
|
267
|
+
texture?: [number, number];
|
|
268
|
+
cubes: EntityModelCube[];
|
|
269
|
+
children: Record<string, EntityModelPart>;
|
|
270
|
+
}
|
|
271
|
+
interface EntityModelCube {
|
|
272
|
+
origin: [number, number, number];
|
|
273
|
+
size: [number, number, number];
|
|
274
|
+
uv: [number, number];
|
|
275
|
+
grow?: [number, number, number];
|
|
276
|
+
mirror?: boolean;
|
|
277
|
+
}
|
|
278
|
+
|
|
198
279
|
declare class Materials {
|
|
199
280
|
private static readonly MISSING_TEXTURE_SRC;
|
|
200
281
|
static get MISSING_TEXTURE(): Material;
|
|
201
282
|
static createImage(key: MaterialKey): Material;
|
|
202
283
|
static createBasicCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
|
|
284
|
+
/** Whether vanilla's render type for the mode culls back faces. */
|
|
285
|
+
static entityModeCulls(mode?: EntityRenderMode): boolean;
|
|
286
|
+
/** UV offset per tick of entity age for the scrolling modes, as vanilla's texture matrix applies it. */
|
|
287
|
+
static entityModeScroll(mode?: EntityRenderMode): [number, number] | undefined;
|
|
288
|
+
/**
|
|
289
|
+
* Entity material for one of vanilla's render types. Entities are unlit here, so the lit and full-bright modes
|
|
290
|
+
* differ only in blending and depth state. Culling is not a material property: {@link entityModeCulls} decides
|
|
291
|
+
* whether the geometry gets inward faces.
|
|
292
|
+
*/
|
|
293
|
+
static createEntityCanvasMaterial(canvas: HTMLCanvasElement, mode?: EntityRenderMode, tint?: ColorRepresentation): MeshBasicMaterial;
|
|
294
|
+
static createGuiCanvasMaterial(canvas: HTMLCanvasElement): MeshBasicMaterial;
|
|
203
295
|
static createShadedCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
|
|
204
296
|
static getImage(key: MaterialKey): Material;
|
|
205
297
|
static needsUpdate(mat: Material): void;
|
|
@@ -245,7 +337,8 @@ declare enum DisplayPosition {
|
|
|
245
337
|
GUI = "gui",
|
|
246
338
|
HEAD = "head",
|
|
247
339
|
GROUND = "ground",
|
|
248
|
-
FIXED = "fixed"
|
|
340
|
+
FIXED = "fixed",
|
|
341
|
+
ON_SHELF = "on_shelf"
|
|
249
342
|
}
|
|
250
343
|
declare const DISPLAY_POSITIONS: DisplayPosition[];
|
|
251
344
|
|
|
@@ -254,6 +347,46 @@ declare enum GuiLight {
|
|
|
254
347
|
SIDE = "side"
|
|
255
348
|
}
|
|
256
349
|
|
|
350
|
+
interface RequestConfig extends RequestInit {
|
|
351
|
+
url: string;
|
|
352
|
+
/** Prepended to relative URLs, preserving any path in the base URL. */
|
|
353
|
+
baseURL?: string;
|
|
354
|
+
/** Timeout per attempt in milliseconds, including body reading. Defaults to 5000; 0 disables it. */
|
|
355
|
+
timeout?: number;
|
|
356
|
+
responseType?: "json" | "arraybuffer";
|
|
357
|
+
}
|
|
358
|
+
interface RequestResponse<T = any> {
|
|
359
|
+
data: T;
|
|
360
|
+
status: number;
|
|
361
|
+
statusText: string;
|
|
362
|
+
headers: Headers;
|
|
363
|
+
/** Final URL after redirects. */
|
|
364
|
+
url: string;
|
|
365
|
+
}
|
|
366
|
+
declare class RequestError extends Error {
|
|
367
|
+
readonly response?: RequestResponse<undefined> | undefined;
|
|
368
|
+
readonly cause?: unknown;
|
|
369
|
+
constructor(message: string, response?: RequestResponse<undefined> | undefined, cause?: unknown);
|
|
370
|
+
}
|
|
371
|
+
declare class Requests {
|
|
372
|
+
private static genericQueue;
|
|
373
|
+
private static mcAssetRequestQueue;
|
|
374
|
+
static genericRequest(request: RequestConfig): Promise<RequestResponse>;
|
|
375
|
+
static mcAssetRequest(request: RequestConfig): Promise<RequestResponse>;
|
|
376
|
+
static setMcAssetRoot(root: string): void;
|
|
377
|
+
/** Counts unsettled calls, including retry delays and requests still running after shutdown. */
|
|
378
|
+
static get queueSizes(): {
|
|
379
|
+
generic: number;
|
|
380
|
+
mcAsset: number;
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
383
|
+
* Permanently stops both queues and rejects waiting, retrying, and future requests.
|
|
384
|
+
* Requests already running can finish. Idle queues hold no timer, so Node can exit without
|
|
385
|
+
* this cleanup. See {@link shutdown}.
|
|
386
|
+
*/
|
|
387
|
+
static end(): void;
|
|
388
|
+
}
|
|
389
|
+
|
|
257
390
|
declare class WrappedImage {
|
|
258
391
|
readonly dta: ExtractableImageData;
|
|
259
392
|
constructor(dta: ExtractableImageData);
|
|
@@ -277,7 +410,7 @@ interface ImageInfo {
|
|
|
277
410
|
width: number;
|
|
278
411
|
height: number;
|
|
279
412
|
type?: string;
|
|
280
|
-
data: Buffer
|
|
413
|
+
data: Buffer;
|
|
281
414
|
}
|
|
282
415
|
declare class ImageLoader {
|
|
283
416
|
protected static _createImage(): CompatImage;
|
|
@@ -289,7 +422,7 @@ declare class ImageLoader {
|
|
|
289
422
|
static infoToData(info: ImageInfo): Promise<ImageData>;
|
|
290
423
|
static getData(src: string): Promise<ImageData>;
|
|
291
424
|
static getCanvasData(src: string): Promise<ExtractableImageData>;
|
|
292
|
-
static processResponse(response:
|
|
425
|
+
static processResponse(response: Pick<RequestResponse<ArrayBuffer>, "data" | "url">): Promise<ImageInfo>;
|
|
293
426
|
static loadInfo(src: string): Promise<ImageInfo>;
|
|
294
427
|
static getInfo(src: string): Promise<ImageInfo>;
|
|
295
428
|
static loadWrapped(src: string): Promise<WrappedImage>;
|
|
@@ -303,7 +436,7 @@ declare const DEFAULT_ELEMENTS: ModelElement[];
|
|
|
303
436
|
interface Model extends MinecraftAsset {
|
|
304
437
|
textures?: IModelTextures;
|
|
305
438
|
parent?: string;
|
|
306
|
-
display?: ModelDisplay
|
|
439
|
+
display?: Partial<Record<DisplayPosition, ModelDisplay>>;
|
|
307
440
|
elements?: ModelElement[];
|
|
308
441
|
hierarchy?: string[];
|
|
309
442
|
}
|
|
@@ -314,11 +447,41 @@ interface BlockModel extends Model {
|
|
|
314
447
|
interface ItemModel extends Model {
|
|
315
448
|
textures?: ItemModelTextures;
|
|
316
449
|
gui_light?: GuiLight;
|
|
317
|
-
|
|
450
|
+
special?: SpecialItemRenderer;
|
|
451
|
+
tints?: ItemTintSource[];
|
|
452
|
+
}
|
|
453
|
+
type ItemTintColor = number | TripleArray;
|
|
454
|
+
type ItemTintSource = {
|
|
455
|
+
type: "constant" | "minecraft:constant";
|
|
456
|
+
value: ItemTintColor;
|
|
457
|
+
} | {
|
|
458
|
+
type: "grass" | "minecraft:grass";
|
|
459
|
+
temperature: number;
|
|
460
|
+
downfall: number;
|
|
461
|
+
} | {
|
|
462
|
+
type: "dye" | "minecraft:dye" | "potion" | "minecraft:potion" | "map_color" | "minecraft:map_color" | "firework" | "minecraft:firework" | "team" | "minecraft:team";
|
|
463
|
+
default: ItemTintColor;
|
|
464
|
+
} | {
|
|
465
|
+
type: "custom_model_data" | "minecraft:custom_model_data";
|
|
466
|
+
index?: number;
|
|
467
|
+
default: ItemTintColor;
|
|
468
|
+
};
|
|
469
|
+
type SpecialItemRenderer = {
|
|
470
|
+
type: "chest" | "minecraft:chest";
|
|
471
|
+
texture: string;
|
|
472
|
+
openness?: number;
|
|
473
|
+
} | {
|
|
474
|
+
type: "bed" | "minecraft:bed";
|
|
475
|
+
texture: string;
|
|
476
|
+
} | {
|
|
477
|
+
type: "head" | "minecraft:head";
|
|
478
|
+
kind: string;
|
|
479
|
+
texture?: string;
|
|
480
|
+
animation?: number;
|
|
481
|
+
};
|
|
318
482
|
interface TextureAsset extends MinecraftAsset, ImageInfo {
|
|
319
483
|
}
|
|
320
484
|
interface ModelDisplay {
|
|
321
|
-
position?: DisplayPosition;
|
|
322
485
|
translation?: TripleArray;
|
|
323
486
|
rotation?: TripleArray;
|
|
324
487
|
scale?: TripleArray;
|
|
@@ -338,13 +501,7 @@ declare function isDoubleArray(obj: any): obj is DoubleArray;
|
|
|
338
501
|
declare function isTripleArray(obj: any): obj is TripleArray;
|
|
339
502
|
declare function isQuadArray(obj: any): obj is QuadArray;
|
|
340
503
|
|
|
341
|
-
/**
|
|
342
|
-
* down up
|
|
343
|
-
* east north west south
|
|
344
|
-
*
|
|
345
|
-
* bottom-left to top-right
|
|
346
|
-
* [bl, br, tl, tr]
|
|
347
|
-
*/
|
|
504
|
+
/** Vanilla Minecraft cube UVs in Three.js BoxGeometry face and vertex order. */
|
|
348
505
|
declare class MinecraftCubeTexture {
|
|
349
506
|
readonly u: number;
|
|
350
507
|
readonly v: number;
|
|
@@ -360,7 +517,7 @@ declare class MinecraftCubeTexture {
|
|
|
360
517
|
getUvSouth(w: number, h: number, l: number): QuadArray<DoubleArray>;
|
|
361
518
|
getUvNorth(w: number, h: number, l: number): QuadArray<DoubleArray>;
|
|
362
519
|
getFaceUv(face: CubeFace, w: number, h: number, l: number): QuadArray<DoubleArray>;
|
|
363
|
-
toUvArray(w: number, h: number, l: number): number[];
|
|
520
|
+
toUvArray(w: number, h: number, l: number, mirror?: boolean): number[];
|
|
364
521
|
}
|
|
365
522
|
|
|
366
523
|
interface MinecraftTextureMeta extends MinecraftAsset {
|
|
@@ -488,6 +645,7 @@ declare class TextureAtlas implements Disposable {
|
|
|
488
645
|
};
|
|
489
646
|
readonly hasTransparency: boolean;
|
|
490
647
|
ticker?: number;
|
|
648
|
+
private readonly subscribers;
|
|
491
649
|
constructor(model: Model, image: CanvasImage, sizes: {
|
|
492
650
|
[texture: string]: DoubleArray;
|
|
493
651
|
}, positions: {
|
|
@@ -495,6 +653,8 @@ declare class TextureAtlas implements Disposable {
|
|
|
495
653
|
}, hasAnimation: boolean, animatorFunctions: {
|
|
496
654
|
[p: string]: AnimatorFunction;
|
|
497
655
|
}, hasTransparency: boolean);
|
|
656
|
+
/** Calls subscribers when an animation frame changes; unused atlases do not tick. */
|
|
657
|
+
subscribe(callback: () => void): () => void;
|
|
498
658
|
getData(texture: string): ImageData$1;
|
|
499
659
|
dispose(): void;
|
|
500
660
|
}
|
|
@@ -513,6 +673,7 @@ declare class UVMapper {
|
|
|
513
673
|
static setCubeUvs(geometry: BoxGeometry, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray, faces: ModelFaces): void;
|
|
514
674
|
static facesToUvArray(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): number[];
|
|
515
675
|
static facesToUv(faces: ModelFaces, originalTextureSize: DoubleArray, actualTextureSize: DoubleArray): Float32BufferAttribute;
|
|
676
|
+
static lockUvs(geometry: BoxGeometry, faces: ModelFaces, atlas: TextureAtlas, rotation: Euler): void;
|
|
516
677
|
static getAtlas(model: Model): Promise<Maybe<TextureAtlas>>;
|
|
517
678
|
static fillMissingTextureKeys<T>(textures: ModelTextures, target: {
|
|
518
679
|
[k: string]: T;
|
|
@@ -534,14 +695,13 @@ declare class MinecraftFaceUV {
|
|
|
534
695
|
}
|
|
535
696
|
|
|
536
697
|
/**
|
|
537
|
-
*
|
|
698
|
+
* Stops the shared Ticker and request queues, and clears the in-memory caches.
|
|
538
699
|
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
* the library is loaded. Browsers don't care, but anything headless - a render server, a CLI, a
|
|
542
|
-
* test run - has to call this when it's done.
|
|
700
|
+
* Idle Node processes can exit without calling this: cache and Ticker timers are unref'd,
|
|
701
|
+
* and idle request queues hold no timer. Pending requests keep their normal timer references.
|
|
543
702
|
*
|
|
544
|
-
*
|
|
703
|
+
* Call this only when finished with MineRender. Queued, retrying, and future requests reject;
|
|
704
|
+
* HTTP requests already running can finish. Queue shutdown is permanent, and cache expiry timers do not restart.
|
|
545
705
|
*/
|
|
546
706
|
declare function shutdown(): void;
|
|
547
707
|
|
|
@@ -549,46 +709,19 @@ declare class BatchedExecutor {
|
|
|
549
709
|
readonly interval: number;
|
|
550
710
|
readonly batch: number;
|
|
551
711
|
private readonly queue;
|
|
552
|
-
private readonly task;
|
|
553
712
|
constructor(interval?: number, batch?: number);
|
|
554
|
-
submit(task: Task):
|
|
555
|
-
|
|
556
|
-
private runNext;
|
|
713
|
+
submit<T>(task: Task<T>): Promise<T>;
|
|
714
|
+
stop(): void;
|
|
557
715
|
}
|
|
558
|
-
type Task = () =>
|
|
716
|
+
type Task<T = unknown> = () => T | Promise<T>;
|
|
559
717
|
|
|
560
718
|
declare function prefix(prefix?: string): string;
|
|
561
719
|
|
|
562
|
-
interface ModelPart {
|
|
563
|
-
textureWidth: number;
|
|
564
|
-
textureHeight: number;
|
|
565
|
-
textureOffsetU: number;
|
|
566
|
-
textureOffsetV: number;
|
|
567
|
-
pivotX: number;
|
|
568
|
-
pivotY: number;
|
|
569
|
-
pivotZ: number;
|
|
570
|
-
pitch: number;
|
|
571
|
-
yaw: number;
|
|
572
|
-
roll: number;
|
|
573
|
-
mirror: boolean;
|
|
574
|
-
cubes: Cube[];
|
|
575
|
-
children: ModelPart[];
|
|
576
|
-
}
|
|
577
|
-
interface Cube {
|
|
578
|
-
minX: number;
|
|
579
|
-
minY: number;
|
|
580
|
-
minZ: number;
|
|
581
|
-
maxX: number;
|
|
582
|
-
maxY: number;
|
|
583
|
-
maxZ: number;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
720
|
declare function applyElementRotation(rotation: ElementRotation, geometry: BufferGeometry): void;
|
|
587
|
-
declare function applyModelPartRotation(modelPart: ModelPart, geometry: BufferGeometry): void;
|
|
588
721
|
declare function applyGenericRotation(axis: Axis, rotation: number, obj: Object3D): void;
|
|
589
722
|
declare function addBox3WireframeToObject(box: Box3, obj: Object3D, color?: number, w?: number): void;
|
|
590
723
|
declare function addWireframeToObject(obj: Object3D, color?: number, w?: number): void;
|
|
591
|
-
declare function addWireframeToMesh(geo: BufferGeometry, mesh: Mesh, color?: number, w?: number): void;
|
|
724
|
+
declare function addWireframeToMesh(geo: BufferGeometry, mesh: Mesh, color?: number, w?: number): () => void;
|
|
592
725
|
|
|
593
726
|
declare function captureException(e: any, ...extra: any[]): void;
|
|
594
727
|
declare function timingStart(marker: string): void;
|
|
@@ -613,16 +746,47 @@ declare enum AssetParser {
|
|
|
613
746
|
declare abstract class AssetSource {
|
|
614
747
|
protected constructor();
|
|
615
748
|
abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
|
|
749
|
+
/**
|
|
750
|
+
* Identifies this source's content across sessions for persistent caching. Sources that
|
|
751
|
+
* cannot tell whether their content changed (an unnamed archive, for example) return
|
|
752
|
+
* undefined, which keeps their results out of long-lived caches.
|
|
753
|
+
*/
|
|
754
|
+
get cacheId(): Maybe<string>;
|
|
755
|
+
}
|
|
756
|
+
/** A source failed to load or parse an asset; cause retains the original failure. */
|
|
757
|
+
declare class AssetLoadError extends Error {
|
|
758
|
+
readonly source: AssetSource;
|
|
759
|
+
readonly key: AssetKey;
|
|
760
|
+
readonly path: string;
|
|
761
|
+
readonly cause: unknown;
|
|
762
|
+
constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
|
|
616
763
|
}
|
|
617
764
|
|
|
618
765
|
declare class AssetLoader {
|
|
619
766
|
static ROOT: string;
|
|
620
767
|
private static _SOURCES;
|
|
768
|
+
/** Used when a registered source cannot identify its content, so nothing persists past this session. */
|
|
769
|
+
private static readonly SESSION_SCOPE;
|
|
770
|
+
static get version(): string;
|
|
771
|
+
static setVersion(version: string): void;
|
|
772
|
+
/**
|
|
773
|
+
* Scope for persistent cache keys. Empty with only the default vanilla sources, so their
|
|
774
|
+
* entries stay valid across sessions; otherwise it names every added source (resource packs,
|
|
775
|
+
* mirrors) so their results never masquerade as vanilla assets after a reload.
|
|
776
|
+
*/
|
|
777
|
+
static get persistentScope(): string;
|
|
778
|
+
/** Prefixes a persistent cache key with the current source scope. */
|
|
779
|
+
static persistentKey(key: string): string;
|
|
621
780
|
static addSource(key: string, source: AssetSource, override?: boolean): void;
|
|
622
781
|
static removeSource(key: string): Maybe<AssetSource>;
|
|
623
782
|
static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
|
|
624
783
|
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
625
784
|
static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
|
|
785
|
+
/** Tries each path within a source before considering lower-priority sources. */
|
|
786
|
+
static getFirst<T extends MinecraftAsset>(keys: readonly AssetKey[], parser: AssetParser | string): Promise<Maybe<{
|
|
787
|
+
key: AssetKey;
|
|
788
|
+
asset: T;
|
|
789
|
+
}>>;
|
|
626
790
|
}
|
|
627
791
|
|
|
628
792
|
interface BlockState extends MinecraftAsset {
|
|
@@ -637,18 +801,19 @@ interface BlockStateVariant {
|
|
|
637
801
|
y?: number;
|
|
638
802
|
x?: number;
|
|
639
803
|
uvlock?: boolean;
|
|
804
|
+
weight?: number;
|
|
640
805
|
}
|
|
641
806
|
interface BlockStateMultipart {
|
|
642
|
-
when?: MultipartCondition
|
|
643
|
-
|
|
644
|
-
};
|
|
645
|
-
apply?: BlockStateVariant;
|
|
646
|
-
}
|
|
647
|
-
interface MultipartCondition {
|
|
648
|
-
[key: string]: string;
|
|
807
|
+
when?: MultipartCondition;
|
|
808
|
+
apply?: BlockStateVariant | BlockStateVariant[];
|
|
649
809
|
}
|
|
810
|
+
type MultipartCondition = Record<string, string> | {
|
|
811
|
+
OR: MultipartCondition[];
|
|
812
|
+
} | {
|
|
813
|
+
AND: MultipartCondition[];
|
|
814
|
+
};
|
|
650
815
|
|
|
651
|
-
declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.
|
|
816
|
+
declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.21.11";
|
|
652
817
|
declare const DEFAULT_NAMESPACE = "minecraft";
|
|
653
818
|
declare class Assets {
|
|
654
819
|
/**
|
|
@@ -673,6 +838,55 @@ type BlockStateProperties = {
|
|
|
673
838
|
[key: string]: string;
|
|
674
839
|
};
|
|
675
840
|
|
|
841
|
+
/** One model drawn by a block-entity renderer. */
|
|
842
|
+
interface BlockEntityPart {
|
|
843
|
+
model: string;
|
|
844
|
+
/** Model layer; defaults to "main". */
|
|
845
|
+
layer?: string;
|
|
846
|
+
/** Set only when the texture differs from the layer's default. */
|
|
847
|
+
textureLocation?: string;
|
|
848
|
+
/** Blockstate multipart syntax: every property must match, and "a|b" matches either value. */
|
|
849
|
+
when?: Record<string, string>;
|
|
850
|
+
}
|
|
851
|
+
/** Degrees per property value, or degrees per unit of a numeric property. */
|
|
852
|
+
type BlockEntityRotation = {
|
|
853
|
+
property: string;
|
|
854
|
+
degrees: Record<string, number>;
|
|
855
|
+
} | {
|
|
856
|
+
property: string;
|
|
857
|
+
step: number;
|
|
858
|
+
};
|
|
859
|
+
interface BlockEntityEntry {
|
|
860
|
+
parts: BlockEntityPart[];
|
|
861
|
+
rotation?: BlockEntityRotation;
|
|
862
|
+
/** Offset in model units, applied before the rotation. */
|
|
863
|
+
translation?: TripleArray;
|
|
864
|
+
}
|
|
865
|
+
/** The dataset's `blocks.json`: block ID to the models its block-entity renderer draws. */
|
|
866
|
+
type BlockEntityIndex = MinecraftAsset & {
|
|
867
|
+
[block: string]: BlockEntityEntry;
|
|
868
|
+
};
|
|
869
|
+
interface ResolvedBlockEntity {
|
|
870
|
+
parts: BlockEntityPart[];
|
|
871
|
+
/** Degrees counter-clockwise seen from above, about the block's vertical centre axis. */
|
|
872
|
+
rotation: number;
|
|
873
|
+
translation: TripleArray;
|
|
874
|
+
}
|
|
875
|
+
declare class BlockEntities {
|
|
876
|
+
/**
|
|
877
|
+
* Loads the block index of a version. Versions and sources without one yield an empty index, and so does
|
|
878
|
+
* a failed load: the index is optional, and blocks must not retry or fail with it one by one. The empty
|
|
879
|
+
* result is cached like any other; `Caching.clear()` or `AssetLoader.setVersion()` forces a new attempt.
|
|
880
|
+
*/
|
|
881
|
+
static getIndex(root?: string): Promise<BlockEntityIndex>;
|
|
882
|
+
/** The index entry of a block ID such as `minecraft:chest`. */
|
|
883
|
+
static entry(index: BlockEntityIndex, block: string): Maybe<BlockEntityEntry>;
|
|
884
|
+
/** Selects the parts and placement for a block ID such as `minecraft:chest`; undefined when nothing is drawn. */
|
|
885
|
+
static resolve(index: BlockEntityIndex, block: string, state?: BlockStateProperties): Maybe<ResolvedBlockEntity>;
|
|
886
|
+
/** Placement in block space (0..16 per axis), applied on top of the model's own transform. */
|
|
887
|
+
static matrix(resolved: ResolvedBlockEntity, matrix?: Matrix4): Matrix4;
|
|
888
|
+
}
|
|
889
|
+
|
|
676
890
|
declare class BlockStates {
|
|
677
891
|
private static _persistentCache;
|
|
678
892
|
private static get PERSISTENT_CACHE();
|
|
@@ -687,25 +901,72 @@ declare class DefaultBlockStates implements MinecraftAsset {
|
|
|
687
901
|
[k: string]: BlockStatePropertyDefaults;
|
|
688
902
|
}
|
|
689
903
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
904
|
+
/** `entity-models/animations/<namespace>/<model id>.json`: vanilla's keyframe animations of one model. */
|
|
905
|
+
interface EntityAnimationFile extends MinecraftAsset {
|
|
906
|
+
id: string;
|
|
907
|
+
animations: Record<string, EntityAnimation>;
|
|
908
|
+
}
|
|
909
|
+
interface EntityAnimation {
|
|
910
|
+
/** Seconds. */
|
|
911
|
+
length: number;
|
|
912
|
+
loop: boolean;
|
|
913
|
+
/** Part name anywhere in a layer; `root` is the layer's root part. */
|
|
914
|
+
bones: Record<string, EntityAnimationBone>;
|
|
694
915
|
}
|
|
916
|
+
type EntityAnimationChannel = "position" | "rotation" | "scale";
|
|
917
|
+
/** Keyframes in time order per channel. */
|
|
918
|
+
type EntityAnimationBone = Partial<Record<EntityAnimationChannel, EntityAnimationKeyframe[]>>;
|
|
919
|
+
interface EntityAnimationKeyframe {
|
|
920
|
+
/** Seconds. */
|
|
921
|
+
time: number;
|
|
922
|
+
/** Offset from the default pose: model units, radians, or scale minus one. */
|
|
923
|
+
value: TripleArray;
|
|
924
|
+
/** Value to arrive at when it differs from `value`; linear interpolation only. */
|
|
925
|
+
pre?: TripleArray;
|
|
926
|
+
/** Applies between the previous keyframe and this one. */
|
|
927
|
+
interpolation: "linear" | "catmullrom";
|
|
928
|
+
}
|
|
929
|
+
/** Sampled offsets from the default pose, per bone and channel. */
|
|
930
|
+
type EntityAnimationPose = Record<string, Partial<Record<EntityAnimationChannel, TripleArray>>>;
|
|
931
|
+
declare const ENTITY_ANIMATION_CHANNELS: readonly EntityAnimationChannel[];
|
|
932
|
+
/**
|
|
933
|
+
* Samples one channel like vanilla's `KeyframeAnimation.Entry`: the first value holds before the
|
|
934
|
+
* first keyframe and the last value after the last one; in between, the later keyframe selects the interpolation.
|
|
935
|
+
*/
|
|
936
|
+
declare function sampleEntityKeyframes(keyframes: readonly EntityAnimationKeyframe[], time: number): TripleArray;
|
|
937
|
+
/** Elapsed seconds within the animation: modulo `length` when looping, as vanilla does. */
|
|
938
|
+
declare function entityAnimationTime(animation: EntityAnimation, time: number, loop?: boolean): number;
|
|
939
|
+
/** Samples every bone and channel of an animation at `time` seconds. */
|
|
940
|
+
declare function sampleEntityAnimation(animation: EntityAnimation, time: number, loop?: boolean): EntityAnimationPose;
|
|
695
941
|
|
|
696
942
|
declare class Entities {
|
|
697
|
-
static getBlockEntityModels(): Promise<Maybe<BlockEntityModels>>;
|
|
698
|
-
static getEntityModels(): Promise<Maybe<EntityModels>>;
|
|
699
|
-
static getBlockList(): Promise<string[]>;
|
|
700
943
|
static getEntityList(): Promise<string[]>;
|
|
701
|
-
static
|
|
702
|
-
static
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
944
|
+
private static getModelFile;
|
|
945
|
+
static getLayerList(modelKey: BasicAssetKey): Promise<string[]>;
|
|
946
|
+
/** The dataset's extra draws on top of `main`; their `when` labels are the states `EntityModelOptions.when` can enable. */
|
|
947
|
+
static getPassList(modelKey: BasicAssetKey): Promise<EntityModelPass[]>;
|
|
948
|
+
static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
|
|
949
|
+
/**
|
|
950
|
+
* Vanilla's keyframe animations of a model by name, or undefined when the model or the selected version has none.
|
|
951
|
+
*/
|
|
952
|
+
static getAnimations(modelKey: BasicAssetKey): Promise<Maybe<Record<string, EntityAnimation>>>;
|
|
953
|
+
static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
|
|
954
|
+
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
955
|
+
static getBlockList(): Promise<string[]>;
|
|
956
|
+
/** @deprecated Use getEntity(); block entities share the entity dataset. */
|
|
957
|
+
static getBlock(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
|
|
706
958
|
}
|
|
707
|
-
|
|
708
|
-
|
|
959
|
+
interface EntityModelOptions {
|
|
960
|
+
layer?: string;
|
|
961
|
+
/** Layer names in draw order; an explicit selection draws exactly these layers and no dataset passes. */
|
|
962
|
+
layers?: string[];
|
|
963
|
+
/**
|
|
964
|
+
* Entity states that enable the dataset's conditional passes, e.g. `["powered"]` for a charged creeper.
|
|
965
|
+
* Without `layer`/`layers`, `main` and every unconditional pass are always drawn.
|
|
966
|
+
*/
|
|
967
|
+
when?: string[];
|
|
968
|
+
/** Per-layer texture overrides, keyed like `EntityModel.layers`. The positional texture key applies to the first selected layer. */
|
|
969
|
+
textures?: Record<string, BasicAssetKey>;
|
|
709
970
|
}
|
|
710
971
|
|
|
711
972
|
declare class Models {
|
|
@@ -713,15 +974,40 @@ declare class Models {
|
|
|
713
974
|
private static get PERSISTENT_CACHE();
|
|
714
975
|
static getItemList(): Promise<string[]>;
|
|
715
976
|
static loadAndMerge(key: AssetKey): Promise<Maybe<Model>>;
|
|
977
|
+
private static getItemModel;
|
|
978
|
+
private static defaultItemModel;
|
|
716
979
|
static getRaw(key: AssetKey): Promise<Maybe<Model>>;
|
|
717
980
|
static getMerged(key: AssetKey): Promise<Maybe<Model>>;
|
|
718
981
|
static get(key: AssetKey): Promise<Maybe<Model>>;
|
|
719
982
|
static clearCache(): Promise<void>;
|
|
720
983
|
}
|
|
721
984
|
|
|
985
|
+
declare class DisplayTransforms {
|
|
986
|
+
/** Resolve hand fallbacks within one model, before inheriting parent display entries. */
|
|
987
|
+
static withHandFallbacks(display: Model["display"]): Model["display"];
|
|
988
|
+
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
989
|
+
static getMatrix(display: Model["display"], position: DisplayPosition): Matrix4;
|
|
990
|
+
static apply(geometry: BufferGeometry, matrix: Matrix4): void;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
declare class ItemTints {
|
|
994
|
+
/** Resolves preview colors from item definitions; explicit per-index colors take precedence. */
|
|
995
|
+
static get(model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
|
|
996
|
+
private static rgb;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
declare class ModelCulling {
|
|
1000
|
+
static toLocalMask(worldMask: number, rotation: Euler): number;
|
|
1001
|
+
static isOpaqueFullCube(atlas: Maybe<TextureAtlas>): boolean;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
722
1004
|
declare class ModelGenerator {
|
|
723
1005
|
static readonly ITEM_LAYERS: string[];
|
|
724
|
-
|
|
1006
|
+
/**
|
|
1007
|
+
* Front and back faces plus one zero-thickness side face per run of texels that border a transparent texel,
|
|
1008
|
+
* like vanilla's ItemModelGenerator. Pass the pixels of a single (first) animation frame.
|
|
1009
|
+
*/
|
|
1010
|
+
static generateItemModel(imageData: Pick<ImageData$1, "width" | "height" | "data">, layer: string): ModelElement[];
|
|
725
1011
|
}
|
|
726
1012
|
|
|
727
1013
|
declare class ModelMerger {
|
|
@@ -729,14 +1015,41 @@ declare class ModelMerger {
|
|
|
729
1015
|
protected static collectAllParents(model: Model): Promise<Model[]>;
|
|
730
1016
|
}
|
|
731
1017
|
|
|
1018
|
+
interface SpecialItemPart {
|
|
1019
|
+
model: EntityModel;
|
|
1020
|
+
transform: Matrix4;
|
|
1021
|
+
rotations: Record<string, TripleArray>;
|
|
1022
|
+
}
|
|
1023
|
+
declare class SpecialItems {
|
|
1024
|
+
/** Resolves the static entity parts drawn by a special item renderer, in model units. */
|
|
1025
|
+
static getParts(special: SpecialItemRenderer, root?: string): Promise<SpecialItemPart[]>;
|
|
1026
|
+
/** An owned material with model-preview shading; its entity texture remains shared. */
|
|
1027
|
+
static createMaterial(source: MeshBasicMaterial, shade: boolean): MeshBasicMaterial;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
732
1030
|
interface Block {
|
|
733
1031
|
type: string;
|
|
734
1032
|
properties?: BlockStateProperties;
|
|
735
1033
|
nbt?: any;
|
|
736
1034
|
}
|
|
737
1035
|
|
|
1036
|
+
declare class BlockStateResolver {
|
|
1037
|
+
static defaults(blockState: BlockState): Promise<BlockStateProperties>;
|
|
1038
|
+
static select(blockState: BlockState, state: BlockStateProperties, choose?: (variants: BlockStateVariant | BlockStateVariant[]) => BlockStateVariant): BlockStateVariant[];
|
|
1039
|
+
static matching(blockState: BlockState, state: BlockStateProperties): (BlockStateVariant | BlockStateVariant[])[];
|
|
1040
|
+
static choose(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
|
|
1041
|
+
static rotation(variant: BlockStateVariant): Euler;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
declare class BlockTints {
|
|
1045
|
+
/** Resolves block preview colors without biome context; explicit tints take precedence. */
|
|
1046
|
+
static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
738
1049
|
interface Instanceable {
|
|
739
1050
|
nextInstance(): InstanceReference<SceneObject>;
|
|
1051
|
+
removeInstanceAt(index: number): void;
|
|
1052
|
+
isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
|
|
740
1053
|
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
741
1054
|
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
742
1055
|
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
@@ -749,12 +1062,15 @@ interface Instanceable {
|
|
|
749
1062
|
}
|
|
750
1063
|
declare function isInstanceable(obj: any): obj is Instanceable;
|
|
751
1064
|
|
|
752
|
-
declare class InstanceReference<T extends Instanceable> implements Transformable {
|
|
1065
|
+
declare class InstanceReference<T extends Instanceable> implements Transformable, Disposable {
|
|
753
1066
|
readonly instanceable: T;
|
|
754
1067
|
readonly index: number;
|
|
755
1068
|
readonly isInstanceReference: true;
|
|
756
1069
|
constructor(instanceable: T, index: number);
|
|
757
1070
|
nextInstance(): InstanceReference<SceneObject>;
|
|
1071
|
+
private get activeInstanceable();
|
|
1072
|
+
removeFromScene(): void;
|
|
1073
|
+
dispose(): void;
|
|
758
1074
|
getMatrix(matrix?: Matrix4): Matrix4;
|
|
759
1075
|
setMatrix(matrix: Matrix4): void;
|
|
760
1076
|
setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
@@ -779,18 +1095,34 @@ declare class ModelObject extends SceneObject {
|
|
|
779
1095
|
readonly isModelObject: true;
|
|
780
1096
|
static readonly DEFAULT_OPTIONS: ModelObjectOptions;
|
|
781
1097
|
readonly options: ModelObjectOptions;
|
|
782
|
-
|
|
1098
|
+
protected atlas?: TextureAtlas;
|
|
1099
|
+
private atlasMaterial?;
|
|
1100
|
+
private atlasTexture?;
|
|
1101
|
+
private unsubscribeAtlas?;
|
|
1102
|
+
private readonly specialMaterials;
|
|
783
1103
|
blockParent: Maybe<BlockObject>;
|
|
784
1104
|
private meshesCreated;
|
|
785
1105
|
constructor(originalModel: Model, options?: Partial<ModelObjectOptions>);
|
|
786
1106
|
init(): Promise<void>;
|
|
787
|
-
dispose(): void;
|
|
788
1107
|
get textureAtlas(): Maybe<TextureAtlas>;
|
|
1108
|
+
get isOpaqueFullCube(): boolean;
|
|
789
1109
|
protected loadTextures(): Promise<void>;
|
|
790
1110
|
protected createMeshes(force?: boolean): void;
|
|
791
1111
|
protected applyTextures(): void;
|
|
1112
|
+
private updateAnimationSubscription;
|
|
1113
|
+
nextInstance(): InstanceReference<SceneObject>;
|
|
1114
|
+
removeInstanceAt(index: number): void;
|
|
1115
|
+
disposeAndRemoveAllChildren(): void;
|
|
792
1116
|
}
|
|
793
1117
|
interface ModelObjectOptions extends SceneObjectOptions {
|
|
1118
|
+
/** Minecraft display pose applied around the model center, before scene transforms. */
|
|
1119
|
+
displayPosition?: DisplayPosition;
|
|
1120
|
+
/** Quarter-turn block rotation in radians to compensate when locking UVs. */
|
|
1121
|
+
uvLockRotation?: TripleArray;
|
|
1122
|
+
/** sRGB 0xRRGGBB colors by face tint index; omitted indices stay white. */
|
|
1123
|
+
tints?: Record<number, number>;
|
|
1124
|
+
/** Hidden neighbor directions in CUBE_FACES order, before the model's block rotation. */
|
|
1125
|
+
cullMask?: number;
|
|
794
1126
|
}
|
|
795
1127
|
declare function isModelObject(obj: any): obj is ModelObject;
|
|
796
1128
|
|
|
@@ -823,24 +1155,71 @@ declare enum SkinPart {
|
|
|
823
1155
|
}
|
|
824
1156
|
declare const SKIN_PARTS: SkinPart[];
|
|
825
1157
|
|
|
1158
|
+
type CapeLayout = "minecraft" | "optifine" | "labymod";
|
|
1159
|
+
declare const capeTextureSizes: Record<CapeLayout, DoubleArray>;
|
|
1160
|
+
|
|
1161
|
+
/** A player model facing +Z. Left and right parts are the player's own: left is +X, right is -X. */
|
|
826
1162
|
declare class SkinObject extends SceneObject {
|
|
827
1163
|
readonly options: SkinObjectOptions;
|
|
828
1164
|
private slim;
|
|
829
|
-
private
|
|
1165
|
+
private detectedSlim;
|
|
830
1166
|
private skinTextureSrc?;
|
|
831
|
-
private
|
|
832
|
-
private
|
|
833
|
-
private
|
|
1167
|
+
private skinMaterial?;
|
|
1168
|
+
private skinLoad;
|
|
1169
|
+
private capeLoad;
|
|
834
1170
|
constructor(options?: DeepPartial<SkinObjectOptions>);
|
|
835
1171
|
init(): Promise<void>;
|
|
836
1172
|
protected removeMeshes(): void;
|
|
837
1173
|
protected createMeshes(): void;
|
|
838
|
-
setSkinTexture(src: string): void
|
|
839
|
-
|
|
840
|
-
|
|
1174
|
+
setSkinTexture(src: string): Promise<void>;
|
|
1175
|
+
/** Load a cape texture in the selected layout, or pass undefined to remove the cape. */
|
|
1176
|
+
setCapeTexture(src?: string, layout?: CapeLayout): Promise<void>;
|
|
1177
|
+
/** Select the arm model, or pass undefined to use texture detection. */
|
|
1178
|
+
setSlim(slim?: boolean): void;
|
|
1179
|
+
private updateSlim;
|
|
1180
|
+
/** Select the texture layout, or pass undefined to detect it from image dimensions. */
|
|
1181
|
+
setLegacy(legacy?: boolean): Promise<void>;
|
|
1182
|
+
dispose(): void;
|
|
841
1183
|
protected getBoxGeometry(part: SkinPart): BoxGeometry;
|
|
842
1184
|
}
|
|
843
1185
|
interface SkinObjectOptions extends SceneObjectOptions {
|
|
1186
|
+
slim?: boolean;
|
|
1187
|
+
legacy?: boolean;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
interface EntityAnimationOptions {
|
|
1191
|
+
/** Overrides the animation's own `loop` flag. */
|
|
1192
|
+
loop?: boolean;
|
|
1193
|
+
/** Playback rate applied to advanced time; defaults to 1. */
|
|
1194
|
+
speed?: number;
|
|
1195
|
+
/** Start time in seconds; defaults to 0. */
|
|
1196
|
+
time?: number;
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Poses part groups from a keyframe animation the way vanilla does: every update restores the
|
|
1200
|
+
* default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.
|
|
1201
|
+
* It owns no timer; the owner advances it.
|
|
1202
|
+
*/
|
|
1203
|
+
declare class EntityAnimationPlayer {
|
|
1204
|
+
private parts;
|
|
1205
|
+
private _animation?;
|
|
1206
|
+
private _time;
|
|
1207
|
+
private loop;
|
|
1208
|
+
private speed;
|
|
1209
|
+
get animation(): EntityAnimation | undefined;
|
|
1210
|
+
get time(): number;
|
|
1211
|
+
/**
|
|
1212
|
+
* Starts an animation on the named parts below each layer root. The current pose of a part becomes its default;
|
|
1213
|
+
* bones without a matching part are skipped.
|
|
1214
|
+
*/
|
|
1215
|
+
play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions): void;
|
|
1216
|
+
/** Restores the default poses. Returns whether an animation was active. */
|
|
1217
|
+
stop(): boolean;
|
|
1218
|
+
/** Forgets the animation without touching the parts, for parts that no longer exist. */
|
|
1219
|
+
clear(): void;
|
|
1220
|
+
setTime(seconds: number): boolean;
|
|
1221
|
+
advance(deltaSeconds: number): boolean;
|
|
1222
|
+
private apply;
|
|
844
1223
|
}
|
|
845
1224
|
|
|
846
1225
|
declare class EntityObject extends SceneObject {
|
|
@@ -848,19 +1227,99 @@ declare class EntityObject extends SceneObject {
|
|
|
848
1227
|
readonly isEntityObject: true;
|
|
849
1228
|
static readonly DEFAULT_OPTIONS: EntityObjectOptions;
|
|
850
1229
|
readonly options: EntityObjectOptions;
|
|
851
|
-
private imageData?;
|
|
852
1230
|
private meshesCreated;
|
|
1231
|
+
private readonly geometries;
|
|
1232
|
+
private readonly disposeWireframes;
|
|
1233
|
+
/** Scrolling materials are owned: their texture offset follows this entity's age. */
|
|
1234
|
+
private readonly scrollMaterials;
|
|
1235
|
+
private scrollTicker;
|
|
1236
|
+
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
1237
|
+
age: number;
|
|
1238
|
+
private readonly animationPlayer;
|
|
853
1239
|
constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
|
|
854
1240
|
init(): Promise<void>;
|
|
855
1241
|
dispose(): void;
|
|
856
|
-
|
|
1242
|
+
disposeAndRemoveAllChildren(): void;
|
|
1243
|
+
private clearScrollMaterials;
|
|
1244
|
+
private updateScrollSubscription;
|
|
1245
|
+
/** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
|
|
1246
|
+
private updateScroll;
|
|
1247
|
+
/** The animation started by {@link playAnimation}, until {@link stopAnimation} or disposal. */
|
|
1248
|
+
get animation(): Maybe<EntityAnimation>;
|
|
1249
|
+
/** Seconds since the animation started, before looping. */
|
|
1250
|
+
get animationTime(): number;
|
|
1251
|
+
/**
|
|
1252
|
+
* Poses the object from a keyframe animation of {@link Entities.getAnimations}, replacing the current one.
|
|
1253
|
+
* Parts of every layer are matched by name and their current pose is the default the offsets add to.
|
|
1254
|
+
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
1255
|
+
*/
|
|
1256
|
+
playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
|
|
1257
|
+
/** Stops the animation and restores the default pose. */
|
|
1258
|
+
stopAnimation(): void;
|
|
1259
|
+
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
1260
|
+
setAnimationTime(seconds: number): void;
|
|
1261
|
+
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
1262
|
+
advanceAnimation(deltaSeconds: number): void;
|
|
1263
|
+
getLayerGroup(name: string): Maybe<Object3D>;
|
|
1264
|
+
getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
|
|
1265
|
+
getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
|
|
1266
|
+
private get entityLayers();
|
|
1267
|
+
private getTextureKey;
|
|
1268
|
+
protected loadTextures(layer?: EntityLayer): Promise<Maybe<ExtractableImageData>>;
|
|
857
1269
|
protected createMeshes(force?: boolean): void;
|
|
1270
|
+
private createPart;
|
|
858
1271
|
protected applyTextures(): Promise<void>;
|
|
859
1272
|
}
|
|
860
1273
|
interface EntityObjectOptions extends SceneObjectOptions {
|
|
1274
|
+
/**
|
|
1275
|
+
* `true` applies only vanilla's entity flip, scale (-1, -1, 1); `false` keeps raw model space.
|
|
1276
|
+
* By default the model's dataset transform is used, or the flip for models without one.
|
|
1277
|
+
*/
|
|
1278
|
+
flip?: boolean;
|
|
1279
|
+
/** Colours for the dataset's tint labels, e.g. `{ wool_color: 0xf9801d }`; a pass whose label is absent stays untinted. */
|
|
1280
|
+
tints?: Record<string, ColorRepresentation>;
|
|
861
1281
|
}
|
|
862
1282
|
declare function isEntityObject(obj: any): obj is EntityObject;
|
|
863
1283
|
|
|
1284
|
+
/** GUI layers use pixel coordinates. Later layers draw above earlier layers. */
|
|
1285
|
+
type GuiLayer = GuiTextureLayer | GuiItemLayer;
|
|
1286
|
+
interface GuiLayerLayout {
|
|
1287
|
+
name?: string;
|
|
1288
|
+
/** Top-left position; x grows right and y grows down. Defaults to [0, 0]. */
|
|
1289
|
+
position?: [number, number];
|
|
1290
|
+
/** Output width and height; defaults to the texture crop size or [16, 16] for items. */
|
|
1291
|
+
size?: [number, number];
|
|
1292
|
+
}
|
|
1293
|
+
interface GuiTextureLayer extends GuiLayerLayout {
|
|
1294
|
+
texture: AssetKey | string;
|
|
1295
|
+
/** Source-image pixels: [x, y, width, height], measured from the top left. */
|
|
1296
|
+
crop?: [number, number, number, number];
|
|
1297
|
+
}
|
|
1298
|
+
interface GuiItemLayer extends GuiLayerLayout {
|
|
1299
|
+
/** Model key, such as minecraft:item/stone; uses the model's GUI display pose. */
|
|
1300
|
+
item: AssetKey | string;
|
|
1301
|
+
/** sRGB 0xRRGGBB colors by face tint index; omitted indices stay white. */
|
|
1302
|
+
tints?: Record<number, number>;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
declare class GuiObject extends SceneObject {
|
|
1306
|
+
readonly textureLayers: readonly GuiLayer[];
|
|
1307
|
+
readonly isGuiObject: true;
|
|
1308
|
+
/** Local bounds in GUI pixels, with y growing down from the origin. */
|
|
1309
|
+
readonly bounds: Box2;
|
|
1310
|
+
private readonly geometries;
|
|
1311
|
+
private readonly ownedMaterials;
|
|
1312
|
+
private initialized;
|
|
1313
|
+
constructor(textureLayers: readonly GuiLayer[], options?: Partial<GuiObjectOptions>);
|
|
1314
|
+
init(): Promise<void>;
|
|
1315
|
+
private createItem;
|
|
1316
|
+
private loadMaterial;
|
|
1317
|
+
disposeAndRemoveAllChildren(): void;
|
|
1318
|
+
}
|
|
1319
|
+
interface GuiObjectOptions extends SceneObjectOptions {
|
|
1320
|
+
}
|
|
1321
|
+
declare function isGuiObject(obj: any): obj is GuiObject;
|
|
1322
|
+
|
|
864
1323
|
declare class MineRenderScene extends Scene {
|
|
865
1324
|
readonly isMineRenderScene: true;
|
|
866
1325
|
static readonly DEFAULT_OPTIONS: MineRenderSceneOptions;
|
|
@@ -880,6 +1339,7 @@ declare class MineRenderScene extends Scene {
|
|
|
880
1339
|
addBlock(blockState: BlockState, options?: Partial<BlockObjectOptions>, parent?: Object3D): Promise<BlockObject | InstanceReference<BlockObject>>;
|
|
881
1340
|
addSkin(skin?: string, options?: Partial<SkinObjectOptions>, parent?: Object3D): Promise<SkinObject>;
|
|
882
1341
|
addEntity(entity: EntityModel, options?: Partial<EntityObjectOptions>, parent?: Object3D): Promise<EntityObject | InstanceReference<EntityObject>>;
|
|
1342
|
+
addGui(layers: readonly GuiLayer[], options?: Partial<GuiObjectOptions>, parent?: Object3D): Promise<GuiObject>;
|
|
883
1343
|
}
|
|
884
1344
|
interface MineRenderSceneOptions {
|
|
885
1345
|
}
|
|
@@ -895,6 +1355,9 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
895
1355
|
private materialCallbacks;
|
|
896
1356
|
protected _isInstanced: boolean;
|
|
897
1357
|
_instanceCounter: number;
|
|
1358
|
+
protected instanceMesh?: InstancedMesh;
|
|
1359
|
+
private readonly instanceReferences;
|
|
1360
|
+
private readonly freeInstanceIndices;
|
|
898
1361
|
constructor(options?: Partial<SceneObjectOptions>);
|
|
899
1362
|
set scene(scene: MineRenderScene);
|
|
900
1363
|
get scene(): MineRenderScene;
|
|
@@ -934,6 +1397,12 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
934
1397
|
get instanceCounter(): number;
|
|
935
1398
|
protected constructInstanceReference(i: number): InstanceReference<SceneObject>;
|
|
936
1399
|
nextInstance(): InstanceReference<SceneObject>;
|
|
1400
|
+
/** Returns the live reference for a raycast hit on this object's instance mesh. */
|
|
1401
|
+
getInstanceReference(mesh: Object3D, index: number): Maybe<InstanceReference<SceneObject>>;
|
|
1402
|
+
isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
|
|
1403
|
+
removeInstanceAt(index: number): void;
|
|
1404
|
+
private growInstances;
|
|
1405
|
+
protected activeInstanceIndices(): Iterable<number>;
|
|
937
1406
|
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
938
1407
|
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
939
1408
|
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
@@ -957,6 +1426,23 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
957
1426
|
}
|
|
958
1427
|
declare function isSceneObject(obj: any): obj is SceneObject;
|
|
959
1428
|
|
|
1429
|
+
type FluidKind = "water" | "lava";
|
|
1430
|
+
interface BlockFluidState {
|
|
1431
|
+
kind: FluidKind;
|
|
1432
|
+
level: number;
|
|
1433
|
+
renderModel: boolean;
|
|
1434
|
+
}
|
|
1435
|
+
declare function getBlockFluidState(key?: AssetKey, state?: BlockStateProperties): BlockFluidState | undefined;
|
|
1436
|
+
declare function getFluidKind(key?: AssetKey, state?: BlockStateProperties): FluidKind | undefined;
|
|
1437
|
+
interface FluidSample {
|
|
1438
|
+
fluid?: FluidKind;
|
|
1439
|
+
level?: number;
|
|
1440
|
+
solid?: boolean;
|
|
1441
|
+
}
|
|
1442
|
+
type FluidSampler = (x: number, y: number, z: number) => FluidSample;
|
|
1443
|
+
/** Builds centered fluid faces with material groups 0 (still) and 1 (flowing). */
|
|
1444
|
+
declare function createFluidGeometry(kind: FluidKind, sample: FluidSampler): BufferGeometry;
|
|
1445
|
+
|
|
960
1446
|
declare class BlockObject extends SceneObject {
|
|
961
1447
|
readonly blockState: BlockState;
|
|
962
1448
|
readonly isBlockObject: true;
|
|
@@ -970,16 +1456,43 @@ declare class BlockObject extends SceneObject {
|
|
|
970
1456
|
private _instanceModel;
|
|
971
1457
|
private _variants;
|
|
972
1458
|
private _models;
|
|
1459
|
+
private _cullMask;
|
|
1460
|
+
private _fluidKey?;
|
|
1461
|
+
private _fluidSampler?;
|
|
1462
|
+
private _fluidModel?;
|
|
1463
|
+
private _entities;
|
|
1464
|
+
private _entityPlacement;
|
|
1465
|
+
private _entityGeneration;
|
|
973
1466
|
constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
|
|
974
1467
|
init(): Promise<void>;
|
|
975
1468
|
dispose(): void;
|
|
976
1469
|
removeFromScene(): void;
|
|
1470
|
+
private clearModels;
|
|
1471
|
+
private removeModels;
|
|
1472
|
+
private removeEntities;
|
|
1473
|
+
/** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
|
|
1474
|
+
get blockEntities(): readonly EntityObject[];
|
|
1475
|
+
/**
|
|
1476
|
+
* Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
|
|
1477
|
+
* when the block is not listed or one of its models cannot be loaded.
|
|
1478
|
+
*/
|
|
1479
|
+
private createBlockEntities;
|
|
1480
|
+
private placeEntities;
|
|
1481
|
+
get isOccluding(): boolean;
|
|
1482
|
+
private getModelMatrix;
|
|
1483
|
+
private getModelCullMask;
|
|
1484
|
+
setCullMask(worldMask: number): Promise<void>;
|
|
977
1485
|
get state(): {
|
|
978
1486
|
[key: string]: string;
|
|
979
1487
|
};
|
|
1488
|
+
get fluidKind(): FluidKind | undefined;
|
|
1489
|
+
get fluidLevel(): number;
|
|
1490
|
+
/** Refreshes fluid surfaces from relative neighbors; standalone previews use air around the block. */
|
|
1491
|
+
updateFluid(sample?: FluidSampler): Promise<void>;
|
|
980
1492
|
nextInstance(): InstanceReference<SceneObject>;
|
|
981
1493
|
protected mapStateToVariant(state: BlockStateProperties): Promise<BlockStateVariant[]>;
|
|
982
1494
|
recreateModels(): Promise<void>;
|
|
1495
|
+
private hasGeometry;
|
|
983
1496
|
protected getSingleVariant(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
|
|
984
1497
|
protected createAVariant(variants: BlockStateVariant | BlockStateVariant[], instanceInfo: Matrix4[]): Promise<void>;
|
|
985
1498
|
protected createVariant(variant: BlockStateVariant): Promise<ModelObject | InstanceReference<ModelObject>>;
|
|
@@ -995,26 +1508,50 @@ declare class BlockObject extends SceneObject {
|
|
|
995
1508
|
}
|
|
996
1509
|
interface BlockObjectOptions extends ModelObjectOptions {
|
|
997
1510
|
applyDefaultState: boolean;
|
|
1511
|
+
/** Properties applied before model creation, overriding defaults when applyDefaultState is enabled. */
|
|
1512
|
+
initialState?: BlockStateProperties;
|
|
998
1513
|
}
|
|
999
1514
|
declare function isBlockObject(obj: any): obj is BlockObject;
|
|
1000
1515
|
|
|
1516
|
+
/** Saved fluid levels and solid neighbors determine the geometry shared by an instance pool. */
|
|
1517
|
+
declare function sampleFluid(kind: FluidKind, sample: FluidSampler): {
|
|
1518
|
+
key: string;
|
|
1519
|
+
sample: FluidSampler;
|
|
1520
|
+
};
|
|
1521
|
+
declare class FluidModelObject extends ModelObject {
|
|
1522
|
+
readonly kind: FluidKind;
|
|
1523
|
+
private readonly sample;
|
|
1524
|
+
private geometry?;
|
|
1525
|
+
constructor(kind: FluidKind, sample: FluidSampler, origin?: AssetKey, options?: Partial<ModelObjectOptions>);
|
|
1526
|
+
protected createMeshes(): void;
|
|
1527
|
+
protected applyTextures(): void;
|
|
1528
|
+
disposeAndRemoveAllChildren(): void;
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1001
1531
|
interface MultiBlockStructure {
|
|
1002
1532
|
readonly size: TripleArray;
|
|
1003
1533
|
readonly blocks: MultiBlockBlock[];
|
|
1534
|
+
readonly dataVersion?: number;
|
|
1535
|
+
readonly entities?: MultiBlockEntity[];
|
|
1536
|
+
}
|
|
1537
|
+
interface MultiBlockEntity {
|
|
1538
|
+
position: TripleArray;
|
|
1539
|
+
blockPosition?: TripleArray;
|
|
1540
|
+
nbt: unknown;
|
|
1004
1541
|
}
|
|
1005
1542
|
interface MultiBlockBlock extends Block {
|
|
1006
1543
|
position: TripleArray;
|
|
1007
1544
|
}
|
|
1008
1545
|
|
|
1009
1546
|
declare class SchematicParser {
|
|
1010
|
-
static parse(): Promise<MultiBlockStructure>;
|
|
1547
|
+
static parse(nbt: NBT): Promise<MultiBlockStructure>;
|
|
1011
1548
|
}
|
|
1012
1549
|
|
|
1013
1550
|
declare class StructureParser {
|
|
1014
1551
|
static parse(_nbt: NBT, paletteIndex?: number): Promise<MultiBlockStructure>;
|
|
1015
1552
|
}
|
|
1016
1553
|
interface StructureNBT {
|
|
1017
|
-
DataVersion
|
|
1554
|
+
DataVersion?: {
|
|
1018
1555
|
type: "int";
|
|
1019
1556
|
value: number;
|
|
1020
1557
|
};
|
|
@@ -1026,7 +1563,13 @@ interface StructureNBT {
|
|
|
1026
1563
|
};
|
|
1027
1564
|
};
|
|
1028
1565
|
palette?: Palette;
|
|
1029
|
-
palettes?:
|
|
1566
|
+
palettes?: {
|
|
1567
|
+
type: "list";
|
|
1568
|
+
value: {
|
|
1569
|
+
type: "list";
|
|
1570
|
+
value: Palette["value"][];
|
|
1571
|
+
};
|
|
1572
|
+
};
|
|
1030
1573
|
blocks: {
|
|
1031
1574
|
type: "list";
|
|
1032
1575
|
value: {
|
|
@@ -1034,7 +1577,32 @@ interface StructureNBT {
|
|
|
1034
1577
|
value: BlockEntry[];
|
|
1035
1578
|
};
|
|
1036
1579
|
};
|
|
1037
|
-
entities
|
|
1580
|
+
entities?: {
|
|
1581
|
+
type: "list";
|
|
1582
|
+
value: {
|
|
1583
|
+
type: "compound";
|
|
1584
|
+
value: {
|
|
1585
|
+
pos: {
|
|
1586
|
+
type: "list";
|
|
1587
|
+
value: {
|
|
1588
|
+
type: "double";
|
|
1589
|
+
value: TripleArray;
|
|
1590
|
+
};
|
|
1591
|
+
};
|
|
1592
|
+
blockPos: {
|
|
1593
|
+
type: "list";
|
|
1594
|
+
value: {
|
|
1595
|
+
type: "int";
|
|
1596
|
+
value: TripleArray;
|
|
1597
|
+
};
|
|
1598
|
+
};
|
|
1599
|
+
nbt: {
|
|
1600
|
+
type: "compound";
|
|
1601
|
+
value: any;
|
|
1602
|
+
};
|
|
1603
|
+
}[];
|
|
1604
|
+
};
|
|
1605
|
+
};
|
|
1038
1606
|
}
|
|
1039
1607
|
interface Palette {
|
|
1040
1608
|
type: "list";
|
|
@@ -1078,14 +1646,17 @@ interface BlockEntry {
|
|
|
1078
1646
|
}
|
|
1079
1647
|
|
|
1080
1648
|
declare class NBTHelper {
|
|
1081
|
-
static fromBuffer(
|
|
1649
|
+
static fromBuffer(data: Uint8Array | ArrayBuffer, format?: NBTFormat): Promise<NBTAsset>;
|
|
1082
1650
|
}
|
|
1083
1651
|
interface NBTAsset extends MinecraftAsset, NBT {
|
|
1652
|
+
format?: NBTFormat;
|
|
1653
|
+
metadata?: Metadata;
|
|
1654
|
+
compression?: "gzip" | "none";
|
|
1084
1655
|
}
|
|
1085
1656
|
|
|
1086
1657
|
interface ResponseParser<T extends MinecraftAsset> {
|
|
1087
|
-
config(request:
|
|
1088
|
-
parse(response:
|
|
1658
|
+
config(request: RequestConfig): any;
|
|
1659
|
+
parse(response: RequestResponse): Maybe<T> | Promise<Maybe<T>>;
|
|
1089
1660
|
}
|
|
1090
1661
|
|
|
1091
1662
|
declare class HostedAssetSource extends AssetSource {
|
|
@@ -1104,6 +1675,7 @@ declare class HostedAssetSource extends AssetSource {
|
|
|
1104
1675
|
private readonly _options;
|
|
1105
1676
|
constructor(root: string, options?: Partial<HostedAssetSourceOptions>);
|
|
1106
1677
|
get root(): string;
|
|
1678
|
+
get cacheId(): string;
|
|
1107
1679
|
get options(): HostedAssetSourceOptions;
|
|
1108
1680
|
get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser): Promise<Maybe<T>>;
|
|
1109
1681
|
}
|
|
@@ -1118,6 +1690,8 @@ interface ArchiveEntry {
|
|
|
1118
1690
|
}
|
|
1119
1691
|
|
|
1120
1692
|
interface ArchiveProxy {
|
|
1693
|
+
/** Identifies the archive's content across sessions; undefined when it cannot be identified. */
|
|
1694
|
+
readonly id?: string;
|
|
1121
1695
|
getEntries(): Promise<ArchiveEntry[]>;
|
|
1122
1696
|
}
|
|
1123
1697
|
|
|
@@ -1125,6 +1699,7 @@ declare class ArchiveAssetSource extends AssetSource implements ArchiveProxy {
|
|
|
1125
1699
|
readonly _archiveProxy: ArchiveProxy;
|
|
1126
1700
|
constructor(archiveProxy: ArchiveProxy);
|
|
1127
1701
|
static blob(blob: Blob): ArchiveAssetSource;
|
|
1702
|
+
get cacheId(): Maybe<string>;
|
|
1128
1703
|
getEntries(): Promise<ArchiveEntry[]>;
|
|
1129
1704
|
getEntry(path: string): Promise<Maybe<ArchiveEntry>>;
|
|
1130
1705
|
get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
|
|
@@ -1135,7 +1710,8 @@ declare class ArchiveAssetSource extends AssetSource implements ArchiveProxy {
|
|
|
1135
1710
|
declare class BrowserArchiveProxy implements ArchiveProxy {
|
|
1136
1711
|
readonly _blob: Blob;
|
|
1137
1712
|
readonly _reader: ZipReader<Blob>;
|
|
1138
|
-
|
|
1713
|
+
readonly id?: string;
|
|
1714
|
+
constructor(blob: Blob, id?: string);
|
|
1139
1715
|
getEntries(): Promise<ArchiveEntry[]>;
|
|
1140
1716
|
}
|
|
1141
1717
|
|
|
@@ -1213,27 +1789,84 @@ declare class Caching {
|
|
|
1213
1789
|
static readonly mergedModelCache: AsyncLoadingCache<CacheKey, Model>;
|
|
1214
1790
|
static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
|
|
1215
1791
|
static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
|
|
1792
|
+
static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
|
|
1793
|
+
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
1794
|
+
static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
|
|
1795
|
+
static readonly entityModelCache: AsyncLoadingCache<CacheKey, EntityModelFile>;
|
|
1796
|
+
static readonly entityTextureCache: AsyncLoadingCache<CacheKey, AssetKey>;
|
|
1797
|
+
static readonly entityAnimationCache: AsyncLoadingCache<CacheKey, EntityAnimationFile>;
|
|
1798
|
+
static readonly blockEntityIndexCache: AsyncLoadingCache<CacheKey, BlockEntityIndex>;
|
|
1799
|
+
private static createAssetCache;
|
|
1216
1800
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1217
1801
|
private static get all();
|
|
1218
1802
|
static clear(): void;
|
|
1219
1803
|
/**
|
|
1220
1804
|
* Clears every cache and stops its expiry timer.
|
|
1221
1805
|
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1806
|
+
* Expiry timers are unref'd in Node, so idle processes can exit without this cleanup.
|
|
1807
|
+
* Use {@link shutdown} to also stop requests and the shared Ticker.
|
|
1224
1808
|
*/
|
|
1225
1809
|
static end(): void;
|
|
1226
1810
|
static get cacheSizes(): {};
|
|
1227
1811
|
}
|
|
1228
1812
|
|
|
1813
|
+
/** Copies the nontransparent bounds without resizing the source; empty images become one transparent pixel. */
|
|
1814
|
+
declare function trimCanvas(source: CompatCanvas): CompatCanvas;
|
|
1815
|
+
|
|
1229
1816
|
declare class MineRenderError extends Error {
|
|
1230
1817
|
constructor(msg: any);
|
|
1231
1818
|
get name(): string;
|
|
1232
1819
|
}
|
|
1233
1820
|
|
|
1234
|
-
|
|
1821
|
+
interface SceneGLTFExportOptions {
|
|
1822
|
+
/** Returns a GLB ArrayBuffer instead of a glTF object. */
|
|
1823
|
+
binary?: boolean;
|
|
1824
|
+
/** Maximum width and height of each exported texture, in pixels. */
|
|
1825
|
+
maxTextureSize?: number;
|
|
1235
1826
|
}
|
|
1236
|
-
|
|
1827
|
+
/** Exports the visible meshes at their current poses without changing the source scene. */
|
|
1828
|
+
declare class SceneExporter {
|
|
1829
|
+
/** Returns OBJ geometry with normals and UVs; material files and textures are not included. */
|
|
1830
|
+
static toObj(root: Object3D): string;
|
|
1831
|
+
/** Returns PLY geometry with vertex colors and UVs; texture images are not included. */
|
|
1832
|
+
static toPLY(root: Object3D, options?: PLYExporterOptions): string | ArrayBuffer;
|
|
1833
|
+
/**
|
|
1834
|
+
* Exports a static glTF/GLB snapshot in a browser. Atlas textures and vertex tints are retained;
|
|
1835
|
+
* MineRender's custom directional lighting is not baked into the exported materials.
|
|
1836
|
+
*/
|
|
1837
|
+
static toGLTF(root: Object3D, options?: SceneGLTFExportOptions): Promise<Record<string, any> | ArrayBuffer>;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
declare class GuiHelper {
|
|
1841
|
+
static inventorySlot(slot: number | [number, number], origin?: [number, number], offset?: [number, number], rowSize?: number): [number, number];
|
|
1842
|
+
/** Creates crafting-table layers for ingredients and the result; stack counts are not drawn. */
|
|
1843
|
+
static recipe(recipe: GuiRecipe, options?: GuiRecipeOptions): GuiLayer[];
|
|
1844
|
+
}
|
|
1845
|
+
type GuiRecipeIngredientValue = string | {
|
|
1846
|
+
item: string;
|
|
1847
|
+
} | {
|
|
1848
|
+
tag: string;
|
|
1849
|
+
};
|
|
1850
|
+
type GuiRecipeIngredient = GuiRecipeIngredientValue | readonly GuiRecipeIngredientValue[];
|
|
1851
|
+
type GuiRecipe = ({
|
|
1852
|
+
type: "minecraft:crafting_shaped" | "crafting_shaped";
|
|
1853
|
+
pattern: readonly string[];
|
|
1854
|
+
key: Readonly<Record<string, GuiRecipeIngredient>>;
|
|
1855
|
+
} | {
|
|
1856
|
+
type: "minecraft:crafting_shapeless" | "crafting_shapeless";
|
|
1857
|
+
ingredients: readonly GuiRecipeIngredient[];
|
|
1858
|
+
}) & {
|
|
1859
|
+
result: {
|
|
1860
|
+
id: string;
|
|
1861
|
+
count?: number;
|
|
1862
|
+
} | {
|
|
1863
|
+
item: string;
|
|
1864
|
+
count?: number;
|
|
1865
|
+
};
|
|
1866
|
+
};
|
|
1867
|
+
interface GuiRecipeOptions {
|
|
1868
|
+
/** Selects a concrete item ID or model AssetKey for a tag or alternatives array. */
|
|
1869
|
+
resolveIngredient?: (ingredient: GuiRecipeIngredient) => string | AssetKey;
|
|
1237
1870
|
}
|
|
1238
1871
|
|
|
1239
1872
|
declare class OrbitControls {
|
|
@@ -1328,7 +1961,10 @@ declare class Renderer implements Disposable {
|
|
|
1328
1961
|
protected _frameInterval?: number;
|
|
1329
1962
|
protected _resizeListener?: () => void;
|
|
1330
1963
|
private _nextFrameTime?;
|
|
1964
|
+
private _running;
|
|
1965
|
+
private _inAnimationLoop;
|
|
1331
1966
|
private _disposed;
|
|
1967
|
+
private readonly _frameCallbacks;
|
|
1332
1968
|
private readonly _debugHelpers;
|
|
1333
1969
|
private readonly _eventDispatchers;
|
|
1334
1970
|
private readonly _changeListener;
|
|
@@ -1349,6 +1985,12 @@ declare class Renderer implements Disposable {
|
|
|
1349
1985
|
resize(width: number, height: number): void;
|
|
1350
1986
|
get dirty(): boolean;
|
|
1351
1987
|
set dirty(dirty: boolean);
|
|
1988
|
+
/**
|
|
1989
|
+
* Calls a synchronous animation update before each FPS-limited draw while started.
|
|
1990
|
+
* Subscriptions keep the scene drawing without manual dirty flags. Returns an unsubscribe function.
|
|
1991
|
+
* Registering the same callback twice has no effect. Image exports do not invoke callbacks.
|
|
1992
|
+
*/
|
|
1993
|
+
onFrame(callback: FrameCallback): () => void;
|
|
1352
1994
|
start(): void;
|
|
1353
1995
|
stop(): void;
|
|
1354
1996
|
/**
|
|
@@ -1358,7 +2000,16 @@ declare class Renderer implements Disposable {
|
|
|
1358
2000
|
*/
|
|
1359
2001
|
dispose(): void;
|
|
1360
2002
|
private animate;
|
|
1361
|
-
|
|
2003
|
+
private drawFrame;
|
|
2004
|
+
/**
|
|
2005
|
+
* Renders a fresh frame and returns an image data URL, including while the animation loop is stopped.
|
|
2006
|
+
* Trimming removes transparent borders; an empty image becomes one transparent pixel.
|
|
2007
|
+
* MIME type support and lossy quality (0–1) follow the canvas encoder.
|
|
2008
|
+
*/
|
|
2009
|
+
toImage(trim?: boolean, mime?: string, quality?: number): string;
|
|
2010
|
+
toObj(): string;
|
|
2011
|
+
toPLY(options?: PLYExporterOptions): string | ArrayBuffer;
|
|
2012
|
+
toGLTF(options?: SceneGLTFExportOptions): Promise<Record<string, any> | ArrayBuffer>;
|
|
1362
2013
|
protected get attachedToBody(): boolean;
|
|
1363
2014
|
protected get viewWidth(): number;
|
|
1364
2015
|
protected get viewHeight(): number;
|
|
@@ -1369,6 +2020,13 @@ declare class Renderer implements Disposable {
|
|
|
1369
2020
|
/** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
|
|
1370
2021
|
get controls(): Maybe<OrbitControls>;
|
|
1371
2022
|
}
|
|
2023
|
+
interface RendererFrame {
|
|
2024
|
+
/** Animation-loop timestamp in seconds, relative to the browser's performance time origin. */
|
|
2025
|
+
readonly time: number;
|
|
2026
|
+
/** Seconds since this callback's previous update; zero on its first update after subscribing or starting. */
|
|
2027
|
+
readonly delta: number;
|
|
2028
|
+
}
|
|
2029
|
+
type FrameCallback = (frame: RendererFrame) => void;
|
|
1372
2030
|
interface RendererOptions {
|
|
1373
2031
|
camera: CameraOptions;
|
|
1374
2032
|
render: RenderOptions;
|
|
@@ -1396,6 +2054,8 @@ interface CameraOptions {
|
|
|
1396
2054
|
interface RenderOptions {
|
|
1397
2055
|
/** Maximum draw rate (60 by default); zero or a negative value disables the limit. */
|
|
1398
2056
|
fpsLimit: number;
|
|
2057
|
+
/** Drawing-buffer pixels per CSS pixel (default 1); also scales toImage() output. */
|
|
2058
|
+
pixelRatio?: number;
|
|
1399
2059
|
stats: boolean;
|
|
1400
2060
|
antialias: boolean;
|
|
1401
2061
|
shade: boolean;
|
|
@@ -1420,17 +2080,21 @@ declare class SceneInspector {
|
|
|
1420
2080
|
protected readonly raycaster: Raycaster;
|
|
1421
2081
|
private readonly mouse;
|
|
1422
2082
|
private selectedObject?;
|
|
2083
|
+
private pointer?;
|
|
2084
|
+
private readonly listeners;
|
|
1423
2085
|
constructor(renderer: Renderer);
|
|
1424
2086
|
protected init(): void;
|
|
2087
|
+
dispose(): void;
|
|
1425
2088
|
findMeshChildren(from: Object3D, out?: Mesh[]): Mesh<three.BufferGeometry<three.NormalBufferAttributes>, three.Material | three.Material[], three.Object3DEventMap>[];
|
|
1426
|
-
onClick(event:
|
|
2089
|
+
onClick(event: MouseEvent): void;
|
|
1427
2090
|
appendTo(el: HTMLElement): void;
|
|
1428
2091
|
protected handleRaycasterObjects(intersections: Intersection[]): void;
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
protected
|
|
2092
|
+
private getIntersectionInstance;
|
|
2093
|
+
selectObject(targetObject: Object3D, targetIntersection?: Intersection, instance?: Maybe<InstanceReference<SceneObject>>): void;
|
|
2094
|
+
protected redraw(targetObject: Object3D, targetIntersection?: Intersection, instance?: InstanceReference<SceneObject>): void;
|
|
2095
|
+
protected addControls(object: Object3D, intersection?: Intersection, instance?: InstanceReference<SceneObject>): void;
|
|
1432
2096
|
protected addInfoLine(name: string, id: string, value: any): HTMLElement;
|
|
1433
|
-
protected addObjectControls(target: Object3D, intersection: Maybe<Intersection>, container: HTMLElement): void;
|
|
2097
|
+
protected addObjectControls(target: Object3D, intersection: Maybe<Intersection>, container: HTMLElement, instance?: InstanceReference<SceneObject>): void;
|
|
1434
2098
|
protected buttonControl(name: string, id: string, click: () => void): HTMLElement;
|
|
1435
2099
|
protected selectControl(name: string, id: string, options: string[], change: (v: string) => void): HTMLElement;
|
|
1436
2100
|
protected toggleControl(name: string, id: string, val: boolean, change: (v: boolean) => void): HTMLElement;
|
|
@@ -1438,13 +2102,15 @@ declare class SceneInspector {
|
|
|
1438
2102
|
protected separator(name?: string): HTMLElement;
|
|
1439
2103
|
}
|
|
1440
2104
|
|
|
1441
|
-
declare class SceneStatsDisplay {
|
|
2105
|
+
declare class SceneStatsDisplay implements Disposable {
|
|
1442
2106
|
readonly renderer: Renderer;
|
|
1443
2107
|
readonly statsContainer: HTMLDivElement;
|
|
1444
2108
|
private readonly lines;
|
|
2109
|
+
private interval?;
|
|
1445
2110
|
constructor(renderer: Renderer);
|
|
1446
2111
|
protected init(): void;
|
|
1447
2112
|
appendTo(el: HTMLElement): void;
|
|
2113
|
+
dispose(): void;
|
|
1448
2114
|
add(line?: StatLine): void;
|
|
1449
2115
|
}
|
|
1450
2116
|
declare class StatLine {
|
|
@@ -1459,34 +2125,33 @@ declare class StatLine {
|
|
|
1459
2125
|
update(): void;
|
|
1460
2126
|
}
|
|
1461
2127
|
|
|
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
2128
|
type SkinGeometries = Record<SkinPart, TripleArray>;
|
|
1483
2129
|
declare const classicSkinGeometries: SkinGeometries;
|
|
1484
2130
|
declare const slimSkinGeometries: SkinGeometries;
|
|
1485
2131
|
|
|
2132
|
+
declare class SkinImage {
|
|
2133
|
+
static getData(src: string): Promise<ImageData>;
|
|
2134
|
+
private static decodePng;
|
|
2135
|
+
}
|
|
2136
|
+
|
|
1486
2137
|
type SkinTextureCoordinates = Record<SkinPart, ModelFaces>;
|
|
1487
2138
|
declare const classicSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
|
|
1488
2139
|
declare const slimSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
|
|
1489
2140
|
|
|
2141
|
+
interface SkinTexture {
|
|
2142
|
+
material: MeshBasicMaterial;
|
|
2143
|
+
slim: boolean;
|
|
2144
|
+
legacy: boolean;
|
|
2145
|
+
}
|
|
2146
|
+
declare class SkinTextures {
|
|
2147
|
+
static get(src: string, legacy?: boolean): Promise<SkinTexture>;
|
|
2148
|
+
static getCape(src: string, layout?: CapeLayout): Promise<MeshBasicMaterial>;
|
|
2149
|
+
private static createMaterial;
|
|
2150
|
+
private static isSlim;
|
|
2151
|
+
private static normalizeLegacy;
|
|
2152
|
+
private static makeBaseOpaque;
|
|
2153
|
+
}
|
|
2154
|
+
|
|
1490
2155
|
declare class Skins {
|
|
1491
2156
|
static fromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
|
|
1492
2157
|
static fromUuid(uuid: string): Promise<Maybe<string>>;
|
|
@@ -1495,8 +2160,11 @@ declare class Skins {
|
|
|
1495
2160
|
static capeFromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
|
|
1496
2161
|
static capeFromUuid(uuid: string): Promise<Maybe<string>>;
|
|
1497
2162
|
static capeFromUsername(username: string): Promise<Maybe<string>>;
|
|
1498
|
-
static
|
|
2163
|
+
/** Returns a full static cape texture for a username or UUID. */
|
|
2164
|
+
static capeFromCapesDev(player: string, capeType?: string): Promise<Maybe<string>>;
|
|
1499
2165
|
private static usernameToUuid;
|
|
2166
|
+
private static usernameToUuidMcProxy;
|
|
2167
|
+
/** @deprecated **/
|
|
1500
2168
|
private static usernameToUuidSkinProxy;
|
|
1501
2169
|
private static usernameToUuidMineTools;
|
|
1502
2170
|
private static getProfileFromMinetools;
|
|
@@ -1506,11 +2174,23 @@ declare class Skins {
|
|
|
1506
2174
|
private static getCrafatarCapeUrl;
|
|
1507
2175
|
private static getMcHeadsSkinUrl;
|
|
1508
2176
|
private static getMineSkinPlayerSkinUrl;
|
|
2177
|
+
/** @deprecated **/
|
|
1509
2178
|
private static getSkinProxySkinUrl;
|
|
2179
|
+
/** @deprecated **/
|
|
1510
2180
|
private static getSkinProxyCapeUrl;
|
|
2181
|
+
private static getMcProxySkinUrl;
|
|
2182
|
+
private static getMcProxyCapeUrl;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
declare class Colormaps {
|
|
2186
|
+
/** Samples the selected resource pack's grass colormap using Minecraft's climate coordinates. */
|
|
2187
|
+
static grassColor(origin?: AssetKey, temperature?: number, downfall?: number): Promise<number>;
|
|
1511
2188
|
}
|
|
1512
2189
|
|
|
1513
2190
|
declare class TextureLoader {
|
|
2191
|
+
private static readonly failedTextures;
|
|
2192
|
+
/** Reports whether image loading failed, so cached textures can be retried. */
|
|
2193
|
+
static hasFailed(texture: Texture): boolean;
|
|
1514
2194
|
protected static createTexture(): Texture;
|
|
1515
2195
|
static loadInBackground(src: string, format?: PixelFormat, rotation?: number): Texture;
|
|
1516
2196
|
static load(src: string, format?: PixelFormat, rotation?: number): Texture;
|
|
@@ -1532,61 +2212,155 @@ declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): Bu
|
|
|
1532
2212
|
declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
|
|
1533
2213
|
declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
|
|
1534
2214
|
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
2215
|
+
declare class ChunkData {
|
|
2216
|
+
private readonly indices;
|
|
2217
|
+
private readonly palette;
|
|
2218
|
+
private readonly paletteIds;
|
|
2219
|
+
private readonly freeIds;
|
|
2220
|
+
private readonly nbt;
|
|
2221
|
+
get(index: number): Maybe<Block>;
|
|
2222
|
+
snapshot(index: number): Maybe<() => Block>;
|
|
2223
|
+
set(index: number, block?: Block): void;
|
|
2224
|
+
clear(): void;
|
|
2225
|
+
static isAir(block: Maybe<Block>): boolean;
|
|
2226
|
+
private static copyBlock;
|
|
2227
|
+
private static validateIndex;
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
type RegionInput = Uint8Array | ArrayBuffer;
|
|
2231
|
+
interface AnvilRegion {
|
|
2232
|
+
chunks: AnvilChunk[];
|
|
2233
|
+
}
|
|
2234
|
+
interface AnvilChunk {
|
|
2235
|
+
x: number;
|
|
2236
|
+
z: number;
|
|
2237
|
+
dataVersion?: number;
|
|
2238
|
+
sections: {
|
|
2239
|
+
y: number;
|
|
2240
|
+
data: ChunkData;
|
|
2241
|
+
}[];
|
|
2242
|
+
entities?: MultiBlockEntity[];
|
|
2243
|
+
}
|
|
2244
|
+
declare class AnvilParser {
|
|
2245
|
+
static getChunkList(data: RegionInput): {
|
|
2246
|
+
x: number;
|
|
2247
|
+
z: number;
|
|
2248
|
+
}[];
|
|
2249
|
+
static parse(data: RegionInput): Promise<AnvilRegion>;
|
|
2250
|
+
static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
|
|
2251
|
+
private static bytes;
|
|
2252
|
+
private static locations;
|
|
2253
|
+
private static readChunk;
|
|
2254
|
+
private static compounds;
|
|
2255
|
+
private static integer;
|
|
2256
|
+
private static block;
|
|
2257
|
+
private static unpack;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
interface BlockInfo<SectionMeshing extends boolean = false> {
|
|
2261
|
+
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
2262
|
+
readonly block: Block;
|
|
2263
|
+
/** Merged terrain has no individual render object in section-meshing mode. */
|
|
2264
|
+
object: SectionMeshing extends false ? BlockObject : BlockObject | undefined;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
interface SectionMeshTemplate {
|
|
2268
|
+
geometry: BufferGeometry;
|
|
2269
|
+
atlas: TextureAtlas;
|
|
2270
|
+
cullFaces: readonly number[];
|
|
2271
|
+
}
|
|
2272
|
+
interface SectionMeshEntry {
|
|
2273
|
+
index: number;
|
|
2274
|
+
template: SectionMeshTemplate;
|
|
2275
|
+
cullMask: number;
|
|
2276
|
+
}
|
|
2277
|
+
declare class SectionMesh extends Group {
|
|
2278
|
+
private readonly ownedMeshes;
|
|
2279
|
+
static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
|
|
2280
|
+
dispose(): void;
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
declare class SectionModels {
|
|
2284
|
+
readonly maxAtlasSize: number;
|
|
2285
|
+
private states;
|
|
2286
|
+
private models;
|
|
2287
|
+
private readonly templates;
|
|
2288
|
+
constructor(maxAtlasSize?: number);
|
|
2289
|
+
get(blockState: BlockState, properties?: BlockStateProperties): Promise<SectionMeshTemplate | undefined>;
|
|
2290
|
+
private prepare;
|
|
2291
|
+
clear(): void;
|
|
1538
2292
|
}
|
|
1539
2293
|
|
|
1540
|
-
declare class Chunk {
|
|
2294
|
+
declare class Chunk<SectionMeshing extends boolean = false> {
|
|
2295
|
+
private readonly onBlocksChanged?;
|
|
2296
|
+
private readonly sectionModels?;
|
|
1541
2297
|
readonly scene: MineRenderScene;
|
|
1542
2298
|
readonly x: number;
|
|
1543
2299
|
readonly y: number;
|
|
1544
2300
|
readonly z: number;
|
|
1545
|
-
private readonly
|
|
1546
|
-
private readonly
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
2301
|
+
private readonly data;
|
|
2302
|
+
private readonly renderedBlocks;
|
|
2303
|
+
private readonly sectionBlocks;
|
|
2304
|
+
private sectionMesh?;
|
|
2305
|
+
private meshDirty;
|
|
2306
|
+
constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
|
|
2307
|
+
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
2308
|
+
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
2309
|
+
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
1551
2310
|
/**
|
|
1552
2311
|
* Set block at a _world_ position
|
|
1553
2312
|
*/
|
|
1554
|
-
setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo
|
|
1555
|
-
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo
|
|
1556
|
-
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo
|
|
2313
|
+
setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2314
|
+
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2315
|
+
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
1557
2316
|
/**
|
|
1558
|
-
* Set block at
|
|
2317
|
+
* Set a block at integer chunk-local coordinates from 0 to 15.
|
|
1559
2318
|
*/
|
|
1560
|
-
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3): Promise<Maybe<BlockInfo
|
|
1561
|
-
|
|
2319
|
+
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2320
|
+
isOccludingAt(pos: Vector3): boolean;
|
|
2321
|
+
setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
|
|
2322
|
+
rebuildSectionMesh(): void;
|
|
2323
|
+
clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
|
|
1562
2324
|
dispose(): Promise<void>;
|
|
2325
|
+
static isAir(block: Maybe<Block>): boolean;
|
|
1563
2326
|
static chunkPosToBlockIndex(pos: Vector3): number;
|
|
1564
2327
|
worldPosToChunkPos(pos: Vector3): Vector3;
|
|
1565
2328
|
chunkPosToWorldPos(pos: Vector3): Vector3;
|
|
1566
2329
|
}
|
|
1567
2330
|
|
|
1568
|
-
declare class MineRenderWorld {
|
|
2331
|
+
declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
1569
2332
|
readonly scene: MineRenderScene;
|
|
1570
|
-
private _size;
|
|
1571
|
-
private _blockSize;
|
|
1572
2333
|
private readonly _chunks;
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
2334
|
+
private readonly sectionModels?;
|
|
2335
|
+
private readonly pendingCulling;
|
|
2336
|
+
private culling?;
|
|
2337
|
+
constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
|
|
2338
|
+
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
2339
|
+
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
2340
|
+
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
2341
|
+
setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2342
|
+
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2343
|
+
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2344
|
+
private placeBlock;
|
|
1580
2345
|
placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
|
|
2346
|
+
private placeBlocks;
|
|
2347
|
+
/** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
|
|
2348
|
+
placeChunk(chunk: AnvilChunk, executor?: BatchedExecutor): Promise<void>;
|
|
1581
2349
|
clear(): Promise<void>;
|
|
2350
|
+
private updateCulling;
|
|
1582
2351
|
private getOrCreateChunkAt;
|
|
1583
|
-
getChunkAt(pos: Vector3): Maybe<Chunk
|
|
2352
|
+
getChunkAt(pos: Vector3): Maybe<Chunk<SectionMeshing>>;
|
|
1584
2353
|
static worldToScenePosition(pos: Vector3): Vector3;
|
|
1585
2354
|
static sceneToWorldPosition(pos: Vector3): Vector3;
|
|
1586
|
-
worldPosToChunkIndex(pos: Vector3): number;
|
|
1587
2355
|
worldPosToChunkKey(pos: Vector3): string;
|
|
1588
2356
|
validatePosBounds(pos: Vector3): void;
|
|
1589
2357
|
}
|
|
2358
|
+
interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
|
|
2359
|
+
/** Merge static opaque cubes into section meshes. Merged blocks have no individual object. */
|
|
2360
|
+
sectionMeshing?: SectionMeshing;
|
|
2361
|
+
/** Maximum width and height of each section atlas page, in pixels. */
|
|
2362
|
+
maxAtlasSize?: number;
|
|
2363
|
+
}
|
|
1590
2364
|
|
|
1591
2365
|
/**
|
|
1592
2366
|
* {@link EnvProvider} backed by the DOM. Uses nothing outside of standard browser APIs and
|
|
@@ -1620,8 +2394,8 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
1620
2394
|
*
|
|
1621
2395
|
* `image-size` pulls in `fs`/`path` at module scope, so it can only live in the Node build.
|
|
1622
2396
|
* Everything MineRender loads is a PNG in practice; GIF and JPEG are handled as a courtesy and
|
|
1623
|
-
* anything else falls through to an empty result
|
|
2397
|
+
* anything else falls through to an empty result, which ImageLoader rejects.
|
|
1624
2398
|
*/
|
|
1625
2399
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
1626
2400
|
|
|
1627
|
-
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,
|
|
2401
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, 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, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiTextureLayer, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, 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, createFluidGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
|