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