minerender 2.1.0-beta.2 → 2.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/browser/index.d.mts +1153 -332
- package/dist/browser/index.d.ts +1153 -332
- package/dist/browser/index.js +5124 -3103
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +5075 -3056
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/section.worker.js +294 -0
- package/dist/browser/section.worker.js.map +1 -0
- package/dist/browser/section.worker.mjs +294 -0
- package/dist/browser/section.worker.mjs.map +1 -0
- package/dist/bundle.js +7149 -5019
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +1214 -359
- package/dist/node/index.d.ts +1214 -359
- package/dist/node/index.js +5357 -3149
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +5234 -3051
- package/dist/node/index.mjs.map +1 -1
- package/package.json +4 -2
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, Group, DataTexture, CanvasTexture, InterleavedBufferAttribute, TrianglesDrawModes, Line, Points } from 'three';
|
|
2
|
+
import { Vector3, PixelFormat, BoxGeometry, Material, ColorRepresentation, MeshBasicMaterial, Mesh, Euler, Vector2, BufferAttribute, Float32BufferAttribute, BufferGeometry, Object3D, Box3, InstancedMesh, PerspectiveCamera, OrthographicCamera, Matrix4, Box2, Scene, Object3DEventMap, ShaderMaterial, Texture, Camera, MOUSE, TOUCH, Controls, 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';
|
|
@@ -11,6 +11,7 @@ export { PLYExporterOptions } from 'three/examples/jsm/exporters/PLYExporter.js'
|
|
|
11
11
|
import Stats from 'stats.js';
|
|
12
12
|
import { EffectComposer } from 'postprocessing';
|
|
13
13
|
import { LocalStorage } from 'node-persist';
|
|
14
|
+
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
14
15
|
|
|
15
16
|
/** Advances a texture animation by one tick. Return `false` when its pixels have not changed. */
|
|
16
17
|
interface AnimatorFunction {
|
|
@@ -106,6 +107,8 @@ interface EnvProvider {
|
|
|
106
107
|
/** Read width/height out of encoded image bytes without fully decoding them. */
|
|
107
108
|
imageSize(data: Uint8Array): ImageSizeInfo;
|
|
108
109
|
openCache(name: string, version: number): PersistentCache;
|
|
110
|
+
/** Optional worker support; returns undefined where unavailable. Only the browser ESM build ships worker files. */
|
|
111
|
+
createWorker?(name: "section"): Worker | undefined;
|
|
109
112
|
}
|
|
110
113
|
/**
|
|
111
114
|
* Registry holding the active {@link EnvProvider}.
|
|
@@ -221,6 +224,7 @@ declare class AssetKey extends BasicAssetKey {
|
|
|
221
224
|
/** Returns a cache identifier that includes the explicit root or {@link AssetLoader.ROOT}. */
|
|
222
225
|
serialize(): string;
|
|
223
226
|
}
|
|
227
|
+
declare function isResourceLocation(value: unknown): value is string;
|
|
224
228
|
declare function isBasicAssetKey(obj: any): obj is BasicAssetKey;
|
|
225
229
|
declare function isAssetKey(obj: any): obj is AssetKey;
|
|
226
230
|
|
|
@@ -453,12 +457,16 @@ declare class Requests {
|
|
|
453
457
|
/** Provides pixel and frame access to a canvas-backed image. Simple frame helpers assume a vertical strip of squares. */
|
|
454
458
|
declare class WrappedImage {
|
|
455
459
|
readonly dta: ExtractableImageData;
|
|
460
|
+
private alpha?;
|
|
456
461
|
constructor(dta: ExtractableImageData);
|
|
457
462
|
get data(): ImageData$1;
|
|
458
463
|
get dataArray(): Uint8ClampedArray;
|
|
459
464
|
get width(): number;
|
|
460
465
|
get height(): number;
|
|
461
466
|
get hasTransparency(): boolean;
|
|
467
|
+
/** Whether any pixel has partial alpha. Binary alpha renders as cutout, not blended. */
|
|
468
|
+
get hasTranslucency(): boolean;
|
|
469
|
+
private getAlpha;
|
|
462
470
|
/** Whether the dimensions form a vertical strip of square frames, without consulting `.mcmeta`. */
|
|
463
471
|
get animated(): boolean;
|
|
464
472
|
get frameWidth(): number;
|
|
@@ -501,7 +509,7 @@ declare class ImageLoader {
|
|
|
501
509
|
static getWrapped(src: string): Promise<WrappedImage>;
|
|
502
510
|
}
|
|
503
511
|
|
|
504
|
-
/**
|
|
512
|
+
/** @deprecated Fixed 1.21.11 palette. Use {@link BannerPatterns.getColors} for the selected version. */
|
|
505
513
|
declare const DYE_COLORS: Readonly<{
|
|
506
514
|
readonly white: 16383998;
|
|
507
515
|
readonly orange: 16351261;
|
|
@@ -534,7 +542,9 @@ interface BannerPatternDraw {
|
|
|
534
542
|
declare class BannerPatterns {
|
|
535
543
|
/** Lists namespaced pattern IDs from the selected namespace's data directory. */
|
|
536
544
|
static getList(namespace?: string, root?: string): Promise<string[]>;
|
|
537
|
-
/**
|
|
545
|
+
/** Loads the selected version's texture dye colors as packed sRGB values. */
|
|
546
|
+
static getColors(root?: string): Promise<Record<DyeColor, number>>;
|
|
547
|
+
/** @deprecated Uses the fixed 1.21.11 palette. Use {@link getColors} for versioned colors. */
|
|
538
548
|
static getColor(color: unknown): number;
|
|
539
549
|
/** Resolves the first 16 layers of a `banner_patterns` component, preserving their order. */
|
|
540
550
|
static getLayers(value: unknown, target: "banner" | "shield", root?: string): Promise<BannerPatternDraw[]>;
|
|
@@ -560,11 +570,13 @@ interface BlockModel extends Model {
|
|
|
560
570
|
}
|
|
561
571
|
/** Item preview data, including GUI lighting, tint sources, and supported special renderers. */
|
|
562
572
|
interface ItemModel extends Model {
|
|
573
|
+
/** Original item ID, retained when resource packs select a different model. */
|
|
574
|
+
itemId?: string;
|
|
563
575
|
textures?: ItemModelTextures;
|
|
564
576
|
gui_light?: GuiLight;
|
|
565
577
|
special?: SpecialItemRenderer;
|
|
566
578
|
tints?: ItemTintSource[];
|
|
567
|
-
/** Stack-component snapshot with namespaced IDs, used by tint sources and special renderers. */
|
|
579
|
+
/** Stack-component snapshot with namespaced IDs, used by tint sources, glint, and special renderers. */
|
|
568
580
|
components?: Record<string, unknown>;
|
|
569
581
|
/** Ordered composite children, each with its own textures, display pose, and tint sources. */
|
|
570
582
|
parts?: ItemModel[];
|
|
@@ -594,7 +606,13 @@ type SpecialItemRenderer = {
|
|
|
594
606
|
} | {
|
|
595
607
|
type: "shield" | "minecraft:shield";
|
|
596
608
|
} | {
|
|
597
|
-
type: "
|
|
609
|
+
type: "decorated_pot" | "minecraft:decorated_pot";
|
|
610
|
+
} | {
|
|
611
|
+
type: "trident" | "minecraft:trident" | "conduit" | "minecraft:conduit" | "player_head" | "minecraft:player_head";
|
|
612
|
+
} | {
|
|
613
|
+
type: "copper_golem_statue" | "minecraft:copper_golem_statue";
|
|
614
|
+
texture: string;
|
|
615
|
+
pose: "standing" | "sitting" | "running" | "star";
|
|
598
616
|
} | {
|
|
599
617
|
type: "chest" | "minecraft:chest";
|
|
600
618
|
texture: string;
|
|
@@ -658,6 +676,10 @@ declare class MinecraftCubeTexture {
|
|
|
658
676
|
/** Texture animation and GUI scaling metadata read from a `.png.mcmeta` file. */
|
|
659
677
|
interface MinecraftTextureMeta extends MinecraftAsset {
|
|
660
678
|
animation?: AnimationMeta;
|
|
679
|
+
texture?: {
|
|
680
|
+
blur?: boolean;
|
|
681
|
+
clamp?: boolean;
|
|
682
|
+
};
|
|
661
683
|
gui?: {
|
|
662
684
|
scaling?: GuiSpriteScaling;
|
|
663
685
|
};
|
|
@@ -767,6 +789,8 @@ declare function toRadians(degrees: number): number;
|
|
|
767
789
|
declare function toDegrees(radians: number): number;
|
|
768
790
|
/** Resolves after a delay in milliseconds. */
|
|
769
791
|
declare function sleep(timeout: number): Promise<void>;
|
|
792
|
+
/** Yields to the next macrotask without timer clamping when the platform supports it. */
|
|
793
|
+
declare function yieldToEventLoop(): Promise<void>;
|
|
770
794
|
/** Reduces an angle modulo 360, retaining a negative sign for negative inputs. */
|
|
771
795
|
declare function clampRotationDegrees(deg: number): number;
|
|
772
796
|
declare function isVector3(obj: any): obj is Vector3;
|
|
@@ -821,6 +845,7 @@ declare class TextureAtlas implements Disposable {
|
|
|
821
845
|
[p: string]: AnimatorFunction;
|
|
822
846
|
};
|
|
823
847
|
readonly hasTransparency: boolean;
|
|
848
|
+
readonly hasTranslucency: boolean;
|
|
824
849
|
ticker?: number;
|
|
825
850
|
private readonly subscribers;
|
|
826
851
|
constructor(model: Model, image: CanvasImage, sizes: {
|
|
@@ -829,7 +854,7 @@ declare class TextureAtlas implements Disposable {
|
|
|
829
854
|
[texture: string]: DoubleArray;
|
|
830
855
|
}, hasAnimation: boolean, animatorFunctions: {
|
|
831
856
|
[p: string]: AnimatorFunction;
|
|
832
|
-
}, hasTransparency: boolean);
|
|
857
|
+
}, hasTransparency: boolean, hasTranslucency?: boolean);
|
|
833
858
|
/** Calls subscribers when an animation frame changes; unused atlases do not tick. */
|
|
834
859
|
subscribe(callback: () => void): () => void;
|
|
835
860
|
/** Copies pixels for a texture variable from its current atlas rectangle. */
|
|
@@ -975,7 +1000,7 @@ declare class AssetLoader {
|
|
|
975
1000
|
/** Selects an mcasset.cloud version, updates the vanilla source, and clears in-memory caches. */
|
|
976
1001
|
static setVersion(version: string): void;
|
|
977
1002
|
/**
|
|
978
|
-
* Scope for persistent cache keys. Empty with only the default vanilla
|
|
1003
|
+
* Scope for persistent cache keys. Empty with only the default vanilla source, so its
|
|
979
1004
|
* entries stay valid across sessions; otherwise it names every added source (resource packs,
|
|
980
1005
|
* mirrors) so their results never masquerade as vanilla assets after a reload.
|
|
981
1006
|
*/
|
|
@@ -1044,6 +1069,24 @@ declare class Assets {
|
|
|
1044
1069
|
static getBlockState(key: AssetKey): Promise<Maybe<BlockState>>;
|
|
1045
1070
|
}
|
|
1046
1071
|
|
|
1072
|
+
type BiomeColorKind = "grass" | "foliage" | "dry_foliage" | "water";
|
|
1073
|
+
/** Climate and color fields from a biome registry entry. Other registry fields are ignored. */
|
|
1074
|
+
interface Biome extends MinecraftAsset {
|
|
1075
|
+
temperature: number;
|
|
1076
|
+
downfall: number;
|
|
1077
|
+
effects: Partial<Record<`${BiomeColorKind}_color`, number | string>> & {
|
|
1078
|
+
grass_color_modifier?: "none" | "dark_forest" | "swamp";
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
/** Resolves biome colors through the selected version's registry and resource-pack colormaps. */
|
|
1082
|
+
declare class Biomes {
|
|
1083
|
+
/** Loads a biome registry entry, or returns `undefined` when no source provides it. */
|
|
1084
|
+
static get(id: string, origin?: AssetKey): Promise<Biome | undefined>;
|
|
1085
|
+
/** Returns packed sRGB, or `undefined` when the biome or requested water color is missing. */
|
|
1086
|
+
static getColor(id: string, kind: BiomeColorKind, origin?: AssetKey, x?: number, z?: number): Promise<number | undefined>;
|
|
1087
|
+
private static parseColor;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1047
1090
|
type BlockStatePropertyValue = string | boolean | number;
|
|
1048
1091
|
/** A vanilla block property's default and allowed values, loaded through {@link BlockStates.getDefaultState}. */
|
|
1049
1092
|
interface BlockStateProperty {
|
|
@@ -1118,7 +1161,7 @@ declare class BlockStates {
|
|
|
1118
1161
|
private static get PERSISTENT_CACHE();
|
|
1119
1162
|
/** Returns blockstate filenames from the selected version's `_list.json`, or an empty list. */
|
|
1120
1163
|
static getList(): Promise<string[]>;
|
|
1121
|
-
static getDefaultStates(): Promise<Maybe<DefaultBlockStates>>;
|
|
1164
|
+
static getDefaultStates(root?: string): Promise<Maybe<DefaultBlockStates>>;
|
|
1122
1165
|
/** Looks up vanilla property definitions for the key's block path, or returns `undefined`. */
|
|
1123
1166
|
static getDefaultState(key: AssetKey): Promise<Maybe<BlockStatePropertyDefaults>>;
|
|
1124
1167
|
/** Loads a cached blockstate definition for {@link MineRenderScene.addBlock}, or returns `undefined`. */
|
|
@@ -1131,6 +1174,13 @@ declare class DefaultBlockStates implements MinecraftAsset {
|
|
|
1131
1174
|
[k: string]: BlockStatePropertyDefaults;
|
|
1132
1175
|
}
|
|
1133
1176
|
|
|
1177
|
+
type DecoratedPotSide = "back" | "left" | "right" | "front";
|
|
1178
|
+
/** Resolves Minecraft 1.21.11 pot decorations to the four side textures. */
|
|
1179
|
+
declare class DecoratedPots {
|
|
1180
|
+
/** Reads up to four item IDs in back, left, right, front order; missing and unmapped items use plain sides. */
|
|
1181
|
+
static getSideTextures(value: unknown, root?: string): Record<DecoratedPotSide, AssetKey>;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1134
1184
|
/** `entity-models/animations/<namespace>/<model id>.json`: native and sampled vanilla animation clips. */
|
|
1135
1185
|
interface EntityAnimationFile extends MinecraftAsset {
|
|
1136
1186
|
id: string;
|
|
@@ -1243,29 +1293,109 @@ declare class Fonts {
|
|
|
1243
1293
|
private static bitmap;
|
|
1244
1294
|
}
|
|
1245
1295
|
|
|
1296
|
+
interface MineRenderDatasets {
|
|
1297
|
+
itemDefaults: Record<string, Record<string, unknown>>;
|
|
1298
|
+
potionColors: {
|
|
1299
|
+
effects: Record<string, number>;
|
|
1300
|
+
potions: Record<string, {
|
|
1301
|
+
id: string;
|
|
1302
|
+
amplifier: number;
|
|
1303
|
+
}[]>;
|
|
1304
|
+
};
|
|
1305
|
+
blockStates: Record<string, BlockStatePropertyDefaults>;
|
|
1306
|
+
blockTints: Record<string, ({
|
|
1307
|
+
source: "constant";
|
|
1308
|
+
color: number;
|
|
1309
|
+
} | {
|
|
1310
|
+
source: "grass" | "stem" | "redstone";
|
|
1311
|
+
}) & {
|
|
1312
|
+
untinted?: number[];
|
|
1313
|
+
biome?: BiomeColorKind;
|
|
1314
|
+
}>;
|
|
1315
|
+
fluids: Record<string, {
|
|
1316
|
+
kind: "water" | "lava";
|
|
1317
|
+
renderModel: boolean;
|
|
1318
|
+
levelProperty?: string;
|
|
1319
|
+
}>;
|
|
1320
|
+
dyes: Record<string, {
|
|
1321
|
+
id: number;
|
|
1322
|
+
textureDiffuseColor: number;
|
|
1323
|
+
fireworkColor: number;
|
|
1324
|
+
textColor: number;
|
|
1325
|
+
}>;
|
|
1326
|
+
legacyBlocks: {
|
|
1327
|
+
blocks: Record<string, string>;
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
interface MineRenderDataManifest {
|
|
1331
|
+
schemaVersion: 1;
|
|
1332
|
+
minecraftVersion: string;
|
|
1333
|
+
dataVersion: number;
|
|
1334
|
+
datasets: Partial<Record<keyof MineRenderDatasets, {
|
|
1335
|
+
file: string;
|
|
1336
|
+
sha256: string;
|
|
1337
|
+
bytes: number;
|
|
1338
|
+
provenance: Record<string, unknown>;
|
|
1339
|
+
}>>;
|
|
1340
|
+
unavailable: Record<string, string>;
|
|
1341
|
+
extractor: {
|
|
1342
|
+
repository: string;
|
|
1343
|
+
revision: string;
|
|
1344
|
+
sha256: string;
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
/** The requested asset version and the published data version used for its registries. */
|
|
1348
|
+
interface ResolvedMineRenderData {
|
|
1349
|
+
requestedVersion: string;
|
|
1350
|
+
version: string;
|
|
1351
|
+
/** Registry lookup root. Rootless requests still allow registered sources to override this URL. */
|
|
1352
|
+
root: string;
|
|
1353
|
+
manifest: MineRenderDataManifest;
|
|
1354
|
+
}
|
|
1355
|
+
/** Loads extracted Minecraft registries from the active asset sources and version. */
|
|
1356
|
+
declare class MineRenderData {
|
|
1357
|
+
/** Loads one registry. Missing files and invalid data reject the request. */
|
|
1358
|
+
static get<K extends keyof MineRenderDatasets>(dataset: K, root?: string): Promise<MineRenderDatasets[K]>;
|
|
1359
|
+
/**
|
|
1360
|
+
* Uses the exact version when published. Otherwise, selects the nearest patch in the same
|
|
1361
|
+
* release line (older on ties), then the latest earlier release or the oldest published release.
|
|
1362
|
+
* Unpublished snapshots reject.
|
|
1363
|
+
*/
|
|
1364
|
+
static resolve(root?: string): Promise<ResolvedMineRenderData>;
|
|
1365
|
+
private static manifest;
|
|
1366
|
+
private static load;
|
|
1367
|
+
private static cached;
|
|
1368
|
+
private static validDataset;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1246
1371
|
/** Caller-supplied item-preview state passed to {@link Models.getMerged}. */
|
|
1247
1372
|
interface ItemModelContext {
|
|
1248
1373
|
/** Context used by display-context selectors, overriding `properties`. Defaults to GUI. */
|
|
1249
1374
|
displayContext?: DisplayPosition | "none";
|
|
1250
1375
|
/** Explicit property overrides. Nodes with the same ID share one override, regardless of their parameters. */
|
|
1251
1376
|
properties?: Record<string, boolean | string | number>;
|
|
1252
|
-
/** Supplied component JSON by ID
|
|
1377
|
+
/** Supplied component JSON by ID, overriding built-in defaults. Component selectors compare structural JSON values. */
|
|
1253
1378
|
components?: Record<string, unknown>;
|
|
1254
|
-
/** Stack count, as a nonnegative integer. Defaults to 1;
|
|
1379
|
+
/** Stack count, as a nonnegative integer. Defaults to 1; items without listed defaults stack to 64. */
|
|
1255
1380
|
count?: number;
|
|
1256
1381
|
/** Item-model keys by reference-node ID, such as `minecraft:bundle/selected_item`. Unset references draw nothing. */
|
|
1257
1382
|
itemReferences?: Record<string, AssetKey>;
|
|
1258
1383
|
}
|
|
1259
1384
|
/** Loads and caches Java block/item models, including inherited geometry and textures. */
|
|
1260
1385
|
declare class Models {
|
|
1386
|
+
private static readonly ITEM_CACHE_VERSION;
|
|
1261
1387
|
private static _persistentCache;
|
|
1262
1388
|
private static get PERSISTENT_CACHE();
|
|
1263
1389
|
/** Lists item filenames from the asset source's `_list.json`, with a legacy model-directory fallback. */
|
|
1264
1390
|
static getItemList(): Promise<string[]>;
|
|
1265
1391
|
static loadAndMerge(key: AssetKey, context?: ItemModelContext): Promise<Maybe<Model>>;
|
|
1266
1392
|
private static getItemModel;
|
|
1393
|
+
private static getPreparedItemModel;
|
|
1267
1394
|
private static contextIdentifier;
|
|
1395
|
+
/** @internal */
|
|
1396
|
+
static componentValue(components: Record<string, unknown>, id: string): unknown;
|
|
1268
1397
|
private static snapshotContext;
|
|
1398
|
+
private static applyDefaults;
|
|
1269
1399
|
private static contextKey;
|
|
1270
1400
|
private static snapshotJson;
|
|
1271
1401
|
private static propertyValue;
|
|
@@ -1275,6 +1405,7 @@ declare class Models {
|
|
|
1275
1405
|
/**
|
|
1276
1406
|
* Loads a model and resolves its parent chain. Returns `undefined` when the model is missing.
|
|
1277
1407
|
* Item keys default to GUI context and a stack count of 1. Unresolved conditions are false and numeric properties are zero.
|
|
1408
|
+
* Versioned stack-size, durability, and glint defaults apply unless components override them.
|
|
1278
1409
|
* Pass `context` to supply component values, property overrides, and item references for a preview.
|
|
1279
1410
|
* Composite items retain independently merged children in `ItemModel.parts`.
|
|
1280
1411
|
*
|
|
@@ -1297,84 +1428,10 @@ declare class DisplayTransforms {
|
|
|
1297
1428
|
static apply(geometry: BufferGeometry, matrix: Matrix4): void;
|
|
1298
1429
|
}
|
|
1299
1430
|
|
|
1300
|
-
/**
|
|
1301
|
-
declare class
|
|
1302
|
-
/**
|
|
1303
|
-
static get(
|
|
1304
|
-
private static componentField;
|
|
1305
|
-
private static colorOrDefault;
|
|
1306
|
-
private static componentColor;
|
|
1307
|
-
private static rgb;
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
/** Identifies fully opaque cubes and maps neighbor visibility to model-local face masks. */
|
|
1311
|
-
declare class ModelCulling {
|
|
1312
|
-
/** Rotates a world-direction bit mask into model space. Bits follow {@link CUBE_FACES}. */
|
|
1313
|
-
static toLocalMask(worldMask: number, rotation: Euler): number;
|
|
1314
|
-
/** Whether a model fills one block with opaque faces and can hide adjacent block faces. */
|
|
1315
|
-
static isOpaqueFullCube(atlas: Maybe<TextureAtlas>): boolean;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
/** Builds extruded item-model elements from sprite pixels, including edges around transparent regions. */
|
|
1319
|
-
declare class ModelGenerator {
|
|
1320
|
-
static readonly ITEM_LAYERS: string[];
|
|
1321
|
-
/**
|
|
1322
|
-
* Front and back faces plus one zero-thickness side face per run of texels that border a transparent texel,
|
|
1323
|
-
* like vanilla's ItemModelGenerator. Pass the pixels of a single (first) animation frame.
|
|
1324
|
-
*/
|
|
1325
|
-
static generateItemModel(imageData: Pick<ImageData$1, "width" | "height" | "data">, layer: string): ModelElement[];
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
/** Resolves Java model inheritance, with child elements and display poses overriding their parents. */
|
|
1329
|
-
declare class ModelMerger {
|
|
1330
|
-
/** Loads the parent chain and returns a merged model without modifying the supplied definition. */
|
|
1331
|
-
static mergeWithParents(model: Model): Promise<Model>;
|
|
1332
|
-
protected static collectAllParents(model: Model): Promise<Model[]>;
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
/** Entity geometry and placement for a special item preview. Named part rotations use radians. */
|
|
1336
|
-
interface SpecialItemPart {
|
|
1337
|
-
model: EntityModel;
|
|
1338
|
-
transform: Matrix4;
|
|
1339
|
-
rotations: Record<string, TripleArray>;
|
|
1340
|
-
/** Absolute named-part positions in the entity model's coordinate system. */
|
|
1341
|
-
positions?: Record<string, TripleArray>;
|
|
1342
|
-
/** Colors for the entity model's named texture passes. */
|
|
1343
|
-
tints?: Record<string, number>;
|
|
1344
|
-
}
|
|
1345
|
-
/** Loads entity geometry and texture passes for supported special item previews. */
|
|
1346
|
-
declare class SpecialItems {
|
|
1347
|
-
/** Resolves the static entity parts drawn by a special item renderer, in model units. */
|
|
1348
|
-
static getParts(special: SpecialItemRenderer, root?: string, components?: Record<string, unknown>): Promise<SpecialItemPart[]>;
|
|
1349
|
-
/** An owned material with model-preview shading; its entity texture remains shared. */
|
|
1350
|
-
static createMaterial(source: MeshBasicMaterial, shade: boolean): MeshBasicMaterial;
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
/** Block data passed to world setters. `type` is a namespaced ID such as `minecraft:oak_log`. */
|
|
1354
|
-
interface Block {
|
|
1355
|
-
type: string;
|
|
1356
|
-
properties?: BlockStateProperties;
|
|
1357
|
-
nbt?: any;
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
/** Selects block models from property values, including multipart conditions and weighted alternatives. */
|
|
1361
|
-
declare class BlockStateResolver {
|
|
1362
|
-
/** Loads vanilla property defaults, falling back to preview values inferred from the blockstate file. */
|
|
1363
|
-
static defaults(blockState: BlockState): Promise<BlockStateProperties>;
|
|
1364
|
-
/** Selects matching models. Supply `choose` to control selection within each alternatives array. */
|
|
1365
|
-
static select(blockState: BlockState, state: BlockStateProperties, choose?: (variants: BlockStateVariant | BlockStateVariant[]) => BlockStateVariant): BlockStateVariant[];
|
|
1366
|
-
/** Returns matching model groups before choosing weighted alternatives. */
|
|
1367
|
-
static matching(blockState: BlockState, state: BlockStateProperties): (BlockStateVariant | BlockStateVariant[])[];
|
|
1368
|
-
/** Selects a random alternative using positive integer weights, each defaulting to 1. */
|
|
1369
|
-
static choose(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
|
|
1370
|
-
/** Converts blockstate rotations in degrees into the Euler rotation used by model rendering. */
|
|
1371
|
-
static rotation(variant: BlockStateVariant): Euler;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
/** Supplies block-preview tint colors from block properties and the active resource pack. */
|
|
1375
|
-
declare class BlockTints {
|
|
1376
|
-
/** Resolves block preview colors without biome context; explicit tints take precedence. */
|
|
1377
|
-
static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
|
|
1431
|
+
/** Item components extracted from the selected Minecraft version; unlisted items stack to 64. */
|
|
1432
|
+
declare class ItemDefaults {
|
|
1433
|
+
/** Returns a fresh map with namespaced component IDs; unlisted items get max_stack_size 64. */
|
|
1434
|
+
static get(itemId: string, root?: string): Promise<Record<string, unknown>>;
|
|
1378
1435
|
}
|
|
1379
1436
|
|
|
1380
1437
|
/** A model that owns reusable instance slots and exposes per-slot transforms to {@link InstanceReference}. */
|
|
@@ -1435,6 +1492,246 @@ interface SceneObjectOptions {
|
|
|
1435
1492
|
maxInstanceCount: number;
|
|
1436
1493
|
}
|
|
1437
1494
|
|
|
1495
|
+
type FluidKind = "water" | "lava";
|
|
1496
|
+
/** Reads the fluid kind from bits 4 and 5 of a section cell byte. */
|
|
1497
|
+
declare function fluidKindOf(byte: number): FluidKind | undefined;
|
|
1498
|
+
/** A neighboring cell's fluid level and full-cube occlusion state. */
|
|
1499
|
+
interface FluidSample {
|
|
1500
|
+
fluid?: FluidKind;
|
|
1501
|
+
level?: number;
|
|
1502
|
+
solid?: boolean;
|
|
1503
|
+
}
|
|
1504
|
+
/** Reads cells at integer block offsets relative to the fluid being rendered, with `(0, 0, 0)` as the center. */
|
|
1505
|
+
type FluidSampler = (x: number, y: number, z: number) => FluidSample;
|
|
1506
|
+
/** Fluid faces as quads centered on the block, four vertices each, in emission order. */
|
|
1507
|
+
interface FluidQuads {
|
|
1508
|
+
positions: number[];
|
|
1509
|
+
normals: number[];
|
|
1510
|
+
uvs: number[];
|
|
1511
|
+
sprites: number[];
|
|
1512
|
+
}
|
|
1513
|
+
/** Builds centered fluid quads with sprite 0 (still) or 1 (flowing). */
|
|
1514
|
+
declare function buildFluidQuads(kind: FluidKind, sample: FluidSampler): FluidQuads;
|
|
1515
|
+
|
|
1516
|
+
/** Fluid contained in a block and whether the block's ordinary model is also drawn. */
|
|
1517
|
+
interface BlockFluidState {
|
|
1518
|
+
kind: FluidKind;
|
|
1519
|
+
level: number;
|
|
1520
|
+
renderModel: boolean;
|
|
1521
|
+
}
|
|
1522
|
+
type FluidRules = MineRenderDatasets["fluids"];
|
|
1523
|
+
/** Finds water or lava from the block ID and properties, including waterlogged blocks and aquatic plants. */
|
|
1524
|
+
declare function getBlockFluidState(key?: AssetKey, state?: BlockStateProperties): Promise<BlockFluidState | undefined>;
|
|
1525
|
+
/** Resolves fluid state using rules already loaded for the block's asset version. */
|
|
1526
|
+
declare function resolveBlockFluidState(key: AssetKey | undefined, state: BlockStateProperties | undefined, rules: FluidRules): BlockFluidState | undefined;
|
|
1527
|
+
declare function getFluidKind(key?: AssetKey, state?: BlockStateProperties): Promise<FluidKind | undefined>;
|
|
1528
|
+
/** Builds centered fluid faces with material groups 0 (still) and 1 (flowing). */
|
|
1529
|
+
declare function createFluidGeometry(kind: FluidKind, sample: FluidSampler): BufferGeometry;
|
|
1530
|
+
|
|
1531
|
+
/** Playback settings passed to {@link EntityObject.playAnimation}, {@link EntityObject.playAnimations}, or {@link EntityAnimationPlayer.play}. */
|
|
1532
|
+
interface EntityAnimationOptions {
|
|
1533
|
+
/** Overrides the animation's own `loop` flag. */
|
|
1534
|
+
loop?: boolean;
|
|
1535
|
+
/** Playback rate applied to advanced time; defaults to 1. */
|
|
1536
|
+
speed?: number;
|
|
1537
|
+
/** Start time in seconds; defaults to 0. */
|
|
1538
|
+
time?: number;
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* Poses part groups from a keyframe animation the way vanilla does: every update restores the
|
|
1542
|
+
* default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.
|
|
1543
|
+
* It owns no timer; the owner advances it.
|
|
1544
|
+
*/
|
|
1545
|
+
declare class EntityAnimationPlayer {
|
|
1546
|
+
private parts;
|
|
1547
|
+
private _animation?;
|
|
1548
|
+
private _time;
|
|
1549
|
+
private loop;
|
|
1550
|
+
private speed;
|
|
1551
|
+
get animation(): EntityAnimation | undefined;
|
|
1552
|
+
get time(): number;
|
|
1553
|
+
/**
|
|
1554
|
+
* Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
|
|
1555
|
+
* without them, the current pose is used. Stopping restores the pose from before playback.
|
|
1556
|
+
*/
|
|
1557
|
+
play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
|
|
1558
|
+
/** Restores the poses from before playback. Returns whether an animation was active. */
|
|
1559
|
+
stop(): boolean;
|
|
1560
|
+
/** Forgets the animation without touching the parts, for parts that no longer exist. */
|
|
1561
|
+
clear(): void;
|
|
1562
|
+
/** Applies the pose at an absolute playback time. Returns `false` when no clip is active. */
|
|
1563
|
+
setTime(seconds: number): boolean;
|
|
1564
|
+
/** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */
|
|
1565
|
+
advance(deltaSeconds: number): boolean;
|
|
1566
|
+
private apply;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
/** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */
|
|
1570
|
+
declare class EntityObject extends SceneObject {
|
|
1571
|
+
readonly entity: EntityModel;
|
|
1572
|
+
readonly isEntityObject: true;
|
|
1573
|
+
static readonly DEFAULT_OPTIONS: EntityObjectOptions;
|
|
1574
|
+
readonly options: EntityObjectOptions;
|
|
1575
|
+
private meshesCreated;
|
|
1576
|
+
private readonly geometries;
|
|
1577
|
+
private readonly disposeWireframes;
|
|
1578
|
+
/** Scrolling materials are owned: their texture offset follows this entity's age. */
|
|
1579
|
+
private readonly scrollMaterials;
|
|
1580
|
+
private scrollTicker;
|
|
1581
|
+
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
1582
|
+
age: number;
|
|
1583
|
+
private readonly animationPlayers;
|
|
1584
|
+
private readonly partPoses;
|
|
1585
|
+
constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
|
|
1586
|
+
/** An optional shared material replaces texture loading for every selected draw; its owner retains disposal. */
|
|
1587
|
+
init(material?: Material): Promise<void>;
|
|
1588
|
+
dispose(): void;
|
|
1589
|
+
disposeAndRemoveAllChildren(): void;
|
|
1590
|
+
private clearScrollMaterials;
|
|
1591
|
+
private updateScrollSubscription;
|
|
1592
|
+
/** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
|
|
1593
|
+
private updateScroll;
|
|
1594
|
+
/** The first active clip, until playback is stopped or the object is disposed. */
|
|
1595
|
+
get animation(): Maybe<EntityAnimation>;
|
|
1596
|
+
/** Clips playing together, each targeting a separate geometry layer. */
|
|
1597
|
+
get activeAnimations(): readonly EntityAnimation[];
|
|
1598
|
+
/** Seconds since the animation started, before looping. */
|
|
1599
|
+
get animationTime(): number;
|
|
1600
|
+
/**
|
|
1601
|
+
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
1602
|
+
* Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
|
|
1603
|
+
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
1604
|
+
*/
|
|
1605
|
+
playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
|
|
1606
|
+
/** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
|
|
1607
|
+
playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
|
|
1608
|
+
/** Stops all clips and restores the poses from before playback. */
|
|
1609
|
+
stopAnimation(): void;
|
|
1610
|
+
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
1611
|
+
setAnimationTime(seconds: number): void;
|
|
1612
|
+
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
1613
|
+
advanceAnimation(deltaSeconds: number): void;
|
|
1614
|
+
/** Finds a selected draw by its layer key, such as `main` or `main#2`, or returns `undefined`. */
|
|
1615
|
+
getLayerGroup(name: string): Maybe<Object3D>;
|
|
1616
|
+
/** Finds a part name without `group:`. Supply `layerName` to restrict the search to one draw. */
|
|
1617
|
+
getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
|
|
1618
|
+
/** Finds a mesh name without `mesh:`. Supply `layerName` to restrict the search to one draw. */
|
|
1619
|
+
getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
|
|
1620
|
+
private get entityLayers();
|
|
1621
|
+
private getTextureKey;
|
|
1622
|
+
protected loadTextures(layer?: EntityLayer): Promise<Maybe<ExtractableImageData>>;
|
|
1623
|
+
protected createMeshes(force?: boolean): void;
|
|
1624
|
+
private createPart;
|
|
1625
|
+
protected applyTextures(): Promise<void>;
|
|
1626
|
+
}
|
|
1627
|
+
/** Render settings passed to `scene.addEntity(entity, options)` or the EntityObject constructor. */
|
|
1628
|
+
interface EntityObjectOptions extends SceneObjectOptions {
|
|
1629
|
+
/**
|
|
1630
|
+
* `true` applies only vanilla's entity flip, scale (-1, -1, 1); `false` keeps raw model space.
|
|
1631
|
+
* By default the model's dataset transform is used, or the flip for models without one.
|
|
1632
|
+
*/
|
|
1633
|
+
flip?: boolean;
|
|
1634
|
+
/** Colours for the dataset's tint labels, e.g. `{ wool_color: 0xf9801d }`; a pass whose label is absent stays untinted. */
|
|
1635
|
+
tints?: Record<string, ColorRepresentation>;
|
|
1636
|
+
/** Cube faces by layer key; omitted layers draw all six faces. */
|
|
1637
|
+
faces?: Record<string, CubeFace[]>;
|
|
1638
|
+
}
|
|
1639
|
+
declare function isEntityObject(obj: any): obj is EntityObject;
|
|
1640
|
+
|
|
1641
|
+
/** Controls the model parts selected by a blockstate. Create it through {@link MineRenderScene.addBlock}. */
|
|
1642
|
+
declare class BlockObject extends SceneObject {
|
|
1643
|
+
readonly blockState: BlockState;
|
|
1644
|
+
readonly isBlockObject: true;
|
|
1645
|
+
static readonly DEFAULT_OPTIONS: BlockObjectOptions;
|
|
1646
|
+
readonly options: BlockObjectOptions;
|
|
1647
|
+
private readonly variantPosition?;
|
|
1648
|
+
private _previousState;
|
|
1649
|
+
private _state;
|
|
1650
|
+
private _variant;
|
|
1651
|
+
private _instanceState;
|
|
1652
|
+
private _instanceVariant;
|
|
1653
|
+
private _instanceModel;
|
|
1654
|
+
private _variants;
|
|
1655
|
+
private _models;
|
|
1656
|
+
private _cullMask;
|
|
1657
|
+
private _fluidKey?;
|
|
1658
|
+
private _fluidRules;
|
|
1659
|
+
private _fluidSampler?;
|
|
1660
|
+
private readonly biomePosition?;
|
|
1661
|
+
private waterTint?;
|
|
1662
|
+
private _fluidModel?;
|
|
1663
|
+
private _entities;
|
|
1664
|
+
private _entityPlacement;
|
|
1665
|
+
private _entityGeneration;
|
|
1666
|
+
constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
|
|
1667
|
+
init(): Promise<void>;
|
|
1668
|
+
dispose(): void;
|
|
1669
|
+
removeFromScene(): void;
|
|
1670
|
+
private clearModels;
|
|
1671
|
+
private removeModels;
|
|
1672
|
+
private removeEntities;
|
|
1673
|
+
/** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
|
|
1674
|
+
get blockEntities(): readonly EntityObject[];
|
|
1675
|
+
/** Sets visibility for this block's model instances and block entities. */
|
|
1676
|
+
setVisible(visible: boolean): void;
|
|
1677
|
+
/**
|
|
1678
|
+
* Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
|
|
1679
|
+
* when the block is not listed or one of its models cannot be loaded.
|
|
1680
|
+
*/
|
|
1681
|
+
private createBlockEntities;
|
|
1682
|
+
private placeEntities;
|
|
1683
|
+
get isOccluding(): boolean;
|
|
1684
|
+
private getModelMatrix;
|
|
1685
|
+
private getModelCullMask;
|
|
1686
|
+
/** World-space face mask currently applied to this block. */
|
|
1687
|
+
get cullMask(): number;
|
|
1688
|
+
setCullMask(worldMask: number): Promise<void>;
|
|
1689
|
+
/** Selected property values. Use {@link setState} to change properties and rebuild the rendered models. */
|
|
1690
|
+
get state(): {
|
|
1691
|
+
[key: string]: string;
|
|
1692
|
+
};
|
|
1693
|
+
get fluidKind(): FluidKind | undefined;
|
|
1694
|
+
get fluidLevel(): number;
|
|
1695
|
+
/** Refreshes fluid surfaces from relative neighbors; standalone previews use air around the block. */
|
|
1696
|
+
updateFluid(sample?: FluidSampler): Promise<void>;
|
|
1697
|
+
nextInstance(): InstanceReference<SceneObject>;
|
|
1698
|
+
protected mapStateToVariant(state: BlockStateProperties): Promise<BlockStateVariant[]>;
|
|
1699
|
+
recreateModels(): Promise<void>;
|
|
1700
|
+
private hasGeometry;
|
|
1701
|
+
protected getSingleVariant(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
|
|
1702
|
+
protected createAVariant(variants: BlockStateVariant | BlockStateVariant[], instanceInfo: Matrix4[]): Promise<void>;
|
|
1703
|
+
protected createVariant(variant: BlockStateVariant): Promise<ModelObject | InstanceReference<ModelObject>>;
|
|
1704
|
+
/** Clears selected properties and rebuilds models without reapplying property defaults. */
|
|
1705
|
+
resetState(): Promise<void>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Updates properties and rebuilds the selected models.
|
|
1708
|
+
* Accepts `"facing=north,open=true"`, a property object, or a key and value.
|
|
1709
|
+
* Properties omitted from the call keep their current values.
|
|
1710
|
+
*/
|
|
1711
|
+
setState(string: string): any;
|
|
1712
|
+
setState(state: BlockStateProperties): any;
|
|
1713
|
+
setState(key: string, value: string): any;
|
|
1714
|
+
protected _setState(stringOrKeyOrState: string | BlockStateProperties, value?: string): void;
|
|
1715
|
+
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1716
|
+
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
1717
|
+
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
1718
|
+
setPosition(position: Vector3): void;
|
|
1719
|
+
}
|
|
1720
|
+
/** Block settings passed to `scene.addBlock(blockState, options)` or the BlockObject constructor. */
|
|
1721
|
+
interface BlockObjectOptions extends ModelObjectOptions {
|
|
1722
|
+
/** Loads vanilla property defaults before applying `initialState`. Defaults to `true`. */
|
|
1723
|
+
applyDefaultState: boolean;
|
|
1724
|
+
/** Properties applied before model creation, overriding defaults when applyDefaultState is enabled. */
|
|
1725
|
+
initialState?: BlockStateProperties;
|
|
1726
|
+
/** Absolute block coordinates for repeatable variants, copied at construction. Omit for random previews. */
|
|
1727
|
+
variantPosition?: TripleArray;
|
|
1728
|
+
/** Saved biome ID used for automatic grass, foliage, and water colors. */
|
|
1729
|
+
biome?: string;
|
|
1730
|
+
/** World block coordinates used by biome grass modifiers. Copied at construction; defaults to the origin. */
|
|
1731
|
+
biomePosition?: TripleArray;
|
|
1732
|
+
}
|
|
1733
|
+
declare function isBlockObject(obj: any): obj is BlockObject;
|
|
1734
|
+
|
|
1438
1735
|
/** Builds render geometry from a merged Java model. Create it through {@link MineRenderScene.addModel}. */
|
|
1439
1736
|
declare class ModelObject extends SceneObject {
|
|
1440
1737
|
readonly originalModel: Model;
|
|
@@ -1447,6 +1744,8 @@ declare class ModelObject extends SceneObject {
|
|
|
1447
1744
|
private unsubscribeAtlas?;
|
|
1448
1745
|
private readonly specialMaterials;
|
|
1449
1746
|
private readonly geometries;
|
|
1747
|
+
private readonly hasGlint;
|
|
1748
|
+
private glint?;
|
|
1450
1749
|
blockParent: Maybe<BlockObject>;
|
|
1451
1750
|
private meshesCreated;
|
|
1452
1751
|
constructor(originalModel: Model, options?: Partial<ModelObjectOptions>);
|
|
@@ -1550,113 +1849,6 @@ interface SkinObjectOptions extends SceneObjectOptions {
|
|
|
1550
1849
|
legacy?: boolean;
|
|
1551
1850
|
}
|
|
1552
1851
|
|
|
1553
|
-
/** Playback settings passed to {@link EntityObject.playAnimation}, {@link EntityObject.playAnimations}, or {@link EntityAnimationPlayer.play}. */
|
|
1554
|
-
interface EntityAnimationOptions {
|
|
1555
|
-
/** Overrides the animation's own `loop` flag. */
|
|
1556
|
-
loop?: boolean;
|
|
1557
|
-
/** Playback rate applied to advanced time; defaults to 1. */
|
|
1558
|
-
speed?: number;
|
|
1559
|
-
/** Start time in seconds; defaults to 0. */
|
|
1560
|
-
time?: number;
|
|
1561
|
-
}
|
|
1562
|
-
/**
|
|
1563
|
-
* Poses part groups from a keyframe animation the way vanilla does: every update restores the
|
|
1564
|
-
* default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.
|
|
1565
|
-
* It owns no timer; the owner advances it.
|
|
1566
|
-
*/
|
|
1567
|
-
declare class EntityAnimationPlayer {
|
|
1568
|
-
private parts;
|
|
1569
|
-
private _animation?;
|
|
1570
|
-
private _time;
|
|
1571
|
-
private loop;
|
|
1572
|
-
private speed;
|
|
1573
|
-
get animation(): EntityAnimation | undefined;
|
|
1574
|
-
get time(): number;
|
|
1575
|
-
/**
|
|
1576
|
-
* Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
|
|
1577
|
-
* without them, the current pose is used. Stopping restores the pose from before playback.
|
|
1578
|
-
*/
|
|
1579
|
-
play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
|
|
1580
|
-
/** Restores the poses from before playback. Returns whether an animation was active. */
|
|
1581
|
-
stop(): boolean;
|
|
1582
|
-
/** Forgets the animation without touching the parts, for parts that no longer exist. */
|
|
1583
|
-
clear(): void;
|
|
1584
|
-
/** Applies the pose at an absolute playback time. Returns `false` when no clip is active. */
|
|
1585
|
-
setTime(seconds: number): boolean;
|
|
1586
|
-
/** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */
|
|
1587
|
-
advance(deltaSeconds: number): boolean;
|
|
1588
|
-
private apply;
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
/** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */
|
|
1592
|
-
declare class EntityObject extends SceneObject {
|
|
1593
|
-
readonly entity: EntityModel;
|
|
1594
|
-
readonly isEntityObject: true;
|
|
1595
|
-
static readonly DEFAULT_OPTIONS: EntityObjectOptions;
|
|
1596
|
-
readonly options: EntityObjectOptions;
|
|
1597
|
-
private meshesCreated;
|
|
1598
|
-
private readonly geometries;
|
|
1599
|
-
private readonly disposeWireframes;
|
|
1600
|
-
/** Scrolling materials are owned: their texture offset follows this entity's age. */
|
|
1601
|
-
private readonly scrollMaterials;
|
|
1602
|
-
private scrollTicker;
|
|
1603
|
-
/** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
|
|
1604
|
-
age: number;
|
|
1605
|
-
private readonly animationPlayers;
|
|
1606
|
-
private readonly partPoses;
|
|
1607
|
-
constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
|
|
1608
|
-
init(): Promise<void>;
|
|
1609
|
-
dispose(): void;
|
|
1610
|
-
disposeAndRemoveAllChildren(): void;
|
|
1611
|
-
private clearScrollMaterials;
|
|
1612
|
-
private updateScrollSubscription;
|
|
1613
|
-
/** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
|
|
1614
|
-
private updateScroll;
|
|
1615
|
-
/** The first active clip, until playback is stopped or the object is disposed. */
|
|
1616
|
-
get animation(): Maybe<EntityAnimation>;
|
|
1617
|
-
/** Clips playing together, each targeting a separate geometry layer. */
|
|
1618
|
-
get activeAnimations(): readonly EntityAnimation[];
|
|
1619
|
-
/** Seconds since the animation started, before looping. */
|
|
1620
|
-
get animationTime(): number;
|
|
1621
|
-
/**
|
|
1622
|
-
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
1623
|
-
* Offsets apply to the baked pose in the clip's layer (`main` by default), including repeated draws of that layer.
|
|
1624
|
-
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
1625
|
-
*/
|
|
1626
|
-
playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
|
|
1627
|
-
/** Plays one clip per selected geometry layer, with a shared clock and no blending between clips. */
|
|
1628
|
-
playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
|
|
1629
|
-
/** Stops all clips and restores the poses from before playback. */
|
|
1630
|
-
stopAnimation(): void;
|
|
1631
|
-
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
1632
|
-
setAnimationTime(seconds: number): void;
|
|
1633
|
-
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
1634
|
-
advanceAnimation(deltaSeconds: number): void;
|
|
1635
|
-
/** Finds a selected draw by its layer key, such as `main` or `main#2`, or returns `undefined`. */
|
|
1636
|
-
getLayerGroup(name: string): Maybe<Object3D>;
|
|
1637
|
-
/** Finds a part name without `group:`. Supply `layerName` to restrict the search to one draw. */
|
|
1638
|
-
getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
|
|
1639
|
-
/** Finds a mesh name without `mesh:`. Supply `layerName` to restrict the search to one draw. */
|
|
1640
|
-
getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
|
|
1641
|
-
private get entityLayers();
|
|
1642
|
-
private getTextureKey;
|
|
1643
|
-
protected loadTextures(layer?: EntityLayer): Promise<Maybe<ExtractableImageData>>;
|
|
1644
|
-
protected createMeshes(force?: boolean): void;
|
|
1645
|
-
private createPart;
|
|
1646
|
-
protected applyTextures(): Promise<void>;
|
|
1647
|
-
}
|
|
1648
|
-
/** Render settings passed to `scene.addEntity(entity, options)` or the EntityObject constructor. */
|
|
1649
|
-
interface EntityObjectOptions extends SceneObjectOptions {
|
|
1650
|
-
/**
|
|
1651
|
-
* `true` applies only vanilla's entity flip, scale (-1, -1, 1); `false` keeps raw model space.
|
|
1652
|
-
* By default the model's dataset transform is used, or the flip for models without one.
|
|
1653
|
-
*/
|
|
1654
|
-
flip?: boolean;
|
|
1655
|
-
/** Colours for the dataset's tint labels, e.g. `{ wool_color: 0xf9801d }`; a pass whose label is absent stays untinted. */
|
|
1656
|
-
tints?: Record<string, ColorRepresentation>;
|
|
1657
|
-
}
|
|
1658
|
-
declare function isEntityObject(obj: any): obj is EntityObject;
|
|
1659
|
-
|
|
1660
1852
|
/** Text appearance set on a GUI text layer or overridden by an individual text run. */
|
|
1661
1853
|
interface GuiTextStyle {
|
|
1662
1854
|
/** sRGB 0xRRGGBB; defaults to white. */
|
|
@@ -1724,8 +1916,10 @@ interface GuiTextureLayer extends GuiLayerLayout {
|
|
|
1724
1916
|
interface GuiItemLayer extends GuiLayerLayout {
|
|
1725
1917
|
/** Model key, such as minecraft:item/stone; uses the model's GUI display pose. */
|
|
1726
1918
|
item: AssetKey | string;
|
|
1727
|
-
/** Supplied item state.
|
|
1919
|
+
/** Supplied item state, count label, and damage bar. Count zero leaves an empty slot; models always use the GUI display context. */
|
|
1728
1920
|
context?: Omit<ItemModelContext, "displayContext">;
|
|
1921
|
+
/** Draw count labels and durability bars. Defaults to true. */
|
|
1922
|
+
decorations?: boolean;
|
|
1729
1923
|
/** sRGB 0xRRGGBB colors by face tint index, overriding the item's automatic preview colors. */
|
|
1730
1924
|
tints?: Record<number, number>;
|
|
1731
1925
|
}
|
|
@@ -1749,6 +1943,10 @@ declare class GuiObject extends SceneObject {
|
|
|
1749
1943
|
private initialized;
|
|
1750
1944
|
constructor(textureLayers: readonly GuiLayer[], options?: Partial<GuiObjectOptions>);
|
|
1751
1945
|
init(): Promise<void>;
|
|
1946
|
+
private createText;
|
|
1947
|
+
private textMaterial;
|
|
1948
|
+
private itemOverlay;
|
|
1949
|
+
private createItemOverlay;
|
|
1752
1950
|
private createItem;
|
|
1753
1951
|
private loadMaterial;
|
|
1754
1952
|
disposeAndRemoveAllChildren(): void;
|
|
@@ -1876,141 +2074,157 @@ declare class SceneObject extends Object3D<Object3DEventMap & {
|
|
|
1876
2074
|
/** Returns the live reference for a raycast hit on this object's instance mesh. */
|
|
1877
2075
|
getInstanceReference(mesh: Object3D, index: number): Maybe<InstanceReference<SceneObject>>;
|
|
1878
2076
|
isInstanceActive(index: number, reference: InstanceReference<Instanceable>): boolean;
|
|
1879
|
-
removeInstanceAt(index: number): void;
|
|
1880
|
-
private growInstances;
|
|
1881
|
-
protected activeInstanceIndices(): Iterable<number>;
|
|
1882
|
-
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
1883
|
-
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
1884
|
-
setInstanceVisibleAt(index: number, visible: boolean): void;
|
|
1885
|
-
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1886
|
-
setPositionAt(index: number, position: Vector3): void;
|
|
1887
|
-
getPositionAt(index: number, vector?: Vector3): Vector3;
|
|
1888
|
-
setRotationAt(index: number, rotation: Euler): void;
|
|
1889
|
-
getRotationAt(index: number, euler?: Euler): Euler;
|
|
1890
|
-
setScaleAt(index: number, scale: Vector3): void;
|
|
1891
|
-
getScaleAt(index: number, vector?: Vector3): Vector3;
|
|
1892
|
-
/** Updates supplied transform components. For a shared model, affects every live instance. */
|
|
1893
|
-
setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
1894
|
-
/** Sets position in scene units. For a shared model, updates every live instance. */
|
|
1895
|
-
setPosition(position: Vector3): void;
|
|
1896
|
-
getPosition(): Vector3;
|
|
1897
|
-
/** Sets rotation in radians. For a shared model, updates every live instance. */
|
|
1898
|
-
setRotation(rotation: Euler): void;
|
|
1899
|
-
getRotation(): Euler;
|
|
1900
|
-
/** Sets scale factors. For a shared model, updates every live instance. */
|
|
1901
|
-
setScale(scale: Vector3): void;
|
|
1902
|
-
getScale(): Vector3;
|
|
1903
|
-
protected toggleObjectVisibility(object?: Object3D, visible?: boolean): boolean;
|
|
1904
|
-
dispose(): void;
|
|
1905
|
-
/** Releases instance slots and removes children, disposing children that implement Disposable. */
|
|
1906
|
-
disposeAndRemoveAllChildren(): void;
|
|
1907
|
-
/** Detaches the object from its parent and requests a redraw. */
|
|
1908
|
-
removeFromScene(): void;
|
|
1909
|
-
}
|
|
1910
|
-
declare function isSceneObject(obj: any): obj is SceneObject;
|
|
1911
|
-
|
|
1912
|
-
type FluidKind = "water" | "lava";
|
|
1913
|
-
/** Fluid contained in a block and whether the block's ordinary model is also drawn. */
|
|
1914
|
-
interface BlockFluidState {
|
|
1915
|
-
kind: FluidKind;
|
|
1916
|
-
level: number;
|
|
1917
|
-
renderModel: boolean;
|
|
1918
|
-
}
|
|
1919
|
-
/** Finds water or lava from the block ID and properties, including waterlogged blocks and aquatic plants. */
|
|
1920
|
-
declare function getBlockFluidState(key?: AssetKey, state?: BlockStateProperties): BlockFluidState | undefined;
|
|
1921
|
-
declare function getFluidKind(key?: AssetKey, state?: BlockStateProperties): FluidKind | undefined;
|
|
1922
|
-
/** A neighboring cell's fluid level and full-cube occlusion state. */
|
|
1923
|
-
interface FluidSample {
|
|
1924
|
-
fluid?: FluidKind;
|
|
1925
|
-
level?: number;
|
|
1926
|
-
solid?: boolean;
|
|
1927
|
-
}
|
|
1928
|
-
/** Reads cells at integer block offsets relative to the fluid being rendered, with `(0, 0, 0)` as the center. */
|
|
1929
|
-
type FluidSampler = (x: number, y: number, z: number) => FluidSample;
|
|
1930
|
-
/** Builds centered fluid faces with material groups 0 (still) and 1 (flowing). */
|
|
1931
|
-
declare function createFluidGeometry(kind: FluidKind, sample: FluidSampler): BufferGeometry;
|
|
1932
|
-
|
|
1933
|
-
/** Controls the model parts selected by a blockstate. Create it through {@link MineRenderScene.addBlock}. */
|
|
1934
|
-
declare class BlockObject extends SceneObject {
|
|
1935
|
-
readonly blockState: BlockState;
|
|
1936
|
-
readonly isBlockObject: true;
|
|
1937
|
-
static readonly DEFAULT_OPTIONS: BlockObjectOptions;
|
|
1938
|
-
readonly options: BlockObjectOptions;
|
|
1939
|
-
private _previousState;
|
|
1940
|
-
private _state;
|
|
1941
|
-
private _variant;
|
|
1942
|
-
private _instanceState;
|
|
1943
|
-
private _instanceVariant;
|
|
1944
|
-
private _instanceModel;
|
|
1945
|
-
private _variants;
|
|
1946
|
-
private _models;
|
|
1947
|
-
private _cullMask;
|
|
1948
|
-
private _fluidKey?;
|
|
1949
|
-
private _fluidSampler?;
|
|
1950
|
-
private _fluidModel?;
|
|
1951
|
-
private _entities;
|
|
1952
|
-
private _entityPlacement;
|
|
1953
|
-
private _entityGeneration;
|
|
1954
|
-
constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
|
|
1955
|
-
init(): Promise<void>;
|
|
2077
|
+
removeInstanceAt(index: number): void;
|
|
2078
|
+
private growInstances;
|
|
2079
|
+
protected activeInstanceIndices(): Iterable<number>;
|
|
2080
|
+
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
2081
|
+
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
2082
|
+
setInstanceVisibleAt(index: number, visible: boolean): void;
|
|
2083
|
+
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
2084
|
+
setPositionAt(index: number, position: Vector3): void;
|
|
2085
|
+
getPositionAt(index: number, vector?: Vector3): Vector3;
|
|
2086
|
+
setRotationAt(index: number, rotation: Euler): void;
|
|
2087
|
+
getRotationAt(index: number, euler?: Euler): Euler;
|
|
2088
|
+
setScaleAt(index: number, scale: Vector3): void;
|
|
2089
|
+
getScaleAt(index: number, vector?: Vector3): Vector3;
|
|
2090
|
+
/** Updates supplied transform components. For a shared model, affects every live instance. */
|
|
2091
|
+
setPositionRotationScale(position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
2092
|
+
/** Sets position in scene units. For a shared model, updates every live instance. */
|
|
2093
|
+
setPosition(position: Vector3): void;
|
|
2094
|
+
getPosition(): Vector3;
|
|
2095
|
+
/** Sets rotation in radians. For a shared model, updates every live instance. */
|
|
2096
|
+
setRotation(rotation: Euler): void;
|
|
2097
|
+
getRotation(): Euler;
|
|
2098
|
+
/** Sets scale factors. For a shared model, updates every live instance. */
|
|
2099
|
+
setScale(scale: Vector3): void;
|
|
2100
|
+
getScale(): Vector3;
|
|
2101
|
+
protected toggleObjectVisibility(object?: Object3D, visible?: boolean): boolean;
|
|
1956
2102
|
dispose(): void;
|
|
2103
|
+
/** Releases instance slots and removes children, disposing children that implement Disposable. */
|
|
2104
|
+
disposeAndRemoveAllChildren(): void;
|
|
2105
|
+
/** Detaches the object from its parent and requests a redraw. */
|
|
1957
2106
|
removeFromScene(): void;
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
2107
|
+
}
|
|
2108
|
+
declare function isSceneObject(obj: any): obj is SceneObject;
|
|
2109
|
+
|
|
2110
|
+
/** An owned glint material over item geometry; textures and geometry retain their owners. */
|
|
2111
|
+
declare class ItemGlint {
|
|
2112
|
+
private readonly owner;
|
|
2113
|
+
readonly material: ShaderMaterial;
|
|
2114
|
+
private ticker?;
|
|
2115
|
+
private constructor();
|
|
2116
|
+
/** Enables glint for enchantments or a lodestone compass unless a boolean component overrides them. */
|
|
2117
|
+
static enabled(components?: Record<string, unknown>, itemId?: string): boolean;
|
|
2118
|
+
/** @internal */
|
|
2119
|
+
static create(owner: SceneObject, baseMap?: Texture, root?: string, entityMeshes?: readonly {
|
|
2120
|
+
mesh: Mesh;
|
|
2121
|
+
parent?: Mesh;
|
|
2122
|
+
}[]): Promise<ItemGlint>;
|
|
1965
2123
|
/**
|
|
1966
|
-
*
|
|
1967
|
-
*
|
|
2124
|
+
* Maps glint before model centering and display transforms. Ordinary sprites approximate Minecraft's shared atlas density.
|
|
2125
|
+
* @internal
|
|
1968
2126
|
*/
|
|
1969
|
-
|
|
1970
|
-
private
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
private
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2127
|
+
static mapUvs(geometry: BufferGeometry, faces: ModelFaces, atlas: TextureAtlas, itemId?: string, display?: DisplayPosition): void;
|
|
2128
|
+
private updateTime;
|
|
2129
|
+
/** @internal */
|
|
2130
|
+
updateSubscription(active: boolean): void;
|
|
2131
|
+
dispose(): void;
|
|
2132
|
+
}
|
|
2133
|
+
|
|
2134
|
+
/** Resolves item-preview colors from vanilla tint definitions, stack components, and caller overrides. */
|
|
2135
|
+
declare class ItemTints {
|
|
2136
|
+
/** Lists potion IDs from the selected version's registry. */
|
|
2137
|
+
static getPotionList(root?: string): Promise<string[]>;
|
|
2138
|
+
/** Resolves preview colors from item definitions; explicit per-index colors take precedence. */
|
|
2139
|
+
static get(model: Model, tints?: Record<number, number>): Promise<Record<number, number> | undefined>;
|
|
2140
|
+
/** Whether a potion component contains a known effect, including effects with hidden particles. */
|
|
2141
|
+
static hasPotionEffects(value: unknown, root?: string): Promise<boolean>;
|
|
2142
|
+
private static potionColor;
|
|
2143
|
+
private static potionContents;
|
|
2144
|
+
private static potionEffects;
|
|
2145
|
+
private static componentField;
|
|
2146
|
+
private static colorOrDefault;
|
|
2147
|
+
private static componentColor;
|
|
2148
|
+
private static rgb;
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
/** Identifies fully opaque cubes and maps neighbor visibility to model-local face masks. */
|
|
2152
|
+
declare class ModelCulling {
|
|
2153
|
+
/** Rotates a world-direction bit mask into model space. Bits follow {@link CUBE_FACES}. */
|
|
2154
|
+
static toLocalMask(worldMask: number, rotation: Euler): number;
|
|
2155
|
+
/** Whether a model fills one block with opaque faces and can hide adjacent block faces. */
|
|
2156
|
+
static isOpaqueFullCube(atlas: Maybe<TextureAtlas>): boolean;
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
/** Builds extruded item-model elements from sprite pixels, including edges around transparent regions. */
|
|
2160
|
+
declare class ModelGenerator {
|
|
2161
|
+
static readonly ITEM_LAYERS: string[];
|
|
1992
2162
|
/**
|
|
1993
|
-
*
|
|
1994
|
-
*
|
|
1995
|
-
* Properties omitted from the call keep their current values.
|
|
2163
|
+
* Front and back faces plus one zero-thickness side face per run of texels that border a transparent texel,
|
|
2164
|
+
* like vanilla's ItemModelGenerator. Pass the pixels of a single (first) animation frame.
|
|
1996
2165
|
*/
|
|
1997
|
-
|
|
1998
|
-
setState(state: BlockStateProperties): any;
|
|
1999
|
-
setState(key: string, value: string): any;
|
|
2000
|
-
protected _setState(stringOrKeyOrState: string | BlockStateProperties, value?: string): void;
|
|
2001
|
-
setPositionRotationScaleAt(index: number, position?: Vector3, rotation?: Euler, scale?: Vector3): void;
|
|
2002
|
-
getMatrixAt(index: number, matrix?: Matrix4): Matrix4;
|
|
2003
|
-
setMatrixAt(index: number, matrix: Matrix4): void;
|
|
2004
|
-
setPosition(position: Vector3): void;
|
|
2166
|
+
static generateItemModel(imageData: Pick<ImageData$1, "width" | "height" | "data">, layer: string): ModelElement[];
|
|
2005
2167
|
}
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2168
|
+
|
|
2169
|
+
/** Resolves Java model inheritance, with child elements and display poses overriding their parents. */
|
|
2170
|
+
declare class ModelMerger {
|
|
2171
|
+
/** Loads the parent chain and returns a merged model without modifying the supplied definition. */
|
|
2172
|
+
static mergeWithParents(model: Model): Promise<Model>;
|
|
2173
|
+
protected static collectAllParents(model: Model): Promise<Model[]>;
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
/** Entity geometry and placement for a special item preview. Named part rotations use radians. */
|
|
2177
|
+
interface SpecialItemPart {
|
|
2178
|
+
model: EntityModel;
|
|
2179
|
+
transform: Matrix4;
|
|
2180
|
+
rotations: Record<string, TripleArray>;
|
|
2181
|
+
/** Absolute named-part positions in the entity model's coordinate system. */
|
|
2182
|
+
positions?: Record<string, TripleArray>;
|
|
2183
|
+
/** Colors for the entity model's named texture passes. */
|
|
2184
|
+
tints?: Record<string, number>;
|
|
2185
|
+
faces?: Record<string, CubeFace[]>;
|
|
2186
|
+
/** Shared prepared material; the renderer clones it and retains ownership of only that clone. */
|
|
2187
|
+
material?: MeshBasicMaterial;
|
|
2188
|
+
}
|
|
2189
|
+
/** Loads entity geometry and texture passes for supported special item previews. */
|
|
2190
|
+
declare class SpecialItems {
|
|
2191
|
+
/** Resolves the static entity parts drawn by a special item renderer, in model units. */
|
|
2192
|
+
static getParts(special: SpecialItemRenderer, root?: string, components?: Record<string, unknown>): Promise<SpecialItemPart[]>;
|
|
2193
|
+
/** An owned material with model-preview shading; its entity texture remains shared. */
|
|
2194
|
+
static createMaterial(source: MeshBasicMaterial, shade: boolean): MeshBasicMaterial;
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2197
|
+
/** Block data passed to world setters. `type` is a namespaced ID such as `minecraft:oak_log`. */
|
|
2198
|
+
interface Block {
|
|
2199
|
+
type: string;
|
|
2200
|
+
properties?: BlockStateProperties;
|
|
2201
|
+
nbt?: any;
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2204
|
+
/** Selects block models from property values, including multipart conditions and weighted alternatives. */
|
|
2205
|
+
declare class BlockStateResolver {
|
|
2206
|
+
/** Loads vanilla property defaults, falling back to preview values inferred from the blockstate file. */
|
|
2207
|
+
static defaults(blockState: BlockState): Promise<BlockStateProperties>;
|
|
2208
|
+
/** Selects matching models. Supply `choose` to control selection within each alternatives array. */
|
|
2209
|
+
static select(blockState: BlockState, state: BlockStateProperties, choose?: (variants: BlockStateVariant | BlockStateVariant[]) => BlockStateVariant): BlockStateVariant[];
|
|
2210
|
+
/** Returns matching model groups before choosing weighted alternatives. */
|
|
2211
|
+
static matching(blockState: BlockState, state: BlockStateProperties): (BlockStateVariant | BlockStateVariant[])[];
|
|
2212
|
+
/** Selects by positive integer weights (default 1); world block coordinates make the choice repeatable. */
|
|
2213
|
+
static choose(variants: BlockStateVariant | BlockStateVariant[], position?: Readonly<TripleArray>): BlockStateVariant;
|
|
2214
|
+
private static positionSample;
|
|
2215
|
+
/** Converts blockstate rotations in degrees into the Euler rotation used by model rendering. */
|
|
2216
|
+
static rotation(variant: BlockStateVariant): Euler;
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
/** Supplies block tint colors from versioned rendering rules and the active resource pack. */
|
|
2220
|
+
declare class BlockTints {
|
|
2221
|
+
/** Returns a block's versioned biome color source, leaving fixed-color blocks unchanged. */
|
|
2222
|
+
static biomeSource(key?: AssetKey): Promise<BiomeColorKind | undefined>;
|
|
2223
|
+
/** Resolves one block's biome tint at world block coordinates, without biome blending. */
|
|
2224
|
+
static getBiomeColor(key?: AssetKey, biome?: string, position?: Readonly<TripleArray>): Promise<number | undefined>;
|
|
2225
|
+
/** Resolves used tint indices from biome or preview colors; explicit tints take precedence. */
|
|
2226
|
+
static get(key: AssetKey | undefined, state: BlockStateProperties, model: Model, tints?: Record<number, number>, biomeColor?: number | (() => Promise<number | undefined>)): Promise<Record<number, number> | undefined>;
|
|
2012
2227
|
}
|
|
2013
|
-
declare function isBlockObject(obj: any): obj is BlockObject;
|
|
2014
2228
|
|
|
2015
2229
|
/** Saved fluid levels and solid neighbors determine the geometry shared by an instance pool. */
|
|
2016
2230
|
declare function sampleFluid(kind: FluidKind, sample: FluidSampler): {
|
|
@@ -2028,6 +2242,11 @@ declare class FluidModelObject extends ModelObject {
|
|
|
2028
2242
|
disposeAndRemoveAllChildren(): void;
|
|
2029
2243
|
}
|
|
2030
2244
|
|
|
2245
|
+
/** Resolves a numeric block using mappings for the selected asset version, with caller overrides. */
|
|
2246
|
+
declare function resolveLegacyBlock(id: number, metadata: number, customMappings?: Readonly<Record<string, string>>, lenient?: boolean, root?: string): Promise<Block | undefined>;
|
|
2247
|
+
/** Resolves a numeric block using a previously loaded mapping table. */
|
|
2248
|
+
declare function resolveLegacyBlockState(id: number, metadata: number, mapping: Readonly<Record<string, string>>, customMappings?: Readonly<Record<string, string>>, lenient?: boolean): Block | undefined;
|
|
2249
|
+
|
|
2031
2250
|
/** Parsed blocks and entity data for {@link MineRenderWorld.placeMultiBlock}. Dimensions and positions use blocks. */
|
|
2032
2251
|
interface MultiBlockStructure {
|
|
2033
2252
|
readonly size: TripleArray;
|
|
@@ -2035,7 +2254,7 @@ interface MultiBlockStructure {
|
|
|
2035
2254
|
readonly dataVersion?: number;
|
|
2036
2255
|
readonly entities?: MultiBlockEntity[];
|
|
2037
2256
|
}
|
|
2038
|
-
/** Preserved entity position and NBT.
|
|
2257
|
+
/** Preserved entity position and NBT. `MineRenderWorld` can render supported mobs with `renderEntities`. */
|
|
2039
2258
|
interface MultiBlockEntity {
|
|
2040
2259
|
position: TripleArray;
|
|
2041
2260
|
blockPosition?: TripleArray;
|
|
@@ -2046,15 +2265,40 @@ interface MultiBlockBlock extends Block {
|
|
|
2046
2265
|
position: TripleArray;
|
|
2047
2266
|
}
|
|
2048
2267
|
|
|
2268
|
+
/** A named region with block and entity positions relative to the schematic origin. */
|
|
2269
|
+
interface LitematicaRegion extends MultiBlockStructure {
|
|
2270
|
+
readonly name: string;
|
|
2271
|
+
/** The selected first corner, relative to the schematic origin. */
|
|
2272
|
+
readonly position: TripleArray;
|
|
2273
|
+
/** Signed source dimensions. The inherited size contains their absolute values. */
|
|
2274
|
+
readonly signedSize: TripleArray;
|
|
2275
|
+
}
|
|
2276
|
+
/** Combined blocks and the named regions that produced them. */
|
|
2277
|
+
interface LitematicaStructure extends MultiBlockStructure {
|
|
2278
|
+
readonly regions: LitematicaRegion[];
|
|
2279
|
+
}
|
|
2280
|
+
/** Reads v5–7 `.litematic` files without migrating block states or entity NBT. */
|
|
2281
|
+
declare class LitematicaParser {
|
|
2282
|
+
/**
|
|
2283
|
+
* Parses decoded NBT, preserving subregion placement and omitting air.
|
|
2284
|
+
* Later entries in regions replace earlier cells, including with air.
|
|
2285
|
+
* Size encloses all region bounds; positions retain the schematic origin.
|
|
2286
|
+
* Metadata and scheduled ticks are not imported. Named regions can be placed individually.
|
|
2287
|
+
*/
|
|
2288
|
+
static parse(nbt: NBT): Promise<LitematicaStructure>;
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2049
2291
|
/** Converts legacy Alpha `.schematic` NBT with numeric block IDs into modern block names and properties. */
|
|
2050
2292
|
declare class SchematicParser {
|
|
2051
2293
|
/**
|
|
2052
|
-
* Parses a legacy schematic using custom mappings before the
|
|
2294
|
+
* Parses a legacy schematic using custom mappings before the selected version's defaults.
|
|
2053
2295
|
* Keys are `id:metadata`; values are block states such as `minecraft:oak_log[axis=x]`.
|
|
2054
2296
|
*/
|
|
2055
2297
|
static parse(nbt: NBT, customMappings?: Readonly<Record<string, string>>, options?: SchematicParserOptions): Promise<MultiBlockStructure>;
|
|
2056
2298
|
}
|
|
2057
2299
|
interface SchematicParserOptions {
|
|
2300
|
+
/** Asset root used to select the legacy mapping version. Omit to use the active asset sources. */
|
|
2301
|
+
root?: string;
|
|
2058
2302
|
/**
|
|
2059
2303
|
* Ignores Materials, tries metadata 0 for unmapped states, and skips unknown IDs. Defaults to false.
|
|
2060
2304
|
* Dimensions, arrays, and entity data remain validated.
|
|
@@ -2062,6 +2306,16 @@ interface SchematicParserOptions {
|
|
|
2062
2306
|
lenient?: boolean;
|
|
2063
2307
|
}
|
|
2064
2308
|
|
|
2309
|
+
/** Converts Sponge v2/v3 `.schem` NBT into blocks and preserved entity data. */
|
|
2310
|
+
declare class SpongeSchematicParser {
|
|
2311
|
+
/**
|
|
2312
|
+
* Parses decoded NBT with a local block palette, omitting air blocks.
|
|
2313
|
+
* Applies Offset to block and entity positions; size remains the source dimensions.
|
|
2314
|
+
* Biomes and metadata are not imported, and DataVersion does not trigger migration.
|
|
2315
|
+
*/
|
|
2316
|
+
static parse(nbt: NBT): Promise<MultiBlockStructure>;
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2065
2319
|
/** Converts Java structure NBT into blocks and preserved entity data for world placement. */
|
|
2066
2320
|
declare class StructureParser {
|
|
2067
2321
|
/**
|
|
@@ -2370,7 +2624,6 @@ declare class Caching {
|
|
|
2370
2624
|
static readonly modelTextureAtlasCache: AsyncLoadingCache<CacheKey, TextureAtlas>;
|
|
2371
2625
|
static readonly blockStateCache: AsyncLoadingCache<CacheKey, BlockState>;
|
|
2372
2626
|
static readonly listAssetCache: AsyncLoadingCache<CacheKey, ListAsset>;
|
|
2373
|
-
static readonly defaultBlockStatesCache: AsyncLoadingCache<CacheKey, DefaultBlockStates>;
|
|
2374
2627
|
static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
|
|
2375
2628
|
static readonly entityModelCache: AsyncLoadingCache<CacheKey, EntityModelFile>;
|
|
2376
2629
|
static readonly entityTextureCache: AsyncLoadingCache<CacheKey, AssetKey>;
|
|
@@ -2378,6 +2631,9 @@ declare class Caching {
|
|
|
2378
2631
|
static readonly blockEntityIndexCache: AsyncLoadingCache<CacheKey, BlockEntityIndex>;
|
|
2379
2632
|
static readonly fontCache: AsyncLoadingCache<CacheKey, BitmapFont>;
|
|
2380
2633
|
static readonly bannerPatternCache: AsyncLoadingCache<CacheKey, BannerPattern>;
|
|
2634
|
+
static readonly mineRenderDataCache: AsyncLoadingCache<CacheKey, unknown>;
|
|
2635
|
+
static readonly usernameUuidCache: AsyncLoadingCache<CacheKey, string>;
|
|
2636
|
+
static readonly biomeCache: AsyncLoadingCache<CacheKey, Biome>;
|
|
2381
2637
|
private static createAssetCache;
|
|
2382
2638
|
/** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
|
|
2383
2639
|
private static get all();
|
|
@@ -2409,7 +2665,7 @@ interface SceneGLTFExportOptions {
|
|
|
2409
2665
|
/** Maximum width and height of each exported texture, in pixels. */
|
|
2410
2666
|
maxTextureSize?: number;
|
|
2411
2667
|
}
|
|
2412
|
-
/** Exports
|
|
2668
|
+
/** Exports visible geometry at its current pose without changing the source scene. Animated item glint is omitted. */
|
|
2413
2669
|
declare class SceneExporter {
|
|
2414
2670
|
/** Returns OBJ geometry with normals and UVs; material files and textures are not included. */
|
|
2415
2671
|
static toObj(root: Object3D): string;
|
|
@@ -2422,6 +2678,53 @@ declare class SceneExporter {
|
|
|
2422
2678
|
static toGLTF(root: Object3D, options?: SceneGLTFExportOptions): Promise<Record<string, any> | ArrayBuffer>;
|
|
2423
2679
|
}
|
|
2424
2680
|
|
|
2681
|
+
/** Settings passed to {@link Renderer.toVideo}. */
|
|
2682
|
+
interface VideoExportOptions {
|
|
2683
|
+
/** Recording duration in seconds, greater than zero and at most 2147483.647. */
|
|
2684
|
+
duration: number;
|
|
2685
|
+
/** Requested capture rate (default 30). Rendering and browser scheduling can lower the actual rate. */
|
|
2686
|
+
fps?: number;
|
|
2687
|
+
/** Supported video MIME type. Defaults to WebM when available, then MP4. */
|
|
2688
|
+
mimeType?: string;
|
|
2689
|
+
/** Target video bitrate in bits per second, as a positive unsigned 32-bit integer. */
|
|
2690
|
+
videoBitsPerSecond?: number;
|
|
2691
|
+
/** Cancels recording and discards its output. */
|
|
2692
|
+
signal?: AbortSignal;
|
|
2693
|
+
}
|
|
2694
|
+
/**
|
|
2695
|
+
* Records fresh canvas frames in a browser, at a fixed size with an opaque black background.
|
|
2696
|
+
* @internal
|
|
2697
|
+
*/
|
|
2698
|
+
declare class VideoExporter {
|
|
2699
|
+
private readonly source;
|
|
2700
|
+
/** Resolves after the recorder provides its final video data. */
|
|
2701
|
+
readonly result: Promise<Blob>;
|
|
2702
|
+
private readonly canvas;
|
|
2703
|
+
private readonly context;
|
|
2704
|
+
private readonly signal?;
|
|
2705
|
+
private readonly duration;
|
|
2706
|
+
private stream?;
|
|
2707
|
+
private recorder?;
|
|
2708
|
+
private timer?;
|
|
2709
|
+
private readonly chunks;
|
|
2710
|
+
private settled;
|
|
2711
|
+
private stopping;
|
|
2712
|
+
private resolve;
|
|
2713
|
+
private reject;
|
|
2714
|
+
constructor(source: HTMLCanvasElement, options: VideoExportOptions);
|
|
2715
|
+
/** Copies a freshly drawn source frame before WebGL can clear its drawing buffer. */
|
|
2716
|
+
capture(): void;
|
|
2717
|
+
/** Cancels recording, releases its capture stream, and rejects {@link result}. */
|
|
2718
|
+
cancel(reason?: unknown): void;
|
|
2719
|
+
private readonly onStart;
|
|
2720
|
+
private readonly onData;
|
|
2721
|
+
private readonly onStop;
|
|
2722
|
+
private readonly onError;
|
|
2723
|
+
private readonly onAbort;
|
|
2724
|
+
private readonly onTrackEnded;
|
|
2725
|
+
private cleanup;
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2425
2728
|
/** Container coordinates in GUI pixels. Crops refer to vanilla's 256×256 sheets; {@link GuiHelper.container} scales them for resource packs. */
|
|
2426
2729
|
declare const GUI_CONTAINER_LAYOUTS: {
|
|
2427
2730
|
readonly generic_54: {
|
|
@@ -2471,7 +2774,7 @@ declare class GuiHelper {
|
|
|
2471
2774
|
* @param rowSize - Slots per row when `slot` is an index.
|
|
2472
2775
|
*/
|
|
2473
2776
|
static inventorySlot(slot: number | readonly [number, number], origin?: readonly [number, number], offset?: readonly [number, number], rowSize?: number): [number, number];
|
|
2474
|
-
/** Creates crafting-table layers for ingredients and the result
|
|
2777
|
+
/** Creates crafting-table layers for ingredients and the result, including its stack count. */
|
|
2475
2778
|
static recipe(recipe: GuiRecipe, options?: GuiRecipeOptions): GuiLayer[];
|
|
2476
2779
|
}
|
|
2477
2780
|
/** Settings passed to {@link GuiHelper.bossBar}. */
|
|
@@ -2609,20 +2912,139 @@ declare class MapControls extends OrbitControls {
|
|
|
2609
2912
|
constructor(object: Camera, domElement?: HTMLElement);
|
|
2610
2913
|
}
|
|
2611
2914
|
|
|
2915
|
+
/** Events dispatched by {@link FlyControls}. */
|
|
2916
|
+
interface FlyControlsEventMap {
|
|
2917
|
+
/** The camera moved or turned. */
|
|
2918
|
+
change: {};
|
|
2919
|
+
/** Mouse look captured the pointer. */
|
|
2920
|
+
lock: {};
|
|
2921
|
+
/** Mouse look released the pointer. */
|
|
2922
|
+
unlock: {};
|
|
2923
|
+
}
|
|
2924
|
+
/** Movement actions that {@link FlyControls.keys} binds to `KeyboardEvent.code` values. */
|
|
2925
|
+
type FlyAction = "forward" | "back" | "left" | "right" | "up" | "down" | "sprint";
|
|
2926
|
+
/**
|
|
2927
|
+
* Creative-flight camera controls: WASD moves horizontally along the view direction, space and shift
|
|
2928
|
+
* move up and down, R sprints, and the mouse turns the camera (pointer lock, or drag).
|
|
2929
|
+
*
|
|
2930
|
+
* Call {@link FlyControls.update} with the elapsed seconds once per frame; the `change` event marks the
|
|
2931
|
+
* renderer dirty while keys are held. Speeds use scene units (16 per block). The element becomes focusable
|
|
2932
|
+
* and keys apply while it has focus or the pointer is locked. A key pressed with Control, Alt, or Command
|
|
2933
|
+
* stays a browser shortcut unless that modifier is bound. The wheel changes the speed, as in vanilla
|
|
2934
|
+
* spectator mode. Touch input uses the left half of the element as a joystick and the right half for looking.
|
|
2935
|
+
*/
|
|
2936
|
+
declare class FlyControls extends Controls<FlyControlsEventMap, Camera> {
|
|
2937
|
+
readonly isFlyControls: true;
|
|
2938
|
+
/** Horizontal and vertical speed in scene units per second; vanilla creative flight by default. */
|
|
2939
|
+
movementSpeed: number;
|
|
2940
|
+
/** Speed multiplier while the sprint key is held. */
|
|
2941
|
+
sprintMultiplier: number;
|
|
2942
|
+
/** Radians per pixel of pointer movement. */
|
|
2943
|
+
lookSpeed: number;
|
|
2944
|
+
/** Smooth acceleration and deceleration, approximating vanilla flight momentum. */
|
|
2945
|
+
enableDamping: boolean;
|
|
2946
|
+
/** Portion of the remaining velocity change applied per 60 Hz frame (0–1) when damping is enabled. */
|
|
2947
|
+
dampingFactor: number;
|
|
2948
|
+
/** Capture the pointer on click so the mouse turns the camera without dragging; dragging works regardless. */
|
|
2949
|
+
pointerLock: boolean;
|
|
2950
|
+
/** Scroll the wheel to change `movementSpeed` within `speedRange`. */
|
|
2951
|
+
enableWheelSpeed: boolean;
|
|
2952
|
+
/** Minimum and maximum `movementSpeed` reachable with the wheel. */
|
|
2953
|
+
speedRange: [number, number];
|
|
2954
|
+
/** Touch joystick travel in CSS pixels for full speed. */
|
|
2955
|
+
joystickRadius: number;
|
|
2956
|
+
/** Key bindings by `KeyboardEvent.code`. */
|
|
2957
|
+
keys: Record<FlyAction, string[]>;
|
|
2958
|
+
private readonly _pressed;
|
|
2959
|
+
private readonly _velocity;
|
|
2960
|
+
private readonly _lastPosition;
|
|
2961
|
+
private readonly _lastQuaternion;
|
|
2962
|
+
private _position0;
|
|
2963
|
+
private _quaternion0;
|
|
2964
|
+
private _dragPointer?;
|
|
2965
|
+
private _dragX;
|
|
2966
|
+
private _dragY;
|
|
2967
|
+
private _dragMoved;
|
|
2968
|
+
private _dragTravel;
|
|
2969
|
+
private _joystick?;
|
|
2970
|
+
private _locked;
|
|
2971
|
+
private _madeFocusable;
|
|
2972
|
+
private _lastTime?;
|
|
2973
|
+
private readonly _onKeyDown;
|
|
2974
|
+
private readonly _onKeyUp;
|
|
2975
|
+
private readonly _onPointerDown;
|
|
2976
|
+
private readonly _onPointerMove;
|
|
2977
|
+
private readonly _onPointerUp;
|
|
2978
|
+
private readonly _onPointerLockChange;
|
|
2979
|
+
private readonly _onContextMenu;
|
|
2980
|
+
private readonly _onWheel;
|
|
2981
|
+
private readonly _onBlur;
|
|
2982
|
+
constructor(camera: Camera, domElement?: HTMLElement | null);
|
|
2983
|
+
connect(element: HTMLElement): void;
|
|
2984
|
+
disconnect(): void;
|
|
2985
|
+
dispose(): void;
|
|
2986
|
+
/** Whether mouse look currently owns the pointer. */
|
|
2987
|
+
get locked(): boolean;
|
|
2988
|
+
/** Requests pointer capture; browsers only allow this from a user gesture. */
|
|
2989
|
+
lock(): void;
|
|
2990
|
+
/** Releases a captured pointer. */
|
|
2991
|
+
unlock(): void;
|
|
2992
|
+
/** Stores the camera pose that {@link reset} restores. */
|
|
2993
|
+
saveState(): void;
|
|
2994
|
+
/** Restores the saved camera pose and stops movement. */
|
|
2995
|
+
reset(): void;
|
|
2996
|
+
/** Horizontal yaw in radians, where zero looks toward -Z. */
|
|
2997
|
+
get yaw(): number;
|
|
2998
|
+
/** Vertical pitch in radians, positive looking up. */
|
|
2999
|
+
get pitch(): number;
|
|
3000
|
+
/** Turns the camera; pitch is clamped to straight up and down. */
|
|
3001
|
+
setRotation(yaw: number, pitch: number): void;
|
|
3002
|
+
/** Points the camera at a position without rolling it. */
|
|
3003
|
+
lookAt(target: Vector3): void;
|
|
3004
|
+
/** Whether an action's key is held. */
|
|
3005
|
+
isPressed(action: FlyAction): boolean;
|
|
3006
|
+
/**
|
|
3007
|
+
* Advances movement by `delta` seconds (measured since the previous call when omitted)
|
|
3008
|
+
* and dispatches `change` when the camera moved.
|
|
3009
|
+
* A step longer than 0.1 s is applied as 0.1 s.
|
|
3010
|
+
*/
|
|
3011
|
+
update(delta?: number): void;
|
|
3012
|
+
private move;
|
|
3013
|
+
private notifyChange;
|
|
3014
|
+
private releaseKeys;
|
|
3015
|
+
private handleKey;
|
|
3016
|
+
/** A key pressed with Control, Alt, or Command stays a browser shortcut unless that modifier is bound to an action. */
|
|
3017
|
+
private isBrowserShortcut;
|
|
3018
|
+
private actionFor;
|
|
3019
|
+
private handlePointerDown;
|
|
3020
|
+
private onJoystickSide;
|
|
3021
|
+
private handlePointerMove;
|
|
3022
|
+
private handlePointerUp;
|
|
3023
|
+
private handleWheel;
|
|
3024
|
+
private handlePointerLockChange;
|
|
3025
|
+
private turn;
|
|
3026
|
+
}
|
|
3027
|
+
declare function isFlyControls(obj: any): obj is FlyControls;
|
|
3028
|
+
|
|
2612
3029
|
/**
|
|
2613
3030
|
* Renders a Minecraft scene with a camera and an optional effects composer.
|
|
2614
|
-
*
|
|
2615
|
-
*
|
|
3031
|
+
* Uses a browser canvas by default, or a caller-supplied {@link RendererSurface}.
|
|
3032
|
+
* Call {@link start} for browser animation or {@link renderOnce} for a single frame.
|
|
2616
3033
|
*/
|
|
2617
3034
|
declare class Renderer implements Disposable {
|
|
2618
3035
|
static readonly DEFAULT_OPTIONS: RendererOptions;
|
|
2619
3036
|
readonly options: RendererOptions;
|
|
2620
3037
|
protected _element?: HTMLElement;
|
|
3038
|
+
private readonly _surface?;
|
|
3039
|
+
private _width;
|
|
3040
|
+
private _height;
|
|
2621
3041
|
protected _scene: MineRenderScene;
|
|
2622
3042
|
protected _camera: Camera;
|
|
2623
3043
|
protected _renderer: WebGLRenderer;
|
|
2624
3044
|
protected _composer?: EffectComposer;
|
|
2625
|
-
protected _controls?:
|
|
3045
|
+
protected _controls?: RendererControls;
|
|
3046
|
+
private _controlsTime?;
|
|
3047
|
+
private _orbitDistance?;
|
|
2626
3048
|
protected _stats?: Stats;
|
|
2627
3049
|
protected _dirty: boolean;
|
|
2628
3050
|
protected _animationLoop: any;
|
|
@@ -2632,16 +3054,29 @@ declare class Renderer implements Disposable {
|
|
|
2632
3054
|
private _running;
|
|
2633
3055
|
private _inAnimationLoop;
|
|
2634
3056
|
private _disposed;
|
|
3057
|
+
private _videoExporter?;
|
|
2635
3058
|
private readonly _frameCallbacks;
|
|
2636
3059
|
private readonly _debugHelpers;
|
|
2637
3060
|
private readonly _eventDispatchers;
|
|
2638
3061
|
private readonly _changeListener;
|
|
2639
|
-
constructor(options?: DeepPartial<RendererOptions
|
|
3062
|
+
constructor(options?: DeepPartial<RendererOptions>, surface?: RendererSurface);
|
|
2640
3063
|
protected createScene(): MineRenderScene;
|
|
2641
3064
|
protected createCamera(): Camera;
|
|
2642
3065
|
protected createRenderer(): WebGLRenderer;
|
|
2643
3066
|
protected createComposer(): Maybe<EffectComposer>;
|
|
2644
|
-
protected createControls(): Maybe<
|
|
3067
|
+
protected createControls(): Maybe<RendererControls>;
|
|
3068
|
+
private initialTarget;
|
|
3069
|
+
private createControlsFor;
|
|
3070
|
+
/**
|
|
3071
|
+
* Replaces renderer-owned controls with the selected mode, keeping the camera where it is.
|
|
3072
|
+
* Switching to orbit controls targets the point the camera looks at, at the previous orbit distance.
|
|
3073
|
+
* The previous controls object is disposed, so its listeners and settings do not carry over.
|
|
3074
|
+
* Returns the new controls, or undefined when controls were disabled at construction or after disposal.
|
|
3075
|
+
*/
|
|
3076
|
+
setControlsMode(mode: ControlsMode): Maybe<RendererControls>;
|
|
3077
|
+
private disposeControls;
|
|
3078
|
+
/** Advances owned controls; without a frame time, flight movement does not progress. */
|
|
3079
|
+
private updateControls;
|
|
2645
3080
|
init(): void;
|
|
2646
3081
|
get element(): Maybe<HTMLElement>;
|
|
2647
3082
|
/** Attaches the canvas to an element and sizes it to that element's dimensions. */
|
|
@@ -2651,8 +3086,10 @@ declare class Renderer implements Disposable {
|
|
|
2651
3086
|
* The renderer removes its listener on disposal; the caller retains ownership of the dispatcher.
|
|
2652
3087
|
*/
|
|
2653
3088
|
registerEventDispatcher(dispatcher: EventDispatcher<any>, changeEvent?: string): void;
|
|
3089
|
+
private unregisterEventDispatcher;
|
|
2654
3090
|
/** Updates the camera and canvas size. Width and height are in CSS pixels. */
|
|
2655
3091
|
resize(width: number, height: number): void;
|
|
3092
|
+
private validateSurfaceSize;
|
|
2656
3093
|
get dirty(): boolean;
|
|
2657
3094
|
set dirty(dirty: boolean);
|
|
2658
3095
|
/**
|
|
@@ -2661,9 +3098,9 @@ declare class Renderer implements Disposable {
|
|
|
2661
3098
|
* Registering the same callback twice has no effect. Image exports do not invoke callbacks.
|
|
2662
3099
|
*/
|
|
2663
3100
|
onFrame(callback: FrameCallback): () => void;
|
|
2664
|
-
/** Starts or resumes the animation loop and registered frame callbacks. */
|
|
3101
|
+
/** Starts or resumes the animation loop and registered frame callbacks. Has no effect while running. */
|
|
2665
3102
|
start(): void;
|
|
2666
|
-
/** Pauses rendering and frame callbacks. Call {@link start} to resume. */
|
|
3103
|
+
/** Pauses rendering and frame callbacks, and cancels video export. Call {@link start} to resume. */
|
|
2667
3104
|
stop(): void;
|
|
2668
3105
|
/**
|
|
2669
3106
|
* Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
|
|
@@ -2673,12 +3110,22 @@ declare class Renderer implements Disposable {
|
|
|
2673
3110
|
dispose(): void;
|
|
2674
3111
|
private animate;
|
|
2675
3112
|
private drawFrame;
|
|
3113
|
+
/** Draws a fresh frame without starting the animation loop or invoking frame callbacks. */
|
|
3114
|
+
renderOnce(): void;
|
|
2676
3115
|
/**
|
|
2677
3116
|
* Renders a fresh frame and returns an image data URL, including while the animation loop is stopped.
|
|
2678
3117
|
* Trimming removes transparent borders; an empty image becomes one transparent pixel.
|
|
2679
3118
|
* MIME type support and lossy quality (0–1) follow the canvas encoder.
|
|
2680
3119
|
*/
|
|
2681
3120
|
toImage(trim?: boolean, mime?: string, quality?: number): string;
|
|
3121
|
+
/**
|
|
3122
|
+
* Records a silent browser video in real time, including frame callbacks and animated textures.
|
|
3123
|
+
* Keep the tab visible; browser scheduling and `render.fpsLimit` limit the capture rate.
|
|
3124
|
+
* The video keeps the initial drawing-buffer size and fills transparent pixels with black.
|
|
3125
|
+
* Temporarily starts a stopped renderer. Stop, disposal, or `options.signal` cancels the export.
|
|
3126
|
+
* Only one export can run at a time. Use the returned Blob's type to select a file extension.
|
|
3127
|
+
*/
|
|
3128
|
+
toVideo(options: VideoExportOptions): Promise<Blob>;
|
|
2682
3129
|
/** Exports visible scene meshes as OBJ text, without texture images. */
|
|
2683
3130
|
toObj(): string;
|
|
2684
3131
|
/** Exports visible scene meshes as PLY. Set `options.binary` for an ArrayBuffer. */
|
|
@@ -2693,7 +3140,23 @@ declare class Renderer implements Disposable {
|
|
|
2693
3140
|
get renderer(): WebGLRenderer;
|
|
2694
3141
|
get composer(): Maybe<EffectComposer>;
|
|
2695
3142
|
/** Renderer-owned controls, or undefined when disabled at construction or after disposal. */
|
|
2696
|
-
get controls(): Maybe<
|
|
3143
|
+
get controls(): Maybe<RendererControls>;
|
|
3144
|
+
/** Renderer-owned OrbitControls, or undefined in fly mode or without controls. */
|
|
3145
|
+
get orbitControls(): Maybe<OrbitControls>;
|
|
3146
|
+
/** Renderer-owned {@link FlyControls}, or undefined in orbit mode or without controls. */
|
|
3147
|
+
get flyControls(): Maybe<FlyControls>;
|
|
3148
|
+
/** The active renderer-owned controls mode, or undefined without controls. */
|
|
3149
|
+
get controlsMode(): Maybe<ControlsMode>;
|
|
3150
|
+
}
|
|
3151
|
+
/** Caller-owned canvas and WebGL 2 context for rendering without a browser DOM. */
|
|
3152
|
+
interface RendererSurface {
|
|
3153
|
+
canvas: Pick<HTMLCanvasElement, "width" | "height" | "addEventListener" | "removeEventListener">;
|
|
3154
|
+
context: WebGL2RenderingContext;
|
|
3155
|
+
/** Initial logical dimensions, before applying `render.pixelRatio`. */
|
|
3156
|
+
width: number;
|
|
3157
|
+
height: number;
|
|
3158
|
+
/** Resizes the native drawing buffer when assigning canvas dimensions is insufficient. */
|
|
3159
|
+
resize?: (drawingBufferWidth: number, drawingBufferHeight: number) => void;
|
|
2697
3160
|
}
|
|
2698
3161
|
/** Timing passed to callbacks registered with {@link Renderer.onFrame}. */
|
|
2699
3162
|
interface RendererFrame {
|
|
@@ -2749,9 +3212,15 @@ interface RenderOptions {
|
|
|
2749
3212
|
interface ComposerOptions {
|
|
2750
3213
|
enabled: boolean;
|
|
2751
3214
|
}
|
|
2752
|
-
/**
|
|
3215
|
+
/** Renderer-owned camera controls: orbiting around a target, or creative-style flight. */
|
|
3216
|
+
type ControlsMode = "orbit" | "fly";
|
|
3217
|
+
/** Controls created through `controls.enabled`; narrow with `isFlyControls` or {@link Renderer.controlsMode}. */
|
|
3218
|
+
type RendererControls = OrbitControls | FlyControls;
|
|
3219
|
+
/** Set `controls: { enabled: true }` in the Renderer constructor to create owned controls. */
|
|
2753
3220
|
interface ControlsOptions {
|
|
2754
3221
|
enabled: boolean;
|
|
3222
|
+
/** `orbit` (default) creates OrbitControls; `fly` creates {@link FlyControls}. */
|
|
3223
|
+
mode?: ControlsMode;
|
|
2755
3224
|
}
|
|
2756
3225
|
/** Scene helpers enabled through `debug` in the Renderer constructor options. */
|
|
2757
3226
|
interface DebugOptions {
|
|
@@ -2863,6 +3332,14 @@ interface SceneBlockDefinition extends SceneObjectDefinitionBase {
|
|
|
2863
3332
|
tints?: Record<number, number>;
|
|
2864
3333
|
};
|
|
2865
3334
|
}
|
|
3335
|
+
/** Supplied item state; see ItemModelContext. Item references are item IDs such as minecraft:apple. */
|
|
3336
|
+
interface SceneItemContext {
|
|
3337
|
+
displayContext?: DisplayPosition | "none";
|
|
3338
|
+
properties?: Record<string, boolean | string | number>;
|
|
3339
|
+
components?: Record<string, unknown>;
|
|
3340
|
+
count?: number;
|
|
3341
|
+
itemReferences?: Record<string, string>;
|
|
3342
|
+
}
|
|
2866
3343
|
interface SceneModelDefinition extends SceneObjectDefinitionBase {
|
|
2867
3344
|
type: "item" | "model";
|
|
2868
3345
|
asset: string;
|
|
@@ -2871,6 +3348,8 @@ interface SceneModelDefinition extends SceneObjectDefinitionBase {
|
|
|
2871
3348
|
displayPosition?: DisplayPosition;
|
|
2872
3349
|
tints?: Record<number, number>;
|
|
2873
3350
|
};
|
|
3351
|
+
/** Item state for `type: "item"` definitions only. */
|
|
3352
|
+
context?: SceneItemContext;
|
|
2874
3353
|
}
|
|
2875
3354
|
interface SceneEntityDefinition extends SceneObjectDefinitionBase {
|
|
2876
3355
|
type: "entity";
|
|
@@ -2894,8 +3373,9 @@ interface SceneEntityDefinition extends SceneObjectDefinitionBase {
|
|
|
2894
3373
|
}
|
|
2895
3374
|
type SceneGuiLayer = (Omit<GuiTextureLayer, "texture"> & {
|
|
2896
3375
|
texture: string;
|
|
2897
|
-
}) | (Omit<GuiItemLayer, "item"> & {
|
|
3376
|
+
}) | (Omit<GuiItemLayer, "item" | "context"> & {
|
|
2898
3377
|
item: string;
|
|
3378
|
+
context?: Omit<SceneItemContext, "displayContext">;
|
|
2899
3379
|
}) | (Omit<GuiTextLayer, "font"> & {
|
|
2900
3380
|
font?: string;
|
|
2901
3381
|
});
|
|
@@ -2936,6 +3416,20 @@ declare class SceneDocumentLoader {
|
|
|
2936
3416
|
private static loadValidatedObject;
|
|
2937
3417
|
}
|
|
2938
3418
|
|
|
3419
|
+
/** Resolves Minecraft profile components to resource textures or shared, prepared player skins. */
|
|
3420
|
+
declare class PlayerHeadTextures {
|
|
3421
|
+
/** Resource textures retain their pixels; downloaded skins use the skin pipeline's legacy and opacity rules. */
|
|
3422
|
+
static get(value: unknown, root?: string): Promise<{
|
|
3423
|
+
texture: AssetKey;
|
|
3424
|
+
material?: MeshBasicMaterial;
|
|
3425
|
+
}>;
|
|
3426
|
+
private static resource;
|
|
3427
|
+
private static profile;
|
|
3428
|
+
private static propertyUrl;
|
|
3429
|
+
private static offlineUuid;
|
|
3430
|
+
private static uuidString;
|
|
3431
|
+
}
|
|
3432
|
+
|
|
2939
3433
|
type SkinGeometries = Record<SkinPart, TripleArray>;
|
|
2940
3434
|
declare const classicSkinGeometries: SkinGeometries;
|
|
2941
3435
|
declare const slimSkinGeometries: SkinGeometries;
|
|
@@ -3007,6 +3501,8 @@ declare class Skins {
|
|
|
3007
3501
|
declare class Colormaps {
|
|
3008
3502
|
/** Samples the selected resource pack's grass colormap using Minecraft's climate coordinates. */
|
|
3009
3503
|
static grassColor(origin?: AssetKey, temperature?: number, downfall?: number): Promise<number>;
|
|
3504
|
+
/** Samples a resource-pack colormap at the supplied climate coordinates. */
|
|
3505
|
+
static getColor(kind: "grass" | "foliage" | "dry_foliage", origin?: AssetKey, temperature?: number, downfall?: number): Promise<number>;
|
|
3010
3506
|
}
|
|
3011
3507
|
|
|
3012
3508
|
/** Creates sRGB textures immediately and fills their pixels after asynchronous image loading. */
|
|
@@ -3042,6 +3538,7 @@ declare function mergeVertices(geometry: BufferGeometry, tolerance?: number): Bu
|
|
|
3042
3538
|
declare function toTrianglesDrawMode(geometry: BufferGeometry, drawMode: TrianglesDrawModes): BufferGeometry;
|
|
3043
3539
|
declare function computeMorphedAttributes(object: Mesh | Line | Points): object;
|
|
3044
3540
|
|
|
3541
|
+
type PaletteState = Readonly<Pick<Block, "type" | "properties">>;
|
|
3045
3542
|
/** Stores 4,096 block cells in a shared state palette, with separate NBT for each cell. */
|
|
3046
3543
|
declare class ChunkData {
|
|
3047
3544
|
private readonly indices;
|
|
@@ -3055,13 +3552,46 @@ declare class ChunkData {
|
|
|
3055
3552
|
snapshot(index: number): Maybe<() => Block>;
|
|
3056
3553
|
/** Copies block data into a cell. An omitted block or an air block clears the cell. */
|
|
3057
3554
|
set(index: number, block?: Block): void;
|
|
3555
|
+
/** Interns a normalized block state without changing cells. Air has palette id 0. */
|
|
3556
|
+
intern(block: Maybe<Block>): number;
|
|
3557
|
+
/** Assigns an interned state to a cell and replaces its NBT. `undefined` clears the NBT. */
|
|
3558
|
+
assign(index: number, id: number, nbt?: unknown): void;
|
|
3559
|
+
/** Replaces all cells from palette indices, normalizes air to 0, and clears NBT. */
|
|
3560
|
+
fill(palette: readonly Maybe<Block>[], indices: Uint16Array): void;
|
|
3561
|
+
/** Returns a cell's palette id, or 0 for air. */
|
|
3562
|
+
idAt(index: number): number;
|
|
3563
|
+
/** Returns a frozen state, or `undefined` for air or a freed palette id. */
|
|
3564
|
+
stateAt(id: number): PaletteState | undefined;
|
|
3565
|
+
/** Replaces cells, palette entries, and NBT with independent copies of another section. */
|
|
3566
|
+
copyFrom(other: ChunkData): void;
|
|
3058
3567
|
clear(): void;
|
|
3059
3568
|
static isAir(block: Maybe<Block>): boolean;
|
|
3569
|
+
/** Identifies a normalized block type and its sorted properties, excluding per-cell NBT. */
|
|
3570
|
+
static paletteKey(block: Block): string;
|
|
3060
3571
|
private static copyBlock;
|
|
3061
3572
|
private static validateIndex;
|
|
3062
3573
|
}
|
|
3063
3574
|
|
|
3064
3575
|
type RegionInput = Uint8Array | ArrayBuffer;
|
|
3576
|
+
/** Reads `c.<x>.<z>.mcc` at absolute chunk coordinates, or returns `undefined` when the file is missing. */
|
|
3577
|
+
type AnvilExternalChunkReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
|
|
3578
|
+
interface AnvilParseOptions {
|
|
3579
|
+
/** Asset root used to select numeric block mappings. Omit to use the active asset sources. */
|
|
3580
|
+
root?: string;
|
|
3581
|
+
/** Overrides numeric `id:metadata` mappings with block states such as `minecraft:oak_log[axis=x]`. */
|
|
3582
|
+
legacyMappings?: Readonly<Record<string, string>>;
|
|
3583
|
+
/** For numeric blocks, tries metadata 0 for unmapped states and skips unknown IDs. Defaults to false. */
|
|
3584
|
+
lenient?: boolean;
|
|
3585
|
+
/** Region coordinates from `r.<x>.<z>.mca`, required when reading external chunks. */
|
|
3586
|
+
region?: {
|
|
3587
|
+
x: number;
|
|
3588
|
+
z: number;
|
|
3589
|
+
};
|
|
3590
|
+
/** Reads external chunk payloads without their region-file header. */
|
|
3591
|
+
readExternalChunk?: AnvilExternalChunkReader;
|
|
3592
|
+
/** Cancels parsing and forwards the signal to external chunk reads. */
|
|
3593
|
+
signal?: AbortSignal;
|
|
3594
|
+
}
|
|
3065
3595
|
/** Chunk columns decoded from an Anvil region file. */
|
|
3066
3596
|
interface AnvilRegion {
|
|
3067
3597
|
chunks: AnvilChunk[];
|
|
@@ -3071,37 +3601,104 @@ interface AnvilChunk {
|
|
|
3071
3601
|
x: number;
|
|
3072
3602
|
z: number;
|
|
3073
3603
|
dataVersion?: number;
|
|
3604
|
+
/** DataVersion of the separate entity-region record; `dataVersion` belongs to the terrain. */
|
|
3605
|
+
entityDataVersion?: number;
|
|
3074
3606
|
sections: {
|
|
3075
3607
|
y: number;
|
|
3076
3608
|
data: ChunkData;
|
|
3609
|
+
/** 64 saved biome IDs, indexed by x + z * 4 + y * 16 at 4-block resolution. */
|
|
3610
|
+
biomes?: readonly string[];
|
|
3077
3611
|
}[];
|
|
3078
3612
|
entities?: MultiBlockEntity[];
|
|
3079
3613
|
}
|
|
3080
|
-
/**
|
|
3614
|
+
/** Entities decoded from an entity region, with absolute chunk coordinates. */
|
|
3615
|
+
interface AnvilEntityChunk {
|
|
3616
|
+
x: number;
|
|
3617
|
+
z: number;
|
|
3618
|
+
dataVersion?: number;
|
|
3619
|
+
entities: MultiBlockEntity[];
|
|
3620
|
+
}
|
|
3621
|
+
/** Reads numeric and paletted Java terrain and entity `.mca` regions without data-version migration. */
|
|
3081
3622
|
declare class AnvilParser {
|
|
3082
3623
|
/** Lists occupied chunk positions within the region, using local coordinates from 0 to 31. */
|
|
3083
3624
|
static getChunkList(data: RegionInput): {
|
|
3084
3625
|
x: number;
|
|
3085
3626
|
z: number;
|
|
3086
3627
|
}[];
|
|
3087
|
-
/** Decodes all stored chunks. Gzip, zlib, and uncompressed payloads are supported. */
|
|
3088
|
-
static parse(data: RegionInput): Promise<AnvilRegion>;
|
|
3628
|
+
/** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
|
|
3629
|
+
static parse(data: RegionInput, options?: AnvilParseOptions): Promise<AnvilRegion>;
|
|
3089
3630
|
/**
|
|
3090
3631
|
* Decodes one chunk for {@link MineRenderWorld.placeChunk}.
|
|
3091
3632
|
* @param localX - Chunk x within the region, from 0 to 31.
|
|
3092
3633
|
* @param localZ - Chunk z within the region, from 0 to 31.
|
|
3093
3634
|
* @returns The chunk with absolute coordinates, or `undefined` if the region has no chunk there.
|
|
3094
3635
|
*/
|
|
3095
|
-
static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
|
|
3636
|
+
static parseChunk(data: RegionInput, localX: number, localZ: number, options?: AnvilParseOptions): Promise<AnvilChunk | undefined>;
|
|
3637
|
+
/**
|
|
3638
|
+
* Decodes one chunk from an `entities/r.x.z.mca` file without migrating its NBT.
|
|
3639
|
+
* @param localX - Chunk x within the region, from 0 to 31.
|
|
3640
|
+
* @param localZ - Chunk z within the region, from 0 to 31.
|
|
3641
|
+
* @returns The entities with absolute chunk coordinates, or `undefined` if no chunk is stored there.
|
|
3642
|
+
*/
|
|
3643
|
+
static parseEntityChunk(data: RegionInput, localX: number, localZ: number, options?: AnvilParseOptions): Promise<AnvilEntityChunk | undefined>;
|
|
3644
|
+
private static location;
|
|
3645
|
+
private static abortable;
|
|
3096
3646
|
private static bytes;
|
|
3097
3647
|
private static locations;
|
|
3648
|
+
private static readNBT;
|
|
3098
3649
|
private static readChunk;
|
|
3650
|
+
private static numericSection;
|
|
3651
|
+
private static entities;
|
|
3652
|
+
private static biomes;
|
|
3099
3653
|
private static compounds;
|
|
3100
3654
|
private static integer;
|
|
3101
3655
|
private static block;
|
|
3102
3656
|
private static unpack;
|
|
3103
3657
|
}
|
|
3104
3658
|
|
|
3659
|
+
/** Loads chunk columns at absolute integer chunk coordinates. */
|
|
3660
|
+
interface WorldChunkSource {
|
|
3661
|
+
/** Returns the requested column, or `undefined` if absent. Honor signal to cancel discarded reads. */
|
|
3662
|
+
getChunk(x: number, z: number, signal?: AbortSignal): Promise<AnvilChunk | undefined>;
|
|
3663
|
+
}
|
|
3664
|
+
|
|
3665
|
+
/**
|
|
3666
|
+
* Reads `r.<x>.<z>.mca` at integer region coordinates, or returns `undefined` when absent.
|
|
3667
|
+
* Forward `signal` to file or network I/O; it aborts when every caller waiting for the region cancels.
|
|
3668
|
+
*/
|
|
3669
|
+
type AnvilRegionReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
|
|
3670
|
+
/** Readers and cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
|
|
3671
|
+
interface AnvilWorldSourceOptions extends Pick<AnvilParseOptions, "readExternalChunk" | "legacyMappings" | "lenient" | "root"> {
|
|
3672
|
+
/** Reads a dimension's separate `entities/r.<x>.<z>.mca` files. Omit to use embedded entities only. */
|
|
3673
|
+
readEntityRegion?: AnvilRegionReader;
|
|
3674
|
+
/** Maximum cached regions per kind (terrain and entities), including missing regions. Defaults to 4 each; 0 disables caching. */
|
|
3675
|
+
maxCachedRegions?: number;
|
|
3676
|
+
/** Maximum retained bytes across both region types. Defaults to 64 MiB; larger regions are read without caching. */
|
|
3677
|
+
maxCachedBytes?: number;
|
|
3678
|
+
}
|
|
3679
|
+
/** Reads selected Java Anvil chunk columns and caches raw regions within count and byte limits. */
|
|
3680
|
+
declare class AnvilWorldSource implements WorldChunkSource {
|
|
3681
|
+
private readonly readRegion;
|
|
3682
|
+
private readonly regions;
|
|
3683
|
+
private readonly pending;
|
|
3684
|
+
private readonly maxCachedRegions;
|
|
3685
|
+
private readonly maxCachedBytes;
|
|
3686
|
+
private readonly readEntityRegion?;
|
|
3687
|
+
private readonly parseOptions;
|
|
3688
|
+
private cachedBytes;
|
|
3689
|
+
constructor(readRegion: AnvilRegionReader, options?: AnvilWorldSourceOptions);
|
|
3690
|
+
/**
|
|
3691
|
+
* Decodes a column at absolute chunk coordinates, including entity-only columns.
|
|
3692
|
+
* A separate entity record replaces embedded entities, even when its list is empty.
|
|
3693
|
+
* Missing entity files or records leave embedded entities intact. Aborting a caller leaves other shared readers active.
|
|
3694
|
+
*/
|
|
3695
|
+
getChunk(x: number, z: number, signal?: AbortSignal): Promise<AnvilChunk | undefined>;
|
|
3696
|
+
/** Releases cached regions. Reads already in progress finish without repopulating this cache. */
|
|
3697
|
+
clearCache(): void;
|
|
3698
|
+
private getRegion;
|
|
3699
|
+
private cacheRegion;
|
|
3700
|
+
}
|
|
3701
|
+
|
|
3105
3702
|
/** A placed block's data snapshot and optional render object, returned by world and chunk accessors. */
|
|
3106
3703
|
interface BlockInfo<SectionMeshing extends boolean = false> {
|
|
3107
3704
|
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
@@ -3110,11 +3707,13 @@ interface BlockInfo<SectionMeshing extends boolean = false> {
|
|
|
3110
3707
|
object: SectionMeshing extends false ? BlockObject : BlockObject | undefined;
|
|
3111
3708
|
}
|
|
3112
3709
|
|
|
3113
|
-
/** Shared
|
|
3710
|
+
/** Shared quad geometry and atlas data prepared for section merging. */
|
|
3114
3711
|
interface SectionMeshTemplate {
|
|
3115
3712
|
geometry: BufferGeometry;
|
|
3116
3713
|
atlas: TextureAtlas;
|
|
3117
|
-
cullFaces:
|
|
3714
|
+
cullFaces: Uint8Array;
|
|
3715
|
+
occludes: boolean;
|
|
3716
|
+
layer: 0 | 1;
|
|
3118
3717
|
}
|
|
3119
3718
|
/** One block placement in a section, with its storage index and hidden-face mask. */
|
|
3120
3719
|
interface SectionMeshEntry {
|
|
@@ -3122,24 +3721,44 @@ interface SectionMeshEntry {
|
|
|
3122
3721
|
template: SectionMeshTemplate;
|
|
3123
3722
|
cullMask: number;
|
|
3124
3723
|
}
|
|
3724
|
+
/** Fluid cells for one section and the shared atlases of the kinds present. */
|
|
3725
|
+
interface SectionFluids {
|
|
3726
|
+
cells: Uint8Array;
|
|
3727
|
+
/** Linear RGB per section cell, indexed by (x + 16z + 256y) * 3. */
|
|
3728
|
+
waterTints?: Float32Array;
|
|
3729
|
+
water?: TextureAtlas;
|
|
3730
|
+
lava?: TextureAtlas;
|
|
3731
|
+
}
|
|
3125
3732
|
/** Merged terrain geometry and atlas pages for one 16×16×16 section. Owns its generated render resources. */
|
|
3126
3733
|
declare class SectionMesh extends Group {
|
|
3127
3734
|
private readonly ownedMeshes;
|
|
3128
|
-
/** Builds section-local meshes from visible
|
|
3129
|
-
static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
|
|
3735
|
+
/** Builds section-local meshes from visible quads. `maxAtlasSize` limits each atlas dimension in pixels. */
|
|
3736
|
+
static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number, fluids?: SectionFluids): SectionMesh;
|
|
3737
|
+
/** Builds section-local meshes in a browser worker when available, with synchronous fallback. */
|
|
3738
|
+
static buildAsync(entries: readonly SectionMeshEntry[], maxAtlasSize?: number, fluids?: SectionFluids): Promise<SectionMesh>;
|
|
3739
|
+
private static fromPages;
|
|
3130
3740
|
dispose(): void;
|
|
3131
3741
|
}
|
|
3132
3742
|
|
|
3133
|
-
/** Prepares and caches
|
|
3743
|
+
/** Prepares and caches model geometry and fluid atlases for merged world sections. */
|
|
3134
3744
|
declare class SectionModels {
|
|
3135
3745
|
readonly maxAtlasSize: number;
|
|
3136
3746
|
private states;
|
|
3137
3747
|
private models;
|
|
3138
3748
|
private readonly templates;
|
|
3749
|
+
private readonly fluidAtlases;
|
|
3139
3750
|
constructor(maxAtlasSize?: number);
|
|
3140
|
-
/** Returns
|
|
3141
|
-
get(blockState: BlockState, properties?: BlockStateProperties): Promise<SectionMeshTemplate | undefined>;
|
|
3751
|
+
/** Returns templates for the matched parts, or `undefined` when the block needs an individual render object. */
|
|
3752
|
+
get(blockState: BlockState, properties?: BlockStateProperties, position?: Readonly<TripleArray>, biome?: string): Promise<SectionMeshTemplate[] | undefined>;
|
|
3753
|
+
/** Resolves section templates for one tint palette, with a synchronous weighted choice for each cell. */
|
|
3754
|
+
prepareState(blockState: BlockState, properties?: BlockStateProperties, biomeColor?: number | (() => Promise<number | undefined>)): Promise<{
|
|
3755
|
+
pick(position?: Readonly<TripleArray>): SectionMeshTemplate[];
|
|
3756
|
+
} | undefined>;
|
|
3757
|
+
private state;
|
|
3758
|
+
/** Returns the shared still/flow atlas used by per-block fluid objects. */
|
|
3759
|
+
fluidAtlas(kind: FluidKind, root?: string): Promise<TextureAtlas>;
|
|
3142
3760
|
private prepare;
|
|
3761
|
+
private template;
|
|
3143
3762
|
/** Disposes prepared geometry and clears this world's template caches. */
|
|
3144
3763
|
clear(): void;
|
|
3145
3764
|
}
|
|
@@ -3152,6 +3771,9 @@ declare class SectionModels {
|
|
|
3152
3771
|
declare class Chunk<SectionMeshing extends boolean = false> {
|
|
3153
3772
|
private readonly onBlocksChanged?;
|
|
3154
3773
|
private readonly sectionModels?;
|
|
3774
|
+
private readonly neighborCell?;
|
|
3775
|
+
private readonly biomeAt?;
|
|
3776
|
+
private readonly onBiomesChanged?;
|
|
3155
3777
|
readonly scene: MineRenderScene;
|
|
3156
3778
|
readonly x: number;
|
|
3157
3779
|
readonly y: number;
|
|
@@ -3160,12 +3782,25 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
3160
3782
|
private readonly renderedBlocks;
|
|
3161
3783
|
private readonly sectionBlocks;
|
|
3162
3784
|
private readonly hiddenBlocks;
|
|
3785
|
+
private readonly fluidCells;
|
|
3786
|
+
private readonly blockPosition;
|
|
3787
|
+
private waterTints?;
|
|
3788
|
+
private biomes?;
|
|
3163
3789
|
private sectionMesh?;
|
|
3164
3790
|
private meshDirty;
|
|
3165
|
-
|
|
3791
|
+
private meshGeneration;
|
|
3792
|
+
constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined, neighborCell?: ((x: number, y: number, z: number) => number) | undefined, biomeAt?: ((x: number, y: number, z: number) => Maybe<string>) | undefined, onBiomesChanged?: ((biomes?: readonly string[]) => Promise<void>) | undefined);
|
|
3166
3793
|
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
3167
3794
|
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
3168
3795
|
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
3796
|
+
/** Returns the saved 4-block biome sample at integer world block coordinates, or `undefined` if absent. */
|
|
3797
|
+
getBiomeAt(x: number, y: number, z: number): Maybe<string>;
|
|
3798
|
+
getBiomeAt(pos: Vector3): Maybe<string>;
|
|
3799
|
+
getBiomeAt(pos: TripleArray): Maybe<string>;
|
|
3800
|
+
/** Copies 64 biome IDs in x + z * 4 + y * 16 order and refreshes placed blocks. Omit the array to clear biome data. */
|
|
3801
|
+
setBiomes(biomes?: readonly string[]): Promise<void>;
|
|
3802
|
+
/** Rebuilds biome-tinted blocks while preserving hidden blocks and unrelated render objects. */
|
|
3803
|
+
refreshBiomes(): Promise<void>;
|
|
3169
3804
|
/**
|
|
3170
3805
|
* Places a block at integer world block coordinates. Pass `undefined` to remove it.
|
|
3171
3806
|
*/
|
|
@@ -3176,14 +3811,38 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
3176
3811
|
* Places a block at integer chunk-local coordinates from 0 to 15.
|
|
3177
3812
|
*/
|
|
3178
3813
|
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
3814
|
+
/** Places cells in input order and returns changed world positions without refreshing neighbors. */
|
|
3815
|
+
placeBlocks(blocks: readonly {
|
|
3816
|
+
index: number;
|
|
3817
|
+
block: Maybe<Block>;
|
|
3818
|
+
}[]): Promise<Vector3[]>;
|
|
3819
|
+
/** Replaces every cell from parsed section data. The caller refreshes neighbor culling. */
|
|
3820
|
+
placeSection(data: ChunkData): Promise<void>;
|
|
3821
|
+
private positionAt;
|
|
3822
|
+
private biomePosition;
|
|
3823
|
+
private resolveState;
|
|
3824
|
+
private setWaterTint;
|
|
3179
3825
|
/** Changes visibility at world block coordinates while preserving the block's data. */
|
|
3180
3826
|
setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
|
|
3181
3827
|
isBlockVisibleAt(pos: Vector3): boolean;
|
|
3828
|
+
/** Reports whether a cell has a visible render object or section entry. */
|
|
3829
|
+
isBlockVisibleIndex(index: number): boolean;
|
|
3830
|
+
/** Fluid kind bits and level of a cell, or 0. Hidden cells report 0. */
|
|
3831
|
+
fluidByteIndex(index: number): number;
|
|
3832
|
+
/** Whether the cell holds a fluid, merged or per-block. */
|
|
3833
|
+
isFluidIndex(index: number): boolean;
|
|
3182
3834
|
isOccludingAt(pos: Vector3): boolean;
|
|
3835
|
+
/** Reports whether a visible cell hides neighboring cube faces. */
|
|
3836
|
+
isOccludingIndex(index: number): boolean;
|
|
3183
3837
|
setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3838
|
+
/** Recomputes section masks and returns changed per-block masks. Omit indices to visit every cell. */
|
|
3839
|
+
updateCullMasks(indices: Iterable<number> | undefined, occludes: (x: number, y: number, z: number) => boolean): [number, number][];
|
|
3840
|
+
/** Updates hidden faces for a cell's section entry or individual render object. */
|
|
3841
|
+
setCullMaskIndex(index: number, mask: number): Promise<void>;
|
|
3842
|
+
/** Rebuilds visible section geometry and discards results superseded by another rebuild or clear. */
|
|
3843
|
+
rebuildSectionMesh(): Promise<void>;
|
|
3844
|
+
/** Removes stored blocks and render objects. Set `notify` to false to skip the owning world's update. */
|
|
3845
|
+
clear(notify?: boolean): Promise<void>;
|
|
3187
3846
|
dispose(): Promise<void>;
|
|
3188
3847
|
static isAir(block: Maybe<Block>): boolean;
|
|
3189
3848
|
/** Maps chunk-local coordinates from 0 to 15 to a storage index, with x varying fastest, then z, then y. */
|
|
@@ -3200,7 +3859,9 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
3200
3859
|
declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
3201
3860
|
readonly scene: MineRenderScene;
|
|
3202
3861
|
private readonly _chunks;
|
|
3862
|
+
private readonly biomes;
|
|
3203
3863
|
private readonly sectionModels?;
|
|
3864
|
+
private readonly entities?;
|
|
3204
3865
|
private readonly pendingCulling;
|
|
3205
3866
|
private culling?;
|
|
3206
3867
|
constructor(scene: MineRenderScene, options?: MineRenderWorldOptions<SectionMeshing>);
|
|
@@ -3208,6 +3869,10 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
3208
3869
|
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
3209
3870
|
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
3210
3871
|
getBlockAt(pos: TripleArray): Maybe<BlockInfo<SectionMeshing>>;
|
|
3872
|
+
/** Returns the saved 4-block biome sample at integer world block coordinates, or `undefined` if absent. */
|
|
3873
|
+
getBiomeAt(x: number, y: number, z: number): Maybe<string>;
|
|
3874
|
+
getBiomeAt(pos: Vector3): Maybe<string>;
|
|
3875
|
+
getBiomeAt(pos: TripleArray): Maybe<string>;
|
|
3211
3876
|
/**
|
|
3212
3877
|
* Places or replaces a block and refreshes neighboring faces.
|
|
3213
3878
|
* Pass `undefined` or an air block to remove the block at these world block coordinates.
|
|
@@ -3225,22 +3890,24 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
3225
3890
|
setBlockVisibleAt(pos: TripleArray, visible: boolean): Promise<void>;
|
|
3226
3891
|
/**
|
|
3227
3892
|
* Places a structure's blocks at their stored positions, then refreshes neighboring faces.
|
|
3228
|
-
*
|
|
3893
|
+
* With `renderEntities`, also places supported saved mobs and applies supported appearance fields.
|
|
3229
3894
|
*
|
|
3230
|
-
* @param useBatches -
|
|
3895
|
+
* @param useBatches - Yields between chunks by default. Set to `false` for sequential placement.
|
|
3231
3896
|
* @param executor - Optional queue for batched placement. The caller remains responsible for stopping it.
|
|
3232
3897
|
*/
|
|
3233
3898
|
placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
|
|
3234
3899
|
private placeBlocks;
|
|
3235
|
-
|
|
3900
|
+
private placeChunkGroups;
|
|
3901
|
+
/** Replaces a chunk column's blocks and biome samples and, with `renderEntities`, its supported saved mobs. */
|
|
3236
3902
|
placeChunk(chunk: AnvilChunk, executor?: BatchedExecutor): Promise<void>;
|
|
3237
3903
|
/**
|
|
3238
|
-
* Removes
|
|
3904
|
+
* Removes blocks and owned entities at chunk-column coordinates, then refreshes neighboring faces and fluids.
|
|
3239
3905
|
* Coordinates match AnvilChunk.x/z, not block positions. Missing columns are ignored.
|
|
3240
3906
|
*/
|
|
3241
3907
|
unloadChunkColumn(x: number, z: number): Promise<void>;
|
|
3242
3908
|
private clearChunkColumn;
|
|
3243
|
-
|
|
3909
|
+
private markSectionChanged;
|
|
3910
|
+
/** Removes all chunks and releases their blocks, section meshes, and owned entities. */
|
|
3244
3911
|
clear(): Promise<void>;
|
|
3245
3912
|
private updateCulling;
|
|
3246
3913
|
private getOrCreateChunkAt;
|
|
@@ -3255,12 +3922,166 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
3255
3922
|
}
|
|
3256
3923
|
/** Settings passed as the second argument to `new MineRenderWorld(scene, options)`. */
|
|
3257
3924
|
interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
|
|
3925
|
+
/** Render supported saved mobs at their position and yaw, including supported appearance fields. Defaults to false. */
|
|
3926
|
+
renderEntities?: boolean;
|
|
3258
3927
|
/** Merge static opaque cubes into section meshes. Merged blocks have no individual object. */
|
|
3259
3928
|
sectionMeshing?: SectionMeshing;
|
|
3260
3929
|
/** Maximum width and height of each section atlas page, in pixels. */
|
|
3261
3930
|
maxAtlasSize?: number;
|
|
3262
3931
|
}
|
|
3263
3932
|
|
|
3933
|
+
/** Static model geometry as quads: four vertices per quad, in quad order. */
|
|
3934
|
+
interface SectionTemplateData {
|
|
3935
|
+
quads: number;
|
|
3936
|
+
positions: Float32Array;
|
|
3937
|
+
normals: Float32Array;
|
|
3938
|
+
uvs: Float32Array;
|
|
3939
|
+
uvBounds: Float32Array;
|
|
3940
|
+
colors: Float32Array;
|
|
3941
|
+
indices: Uint16Array;
|
|
3942
|
+
cullFaces: Uint8Array;
|
|
3943
|
+
atlas: number;
|
|
3944
|
+
layer: number;
|
|
3945
|
+
}
|
|
3946
|
+
/** The pixel dimensions and animation state of a source atlas. */
|
|
3947
|
+
interface SectionAtlasSize {
|
|
3948
|
+
width: number;
|
|
3949
|
+
height: number;
|
|
3950
|
+
animated: boolean;
|
|
3951
|
+
}
|
|
3952
|
+
/** One fluid kind's sprite rectangles in atlas pixels and its linear-light vertex tint. */
|
|
3953
|
+
interface SectionFluidKind {
|
|
3954
|
+
atlas: number;
|
|
3955
|
+
still: [x: number, y: number, width: number, height: number];
|
|
3956
|
+
flow: [x: number, y: number, width: number, height: number];
|
|
3957
|
+
tint: [r: number, g: number, b: number];
|
|
3958
|
+
}
|
|
3959
|
+
/** Fluid cells of the section plus a one-cell shell, 18×18×18, x fastest, then z, then y. */
|
|
3960
|
+
interface SectionFluidInput {
|
|
3961
|
+
/** Bit 128 marks a surface rendered elsewhere; the cell still supplies neighbor fluid samples. */
|
|
3962
|
+
cells: Uint8Array;
|
|
3963
|
+
/** Linear RGB per section cell, indexed by (x + 16z + 256y) * 3. Omission uses the water kind's tint. */
|
|
3964
|
+
waterTints?: Float32Array;
|
|
3965
|
+
water?: SectionFluidKind;
|
|
3966
|
+
lava?: SectionFluidKind;
|
|
3967
|
+
}
|
|
3968
|
+
/** Section placements and their shared templates, ready for geometry building. */
|
|
3969
|
+
interface SectionGeometryInput {
|
|
3970
|
+
count: number;
|
|
3971
|
+
indices: Uint16Array;
|
|
3972
|
+
templates: Uint16Array;
|
|
3973
|
+
cullMasks: Uint8Array;
|
|
3974
|
+
templateData: SectionTemplateData[];
|
|
3975
|
+
atlases: SectionAtlasSize[];
|
|
3976
|
+
maxAtlasSize: number;
|
|
3977
|
+
fluids?: SectionFluidInput;
|
|
3978
|
+
}
|
|
3979
|
+
/** Merged quads and source-atlas placements for one atlas page. */
|
|
3980
|
+
interface SectionGeometryPage {
|
|
3981
|
+
layer: number;
|
|
3982
|
+
width: number;
|
|
3983
|
+
height: number;
|
|
3984
|
+
placements: {
|
|
3985
|
+
atlas: number;
|
|
3986
|
+
x: number;
|
|
3987
|
+
y: number;
|
|
3988
|
+
}[];
|
|
3989
|
+
positions: Float32Array;
|
|
3990
|
+
normals: Float32Array;
|
|
3991
|
+
uvs: Float32Array;
|
|
3992
|
+
uvBounds: Float32Array;
|
|
3993
|
+
colors: Float32Array;
|
|
3994
|
+
indices: Uint32Array;
|
|
3995
|
+
}
|
|
3996
|
+
/** Builds section-local geometry from visible quads, with bounded atlas pages per layer. */
|
|
3997
|
+
declare function buildSectionGeometry(input: SectionGeometryInput): SectionGeometryPage[];
|
|
3998
|
+
/** Returns the buffers behind each page's typed arrays for transfer to another thread. */
|
|
3999
|
+
declare function sectionGeometryTransferables(pages: readonly SectionGeometryPage[]): ArrayBuffer[];
|
|
4000
|
+
|
|
4001
|
+
/** Runs section geometry builds in the environment's shared worker. */
|
|
4002
|
+
declare class SectionWorker {
|
|
4003
|
+
private worker;
|
|
4004
|
+
private static initialized;
|
|
4005
|
+
private static instance;
|
|
4006
|
+
private nextId;
|
|
4007
|
+
private readonly pending;
|
|
4008
|
+
private constructor();
|
|
4009
|
+
/** The shared worker, or undefined when the environment has none or a previous worker failed. */
|
|
4010
|
+
static shared(): SectionWorker | undefined;
|
|
4011
|
+
/** Builds geometry without transferring the input buffers away from the caller. */
|
|
4012
|
+
build(input: SectionGeometryInput): Promise<SectionGeometryPage[]>;
|
|
4013
|
+
/** Rejects pending builds, terminates the worker, and makes shared() return undefined. */
|
|
4014
|
+
terminate(): void;
|
|
4015
|
+
private fail;
|
|
4016
|
+
}
|
|
4017
|
+
|
|
4018
|
+
interface WorldStreamerOptions {
|
|
4019
|
+
/** Loads a square of chunk columns around the center. Integer from 0 to 32; defaults to 2. */
|
|
4020
|
+
loadRadius?: number;
|
|
4021
|
+
/** Retains loaded columns within this radius. Defaults to loadRadius + 1, capped at 32. */
|
|
4022
|
+
unloadRadius?: number;
|
|
4023
|
+
}
|
|
4024
|
+
/**
|
|
4025
|
+
* Loads nearby chunk columns in distance order and unloads distant columns.
|
|
4026
|
+
* Updates coalesce to the latest center and serialize world mutations. Use a dedicated world:
|
|
4027
|
+
* the streamer replaces columns it loads, and callers must await disposal before editing that world.
|
|
4028
|
+
* The source remains caller-owned. Lighting, biome tint, and LOD are not added by streaming.
|
|
4029
|
+
*/
|
|
4030
|
+
declare class WorldStreamer {
|
|
4031
|
+
private readonly world;
|
|
4032
|
+
private readonly source;
|
|
4033
|
+
private readonly loadRadius;
|
|
4034
|
+
private readonly unloadRadius;
|
|
4035
|
+
private readonly loaded;
|
|
4036
|
+
private readonly owned;
|
|
4037
|
+
private readonly missing;
|
|
4038
|
+
private readonly failed;
|
|
4039
|
+
private desired;
|
|
4040
|
+
private center?;
|
|
4041
|
+
private loading?;
|
|
4042
|
+
private running?;
|
|
4043
|
+
private disposal?;
|
|
4044
|
+
private disposed;
|
|
4045
|
+
constructor(world: Pick<MineRenderWorld<boolean>, "placeChunk" | "unloadChunkColumn">, source: WorldChunkSource, options?: WorldStreamerOptions);
|
|
4046
|
+
/** Returns absolute coordinates of successfully placed columns, including retained columns. */
|
|
4047
|
+
get loadedChunks(): readonly {
|
|
4048
|
+
x: number;
|
|
4049
|
+
z: number;
|
|
4050
|
+
}[];
|
|
4051
|
+
/** Returns source failures retained within the unload radius. Failed columns do not block other loads. */
|
|
4052
|
+
get failedChunks(): readonly {
|
|
4053
|
+
x: number;
|
|
4054
|
+
z: number;
|
|
4055
|
+
error: unknown;
|
|
4056
|
+
}[];
|
|
4057
|
+
/** Counts desired columns still waiting for a source read or placement, including the active column. */
|
|
4058
|
+
get pendingChunks(): number;
|
|
4059
|
+
/**
|
|
4060
|
+
* Updates the center in absolute chunk coordinates. Repeated calls share the active drain.
|
|
4061
|
+
* Source failures are recorded in failedChunks; other columns continue loading. Missing and failed
|
|
4062
|
+
* columns are remembered within the retention radius. Call retryFailedChunks to retry source failures.
|
|
4063
|
+
* Placement and unload failures reject the drain; call update again to retry those operations.
|
|
4064
|
+
* Reads outside the latest load radius receive an abort signal; placement finishes before unloading.
|
|
4065
|
+
* Sources should represent an unchanged world during streaming.
|
|
4066
|
+
*/
|
|
4067
|
+
update(x: number, z: number): Promise<void>;
|
|
4068
|
+
/** Updates from a camera or view-center position in scene units. One chunk spans 256 scene units. */
|
|
4069
|
+
updatePosition(position: {
|
|
4070
|
+
x: number;
|
|
4071
|
+
z: number;
|
|
4072
|
+
}): Promise<void>;
|
|
4073
|
+
/** Forgets recorded source failures and retries desired columns at the latest center. */
|
|
4074
|
+
retryFailedChunks(): Promise<void>;
|
|
4075
|
+
/** Aborts source reads, waits for active work, then unloads owned columns. The world and source remain caller-owned. */
|
|
4076
|
+
dispose(): Promise<void>;
|
|
4077
|
+
private drain;
|
|
4078
|
+
private needsLoad;
|
|
4079
|
+
private unload;
|
|
4080
|
+
private validateChunk;
|
|
4081
|
+
private within;
|
|
4082
|
+
private key;
|
|
4083
|
+
}
|
|
4084
|
+
|
|
3264
4085
|
/**
|
|
3265
4086
|
* {@link EnvProvider} for headless Node.
|
|
3266
4087
|
*
|
|
@@ -3300,4 +4121,38 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
|
|
|
3300
4121
|
forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
|
|
3301
4122
|
}
|
|
3302
4123
|
|
|
3303
|
-
|
|
4124
|
+
/** Renderer settings and logical image dimensions for {@link NodeRenderer.create}. */
|
|
4125
|
+
type NodeRendererOptions = DeepPartial<RendererOptions> & {
|
|
4126
|
+
width: number;
|
|
4127
|
+
height: number;
|
|
4128
|
+
};
|
|
4129
|
+
/** PNG export settings for {@link NodeRenderer.renderToBuffer}. */
|
|
4130
|
+
interface NodeImageOptions {
|
|
4131
|
+
/** Removes transparent borders. An empty image becomes one transparent pixel. */
|
|
4132
|
+
trim?: boolean;
|
|
4133
|
+
}
|
|
4134
|
+
/** Renders individual frames in Node using an injected or factory-owned WebGL 2 context. */
|
|
4135
|
+
declare class NodeRenderer extends Renderer {
|
|
4136
|
+
private destroyContext?;
|
|
4137
|
+
private nodeDisposed;
|
|
4138
|
+
/**
|
|
4139
|
+
* Uses a caller-owned surface; alpha-enabled contexts require `premultipliedAlpha: true`.
|
|
4140
|
+
* Disposal releases renderer resources but retains the canvas and context.
|
|
4141
|
+
*/
|
|
4142
|
+
constructor(options: DeepPartial<RendererOptions>, surface: RendererSurface);
|
|
4143
|
+
/**
|
|
4144
|
+
* Creates an owned native context through the optional `gl` package. Dimensions are in logical pixels.
|
|
4145
|
+
* Native antialiasing is unavailable; increase `render.pixelRatio` for a larger output image.
|
|
4146
|
+
*/
|
|
4147
|
+
static create(options: NodeRendererOptions): Promise<NodeRenderer>;
|
|
4148
|
+
/** Draws and returns a PNG with straight alpha, including while stopped. Frame callbacks are not invoked. */
|
|
4149
|
+
renderToBuffer(options?: NodeImageOptions): Promise<Buffer$1>;
|
|
4150
|
+
/** Node renderers draw on demand. Use {@link renderOnce} or {@link renderToBuffer}. */
|
|
4151
|
+
start(): never;
|
|
4152
|
+
/** Node image capture returns encoded bytes through {@link renderToBuffer}. */
|
|
4153
|
+
toImage(_trim?: boolean, _mime?: string, _quality?: number): never;
|
|
4154
|
+
/** Releases renderer resources and destroys contexts created by {@link create}. */
|
|
4155
|
+
dispose(): void;
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, 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 ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, 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 FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, 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, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, 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, type NodeImageOptions, NodeRenderer, type NodeRendererOptions, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
|