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