minerender 2.1.0-alpha.75 → 2.1.0-alpha.77
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 +57 -0
- package/dist/browser/index.d.mts +594 -14
- package/dist/browser/index.d.ts +594 -14
- package/dist/browser/index.js +965 -312
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +933 -280
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +1708 -1044
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +594 -14
- package/dist/node/index.d.ts +594 -14
- package/dist/node/index.js +966 -311
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +932 -279
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as three 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, DataTexture, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points
|
|
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, Group, DataTexture, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
|
|
3
3
|
import * as nodeCanvas from 'canvas';
|
|
4
4
|
import { ImageData as ImageData$1, CanvasRenderingContext2D } from 'canvas';
|
|
5
5
|
import { Buffer } from 'buffer';
|
|
@@ -12,6 +12,7 @@ import Stats from 'stats.js';
|
|
|
12
12
|
import { EffectComposer } from 'postprocessing';
|
|
13
13
|
import { LocalStorage } from 'node-persist';
|
|
14
14
|
|
|
15
|
+
/** Advances a texture animation by one tick. Return `false` when its pixels have not changed. */
|
|
15
16
|
interface AnimatorFunction {
|
|
16
17
|
(): boolean | void;
|
|
17
18
|
}
|
|
@@ -43,6 +44,7 @@ declare enum CubeFaceIndex {
|
|
|
43
44
|
declare const CUBE_FACES: CubeFace[];
|
|
44
45
|
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]];
|
|
45
46
|
|
|
47
|
+
/** An object that can release the resources it owns. */
|
|
46
48
|
interface Disposable {
|
|
47
49
|
dispose(): void;
|
|
48
50
|
}
|
|
@@ -50,7 +52,9 @@ declare function isDisposable(obj: any): obj is Disposable;
|
|
|
50
52
|
|
|
51
53
|
type CompatImage = HTMLImageElement | nodeCanvas.Image;
|
|
52
54
|
type CompatCanvas = HTMLCanvasElement | nodeCanvas.Canvas;
|
|
55
|
+
/** Creates an image through the active environment provider. Dimensions are in pixels. */
|
|
53
56
|
declare function createImage(width?: number, height?: number): CompatImage;
|
|
57
|
+
/** Creates a browser or Node canvas through the active environment provider, sized in pixels. */
|
|
54
58
|
declare function createCanvas(width: number, height: number): CompatCanvas;
|
|
55
59
|
|
|
56
60
|
/**
|
|
@@ -64,6 +68,7 @@ declare abstract class PersistentCache<B = unknown> {
|
|
|
64
68
|
readonly backing: B;
|
|
65
69
|
/** Bump to invalidate every persisted entry. */
|
|
66
70
|
static readonly VERSION = 2;
|
|
71
|
+
/** Opens a named store in the active environment using the current cache schema version. */
|
|
67
72
|
static open(name: string): PersistentCache;
|
|
68
73
|
protected constructor(backing: B);
|
|
69
74
|
abstract get<T>(key: string): Promise<T>;
|
|
@@ -116,6 +121,7 @@ declare class Env {
|
|
|
116
121
|
static get provider(): EnvProvider;
|
|
117
122
|
}
|
|
118
123
|
|
|
124
|
+
/** A canvas-backed image with dimensions and a context for reading pixel regions. */
|
|
119
125
|
interface ExtractableImageData {
|
|
120
126
|
readonly data: CanvasImageData;
|
|
121
127
|
readonly width: number;
|
|
@@ -123,10 +129,12 @@ interface ExtractableImageData {
|
|
|
123
129
|
}
|
|
124
130
|
|
|
125
131
|
type CacheKey = string;
|
|
132
|
+
/** Source URL used to identify cached image bytes and pixels. */
|
|
126
133
|
interface RawImageKey {
|
|
127
134
|
src: string;
|
|
128
135
|
}
|
|
129
136
|
declare function serializeImageKey(key: RawImageKey): string;
|
|
137
|
+
/** Box dimensions in scene units and optional normalized UVs in Three.js face order. */
|
|
130
138
|
interface BoxGeometryKey {
|
|
131
139
|
width: number;
|
|
132
140
|
height: number;
|
|
@@ -134,32 +142,39 @@ interface BoxGeometryKey {
|
|
|
134
142
|
uv?: number[];
|
|
135
143
|
}
|
|
136
144
|
declare function serializeBoxGeometryKey(key: BoxGeometryKey): string;
|
|
145
|
+
/** Settings passed to {@link Textures.getImage}. Texture rotation uses radians. */
|
|
137
146
|
interface TextureKey extends RawImageKey {
|
|
138
147
|
format?: PixelFormat;
|
|
139
148
|
rotation?: number;
|
|
140
149
|
}
|
|
141
150
|
declare function serializeTextureKey(key: TextureKey): string;
|
|
151
|
+
/** Texture and transparency settings passed to {@link Materials.getImage}. */
|
|
142
152
|
interface MaterialKey {
|
|
143
153
|
texture: TextureKey;
|
|
144
154
|
transparent?: boolean;
|
|
145
155
|
}
|
|
146
156
|
declare function serializeMaterialKey(key: MaterialKey): string;
|
|
157
|
+
/** Geometry and material settings passed to {@link Meshes.createBox} or {@link Meshes.getBox}. */
|
|
147
158
|
interface MeshKey {
|
|
148
159
|
geometry: BoxGeometryKey;
|
|
149
160
|
material: MaterialKey;
|
|
150
161
|
}
|
|
151
162
|
declare function serializeMeshKey(key: MeshKey): string;
|
|
152
163
|
|
|
164
|
+
/** Creates box geometry with optional face UVs and caches it by dimensions and UV values. */
|
|
153
165
|
declare class Geometries {
|
|
154
166
|
static createBox(key: BoxGeometryKey): BoxGeometry;
|
|
167
|
+
/** Returns shared geometry. Use {@link createBox} when the caller needs to modify or dispose it independently. */
|
|
155
168
|
static getBox(key: BoxGeometryKey): BoxGeometry;
|
|
156
169
|
}
|
|
157
170
|
|
|
171
|
+
/** Produces a string representation, such as an asset cache key. */
|
|
158
172
|
interface Serializable {
|
|
159
173
|
serialize(): string;
|
|
160
174
|
}
|
|
161
175
|
|
|
162
176
|
type AssetType = "models" | "textures" | "blockstates" | string;
|
|
177
|
+
/** A Minecraft namespace and path, such as `minecraft` and `zombie`. */
|
|
163
178
|
declare class BasicAssetKey implements Serializable {
|
|
164
179
|
readonly namespace: string;
|
|
165
180
|
readonly path: string;
|
|
@@ -169,6 +184,7 @@ declare class BasicAssetKey implements Serializable {
|
|
|
169
184
|
toString(): string;
|
|
170
185
|
serialize(): string;
|
|
171
186
|
}
|
|
187
|
+
/** Locates an asset by namespace, directory, extension, and optional asset root. */
|
|
172
188
|
declare class AssetKey extends BasicAssetKey {
|
|
173
189
|
readonly namespace: string;
|
|
174
190
|
readonly path: string;
|
|
@@ -178,28 +194,52 @@ declare class AssetKey extends BasicAssetKey {
|
|
|
178
194
|
extension: ".json" | ".png" | string;
|
|
179
195
|
root?: string | undefined;
|
|
180
196
|
readonly isAssetKey: true;
|
|
197
|
+
/**
|
|
198
|
+
* Creates a key from separate path components. Use {@link parse} for a combined reference.
|
|
199
|
+
*
|
|
200
|
+
* @param assetType - Asset directory, such as `models`, `textures`, or `blockstates`.
|
|
201
|
+
* @param type - Subdirectory, such as `block` or `item`.
|
|
202
|
+
* @param rootType - Top-level directory, usually `assets` or `data`.
|
|
203
|
+
* @param root - Base URL override for hosted asset sources.
|
|
204
|
+
*/
|
|
181
205
|
constructor(namespace: string, path: string, assetType?: AssetType | undefined, type?: string | undefined, rootType?: "assets" | "data" | string, extension?: ".json" | ".png" | string, root?: string | undefined);
|
|
206
|
+
/**
|
|
207
|
+
* Parses an asset reference such as `minecraft:block/stone`.
|
|
208
|
+
* A missing namespace defaults to the origin's namespace or `minecraft`.
|
|
209
|
+
*
|
|
210
|
+
* @param assetType - Asset category, such as `models` or `textures`.
|
|
211
|
+
* @param str - Path with an optional namespace and file extension.
|
|
212
|
+
* @param origin - Supplies the asset root, default namespace, and non-texture extension.
|
|
213
|
+
* @returns A key with the matching extension removed from its path. Textures use `.png`;
|
|
214
|
+
* other assets use the origin's extension or `.json`.
|
|
215
|
+
*/
|
|
182
216
|
static parse(assetType: AssetType, str: string, origin?: AssetKey): AssetKey;
|
|
183
217
|
toString(): string;
|
|
218
|
+
/** Joins the type subdirectory and path without adding a namespace or file extension. */
|
|
184
219
|
getFullPath(): string;
|
|
185
220
|
toNamespacedString(): string;
|
|
221
|
+
/** Returns a cache identifier that includes the explicit root or {@link AssetLoader.ROOT}. */
|
|
186
222
|
serialize(): string;
|
|
187
223
|
}
|
|
188
224
|
declare function isBasicAssetKey(obj: any): obj is BasicAssetKey;
|
|
189
225
|
declare function isAssetKey(obj: any): obj is AssetKey;
|
|
190
226
|
|
|
227
|
+
/** Loaded data with an optional namespace-and-path identity. */
|
|
191
228
|
interface BasicMinecraftAsset {
|
|
192
229
|
key?: BasicAssetKey;
|
|
193
230
|
}
|
|
231
|
+
/** Loaded data that can retain its full source key for related asset lookups. */
|
|
194
232
|
interface MinecraftAsset extends BasicMinecraftAsset {
|
|
195
233
|
key?: AssetKey;
|
|
196
234
|
}
|
|
197
235
|
|
|
236
|
+
/** A hosted `_list.json` directory index used by asset-listing APIs. */
|
|
198
237
|
interface ListAsset extends MinecraftAsset {
|
|
199
238
|
directories: string[];
|
|
200
239
|
files: string[];
|
|
201
240
|
}
|
|
202
241
|
|
|
242
|
+
/** One selected draw, combining geometry, texture, and material settings. */
|
|
203
243
|
interface EntityLayer {
|
|
204
244
|
key: BasicAssetKey;
|
|
205
245
|
texture?: AssetKey;
|
|
@@ -209,6 +249,7 @@ interface EntityLayer {
|
|
|
209
249
|
/** Label of the state colour that multiplies the texture, from the pass that selected this draw. */
|
|
210
250
|
tint?: string;
|
|
211
251
|
}
|
|
252
|
+
/** Selected entity data returned by {@link Entities.getEntity} for rendering. */
|
|
212
253
|
interface EntityModel extends EntityLayer {
|
|
213
254
|
id: string;
|
|
214
255
|
/** Root transform from the dataset; see {@link EntityTransformOp}. */
|
|
@@ -219,6 +260,7 @@ interface EntityModel extends EntityLayer {
|
|
|
219
260
|
*/
|
|
220
261
|
layers?: Record<string, EntityLayer>;
|
|
221
262
|
}
|
|
263
|
+
/** Dataset file containing all geometry layers and optional extra render passes. */
|
|
222
264
|
interface EntityModelFile extends MinecraftAsset {
|
|
223
265
|
id: string;
|
|
224
266
|
transform?: EntityTransformOp[];
|
|
@@ -228,6 +270,7 @@ interface EntityModelFile extends MinecraftAsset {
|
|
|
228
270
|
}
|
|
229
271
|
/** Vanilla render type of a draw; see the dataset README for the mode table. */
|
|
230
272
|
type EntityRenderMode = "cutout" | "cutout_cull" | "cutout_z_offset" | "solid" | "translucent" | "translucent_emissive" | "eyes" | "energy_swirl" | "breeze_wind" | "water_mask";
|
|
273
|
+
/** An extra draw of a geometry layer, optionally enabled by an entity-state label. */
|
|
231
274
|
interface EntityModelPass {
|
|
232
275
|
/** Geometry layer of the same file; a pass on `main` draws that geometry again. */
|
|
233
276
|
layer: string;
|
|
@@ -252,6 +295,7 @@ type EntityTransformOp = {
|
|
|
252
295
|
} | {
|
|
253
296
|
rotate: [number, number, number];
|
|
254
297
|
};
|
|
298
|
+
/** A named geometry tree with texture dimensions in pixels and an optional default texture path. */
|
|
255
299
|
interface EntityModelLayer {
|
|
256
300
|
texture: [number, number];
|
|
257
301
|
textureLocation?: string;
|
|
@@ -259,6 +303,7 @@ interface EntityModelLayer {
|
|
|
259
303
|
render?: EntityRenderMode;
|
|
260
304
|
root: EntityModelPart;
|
|
261
305
|
}
|
|
306
|
+
/** A named part's baked pose and children. Offsets use model units and rotations use radians. */
|
|
262
307
|
interface EntityModelPart {
|
|
263
308
|
pose: {
|
|
264
309
|
offset: [number, number, number];
|
|
@@ -269,6 +314,7 @@ interface EntityModelPart {
|
|
|
269
314
|
cubes: EntityModelCube[];
|
|
270
315
|
children: Record<string, EntityModelPart>;
|
|
271
316
|
}
|
|
317
|
+
/** A part's cuboid in model units, with a texture origin in pixels and optional per-axis growth. */
|
|
272
318
|
interface EntityModelCube {
|
|
273
319
|
origin: [number, number, number];
|
|
274
320
|
size: [number, number, number];
|
|
@@ -277,7 +323,9 @@ interface EntityModelCube {
|
|
|
277
323
|
mirror?: boolean;
|
|
278
324
|
}
|
|
279
325
|
|
|
326
|
+
/** Creates Minecraft model, entity, and GUI materials, with shared caches for image materials. */
|
|
280
327
|
declare class Materials {
|
|
328
|
+
/** Shared checkerboard material, created on first access. */
|
|
281
329
|
static get MISSING_TEXTURE(): Material;
|
|
282
330
|
static createImage(key: MaterialKey): Material;
|
|
283
331
|
static createBasicCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean): Material;
|
|
@@ -291,17 +339,22 @@ declare class Materials {
|
|
|
291
339
|
* whether the geometry gets inward faces.
|
|
292
340
|
*/
|
|
293
341
|
static createEntityCanvasMaterial(canvas: HTMLCanvasElement, mode?: EntityRenderMode, tint?: ColorRepresentation): MeshBasicMaterial;
|
|
342
|
+
/** Creates an unlit, transparent GUI material without depth writes or tone mapping. */
|
|
294
343
|
static createGuiCanvasMaterial(canvas: HTMLCanvasElement): MeshBasicMaterial;
|
|
295
344
|
static createShadedCanvasMaterial(canvas: HTMLCanvasElement, transparent?: boolean, shade?: boolean, boundUvs?: boolean): Material;
|
|
345
|
+
/** Returns a shared image material. Use {@link createImage} for a separate material instance. */
|
|
296
346
|
static getImage(key: MaterialKey): Material;
|
|
297
347
|
static needsUpdate(mat: Material): void;
|
|
298
348
|
}
|
|
299
349
|
|
|
350
|
+
/** Creates box meshes from shared geometry and image materials. */
|
|
300
351
|
declare class Meshes {
|
|
301
352
|
static createBox(key: MeshKey): Mesh;
|
|
353
|
+
/** Returns a shared Mesh object. Use {@link createBox} for a mesh with its own transform and parent. */
|
|
302
354
|
static getBox(key: MeshKey): Mesh;
|
|
303
355
|
}
|
|
304
356
|
|
|
357
|
+
/** Texture and culling settings for one cuboid face. Java model UVs use Minecraft's 0–16 texture space. */
|
|
305
358
|
interface ElementFace {
|
|
306
359
|
uv: QuadArray;
|
|
307
360
|
mappedUv?: QuadArray;
|
|
@@ -315,6 +368,7 @@ interface FromTo {
|
|
|
315
368
|
from: TripleArray;
|
|
316
369
|
to: TripleArray;
|
|
317
370
|
}
|
|
371
|
+
/** A cuboid in model units, where 16 units equal one block. */
|
|
318
372
|
interface ModelElement extends FromTo {
|
|
319
373
|
rotation?: ElementRotation;
|
|
320
374
|
shade?: boolean;
|
|
@@ -322,6 +376,7 @@ interface ModelElement extends FromTo {
|
|
|
322
376
|
mappedUv?: number[];
|
|
323
377
|
}
|
|
324
378
|
type ModelFaces = Partial<Record<CubeFace, Partial<ElementFace>>>;
|
|
379
|
+
/** Rotates one cuboid around an origin in model units, using an angle in degrees. */
|
|
325
380
|
interface ElementRotation {
|
|
326
381
|
origin: TripleArray;
|
|
327
382
|
axis: Axis;
|
|
@@ -347,14 +402,17 @@ declare enum GuiLight {
|
|
|
347
402
|
SIDE = "side"
|
|
348
403
|
}
|
|
349
404
|
|
|
405
|
+
/** Fetch settings passed to {@link Requests.genericRequest} or {@link Requests.mcAssetRequest}. */
|
|
350
406
|
interface RequestConfig extends RequestInit {
|
|
351
407
|
url: string;
|
|
352
408
|
/** Prepended to relative URLs, preserving any path in the base URL. */
|
|
353
409
|
baseURL?: string;
|
|
354
410
|
/** Timeout per attempt in milliseconds, including body reading. Defaults to 5000; 0 disables it. */
|
|
355
411
|
timeout?: number;
|
|
412
|
+
/** Response-body decoding. Defaults to `json`. */
|
|
356
413
|
responseType?: "json" | "arraybuffer";
|
|
357
414
|
}
|
|
415
|
+
/** A decoded response body with the HTTP status, native headers, and final URL. */
|
|
358
416
|
interface RequestResponse<T = any> {
|
|
359
417
|
data: T;
|
|
360
418
|
status: number;
|
|
@@ -363,16 +421,21 @@ interface RequestResponse<T = any> {
|
|
|
363
421
|
/** Final URL after redirects. */
|
|
364
422
|
url: string;
|
|
365
423
|
}
|
|
424
|
+
/** An HTTP or network failure, with response details or an underlying cause when available. */
|
|
366
425
|
declare class RequestError extends Error {
|
|
367
426
|
readonly response?: RequestResponse<undefined> | undefined;
|
|
368
427
|
readonly cause?: unknown;
|
|
369
428
|
constructor(message: string, response?: RequestResponse<undefined> | undefined, cause?: unknown);
|
|
370
429
|
}
|
|
430
|
+
/** Shared Fetch queues with concurrency limits, cancellation, timeouts, and bounded retries for GET requests. */
|
|
371
431
|
declare class Requests {
|
|
372
432
|
private static genericQueue;
|
|
373
433
|
private static mcAssetRequestQueue;
|
|
434
|
+
/** Queues a general request. Set `request.signal` to cancel it and `request.timeout` to limit each attempt. */
|
|
374
435
|
static genericRequest(request: RequestConfig): Promise<RequestResponse>;
|
|
436
|
+
/** Queues a request separately from general traffic, using the configured asset base URL for relative paths. */
|
|
375
437
|
static mcAssetRequest(request: RequestConfig): Promise<RequestResponse>;
|
|
438
|
+
/** Sets the base URL for relative asset requests. Use {@link AssetLoader.setVersion} to change Minecraft versions. */
|
|
376
439
|
static setMcAssetRoot(root: string): void;
|
|
377
440
|
/** Counts unsettled calls, including retry delays and requests still running after shutdown. */
|
|
378
441
|
static get queueSizes(): {
|
|
@@ -387,6 +450,7 @@ declare class Requests {
|
|
|
387
450
|
static end(): void;
|
|
388
451
|
}
|
|
389
452
|
|
|
453
|
+
/** Provides pixel and frame access to a canvas-backed image. Simple frame helpers assume a vertical strip of squares. */
|
|
390
454
|
declare class WrappedImage {
|
|
391
455
|
readonly dta: ExtractableImageData;
|
|
392
456
|
constructor(dta: ExtractableImageData);
|
|
@@ -395,6 +459,7 @@ declare class WrappedImage {
|
|
|
395
459
|
get width(): number;
|
|
396
460
|
get height(): number;
|
|
397
461
|
get hasTransparency(): boolean;
|
|
462
|
+
/** Whether the dimensions form a vertical strip of square frames, without consulting `.mcmeta`. */
|
|
398
463
|
get animated(): boolean;
|
|
399
464
|
get frameWidth(): number;
|
|
400
465
|
get frameHeight(): number;
|
|
@@ -405,6 +470,7 @@ declare class WrappedImage {
|
|
|
405
470
|
getFrameSectionData(frame: number): ImageData$1;
|
|
406
471
|
}
|
|
407
472
|
|
|
473
|
+
/** Encoded image bytes with dimensions and format detected from the file header. */
|
|
408
474
|
interface ImageInfo {
|
|
409
475
|
src?: string;
|
|
410
476
|
width: number;
|
|
@@ -412,15 +478,21 @@ interface ImageInfo {
|
|
|
412
478
|
type?: string;
|
|
413
479
|
data: Buffer;
|
|
414
480
|
}
|
|
481
|
+
/** Fetches and decodes images through the active browser or Node environment provider. */
|
|
415
482
|
declare class ImageLoader {
|
|
416
483
|
protected static _createImage(): CompatImage;
|
|
484
|
+
/** Resolves when an image URL has decoded, or rejects if decoding fails. */
|
|
417
485
|
static loadAsync(src: string): Promise<CompatImage>;
|
|
486
|
+
/** Returns an image immediately. Use the callbacks to observe loading, or await {@link loadAsync}. */
|
|
418
487
|
static loadElement(src: string, onload?: () => void, onerr?: (err: Error) => void): CompatImage;
|
|
419
488
|
static loadData(src: string): Promise<ImageData>;
|
|
420
489
|
static loadCanvasData(src: string): Promise<ExtractableImageData>;
|
|
490
|
+
/** Decodes the supplied bytes into a canvas without fetching the source URL again. */
|
|
421
491
|
static infoToCanvasData(info: ImageInfo): Promise<ExtractableImageData>;
|
|
422
492
|
static infoToData(info: ImageInfo): Promise<ImageData>;
|
|
493
|
+
/** Returns cached RGBA pixels for an image URL or data URL. Failed loads can be retried. */
|
|
423
494
|
static getData(src: string): Promise<ImageData>;
|
|
495
|
+
/** Returns a cached canvas context and dimensions for an image URL or data URL. */
|
|
424
496
|
static getCanvasData(src: string): Promise<ExtractableImageData>;
|
|
425
497
|
static processResponse(response: Pick<RequestResponse<ArrayBuffer>, "data" | "url">): Promise<ImageInfo>;
|
|
426
498
|
static loadInfo(src: string): Promise<ImageInfo>;
|
|
@@ -433,6 +505,7 @@ declare const ITEM_GENERATED = "item/generated";
|
|
|
433
505
|
declare const BUILTIN_GENERATED = "builtin/generated";
|
|
434
506
|
declare const BUILTIN_ENTITY = "builtin/entity";
|
|
435
507
|
declare const DEFAULT_ELEMENTS: ModelElement[];
|
|
508
|
+
/** A Java model definition. {@link Models.getMerged} resolves its parent, textures, and elements. */
|
|
436
509
|
interface Model extends MinecraftAsset {
|
|
437
510
|
textures?: IModelTextures;
|
|
438
511
|
parent?: string;
|
|
@@ -440,17 +513,21 @@ interface Model extends MinecraftAsset {
|
|
|
440
513
|
elements?: ModelElement[];
|
|
441
514
|
hierarchy?: string[];
|
|
442
515
|
}
|
|
516
|
+
/** Java block-model data, including the ambient-occlusion flag. */
|
|
443
517
|
interface BlockModel extends Model {
|
|
444
518
|
textures?: BlockModelTextures;
|
|
445
519
|
ambientocclusion?: boolean;
|
|
446
520
|
}
|
|
521
|
+
/** Item preview data, including GUI lighting, tint sources, and supported special renderers. */
|
|
447
522
|
interface ItemModel extends Model {
|
|
448
523
|
textures?: ItemModelTextures;
|
|
449
524
|
gui_light?: GuiLight;
|
|
450
525
|
special?: SpecialItemRenderer;
|
|
451
526
|
tints?: ItemTintSource[];
|
|
452
527
|
}
|
|
528
|
+
/** An sRGB packed `0xRRGGBB` value or an RGB triple with components from 0 to 1. */
|
|
453
529
|
type ItemTintColor = number | TripleArray;
|
|
530
|
+
/** A vanilla item color source. Gameplay-dependent sources use their declared default color. */
|
|
454
531
|
type ItemTintSource = {
|
|
455
532
|
type: "constant" | "minecraft:constant";
|
|
456
533
|
value: ItemTintColor;
|
|
@@ -466,6 +543,7 @@ type ItemTintSource = {
|
|
|
466
543
|
index?: number;
|
|
467
544
|
default: ItemTintColor;
|
|
468
545
|
};
|
|
546
|
+
/** Supported item definitions that draw entity geometry instead of ordinary model elements. */
|
|
469
547
|
type SpecialItemRenderer = {
|
|
470
548
|
type: "chest" | "minecraft:chest";
|
|
471
549
|
texture: string;
|
|
@@ -481,6 +559,7 @@ type SpecialItemRenderer = {
|
|
|
481
559
|
};
|
|
482
560
|
interface TextureAsset extends MinecraftAsset, ImageInfo {
|
|
483
561
|
}
|
|
562
|
+
/** A model display pose: translation in model units, rotation in degrees, and scale factors. */
|
|
484
563
|
interface ModelDisplay {
|
|
485
564
|
translation?: TripleArray;
|
|
486
565
|
rotation?: TripleArray;
|
|
@@ -520,12 +599,14 @@ declare class MinecraftCubeTexture {
|
|
|
520
599
|
toUvArray(w: number, h: number, l: number, mirror?: boolean): number[];
|
|
521
600
|
}
|
|
522
601
|
|
|
602
|
+
/** Texture animation and GUI scaling metadata read from a `.png.mcmeta` file. */
|
|
523
603
|
interface MinecraftTextureMeta extends MinecraftAsset {
|
|
524
604
|
animation?: AnimationMeta;
|
|
525
605
|
gui?: {
|
|
526
606
|
scaling?: GuiSpriteScaling;
|
|
527
607
|
};
|
|
528
608
|
}
|
|
609
|
+
/** GUI sprite scaling rules. Dimensions and borders use logical GUI pixels, independent of PNG resolution. */
|
|
529
610
|
type GuiSpriteScaling = {
|
|
530
611
|
type: "stretch";
|
|
531
612
|
} | {
|
|
@@ -544,6 +625,7 @@ type GuiSpriteScaling = {
|
|
|
544
625
|
};
|
|
545
626
|
stretch_inner?: boolean;
|
|
546
627
|
};
|
|
628
|
+
/** Texture frame-grid and playback settings. Frame durations use ticks at 20 ticks per second. */
|
|
547
629
|
interface AnimationMeta {
|
|
548
630
|
interpolate: boolean;
|
|
549
631
|
width: number;
|
|
@@ -551,17 +633,20 @@ interface AnimationMeta {
|
|
|
551
633
|
frametime: number;
|
|
552
634
|
frames: Array<number | AnimationFrame>;
|
|
553
635
|
}
|
|
636
|
+
/** A zero-based frame index and its duration in ticks, overriding the animation's default frame time. */
|
|
554
637
|
interface AnimationFrame {
|
|
555
638
|
index: number;
|
|
556
639
|
time: number;
|
|
557
640
|
}
|
|
558
641
|
|
|
642
|
+
/** Counts direct scene children, Minecraft scene objects, and live instance placements. */
|
|
559
643
|
declare class SceneStats {
|
|
560
644
|
objectCount: number;
|
|
561
645
|
sceneObjectCount: number;
|
|
562
646
|
instanceCount: number;
|
|
563
647
|
}
|
|
564
648
|
|
|
649
|
+
/** A synchronous callback registered with {@link Ticker.add}. */
|
|
565
650
|
interface TickerFunction {
|
|
566
651
|
(): void;
|
|
567
652
|
}
|
|
@@ -583,18 +668,24 @@ declare class Ticker {
|
|
|
583
668
|
private static fiveSecondTps;
|
|
584
669
|
private static fiveSecondTicks;
|
|
585
670
|
private static schedule;
|
|
671
|
+
/** Starts or resumes the shared tick loop. Repeated calls have no effect. */
|
|
586
672
|
static start(): void;
|
|
673
|
+
/** Pauses the loop while retaining callbacks for a later {@link start}. */
|
|
587
674
|
static stop(): void;
|
|
675
|
+
/** Registers a callback, starts the loop if needed, and returns an ID for {@link remove}. */
|
|
588
676
|
static add(tick: TickerFunction): number;
|
|
677
|
+
/** Removes a callback by ID and stops the timers when no callbacks remain. */
|
|
589
678
|
static remove(c?: number): void;
|
|
590
679
|
static get tickers(): Map<number, TickerFunction>;
|
|
591
680
|
static get tpsOneSecond(): number;
|
|
592
681
|
static get tpsFiveSeconds(): number;
|
|
682
|
+
/** Stops the loop and removes all registered callbacks. */
|
|
593
683
|
static dispose(): void;
|
|
594
684
|
}
|
|
595
685
|
|
|
596
686
|
declare const TintColors: never[];
|
|
597
687
|
|
|
688
|
+
/** Transform access shared by scene objects and instance references. Positions use scene units and rotations use radians. */
|
|
598
689
|
interface Transformable {
|
|
599
690
|
setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
600
691
|
setPosition(position: Vector3): void;
|
|
@@ -618,22 +709,30 @@ declare function base64encode(str: string): string;
|
|
|
618
709
|
declare function base64decode(str: string): string;
|
|
619
710
|
declare function toRadians(degrees: number): number;
|
|
620
711
|
declare function toDegrees(radians: number): number;
|
|
712
|
+
/** Resolves after a delay in milliseconds. */
|
|
621
713
|
declare function sleep(timeout: number): Promise<void>;
|
|
714
|
+
/** Reduces an angle modulo 360, retaining a negative sign for negative inputs. */
|
|
622
715
|
declare function clampRotationDegrees(deg: number): number;
|
|
623
716
|
declare function isVector3(obj: any): obj is Vector3;
|
|
624
717
|
type DeepPartial<T> = {
|
|
625
718
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
626
719
|
};
|
|
627
720
|
|
|
721
|
+
/** Loads texture pixels and `.mcmeta` files through the active asset sources. */
|
|
628
722
|
declare class ModelTextures {
|
|
629
723
|
private static _persistentMetaCache;
|
|
630
724
|
private static get PERSISTENT_META_CACHE();
|
|
725
|
+
/** Loads and decodes a texture into a readable canvas, or returns `undefined` when missing. */
|
|
631
726
|
static get(key: AssetKey): Promise<Maybe<ExtractableImageData>>;
|
|
727
|
+
/** Fetches and caches encoded texture bytes without decoding the pixels. */
|
|
632
728
|
static preload(key: AssetKey): Promise<Maybe<TextureAsset>>;
|
|
729
|
+
/** Loads a texture's `.mcmeta` file, or returns `undefined` when no metadata file exists. */
|
|
633
730
|
static getMeta(key: AssetKey): Promise<Maybe<MinecraftTextureMeta>>;
|
|
731
|
+
/** Clears persisted texture metadata. Use {@link Caching.clear} to discard in-memory textures and metadata. */
|
|
634
732
|
static clearCache(): Promise<void>;
|
|
635
733
|
}
|
|
636
734
|
|
|
735
|
+
/** Wraps a browser or Node canvas for pixel reads and writes. All coordinates and dimensions use pixels. */
|
|
637
736
|
declare class CanvasImage implements Disposable {
|
|
638
737
|
readonly canvas: CompatCanvas;
|
|
639
738
|
readonly context: CanvasRenderingContext2D;
|
|
@@ -651,6 +750,7 @@ declare class CanvasImage implements Disposable {
|
|
|
651
750
|
dispose(): void;
|
|
652
751
|
}
|
|
653
752
|
|
|
753
|
+
/** A model's combined texture canvas, per-texture rectangles, and shared animation subscriptions. */
|
|
654
754
|
declare class TextureAtlas implements Disposable {
|
|
655
755
|
readonly model: Model;
|
|
656
756
|
readonly image: CanvasImage;
|
|
@@ -676,11 +776,13 @@ declare class TextureAtlas implements Disposable {
|
|
|
676
776
|
}, hasTransparency: boolean);
|
|
677
777
|
/** Calls subscribers when an animation frame changes; unused atlases do not tick. */
|
|
678
778
|
subscribe(callback: () => void): () => void;
|
|
779
|
+
/** Copies pixels for a texture variable from its current atlas rectangle. */
|
|
679
780
|
getData(texture: string): ImageData$1;
|
|
680
781
|
dispose(): void;
|
|
681
782
|
}
|
|
682
783
|
|
|
683
784
|
declare const DEFAULT_UV: QuadArray;
|
|
785
|
+
/** Maps Minecraft face coordinates to Three.js UVs and builds per-model texture atlases. */
|
|
684
786
|
declare class UVMapper {
|
|
685
787
|
protected static makeUv(uvCoord: number, originalTextureSize: number, actualTextureSize: number): number;
|
|
686
788
|
protected static makeUvCoords([originalTextureWidth, originalTextureHeight]: DoubleArray, [actualTextureWidth, actualTextureHeight]: DoubleArray, [x1, y1, x2, y2]: QuadArray): QuadArray;
|
|
@@ -697,6 +799,7 @@ declare class UVMapper {
|
|
|
697
799
|
/** Bounds texture sampling to texel centres without changing cropped face UVs. */
|
|
698
800
|
static setAtlasUvBounds(geometry: BoxGeometry, faces: ModelFaces, atlas: TextureAtlas): void;
|
|
699
801
|
static lockUvs(geometry: BoxGeometry, faces: ModelFaces, atlas: TextureAtlas, rotation: Euler): void;
|
|
802
|
+
/** Returns the shared atlas for a keyed, merged model, creating it on first use. */
|
|
700
803
|
static getAtlas(model: Model): Promise<Maybe<TextureAtlas>>;
|
|
701
804
|
static fillMissingTextureKeys<T>(textures: ModelTextures, target: {
|
|
702
805
|
[k: string]: T;
|
|
@@ -705,8 +808,14 @@ declare class UVMapper {
|
|
|
705
808
|
};
|
|
706
809
|
protected static getFallbackUv(element: ModelElement, faceName: CubeFace): QuadArray;
|
|
707
810
|
protected static expandAndRotateMcUvs([u1, v1, u2, v2]: QuadArray, rotation: number | undefined, actualWidth: number, actualHeight: number): QuadArray<Vector2>;
|
|
811
|
+
/**
|
|
812
|
+
* Combines model textures and animation metadata into an atlas.
|
|
813
|
+
* Mapped UVs are stored on copies of the model's elements, available through the returned atlas.
|
|
814
|
+
* Returns `undefined` for models without a texture map.
|
|
815
|
+
*/
|
|
708
816
|
static createAtlas(originalModel: Model): Promise<Maybe<TextureAtlas>>;
|
|
709
817
|
}
|
|
818
|
+
/** Stores a Minecraft face's UV rectangle and its rotation in degrees. */
|
|
710
819
|
declare class MinecraftFaceUV {
|
|
711
820
|
readonly uv: QuadArray;
|
|
712
821
|
readonly rotation: number;
|
|
@@ -728,22 +837,32 @@ declare class MinecraftFaceUV {
|
|
|
728
837
|
*/
|
|
729
838
|
declare function shutdown(): void;
|
|
730
839
|
|
|
840
|
+
/** Runs queued tasks in bounded batches. Idle executors do not keep a timer running. */
|
|
731
841
|
declare class BatchedExecutor {
|
|
732
842
|
readonly interval: number;
|
|
733
843
|
readonly batch: number;
|
|
734
844
|
private readonly queue;
|
|
845
|
+
/**
|
|
846
|
+
* @param interval - Delay between queue runs, in milliseconds.
|
|
847
|
+
* @param batch - Maximum tasks started per run and maximum tasks active at once.
|
|
848
|
+
*/
|
|
735
849
|
constructor(interval?: number, batch?: number);
|
|
850
|
+
/** Queues a task and resolves with its result, or rejects with its error. */
|
|
736
851
|
submit<T>(task: Task<T>): Promise<T>;
|
|
852
|
+
/** Rejects queued and future tasks. Tasks already running are allowed to finish. */
|
|
737
853
|
stop(): void;
|
|
738
854
|
}
|
|
739
855
|
type Task<T = unknown> = () => T | Promise<T>;
|
|
740
856
|
|
|
741
857
|
declare function prefix(prefix?: string): string;
|
|
742
858
|
|
|
859
|
+
/** Rotates geometry in place around the element's origin. The supplied angle is in degrees. */
|
|
743
860
|
declare function applyElementRotation(rotation: ElementRotation, geometry: BufferGeometry): void;
|
|
861
|
+
/** Rotates an object around a local axis by an angle in degrees. */
|
|
744
862
|
declare function applyGenericRotation(axis: Axis, rotation: number, obj: Object3D): void;
|
|
745
863
|
declare function addBox3WireframeToObject(box: Box3, obj: Object3D, color?: number, w?: number): void;
|
|
746
864
|
declare function addWireframeToObject(obj: Object3D, color?: number, w?: number): void;
|
|
865
|
+
/** Adds edge and axis helpers to a mesh and returns a function that disposes their resources. */
|
|
747
866
|
declare function addWireframeToMesh(geo: BufferGeometry, mesh: Mesh, color?: number, w?: number): () => void;
|
|
748
867
|
|
|
749
868
|
declare function captureException(e: any, ...extra: any[]): void;
|
|
@@ -766,8 +885,10 @@ declare enum AssetParser {
|
|
|
766
885
|
JSON = "json"
|
|
767
886
|
}
|
|
768
887
|
|
|
888
|
+
/** An asset provider registered with {@link AssetLoader.addSource}. */
|
|
769
889
|
declare abstract class AssetSource {
|
|
770
890
|
protected constructor();
|
|
891
|
+
/** Returns a parsed asset, or `undefined` to allow fallback. Load and parse failures should reject. */
|
|
771
892
|
abstract get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
|
|
772
893
|
/** Whether this source prevents lower-priority sources from supplying the key. Its own assets remain available. */
|
|
773
894
|
blocks(key: AssetKey): boolean | Promise<boolean>;
|
|
@@ -787,12 +908,15 @@ declare class AssetLoadError extends Error {
|
|
|
787
908
|
constructor(source: AssetSource, key: AssetKey, path: string, cause: unknown);
|
|
788
909
|
}
|
|
789
910
|
|
|
911
|
+
/** Loads assets from a shared, ordered registry of hosted sources and resource packs. */
|
|
790
912
|
declare class AssetLoader {
|
|
913
|
+
/** Default asset base URL. Use {@link setVersion} to select a Minecraft version. */
|
|
791
914
|
static ROOT: string;
|
|
792
915
|
private static _SOURCES;
|
|
793
916
|
/** Used when a registered source cannot identify its content, so nothing persists past this session. */
|
|
794
917
|
private static readonly SESSION_SCOPE;
|
|
795
918
|
static get version(): string;
|
|
919
|
+
/** Selects an mcasset.cloud version, updates the vanilla source, and clears in-memory caches. */
|
|
796
920
|
static setVersion(version: string): void;
|
|
797
921
|
/**
|
|
798
922
|
* Scope for persistent cache keys. Empty with only the default vanilla sources, so their
|
|
@@ -802,8 +926,17 @@ declare class AssetLoader {
|
|
|
802
926
|
static get persistentScope(): string;
|
|
803
927
|
/** Prefixes a persistent cache key with the current source scope. */
|
|
804
928
|
static persistentKey(key: string): string;
|
|
929
|
+
/**
|
|
930
|
+
* Registers a source at the highest priority.
|
|
931
|
+
* Call {@link Caching.clear} after changing sources to discard previously loaded assets.
|
|
932
|
+
*
|
|
933
|
+
* @param key - Name used to replace or remove this source.
|
|
934
|
+
* @param override - Removes the first source with this name before adding the new one.
|
|
935
|
+
*/
|
|
805
936
|
static addSource(key: string, source: AssetSource, override?: boolean): void;
|
|
937
|
+
/** Removes and returns the first source with this name. Call {@link Caching.clear} to reload assets. */
|
|
806
938
|
static removeSource(key: string): Maybe<AssetSource>;
|
|
939
|
+
/** Loads from all sources and returns defined results in priority order. Any source failure rejects the call. */
|
|
807
940
|
static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
|
|
808
941
|
/** Returns the first defined result in source-priority order, without merging assets. */
|
|
809
942
|
static get<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<Maybe<T>>;
|
|
@@ -814,6 +947,7 @@ declare class AssetLoader {
|
|
|
814
947
|
}>>;
|
|
815
948
|
}
|
|
816
949
|
|
|
950
|
+
/** A Java blockstate file that selects models through variants or multipart conditions. */
|
|
817
951
|
interface BlockState extends MinecraftAsset {
|
|
818
952
|
variants?: BlockStateVariants;
|
|
819
953
|
multipart?: BlockStateMultipart[];
|
|
@@ -821,6 +955,7 @@ interface BlockState extends MinecraftAsset {
|
|
|
821
955
|
type BlockStateVariants = {
|
|
822
956
|
[key: string]: BlockStateVariant | BlockStateVariant[];
|
|
823
957
|
};
|
|
958
|
+
/** A model selection with optional x/y rotations in degrees, UV locking, and random-selection weight. */
|
|
824
959
|
interface BlockStateVariant {
|
|
825
960
|
model?: string;
|
|
826
961
|
y?: number;
|
|
@@ -832,6 +967,7 @@ interface BlockStateMultipart {
|
|
|
832
967
|
when?: MultipartCondition;
|
|
833
968
|
apply?: BlockStateVariant | BlockStateVariant[];
|
|
834
969
|
}
|
|
970
|
+
/** Property tests combined with AND or OR. A property value such as `north|south` accepts either value. */
|
|
835
971
|
type MultipartCondition = Record<string, string> | {
|
|
836
972
|
OR: MultipartCondition[];
|
|
837
973
|
} | {
|
|
@@ -840,16 +976,20 @@ type MultipartCondition = Record<string, string> | {
|
|
|
840
976
|
|
|
841
977
|
declare const DEFAULT_ROOT = "https://assets.mcasset.cloud/1.21.11";
|
|
842
978
|
declare const DEFAULT_NAMESPACE = "minecraft";
|
|
979
|
+
/** Convenience accessors for model and blockstate loading. */
|
|
843
980
|
declare class Assets {
|
|
844
981
|
/**
|
|
845
982
|
* @deprecated
|
|
846
983
|
*/
|
|
847
984
|
static parseAssetKey(assetType: AssetType, str: string, origin?: AssetKey): AssetKey;
|
|
985
|
+
/** Loads a model with its parent chain resolved. See {@link Models.getMerged}. */
|
|
848
986
|
static getModel(key: AssetKey): Promise<Maybe<Model>>;
|
|
987
|
+
/** Loads a blockstate definition. See {@link BlockStates.get}. */
|
|
849
988
|
static getBlockState(key: AssetKey): Promise<Maybe<BlockState>>;
|
|
850
989
|
}
|
|
851
990
|
|
|
852
991
|
type BlockStatePropertyValue = string | boolean | number;
|
|
992
|
+
/** A vanilla block property's default and allowed values, loaded through {@link BlockStates.getDefaultState}. */
|
|
853
993
|
interface BlockStateProperty {
|
|
854
994
|
default: BlockStatePropertyValue;
|
|
855
995
|
type: "boolean" | "int" | "enum";
|
|
@@ -859,6 +999,7 @@ interface BlockStateProperty {
|
|
|
859
999
|
type BlockStatePropertyDefaults = {
|
|
860
1000
|
[key: string]: BlockStateProperty;
|
|
861
1001
|
};
|
|
1002
|
+
/** Block property values, such as `{ facing: "north", waterlogged: "false" }`. */
|
|
862
1003
|
type BlockStateProperties = {
|
|
863
1004
|
[key: string]: string;
|
|
864
1005
|
};
|
|
@@ -881,6 +1022,7 @@ type BlockEntityRotation = {
|
|
|
881
1022
|
property: string;
|
|
882
1023
|
step: number;
|
|
883
1024
|
};
|
|
1025
|
+
/** Models and state-dependent placement for one block ID in the block-entity index. */
|
|
884
1026
|
interface BlockEntityEntry {
|
|
885
1027
|
parts: BlockEntityPart[];
|
|
886
1028
|
rotation?: BlockEntityRotation;
|
|
@@ -891,12 +1033,14 @@ interface BlockEntityEntry {
|
|
|
891
1033
|
type BlockEntityIndex = MinecraftAsset & {
|
|
892
1034
|
[block: string]: BlockEntityEntry;
|
|
893
1035
|
};
|
|
1036
|
+
/** Parts and placement selected by {@link BlockEntities.resolve} for a block's properties. */
|
|
894
1037
|
interface ResolvedBlockEntity {
|
|
895
1038
|
parts: BlockEntityPart[];
|
|
896
1039
|
/** Degrees counter-clockwise seen from above, about the block's vertical centre axis. */
|
|
897
1040
|
rotation: number;
|
|
898
1041
|
translation: TripleArray;
|
|
899
1042
|
}
|
|
1043
|
+
/** Resolves blockstate properties into the entity models used to draw chests, beds, and other block entities. */
|
|
900
1044
|
declare class BlockEntities {
|
|
901
1045
|
/**
|
|
902
1046
|
* Loads the block index of a version. Versions and sources without one yield an empty index, and so does
|
|
@@ -912,14 +1056,19 @@ declare class BlockEntities {
|
|
|
912
1056
|
static matrix(resolved: ResolvedBlockEntity, matrix?: Matrix4): Matrix4;
|
|
913
1057
|
}
|
|
914
1058
|
|
|
1059
|
+
/** Loads blockstate definitions and the property defaults used to select block models. */
|
|
915
1060
|
declare class BlockStates {
|
|
916
1061
|
private static _persistentCache;
|
|
917
1062
|
private static get PERSISTENT_CACHE();
|
|
1063
|
+
/** Returns blockstate filenames from the selected version's `_list.json`, or an empty list. */
|
|
918
1064
|
static getList(): Promise<string[]>;
|
|
919
1065
|
static getDefaultStates(): Promise<Maybe<DefaultBlockStates>>;
|
|
1066
|
+
/** Looks up vanilla property definitions for the key's block path, or returns `undefined`. */
|
|
920
1067
|
static getDefaultState(key: AssetKey): Promise<Maybe<BlockStatePropertyDefaults>>;
|
|
1068
|
+
/** Loads a cached blockstate definition for {@link MineRenderScene.addBlock}, or returns `undefined`. */
|
|
921
1069
|
static get(key: AssetKey): Promise<Maybe<BlockState>>;
|
|
922
1070
|
static getAll(keys: AssetKey[] | Iterable<AssetKey>): Promise<Maybe<BlockState>[]>;
|
|
1071
|
+
/** Clears persisted blockstates. Use {@link Caching.clear} to also discard in-memory assets. */
|
|
923
1072
|
static clearCache(): Promise<void>;
|
|
924
1073
|
}
|
|
925
1074
|
declare class DefaultBlockStates implements MinecraftAsset {
|
|
@@ -931,6 +1080,7 @@ interface EntityAnimationFile extends MinecraftAsset {
|
|
|
931
1080
|
id: string;
|
|
932
1081
|
animations: Record<string, EntityAnimation>;
|
|
933
1082
|
}
|
|
1083
|
+
/** A clip of pose offsets, played with {@link EntityObject.playAnimation} or sampled directly. */
|
|
934
1084
|
interface EntityAnimation {
|
|
935
1085
|
/** Seconds. */
|
|
936
1086
|
length: number;
|
|
@@ -943,6 +1093,7 @@ interface EntityAnimation {
|
|
|
943
1093
|
type EntityAnimationChannel = "position" | "rotation" | "scale";
|
|
944
1094
|
/** Keyframes in time order per channel. */
|
|
945
1095
|
type EntityAnimationBone = Partial<Record<EntityAnimationChannel, EntityAnimationKeyframe[]>>;
|
|
1096
|
+
/** One timed offset for a part's position, rotation, or scale channel. */
|
|
946
1097
|
interface EntityAnimationKeyframe {
|
|
947
1098
|
/** Seconds. */
|
|
948
1099
|
time: number;
|
|
@@ -966,24 +1117,39 @@ declare function entityAnimationTime(animation: EntityAnimation, time: number, l
|
|
|
966
1117
|
/** Samples every bone and channel of an animation at `time` seconds. */
|
|
967
1118
|
declare function sampleEntityAnimation(animation: EntityAnimation, time: number, loop?: boolean): EntityAnimationPose;
|
|
968
1119
|
|
|
1120
|
+
/** Loads entity and block-entity geometry, texture selections, and animation clips from the dataset. */
|
|
969
1121
|
declare class Entities {
|
|
1122
|
+
/** Lists model paths in the `minecraft` namespace, including subdirectories and excluding `.json`. */
|
|
970
1123
|
static getEntityList(): Promise<string[]>;
|
|
971
1124
|
private static getModelFile;
|
|
1125
|
+
/** Returns selectable geometry-layer names, or an empty list when the model is missing. */
|
|
972
1126
|
static getLayerList(modelKey: BasicAssetKey): Promise<string[]>;
|
|
973
1127
|
/** The dataset's extra draws on top of `main`; their `when` labels are the states `EntityModelOptions.when` can enable. */
|
|
974
1128
|
static getPassList(modelKey: BasicAssetKey): Promise<EntityModelPass[]>;
|
|
1129
|
+
/**
|
|
1130
|
+
* Loads the layers and textures to pass to {@link MineRenderScene.addEntity}.
|
|
1131
|
+
* By default, selects `main`, unconditional passes, and passes enabled by `options.when`.
|
|
1132
|
+
*
|
|
1133
|
+
* @param modelKey - Dataset model, such as `new BasicAssetKey("minecraft", "zombie")`.
|
|
1134
|
+
* @param textureKey - Texture override for the first selected layer.
|
|
1135
|
+
* @param options - Layer selection, conditional passes, and per-layer texture overrides.
|
|
1136
|
+
* @returns The selected model, or `undefined` when its dataset file is missing.
|
|
1137
|
+
*/
|
|
975
1138
|
static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
|
|
976
1139
|
/**
|
|
977
1140
|
* Native and sampled vanilla clips by name, or undefined when the model or selected version has none.
|
|
978
1141
|
*/
|
|
979
1142
|
static getAnimations(modelKey: BasicAssetKey): Promise<Maybe<Record<string, EntityAnimation>>>;
|
|
1143
|
+
/** Finds a fallback texture using the model path, its directory, and vanilla variant data. */
|
|
980
1144
|
static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
|
|
981
1145
|
/** @deprecated Use getEntityList(); block entities share the entity dataset. */
|
|
982
1146
|
static getBlockList(): Promise<string[]>;
|
|
983
1147
|
/** @deprecated Use getEntity(); block entities share the entity dataset. */
|
|
984
1148
|
static getBlock(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
|
|
985
1149
|
}
|
|
1150
|
+
/** Selection settings passed as the third argument to {@link Entities.getEntity}. */
|
|
986
1151
|
interface EntityModelOptions {
|
|
1152
|
+
/** Selects one geometry layer without dataset passes. `layers` takes precedence when supplied. */
|
|
987
1153
|
layer?: string;
|
|
988
1154
|
/** Layer names in draw order; an explicit selection draws exactly these layers and no dataset passes. */
|
|
989
1155
|
layers?: string[];
|
|
@@ -996,6 +1162,7 @@ interface EntityModelOptions {
|
|
|
996
1162
|
textures?: Record<string, BasicAssetKey>;
|
|
997
1163
|
}
|
|
998
1164
|
|
|
1165
|
+
/** A glyph's source pixels and layout metrics. Glyphs without an image contribute spacing only. */
|
|
999
1166
|
interface BitmapGlyph {
|
|
1000
1167
|
image?: CompatCanvas;
|
|
1001
1168
|
/** Source rectangle in the bitmap sheet, before applying scale. */
|
|
@@ -1007,48 +1174,69 @@ interface BitmapGlyph {
|
|
|
1007
1174
|
ascent: number;
|
|
1008
1175
|
advance: number;
|
|
1009
1176
|
}
|
|
1177
|
+
/** Character-to-glyph lookup assembled from the active resource-pack fonts. */
|
|
1010
1178
|
interface BitmapFont {
|
|
1011
1179
|
glyphs: Map<string, BitmapGlyph>;
|
|
1012
1180
|
}
|
|
1181
|
+
/** Loads Minecraft bitmap, space, and reference font providers for GUI text. */
|
|
1013
1182
|
declare class Fonts {
|
|
1183
|
+
/** Combines font definitions in source-priority order. Unsupported Unihex and TrueType providers are skipped. */
|
|
1014
1184
|
static get(key?: AssetKey | string): Promise<BitmapFont>;
|
|
1015
1185
|
private static relatedKey;
|
|
1016
1186
|
private static load;
|
|
1017
1187
|
private static bitmap;
|
|
1018
1188
|
}
|
|
1019
1189
|
|
|
1190
|
+
/** Loads and caches Java block/item models, including inherited geometry and textures. */
|
|
1020
1191
|
declare class Models {
|
|
1021
1192
|
private static _persistentCache;
|
|
1022
1193
|
private static get PERSISTENT_CACHE();
|
|
1194
|
+
/** Lists item filenames from the asset source's `_list.json`, with a legacy model-directory fallback. */
|
|
1023
1195
|
static getItemList(): Promise<string[]>;
|
|
1024
1196
|
static loadAndMerge(key: AssetKey): Promise<Maybe<Model>>;
|
|
1025
1197
|
private static getItemModel;
|
|
1026
1198
|
private static defaultItemModel;
|
|
1199
|
+
/** Loads one model file without resolving its parents. Returns `undefined` when the file is missing. */
|
|
1027
1200
|
static getRaw(key: AssetKey): Promise<Maybe<Model>>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Loads a model and resolves its parent chain. Returns `undefined` when the model is missing.
|
|
1203
|
+
* Item keys use GUI context, false conditions, and zero numeric properties.
|
|
1204
|
+
*
|
|
1205
|
+
* @param key - Model key, for example `AssetKey.parse("models", "minecraft:item/diamond_sword")`.
|
|
1206
|
+
*/
|
|
1028
1207
|
static getMerged(key: AssetKey): Promise<Maybe<Model>>;
|
|
1208
|
+
/** Alias for {@link getMerged}. */
|
|
1029
1209
|
static get(key: AssetKey): Promise<Maybe<Model>>;
|
|
1210
|
+
/** Clears persisted models. Use {@link Caching.clear} to also discard in-memory assets. */
|
|
1030
1211
|
static clearCache(): Promise<void>;
|
|
1031
1212
|
}
|
|
1032
1213
|
|
|
1214
|
+
/** Resolves Minecraft display poses and applies them to model geometry. */
|
|
1033
1215
|
declare class DisplayTransforms {
|
|
1034
1216
|
/** Resolve hand fallbacks within one model, before inheriting parent display entries. */
|
|
1035
1217
|
static withHandFallbacks(display: Model["display"]): Model["display"];
|
|
1036
1218
|
/** Build a display pose for geometry already centered at the model's [8, 8, 8] pivot. */
|
|
1037
1219
|
static getMatrix(display: Model["display"], position: DisplayPosition): Matrix4;
|
|
1220
|
+
/** Transforms geometry in place and reverses triangle winding when the matrix reflects it. */
|
|
1038
1221
|
static apply(geometry: BufferGeometry, matrix: Matrix4): void;
|
|
1039
1222
|
}
|
|
1040
1223
|
|
|
1224
|
+
/** Resolves static item-preview colors from vanilla tint definitions and caller overrides. */
|
|
1041
1225
|
declare class ItemTints {
|
|
1042
1226
|
/** Resolves preview colors from item definitions; explicit per-index colors take precedence. */
|
|
1043
1227
|
static get(model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
|
|
1044
1228
|
private static rgb;
|
|
1045
1229
|
}
|
|
1046
1230
|
|
|
1231
|
+
/** Identifies fully opaque cubes and maps neighbor visibility to model-local face masks. */
|
|
1047
1232
|
declare class ModelCulling {
|
|
1233
|
+
/** Rotates a world-direction bit mask into model space. Bits follow {@link CUBE_FACES}. */
|
|
1048
1234
|
static toLocalMask(worldMask: number, rotation: Euler): number;
|
|
1235
|
+
/** Whether a model fills one block with opaque faces and can hide adjacent block faces. */
|
|
1049
1236
|
static isOpaqueFullCube(atlas: Maybe<TextureAtlas>): boolean;
|
|
1050
1237
|
}
|
|
1051
1238
|
|
|
1239
|
+
/** Builds extruded item-model elements from sprite pixels, including edges around transparent regions. */
|
|
1052
1240
|
declare class ModelGenerator {
|
|
1053
1241
|
static readonly ITEM_LAYERS: string[];
|
|
1054
1242
|
/**
|
|
@@ -1058,16 +1246,20 @@ declare class ModelGenerator {
|
|
|
1058
1246
|
static generateItemModel(imageData: Pick<ImageData$1, "width" | "height" | "data">, layer: string): ModelElement[];
|
|
1059
1247
|
}
|
|
1060
1248
|
|
|
1249
|
+
/** Resolves Java model inheritance, with child elements and display poses overriding their parents. */
|
|
1061
1250
|
declare class ModelMerger {
|
|
1251
|
+
/** Loads the parent chain and returns a merged model without modifying the supplied definition. */
|
|
1062
1252
|
static mergeWithParents(model: Model): Promise<Model>;
|
|
1063
1253
|
protected static collectAllParents(model: Model): Promise<Model[]>;
|
|
1064
1254
|
}
|
|
1065
1255
|
|
|
1256
|
+
/** Entity geometry and placement for a special item preview. Named part rotations use radians. */
|
|
1066
1257
|
interface SpecialItemPart {
|
|
1067
1258
|
model: EntityModel;
|
|
1068
1259
|
transform: Matrix4;
|
|
1069
1260
|
rotations: Record<string, TripleArray>;
|
|
1070
1261
|
}
|
|
1262
|
+
/** Loads the entity geometry used by chest, bed, and supported mob-head item previews. */
|
|
1071
1263
|
declare class SpecialItems {
|
|
1072
1264
|
/** Resolves the static entity parts drawn by a special item renderer, in model units. */
|
|
1073
1265
|
static getParts(special: SpecialItemRenderer, root?: string): Promise<SpecialItemPart[]>;
|
|
@@ -1075,25 +1267,34 @@ declare class SpecialItems {
|
|
|
1075
1267
|
static createMaterial(source: MeshBasicMaterial, shade: boolean): MeshBasicMaterial;
|
|
1076
1268
|
}
|
|
1077
1269
|
|
|
1270
|
+
/** Block data passed to world setters. `type` is a namespaced ID such as `minecraft:oak_log`. */
|
|
1078
1271
|
interface Block {
|
|
1079
1272
|
type: string;
|
|
1080
1273
|
properties?: BlockStateProperties;
|
|
1081
1274
|
nbt?: any;
|
|
1082
1275
|
}
|
|
1083
1276
|
|
|
1277
|
+
/** Selects block models from property values, including multipart conditions and weighted alternatives. */
|
|
1084
1278
|
declare class BlockStateResolver {
|
|
1279
|
+
/** Loads vanilla property defaults, falling back to preview values inferred from the blockstate file. */
|
|
1085
1280
|
static defaults(blockState: BlockState): Promise<BlockStateProperties>;
|
|
1281
|
+
/** Selects matching models. Supply `choose` to control selection within each alternatives array. */
|
|
1086
1282
|
static select(blockState: BlockState, state: BlockStateProperties, choose?: (variants: BlockStateVariant | BlockStateVariant[]) => BlockStateVariant): BlockStateVariant[];
|
|
1283
|
+
/** Returns matching model groups before choosing weighted alternatives. */
|
|
1087
1284
|
static matching(blockState: BlockState, state: BlockStateProperties): (BlockStateVariant | BlockStateVariant[])[];
|
|
1285
|
+
/** Selects a random alternative using positive integer weights, each defaulting to 1. */
|
|
1088
1286
|
static choose(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
|
|
1287
|
+
/** Converts blockstate rotations in degrees into the Euler rotation used by model rendering. */
|
|
1089
1288
|
static rotation(variant: BlockStateVariant): Euler;
|
|
1090
1289
|
}
|
|
1091
1290
|
|
|
1291
|
+
/** Supplies block-preview tint colors from block properties and the active resource pack. */
|
|
1092
1292
|
declare class BlockTints {
|
|
1093
1293
|
/** Resolves block preview colors without biome context; explicit tints take precedence. */
|
|
1094
1294
|
static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
|
|
1095
1295
|
}
|
|
1096
1296
|
|
|
1297
|
+
/** A model that owns reusable instance slots and exposes per-slot transforms to {@link InstanceReference}. */
|
|
1097
1298
|
interface Instanceable {
|
|
1098
1299
|
nextInstance(): InstanceReference<SceneObject>;
|
|
1099
1300
|
removeInstanceAt(index: number): void;
|
|
@@ -1111,6 +1312,10 @@ interface Instanceable {
|
|
|
1111
1312
|
}
|
|
1112
1313
|
declare function isInstanceable(obj: any): obj is Instanceable;
|
|
1113
1314
|
|
|
1315
|
+
/**
|
|
1316
|
+
* Controls one placement of a shared model. Transform methods affect only this instance.
|
|
1317
|
+
* After {@link removeFromScene} or {@link dispose}, accessing its transforms throws.
|
|
1318
|
+
*/
|
|
1114
1319
|
declare class InstanceReference<T extends Instanceable> implements Transformable, Disposable {
|
|
1115
1320
|
readonly instanceable: T;
|
|
1116
1321
|
readonly index: number;
|
|
@@ -1118,11 +1323,14 @@ declare class InstanceReference<T extends Instanceable> implements Transformable
|
|
|
1118
1323
|
constructor(instanceable: T, index: number);
|
|
1119
1324
|
nextInstance(): InstanceReference<SceneObject>;
|
|
1120
1325
|
private get activeInstanceable();
|
|
1326
|
+
/** Releases this placement's slot for reuse. Repeated calls have no effect. */
|
|
1121
1327
|
removeFromScene(): void;
|
|
1122
1328
|
dispose(): void;
|
|
1123
1329
|
getMatrix(matrix?: Matrix4): Matrix4;
|
|
1124
1330
|
setMatrix(matrix: Matrix4): void;
|
|
1331
|
+
/** Hides or restores this placement while preserving its transform and allocated slot. */
|
|
1125
1332
|
setVisible(visible: boolean): void;
|
|
1333
|
+
/** Updates the supplied transform components. Positions use scene units and rotations use radians. */
|
|
1126
1334
|
setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1127
1335
|
setPosition(position: Vector3): void;
|
|
1128
1336
|
getPosition(): Vector3;
|
|
@@ -1133,13 +1341,18 @@ declare class InstanceReference<T extends Instanceable> implements Transformable
|
|
|
1133
1341
|
}
|
|
1134
1342
|
declare function isInstanceReference(obj: any): obj is InstanceReference<any>;
|
|
1135
1343
|
|
|
1344
|
+
/** Shared settings passed to scene-object constructors or the scene's `addModel` and `addBlock` methods. */
|
|
1136
1345
|
interface SceneObjectOptions {
|
|
1137
1346
|
wireframe: boolean;
|
|
1347
|
+
/** Combines compatible model elements into one geometry. */
|
|
1138
1348
|
mergeMeshes: boolean;
|
|
1349
|
+
/** Allows compatible models to share geometry through instance references. */
|
|
1139
1350
|
instanceMeshes: boolean;
|
|
1351
|
+
/** Initial instance capacity. Buffers grow when more placements are added. */
|
|
1140
1352
|
maxInstanceCount: number;
|
|
1141
1353
|
}
|
|
1142
1354
|
|
|
1355
|
+
/** Builds render geometry from a merged Java model. Create it through {@link MineRenderScene.addModel}. */
|
|
1143
1356
|
declare class ModelObject extends SceneObject {
|
|
1144
1357
|
readonly originalModel: Model;
|
|
1145
1358
|
readonly isModelObject: true;
|
|
@@ -1164,26 +1377,31 @@ declare class ModelObject extends SceneObject {
|
|
|
1164
1377
|
removeInstanceAt(index: number): void;
|
|
1165
1378
|
disposeAndRemoveAllChildren(): void;
|
|
1166
1379
|
}
|
|
1380
|
+
/** Model settings passed to `scene.addModel(model, options)` or the ModelObject constructor. */
|
|
1167
1381
|
interface ModelObjectOptions extends SceneObjectOptions {
|
|
1168
1382
|
/** Minecraft display pose applied around the model center, before scene transforms. */
|
|
1169
1383
|
displayPosition?: DisplayPosition;
|
|
1170
1384
|
/** Quarter-turn block rotation in radians to compensate when locking UVs. */
|
|
1171
1385
|
uvLockRotation?: TripleArray;
|
|
1172
|
-
/** sRGB 0xRRGGBB colors by face tint index
|
|
1386
|
+
/** sRGB 0xRRGGBB colors by face tint index, overriding automatic item or block preview colors. */
|
|
1173
1387
|
tints?: Record<number, number>;
|
|
1174
1388
|
/** Hidden neighbor directions in CUBE_FACES order, before the model's block rotation. */
|
|
1175
1389
|
cullMask?: number;
|
|
1176
1390
|
}
|
|
1177
1391
|
declare function isModelObject(obj: any): obj is ModelObject;
|
|
1178
1392
|
|
|
1393
|
+
/** Shares initialized model objects by cache key and allocates references to their placements. */
|
|
1179
1394
|
declare class InstanceManager {
|
|
1180
1395
|
readonly isInstanceManager: true;
|
|
1181
1396
|
protected readonly instanceCache: {
|
|
1182
1397
|
[key: string]: Promise<InstanceReference<SceneObject>>;
|
|
1183
1398
|
};
|
|
1184
1399
|
constructor();
|
|
1400
|
+
/** Allocates a new placement of a cached model, or returns `undefined` if the key is unknown. */
|
|
1185
1401
|
get<T extends SceneObject>(key: string): Promise<Maybe<InstanceReference<T>>>;
|
|
1402
|
+
/** Allocates a placement, calling the supplier once when the shared model is first needed. */
|
|
1186
1403
|
getOrCreate<T extends SceneObject>(key: string, supplier: () => T | Promise<T>): Promise<InstanceReference<T>>;
|
|
1404
|
+
/** Forgets cached models without disposing them or releasing their existing placements. */
|
|
1187
1405
|
reset(): void;
|
|
1188
1406
|
}
|
|
1189
1407
|
declare function isInstanceManager(obj: any): obj is InstanceManager;
|
|
@@ -1221,6 +1439,14 @@ declare class SkinObject extends SceneObject {
|
|
|
1221
1439
|
init(): Promise<void>;
|
|
1222
1440
|
protected removeMeshes(): void;
|
|
1223
1441
|
protected createMeshes(): void;
|
|
1442
|
+
/**
|
|
1443
|
+
* Loads a skin texture, detecting slim arms and legacy layouts by default.
|
|
1444
|
+
* To override detection, set `slim` or `legacy` in the options passed to
|
|
1445
|
+
* `new SkinObject(options)` or `scene.addSkin(src, options)`.
|
|
1446
|
+
* Use {@link setSlim} or {@link setLegacy} to change these settings later.
|
|
1447
|
+
*
|
|
1448
|
+
* @param src - URL of the skin texture.
|
|
1449
|
+
*/
|
|
1224
1450
|
setSkinTexture(src: string): Promise<void>;
|
|
1225
1451
|
/** Load a cape texture in the selected layout, or pass undefined to remove the cape. */
|
|
1226
1452
|
setCapeTexture(src?: string, layout?: CapeLayout): Promise<void>;
|
|
@@ -1232,11 +1458,15 @@ declare class SkinObject extends SceneObject {
|
|
|
1232
1458
|
dispose(): void;
|
|
1233
1459
|
protected getBoxGeometry(part: SkinPart): BoxGeometry;
|
|
1234
1460
|
}
|
|
1461
|
+
/** Player settings passed to `new SkinObject(options)` or `scene.addSkin(src, options)`. */
|
|
1235
1462
|
interface SkinObjectOptions extends SceneObjectOptions {
|
|
1463
|
+
/** Forces slim (`true`) or classic (`false`) arms. Omit it to detect the model from the texture. */
|
|
1236
1464
|
slim?: boolean;
|
|
1465
|
+
/** Forces the legacy (`true`) or modern (`false`) texture layout. Omit it to detect the layout. */
|
|
1237
1466
|
legacy?: boolean;
|
|
1238
1467
|
}
|
|
1239
1468
|
|
|
1469
|
+
/** Playback settings passed to {@link EntityObject.playAnimation}, {@link EntityObject.playAnimations}, or {@link EntityAnimationPlayer.play}. */
|
|
1240
1470
|
interface EntityAnimationOptions {
|
|
1241
1471
|
/** Overrides the animation's own `loop` flag. */
|
|
1242
1472
|
loop?: boolean;
|
|
@@ -1267,11 +1497,14 @@ declare class EntityAnimationPlayer {
|
|
|
1267
1497
|
stop(): boolean;
|
|
1268
1498
|
/** Forgets the animation without touching the parts, for parts that no longer exist. */
|
|
1269
1499
|
clear(): void;
|
|
1500
|
+
/** Applies the pose at an absolute playback time. Returns `false` when no clip is active. */
|
|
1270
1501
|
setTime(seconds: number): boolean;
|
|
1502
|
+
/** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */
|
|
1271
1503
|
advance(deltaSeconds: number): boolean;
|
|
1272
1504
|
private apply;
|
|
1273
1505
|
}
|
|
1274
1506
|
|
|
1507
|
+
/** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */
|
|
1275
1508
|
declare class EntityObject extends SceneObject {
|
|
1276
1509
|
readonly entity: EntityModel;
|
|
1277
1510
|
readonly isEntityObject: true;
|
|
@@ -1315,8 +1548,11 @@ declare class EntityObject extends SceneObject {
|
|
|
1315
1548
|
setAnimationTime(seconds: number): void;
|
|
1316
1549
|
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
1317
1550
|
advanceAnimation(deltaSeconds: number): void;
|
|
1551
|
+
/** Finds a selected draw by its layer key, such as `main` or `main#2`, or returns `undefined`. */
|
|
1318
1552
|
getLayerGroup(name: string): Maybe<Object3D>;
|
|
1553
|
+
/** Finds a part name without `group:`. Supply `layerName` to restrict the search to one draw. */
|
|
1319
1554
|
getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
|
|
1555
|
+
/** Finds a mesh name without `mesh:`. Supply `layerName` to restrict the search to one draw. */
|
|
1320
1556
|
getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
|
|
1321
1557
|
private get entityLayers();
|
|
1322
1558
|
private getTextureKey;
|
|
@@ -1325,6 +1561,7 @@ declare class EntityObject extends SceneObject {
|
|
|
1325
1561
|
private createPart;
|
|
1326
1562
|
protected applyTextures(): Promise<void>;
|
|
1327
1563
|
}
|
|
1564
|
+
/** Render settings passed to `scene.addEntity(entity, options)` or the EntityObject constructor. */
|
|
1328
1565
|
interface EntityObjectOptions extends SceneObjectOptions {
|
|
1329
1566
|
/**
|
|
1330
1567
|
* `true` applies only vanilla's entity flip, scale (-1, -1, 1); `false` keeps raw model space.
|
|
@@ -1336,17 +1573,20 @@ interface EntityObjectOptions extends SceneObjectOptions {
|
|
|
1336
1573
|
}
|
|
1337
1574
|
declare function isEntityObject(obj: any): obj is EntityObject;
|
|
1338
1575
|
|
|
1576
|
+
/** Text appearance set on a GUI text layer or overridden by an individual text run. */
|
|
1339
1577
|
interface GuiTextStyle {
|
|
1340
1578
|
/** sRGB 0xRRGGBB; defaults to white. */
|
|
1341
1579
|
color?: number;
|
|
1342
1580
|
bold?: boolean;
|
|
1343
1581
|
italic?: boolean;
|
|
1344
1582
|
}
|
|
1583
|
+
/** A text segment with optional style overrides within {@link GuiText}. */
|
|
1345
1584
|
interface GuiTextRun extends GuiTextStyle {
|
|
1346
1585
|
text: string;
|
|
1347
1586
|
}
|
|
1348
1587
|
/** Literal text, or styled runs. Newlines are preserved. */
|
|
1349
1588
|
type GuiText = string | readonly GuiTextRun[];
|
|
1589
|
+
/** Text layout settings set on a GUI text layer or passed to {@link layoutGuiText}. */
|
|
1350
1590
|
interface GuiTextOptions extends GuiTextStyle {
|
|
1351
1591
|
/** Font resource ID; defaults to minecraft:default. */
|
|
1352
1592
|
font?: AssetKey | string;
|
|
@@ -1357,6 +1597,7 @@ interface GuiTextOptions extends GuiTextStyle {
|
|
|
1357
1597
|
/** Distance between line origins; defaults to 9 GUI pixels. */
|
|
1358
1598
|
lineHeight?: number;
|
|
1359
1599
|
}
|
|
1600
|
+
/** One measured glyph and its position in GUI pixels, produced by {@link layoutGuiText}. */
|
|
1360
1601
|
interface PositionedGuiGlyph {
|
|
1361
1602
|
character: string;
|
|
1362
1603
|
glyph?: BitmapGlyph;
|
|
@@ -1365,6 +1606,7 @@ interface PositionedGuiGlyph {
|
|
|
1365
1606
|
advance: number;
|
|
1366
1607
|
style: Required<GuiTextStyle>;
|
|
1367
1608
|
}
|
|
1609
|
+
/** Measured glyphs, line widths, and overall dimensions in GUI pixels. */
|
|
1368
1610
|
interface GuiTextLayout {
|
|
1369
1611
|
glyphs: PositionedGuiGlyph[];
|
|
1370
1612
|
lineWidths: number[];
|
|
@@ -1388,21 +1630,28 @@ interface GuiLayerLayout {
|
|
|
1388
1630
|
/** Output size; defaults to native texture/text dimensions, and [16, 16] for items. */
|
|
1389
1631
|
size?: [number, number];
|
|
1390
1632
|
}
|
|
1633
|
+
/** A texture layer for {@link MineRenderScene.addGui}. Uncropped textures use their `.mcmeta` scaling rules. */
|
|
1391
1634
|
interface GuiTextureLayer extends GuiLayerLayout {
|
|
1392
1635
|
texture: AssetKey | string;
|
|
1393
1636
|
/** Source-image pixels: [x, y, width, height], measured from the top left. Crops ignore sprite scaling. */
|
|
1394
1637
|
crop?: [number, number, number, number];
|
|
1395
1638
|
}
|
|
1639
|
+
/** An item preview in a 16×16 GUI slot by default, with optional tint overrides. */
|
|
1396
1640
|
interface GuiItemLayer extends GuiLayerLayout {
|
|
1397
1641
|
/** Model key, such as minecraft:item/stone; uses the model's GUI display pose. */
|
|
1398
1642
|
item: AssetKey | string;
|
|
1399
|
-
/** sRGB 0xRRGGBB colors by face tint index
|
|
1643
|
+
/** sRGB 0xRRGGBB colors by face tint index, overriding the item's automatic preview colors. */
|
|
1400
1644
|
tints?: Record<number, number>;
|
|
1401
1645
|
}
|
|
1646
|
+
/** A bitmap-text layer. Set font, wrapping, and style directly on the layer object. */
|
|
1402
1647
|
interface GuiTextLayer extends GuiLayerLayout, GuiTextOptions {
|
|
1403
1648
|
text: GuiText;
|
|
1404
1649
|
}
|
|
1405
1650
|
|
|
1651
|
+
/**
|
|
1652
|
+
* Renders ordered texture, item, and text layers. Create it through {@link MineRenderScene.addGui}.
|
|
1653
|
+
* GUI coordinates grow right and down, with one pixel equal to one scene unit.
|
|
1654
|
+
*/
|
|
1406
1655
|
declare class GuiObject extends SceneObject {
|
|
1407
1656
|
readonly textureLayers: readonly GuiLayer[];
|
|
1408
1657
|
readonly isGuiObject: true;
|
|
@@ -1418,10 +1667,12 @@ declare class GuiObject extends SceneObject {
|
|
|
1418
1667
|
private loadMaterial;
|
|
1419
1668
|
disposeAndRemoveAllChildren(): void;
|
|
1420
1669
|
}
|
|
1670
|
+
/** Scene-object settings for `scene.addGui(layers, options)`. GUI objects disable instancing and mesh merging. */
|
|
1421
1671
|
interface GuiObjectOptions extends SceneObjectOptions {
|
|
1422
1672
|
}
|
|
1423
1673
|
declare function isGuiObject(obj: any): obj is GuiObject;
|
|
1424
1674
|
|
|
1675
|
+
/** A Three.js scene that initializes Minecraft objects and tracks changes that need a redraw. */
|
|
1425
1676
|
declare class MineRenderScene extends Scene {
|
|
1426
1677
|
readonly isMineRenderScene: true;
|
|
1427
1678
|
static readonly DEFAULT_OPTIONS: MineRenderSceneOptions;
|
|
@@ -1435,18 +1686,48 @@ declare class MineRenderScene extends Scene {
|
|
|
1435
1686
|
add(...objects: Object3D[]): this;
|
|
1436
1687
|
remove(...objects: Object3D[]): this;
|
|
1437
1688
|
private updateObjectRegistration;
|
|
1689
|
+
/** Initializes each object before attaching it to the scene. */
|
|
1438
1690
|
initAndAdd(...object: SceneObject[]): Promise<this>;
|
|
1439
1691
|
addSceneObject<A extends BasicMinecraftAsset, T extends SceneObject, O extends SceneObjectOptions>(asset: A, objectSupplier: () => T | Promise<T>, _options?: Partial<O>, parent?: Object3D): Promise<T | InstanceReference<T>>;
|
|
1692
|
+
/**
|
|
1693
|
+
* Adds a model loaded with {@link Models.getMerged}.
|
|
1694
|
+
* Set `options.instanceMeshes` to `false` to create a separate ModelObject.
|
|
1695
|
+
*
|
|
1696
|
+
* @param parent - Object to attach the model to. Defaults to this scene.
|
|
1697
|
+
* @returns The model, or a reference to one placement of a shared model.
|
|
1698
|
+
*/
|
|
1440
1699
|
addModel(model: Model, options?: Partial<ModelObjectOptions>, parent?: Object3D): Promise<ModelObject | InstanceReference<ModelObject>>;
|
|
1700
|
+
/**
|
|
1701
|
+
* Adds the models selected by a blockstate loaded with {@link BlockStates.get}.
|
|
1702
|
+
* Set `options.initialState` to choose block properties such as `facing` or `axis`.
|
|
1703
|
+
* Use the returned object's `setPosition` method to move all of its model parts.
|
|
1704
|
+
*/
|
|
1441
1705
|
addBlock(blockState: BlockState, options?: Partial<BlockObjectOptions>, parent?: Object3D): Promise<BlockObject | InstanceReference<BlockObject>>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Loads a skin and adds an initialized player model.
|
|
1708
|
+
*
|
|
1709
|
+
* @param skin - Texture URL, such as one returned by {@link Skins.fromUuidOrUsername}.
|
|
1710
|
+
* Omit it to assign a texture later with {@link SkinObject.setSkinTexture}.
|
|
1711
|
+
* @param options - Player settings, including `slim` and `legacy` detection overrides.
|
|
1712
|
+
* @param parent - Object to attach the player to. Defaults to this scene.
|
|
1713
|
+
*/
|
|
1442
1714
|
addSkin(skin?: string, options?: Partial<SkinObjectOptions>, parent?: Object3D): Promise<SkinObject>;
|
|
1715
|
+
/** Adds an entity loaded with {@link Entities.getEntity}, using its selected layers and textures. */
|
|
1443
1716
|
addEntity(entity: EntityModel, options?: Partial<EntityObjectOptions>, parent?: Object3D): Promise<EntityObject | InstanceReference<EntityObject>>;
|
|
1717
|
+
/**
|
|
1718
|
+
* Adds GUI layers in draw order. One GUI pixel equals one scene unit.
|
|
1719
|
+
* Layer positions start at the top left, with positive GUI y pointing down.
|
|
1720
|
+
*/
|
|
1444
1721
|
addGui(layers: readonly GuiLayer[], options?: Partial<GuiObjectOptions>, parent?: Object3D): Promise<GuiObject>;
|
|
1445
1722
|
}
|
|
1446
1723
|
interface MineRenderSceneOptions {
|
|
1447
1724
|
}
|
|
1448
1725
|
declare function isMineRenderScene(obj: any): obj is MineRenderScene;
|
|
1449
1726
|
|
|
1727
|
+
/**
|
|
1728
|
+
* Base for renderable Minecraft objects, with named parts and optional shared instances.
|
|
1729
|
+
* Use {@link notifyDirty} after changing a part directly so the renderer redraws it.
|
|
1730
|
+
*/
|
|
1450
1731
|
declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
1451
1732
|
change: {};
|
|
1452
1733
|
}> implements Disposable, Instanceable, Transformable {
|
|
@@ -1465,17 +1746,20 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1465
1746
|
set scene(scene: MineRenderScene);
|
|
1466
1747
|
get scene(): MineRenderScene;
|
|
1467
1748
|
init(): Promise<void>;
|
|
1749
|
+
/** Marks ancestor scenes for redraw and emits a `change` event. */
|
|
1468
1750
|
notifyDirty(): void;
|
|
1469
1751
|
protected createAndAddGroup(name?: string, x?: number, y?: number, z?: number, offsetAxis?: Axis, offset?: number): Object3D;
|
|
1470
1752
|
protected createGroup(name?: string, x?: number, y?: number, z?: number, offsetAxis?: Axis, offset?: number): Object3D;
|
|
1471
1753
|
/**
|
|
1472
|
-
*
|
|
1754
|
+
* Finds a named part, such as `head`, without the internal `group:` prefix.
|
|
1755
|
+
* Returns `undefined` when the group does not exist.
|
|
1473
1756
|
*/
|
|
1474
1757
|
getGroupByName(name: string): Maybe<Object3D>;
|
|
1475
1758
|
/**
|
|
1476
|
-
*
|
|
1477
|
-
* @param name name
|
|
1478
|
-
* @param visible
|
|
1759
|
+
* Changes a named group's visibility and requests a redraw.
|
|
1760
|
+
* @param name - Part name without the `group:` prefix.
|
|
1761
|
+
* @param visible - Visibility to assign. Omit it to toggle the current value.
|
|
1762
|
+
* @returns The resulting visibility, or `false` if the group does not exist.
|
|
1479
1763
|
*/
|
|
1480
1764
|
toggleGroupVisibility(name: string, visible?: boolean): boolean;
|
|
1481
1765
|
protected addOrReplaceMesh(mesh: Mesh, parent: Object3D, name?: string): void;
|
|
@@ -1483,13 +1767,14 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1483
1767
|
protected createMesh(name?: string, geometry?: BufferGeometry, material?: Material | Material[], offsetAxis?: Axis, offset?: number): Mesh;
|
|
1484
1768
|
protected createInstancedMesh(name: Maybe<string>, geometry: BufferGeometry, material: Material | Material[], count: number): InstancedMesh;
|
|
1485
1769
|
/**
|
|
1486
|
-
*
|
|
1770
|
+
* Finds a named mesh without the internal `mesh:` prefix, or returns `undefined`.
|
|
1487
1771
|
*/
|
|
1488
1772
|
getMeshByName(name: string): Maybe<Mesh>;
|
|
1489
1773
|
/**
|
|
1490
|
-
*
|
|
1491
|
-
* @param name name
|
|
1492
|
-
* @param visible
|
|
1774
|
+
* Changes a named mesh's visibility and requests a redraw.
|
|
1775
|
+
* @param name - Mesh name without the `mesh:` prefix.
|
|
1776
|
+
* @param visible - Visibility to assign. Omit it to toggle the current value.
|
|
1777
|
+
* @returns The resulting visibility, or `false` if the mesh does not exist.
|
|
1493
1778
|
*/
|
|
1494
1779
|
toggleMeshVisibility(name: string, visible?: boolean): boolean;
|
|
1495
1780
|
iterateAllMeshes(cb: (mesh: Mesh) => void): void;
|
|
@@ -1497,8 +1782,10 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1497
1782
|
protected _getBoxGeometryFromElement(element: ModelElement): BoxGeometry;
|
|
1498
1783
|
protected _getBoxGeometryForDimensionsAndUv(width: number, height: number, depth: number, uv: number[]): BoxGeometry;
|
|
1499
1784
|
get isInstanced(): boolean;
|
|
1785
|
+
/** Number of live placements, excluding released instance slots. */
|
|
1500
1786
|
get instanceCounter(): number;
|
|
1501
1787
|
protected constructInstanceReference(i: number): InstanceReference<SceneObject>;
|
|
1788
|
+
/** Allocates a placement of this instanced object, reusing a released slot when available. */
|
|
1502
1789
|
nextInstance(): InstanceReference<SceneObject>;
|
|
1503
1790
|
/** Returns the live reference for a raycast hit on this object's instance mesh. */
|
|
1504
1791
|
getInstanceReference(mesh: Object3D, index: number): Maybe<InstanceReference<SceneObject>>;
|
|
@@ -1516,37 +1803,48 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1516
1803
|
getRotationAt(index: number, euler?: Euler): Euler;
|
|
1517
1804
|
setScaleAt(index: number, scale: Vector3): void;
|
|
1518
1805
|
getScaleAt(index: number, vector?: Vector3): Vector3;
|
|
1806
|
+
/** Updates supplied transform components. For a shared model, affects every live instance. */
|
|
1519
1807
|
setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1808
|
+
/** Sets position in scene units. For a shared model, updates every live instance. */
|
|
1520
1809
|
setPosition(position: Vector3): void;
|
|
1521
1810
|
getPosition(): Vector3;
|
|
1811
|
+
/** Sets rotation in radians. For a shared model, updates every live instance. */
|
|
1522
1812
|
setRotation(rotation: Euler): void;
|
|
1523
1813
|
getRotation(): Euler;
|
|
1814
|
+
/** Sets scale factors. For a shared model, updates every live instance. */
|
|
1524
1815
|
setScale(scale: Vector3): void;
|
|
1525
1816
|
getScale(): Vector3;
|
|
1526
1817
|
protected toggleObjectVisibility(object?: Object3D, visible?: boolean): boolean;
|
|
1527
1818
|
dispose(): void;
|
|
1819
|
+
/** Releases instance slots and removes children, disposing children that implement Disposable. */
|
|
1528
1820
|
disposeAndRemoveAllChildren(): void;
|
|
1821
|
+
/** Detaches the object from its parent and requests a redraw. */
|
|
1529
1822
|
removeFromScene(): void;
|
|
1530
1823
|
}
|
|
1531
1824
|
declare function isSceneObject(obj: any): obj is SceneObject;
|
|
1532
1825
|
|
|
1533
1826
|
type FluidKind = "water" | "lava";
|
|
1827
|
+
/** Fluid contained in a block and whether the block's ordinary model is also drawn. */
|
|
1534
1828
|
interface BlockFluidState {
|
|
1535
1829
|
kind: FluidKind;
|
|
1536
1830
|
level: number;
|
|
1537
1831
|
renderModel: boolean;
|
|
1538
1832
|
}
|
|
1833
|
+
/** Finds water or lava from the block ID and properties, including waterlogged blocks and aquatic plants. */
|
|
1539
1834
|
declare function getBlockFluidState(key?: AssetKey, state?: BlockStateProperties): BlockFluidState | undefined;
|
|
1540
1835
|
declare function getFluidKind(key?: AssetKey, state?: BlockStateProperties): FluidKind | undefined;
|
|
1836
|
+
/** A neighboring cell's fluid level and full-cube occlusion state. */
|
|
1541
1837
|
interface FluidSample {
|
|
1542
1838
|
fluid?: FluidKind;
|
|
1543
1839
|
level?: number;
|
|
1544
1840
|
solid?: boolean;
|
|
1545
1841
|
}
|
|
1842
|
+
/** Reads cells at integer block offsets relative to the fluid being rendered, with `(0, 0, 0)` as the center. */
|
|
1546
1843
|
type FluidSampler = (x: number, y: number, z: number) => FluidSample;
|
|
1547
1844
|
/** Builds centered fluid faces with material groups 0 (still) and 1 (flowing). */
|
|
1548
1845
|
declare function createFluidGeometry(kind: FluidKind, sample: FluidSampler): BufferGeometry;
|
|
1549
1846
|
|
|
1847
|
+
/** Controls the model parts selected by a blockstate. Create it through {@link MineRenderScene.addBlock}. */
|
|
1550
1848
|
declare class BlockObject extends SceneObject {
|
|
1551
1849
|
readonly blockState: BlockState;
|
|
1552
1850
|
readonly isBlockObject: true;
|
|
@@ -1588,6 +1886,7 @@ declare class BlockObject extends SceneObject {
|
|
|
1588
1886
|
private getModelMatrix;
|
|
1589
1887
|
private getModelCullMask;
|
|
1590
1888
|
setCullMask(worldMask: number): Promise<void>;
|
|
1889
|
+
/** Selected property values. Use {@link setState} to change properties and rebuild the rendered models. */
|
|
1591
1890
|
get state(): {
|
|
1592
1891
|
[key: string]: string;
|
|
1593
1892
|
};
|
|
@@ -1602,7 +1901,13 @@ declare class BlockObject extends SceneObject {
|
|
|
1602
1901
|
protected getSingleVariant(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
|
|
1603
1902
|
protected createAVariant(variants: BlockStateVariant | BlockStateVariant[], instanceInfo: Matrix4[]): Promise<void>;
|
|
1604
1903
|
protected createVariant(variant: BlockStateVariant): Promise<ModelObject | InstanceReference<ModelObject>>;
|
|
1904
|
+
/** Clears selected properties and rebuilds models without reapplying property defaults. */
|
|
1605
1905
|
resetState(): Promise<void>;
|
|
1906
|
+
/**
|
|
1907
|
+
* Updates properties and rebuilds the selected models.
|
|
1908
|
+
* Accepts `"facing=north,open=true"`, a property object, or a key and value.
|
|
1909
|
+
* Properties omitted from the call keep their current values.
|
|
1910
|
+
*/
|
|
1606
1911
|
setState(string: string): any;
|
|
1607
1912
|
setState(state: BlockStateProperties): any;
|
|
1608
1913
|
setState(key: string, value: string): any;
|
|
@@ -1612,7 +1917,9 @@ declare class BlockObject extends SceneObject {
|
|
|
1612
1917
|
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
1613
1918
|
setPosition(position: Vector3): void;
|
|
1614
1919
|
}
|
|
1920
|
+
/** Block settings passed to `scene.addBlock(blockState, options)` or the BlockObject constructor. */
|
|
1615
1921
|
interface BlockObjectOptions extends ModelObjectOptions {
|
|
1922
|
+
/** Loads vanilla property defaults before applying `initialState`. Defaults to `true`. */
|
|
1616
1923
|
applyDefaultState: boolean;
|
|
1617
1924
|
/** Properties applied before model creation, overriding defaults when applyDefaultState is enabled. */
|
|
1618
1925
|
initialState?: BlockStateProperties;
|
|
@@ -1624,6 +1931,7 @@ declare function sampleFluid(kind: FluidKind, sample: FluidSampler): {
|
|
|
1624
1931
|
key: string;
|
|
1625
1932
|
sample: FluidSampler;
|
|
1626
1933
|
};
|
|
1934
|
+
/** Renders water or lava with neighbor-dependent surfaces and animated still/flow textures. */
|
|
1627
1935
|
declare class FluidModelObject extends ModelObject {
|
|
1628
1936
|
readonly kind: FluidKind;
|
|
1629
1937
|
private readonly sample;
|
|
@@ -1634,21 +1942,25 @@ declare class FluidModelObject extends ModelObject {
|
|
|
1634
1942
|
disposeAndRemoveAllChildren(): void;
|
|
1635
1943
|
}
|
|
1636
1944
|
|
|
1945
|
+
/** Parsed blocks and entity data for {@link MineRenderWorld.placeMultiBlock}. Dimensions and positions use blocks. */
|
|
1637
1946
|
interface MultiBlockStructure {
|
|
1638
1947
|
readonly size: TripleArray;
|
|
1639
1948
|
readonly blocks: MultiBlockBlock[];
|
|
1640
1949
|
readonly dataVersion?: number;
|
|
1641
1950
|
readonly entities?: MultiBlockEntity[];
|
|
1642
1951
|
}
|
|
1952
|
+
/** Preserved entity position and NBT. World placement does not create a render object for it. */
|
|
1643
1953
|
interface MultiBlockEntity {
|
|
1644
1954
|
position: TripleArray;
|
|
1645
1955
|
blockPosition?: TripleArray;
|
|
1646
1956
|
nbt: unknown;
|
|
1647
1957
|
}
|
|
1958
|
+
/** Block data and its position within a parsed structure. */
|
|
1648
1959
|
interface MultiBlockBlock extends Block {
|
|
1649
1960
|
position: TripleArray;
|
|
1650
1961
|
}
|
|
1651
1962
|
|
|
1963
|
+
/** Converts legacy Alpha `.schematic` NBT with numeric block IDs into modern block names and properties. */
|
|
1652
1964
|
declare class SchematicParser {
|
|
1653
1965
|
/**
|
|
1654
1966
|
* Parses a legacy schematic using custom mappings before the bundled defaults.
|
|
@@ -1664,9 +1976,16 @@ interface SchematicParserOptions {
|
|
|
1664
1976
|
lenient?: boolean;
|
|
1665
1977
|
}
|
|
1666
1978
|
|
|
1979
|
+
/** Converts Java structure NBT into blocks and preserved entity data for world placement. */
|
|
1667
1980
|
declare class StructureParser {
|
|
1981
|
+
/**
|
|
1982
|
+
* Parses decoded NBT, omitting air blocks.
|
|
1983
|
+
* @param _nbt - Structure data decoded by {@link NBTHelper.fromBuffer}.
|
|
1984
|
+
* @param paletteIndex - Palette to select when the structure has several. Defaults to 0.
|
|
1985
|
+
*/
|
|
1668
1986
|
static parse(_nbt: NBT, paletteIndex?: number): Promise<MultiBlockStructure>;
|
|
1669
1987
|
}
|
|
1988
|
+
/** Tagged NBT fields used by Java structure files. */
|
|
1670
1989
|
interface StructureNBT {
|
|
1671
1990
|
DataVersion?: {
|
|
1672
1991
|
type: "int";
|
|
@@ -1762,20 +2081,27 @@ interface BlockEntry {
|
|
|
1762
2081
|
};
|
|
1763
2082
|
}
|
|
1764
2083
|
|
|
2084
|
+
/** Decodes Named Binary Tag (NBT) data for structure and world parsers. */
|
|
1765
2085
|
declare class NBTHelper {
|
|
2086
|
+
/** Parses NBT bytes and preserves format and compression metadata. Omit `format` for automatic detection. */
|
|
1766
2087
|
static fromBuffer(data: Uint8Array | ArrayBuffer, format?: NBTFormat): Promise<NBTAsset>;
|
|
1767
2088
|
}
|
|
2089
|
+
/** Decoded NBT with the source format and parser metadata attached. */
|
|
1768
2090
|
interface NBTAsset extends MinecraftAsset, NBT {
|
|
1769
2091
|
format?: NBTFormat;
|
|
1770
2092
|
metadata?: Metadata;
|
|
1771
2093
|
compression?: "gzip" | "none";
|
|
1772
2094
|
}
|
|
1773
2095
|
|
|
2096
|
+
/** Configures a hosted asset request and converts its response into an asset. */
|
|
1774
2097
|
interface ResponseParser<T extends MinecraftAsset> {
|
|
2098
|
+
/** Sets response decoding or other request options before the request starts. */
|
|
1775
2099
|
config(request: RequestConfig): any;
|
|
2100
|
+
/** Returns `undefined` to permit source fallback, or throws to report a parse failure. */
|
|
1776
2101
|
parse(response: RequestResponse): Maybe<T> | Promise<Maybe<T>>;
|
|
1777
2102
|
}
|
|
1778
2103
|
|
|
2104
|
+
/** Loads assets over HTTP from a Minecraft directory tree rooted at the constructor's URL. */
|
|
1779
2105
|
declare class HostedAssetSource extends AssetSource {
|
|
1780
2106
|
static readonly MODEL: ResponseParser<Model>;
|
|
1781
2107
|
static readonly BLOCKSTATE: ResponseParser<BlockState>;
|
|
@@ -1785,11 +2111,16 @@ declare class HostedAssetSource extends AssetSource {
|
|
|
1785
2111
|
static readonly LIST: ResponseParser<ListAsset>;
|
|
1786
2112
|
static readonly JSON: ResponseParser<any>;
|
|
1787
2113
|
static readonly PARSER_MAP: Map<AssetParser, ResponseParser<any>>;
|
|
2114
|
+
/** Retries missing assets with the `minecraft` namespace and default root. Other failures reject. */
|
|
1788
2115
|
loadOrRetryWithDefaults<T extends MinecraftAsset>(key: AssetKey, parser: ResponseParser<T>): Promise<Maybe<T>>;
|
|
1789
2116
|
protected load<T extends MinecraftAsset>(key: AssetKey, parser: ResponseParser<T>): Promise<Maybe<T>>;
|
|
1790
2117
|
assetBasePath(key: AssetKey): string;
|
|
1791
2118
|
private readonly _root;
|
|
1792
2119
|
private readonly _options;
|
|
2120
|
+
/**
|
|
2121
|
+
* Creates a hosted source for {@link AssetLoader.addSource}.
|
|
2122
|
+
* Set `options.retryDefaults` to `false` to restrict lookups to the requested namespace and root.
|
|
2123
|
+
*/
|
|
1793
2124
|
constructor(root: string, options?: Partial<HostedAssetSourceOptions>);
|
|
1794
2125
|
get root(): string;
|
|
1795
2126
|
get cacheId(): string;
|
|
@@ -1800,12 +2131,14 @@ interface HostedAssetSourceOptions {
|
|
|
1800
2131
|
retryDefaults: boolean;
|
|
1801
2132
|
}
|
|
1802
2133
|
|
|
2134
|
+
/** A resource-pack ZIP entry, with its archive-relative path and lazily extracted bytes. */
|
|
1803
2135
|
interface ArchiveEntry {
|
|
1804
2136
|
filename: string;
|
|
1805
2137
|
directory: boolean;
|
|
1806
2138
|
getData(): Promise<Blob>;
|
|
1807
2139
|
}
|
|
1808
2140
|
|
|
2141
|
+
/** Supplies resource-pack entries to {@link ArchiveAssetSource}. */
|
|
1809
2142
|
interface ArchiveProxy {
|
|
1810
2143
|
/** Identifies the archive's content across sessions; undefined when it cannot be identified. */
|
|
1811
2144
|
readonly id?: string;
|
|
@@ -1831,12 +2164,14 @@ interface ArchiveAssetSourceOptions {
|
|
|
1831
2164
|
/** Target data-pack format, used for assets under data/. Omit to look up the selected version. */
|
|
1832
2165
|
dataPackFormat?: PackFormat;
|
|
1833
2166
|
}
|
|
2167
|
+
/** Loads assets from resource-pack ZIP entries. Register it with {@link AssetLoader.addSource}. */
|
|
1834
2168
|
declare class ArchiveAssetSource extends AssetSource implements ArchiveProxy {
|
|
1835
2169
|
readonly _archiveProxy: ArchiveProxy;
|
|
1836
2170
|
private readonly options;
|
|
1837
2171
|
private entries?;
|
|
1838
2172
|
private metadata?;
|
|
1839
2173
|
constructor(archiveProxy: ArchiveProxy, options?: ArchiveAssetSourceOptions);
|
|
2174
|
+
/** Creates a browser ZIP source from a Blob or File. */
|
|
1840
2175
|
static blob(blob: Blob, options?: ArchiveAssetSourceOptions): ArchiveAssetSource;
|
|
1841
2176
|
get cacheId(): Maybe<string>;
|
|
1842
2177
|
getEntries(): Promise<ArchiveEntry[]>;
|
|
@@ -1848,10 +2183,16 @@ declare class ArchiveAssetSource extends AssetSource implements ArchiveProxy {
|
|
|
1848
2183
|
assetBasePath(key: AssetKey): string;
|
|
1849
2184
|
}
|
|
1850
2185
|
|
|
2186
|
+
/** Reads a resource-pack ZIP from a browser Blob or File for {@link ArchiveAssetSource}. */
|
|
1851
2187
|
declare class BrowserArchiveProxy implements ArchiveProxy {
|
|
1852
2188
|
readonly _blob: Blob;
|
|
1853
2189
|
readonly _reader: ZipReader<Blob>;
|
|
1854
2190
|
readonly id?: string;
|
|
2191
|
+
/**
|
|
2192
|
+
* Opens a ZIP for asset lookup.
|
|
2193
|
+
* @param id - Cache identity for this content. Change it when the pack changes.
|
|
2194
|
+
* A File supplies an identity from its name, size, and modification time when omitted.
|
|
2195
|
+
*/
|
|
1855
2196
|
constructor(blob: Blob, id?: string);
|
|
1856
2197
|
getEntries(): Promise<ArchiveEntry[]>;
|
|
1857
2198
|
}
|
|
@@ -1863,6 +2204,7 @@ declare class PackFormats {
|
|
|
1863
2204
|
private static load;
|
|
1864
2205
|
}
|
|
1865
2206
|
|
|
2207
|
+
/** Bedrock client-entity resource references. This schema does not provide a Bedrock renderer. */
|
|
1866
2208
|
interface BedrockEntityDescription {
|
|
1867
2209
|
identifier: string;
|
|
1868
2210
|
materials: {
|
|
@@ -1883,6 +2225,7 @@ interface BedrockEntityDescription {
|
|
|
1883
2225
|
enable_attachables?: boolean;
|
|
1884
2226
|
}
|
|
1885
2227
|
|
|
2228
|
+
/** Bedrock client-entity JSON schema, provided for typing only. */
|
|
1886
2229
|
interface BedrockEntityFile {
|
|
1887
2230
|
format_version: string;
|
|
1888
2231
|
"minecraft:client_entity": {
|
|
@@ -1890,6 +2233,7 @@ interface BedrockEntityFile {
|
|
|
1890
2233
|
};
|
|
1891
2234
|
}
|
|
1892
2235
|
|
|
2236
|
+
/** Bedrock bone-and-cube geometry schema, provided for typing only. */
|
|
1893
2237
|
interface BedrockGeometry {
|
|
1894
2238
|
visible_bounds_width: number;
|
|
1895
2239
|
visible_bounds_height: number;
|
|
@@ -1917,11 +2261,13 @@ interface BedrockCube {
|
|
|
1917
2261
|
inflate?: number;
|
|
1918
2262
|
}
|
|
1919
2263
|
|
|
2264
|
+
/** A versioned Bedrock JSON container for named geometry definitions. */
|
|
1920
2265
|
interface BedrockGeometryFile {
|
|
1921
2266
|
format_version: string;
|
|
1922
2267
|
[key: string]: BedrockGeometry | any;
|
|
1923
2268
|
}
|
|
1924
2269
|
|
|
2270
|
+
/** Shared in-memory caches for loaded assets and render resources. Persistent stores are managed separately. */
|
|
1925
2271
|
declare class Caching {
|
|
1926
2272
|
static readonly rawImageCache: AsyncLoadingCache<CacheKey, ImageInfo>;
|
|
1927
2273
|
static readonly imageDataCache: AsyncLoadingCache<CacheKey, ImageData>;
|
|
@@ -1948,6 +2294,7 @@ declare class Caching {
|
|
|
1948
2294
|
private static createAssetCache;
|
|
1949
2295
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
1950
2296
|
private static get all();
|
|
2297
|
+
/** Invalidates in-memory entries so later lookups reload them. Persisted entries are retained. */
|
|
1951
2298
|
static clear(): void;
|
|
1952
2299
|
/**
|
|
1953
2300
|
* Clears every cache and stops its expiry timer.
|
|
@@ -1962,11 +2309,13 @@ declare class Caching {
|
|
|
1962
2309
|
/** Copies the nontransparent bounds without resizing the source; empty images become one transparent pixel. */
|
|
1963
2310
|
declare function trimCanvas(source: CompatCanvas): CompatCanvas;
|
|
1964
2311
|
|
|
2312
|
+
/** Reports invalid Minecraft data or an unsupported rendering operation. */
|
|
1965
2313
|
declare class MineRenderError extends Error {
|
|
1966
2314
|
constructor(msg: any);
|
|
1967
2315
|
get name(): string;
|
|
1968
2316
|
}
|
|
1969
2317
|
|
|
2318
|
+
/** Settings passed to {@link Renderer.toGLTF} or {@link SceneExporter.toGLTF}. */
|
|
1970
2319
|
interface SceneGLTFExportOptions {
|
|
1971
2320
|
/** Returns a GLB ArrayBuffer instead of a glTF object. */
|
|
1972
2321
|
binary?: boolean;
|
|
@@ -1986,13 +2335,22 @@ declare class SceneExporter {
|
|
|
1986
2335
|
static toGLTF(root: Object3D, options?: SceneGLTFExportOptions): Promise<Record<string, any> | ArrayBuffer>;
|
|
1987
2336
|
}
|
|
1988
2337
|
|
|
2338
|
+
/** Creates GUI positions and layer lists for {@link MineRenderScene.addGui}. */
|
|
1989
2339
|
declare class GuiHelper {
|
|
1990
2340
|
/** Sizes a tooltip around supplied text; the first entry is its title. */
|
|
1991
2341
|
static tooltip(lines: readonly GuiText[], options?: GuiTooltipOptions): Promise<GuiLayer[]>;
|
|
2342
|
+
/**
|
|
2343
|
+
* Calculates a slot's top-left position in GUI pixels.
|
|
2344
|
+
* @param slot - Zero-based slot index, or `[column, row]`.
|
|
2345
|
+
* @param origin - Position of the first slot.
|
|
2346
|
+
* @param offset - Horizontal and vertical spacing between slot origins, in pixels.
|
|
2347
|
+
* @param rowSize - Slots per row when `slot` is an index.
|
|
2348
|
+
*/
|
|
1992
2349
|
static inventorySlot(slot: number | [number, number], origin?: [number, number], offset?: [number, number], rowSize?: number): [number, number];
|
|
1993
2350
|
/** Creates crafting-table layers for ingredients and the result; stack counts are not drawn. */
|
|
1994
2351
|
static recipe(recipe: GuiRecipe, options?: GuiRecipeOptions): GuiLayer[];
|
|
1995
2352
|
}
|
|
2353
|
+
/** Settings passed to {@link GuiHelper.tooltip}. Its default `lineHeight` is 10 GUI pixels. */
|
|
1996
2354
|
interface GuiTooltipOptions extends GuiTextOptions {
|
|
1997
2355
|
/** Top-left text position, inside the tooltip's padding. */
|
|
1998
2356
|
position?: [number, number];
|
|
@@ -2004,7 +2362,9 @@ type GuiRecipeIngredientValue = string | {
|
|
|
2004
2362
|
} | {
|
|
2005
2363
|
tag: string;
|
|
2006
2364
|
};
|
|
2365
|
+
/** An item, tag, or alternatives list. Tags and alternatives need `GuiRecipeOptions.resolveIngredient`. */
|
|
2007
2366
|
type GuiRecipeIngredient = GuiRecipeIngredientValue | readonly GuiRecipeIngredientValue[];
|
|
2367
|
+
/** Shaped or shapeless crafting data accepted by {@link GuiHelper.recipe}. */
|
|
2008
2368
|
type GuiRecipe = ({
|
|
2009
2369
|
type: "minecraft:crafting_shaped" | "crafting_shaped";
|
|
2010
2370
|
pattern: readonly string[];
|
|
@@ -2021,6 +2381,7 @@ type GuiRecipe = ({
|
|
|
2021
2381
|
count?: number;
|
|
2022
2382
|
};
|
|
2023
2383
|
};
|
|
2384
|
+
/** Settings passed as the second argument to {@link GuiHelper.recipe}. */
|
|
2024
2385
|
interface GuiRecipeOptions {
|
|
2025
2386
|
/** Selects a concrete item ID or model AssetKey for a tag or alternatives array. */
|
|
2026
2387
|
resolveIngredient?: (ingredient: GuiRecipeIngredient) => string | AssetKey;
|
|
@@ -2106,6 +2467,11 @@ declare class MapControls extends OrbitControls {
|
|
|
2106
2467
|
constructor(object: Camera, domElement?: HTMLElement);
|
|
2107
2468
|
}
|
|
2108
2469
|
|
|
2470
|
+
/**
|
|
2471
|
+
* Renders a Minecraft scene with a camera and an optional effects composer.
|
|
2472
|
+
* Requires a browser DOM and WebGL. Call {@link appendTo} to attach the canvas,
|
|
2473
|
+
* then {@link start} to render scene changes.
|
|
2474
|
+
*/
|
|
2109
2475
|
declare class Renderer implements Disposable {
|
|
2110
2476
|
static readonly DEFAULT_OPTIONS: RendererOptions;
|
|
2111
2477
|
readonly options: RendererOptions;
|
|
@@ -2136,12 +2502,14 @@ declare class Renderer implements Disposable {
|
|
|
2136
2502
|
protected createControls(): Maybe<OrbitControls>;
|
|
2137
2503
|
init(): void;
|
|
2138
2504
|
get element(): Maybe<HTMLElement>;
|
|
2505
|
+
/** Attaches the canvas to an element and sizes it to that element's dimensions. */
|
|
2139
2506
|
appendTo(element: HTMLElement): void;
|
|
2140
2507
|
/**
|
|
2141
2508
|
* Redraws when the dispatcher emits the selected event. Registering the same pair twice has no effect.
|
|
2142
2509
|
* The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
|
|
2143
2510
|
*/
|
|
2144
2511
|
registerEventDispatcher(dispatcher: EventDispatcher<any>, changeEvent?: string): void;
|
|
2512
|
+
/** Updates the camera and canvas size. Width and height are in CSS pixels. */
|
|
2145
2513
|
resize(width: number, height: number): void;
|
|
2146
2514
|
get dirty(): boolean;
|
|
2147
2515
|
set dirty(dirty: boolean);
|
|
@@ -2151,7 +2519,9 @@ declare class Renderer implements Disposable {
|
|
|
2151
2519
|
* Registering the same callback twice has no effect. Image exports do not invoke callbacks.
|
|
2152
2520
|
*/
|
|
2153
2521
|
onFrame(callback: FrameCallback): () => void;
|
|
2522
|
+
/** Starts or resumes the animation loop and registered frame callbacks. */
|
|
2154
2523
|
start(): void;
|
|
2524
|
+
/** Pauses rendering and frame callbacks. Call {@link start} to resume. */
|
|
2155
2525
|
stop(): void;
|
|
2156
2526
|
/**
|
|
2157
2527
|
* Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
|
|
@@ -2167,8 +2537,11 @@ declare class Renderer implements Disposable {
|
|
|
2167
2537
|
* MIME type support and lossy quality (0–1) follow the canvas encoder.
|
|
2168
2538
|
*/
|
|
2169
2539
|
toImage(trim?: boolean, mime?: string, quality?: number): string;
|
|
2540
|
+
/** Exports visible scene meshes as OBJ text, without texture images. */
|
|
2170
2541
|
toObj(): string;
|
|
2542
|
+
/** Exports visible scene meshes as PLY. Set `options.binary` for an ArrayBuffer. */
|
|
2171
2543
|
toPLY(options?: PLYExporterOptions): string | ArrayBuffer;
|
|
2544
|
+
/** Exports a static textured scene in the browser. Set `options.binary` for GLB output. */
|
|
2172
2545
|
toGLTF(options?: SceneGLTFExportOptions): Promise<Record<string, any> | ArrayBuffer>;
|
|
2173
2546
|
protected get attachedToBody(): boolean;
|
|
2174
2547
|
protected get viewWidth(): number;
|
|
@@ -2180,13 +2553,16 @@ declare class Renderer implements Disposable {
|
|
|
2180
2553
|
/** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
|
|
2181
2554
|
get controls(): Maybe<OrbitControls>;
|
|
2182
2555
|
}
|
|
2556
|
+
/** Timing passed to callbacks registered with {@link Renderer.onFrame}. */
|
|
2183
2557
|
interface RendererFrame {
|
|
2184
2558
|
/** Animation-loop timestamp in seconds, relative to the browser's performance time origin. */
|
|
2185
2559
|
readonly time: number;
|
|
2186
2560
|
/** Seconds since this callback's previous update; zero on its first update after subscribing or starting. */
|
|
2187
2561
|
readonly delta: number;
|
|
2188
2562
|
}
|
|
2563
|
+
/** A synchronous scene update registered with {@link Renderer.onFrame}. */
|
|
2189
2564
|
type FrameCallback = (frame: RendererFrame) => void;
|
|
2565
|
+
/** Settings for `new Renderer(options)`. Omitted values use {@link Renderer.DEFAULT_OPTIONS}. */
|
|
2190
2566
|
interface RendererOptions {
|
|
2191
2567
|
camera: CameraOptions;
|
|
2192
2568
|
render: RenderOptions;
|
|
@@ -2194,12 +2570,14 @@ interface RendererOptions {
|
|
|
2194
2570
|
controls?: ControlsOptions;
|
|
2195
2571
|
debug: DebugOptions;
|
|
2196
2572
|
}
|
|
2573
|
+
/** Camera settings passed as `camera` in the Renderer constructor options. Positions use scene units. */
|
|
2197
2574
|
interface CameraOptions {
|
|
2198
2575
|
type: "perspective" | "orthographic";
|
|
2199
2576
|
near: number;
|
|
2200
2577
|
far: number;
|
|
2201
2578
|
perspective: {
|
|
2202
2579
|
aspect: undefined | number;
|
|
2580
|
+
/** Vertical field of view in degrees. */
|
|
2203
2581
|
fov: number;
|
|
2204
2582
|
};
|
|
2205
2583
|
orthographic: {
|
|
@@ -2211,6 +2589,7 @@ interface CameraOptions {
|
|
|
2211
2589
|
position: Vector3 | TripleArray;
|
|
2212
2590
|
lookingAt: Vector3 | TripleArray;
|
|
2213
2591
|
}
|
|
2592
|
+
/** Canvas and draw-loop settings passed as `render` in the Renderer constructor options. */
|
|
2214
2593
|
interface RenderOptions {
|
|
2215
2594
|
/** Maximum draw rate (60 by default); zero or a negative value disables the limit. */
|
|
2216
2595
|
fpsLimit: number;
|
|
@@ -2219,20 +2598,29 @@ interface RenderOptions {
|
|
|
2219
2598
|
stats: boolean;
|
|
2220
2599
|
antialias: boolean;
|
|
2221
2600
|
shade: boolean;
|
|
2601
|
+
/** Resizes to the attached element when the browser window resizes. */
|
|
2222
2602
|
autoResize: boolean;
|
|
2603
|
+
/** Draws even when the scene is unchanged, while still respecting `fpsLimit`. */
|
|
2223
2604
|
renderAlways: boolean;
|
|
2224
2605
|
}
|
|
2606
|
+
/** Effects settings passed as `composer` in the Renderer constructor options. */
|
|
2225
2607
|
interface ComposerOptions {
|
|
2226
2608
|
enabled: boolean;
|
|
2227
2609
|
}
|
|
2610
|
+
/** Set `controls: { enabled: true }` in the Renderer constructor to create owned OrbitControls. */
|
|
2228
2611
|
interface ControlsOptions {
|
|
2229
2612
|
enabled: boolean;
|
|
2230
2613
|
}
|
|
2614
|
+
/** Scene helpers enabled through `debug` in the Renderer constructor options. */
|
|
2231
2615
|
interface DebugOptions {
|
|
2232
2616
|
grid: boolean;
|
|
2233
2617
|
axes: boolean;
|
|
2234
2618
|
}
|
|
2235
2619
|
|
|
2620
|
+
/**
|
|
2621
|
+
* Browser controls for inspecting and editing scene objects with Ctrl/Cmd-click selection.
|
|
2622
|
+
* Construct it with a renderer, attach its panels with {@link appendTo}, and call {@link dispose} when finished.
|
|
2623
|
+
*/
|
|
2236
2624
|
declare class SceneInspector {
|
|
2237
2625
|
readonly renderer: Renderer;
|
|
2238
2626
|
readonly objectInfoContainer: HTMLDivElement;
|
|
@@ -2262,6 +2650,7 @@ declare class SceneInspector {
|
|
|
2262
2650
|
protected separator(name?: string): HTMLElement;
|
|
2263
2651
|
}
|
|
2264
2652
|
|
|
2653
|
+
/** A browser statistics panel refreshed once per second. Dispose it separately from its renderer. */
|
|
2265
2654
|
declare class SceneStatsDisplay implements Disposable {
|
|
2266
2655
|
readonly renderer: Renderer;
|
|
2267
2656
|
readonly statsContainer: HTMLDivElement;
|
|
@@ -2270,6 +2659,7 @@ declare class SceneStatsDisplay implements Disposable {
|
|
|
2270
2659
|
constructor(renderer: Renderer);
|
|
2271
2660
|
protected init(): void;
|
|
2272
2661
|
appendTo(el: HTMLElement): void;
|
|
2662
|
+
/** Stops the refresh timer and removes the panel from the page. */
|
|
2273
2663
|
dispose(): void;
|
|
2274
2664
|
add(line?: StatLine): void;
|
|
2275
2665
|
}
|
|
@@ -2285,10 +2675,130 @@ declare class StatLine {
|
|
|
2285
2675
|
update(): void;
|
|
2286
2676
|
}
|
|
2287
2677
|
|
|
2678
|
+
/** Portable scene setup. Positions use model units (16 per block); rotations use radians. */
|
|
2679
|
+
interface SceneDocument {
|
|
2680
|
+
format: "minerender-scene";
|
|
2681
|
+
version: 1;
|
|
2682
|
+
minecraftVersion?: string;
|
|
2683
|
+
camera?: {
|
|
2684
|
+
position: TripleArray;
|
|
2685
|
+
target: TripleArray;
|
|
2686
|
+
};
|
|
2687
|
+
objects: SceneObjectDefinition[];
|
|
2688
|
+
}
|
|
2689
|
+
interface SceneObjectDefinitionBase {
|
|
2690
|
+
id: string;
|
|
2691
|
+
name?: string;
|
|
2692
|
+
position?: TripleArray;
|
|
2693
|
+
rotation?: TripleArray;
|
|
2694
|
+
scale?: TripleArray;
|
|
2695
|
+
visible?: boolean;
|
|
2696
|
+
}
|
|
2697
|
+
type SceneSkinPosePart = "head" | "body" | "rightArm" | "leftArm" | "rightLeg" | "leftLeg" | "cape";
|
|
2698
|
+
interface SceneSkinDefinition extends SceneObjectDefinitionBase {
|
|
2699
|
+
type: "skin";
|
|
2700
|
+
/** Texture URL, Minecraft username, or UUID. Omit for Steve, or Alex with slim: true, from the active asset version. */
|
|
2701
|
+
skin?: string;
|
|
2702
|
+
cape?: {
|
|
2703
|
+
texture: string;
|
|
2704
|
+
layout?: CapeLayout;
|
|
2705
|
+
};
|
|
2706
|
+
options?: {
|
|
2707
|
+
slim?: boolean;
|
|
2708
|
+
legacy?: boolean;
|
|
2709
|
+
};
|
|
2710
|
+
/** Mesh names from SkinPart; hiding a base part does not hide its overlay. */
|
|
2711
|
+
hiddenParts?: string[];
|
|
2712
|
+
/** Absolute local XYZ joint rotations in radians; omitted joints keep their default pose. */
|
|
2713
|
+
pose?: Partial<Record<SceneSkinPosePart, TripleArray>>;
|
|
2714
|
+
}
|
|
2715
|
+
interface SceneBlockDefinition extends SceneObjectDefinitionBase {
|
|
2716
|
+
type: "block";
|
|
2717
|
+
asset: string;
|
|
2718
|
+
state?: Record<string, string>;
|
|
2719
|
+
options?: {
|
|
2720
|
+
wireframe?: boolean;
|
|
2721
|
+
tints?: Record<number, number>;
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
interface SceneModelDefinition extends SceneObjectDefinitionBase {
|
|
2725
|
+
type: "item" | "model";
|
|
2726
|
+
asset: string;
|
|
2727
|
+
options?: {
|
|
2728
|
+
wireframe?: boolean;
|
|
2729
|
+
displayPosition?: DisplayPosition;
|
|
2730
|
+
tints?: Record<number, number>;
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2733
|
+
interface SceneEntityDefinition extends SceneObjectDefinitionBase {
|
|
2734
|
+
type: "entity";
|
|
2735
|
+
asset: string;
|
|
2736
|
+
texture?: string;
|
|
2737
|
+
layers?: string[];
|
|
2738
|
+
when?: string[];
|
|
2739
|
+
textures?: Record<string, string>;
|
|
2740
|
+
options?: {
|
|
2741
|
+
flip?: boolean;
|
|
2742
|
+
wireframe?: boolean;
|
|
2743
|
+
tints?: Record<string, string | number>;
|
|
2744
|
+
};
|
|
2745
|
+
animation?: {
|
|
2746
|
+
name: string;
|
|
2747
|
+
loop?: boolean;
|
|
2748
|
+
speed?: number;
|
|
2749
|
+
time?: number;
|
|
2750
|
+
paused?: boolean;
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
type SceneGuiLayer = (Omit<GuiTextureLayer, "texture"> & {
|
|
2754
|
+
texture: string;
|
|
2755
|
+
}) | (Omit<GuiItemLayer, "item"> & {
|
|
2756
|
+
item: string;
|
|
2757
|
+
}) | (Omit<GuiTextLayer, "font"> & {
|
|
2758
|
+
font?: string;
|
|
2759
|
+
});
|
|
2760
|
+
interface SceneGuiDefinition extends SceneObjectDefinitionBase {
|
|
2761
|
+
type: "gui";
|
|
2762
|
+
layers: SceneGuiLayer[];
|
|
2763
|
+
}
|
|
2764
|
+
type SceneObjectDefinition = SceneSkinDefinition | SceneBlockDefinition | SceneModelDefinition | SceneEntityDefinition | SceneGuiDefinition;
|
|
2765
|
+
/** Validates and copies a scene document without requesting assets or changing the active asset version. */
|
|
2766
|
+
declare function parseSceneDocument(value: unknown): SceneDocument;
|
|
2767
|
+
|
|
2768
|
+
interface LoadedSceneObject {
|
|
2769
|
+
readonly root: Group;
|
|
2770
|
+
readonly object: SceneObject;
|
|
2771
|
+
readonly definition: SceneObjectDefinition;
|
|
2772
|
+
/** Advances entity playback in seconds unless the definition has paused it. */
|
|
2773
|
+
advanceAnimation(delta: number): void;
|
|
2774
|
+
/** Removes this object and releases its owned resources. Safe to call more than once. */
|
|
2775
|
+
dispose(): void;
|
|
2776
|
+
}
|
|
2777
|
+
interface LoadedSceneDocument {
|
|
2778
|
+
readonly root: Group;
|
|
2779
|
+
readonly objects: LoadedSceneObject[];
|
|
2780
|
+
readonly definition: SceneDocument;
|
|
2781
|
+
advanceAnimations(delta: number): void;
|
|
2782
|
+
dispose(): void;
|
|
2783
|
+
}
|
|
2784
|
+
/** Loads portable scene documents using the asset sources already configured by the caller. */
|
|
2785
|
+
declare class SceneDocumentLoader {
|
|
2786
|
+
static parse(value: unknown): SceneDocument;
|
|
2787
|
+
/**
|
|
2788
|
+
* Loads objects concurrently and attaches them in document order after every load succeeds.
|
|
2789
|
+
* A failure waits for all loads, disposes staged objects, and reports the first error in document order.
|
|
2790
|
+
*/
|
|
2791
|
+
static load(scene: MineRenderScene, value: unknown, parent?: Object3D): Promise<LoadedSceneDocument>;
|
|
2792
|
+
/** Loads an independently editable object. Its root owns the document's position, rotation, and scale. */
|
|
2793
|
+
static loadObject(scene: MineRenderScene, value: SceneObjectDefinition, parent?: Object3D): Promise<LoadedSceneObject>;
|
|
2794
|
+
private static loadValidatedObject;
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2288
2797
|
type SkinGeometries = Record<SkinPart, TripleArray>;
|
|
2289
2798
|
declare const classicSkinGeometries: SkinGeometries;
|
|
2290
2799
|
declare const slimSkinGeometries: SkinGeometries;
|
|
2291
2800
|
|
|
2801
|
+
/** Decodes skin pixels while preserving hidden RGB values in transparent PNG pixels. */
|
|
2292
2802
|
declare class SkinImage {
|
|
2293
2803
|
static getData(src: string): Promise<ImageData>;
|
|
2294
2804
|
private static decodePng;
|
|
@@ -2298,12 +2808,15 @@ type SkinTextureCoordinates = Record<SkinPart, ModelFaces>;
|
|
|
2298
2808
|
declare const classicSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
|
|
2299
2809
|
declare const slimSkinTextureCoordinates: Readonly<SkinTextureCoordinates>;
|
|
2300
2810
|
|
|
2811
|
+
/** A prepared shared skin material with detected arm-model and texture-layout flags. */
|
|
2301
2812
|
interface SkinTexture {
|
|
2302
2813
|
material: MeshBasicMaterial;
|
|
2303
2814
|
slim: boolean;
|
|
2304
2815
|
legacy: boolean;
|
|
2305
2816
|
}
|
|
2817
|
+
/** Prepares shared skin and cape materials, including legacy layout conversion and base-layer opacity. */
|
|
2306
2818
|
declare class SkinTextures {
|
|
2819
|
+
/** Loads a skin URL. Pass `legacy` to override layout detection from the image dimensions. */
|
|
2307
2820
|
static get(src: string, legacy?: boolean): Promise<SkinTexture>;
|
|
2308
2821
|
static getCape(src: string, layout?: CapeLayout): Promise<MeshBasicMaterial>;
|
|
2309
2822
|
private static createMaterial;
|
|
@@ -2312,12 +2825,18 @@ declare class SkinTextures {
|
|
|
2312
2825
|
private static makeBaseOpaque;
|
|
2313
2826
|
}
|
|
2314
2827
|
|
|
2828
|
+
/** Resolves player names, UUIDs, and service IDs to skin or cape texture URLs. */
|
|
2315
2829
|
declare class Skins {
|
|
2830
|
+
/** Returns a skin URL for {@link MineRenderScene.addSkin}, or `undefined` if name lookup fails. */
|
|
2316
2831
|
static fromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
|
|
2832
|
+
/** Builds a proxy URL for a UUID without downloading or checking the skin. */
|
|
2317
2833
|
static fromUuid(uuid: string): Promise<Maybe<string>>;
|
|
2318
2834
|
static fromUsername(username: string): Promise<Maybe<string>>;
|
|
2835
|
+
/** Looks up a saved MineSkin skin and returns its texture URL, or `undefined` on lookup failure. */
|
|
2319
2836
|
static fromMineSkin(mineskinId: string): Promise<Maybe<string>>;
|
|
2837
|
+
/** Resolves a player's Minecraft cape URL for {@link SkinObject.setCapeTexture}. */
|
|
2320
2838
|
static capeFromUuidOrUsername(uuidOrUsername: string): Promise<Maybe<string>>;
|
|
2839
|
+
/** Builds a proxy URL without checking whether the player has a cape. */
|
|
2321
2840
|
static capeFromUuid(uuid: string): Promise<Maybe<string>>;
|
|
2322
2841
|
static capeFromUsername(username: string): Promise<Maybe<string>>;
|
|
2323
2842
|
/** Returns a full static cape texture for a username or UUID. */
|
|
@@ -2342,27 +2861,34 @@ declare class Skins {
|
|
|
2342
2861
|
private static getMcProxyCapeUrl;
|
|
2343
2862
|
}
|
|
2344
2863
|
|
|
2864
|
+
/** Samples resource-pack colormaps to produce packed sRGB tint colors. */
|
|
2345
2865
|
declare class Colormaps {
|
|
2346
2866
|
/** Samples the selected resource pack's grass colormap using Minecraft's climate coordinates. */
|
|
2347
2867
|
static grassColor(origin?: AssetKey, temperature?: number, downfall?: number): Promise<number>;
|
|
2348
2868
|
}
|
|
2349
2869
|
|
|
2870
|
+
/** Creates sRGB textures immediately and fills their pixels after asynchronous image loading. */
|
|
2350
2871
|
declare class TextureLoader {
|
|
2351
2872
|
private static readonly failedTextures;
|
|
2352
2873
|
/** Reports whether image loading failed, so cached textures can be retried. */
|
|
2353
2874
|
static hasFailed(texture: Texture): boolean;
|
|
2354
2875
|
protected static createTexture(): Texture;
|
|
2355
2876
|
static loadInBackground(src: string, format?: PixelFormat, rotation?: number): Texture;
|
|
2877
|
+
/** Loads image pixels in the background. `rotation` is in radians. Check {@link hasFailed} for load failures. */
|
|
2356
2878
|
static load(src: string, format?: PixelFormat, rotation?: number): Texture;
|
|
2357
2879
|
}
|
|
2358
2880
|
|
|
2881
|
+
/** Creates and caches Three.js textures with nearest-neighbor sampling for Minecraft artwork. */
|
|
2359
2882
|
declare class Textures {
|
|
2360
2883
|
/** Creates the shared checkerboard from pixels without fetching or decoding an image. */
|
|
2361
2884
|
static getMissing(): DataTexture;
|
|
2885
|
+
/** Sets nearest-neighbor filters without changing the texture's color space. Returns the same texture. */
|
|
2362
2886
|
static initTextureProps<T extends Texture>(texture: T): T;
|
|
2363
2887
|
static createImage(key: TextureKey): Texture;
|
|
2364
2888
|
static createAsset(key: AssetKey): Texture;
|
|
2889
|
+
/** Creates an sRGB color texture from a canvas. */
|
|
2365
2890
|
static createCanvasTexture(canvas: HTMLCanvasElement): CanvasTexture;
|
|
2891
|
+
/** Returns a shared texture immediately and loads its image asynchronously. Failed cached loads are retried. */
|
|
2366
2892
|
static getImage(key: TextureKey): Texture;
|
|
2367
2893
|
}
|
|
2368
2894
|
|
|
@@ -2374,14 +2900,18 @@ declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): Bu
|
|
|
2374
2900
|
declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
|
|
2375
2901
|
declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
|
|
2376
2902
|
|
|
2903
|
+
/** Stores 4,096 block cells in a shared state palette, with separate NBT for each cell. */
|
|
2377
2904
|
declare class ChunkData {
|
|
2378
2905
|
private readonly indices;
|
|
2379
2906
|
private readonly palette;
|
|
2380
2907
|
private readonly paletteIds;
|
|
2381
2908
|
private readonly freeIds;
|
|
2382
2909
|
private readonly nbt;
|
|
2910
|
+
/** Returns a detached copy of a cell, or `undefined` for air. Indices range from 0 to 4095. */
|
|
2383
2911
|
get(index: number): Maybe<Block>;
|
|
2912
|
+
/** Captures a cell's data and returns a copy-producing reader that survives later cell changes. */
|
|
2384
2913
|
snapshot(index: number): Maybe<() => Block>;
|
|
2914
|
+
/** Copies block data into a cell. An omitted block or an air block clears the cell. */
|
|
2385
2915
|
set(index: number, block?: Block): void;
|
|
2386
2916
|
clear(): void;
|
|
2387
2917
|
static isAir(block: Maybe<Block>): boolean;
|
|
@@ -2390,9 +2920,11 @@ declare class ChunkData {
|
|
|
2390
2920
|
}
|
|
2391
2921
|
|
|
2392
2922
|
type RegionInput = Uint8Array | ArrayBuffer;
|
|
2923
|
+
/** Chunk columns decoded from an Anvil region file. */
|
|
2393
2924
|
interface AnvilRegion {
|
|
2394
2925
|
chunks: AnvilChunk[];
|
|
2395
2926
|
}
|
|
2927
|
+
/** A decoded chunk column. `x` and `z` are absolute chunk coordinates, and section `y` is a section coordinate. */
|
|
2396
2928
|
interface AnvilChunk {
|
|
2397
2929
|
x: number;
|
|
2398
2930
|
z: number;
|
|
@@ -2403,12 +2935,21 @@ interface AnvilChunk {
|
|
|
2403
2935
|
}[];
|
|
2404
2936
|
entities?: MultiBlockEntity[];
|
|
2405
2937
|
}
|
|
2938
|
+
/** Reads Java 1.13+ paletted `.mca` regions. Entity NBT is preserved without data-version migration. */
|
|
2406
2939
|
declare class AnvilParser {
|
|
2940
|
+
/** Lists occupied chunk positions within the region, using local coordinates from 0 to 31. */
|
|
2407
2941
|
static getChunkList(data: RegionInput): {
|
|
2408
2942
|
x: number;
|
|
2409
2943
|
z: number;
|
|
2410
2944
|
}[];
|
|
2945
|
+
/** Decodes all stored chunks. Gzip, zlib, and uncompressed payloads are supported. */
|
|
2411
2946
|
static parse(data: RegionInput): Promise<AnvilRegion>;
|
|
2947
|
+
/**
|
|
2948
|
+
* Decodes one chunk for {@link MineRenderWorld.placeChunk}.
|
|
2949
|
+
* @param localX - Chunk x within the region, from 0 to 31.
|
|
2950
|
+
* @param localZ - Chunk z within the region, from 0 to 31.
|
|
2951
|
+
* @returns The chunk with absolute coordinates, or `undefined` if the region has no chunk there.
|
|
2952
|
+
*/
|
|
2412
2953
|
static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
|
|
2413
2954
|
private static bytes;
|
|
2414
2955
|
private static locations;
|
|
@@ -2419,6 +2960,7 @@ declare class AnvilParser {
|
|
|
2419
2960
|
private static unpack;
|
|
2420
2961
|
}
|
|
2421
2962
|
|
|
2963
|
+
/** A placed block's data snapshot and optional render object, returned by world and chunk accessors. */
|
|
2422
2964
|
interface BlockInfo<SectionMeshing extends boolean = false> {
|
|
2423
2965
|
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
2424
2966
|
readonly block: Block;
|
|
@@ -2426,33 +2968,45 @@ interface BlockInfo<SectionMeshing extends boolean = false> {
|
|
|
2426
2968
|
object: SectionMeshing extends false ? BlockObject : BlockObject | undefined;
|
|
2427
2969
|
}
|
|
2428
2970
|
|
|
2971
|
+
/** Shared cube geometry and atlas data prepared for section merging. */
|
|
2429
2972
|
interface SectionMeshTemplate {
|
|
2430
2973
|
geometry: BufferGeometry;
|
|
2431
2974
|
atlas: TextureAtlas;
|
|
2432
2975
|
cullFaces: readonly number[];
|
|
2433
2976
|
}
|
|
2977
|
+
/** One block placement in a section, with its storage index and hidden-face mask. */
|
|
2434
2978
|
interface SectionMeshEntry {
|
|
2435
2979
|
index: number;
|
|
2436
2980
|
template: SectionMeshTemplate;
|
|
2437
2981
|
cullMask: number;
|
|
2438
2982
|
}
|
|
2983
|
+
/** Merged terrain geometry and atlas pages for one 16×16×16 section. Owns its generated render resources. */
|
|
2439
2984
|
declare class SectionMesh extends Group {
|
|
2440
2985
|
private readonly ownedMeshes;
|
|
2986
|
+
/** Builds section-local meshes from visible cube faces. `maxAtlasSize` limits each atlas dimension in pixels. */
|
|
2441
2987
|
static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
|
|
2442
2988
|
dispose(): void;
|
|
2443
2989
|
}
|
|
2444
2990
|
|
|
2991
|
+
/** Prepares and caches static opaque cube geometry for merged world sections. */
|
|
2445
2992
|
declare class SectionModels {
|
|
2446
2993
|
readonly maxAtlasSize: number;
|
|
2447
2994
|
private states;
|
|
2448
2995
|
private models;
|
|
2449
2996
|
private readonly templates;
|
|
2450
2997
|
constructor(maxAtlasSize?: number);
|
|
2998
|
+
/** Returns a cube template, or `undefined` when the block requires an individual render object. */
|
|
2451
2999
|
get(blockState: BlockState, properties?: BlockStateProperties): Promise<SectionMeshTemplate | undefined>;
|
|
2452
3000
|
private prepare;
|
|
3001
|
+
/** Disposes prepared geometry and clears this world's template caches. */
|
|
2453
3002
|
clear(): void;
|
|
2454
3003
|
}
|
|
2455
3004
|
|
|
3005
|
+
/**
|
|
3006
|
+
* A 16×16×16 block section and its render objects.
|
|
3007
|
+
* Constructor coordinates identify the section. Block accessors use world block coordinates
|
|
3008
|
+
* unless their name explicitly refers to positions within the chunk.
|
|
3009
|
+
*/
|
|
2456
3010
|
declare class Chunk<SectionMeshing extends boolean = false> {
|
|
2457
3011
|
private readonly onBlocksChanged?;
|
|
2458
3012
|
private readonly sectionModels?;
|
|
@@ -2471,28 +3025,36 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
2471
3025
|
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
2472
3026
|
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
2473
3027
|
/**
|
|
2474
|
-
*
|
|
3028
|
+
* Places a block at integer world block coordinates. Pass `undefined` to remove it.
|
|
2475
3029
|
*/
|
|
2476
3030
|
setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2477
3031
|
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2478
3032
|
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2479
3033
|
/**
|
|
2480
|
-
*
|
|
3034
|
+
* Places a block at integer chunk-local coordinates from 0 to 15.
|
|
2481
3035
|
*/
|
|
2482
3036
|
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
3037
|
+
/** Changes visibility at world block coordinates while preserving the block's data. */
|
|
2483
3038
|
setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
|
|
2484
3039
|
isBlockVisibleAt(pos: Vector3): boolean;
|
|
2485
3040
|
isOccludingAt(pos: Vector3): boolean;
|
|
2486
3041
|
setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
|
|
2487
3042
|
rebuildSectionMesh(): void;
|
|
3043
|
+
/** Removes stored blocks and their render objects, then notifies the owning world of changed positions. */
|
|
2488
3044
|
clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
|
|
2489
3045
|
dispose(): Promise<void>;
|
|
2490
3046
|
static isAir(block: Maybe<Block>): boolean;
|
|
3047
|
+
/** Maps chunk-local coordinates from 0 to 15 to a storage index, with x varying fastest, then z, then y. */
|
|
2491
3048
|
static chunkPosToBlockIndex(pos: Vector3): number;
|
|
2492
3049
|
worldPosToChunkPos(pos: Vector3): Vector3;
|
|
2493
3050
|
chunkPosToWorldPos(pos: Vector3): Vector3;
|
|
2494
3051
|
}
|
|
2495
3052
|
|
|
3053
|
+
/**
|
|
3054
|
+
* Stores and renders blocks in sparse 16×16×16 chunks.
|
|
3055
|
+
* Positions use integer block coordinates, including negatives. One block is 16 scene units.
|
|
3056
|
+
* Set `options.sectionMeshing` in `new MineRenderWorld(scene, options)` to merge compatible terrain.
|
|
3057
|
+
*/
|
|
2496
3058
|
declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
2497
3059
|
readonly scene: MineRenderScene;
|
|
2498
3060
|
private readonly _chunks;
|
|
@@ -2500,9 +3062,14 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
2500
3062
|
private readonly pendingCulling;
|
|
2501
3063
|
private culling?;
|
|
2502
3064
|
constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
|
|
3065
|
+
/** Returns a placed block at world block coordinates, or `undefined` for an empty position. */
|
|
2503
3066
|
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
2504
3067
|
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
2505
3068
|
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
3069
|
+
/**
|
|
3070
|
+
* Places or replaces a block and refreshes neighboring faces.
|
|
3071
|
+
* Pass `undefined` or an air block to remove the block at these world block coordinates.
|
|
3072
|
+
*/
|
|
2506
3073
|
setBlockAt(x: number, y: number, z: number, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2507
3074
|
setBlockAt(pos: Vector3, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
2508
3075
|
setBlockAt(pos: TripleArray, block: Maybe<Block>): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
@@ -2514,6 +3081,13 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
2514
3081
|
setBlockVisibleAt(x: number, y: number, z: number, visible: boolean): Promise<void>;
|
|
2515
3082
|
setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
|
|
2516
3083
|
setBlockVisibleAt(pos: TripleArray, visible: boolean): Promise<void>;
|
|
3084
|
+
/**
|
|
3085
|
+
* Places a structure's blocks at their stored positions, then refreshes neighboring faces.
|
|
3086
|
+
* Entity NBT is retained by the structure but is not rendered.
|
|
3087
|
+
*
|
|
3088
|
+
* @param useBatches - Uses bounded batches by default. Set to `false` for sequential placement.
|
|
3089
|
+
* @param executor - Optional queue for batched placement. The caller remains responsible for stopping it.
|
|
3090
|
+
*/
|
|
2517
3091
|
placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
|
|
2518
3092
|
private placeBlocks;
|
|
2519
3093
|
/** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
|
|
@@ -2524,15 +3098,20 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
2524
3098
|
*/
|
|
2525
3099
|
unloadChunkColumn(x: number, z: number): Promise<void>;
|
|
2526
3100
|
private clearChunkColumn;
|
|
3101
|
+
/** Removes all chunks and releases their block placements and section meshes. */
|
|
2527
3102
|
clear(): Promise<void>;
|
|
2528
3103
|
private updateCulling;
|
|
2529
3104
|
private getOrCreateChunkAt;
|
|
3105
|
+
/** Returns the loaded chunk containing a world block position, without creating a chunk. */
|
|
2530
3106
|
getChunkAt(pos: Vector3): Maybe<Chunk<SectionMeshing>>;
|
|
3107
|
+
/** Converts block coordinates to scene units by multiplying each component by 16. */
|
|
2531
3108
|
static worldToScenePosition(pos: Vector3): Vector3;
|
|
3109
|
+
/** Converts scene units to block coordinates without rounding to an integer block. */
|
|
2532
3110
|
static sceneToWorldPosition(pos: Vector3): Vector3;
|
|
2533
3111
|
worldPosToChunkKey(pos: Vector3): string;
|
|
2534
3112
|
validatePosBounds(pos: Vector3): void;
|
|
2535
3113
|
}
|
|
3114
|
+
/** Settings passed as the second argument to `new MineRenderWorld(scene, options)`. */
|
|
2536
3115
|
interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
|
|
2537
3116
|
/** Merge static opaque cubes into section meshes. Merged blocks have no individual object. */
|
|
2538
3117
|
sectionMeshing?: SectionMeshing;
|
|
@@ -2557,6 +3136,7 @@ declare class NodeEnv implements EnvProvider {
|
|
|
2557
3136
|
imageSize(data: Uint8Array): ImageSizeInfo;
|
|
2558
3137
|
openCache(name: string, version: number): PersistentCache;
|
|
2559
3138
|
}
|
|
3139
|
+
/** Installs the Node provider. The Node package entry calls this automatically and requires native `canvas`. */
|
|
2560
3140
|
declare function registerNodeEnv(): NodeEnv;
|
|
2561
3141
|
|
|
2562
3142
|
/**
|
|
@@ -2578,4 +3158,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
|
|
|
2578
3158
|
forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
|
|
2579
3159
|
}
|
|
2580
3160
|
|
|
2581
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveAssetSourceOptions, 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 BitmapFont, type BitmapGlyph, 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, 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, Fonts, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, 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, NodeCache, NodeEnv, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, 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, type SchematicParserOptions, 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, createGuiTextGeometry, createGuiTextureGeometry, 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, layoutGuiText, 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 };
|
|
3161
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveAssetSourceOptions, 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 BitmapFont, type BitmapGlyph, 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, 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, Fonts, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, 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, type LoadedSceneDocument, type LoadedSceneObject, 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, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, 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, createGuiTextGeometry, createGuiTextureGeometry, 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, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
|