minerender 2.1.0-alpha.86 → 2.1.0-alpha.88
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/dist/browser/index.d.mts +194 -3
- package/dist/browser/index.d.ts +194 -3
- package/dist/browser/index.js +806 -184
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +806 -185
- package/dist/browser/index.mjs.map +1 -1
- package/dist/browser/section.worker.js +119 -0
- package/dist/browser/section.worker.js.map +1 -0
- package/dist/browser/section.worker.mjs +119 -0
- package/dist/browser/section.worker.mjs.map +1 -0
- package/dist/bundle.js +826 -187
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +193 -3
- package/dist/node/index.d.ts +193 -3
- package/dist/node/index.js +804 -184
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +798 -184
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.mts
CHANGED
|
@@ -105,6 +105,8 @@ interface EnvProvider {
|
|
|
105
105
|
/** Read width/height out of encoded image bytes without fully decoding them. */
|
|
106
106
|
imageSize(data: Uint8Array): ImageSizeInfo;
|
|
107
107
|
openCache(name: string, version: number): PersistentCache;
|
|
108
|
+
/** Optional worker support; returns undefined where unavailable. Only the browser ESM build ships worker files. */
|
|
109
|
+
createWorker?(name: "section"): Worker | undefined;
|
|
108
110
|
}
|
|
109
111
|
/**
|
|
110
112
|
* Registry holding the active {@link EnvProvider}.
|
|
@@ -766,6 +768,8 @@ declare function toRadians(degrees: number): number;
|
|
|
766
768
|
declare function toDegrees(radians: number): number;
|
|
767
769
|
/** Resolves after a delay in milliseconds. */
|
|
768
770
|
declare function sleep(timeout: number): Promise<void>;
|
|
771
|
+
/** Yields to the next macrotask without timer clamping when the platform supports it. */
|
|
772
|
+
declare function yieldToEventLoop(): Promise<void>;
|
|
769
773
|
/** Reduces an angle modulo 360, retaining a negative sign for negative inputs. */
|
|
770
774
|
declare function clampRotationDegrees(deg: number): number;
|
|
771
775
|
declare function isVector3(obj: any): obj is Vector3;
|
|
@@ -3111,6 +3115,8 @@ declare class ChunkData {
|
|
|
3111
3115
|
set(index: number, block?: Block): void;
|
|
3112
3116
|
clear(): void;
|
|
3113
3117
|
static isAir(block: Maybe<Block>): boolean;
|
|
3118
|
+
/** Identifies a normalized block type and its sorted properties, excluding per-cell NBT. */
|
|
3119
|
+
static paletteKey(block: Block): string;
|
|
3114
3120
|
private static copyBlock;
|
|
3115
3121
|
private static validateIndex;
|
|
3116
3122
|
}
|
|
@@ -3156,6 +3162,41 @@ declare class AnvilParser {
|
|
|
3156
3162
|
private static unpack;
|
|
3157
3163
|
}
|
|
3158
3164
|
|
|
3165
|
+
/** Loads chunk columns at absolute integer chunk coordinates. */
|
|
3166
|
+
interface WorldChunkSource {
|
|
3167
|
+
/** Returns the requested column, or `undefined` if absent. Honor signal to cancel discarded reads. */
|
|
3168
|
+
getChunk(x: number, z: number, signal?: AbortSignal): Promise<AnvilChunk | undefined>;
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
/**
|
|
3172
|
+
* Reads `r.<x>.<z>.mca` at integer region coordinates, or returns `undefined` when absent.
|
|
3173
|
+
* Forward `signal` to file or network I/O; it aborts when every caller waiting for the region cancels.
|
|
3174
|
+
*/
|
|
3175
|
+
type AnvilRegionReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
|
|
3176
|
+
/** Cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
|
|
3177
|
+
interface AnvilWorldSourceOptions {
|
|
3178
|
+
/** Maximum cached regions, including missing regions. Defaults to 4; 0 disables caching. */
|
|
3179
|
+
maxCachedRegions?: number;
|
|
3180
|
+
/** Maximum retained region bytes. Defaults to 64 MiB; larger regions are read without caching. */
|
|
3181
|
+
maxCachedBytes?: number;
|
|
3182
|
+
}
|
|
3183
|
+
/** Reads selected Java Anvil chunk columns and caches raw regions within count and byte limits. */
|
|
3184
|
+
declare class AnvilWorldSource implements WorldChunkSource {
|
|
3185
|
+
private readonly readRegion;
|
|
3186
|
+
private readonly regions;
|
|
3187
|
+
private readonly pending;
|
|
3188
|
+
private readonly maxCachedRegions;
|
|
3189
|
+
private readonly maxCachedBytes;
|
|
3190
|
+
private cachedBytes;
|
|
3191
|
+
constructor(readRegion: AnvilRegionReader, options?: AnvilWorldSourceOptions);
|
|
3192
|
+
/** Decodes one column at absolute chunk coordinates. Aborting a caller leaves other shared readers active. */
|
|
3193
|
+
getChunk(x: number, z: number, signal?: AbortSignal): Promise<AnvilChunk | undefined>;
|
|
3194
|
+
/** Releases cached regions. Reads already in progress finish without repopulating this cache. */
|
|
3195
|
+
clearCache(): void;
|
|
3196
|
+
private getRegion;
|
|
3197
|
+
private cacheRegion;
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3159
3200
|
/** A placed block's data snapshot and optional render object, returned by world and chunk accessors. */
|
|
3160
3201
|
interface BlockInfo<SectionMeshing extends boolean = false> {
|
|
3161
3202
|
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
@@ -3181,6 +3222,9 @@ declare class SectionMesh extends Group {
|
|
|
3181
3222
|
private readonly ownedMeshes;
|
|
3182
3223
|
/** Builds section-local meshes from visible cube faces. `maxAtlasSize` limits each atlas dimension in pixels. */
|
|
3183
3224
|
static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
|
|
3225
|
+
/** Builds section-local meshes in a browser worker when available, with synchronous fallback. */
|
|
3226
|
+
static buildAsync(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): Promise<SectionMesh>;
|
|
3227
|
+
private static fromPages;
|
|
3184
3228
|
dispose(): void;
|
|
3185
3229
|
}
|
|
3186
3230
|
|
|
@@ -3214,8 +3258,10 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
3214
3258
|
private readonly renderedBlocks;
|
|
3215
3259
|
private readonly sectionBlocks;
|
|
3216
3260
|
private readonly hiddenBlocks;
|
|
3261
|
+
private readonly blockPosition;
|
|
3217
3262
|
private sectionMesh?;
|
|
3218
3263
|
private meshDirty;
|
|
3264
|
+
private meshGeneration;
|
|
3219
3265
|
constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
|
|
3220
3266
|
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
3221
3267
|
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
@@ -3230,12 +3276,24 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
3230
3276
|
* Places a block at integer chunk-local coordinates from 0 to 15.
|
|
3231
3277
|
*/
|
|
3232
3278
|
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
3279
|
+
/** Places cells in input order and returns changed world positions without refreshing neighbors. */
|
|
3280
|
+
placeBlocks(blocks: readonly {
|
|
3281
|
+
index: number;
|
|
3282
|
+
block: Maybe<Block>;
|
|
3283
|
+
}[]): Promise<Vector3[]>;
|
|
3233
3284
|
/** Changes visibility at world block coordinates while preserving the block's data. */
|
|
3234
3285
|
setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
|
|
3235
3286
|
isBlockVisibleAt(pos: Vector3): boolean;
|
|
3287
|
+
/** Reports whether a cell has a visible render object or section entry. */
|
|
3288
|
+
isBlockVisibleIndex(index: number): boolean;
|
|
3236
3289
|
isOccludingAt(pos: Vector3): boolean;
|
|
3290
|
+
/** Reports whether a visible cell hides neighboring cube faces. */
|
|
3291
|
+
isOccludingIndex(index: number): boolean;
|
|
3237
3292
|
setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
|
|
3238
|
-
|
|
3293
|
+
/** Updates hidden faces for a cell's section entry or individual render object. */
|
|
3294
|
+
setCullMaskIndex(index: number, mask: number): Promise<void>;
|
|
3295
|
+
/** Rebuilds visible section geometry and discards results superseded by another rebuild or clear. */
|
|
3296
|
+
rebuildSectionMesh(): Promise<void>;
|
|
3239
3297
|
/** Removes stored blocks and their render objects, then notifies the owning world of changed positions. */
|
|
3240
3298
|
clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
|
|
3241
3299
|
dispose(): Promise<void>;
|
|
@@ -3281,11 +3339,12 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
3281
3339
|
* Places a structure's blocks at their stored positions, then refreshes neighboring faces.
|
|
3282
3340
|
* Entity NBT is retained by the structure but is not rendered.
|
|
3283
3341
|
*
|
|
3284
|
-
* @param useBatches -
|
|
3342
|
+
* @param useBatches - Yields between chunks by default. Set to `false` for sequential placement.
|
|
3285
3343
|
* @param executor - Optional queue for batched placement. The caller remains responsible for stopping it.
|
|
3286
3344
|
*/
|
|
3287
3345
|
placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
|
|
3288
3346
|
private placeBlocks;
|
|
3347
|
+
private placeChunkGroups;
|
|
3289
3348
|
/** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
|
|
3290
3349
|
placeChunk(chunk: AnvilChunk, executor?: BatchedExecutor): Promise<void>;
|
|
3291
3350
|
/**
|
|
@@ -3315,6 +3374,137 @@ interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
|
|
|
3315
3374
|
maxAtlasSize?: number;
|
|
3316
3375
|
}
|
|
3317
3376
|
|
|
3377
|
+
/** One cube template with four vertices per face in `CUBE_FACES` order. */
|
|
3378
|
+
interface SectionTemplateData {
|
|
3379
|
+
positions: Float32Array;
|
|
3380
|
+
normals: Float32Array;
|
|
3381
|
+
uvs: Float32Array;
|
|
3382
|
+
uvBounds: Float32Array;
|
|
3383
|
+
colors: Float32Array;
|
|
3384
|
+
indices: Uint16Array;
|
|
3385
|
+
cullFaces: Uint8Array;
|
|
3386
|
+
atlas: number;
|
|
3387
|
+
}
|
|
3388
|
+
/** The pixel dimensions of a template atlas. */
|
|
3389
|
+
interface SectionAtlasSize {
|
|
3390
|
+
width: number;
|
|
3391
|
+
height: number;
|
|
3392
|
+
}
|
|
3393
|
+
/** Section placements and their shared cube templates, ready for geometry building. */
|
|
3394
|
+
interface SectionGeometryInput {
|
|
3395
|
+
count: number;
|
|
3396
|
+
indices: Uint16Array;
|
|
3397
|
+
templates: Uint16Array;
|
|
3398
|
+
cullMasks: Uint8Array;
|
|
3399
|
+
templateData: SectionTemplateData[];
|
|
3400
|
+
atlases: SectionAtlasSize[];
|
|
3401
|
+
maxAtlasSize: number;
|
|
3402
|
+
}
|
|
3403
|
+
/** Merged cube faces and source-atlas placements for one atlas page. */
|
|
3404
|
+
interface SectionGeometryPage {
|
|
3405
|
+
width: number;
|
|
3406
|
+
height: number;
|
|
3407
|
+
placements: {
|
|
3408
|
+
atlas: number;
|
|
3409
|
+
x: number;
|
|
3410
|
+
y: number;
|
|
3411
|
+
}[];
|
|
3412
|
+
positions: Float32Array;
|
|
3413
|
+
normals: Float32Array;
|
|
3414
|
+
uvs: Float32Array;
|
|
3415
|
+
uvBounds: Float32Array;
|
|
3416
|
+
colors: Float32Array;
|
|
3417
|
+
indices: Uint32Array;
|
|
3418
|
+
}
|
|
3419
|
+
/** Builds section-local geometry from visible cube faces, with bounded atlas pages. */
|
|
3420
|
+
declare function buildSectionGeometry(input: SectionGeometryInput): SectionGeometryPage[];
|
|
3421
|
+
/** Returns the buffers behind each page's typed arrays for transfer to another thread. */
|
|
3422
|
+
declare function sectionGeometryTransferables(pages: readonly SectionGeometryPage[]): ArrayBuffer[];
|
|
3423
|
+
|
|
3424
|
+
/** Runs section geometry builds in the environment's shared worker. */
|
|
3425
|
+
declare class SectionWorker {
|
|
3426
|
+
private worker;
|
|
3427
|
+
private static initialized;
|
|
3428
|
+
private static instance;
|
|
3429
|
+
private nextId;
|
|
3430
|
+
private readonly pending;
|
|
3431
|
+
private constructor();
|
|
3432
|
+
/** The shared worker, or undefined when the environment has none or a previous worker failed. */
|
|
3433
|
+
static shared(): SectionWorker | undefined;
|
|
3434
|
+
/** Builds geometry without transferring the input buffers away from the caller. */
|
|
3435
|
+
build(input: SectionGeometryInput): Promise<SectionGeometryPage[]>;
|
|
3436
|
+
/** Rejects pending builds, terminates the worker, and makes shared() return undefined. */
|
|
3437
|
+
terminate(): void;
|
|
3438
|
+
private fail;
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3441
|
+
interface WorldStreamerOptions {
|
|
3442
|
+
/** Loads a square of chunk columns around the center. Integer from 0 to 32; defaults to 2. */
|
|
3443
|
+
loadRadius?: number;
|
|
3444
|
+
/** Retains loaded columns within this radius. Defaults to loadRadius + 1, capped at 32. */
|
|
3445
|
+
unloadRadius?: number;
|
|
3446
|
+
}
|
|
3447
|
+
/**
|
|
3448
|
+
* Loads nearby chunk columns in distance order and unloads distant columns.
|
|
3449
|
+
* Updates coalesce to the latest center and serialize world mutations. Use a dedicated world:
|
|
3450
|
+
* the streamer replaces columns it loads, and callers must await disposal before editing that world.
|
|
3451
|
+
* The source remains caller-owned. Lighting, biome tint, and LOD are not added by streaming.
|
|
3452
|
+
*/
|
|
3453
|
+
declare class WorldStreamer {
|
|
3454
|
+
private readonly world;
|
|
3455
|
+
private readonly source;
|
|
3456
|
+
private readonly loadRadius;
|
|
3457
|
+
private readonly unloadRadius;
|
|
3458
|
+
private readonly loaded;
|
|
3459
|
+
private readonly owned;
|
|
3460
|
+
private readonly missing;
|
|
3461
|
+
private readonly failed;
|
|
3462
|
+
private desired;
|
|
3463
|
+
private center?;
|
|
3464
|
+
private loading?;
|
|
3465
|
+
private running?;
|
|
3466
|
+
private disposal?;
|
|
3467
|
+
private disposed;
|
|
3468
|
+
constructor(world: Pick<MineRenderWorld<boolean>, "placeChunk" | "unloadChunkColumn">, source: WorldChunkSource, options?: WorldStreamerOptions);
|
|
3469
|
+
/** Returns absolute coordinates of successfully placed columns, including retained columns. */
|
|
3470
|
+
get loadedChunks(): readonly {
|
|
3471
|
+
x: number;
|
|
3472
|
+
z: number;
|
|
3473
|
+
}[];
|
|
3474
|
+
/** Returns source failures retained within the unload radius. Failed columns do not block other loads. */
|
|
3475
|
+
get failedChunks(): readonly {
|
|
3476
|
+
x: number;
|
|
3477
|
+
z: number;
|
|
3478
|
+
error: unknown;
|
|
3479
|
+
}[];
|
|
3480
|
+
/** Counts desired columns still waiting for a source read or placement, including the active column. */
|
|
3481
|
+
get pendingChunks(): number;
|
|
3482
|
+
/**
|
|
3483
|
+
* Updates the center in absolute chunk coordinates. Repeated calls share the active drain.
|
|
3484
|
+
* Source failures are recorded in failedChunks; other columns continue loading. Missing and failed
|
|
3485
|
+
* columns are remembered within the retention radius. Call retryFailedChunks to retry source failures.
|
|
3486
|
+
* Placement and unload failures reject the drain; call update again to retry those operations.
|
|
3487
|
+
* Reads outside the latest load radius receive an abort signal; placement finishes before unloading.
|
|
3488
|
+
* Sources should represent an unchanged world during streaming.
|
|
3489
|
+
*/
|
|
3490
|
+
update(x: number, z: number): Promise<void>;
|
|
3491
|
+
/** Updates from a camera or view-center position in scene units. One chunk spans 256 scene units. */
|
|
3492
|
+
updatePosition(position: {
|
|
3493
|
+
x: number;
|
|
3494
|
+
z: number;
|
|
3495
|
+
}): Promise<void>;
|
|
3496
|
+
/** Forgets recorded source failures and retries desired columns at the latest center. */
|
|
3497
|
+
retryFailedChunks(): Promise<void>;
|
|
3498
|
+
/** Aborts source reads, waits for active work, then unloads owned columns. The world and source remain caller-owned. */
|
|
3499
|
+
dispose(): Promise<void>;
|
|
3500
|
+
private drain;
|
|
3501
|
+
private needsLoad;
|
|
3502
|
+
private unload;
|
|
3503
|
+
private validateChunk;
|
|
3504
|
+
private within;
|
|
3505
|
+
private key;
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3318
3508
|
/**
|
|
3319
3509
|
* {@link EnvProvider} backed by the DOM. Uses nothing outside of standard browser APIs and
|
|
3320
3510
|
* localforage, so it stays free of Node polyfills.
|
|
@@ -3325,6 +3515,7 @@ declare class BrowserEnv implements EnvProvider {
|
|
|
3325
3515
|
createImage(width?: number, height?: number): CompatImage;
|
|
3326
3516
|
imageSize(data: Uint8Array): ImageSizeInfo;
|
|
3327
3517
|
openCache(name: string, version: number): PersistentCache;
|
|
3518
|
+
createWorker(name: "section"): Worker | undefined;
|
|
3328
3519
|
}
|
|
3329
3520
|
/** Installs the browser provider. The browser package entry calls this automatically. */
|
|
3330
3521
|
declare function registerBrowserEnv(): BrowserEnv;
|
|
@@ -3352,4 +3543,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
3352
3543
|
*/
|
|
3353
3544
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
3354
3545
|
|
|
3355
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, 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 FluidSample, type FluidSampler, 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, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
|
|
3546
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, 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 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, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, 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 FluidSample, type FluidSampler, 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, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, 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, 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, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -105,6 +105,8 @@ interface EnvProvider {
|
|
|
105
105
|
/** Read width/height out of encoded image bytes without fully decoding them. */
|
|
106
106
|
imageSize(data: Uint8Array): ImageSizeInfo;
|
|
107
107
|
openCache(name: string, version: number): PersistentCache;
|
|
108
|
+
/** Optional worker support; returns undefined where unavailable. Only the browser ESM build ships worker files. */
|
|
109
|
+
createWorker?(name: "section"): Worker | undefined;
|
|
108
110
|
}
|
|
109
111
|
/**
|
|
110
112
|
* Registry holding the active {@link EnvProvider}.
|
|
@@ -766,6 +768,8 @@ declare function toRadians(degrees: number): number;
|
|
|
766
768
|
declare function toDegrees(radians: number): number;
|
|
767
769
|
/** Resolves after a delay in milliseconds. */
|
|
768
770
|
declare function sleep(timeout: number): Promise<void>;
|
|
771
|
+
/** Yields to the next macrotask without timer clamping when the platform supports it. */
|
|
772
|
+
declare function yieldToEventLoop(): Promise<void>;
|
|
769
773
|
/** Reduces an angle modulo 360, retaining a negative sign for negative inputs. */
|
|
770
774
|
declare function clampRotationDegrees(deg: number): number;
|
|
771
775
|
declare function isVector3(obj: any): obj is Vector3;
|
|
@@ -3111,6 +3115,8 @@ declare class ChunkData {
|
|
|
3111
3115
|
set(index: number, block?: Block): void;
|
|
3112
3116
|
clear(): void;
|
|
3113
3117
|
static isAir(block: Maybe<Block>): boolean;
|
|
3118
|
+
/** Identifies a normalized block type and its sorted properties, excluding per-cell NBT. */
|
|
3119
|
+
static paletteKey(block: Block): string;
|
|
3114
3120
|
private static copyBlock;
|
|
3115
3121
|
private static validateIndex;
|
|
3116
3122
|
}
|
|
@@ -3156,6 +3162,41 @@ declare class AnvilParser {
|
|
|
3156
3162
|
private static unpack;
|
|
3157
3163
|
}
|
|
3158
3164
|
|
|
3165
|
+
/** Loads chunk columns at absolute integer chunk coordinates. */
|
|
3166
|
+
interface WorldChunkSource {
|
|
3167
|
+
/** Returns the requested column, or `undefined` if absent. Honor signal to cancel discarded reads. */
|
|
3168
|
+
getChunk(x: number, z: number, signal?: AbortSignal): Promise<AnvilChunk | undefined>;
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3171
|
+
/**
|
|
3172
|
+
* Reads `r.<x>.<z>.mca` at integer region coordinates, or returns `undefined` when absent.
|
|
3173
|
+
* Forward `signal` to file or network I/O; it aborts when every caller waiting for the region cancels.
|
|
3174
|
+
*/
|
|
3175
|
+
type AnvilRegionReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
|
|
3176
|
+
/** Cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
|
|
3177
|
+
interface AnvilWorldSourceOptions {
|
|
3178
|
+
/** Maximum cached regions, including missing regions. Defaults to 4; 0 disables caching. */
|
|
3179
|
+
maxCachedRegions?: number;
|
|
3180
|
+
/** Maximum retained region bytes. Defaults to 64 MiB; larger regions are read without caching. */
|
|
3181
|
+
maxCachedBytes?: number;
|
|
3182
|
+
}
|
|
3183
|
+
/** Reads selected Java Anvil chunk columns and caches raw regions within count and byte limits. */
|
|
3184
|
+
declare class AnvilWorldSource implements WorldChunkSource {
|
|
3185
|
+
private readonly readRegion;
|
|
3186
|
+
private readonly regions;
|
|
3187
|
+
private readonly pending;
|
|
3188
|
+
private readonly maxCachedRegions;
|
|
3189
|
+
private readonly maxCachedBytes;
|
|
3190
|
+
private cachedBytes;
|
|
3191
|
+
constructor(readRegion: AnvilRegionReader, options?: AnvilWorldSourceOptions);
|
|
3192
|
+
/** Decodes one column at absolute chunk coordinates. Aborting a caller leaves other shared readers active. */
|
|
3193
|
+
getChunk(x: number, z: number, signal?: AbortSignal): Promise<AnvilChunk | undefined>;
|
|
3194
|
+
/** Releases cached regions. Reads already in progress finish without repopulating this cache. */
|
|
3195
|
+
clearCache(): void;
|
|
3196
|
+
private getRegion;
|
|
3197
|
+
private cacheRegion;
|
|
3198
|
+
}
|
|
3199
|
+
|
|
3159
3200
|
/** A placed block's data snapshot and optional render object, returned by world and chunk accessors. */
|
|
3160
3201
|
interface BlockInfo<SectionMeshing extends boolean = false> {
|
|
3161
3202
|
/** Detached block data; use world or chunk setters to update stored blocks. */
|
|
@@ -3181,6 +3222,9 @@ declare class SectionMesh extends Group {
|
|
|
3181
3222
|
private readonly ownedMeshes;
|
|
3182
3223
|
/** Builds section-local meshes from visible cube faces. `maxAtlasSize` limits each atlas dimension in pixels. */
|
|
3183
3224
|
static build(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): SectionMesh;
|
|
3225
|
+
/** Builds section-local meshes in a browser worker when available, with synchronous fallback. */
|
|
3226
|
+
static buildAsync(entries: readonly SectionMeshEntry[], maxAtlasSize?: number): Promise<SectionMesh>;
|
|
3227
|
+
private static fromPages;
|
|
3184
3228
|
dispose(): void;
|
|
3185
3229
|
}
|
|
3186
3230
|
|
|
@@ -3214,8 +3258,10 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
3214
3258
|
private readonly renderedBlocks;
|
|
3215
3259
|
private readonly sectionBlocks;
|
|
3216
3260
|
private readonly hiddenBlocks;
|
|
3261
|
+
private readonly blockPosition;
|
|
3217
3262
|
private sectionMesh?;
|
|
3218
3263
|
private meshDirty;
|
|
3264
|
+
private meshGeneration;
|
|
3219
3265
|
constructor(scene: MineRenderScene, x: number, y: number, z: number, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined, sectionModels?: SectionModels | undefined);
|
|
3220
3266
|
getBlockAt(x: number, y: number, z: number): Maybe<BlockInfo<SectionMeshing>>;
|
|
3221
3267
|
getBlockAt(pos: Vector3): Maybe<BlockInfo<SectionMeshing>>;
|
|
@@ -3230,12 +3276,24 @@ declare class Chunk<SectionMeshing extends boolean = false> {
|
|
|
3230
3276
|
* Places a block at integer chunk-local coordinates from 0 to 15.
|
|
3231
3277
|
*/
|
|
3232
3278
|
setBlockInChunkAt(pos: Vector3, block?: Block, worldPos?: Vector3, onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<Maybe<BlockInfo<SectionMeshing>>>;
|
|
3279
|
+
/** Places cells in input order and returns changed world positions without refreshing neighbors. */
|
|
3280
|
+
placeBlocks(blocks: readonly {
|
|
3281
|
+
index: number;
|
|
3282
|
+
block: Maybe<Block>;
|
|
3283
|
+
}[]): Promise<Vector3[]>;
|
|
3233
3284
|
/** Changes visibility at world block coordinates while preserving the block's data. */
|
|
3234
3285
|
setBlockVisibleAt(pos: Vector3, visible: boolean): Promise<void>;
|
|
3235
3286
|
isBlockVisibleAt(pos: Vector3): boolean;
|
|
3287
|
+
/** Reports whether a cell has a visible render object or section entry. */
|
|
3288
|
+
isBlockVisibleIndex(index: number): boolean;
|
|
3236
3289
|
isOccludingAt(pos: Vector3): boolean;
|
|
3290
|
+
/** Reports whether a visible cell hides neighboring cube faces. */
|
|
3291
|
+
isOccludingIndex(index: number): boolean;
|
|
3237
3292
|
setCullMaskAt(pos: Vector3, mask: number): Promise<void>;
|
|
3238
|
-
|
|
3293
|
+
/** Updates hidden faces for a cell's section entry or individual render object. */
|
|
3294
|
+
setCullMaskIndex(index: number, mask: number): Promise<void>;
|
|
3295
|
+
/** Rebuilds visible section geometry and discards results superseded by another rebuild or clear. */
|
|
3296
|
+
rebuildSectionMesh(): Promise<void>;
|
|
3239
3297
|
/** Removes stored blocks and their render objects, then notifies the owning world of changed positions. */
|
|
3240
3298
|
clear(onBlocksChanged?: ((positions: Vector3[]) => Promise<void>) | undefined): Promise<void>;
|
|
3241
3299
|
dispose(): Promise<void>;
|
|
@@ -3281,11 +3339,12 @@ declare class MineRenderWorld<SectionMeshing extends boolean = false> {
|
|
|
3281
3339
|
* Places a structure's blocks at their stored positions, then refreshes neighboring faces.
|
|
3282
3340
|
* Entity NBT is retained by the structure but is not rendered.
|
|
3283
3341
|
*
|
|
3284
|
-
* @param useBatches -
|
|
3342
|
+
* @param useBatches - Yields between chunks by default. Set to `false` for sequential placement.
|
|
3285
3343
|
* @param executor - Optional queue for batched placement. The caller remains responsible for stopping it.
|
|
3286
3344
|
*/
|
|
3287
3345
|
placeMultiBlock(multiblock: MultiBlockStructure, useBatches?: boolean, executor?: BatchedExecutor): Promise<void>;
|
|
3288
3346
|
private placeBlocks;
|
|
3347
|
+
private placeChunkGroups;
|
|
3289
3348
|
/** Replaces one chunk column's blocks. Entity NBT remains available on the parsed chunk. */
|
|
3290
3349
|
placeChunk(chunk: AnvilChunk, executor?: BatchedExecutor): Promise<void>;
|
|
3291
3350
|
/**
|
|
@@ -3315,6 +3374,137 @@ interface MineRenderWorldOptions<SectionMeshing extends boolean = boolean> {
|
|
|
3315
3374
|
maxAtlasSize?: number;
|
|
3316
3375
|
}
|
|
3317
3376
|
|
|
3377
|
+
/** One cube template with four vertices per face in `CUBE_FACES` order. */
|
|
3378
|
+
interface SectionTemplateData {
|
|
3379
|
+
positions: Float32Array;
|
|
3380
|
+
normals: Float32Array;
|
|
3381
|
+
uvs: Float32Array;
|
|
3382
|
+
uvBounds: Float32Array;
|
|
3383
|
+
colors: Float32Array;
|
|
3384
|
+
indices: Uint16Array;
|
|
3385
|
+
cullFaces: Uint8Array;
|
|
3386
|
+
atlas: number;
|
|
3387
|
+
}
|
|
3388
|
+
/** The pixel dimensions of a template atlas. */
|
|
3389
|
+
interface SectionAtlasSize {
|
|
3390
|
+
width: number;
|
|
3391
|
+
height: number;
|
|
3392
|
+
}
|
|
3393
|
+
/** Section placements and their shared cube templates, ready for geometry building. */
|
|
3394
|
+
interface SectionGeometryInput {
|
|
3395
|
+
count: number;
|
|
3396
|
+
indices: Uint16Array;
|
|
3397
|
+
templates: Uint16Array;
|
|
3398
|
+
cullMasks: Uint8Array;
|
|
3399
|
+
templateData: SectionTemplateData[];
|
|
3400
|
+
atlases: SectionAtlasSize[];
|
|
3401
|
+
maxAtlasSize: number;
|
|
3402
|
+
}
|
|
3403
|
+
/** Merged cube faces and source-atlas placements for one atlas page. */
|
|
3404
|
+
interface SectionGeometryPage {
|
|
3405
|
+
width: number;
|
|
3406
|
+
height: number;
|
|
3407
|
+
placements: {
|
|
3408
|
+
atlas: number;
|
|
3409
|
+
x: number;
|
|
3410
|
+
y: number;
|
|
3411
|
+
}[];
|
|
3412
|
+
positions: Float32Array;
|
|
3413
|
+
normals: Float32Array;
|
|
3414
|
+
uvs: Float32Array;
|
|
3415
|
+
uvBounds: Float32Array;
|
|
3416
|
+
colors: Float32Array;
|
|
3417
|
+
indices: Uint32Array;
|
|
3418
|
+
}
|
|
3419
|
+
/** Builds section-local geometry from visible cube faces, with bounded atlas pages. */
|
|
3420
|
+
declare function buildSectionGeometry(input: SectionGeometryInput): SectionGeometryPage[];
|
|
3421
|
+
/** Returns the buffers behind each page's typed arrays for transfer to another thread. */
|
|
3422
|
+
declare function sectionGeometryTransferables(pages: readonly SectionGeometryPage[]): ArrayBuffer[];
|
|
3423
|
+
|
|
3424
|
+
/** Runs section geometry builds in the environment's shared worker. */
|
|
3425
|
+
declare class SectionWorker {
|
|
3426
|
+
private worker;
|
|
3427
|
+
private static initialized;
|
|
3428
|
+
private static instance;
|
|
3429
|
+
private nextId;
|
|
3430
|
+
private readonly pending;
|
|
3431
|
+
private constructor();
|
|
3432
|
+
/** The shared worker, or undefined when the environment has none or a previous worker failed. */
|
|
3433
|
+
static shared(): SectionWorker | undefined;
|
|
3434
|
+
/** Builds geometry without transferring the input buffers away from the caller. */
|
|
3435
|
+
build(input: SectionGeometryInput): Promise<SectionGeometryPage[]>;
|
|
3436
|
+
/** Rejects pending builds, terminates the worker, and makes shared() return undefined. */
|
|
3437
|
+
terminate(): void;
|
|
3438
|
+
private fail;
|
|
3439
|
+
}
|
|
3440
|
+
|
|
3441
|
+
interface WorldStreamerOptions {
|
|
3442
|
+
/** Loads a square of chunk columns around the center. Integer from 0 to 32; defaults to 2. */
|
|
3443
|
+
loadRadius?: number;
|
|
3444
|
+
/** Retains loaded columns within this radius. Defaults to loadRadius + 1, capped at 32. */
|
|
3445
|
+
unloadRadius?: number;
|
|
3446
|
+
}
|
|
3447
|
+
/**
|
|
3448
|
+
* Loads nearby chunk columns in distance order and unloads distant columns.
|
|
3449
|
+
* Updates coalesce to the latest center and serialize world mutations. Use a dedicated world:
|
|
3450
|
+
* the streamer replaces columns it loads, and callers must await disposal before editing that world.
|
|
3451
|
+
* The source remains caller-owned. Lighting, biome tint, and LOD are not added by streaming.
|
|
3452
|
+
*/
|
|
3453
|
+
declare class WorldStreamer {
|
|
3454
|
+
private readonly world;
|
|
3455
|
+
private readonly source;
|
|
3456
|
+
private readonly loadRadius;
|
|
3457
|
+
private readonly unloadRadius;
|
|
3458
|
+
private readonly loaded;
|
|
3459
|
+
private readonly owned;
|
|
3460
|
+
private readonly missing;
|
|
3461
|
+
private readonly failed;
|
|
3462
|
+
private desired;
|
|
3463
|
+
private center?;
|
|
3464
|
+
private loading?;
|
|
3465
|
+
private running?;
|
|
3466
|
+
private disposal?;
|
|
3467
|
+
private disposed;
|
|
3468
|
+
constructor(world: Pick<MineRenderWorld<boolean>, "placeChunk" | "unloadChunkColumn">, source: WorldChunkSource, options?: WorldStreamerOptions);
|
|
3469
|
+
/** Returns absolute coordinates of successfully placed columns, including retained columns. */
|
|
3470
|
+
get loadedChunks(): readonly {
|
|
3471
|
+
x: number;
|
|
3472
|
+
z: number;
|
|
3473
|
+
}[];
|
|
3474
|
+
/** Returns source failures retained within the unload radius. Failed columns do not block other loads. */
|
|
3475
|
+
get failedChunks(): readonly {
|
|
3476
|
+
x: number;
|
|
3477
|
+
z: number;
|
|
3478
|
+
error: unknown;
|
|
3479
|
+
}[];
|
|
3480
|
+
/** Counts desired columns still waiting for a source read or placement, including the active column. */
|
|
3481
|
+
get pendingChunks(): number;
|
|
3482
|
+
/**
|
|
3483
|
+
* Updates the center in absolute chunk coordinates. Repeated calls share the active drain.
|
|
3484
|
+
* Source failures are recorded in failedChunks; other columns continue loading. Missing and failed
|
|
3485
|
+
* columns are remembered within the retention radius. Call retryFailedChunks to retry source failures.
|
|
3486
|
+
* Placement and unload failures reject the drain; call update again to retry those operations.
|
|
3487
|
+
* Reads outside the latest load radius receive an abort signal; placement finishes before unloading.
|
|
3488
|
+
* Sources should represent an unchanged world during streaming.
|
|
3489
|
+
*/
|
|
3490
|
+
update(x: number, z: number): Promise<void>;
|
|
3491
|
+
/** Updates from a camera or view-center position in scene units. One chunk spans 256 scene units. */
|
|
3492
|
+
updatePosition(position: {
|
|
3493
|
+
x: number;
|
|
3494
|
+
z: number;
|
|
3495
|
+
}): Promise<void>;
|
|
3496
|
+
/** Forgets recorded source failures and retries desired columns at the latest center. */
|
|
3497
|
+
retryFailedChunks(): Promise<void>;
|
|
3498
|
+
/** Aborts source reads, waits for active work, then unloads owned columns. The world and source remain caller-owned. */
|
|
3499
|
+
dispose(): Promise<void>;
|
|
3500
|
+
private drain;
|
|
3501
|
+
private needsLoad;
|
|
3502
|
+
private unload;
|
|
3503
|
+
private validateChunk;
|
|
3504
|
+
private within;
|
|
3505
|
+
private key;
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3318
3508
|
/**
|
|
3319
3509
|
* {@link EnvProvider} backed by the DOM. Uses nothing outside of standard browser APIs and
|
|
3320
3510
|
* localforage, so it stays free of Node polyfills.
|
|
@@ -3325,6 +3515,7 @@ declare class BrowserEnv implements EnvProvider {
|
|
|
3325
3515
|
createImage(width?: number, height?: number): CompatImage;
|
|
3326
3516
|
imageSize(data: Uint8Array): ImageSizeInfo;
|
|
3327
3517
|
openCache(name: string, version: number): PersistentCache;
|
|
3518
|
+
createWorker(name: "section"): Worker | undefined;
|
|
3328
3519
|
}
|
|
3329
3520
|
/** Installs the browser provider. The browser package entry calls this automatically. */
|
|
3330
3521
|
declare function registerBrowserEnv(): BrowserEnv;
|
|
@@ -3352,4 +3543,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
3352
3543
|
*/
|
|
3353
3544
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
3354
3545
|
|
|
3355
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, 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 FluidSample, type FluidSampler, 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, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
|
|
3546
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, 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 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, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, 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 FluidSample, type FluidSampler, 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, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, 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, 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, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
|