minerender 2.1.0-alpha.131 → 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.
- package/dist/browser/esm/entity/scene/EntityAnimationPlayer.mjs +62 -11
- package/dist/browser/esm/entity/scene/EntityAnimationPlayer.mjs.map +1 -1
- package/dist/browser/esm/entity/scene/EntityObject.mjs +53 -20
- package/dist/browser/esm/entity/scene/EntityObject.mjs.map +1 -1
- package/dist/browser/esm/index.browser.d.mts +28 -7
- package/dist/browser/index.d.ts +28 -7
- package/dist/browser/index.js +112 -28
- package/dist/browser/index.js.map +1 -1
- package/dist/bundle.js +112 -28
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +28 -7
- package/dist/node/index.d.ts +28 -7
- package/dist/node/index.js +113 -28
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +112 -28
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -1576,25 +1576,35 @@ interface EntityAnimationOptions {
|
|
|
1576
1576
|
speed?: number;
|
|
1577
1577
|
/** Start time in seconds; defaults to 0. */
|
|
1578
1578
|
time?: number;
|
|
1579
|
+
/** Nonnegative finite weights in clip order; defaults to 1 per clip. Offsets add without normalizing weights. */
|
|
1580
|
+
weights?: readonly number[];
|
|
1579
1581
|
}
|
|
1580
1582
|
/**
|
|
1581
|
-
* Poses part groups from
|
|
1582
|
-
*
|
|
1583
|
+
* Poses part groups from keyframe animations: every update restores the default pose of each
|
|
1584
|
+
* animated part, then adds weighted sampled offsets to its position, Euler angles and scale.
|
|
1583
1585
|
* It owns no timer; the owner advances it.
|
|
1584
1586
|
*/
|
|
1585
1587
|
declare class EntityAnimationPlayer {
|
|
1586
1588
|
private parts;
|
|
1587
|
-
private
|
|
1589
|
+
private _animations;
|
|
1590
|
+
private _weights;
|
|
1591
|
+
private loops;
|
|
1588
1592
|
private _time;
|
|
1589
|
-
private loop;
|
|
1590
1593
|
private speed;
|
|
1591
1594
|
get animation(): EntityAnimation | undefined;
|
|
1595
|
+
get animations(): readonly EntityAnimation[];
|
|
1596
|
+
get weights(): readonly number[];
|
|
1592
1597
|
get time(): number;
|
|
1593
1598
|
/**
|
|
1594
1599
|
* Starts an animation on matching named parts. Supplied baked poses are the baseline for offsets;
|
|
1595
1600
|
* without them, the current pose is used. Stopping restores the pose from before playback.
|
|
1596
1601
|
*/
|
|
1597
1602
|
play(layers: Object3D[], animation: EntityAnimation, options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
|
|
1603
|
+
/**
|
|
1604
|
+
* Starts clips on matching parts with a shared clock. Weighted offsets add to the supplied baked poses
|
|
1605
|
+
* or, without poses, to each animated part's pose when playback starts.
|
|
1606
|
+
*/
|
|
1607
|
+
playAnimations(layers: Object3D[], animations: readonly EntityAnimation[], options?: EntityAnimationOptions, poses?: ReadonlyMap<Object3D, EntityModelPart["pose"]>): void;
|
|
1598
1608
|
/** Restores the poses from before playback. Returns whether an animation was active. */
|
|
1599
1609
|
stop(): boolean;
|
|
1600
1610
|
/** Forgets the animation without touching the parts, for parts that no longer exist. */
|
|
@@ -1603,8 +1613,12 @@ declare class EntityAnimationPlayer {
|
|
|
1603
1613
|
setTime(seconds: number): boolean;
|
|
1604
1614
|
/** Advances playback by elapsed seconds multiplied by the speed passed to {@link play}. */
|
|
1605
1615
|
advance(deltaSeconds: number): boolean;
|
|
1616
|
+
/** Changes weights in clip order and reapplies the current time without restarting playback. */
|
|
1617
|
+
setWeights(weights: readonly number[]): boolean;
|
|
1606
1618
|
private apply;
|
|
1607
1619
|
}
|
|
1620
|
+
/** @internal */
|
|
1621
|
+
declare function validateAnimationWeights(weights: readonly number[], count: number): number[];
|
|
1608
1622
|
|
|
1609
1623
|
/** Renders selected entity layers as named part groups. Create it through {@link MineRenderScene.addEntity}. */
|
|
1610
1624
|
declare class EntityObject extends SceneObject {
|
|
@@ -1633,8 +1647,10 @@ declare class EntityObject extends SceneObject {
|
|
|
1633
1647
|
private updateScroll;
|
|
1634
1648
|
/** The first active clip, until playback is stopped or the object is disposed. */
|
|
1635
1649
|
get animation(): Maybe<EntityAnimation>;
|
|
1636
|
-
/** Clips playing together,
|
|
1650
|
+
/** Clips playing together, in the order passed to {@link playAnimations}. */
|
|
1637
1651
|
get activeAnimations(): readonly EntityAnimation[];
|
|
1652
|
+
/** Weights of the active clips, in the same order as {@link activeAnimations}. */
|
|
1653
|
+
get animationWeights(): readonly number[];
|
|
1638
1654
|
/** Seconds since the animation started, before looping. */
|
|
1639
1655
|
get animationTime(): number;
|
|
1640
1656
|
/**
|
|
@@ -1644,8 +1660,13 @@ declare class EntityObject extends SceneObject {
|
|
|
1644
1660
|
* The object owns no clock: call {@link advanceAnimation} per frame, or {@link setAnimationTime}.
|
|
1645
1661
|
*/
|
|
1646
1662
|
playAnimation(animation: EntityAnimation, options?: EntityAnimationOptions): void;
|
|
1647
|
-
/**
|
|
1663
|
+
/**
|
|
1664
|
+
* Plays clips with a shared clock, adding their weighted offsets within each geometry layer.
|
|
1665
|
+
* Weights default to 1 and are not normalized. Selected layers without their own clip follow `main`.
|
|
1666
|
+
*/
|
|
1648
1667
|
playAnimations(animations: readonly EntityAnimation[], options?: EntityAnimationOptions): void;
|
|
1668
|
+
/** Changes weights in active clip order, notifying the scene without restarting the shared clock. Has no effect without an animation. */
|
|
1669
|
+
setAnimationWeights(weights: readonly number[]): void;
|
|
1649
1670
|
/** Stops all clips and restores the poses from before playback. */
|
|
1650
1671
|
stopAnimation(): void;
|
|
1651
1672
|
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
@@ -4344,4 +4365,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
4344
4365
|
*/
|
|
4345
4366
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
4346
4367
|
|
|
4347
|
-
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, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type 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, 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, probeImageSize, registerBrowserEnv, 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 };
|
|
4368
|
+
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, BrowserCache, BrowserEnv, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type 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, 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, probeImageSize, registerBrowserEnv, 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 };
|
package/dist/browser/index.js
CHANGED
|
@@ -4909,6 +4909,13 @@ var init_EntityAnimation = __esm({
|
|
|
4909
4909
|
});
|
|
4910
4910
|
|
|
4911
4911
|
// src/entity/scene/EntityAnimationPlayer.ts
|
|
4912
|
+
function validateAnimationWeights(weights, count) {
|
|
4913
|
+
const values = Array.from(weights);
|
|
4914
|
+
if (values.length !== count || values.some((weight) => !Number.isFinite(weight) || weight < 0)) {
|
|
4915
|
+
throw new Error("Animation weights must match the clip count and contain only finite nonnegative numbers");
|
|
4916
|
+
}
|
|
4917
|
+
return values;
|
|
4918
|
+
}
|
|
4912
4919
|
var import_three11, ZERO, EntityAnimationPlayer;
|
|
4913
4920
|
var init_EntityAnimationPlayer = __esm({
|
|
4914
4921
|
"src/entity/scene/EntityAnimationPlayer.ts"() {
|
|
@@ -4918,12 +4925,20 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
4918
4925
|
EntityAnimationPlayer = class {
|
|
4919
4926
|
constructor() {
|
|
4920
4927
|
this.parts = [];
|
|
4928
|
+
this._animations = [];
|
|
4929
|
+
this._weights = [];
|
|
4930
|
+
this.loops = [];
|
|
4921
4931
|
this._time = 0;
|
|
4922
|
-
this.loop = false;
|
|
4923
4932
|
this.speed = 1;
|
|
4924
4933
|
}
|
|
4925
4934
|
get animation() {
|
|
4926
|
-
return this.
|
|
4935
|
+
return this._animations[0];
|
|
4936
|
+
}
|
|
4937
|
+
get animations() {
|
|
4938
|
+
return this._animations.slice();
|
|
4939
|
+
}
|
|
4940
|
+
get weights() {
|
|
4941
|
+
return this._weights.slice();
|
|
4927
4942
|
}
|
|
4928
4943
|
get time() {
|
|
4929
4944
|
return this._time;
|
|
@@ -4933,10 +4948,20 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
4933
4948
|
* without them, the current pose is used. Stopping restores the pose from before playback.
|
|
4934
4949
|
*/
|
|
4935
4950
|
play(layers, animation, options = {}, poses) {
|
|
4951
|
+
this.playAnimations(layers, [animation], options, poses);
|
|
4952
|
+
}
|
|
4953
|
+
/**
|
|
4954
|
+
* Starts clips on matching parts with a shared clock. Weighted offsets add to the supplied baked poses
|
|
4955
|
+
* or, without poses, to each animated part's pose when playback starts.
|
|
4956
|
+
*/
|
|
4957
|
+
playAnimations(layers, animations, options = {}, poses) {
|
|
4958
|
+
const weights = validateAnimationWeights(options.weights ?? animations.map(() => 1), animations.length);
|
|
4936
4959
|
this.stop();
|
|
4937
|
-
this.
|
|
4960
|
+
this._animations = animations.slice();
|
|
4961
|
+
this._weights = weights;
|
|
4962
|
+
if (!animations.length) return;
|
|
4938
4963
|
this._time = options.time ?? 0;
|
|
4939
|
-
this.
|
|
4964
|
+
this.loops = animations.map((animation) => options.loop ?? animation.loop);
|
|
4940
4965
|
this.speed = options.speed ?? 1;
|
|
4941
4966
|
for (const layer of layers) {
|
|
4942
4967
|
const objects = [];
|
|
@@ -4945,7 +4970,8 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
4945
4970
|
if (poses.has(object4)) objects.push(object4);
|
|
4946
4971
|
});
|
|
4947
4972
|
} else {
|
|
4948
|
-
|
|
4973
|
+
const bones = new Set(animations.flatMap((animation) => Object.keys(animation.bones)));
|
|
4974
|
+
for (const bone of bones) {
|
|
4949
4975
|
const object4 = layer.getObjectByName(`group:${bone}`);
|
|
4950
4976
|
if (object4) objects.push(object4);
|
|
4951
4977
|
}
|
|
@@ -4969,7 +4995,7 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
4969
4995
|
}
|
|
4970
4996
|
/** Restores the poses from before playback. Returns whether an animation was active. */
|
|
4971
4997
|
stop() {
|
|
4972
|
-
if (!this.
|
|
4998
|
+
if (!this._animations.length) return false;
|
|
4973
4999
|
for (const part of this.parts) {
|
|
4974
5000
|
part.object.position.copy(part.position);
|
|
4975
5001
|
part.object.rotation.copy(part.rotation);
|
|
@@ -4981,12 +5007,14 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
4981
5007
|
/** Forgets the animation without touching the parts, for parts that no longer exist. */
|
|
4982
5008
|
clear() {
|
|
4983
5009
|
this.parts = [];
|
|
4984
|
-
this.
|
|
5010
|
+
this._animations = [];
|
|
5011
|
+
this._weights = [];
|
|
5012
|
+
this.loops = [];
|
|
4985
5013
|
this._time = 0;
|
|
4986
5014
|
}
|
|
4987
5015
|
/** Applies the pose at an absolute playback time. Returns `false` when no clip is active. */
|
|
4988
5016
|
setTime(seconds) {
|
|
4989
|
-
if (!this.
|
|
5017
|
+
if (!this._animations.length) return false;
|
|
4990
5018
|
this._time = seconds;
|
|
4991
5019
|
this.apply();
|
|
4992
5020
|
return true;
|
|
@@ -4995,8 +5023,30 @@ var init_EntityAnimationPlayer = __esm({
|
|
|
4995
5023
|
advance(deltaSeconds) {
|
|
4996
5024
|
return this.setTime(this._time + deltaSeconds * this.speed);
|
|
4997
5025
|
}
|
|
5026
|
+
/** Changes weights in clip order and reapplies the current time without restarting playback. */
|
|
5027
|
+
setWeights(weights) {
|
|
5028
|
+
if (!this._animations.length) return false;
|
|
5029
|
+
const validated = validateAnimationWeights(weights, this._animations.length);
|
|
5030
|
+
this._weights = validated;
|
|
5031
|
+
this.apply();
|
|
5032
|
+
return true;
|
|
5033
|
+
}
|
|
4998
5034
|
apply() {
|
|
4999
|
-
const pose =
|
|
5035
|
+
const pose = /* @__PURE__ */ Object.create(null);
|
|
5036
|
+
for (let i = 0; i < this._animations.length; i++) {
|
|
5037
|
+
const weight = this._weights[i];
|
|
5038
|
+
if (weight === 0) continue;
|
|
5039
|
+
const sampled = sampleEntityAnimation(this._animations[i], this._time, this.loops[i]);
|
|
5040
|
+
for (const [bone, channels] of Object.entries(sampled)) {
|
|
5041
|
+
const blended = pose[bone] ?? (pose[bone] = {});
|
|
5042
|
+
for (const channel of ENTITY_ANIMATION_CHANNELS) {
|
|
5043
|
+
const value = channels[channel];
|
|
5044
|
+
if (!value) continue;
|
|
5045
|
+
const target = blended[channel] ?? (blended[channel] = [0, 0, 0]);
|
|
5046
|
+
for (let axis = 0; axis < 3; axis++) target[axis] += value[axis] * weight;
|
|
5047
|
+
}
|
|
5048
|
+
}
|
|
5049
|
+
}
|
|
5000
5050
|
for (const part of this.parts) {
|
|
5001
5051
|
const { position = ZERO, rotation = ZERO, scale = ZERO } = pose[part.bone] ?? {};
|
|
5002
5052
|
part.object.position.set(part.basePosition.x + position[0], part.basePosition.y + position[1], part.basePosition.z + position[2]);
|
|
@@ -5616,7 +5666,7 @@ var init_EntityObject = __esm({
|
|
|
5616
5666
|
for (const geometry of this.geometries) geometry.dispose();
|
|
5617
5667
|
this.geometries.clear();
|
|
5618
5668
|
for (const dispose of this.disposeWireframes.splice(0)) dispose();
|
|
5619
|
-
for (const player of this.animationPlayers.splice(0)) player.clear();
|
|
5669
|
+
for (const { player } of this.animationPlayers.splice(0)) player.clear();
|
|
5620
5670
|
this.partPoses.clear();
|
|
5621
5671
|
super.disposeAndRemoveAllChildren();
|
|
5622
5672
|
}
|
|
@@ -5651,15 +5701,31 @@ var init_EntityObject = __esm({
|
|
|
5651
5701
|
//<editor-fold desc="ANIMATION">
|
|
5652
5702
|
/** The first active clip, until playback is stopped or the object is disposed. */
|
|
5653
5703
|
get animation() {
|
|
5654
|
-
return this.animationPlayers[0]?.animation;
|
|
5704
|
+
return this.animationPlayers[0]?.player.animation;
|
|
5655
5705
|
}
|
|
5656
|
-
/** Clips playing together,
|
|
5706
|
+
/** Clips playing together, in the order passed to {@link playAnimations}. */
|
|
5657
5707
|
get activeAnimations() {
|
|
5658
|
-
|
|
5708
|
+
const animations = [];
|
|
5709
|
+
for (const { player, indices } of this.animationPlayers) {
|
|
5710
|
+
player.animations.forEach((animation, i) => {
|
|
5711
|
+
animations[indices[i]] = animation;
|
|
5712
|
+
});
|
|
5713
|
+
}
|
|
5714
|
+
return animations;
|
|
5715
|
+
}
|
|
5716
|
+
/** Weights of the active clips, in the same order as {@link activeAnimations}. */
|
|
5717
|
+
get animationWeights() {
|
|
5718
|
+
const weights = [];
|
|
5719
|
+
for (const { player, indices } of this.animationPlayers) {
|
|
5720
|
+
player.weights.forEach((weight, i) => {
|
|
5721
|
+
weights[indices[i]] = weight;
|
|
5722
|
+
});
|
|
5723
|
+
}
|
|
5724
|
+
return weights;
|
|
5659
5725
|
}
|
|
5660
5726
|
/** Seconds since the animation started, before looping. */
|
|
5661
5727
|
get animationTime() {
|
|
5662
|
-
return this.animationPlayers[0]?.time ?? 0;
|
|
5728
|
+
return this.animationPlayers[0]?.player.time ?? 0;
|
|
5663
5729
|
}
|
|
5664
5730
|
/**
|
|
5665
5731
|
* Plays a clip from {@link Entities.getAnimations}, replacing all active clips.
|
|
@@ -5670,42 +5736,59 @@ var init_EntityObject = __esm({
|
|
|
5670
5736
|
playAnimation(animation, options) {
|
|
5671
5737
|
this.playAnimations([animation], options);
|
|
5672
5738
|
}
|
|
5673
|
-
/**
|
|
5739
|
+
/**
|
|
5740
|
+
* Plays clips with a shared clock, adding their weighted offsets within each geometry layer.
|
|
5741
|
+
* Weights default to 1 and are not normalized. Selected layers without their own clip follow `main`.
|
|
5742
|
+
*/
|
|
5674
5743
|
playAnimations(animations, options) {
|
|
5675
|
-
const
|
|
5676
|
-
const selections =
|
|
5744
|
+
const weights = validateAnimationWeights(options?.weights ?? animations.map(() => 1), animations.length);
|
|
5745
|
+
const selections = /* @__PURE__ */ new Map();
|
|
5746
|
+
animations.forEach((animation, index) => {
|
|
5677
5747
|
const layer = animation.layer ?? "main";
|
|
5678
|
-
if (targets.has(layer)) throw new Error(`Multiple animations target layer "${layer}"`);
|
|
5679
|
-
targets.add(layer);
|
|
5680
5748
|
const names = Object.keys(this.entityLayers).filter((name) => name.split("#")[0] === layer);
|
|
5681
5749
|
if (!names.length) throw new Error(`Entity ${this.entity.id} has no selected animation layer "${layer}"`);
|
|
5682
|
-
|
|
5750
|
+
let selection = selections.get(layer);
|
|
5751
|
+
if (!selection) selections.set(layer, selection = { animations: [], names, indices: [] });
|
|
5752
|
+
selection.animations.push(animation);
|
|
5753
|
+
selection.indices.push(index);
|
|
5683
5754
|
});
|
|
5684
|
-
const main = selections.
|
|
5685
|
-
if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !
|
|
5755
|
+
const main = selections.get("main");
|
|
5756
|
+
if (main) main.names.push(...Object.keys(this.entityLayers).filter((name) => !selections.has(name.split("#")[0])));
|
|
5686
5757
|
this.createMeshes();
|
|
5687
5758
|
this.stopAnimation();
|
|
5688
|
-
for (const {
|
|
5759
|
+
for (const { animations: clips, names, indices } of selections.values()) {
|
|
5689
5760
|
const player = new EntityAnimationPlayer();
|
|
5690
|
-
player.
|
|
5691
|
-
|
|
5761
|
+
player.playAnimations(
|
|
5762
|
+
names.map((name) => this.getLayerGroup(name)),
|
|
5763
|
+
clips,
|
|
5764
|
+
{ ...options, weights: indices.map((index) => weights[index]) },
|
|
5765
|
+
this.partPoses
|
|
5766
|
+
);
|
|
5767
|
+
this.animationPlayers.push({ player, indices });
|
|
5692
5768
|
}
|
|
5693
5769
|
this.notifyDirty();
|
|
5694
5770
|
}
|
|
5771
|
+
/** Changes weights in active clip order, notifying the scene without restarting the shared clock. Has no effect without an animation. */
|
|
5772
|
+
setAnimationWeights(weights) {
|
|
5773
|
+
if (!this.animationPlayers.length) return;
|
|
5774
|
+
const values = validateAnimationWeights(weights, this.activeAnimations.length);
|
|
5775
|
+
for (const { player, indices } of this.animationPlayers) player.setWeights(indices.map((index) => values[index]));
|
|
5776
|
+
this.notifyDirty();
|
|
5777
|
+
}
|
|
5695
5778
|
/** Stops all clips and restores the poses from before playback. */
|
|
5696
5779
|
stopAnimation() {
|
|
5697
5780
|
const players = this.animationPlayers.splice(0);
|
|
5698
|
-
for (const player of players) player.stop();
|
|
5781
|
+
for (const { player } of players) player.stop();
|
|
5699
5782
|
if (players.length) this.notifyDirty();
|
|
5700
5783
|
}
|
|
5701
5784
|
/** Poses the object at an explicit time in seconds. Has no effect without an animation. */
|
|
5702
5785
|
setAnimationTime(seconds) {
|
|
5703
|
-
for (const player of this.animationPlayers) player.setTime(seconds);
|
|
5786
|
+
for (const { player } of this.animationPlayers) player.setTime(seconds);
|
|
5704
5787
|
if (this.animationPlayers.length) this.notifyDirty();
|
|
5705
5788
|
}
|
|
5706
5789
|
/** Advances the animation by a frame delta in seconds, scaled by its speed. Has no effect without an animation. */
|
|
5707
5790
|
advanceAnimation(deltaSeconds) {
|
|
5708
|
-
for (const player of this.animationPlayers) player.advance(deltaSeconds);
|
|
5791
|
+
for (const { player } of this.animationPlayers) player.advance(deltaSeconds);
|
|
5709
5792
|
if (this.animationPlayers.length) this.notifyDirty();
|
|
5710
5793
|
}
|
|
5711
5794
|
//</editor-fold>
|
|
@@ -11299,6 +11382,7 @@ __export(index_browser_exports, {
|
|
|
11299
11382
|
toRadians: () => toRadians,
|
|
11300
11383
|
toTrianglesDrawMode: () => toTrianglesDrawMode,
|
|
11301
11384
|
trimCanvas: () => trimCanvas,
|
|
11385
|
+
validateAnimationWeights: () => validateAnimationWeights,
|
|
11302
11386
|
yieldToEventLoop: () => yieldToEventLoop
|
|
11303
11387
|
});
|
|
11304
11388
|
module.exports = __toCommonJS(index_browser_exports);
|