minerender 2.1.0-alpha.54 → 2.1.0-alpha.55

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.
@@ -807,6 +807,55 @@ type BlockStateProperties = {
807
807
  [key: string]: string;
808
808
  };
809
809
 
810
+ /** One model drawn by a block-entity renderer. */
811
+ interface BlockEntityPart {
812
+ model: string;
813
+ /** Model layer; defaults to "main". */
814
+ layer?: string;
815
+ /** Set only when the texture differs from the layer's default. */
816
+ textureLocation?: string;
817
+ /** Blockstate multipart syntax: every property must match, and "a|b" matches either value. */
818
+ when?: Record<string, string>;
819
+ }
820
+ /** Degrees per property value, or degrees per unit of a numeric property. */
821
+ type BlockEntityRotation = {
822
+ property: string;
823
+ degrees: Record<string, number>;
824
+ } | {
825
+ property: string;
826
+ step: number;
827
+ };
828
+ interface BlockEntityEntry {
829
+ parts: BlockEntityPart[];
830
+ rotation?: BlockEntityRotation;
831
+ /** Offset in model units, applied before the rotation. */
832
+ translation?: TripleArray;
833
+ }
834
+ /** The dataset's `blocks.json`: block ID to the models its block-entity renderer draws. */
835
+ type BlockEntityIndex = MinecraftAsset & {
836
+ [block: string]: BlockEntityEntry;
837
+ };
838
+ interface ResolvedBlockEntity {
839
+ parts: BlockEntityPart[];
840
+ /** Degrees counter-clockwise seen from above, about the block's vertical centre axis. */
841
+ rotation: number;
842
+ translation: TripleArray;
843
+ }
844
+ declare class BlockEntities {
845
+ /**
846
+ * Loads the block index of a version. Versions and sources without one yield an empty index, and so does
847
+ * a failed load: the index is optional, and blocks must not retry or fail with it one by one. The empty
848
+ * result is cached like any other; `Caching.clear()` or `AssetLoader.setVersion()` forces a new attempt.
849
+ */
850
+ static getIndex(root?: string): Promise<BlockEntityIndex>;
851
+ /** The index entry of a block ID such as `minecraft:chest`. */
852
+ static entry(index: BlockEntityIndex, block: string): Maybe<BlockEntityEntry>;
853
+ /** Selects the parts and placement for a block ID such as `minecraft:chest`; undefined when nothing is drawn. */
854
+ static resolve(index: BlockEntityIndex, block: string, state?: BlockStateProperties): Maybe<ResolvedBlockEntity>;
855
+ /** Placement in block space (0..16 per axis), applied on top of the model's own transform. */
856
+ static matrix(resolved: ResolvedBlockEntity, matrix?: Matrix4): Matrix4;
857
+ }
858
+
810
859
  declare class BlockStates {
811
860
  private static _persistentCache;
812
861
  private static get PERSISTENT_CACHE();
@@ -821,6 +870,44 @@ declare class DefaultBlockStates implements MinecraftAsset {
821
870
  [k: string]: BlockStatePropertyDefaults;
822
871
  }
823
872
 
873
+ /** `entity-models/animations/<namespace>/<model id>.json`: vanilla's keyframe animations of one model. */
874
+ interface EntityAnimationFile extends MinecraftAsset {
875
+ id: string;
876
+ animations: Record<string, EntityAnimation>;
877
+ }
878
+ interface EntityAnimation {
879
+ /** Seconds. */
880
+ length: number;
881
+ loop: boolean;
882
+ /** Part name anywhere in a layer; `root` is the layer's root part. */
883
+ bones: Record<string, EntityAnimationBone>;
884
+ }
885
+ type EntityAnimationChannel = "position" | "rotation" | "scale";
886
+ /** Keyframes in time order per channel. */
887
+ type EntityAnimationBone = Partial<Record<EntityAnimationChannel, EntityAnimationKeyframe[]>>;
888
+ interface EntityAnimationKeyframe {
889
+ /** Seconds. */
890
+ time: number;
891
+ /** Offset from the default pose: model units, radians, or scale minus one. */
892
+ value: TripleArray;
893
+ /** Value to arrive at when it differs from `value`; linear interpolation only. */
894
+ pre?: TripleArray;
895
+ /** Applies between the previous keyframe and this one. */
896
+ interpolation: "linear" | "catmullrom";
897
+ }
898
+ /** Sampled offsets from the default pose, per bone and channel. */
899
+ type EntityAnimationPose = Record<string, Partial<Record<EntityAnimationChannel, TripleArray>>>;
900
+ declare const ENTITY_ANIMATION_CHANNELS: readonly EntityAnimationChannel[];
901
+ /**
902
+ * Samples one channel like vanilla's `KeyframeAnimation.Entry`: the first value holds before the
903
+ * first keyframe and the last value after the last one; in between, the later keyframe selects the interpolation.
904
+ */
905
+ declare function sampleEntityKeyframes(keyframes: readonly EntityAnimationKeyframe[], time: number): TripleArray;
906
+ /** Elapsed seconds within the animation: modulo `length` when looping, as vanilla does. */
907
+ declare function entityAnimationTime(animation: EntityAnimation, time: number, loop?: boolean): number;
908
+ /** Samples every bone and channel of an animation at `time` seconds. */
909
+ declare function sampleEntityAnimation(animation: EntityAnimation, time: number, loop?: boolean): EntityAnimationPose;
910
+
824
911
  declare class Entities {
825
912
  static getEntityList(): Promise<string[]>;
826
913
  private static getModelFile;
@@ -828,6 +915,10 @@ declare class Entities {
828
915
  /** The dataset's extra draws on top of `main`; their `when` labels are the states `EntityModelOptions.when` can enable. */
829
916
  static getPassList(modelKey: BasicAssetKey): Promise<EntityModelPass[]>;
830
917
  static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
918
+ /**
919
+ * Vanilla's keyframe animations of a model by name, or undefined when the model or the selected version has none.
920
+ */
921
+ static getAnimations(modelKey: BasicAssetKey): Promise<Maybe<Record<string, EntityAnimation>>>;
831
922
  static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
832
923
  /** @deprecated Use getEntityList(); block entities share the entity dataset. */
833
924
  static getBlockList(): Promise<string[]>;
@@ -1047,6 +1138,41 @@ interface SkinObjectOptions extends SceneObjectOptions {
1047
1138
  legacy?: boolean;
1048
1139
  }
1049
1140
 
1141
+ interface EntityAnimationOptions {
1142
+ /** Overrides the animation's own `loop` flag. */
1143
+ loop?: boolean;
1144
+ /** Playback rate applied to advanced time; defaults to 1. */
1145
+ speed?: number;
1146
+ /** Start time in seconds; defaults to 0. */
1147
+ time?: number;
1148
+ }
1149
+ /**
1150
+ * Poses part groups from a keyframe animation the way vanilla does: every update restores the
1151
+ * default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.
1152
+ * It owns no timer; the owner advances it.
1153
+ */
1154
+ declare class EntityAnimationPlayer {
1155
+ private parts;
1156
+ private _animation?;
1157
+ private _time;
1158
+ private loop;
1159
+ private speed;
1160
+ get animation(): EntityAnimation | undefined;
1161
+ get time(): number;
1162
+ /**
1163
+ * Starts an animation on the named parts below each layer root. The current pose of a part becomes its default;
1164
+ * bones without a matching part are skipped.
1165
+ */
1166
+ play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions): void;
1167
+ /** Restores the default poses. Returns whether an animation was active. */
1168
+ stop(): boolean;
1169
+ /** Forgets the animation without touching the parts, for parts that no longer exist. */
1170
+ clear(): void;
1171
+ setTime(seconds: number): boolean;
1172
+ advance(deltaSeconds: number): boolean;
1173
+ private apply;
1174
+ }
1175
+
1050
1176
  declare class EntityObject extends SceneObject {
1051
1177
  readonly entity: EntityModel;
1052
1178
  readonly isEntityObject: true;
@@ -1058,6 +1184,7 @@ declare class EntityObject extends SceneObject {
1058
1184
  private scrollTicker;
1059
1185
  /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
1060
1186
  age: number;
1187
+ private readonly animationPlayer;
1061
1188
  constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
1062
1189
  init(): Promise<void>;
1063
1190
  dispose(): void;
@@ -1065,6 +1192,22 @@ declare class EntityObject extends SceneObject {
1065
1192
  private clearScrollMaterials;
1066
1193
  /** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
1067
1194
  private updateScroll;
1195
+ /** The animation started by {@link playAnimation}, until {@link stopAnimation} or disposal. */
1196
+ get animation(): Maybe<EntityAnimation>;
1197
+ /** Seconds since the animation started, before looping. */
1198
+ get animationTime(): number;
1199
+ /**
1200
+ * Poses the object from a keyframe animation of {@link Entities.getAnimations}, replacing the current one.
1201
+ * Parts of every layer are matched by name and their current pose is the default the offsets add to.
1202
+ * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1203
+ */
1204
+ playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1205
+ /** Stops the animation and restores the default pose. */
1206
+ stopAnimation(): void;
1207
+ /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
1208
+ setAnimationTime(seconds: number): void;
1209
+ /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
1210
+ advanceAnimation(deltaSeconds: number): void;
1068
1211
  getLayerGroup(name: string): Maybe<Object3D>;
1069
1212
  getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
1070
1213
  getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
@@ -1265,12 +1408,24 @@ declare class BlockObject extends SceneObject {
1265
1408
  private _fluidKey?;
1266
1409
  private _fluidSampler?;
1267
1410
  private _fluidModel?;
1411
+ private _entities;
1412
+ private _entityPlacement;
1413
+ private _entityGeneration;
1268
1414
  constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
1269
1415
  init(): Promise<void>;
1270
1416
  dispose(): void;
1271
1417
  removeFromScene(): void;
1272
1418
  private clearModels;
1273
1419
  private removeModels;
1420
+ private removeEntities;
1421
+ /** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
1422
+ get blockEntities(): readonly EntityObject[];
1423
+ /**
1424
+ * Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
1425
+ * when the block is not listed or one of its models cannot be loaded.
1426
+ */
1427
+ private createBlockEntities;
1428
+ private placeEntities;
1274
1429
  get isOccluding(): boolean;
1275
1430
  private getModelMatrix;
1276
1431
  private getModelCullMask;
@@ -1285,6 +1440,7 @@ declare class BlockObject extends SceneObject {
1285
1440
  nextInstance(): InstanceReference<SceneObject>;
1286
1441
  protected mapStateToVariant(state: BlockStateProperties): Promise<BlockStateVariant[]>;
1287
1442
  recreateModels(): Promise<void>;
1443
+ private hasGeometry;
1288
1444
  protected getSingleVariant(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
1289
1445
  protected createAVariant(variants: BlockStateVariant | BlockStateVariant[], instanceInfo: Matrix4[]): Promise<void>;
1290
1446
  protected createVariant(variant: BlockStateVariant): Promise<ModelObject | InstanceReference<ModelObject>>;
@@ -1586,6 +1742,8 @@ declare class Caching {
1586
1742
  static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
1587
1743
  static readonly entityModelCache: AsyncLoadingCache<CacheKey, EntityModelFile>;
1588
1744
  static readonly entityTextureCache: AsyncLoadingCache<CacheKey, AssetKey>;
1745
+ static readonly entityAnimationCache: AsyncLoadingCache<CacheKey, EntityAnimationFile>;
1746
+ static readonly blockEntityIndexCache: AsyncLoadingCache<CacheKey, BlockEntityIndex>;
1589
1747
  private static createAssetCache;
1590
1748
  /** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
1591
1749
  private static get all();
@@ -2183,4 +2341,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
2183
2341
  */
2184
2342
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
2185
2343
 
2186
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, 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, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiTextureLayer, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createImage, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
2344
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiTextureLayer, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
@@ -807,6 +807,55 @@ type BlockStateProperties = {
807
807
  [key: string]: string;
808
808
  };
809
809
 
810
+ /** One model drawn by a block-entity renderer. */
811
+ interface BlockEntityPart {
812
+ model: string;
813
+ /** Model layer; defaults to "main". */
814
+ layer?: string;
815
+ /** Set only when the texture differs from the layer's default. */
816
+ textureLocation?: string;
817
+ /** Blockstate multipart syntax: every property must match, and "a|b" matches either value. */
818
+ when?: Record<string, string>;
819
+ }
820
+ /** Degrees per property value, or degrees per unit of a numeric property. */
821
+ type BlockEntityRotation = {
822
+ property: string;
823
+ degrees: Record<string, number>;
824
+ } | {
825
+ property: string;
826
+ step: number;
827
+ };
828
+ interface BlockEntityEntry {
829
+ parts: BlockEntityPart[];
830
+ rotation?: BlockEntityRotation;
831
+ /** Offset in model units, applied before the rotation. */
832
+ translation?: TripleArray;
833
+ }
834
+ /** The dataset's `blocks.json`: block ID to the models its block-entity renderer draws. */
835
+ type BlockEntityIndex = MinecraftAsset & {
836
+ [block: string]: BlockEntityEntry;
837
+ };
838
+ interface ResolvedBlockEntity {
839
+ parts: BlockEntityPart[];
840
+ /** Degrees counter-clockwise seen from above, about the block's vertical centre axis. */
841
+ rotation: number;
842
+ translation: TripleArray;
843
+ }
844
+ declare class BlockEntities {
845
+ /**
846
+ * Loads the block index of a version. Versions and sources without one yield an empty index, and so does
847
+ * a failed load: the index is optional, and blocks must not retry or fail with it one by one. The empty
848
+ * result is cached like any other; `Caching.clear()` or `AssetLoader.setVersion()` forces a new attempt.
849
+ */
850
+ static getIndex(root?: string): Promise<BlockEntityIndex>;
851
+ /** The index entry of a block ID such as `minecraft:chest`. */
852
+ static entry(index: BlockEntityIndex, block: string): Maybe<BlockEntityEntry>;
853
+ /** Selects the parts and placement for a block ID such as `minecraft:chest`; undefined when nothing is drawn. */
854
+ static resolve(index: BlockEntityIndex, block: string, state?: BlockStateProperties): Maybe<ResolvedBlockEntity>;
855
+ /** Placement in block space (0..16 per axis), applied on top of the model's own transform. */
856
+ static matrix(resolved: ResolvedBlockEntity, matrix?: Matrix4): Matrix4;
857
+ }
858
+
810
859
  declare class BlockStates {
811
860
  private static _persistentCache;
812
861
  private static get PERSISTENT_CACHE();
@@ -821,6 +870,44 @@ declare class DefaultBlockStates implements MinecraftAsset {
821
870
  [k: string]: BlockStatePropertyDefaults;
822
871
  }
823
872
 
873
+ /** `entity-models/animations/<namespace>/<model id>.json`: vanilla's keyframe animations of one model. */
874
+ interface EntityAnimationFile extends MinecraftAsset {
875
+ id: string;
876
+ animations: Record<string, EntityAnimation>;
877
+ }
878
+ interface EntityAnimation {
879
+ /** Seconds. */
880
+ length: number;
881
+ loop: boolean;
882
+ /** Part name anywhere in a layer; `root` is the layer's root part. */
883
+ bones: Record<string, EntityAnimationBone>;
884
+ }
885
+ type EntityAnimationChannel = "position" | "rotation" | "scale";
886
+ /** Keyframes in time order per channel. */
887
+ type EntityAnimationBone = Partial<Record<EntityAnimationChannel, EntityAnimationKeyframe[]>>;
888
+ interface EntityAnimationKeyframe {
889
+ /** Seconds. */
890
+ time: number;
891
+ /** Offset from the default pose: model units, radians, or scale minus one. */
892
+ value: TripleArray;
893
+ /** Value to arrive at when it differs from `value`; linear interpolation only. */
894
+ pre?: TripleArray;
895
+ /** Applies between the previous keyframe and this one. */
896
+ interpolation: "linear" | "catmullrom";
897
+ }
898
+ /** Sampled offsets from the default pose, per bone and channel. */
899
+ type EntityAnimationPose = Record<string, Partial<Record<EntityAnimationChannel, TripleArray>>>;
900
+ declare const ENTITY_ANIMATION_CHANNELS: readonly EntityAnimationChannel[];
901
+ /**
902
+ * Samples one channel like vanilla's `KeyframeAnimation.Entry`: the first value holds before the
903
+ * first keyframe and the last value after the last one; in between, the later keyframe selects the interpolation.
904
+ */
905
+ declare function sampleEntityKeyframes(keyframes: readonly EntityAnimationKeyframe[], time: number): TripleArray;
906
+ /** Elapsed seconds within the animation: modulo `length` when looping, as vanilla does. */
907
+ declare function entityAnimationTime(animation: EntityAnimation, time: number, loop?: boolean): number;
908
+ /** Samples every bone and channel of an animation at `time` seconds. */
909
+ declare function sampleEntityAnimation(animation: EntityAnimation, time: number, loop?: boolean): EntityAnimationPose;
910
+
824
911
  declare class Entities {
825
912
  static getEntityList(): Promise<string[]>;
826
913
  private static getModelFile;
@@ -828,6 +915,10 @@ declare class Entities {
828
915
  /** The dataset's extra draws on top of `main`; their `when` labels are the states `EntityModelOptions.when` can enable. */
829
916
  static getPassList(modelKey: BasicAssetKey): Promise<EntityModelPass[]>;
830
917
  static getEntity(modelKey: BasicAssetKey, textureKey?: BasicAssetKey, options?: EntityModelOptions): Promise<Maybe<EntityModel>>;
918
+ /**
919
+ * Vanilla's keyframe animations of a model by name, or undefined when the model or the selected version has none.
920
+ */
921
+ static getAnimations(modelKey: BasicAssetKey): Promise<Maybe<Record<string, EntityAnimation>>>;
831
922
  static resolveTexture(modelKey: BasicAssetKey): Promise<Maybe<AssetKey>>;
832
923
  /** @deprecated Use getEntityList(); block entities share the entity dataset. */
833
924
  static getBlockList(): Promise<string[]>;
@@ -1047,6 +1138,41 @@ interface SkinObjectOptions extends SceneObjectOptions {
1047
1138
  legacy?: boolean;
1048
1139
  }
1049
1140
 
1141
+ interface EntityAnimationOptions {
1142
+ /** Overrides the animation's own `loop` flag. */
1143
+ loop?: boolean;
1144
+ /** Playback rate applied to advanced time; defaults to 1. */
1145
+ speed?: number;
1146
+ /** Start time in seconds; defaults to 0. */
1147
+ time?: number;
1148
+ }
1149
+ /**
1150
+ * Poses part groups from a keyframe animation the way vanilla does: every update restores the
1151
+ * default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.
1152
+ * It owns no timer; the owner advances it.
1153
+ */
1154
+ declare class EntityAnimationPlayer {
1155
+ private parts;
1156
+ private _animation?;
1157
+ private _time;
1158
+ private loop;
1159
+ private speed;
1160
+ get animation(): EntityAnimation | undefined;
1161
+ get time(): number;
1162
+ /**
1163
+ * Starts an animation on the named parts below each layer root. The current pose of a part becomes its default;
1164
+ * bones without a matching part are skipped.
1165
+ */
1166
+ play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions): void;
1167
+ /** Restores the default poses. Returns whether an animation was active. */
1168
+ stop(): boolean;
1169
+ /** Forgets the animation without touching the parts, for parts that no longer exist. */
1170
+ clear(): void;
1171
+ setTime(seconds: number): boolean;
1172
+ advance(deltaSeconds: number): boolean;
1173
+ private apply;
1174
+ }
1175
+
1050
1176
  declare class EntityObject extends SceneObject {
1051
1177
  readonly entity: EntityModel;
1052
1178
  readonly isEntityObject: true;
@@ -1058,6 +1184,7 @@ declare class EntityObject extends SceneObject {
1058
1184
  private scrollTicker;
1059
1185
  /** Entity age in ticks, as vanilla's `ageInTicks`; drives the scrolling render modes. */
1060
1186
  age: number;
1187
+ private readonly animationPlayer;
1061
1188
  constructor(entity: EntityModel, options?: Partial<EntityObjectOptions>);
1062
1189
  init(): Promise<void>;
1063
1190
  dispose(): void;
@@ -1065,6 +1192,22 @@ declare class EntityObject extends SceneObject {
1065
1192
  private clearScrollMaterials;
1066
1193
  /** Applies the entity age to the scrolling materials; the ticker calls this 20 times per second. */
1067
1194
  private updateScroll;
1195
+ /** The animation started by {@link playAnimation}, until {@link stopAnimation} or disposal. */
1196
+ get animation(): Maybe<EntityAnimation>;
1197
+ /** Seconds since the animation started, before looping. */
1198
+ get animationTime(): number;
1199
+ /**
1200
+ * Poses the object from a keyframe animation of {@link Entities.getAnimations}, replacing the current one.
1201
+ * Parts of every layer are matched by name and their current pose is the default the offsets add to.
1202
+ * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1203
+ */
1204
+ playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1205
+ /** Stops the animation and restores the default pose. */
1206
+ stopAnimation(): void;
1207
+ /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
1208
+ setAnimationTime(seconds: number): void;
1209
+ /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
1210
+ advanceAnimation(deltaSeconds: number): void;
1068
1211
  getLayerGroup(name: string): Maybe<Object3D>;
1069
1212
  getGroupByName(name: string, layerName?: string): Maybe<Object3D>;
1070
1213
  getMeshByName(name: string, layerName?: string): Maybe<Mesh>;
@@ -1265,12 +1408,24 @@ declare class BlockObject extends SceneObject {
1265
1408
  private _fluidKey?;
1266
1409
  private _fluidSampler?;
1267
1410
  private _fluidModel?;
1411
+ private _entities;
1412
+ private _entityPlacement;
1413
+ private _entityGeneration;
1268
1414
  constructor(blockState: BlockState, options?: Partial<BlockObjectOptions>);
1269
1415
  init(): Promise<void>;
1270
1416
  dispose(): void;
1271
1417
  removeFromScene(): void;
1272
1418
  private clearModels;
1273
1419
  private removeModels;
1420
+ private removeEntities;
1421
+ /** Entity models drawn for this block instead of its block model; they are scene children, unlike the block. */
1422
+ get blockEntities(): readonly EntityObject[];
1423
+ /**
1424
+ * Draws the block through the dataset's block-entity index. Returns false, leaving nothing behind,
1425
+ * when the block is not listed or one of its models cannot be loaded.
1426
+ */
1427
+ private createBlockEntities;
1428
+ private placeEntities;
1274
1429
  get isOccluding(): boolean;
1275
1430
  private getModelMatrix;
1276
1431
  private getModelCullMask;
@@ -1285,6 +1440,7 @@ declare class BlockObject extends SceneObject {
1285
1440
  nextInstance(): InstanceReference<SceneObject>;
1286
1441
  protected mapStateToVariant(state: BlockStateProperties): Promise<BlockStateVariant[]>;
1287
1442
  recreateModels(): Promise<void>;
1443
+ private hasGeometry;
1288
1444
  protected getSingleVariant(variants: BlockStateVariant | BlockStateVariant[]): BlockStateVariant;
1289
1445
  protected createAVariant(variants: BlockStateVariant | BlockStateVariant[], instanceInfo: Matrix4[]): Promise<void>;
1290
1446
  protected createVariant(variant: BlockStateVariant): Promise<ModelObject | InstanceReference<ModelObject>>;
@@ -1586,6 +1742,8 @@ declare class Caching {
1586
1742
  static readonly blockTintCache: AsyncLoadingCache<CacheKey, number>;
1587
1743
  static readonly entityModelCache: AsyncLoadingCache<CacheKey, EntityModelFile>;
1588
1744
  static readonly entityTextureCache: AsyncLoadingCache<CacheKey, AssetKey>;
1745
+ static readonly entityAnimationCache: AsyncLoadingCache<CacheKey, EntityAnimationFile>;
1746
+ static readonly blockEntityIndexCache: AsyncLoadingCache<CacheKey, BlockEntityIndex>;
1589
1747
  private static createAssetCache;
1590
1748
  /** Every cache above, so clear()/end() can never fall out of sync with the field list again. */
1591
1749
  private static get all();
@@ -2183,4 +2341,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
2183
2341
  */
2184
2342
  declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
2185
2343
 
2186
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, 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, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type ElementFace, type ElementRotation, Entities, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiTextureLayer, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createImage, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
2344
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, type FrameCallback, type FromTo, Geometries, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiTextureLayer, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelTextures, type ListAsset, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, OrbitControls, PersistentCache, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, SceneExporter, type SceneGLTFExportOptions, SceneInspector, SceneObject, type SceneObjectOptions, SceneStats, SceneStatsDisplay, SchematicParser, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, prefix, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };