minerender 2.1.0-alpha.130 → 2.1.0-alpha.132

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.
@@ -1578,25 +1578,35 @@ interface EntityAnimationOptions {
1578
1578
  speed?: number;
1579
1579
  /** Start time in seconds; defaults to 0. */
1580
1580
  time?: number;
1581
+ /** Nonnegative finite weights in clip order; defaults to 1 per clip. Offsets add without normalizing weights. */
1582
+ weights?: readonly number[];
1581
1583
  }
1582
1584
  /**
1583
- * Poses part groups from a keyframe animation the way vanilla does: every update restores the
1584
- * default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.
1585
+ * Poses part groups from keyframe animations: every update restores the default pose of each
1586
+ * animated part, then adds weighted sampled offsets to its position, Euler angles and scale.
1585
1587
  * It owns no timer; the owner advances it.
1586
1588
  */
1587
1589
  declare class EntityAnimationPlayer {
1588
1590
  private parts;
1589
- private _animation?;
1591
+ private _animations;
1592
+ private _weights;
1593
+ private loops;
1590
1594
  private _time;
1591
- private loop;
1592
1595
  private speed;
1593
1596
  get animation(): EntityAnimation | undefined;
1597
+ get animations(): readonly EntityAnimation[];
1598
+ get weights(): readonly number[];
1594
1599
  get time(): number;
1595
1600
  /**
1596
1601
  * Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
1597
1602
  * without them, the current pose is used. Stopping restores the pose from before playback.
1598
1603
  */
1599
1604
  play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
1605
+ /**
1606
+ * Starts clips on matching parts with a shared clock. Weighted offsets add to the supplied baked poses
1607
+ * or, without poses, to each animated part's pose when playback starts.
1608
+ */
1609
+ playAnimations(layers: Object3D[], animations: readonly EntityAnimation[], options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
1600
1610
  /** Restores the poses from before playback. Returns whether an animation was active. */
1601
1611
  stop(): boolean;
1602
1612
  /** Forgets the animation without touching the parts, for parts that no longer exist. */
@@ -1605,8 +1615,12 @@ declare class EntityAnimationPlayer {
1605
1615
  setTime(seconds: number): boolean;
1606
1616
  /** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */
1607
1617
  advance(deltaSeconds: number): boolean;
1618
+ /** Changes weights in clip order and reapplies the current time without restarting playback. */
1619
+ setWeights(weights: readonly number[]): boolean;
1608
1620
  private apply;
1609
1621
  }
1622
+ /** @internal */
1623
+ declare function validateAnimationWeights(weights: readonly number[], count: number): number[];
1610
1624
 
1611
1625
  /** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */
1612
1626
  declare class EntityObject extends SceneObject {
@@ -1635,8 +1649,10 @@ declare class EntityObject extends SceneObject {
1635
1649
  private updateScroll;
1636
1650
  /** The first active clip, until playback is stopped or the object is disposed. */
1637
1651
  get animation(): Maybe<EntityAnimation>;
1638
- /** Clips playing together, each targeting a separate geometry layer. */
1652
+ /** Clips playing together, in the order passed to {@link playAnimations}. */
1639
1653
  get activeAnimations(): readonly EntityAnimation[];
1654
+ /** Weights of the active clips, in the same order as {@link activeAnimations}. */
1655
+ get animationWeights(): readonly number[];
1640
1656
  /** Seconds since the animation started, before looping. */
1641
1657
  get animationTime(): number;
1642
1658
  /**
@@ -1646,8 +1662,13 @@ declare class EntityObject extends SceneObject {
1646
1662
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1647
1663
  */
1648
1664
  playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1649
- /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
1665
+ /**
1666
+ * Plays clips with a shared clock, adding their weighted offsets within each geometry layer.
1667
+ * Weights default to 1 and are not normalized. Selected layers without their own clip follow `main`.
1668
+ */
1650
1669
  playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
1670
+ /** Changes weights in active clip order, notifying the scene without restarting the shared clock. Has no effect without an animation. */
1671
+ setAnimationWeights(weights: readonly number[]): void;
1651
1672
  /** Stops all clips and restores the poses from before playback. */
1652
1673
  stopAnimation(): void;
1653
1674
  /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
@@ -4376,4 +4397,4 @@ declare class NodeRenderer extends Renderer {
4376
4397
  dispose(): void;
4377
4398
  }
4378
4399
 
4379
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, type NodeImageOptions, NodeRenderer, type NodeRendererOptions, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenameKind, Renames, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, type WorldEntityIntersection, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
4400
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, type NodeImageOptions, NodeRenderer, type NodeRendererOptions, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenameKind, Renames, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, type WorldEntityIntersection, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, validateAnimationWeights, yieldToEventLoop };
@@ -1578,25 +1578,35 @@ interface EntityAnimationOptions {
1578
1578
  speed?: number;
1579
1579
  /** Start time in seconds; defaults to 0. */
1580
1580
  time?: number;
1581
+ /** Nonnegative finite weights in clip order; defaults to 1 per clip. Offsets add without normalizing weights. */
1582
+ weights?: readonly number[];
1581
1583
  }
1582
1584
  /**
1583
- * Poses part groups from a keyframe animation the way vanilla does: every update restores the
1584
- * default pose of each animated part, then adds the sampled offsets to its position, Euler angles and scale.
1585
+ * Poses part groups from keyframe animations: every update restores the default pose of each
1586
+ * animated part, then adds weighted sampled offsets to its position, Euler angles and scale.
1585
1587
  * It owns no timer; the owner advances it.
1586
1588
  */
1587
1589
  declare class EntityAnimationPlayer {
1588
1590
  private parts;
1589
- private _animation?;
1591
+ private _animations;
1592
+ private _weights;
1593
+ private loops;
1590
1594
  private _time;
1591
- private loop;
1592
1595
  private speed;
1593
1596
  get animation(): EntityAnimation | undefined;
1597
+ get animations(): readonly EntityAnimation[];
1598
+ get weights(): readonly number[];
1594
1599
  get time(): number;
1595
1600
  /**
1596
1601
  * Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
1597
1602
  * without them, the current pose is used. Stopping restores the pose from before playback.
1598
1603
  */
1599
1604
  play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
1605
+ /**
1606
+ * Starts clips on matching parts with a shared clock. Weighted offsets add to the supplied baked poses
1607
+ * or, without poses, to each animated part's pose when playback starts.
1608
+ */
1609
+ playAnimations(layers: Object3D[], animations: readonly EntityAnimation[], options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
1600
1610
  /** Restores the poses from before playback. Returns whether an animation was active. */
1601
1611
  stop(): boolean;
1602
1612
  /** Forgets the animation without touching the parts, for parts that no longer exist. */
@@ -1605,8 +1615,12 @@ declare class EntityAnimationPlayer {
1605
1615
  setTime(seconds: number): boolean;
1606
1616
  /** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */
1607
1617
  advance(deltaSeconds: number): boolean;
1618
+ /** Changes weights in clip order and reapplies the current time without restarting playback. */
1619
+ setWeights(weights: readonly number[]): boolean;
1608
1620
  private apply;
1609
1621
  }
1622
+ /** @internal */
1623
+ declare function validateAnimationWeights(weights: readonly number[], count: number): number[];
1610
1624
 
1611
1625
  /** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */
1612
1626
  declare class EntityObject extends SceneObject {
@@ -1635,8 +1649,10 @@ declare class EntityObject extends SceneObject {
1635
1649
  private updateScroll;
1636
1650
  /** The first active clip, until playback is stopped or the object is disposed. */
1637
1651
  get animation(): Maybe<EntityAnimation>;
1638
- /** Clips playing together, each targeting a separate geometry layer. */
1652
+ /** Clips playing together, in the order passed to {@link playAnimations}. */
1639
1653
  get activeAnimations(): readonly EntityAnimation[];
1654
+ /** Weights of the active clips, in the same order as {@link activeAnimations}. */
1655
+ get animationWeights(): readonly number[];
1640
1656
  /** Seconds since the animation started, before looping. */
1641
1657
  get animationTime(): number;
1642
1658
  /**
@@ -1646,8 +1662,13 @@ declare class EntityObject extends SceneObject {
1646
1662
  * The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
1647
1663
  */
1648
1664
  playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
1649
- /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
1665
+ /**
1666
+ * Plays clips with a shared clock, adding their weighted offsets within each geometry layer.
1667
+ * Weights default to 1 and are not normalized. Selected layers without their own clip follow `main`.
1668
+ */
1650
1669
  playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
1670
+ /** Changes weights in active clip order, notifying the scene without restarting the shared clock. Has no effect without an animation. */
1671
+ setAnimationWeights(weights: readonly number[]): void;
1651
1672
  /** Stops all clips and restores the poses from before playback. */
1652
1673
  stopAnimation(): void;
1653
1674
  /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
@@ -4376,4 +4397,4 @@ declare class NodeRenderer extends Renderer {
4376
4397
  dispose(): void;
4377
4398
  }
4378
4399
 
4379
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, type NodeImageOptions, NodeRenderer, type NodeRendererOptions, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenameKind, Renames, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, type WorldEntityIntersection, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
4400
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilEntityChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type Biome, type BiomeColorKind, Biomes, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsMode, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DecoratedPotSide, DecoratedPots, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidQuads, type FluidRules, type FluidSample, type FluidSampler, type FlyAction, FlyControls, type FlyControlsEventMap, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, ItemDefaults, ItemGlint, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderData, type MineRenderDataManifest, type MineRenderDatasets, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, type NodeImageOptions, NodeRenderer, type NodeRendererOptions, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, PlayerHeadTextures, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenameKind, Renames, type RenderOptions, Renderer, type RendererControls, type RendererFrame, type RendererOptions, type RendererSurface, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResolvedMineRenderData, type ResponseParser, SCENE_DOCUMENT_MAX_BYTES, SKIN_PARTS, type SavedLightSample, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneItemContext, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionFluidInput, type SectionFluidKind, type SectionFluids, type SectionGeometryInput, type SectionGeometryPage, type SectionLightData, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldBlockIntersection, type WorldChunkSource, type WorldEntityIntersection, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildFluidQuads, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, copySectionLight, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, decodeSceneDocument, encodeSceneDocument, entityAnimationTime, estimateBytesUsed, fluidKindOf, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isFlyControls, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isResourceLocation, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, resolveBlockFluidState, resolveLegacyBlock, resolveLegacyBlockState, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sampleSectionLight, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, validateAnimationWeights, yieldToEventLoop };
@@ -2691,13 +2691,13 @@ function applyElementRotation(rotation, geometry) {
2691
2691
  break;
2692
2692
  }
2693
2693
  if (rotation.rescale) {
2694
- if (Math.abs(rotation.angle) === 22.5) {
2695
- const s = 1 / Math.cos(0.39269909262657166);
2696
- geometry.scale(s, 1, s);
2697
- } else {
2698
- const s = 1 / Math.cos(0.7853981852531433);
2699
- geometry.scale(s, 1, s);
2700
- }
2694
+ const angle = toRadians(rotation.angle);
2695
+ const s = 1 / Math.max(Math.abs(Math.cos(angle)), Math.abs(Math.sin(angle)));
2696
+ geometry.scale(
2697
+ rotation.axis === "x" /* X */ ? 1 : s,
2698
+ rotation.axis === "y" /* Y */ ? 1 : s,
2699
+ rotation.axis === "z" /* Z */ ? 1 : s
2700
+ );
2701
2701
  }
2702
2702
  geometry.translate(origin.x, origin.y, origin.z);
2703
2703
  }
@@ -5005,6 +5005,13 @@ var init_EntityAnimation = __esm({
5005
5005
  });
5006
5006
 
5007
5007
  // src/entity/scene/EntityAnimationPlayer.ts
5008
+ function validateAnimationWeights(weights, count) {
5009
+ const values = Array.from(weights);
5010
+ if (values.length !== count || values.some((weight) => !Number.isFinite(weight) || weight < 0)) {
5011
+ throw new Error("Animation weights must match the clip count and contain only finite nonnegative numbers");
5012
+ }
5013
+ return values;
5014
+ }
5008
5015
  var import_three11, ZERO, EntityAnimationPlayer;
5009
5016
  var init_EntityAnimationPlayer = __esm({
5010
5017
  "src/entity/scene/EntityAnimationPlayer.ts"() {
@@ -5014,12 +5021,20 @@ var init_EntityAnimationPlayer = __esm({
5014
5021
  EntityAnimationPlayer = class {
5015
5022
  constructor() {
5016
5023
  this.parts = [];
5024
+ this._animations = [];
5025
+ this._weights = [];
5026
+ this.loops = [];
5017
5027
  this._time = 0;
5018
- this.loop = false;
5019
5028
  this.speed = 1;
5020
5029
  }
5021
5030
  get animation() {
5022
- return this._animation;
5031
+ return this._animations[0];
5032
+ }
5033
+ get animations() {
5034
+ return this._animations.slice();
5035
+ }
5036
+ get weights() {
5037
+ return this._weights.slice();
5023
5038
  }
5024
5039
  get time() {
5025
5040
  return this._time;
@@ -5029,10 +5044,20 @@ var init_EntityAnimationPlayer = __esm({
5029
5044
  * without them, the current pose is used. Stopping restores the pose from before playback.
5030
5045
  */
5031
5046
  play(layers, animation, options = {}, poses) {
5047
+ this.playAnimations(layers, [animation], options, poses);
5048
+ }
5049
+ /**
5050
+ * Starts clips on matching parts with a shared clock. Weighted offsets add to the supplied baked poses
5051
+ * or, without poses, to each animated part's pose when playback starts.
5052
+ */
5053
+ playAnimations(layers, animations, options = {}, poses) {
5054
+ const weights = validateAnimationWeights(options.weights ?? animations.map(() => 1), animations.length);
5032
5055
  this.stop();
5033
- this._animation = animation;
5056
+ this._animations = animations.slice();
5057
+ this._weights = weights;
5058
+ if (!animations.length) return;
5034
5059
  this._time = options.time ?? 0;
5035
- this.loop = options.loop ?? animation.loop;
5060
+ this.loops = animations.map((animation) => options.loop ?? animation.loop);
5036
5061
  this.speed = options.speed ?? 1;
5037
5062
  for (const layer of layers) {
5038
5063
  const objects = [];
@@ -5041,7 +5066,8 @@ var init_EntityAnimationPlayer = __esm({
5041
5066
  if (poses.has(object4)) objects.push(object4);
5042
5067
  });
5043
5068
  } else {
5044
- for (const bone of Object.keys(animation.bones)) {
5069
+ const bones = new Set(animations.flatMap((animation) => Object.keys(animation.bones)));
5070
+ for (const bone of bones) {
5045
5071
  const object4 = layer.getObjectByName(`group:${bone}`);
5046
5072
  if (object4) objects.push(object4);
5047
5073
  }
@@ -5065,7 +5091,7 @@ var init_EntityAnimationPlayer = __esm({
5065
5091
  }
5066
5092
  /** Restores the poses from before playback. Returns whether an animation was active. */
5067
5093
  stop() {
5068
- if (!this._animation) return false;
5094
+ if (!this._animations.length) return false;
5069
5095
  for (const part of this.parts) {
5070
5096
  part.object.position.copy(part.position);
5071
5097
  part.object.rotation.copy(part.rotation);
@@ -5077,12 +5103,14 @@ var init_EntityAnimationPlayer = __esm({
5077
5103
  /** Forgets the animation without touching the parts, for parts that no longer exist. */
5078
5104
  clear() {
5079
5105
  this.parts = [];
5080
- this._animation = void 0;
5106
+ this._animations = [];
5107
+ this._weights = [];
5108
+ this.loops = [];
5081
5109
  this._time = 0;
5082
5110
  }
5083
5111
  /** Applies the pose at an absolute playback time. Returns `false` when no clip is active. */
5084
5112
  setTime(seconds) {
5085
- if (!this._animation) return false;
5113
+ if (!this._animations.length) return false;
5086
5114
  this._time = seconds;
5087
5115
  this.apply();
5088
5116
  return true;
@@ -5091,8 +5119,30 @@ var init_EntityAnimationPlayer = __esm({
5091
5119
  advance(deltaSeconds) {
5092
5120
  return this.setTime(this._time + deltaSeconds * this.speed);
5093
5121
  }
5122
+ /** Changes weights in clip order and reapplies the current time without restarting playback. */
5123
+ setWeights(weights) {
5124
+ if (!this._animations.length) return false;
5125
+ const validated = validateAnimationWeights(weights, this._animations.length);
5126
+ this._weights = validated;
5127
+ this.apply();
5128
+ return true;
5129
+ }
5094
5130
  apply() {
5095
- const pose = sampleEntityAnimation(this._animation, this._time, this.loop);
5131
+ const pose = /* @__PURE__ */ Object.create(null);
5132
+ for (let i = 0; i < this._animations.length; i++) {
5133
+ const weight = this._weights[i];
5134
+ if (weight === 0) continue;
5135
+ const sampled = sampleEntityAnimation(this._animations[i], this._time, this.loops[i]);
5136
+ for (const [bone, channels] of Object.entries(sampled)) {
5137
+ const blended = pose[bone] ??= {};
5138
+ for (const channel of ENTITY_ANIMATION_CHANNELS) {
5139
+ const value = channels[channel];
5140
+ if (!value) continue;
5141
+ const target = blended[channel] ??= [0, 0, 0];
5142
+ for (let axis = 0; axis < 3; axis++) target[axis] += value[axis] * weight;
5143
+ }
5144
+ }
5145
+ }
5096
5146
  for (const part of this.parts) {
5097
5147
  const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
5098
5148
  part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
@@ -5716,7 +5766,7 @@ var init_EntityObject = __esm({
5716
5766
  for (const geometry of this.geometries) geometry.dispose();
5717
5767
  this.geometries.clear();
5718
5768
  for (const dispose of this.disposeWireframes.splice(0)) dispose();
5719
- for (const player of this.animationPlayers.splice(0)) player.clear();
5769
+ for (const { player } of this.animationPlayers.splice(0)) player.clear();
5720
5770
  this.partPoses.clear();
5721
5771
  super.disposeAndRemoveAllChildren();
5722
5772
  }
@@ -5751,15 +5801,31 @@ var init_EntityObject = __esm({
5751
5801
  //<editor-fold desc="ANIMATION">
5752
5802
  /** The first active clip, until playback is stopped or the object is disposed. */
5753
5803
  get animation() {
5754
- return this.animationPlayers[0]?.animation;
5804
+ return this.animationPlayers[0]?.player.animation;
5755
5805
  }
5756
- /** Clips playing together, each targeting a separate geometry layer. */
5806
+ /** Clips playing together, in the order passed to {@link playAnimations}. */
5757
5807
  get activeAnimations() {
5758
- return this.animationPlayers.map((player) => player.animation);
5808
+ const animations = [];
5809
+ for (const { player, indices } of this.animationPlayers) {
5810
+ player.animations.forEach((animation, i) => {
5811
+ animations[indices[i]] = animation;
5812
+ });
5813
+ }
5814
+ return animations;
5815
+ }
5816
+ /** Weights of the active clips, in the same order as {@link activeAnimations}. */
5817
+ get animationWeights() {
5818
+ const weights = [];
5819
+ for (const { player, indices } of this.animationPlayers) {
5820
+ player.weights.forEach((weight, i) => {
5821
+ weights[indices[i]] = weight;
5822
+ });
5823
+ }
5824
+ return weights;
5759
5825
  }
5760
5826
  /** Seconds since the animation started, before looping. */
5761
5827
  get animationTime() {
5762
- return this.animationPlayers[0]?.time ?? 0;
5828
+ return this.animationPlayers[0]?.player.time ?? 0;
5763
5829
  }
5764
5830
  /**
5765
5831
  * Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
@@ -5770,42 +5836,59 @@ var init_EntityObject = __esm({
5770
5836
  playAnimation(animation, options) {
5771
5837
  this.playAnimations([animation], options);
5772
5838
  }
5773
- /** Plays clips with a shared clock and no blending. Selected layers without their own clip follow `main`. */
5839
+ /**
5840
+ * Plays clips with a shared clock, adding their weighted offsets within each geometry layer.
5841
+ * Weights default to 1 and are not normalized. Selected layers without their own clip follow `main`.
5842
+ */
5774
5843
  playAnimations(animations, options) {
5775
- const targets = /* @__PURE__ */ new Set();
5776
- const selections = animations.map((animation) => {
5844
+ const weights = validateAnimationWeights(options?.weights ?? animations.map(() => 1), animations.length);
5845
+ const selections = /* @__PURE__ */ new Map();
5846
+ animations.forEach((animation, index) => {
5777
5847
  const layer = animation.layer ?? "main";
5778
- if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
5779
- targets.add(layer);
5780
5848
  const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
5781
5849
  if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
5782
- return { animation, names };
5850
+ let selection = selections.get(layer);
5851
+ if (!selection) selections.set(layer, selection = { animations: [], names, indices: [] });
5852
+ selection.animations.push(animation);
5853
+ selection.indices.push(index);
5783
5854
  });
5784
- const main = selections.find(({ animation }) => (animation.layer ?? "main") === "main");
5785
- if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !targets.has(name.split("#")[0])));
5855
+ const main = selections.get("main");
5856
+ if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !selections.has(name.split("#")[0])));
5786
5857
  this.createMeshes();
5787
5858
  this.stopAnimation();
5788
- for (const { animation, names } of selections) {
5859
+ for (const { animations: clips, names, indices } of selections.values()) {
5789
5860
  const player = new EntityAnimationPlayer();
5790
- player.play(names.map((name) => this.getLayerGroup(name)), animation, options, this.partPoses);
5791
- this.animationPlayers.push(player);
5861
+ player.playAnimations(
5862
+ names.map((name) => this.getLayerGroup(name)),
5863
+ clips,
5864
+ { ...options, weights: indices.map((index) => weights[index]) },
5865
+ this.partPoses
5866
+ );
5867
+ this.animationPlayers.push({ player, indices });
5792
5868
  }
5793
5869
  this.notifyDirty();
5794
5870
  }
5871
+ /** Changes weights in active clip order, notifying the scene without restarting the shared clock. Has no effect without an animation. */
5872
+ setAnimationWeights(weights) {
5873
+ if (!this.animationPlayers.length) return;
5874
+ const values = validateAnimationWeights(weights, this.activeAnimations.length);
5875
+ for (const { player, indices } of this.animationPlayers) player.setWeights(indices.map((index) => values[index]));
5876
+ this.notifyDirty();
5877
+ }
5795
5878
  /** Stops all clips and restores the poses from before playback. */
5796
5879
  stopAnimation() {
5797
5880
  const players = this.animationPlayers.splice(0);
5798
- for (const player of players) player.stop();
5881
+ for (const { player } of players) player.stop();
5799
5882
  if (players.length) this.notifyDirty();
5800
5883
  }
5801
5884
  /** Poses the object at an explicit time in seconds. Has no effect without an animation. */
5802
5885
  setAnimationTime(seconds) {
5803
- for (const player of this.animationPlayers) player.setTime(seconds);
5886
+ for (const { player } of this.animationPlayers) player.setTime(seconds);
5804
5887
  if (this.animationPlayers.length) this.notifyDirty();
5805
5888
  }
5806
5889
  /** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
5807
5890
  advanceAnimation(deltaSeconds) {
5808
- for (const player of this.animationPlayers) player.advance(deltaSeconds);
5891
+ for (const { player } of this.animationPlayers) player.advance(deltaSeconds);
5809
5892
  if (this.animationPlayers.length) this.notifyDirty();
5810
5893
  }
5811
5894
  //</editor-fold>
@@ -11399,6 +11482,7 @@ __export(index_node_exports, {
11399
11482
  toRadians: () => toRadians,
11400
11483
  toTrianglesDrawMode: () => toTrianglesDrawMode,
11401
11484
  trimCanvas: () => trimCanvas,
11485
+ validateAnimationWeights: () => validateAnimationWeights,
11402
11486
  yieldToEventLoop: () => yieldToEventLoop
11403
11487
  });
11404
11488
  module.exports = __toCommonJS(index_node_exports);
@@ -20690,6 +20774,7 @@ var NodeRenderer = class _NodeRenderer extends Renderer {
20690
20774
  toRadians,
20691
20775
  toTrianglesDrawMode,
20692
20776
  trimCanvas,
20777
+ validateAnimationWeights,
20693
20778
  yieldToEventLoop
20694
20779
  });
20695
20780
  //# sourceMappingURL=index.js.map