diff --git a/cc.config.json b/cc.config.json index e33cc13331..3fecc5c073 100644 --- a/cc.config.json +++ b/cc.config.json @@ -4,6 +4,8 @@ "gfx-webgl": { "modules": [ "gfx-webgl" ] }, "gfx-webgl2": { "modules": [ "gfx-webgl2" ] }, "3d": { "modules": [ "3d" ] }, + "animation": { "modules": ["animation"] }, + "skeletal-animation": { "modules": ["animation", "skeletal-animation"] }, "2d": { "modules": [ "2d" ] }, "ui": { "modules": [ "ui", "2d" ] }, "particle": { "modules": [ "particle" ] }, diff --git a/cocos/3d/assets/skeleton.ts b/cocos/3d/assets/skeleton.ts index fc49b49777..39871a6c1f 100644 --- a/cocos/3d/assets/skeleton.ts +++ b/cocos/3d/assets/skeleton.ts @@ -32,7 +32,7 @@ import { ccclass, type, serializable } from 'cc.decorator'; import { CCString } from '../../core/data/utils/attribute'; import { Mat4 } from '../../core/math'; import { murmurhash2_32_gc } from '../../core/utils/murmurhash2_gc'; -import { DataPoolManager } from '../skeletal-animation/data-pool-manager'; +import type { DataPoolManager } from '../skeletal-animation/data-pool-manager'; import { Asset } from '../../core/assets/asset'; import { legacyCC } from '../../core/global-exports'; diff --git a/cocos/3d/index.ts b/cocos/3d/index.ts index ec07c5e66d..a18790c602 100644 --- a/cocos/3d/index.ts +++ b/cocos/3d/index.ts @@ -37,7 +37,6 @@ export * from './framework'; export * from './lights'; export * from './skinned-mesh-renderer'; -export * from './skeletal-animation'; export { utils, }; diff --git a/cocos/3d/misc/joint-texture-sampler-info.ts b/cocos/3d/misc/joint-texture-sampler-info.ts new file mode 100644 index 0000000000..440e5db24e --- /dev/null +++ b/cocos/3d/misc/joint-texture-sampler-info.ts @@ -0,0 +1,10 @@ +import { Address, Filter, SamplerInfo } from '../../core/gfx'; + +export const jointTextureSamplerInfo = new SamplerInfo( + Filter.POINT, + Filter.POINT, + Filter.NONE, + Address.CLAMP, + Address.CLAMP, + Address.CLAMP, +); diff --git a/cocos/3d/models/baked-skinning-model.ts b/cocos/3d/models/baked-skinning-model.ts index 648282c4c5..dcadbab228 100644 --- a/cocos/3d/models/baked-skinning-model.ts +++ b/cocos/3d/models/baked-skinning-model.ts @@ -29,7 +29,7 @@ */ import { JSB } from 'internal:constants'; -import { AnimationClip } from '../../core/animation/animation-clip'; +import type { AnimationClip } from '../../core/animation/animation-clip'; import { Mesh } from '../assets/mesh'; import { Skeleton } from '../assets/skeleton'; import { AABB } from '../../core/geometry'; @@ -37,12 +37,13 @@ import { BufferUsageBit, MemoryUsageBit, Attribute, DescriptorSet, Buffer, Buffe import { INST_JOINT_ANIM_INFO, UBOSkinningAnimation, UBOSkinningTexture, UNIFORM_JOINT_TEXTURE_BINDING } from '../../core/pipeline/define'; import { Node } from '../../core/scene-graph'; import { IMacroPatch, Pass } from '../../core/renderer/core/pass'; -import { DataPoolManager } from '../skeletal-animation/data-pool-manager'; +import type { DataPoolManager } from '../skeletal-animation/data-pool-manager'; import { ModelType } from '../../core/renderer/scene/model'; -import { IAnimInfo, IJointTextureHandle, jointTextureSamplerInfo } from '../skeletal-animation/skeletal-animation-utils'; +import { IAnimInfo, IJointTextureHandle } from '../skeletal-animation/skeletal-animation-utils'; import { MorphModel } from './morph-model'; import { legacyCC } from '../../core/global-exports'; import { NativeAABB, NativeBakedSkinningModel } from '../../core/renderer/scene/native-scene'; +import { jointTextureSamplerInfo } from '../misc/joint-texture-sampler-info'; interface IJointsInfo { buffer: Buffer | null; diff --git a/cocos/3d/skeletal-animation/data-pool-manager.ts b/cocos/3d/skeletal-animation/data-pool-manager.ts index fad34a4a09..7b7f5c0360 100644 --- a/cocos/3d/skeletal-animation/data-pool-manager.ts +++ b/cocos/3d/skeletal-animation/data-pool-manager.ts @@ -28,8 +28,8 @@ * @hidden */ -import { AnimationClip } from '../../core/animation/animation-clip'; -import { Skeleton } from '../assets'; +import type { AnimationClip } from '../../core/animation/animation-clip'; +import type { Skeleton } from '../assets'; import { Device } from '../../core/gfx'; import { JointAnimationInfo, JointTexturePool } from './skeletal-animation-utils'; import { legacyCC } from '../../core/global-exports'; diff --git a/cocos/3d/skeletal-animation/skeletal-animation-blending.ts b/cocos/3d/skeletal-animation/skeletal-animation-blending.ts index ea4caba5fc..f7cf063f54 100644 --- a/cocos/3d/skeletal-animation/skeletal-animation-blending.ts +++ b/cocos/3d/skeletal-animation/skeletal-animation-blending.ts @@ -31,7 +31,7 @@ import { DEBUG } from 'internal:constants'; import { Vec3, Quat, approx } from '../../core/math'; import { Node } from '../../core/scene-graph'; -import { RuntimeBinding } from '../../core/animation/tracks/track'; +import type { RuntimeBinding } from '../../core/animation/tracks/track'; import { assertIsTrue } from '../../core/data/utils/asserts'; export class BlendStateBuffer { diff --git a/cocos/3d/skeletal-animation/skeletal-animation-state.ts b/cocos/3d/skeletal-animation/skeletal-animation-state.ts index a304d6e4c5..434db1c64b 100644 --- a/cocos/3d/skeletal-animation/skeletal-animation-state.ts +++ b/cocos/3d/skeletal-animation/skeletal-animation-state.ts @@ -32,7 +32,7 @@ import { JSB } from 'internal:constants'; import { Mat4, Quat, Vec3 } from '../../core/math'; import { IAnimInfo, JointAnimationInfo } from './skeletal-animation-utils'; import { Node } from '../../core/scene-graph/node'; -import { AnimationClip } from '../../core/animation/animation-clip'; +import type { AnimationClip } from '../../core/animation/animation-clip'; import { AnimationState } from '../../core/animation/animation-state'; import { SkeletalAnimation, Socket } from './skeletal-animation'; import { SkelAnimDataHub } from './skeletal-animation-data-hub'; diff --git a/cocos/3d/skeletal-animation/skeletal-animation-utils.ts b/cocos/3d/skeletal-animation/skeletal-animation-utils.ts index 6af0ac1854..2df6dd2b28 100644 --- a/cocos/3d/skeletal-animation/skeletal-animation-utils.ts +++ b/cocos/3d/skeletal-animation/skeletal-animation-utils.ts @@ -29,7 +29,7 @@ */ import { EDITOR, JSB } from 'internal:constants'; -import { AnimationClip } from '../../core/animation/animation-clip'; +import type { AnimationClip } from '../../core/animation/animation-clip'; import { SkelAnimDataHub } from './skeletal-animation-data-hub'; import { getWorldTransformUntilRoot } from '../../core/animation/transform-utils'; import { Mesh } from '../assets/mesh'; @@ -41,6 +41,7 @@ import { Mat4, Quat, Vec3 } from '../../core/math'; import { UBOSkinningAnimation } from '../../core/pipeline/define'; import { Node } from '../../core/scene-graph'; import { ITextureBufferHandle, TextureBufferPool } from '../../core/renderer/core/texture-buffer-pool'; +import { jointTextureSamplerInfo } from '../misc/joint-texture-sampler-info'; // change here and cc-skinning.chunk to use other skinning algorithms export const uploadJointData = uploadJointDataLBS; @@ -102,14 +103,7 @@ function roundUpTextureSize (targetLength: number, formatSize: number) { return Math.ceil(Math.max(MINIMUM_JOINT_TEXTURE_SIZE * formatScale, targetLength) / 12) * 12; } -export const jointTextureSamplerInfo = new SamplerInfo( - Filter.POINT, - Filter.POINT, - Filter.NONE, - Address.CLAMP, - Address.CLAMP, - Address.CLAMP, -); +export { jointTextureSamplerInfo }; interface IInternalJointAnimInfo { downstream?: Mat4; // downstream default pose, if present diff --git a/cocos/3d/skeletal-animation/skeletal-animation.ts b/cocos/3d/skeletal-animation/skeletal-animation.ts index 87b9e7f0da..caa1283269 100644 --- a/cocos/3d/skeletal-animation/skeletal-animation.ts +++ b/cocos/3d/skeletal-animation/skeletal-animation.ts @@ -41,10 +41,10 @@ import { SkelAnimDataHub } from './skeletal-animation-data-hub'; import { SkeletalAnimationState } from './skeletal-animation-state'; import { getWorldTransformUntilRoot } from '../../core/animation/transform-utils'; import { legacyCC } from '../../core/global-exports'; -import { AnimationManager } from '../../core/animation/animation-manager'; import { js } from '../../core/utils/js'; import type { AnimationState } from '../../core/animation/animation-state'; import { assertIsTrue } from '../../core/data/utils/asserts'; +import { getGlobalAnimationManager } from '../../core/animation/global-animation-manager'; @ccclass('cc.SkeletalAnimation.Socket') export class Socket { @@ -119,7 +119,7 @@ export class SkeletalAnimation extends Animation { set sockets (val) { if (!this._useBakedAnimation) { - const animMgr = legacyCC.director.getAnimationManager() as AnimationManager; + const animMgr = getGlobalAnimationManager(); animMgr.removeSockets(this.node, this._sockets); animMgr.addSockets(this.node, val); } @@ -154,9 +154,9 @@ export class SkeletalAnimation extends Animation { }); if (this._useBakedAnimation) { - (legacyCC.director.getAnimationManager() as AnimationManager).removeSockets(this.node, this._sockets); + getGlobalAnimationManager().removeSockets(this.node, this._sockets); } else { - (legacyCC.director.getAnimationManager() as AnimationManager).addSockets(this.node, this._sockets); + getGlobalAnimationManager().addSockets(this.node, this._sockets); this._currentBakedState = null; } } @@ -182,7 +182,7 @@ export class SkeletalAnimation extends Animation { public onDestroy () { super.onDestroy(); (legacyCC.director.root.dataPoolManager as DataPoolManager).jointAnimationInfo.destroy(this.node.uuid); - (legacyCC.director.getAnimationManager() as AnimationManager).removeSockets(this.node, this._sockets); + getGlobalAnimationManager().removeSockets(this.node, this._sockets); this._removeAllUsers(); } diff --git a/cocos/3d/skinned-mesh-renderer/index.ts b/cocos/3d/skinned-mesh-renderer/index.ts index 6497b416de..24413a5ef3 100644 --- a/cocos/3d/skinned-mesh-renderer/index.ts +++ b/cocos/3d/skinned-mesh-renderer/index.ts @@ -24,12 +24,6 @@ THE SOFTWARE. */ -/** - * @packageDocumentation - * @hidden - */ -import '../skeletal-animation/data-pool-manager'; - export { SkinnedMeshRenderer } from './skinned-mesh-renderer'; export { SkinnedMeshBatchRenderer, SkinnedMeshUnit } from './skinned-mesh-batch-renderer'; export * from './deprecated'; diff --git a/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts b/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts index 814a6c224b..e1aa3459d1 100644 --- a/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts +++ b/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts @@ -31,7 +31,7 @@ import { ccclass, executeInEditMode, executionOrder, help, menu, tooltip, type, } from 'cc.decorator'; -import { AnimationClip } from '../../core/animation/animation-clip'; +import type { AnimationClip } from '../../core/animation/animation-clip'; import { Material } from '../../core/assets'; import { Skeleton } from '../assets/skeleton'; import { Node } from '../../core/scene-graph/node'; diff --git a/cocos/core/animation/animation-clip.ts b/cocos/core/animation/animation-clip.ts index 44b933b987..092636fa9c 100644 --- a/cocos/core/animation/animation-clip.ts +++ b/cocos/core/animation/animation-clip.ts @@ -52,6 +52,7 @@ import { ObjectTrack } from './tracks/object-track'; import type { ExoticAnimation } from './exotic-animation/exotic-animation'; import './exotic-animation/exotic-animation'; import { array } from '../utils/js'; +import { getGlobalAnimationManager } from './global-animation-manager'; export declare namespace AnimationClip { export interface IEvent { @@ -1159,7 +1160,7 @@ class EventEvaluator { private _doFire (eventIndex: number, delay: boolean) { if (delay) { - legacyCC.director.getAnimationManager().pushDelayEvent(this._checkAndFire, this, [eventIndex]); + getGlobalAnimationManager().pushDelayEvent(this._checkAndFire, this, [eventIndex]); } else { this._checkAndFire(eventIndex); } diff --git a/cocos/core/animation/animation-curve.ts b/cocos/core/animation/animation-curve.ts index 2ab3926e5a..55b5e68680 100644 --- a/cocos/core/animation/animation-curve.ts +++ b/cocos/core/animation/animation-curve.ts @@ -32,8 +32,8 @@ import { binarySearchEpsilon as binarySearch } from '../algorithm/binary-search' import { lerp, Quat } from '../math'; import { errorID } from '../platform/debug'; import { ValueType } from '../value-types'; -import { bezierByTime, BezierControlPoints } from './bezier'; -import * as easing from './easing'; +import { bezierByTime, BezierControlPoints } from '../curves/bezier'; +import * as easing from '../easing/easing'; import { ILerpable, isLerpable } from './types'; import { legacyCC } from '../global-exports'; import type * as legacy from './legacy-clip-data'; diff --git a/cocos/core/animation/animation-state.ts b/cocos/core/animation/animation-state.ts index 7ae8d87e32..a1ae3db19d 100644 --- a/cocos/core/animation/animation-state.ts +++ b/cocos/core/animation/animation-state.ts @@ -40,6 +40,7 @@ import { debug } from '../platform/debug'; import { SkeletonMask } from './skeleton-mask'; import { PoseOutput } from './pose-output'; import { BlendStateBuffer } from '../../3d/skeletal-animation/skeletal-animation-blending'; +import { getGlobalAnimationManager } from './global-animation-manager'; /** * @en The event type supported by Animation @@ -354,7 +355,7 @@ export class AnimationState extends Playable { } if (!this._doNotCreateEval) { - const pose = blendStateBuffer ?? legacyCC.director.getAnimationManager()?.blendState ?? null; + const pose = blendStateBuffer ?? getGlobalAnimationManager()?.blendState ?? null; if (pose) { this._poseOutput = new PoseOutput(pose); } @@ -371,7 +372,7 @@ export class AnimationState extends Playable { public destroy () { if (!this.isMotionless) { - legacyCC.director.getAnimationManager().removeAnimation(this); + getGlobalAnimationManager().removeAnimation(this); } if (this._poseOutput) { this._poseOutput.destroy(); @@ -386,7 +387,7 @@ export class AnimationState extends Playable { * To process animation events, use `Animation` instead. */ public emit (...args: any[]) { - legacyCC.director.getAnimationManager().pushDelayEvent(this._emit, this, args); + getGlobalAnimationManager().pushDelayEvent(this._emit, this, args); } /** @@ -684,11 +685,11 @@ export class AnimationState extends Playable { } private _onReplayOrResume () { - legacyCC.director.getAnimationManager().addAnimation(this); + getGlobalAnimationManager().addAnimation(this); } private _onPauseOrStop () { - legacyCC.director.getAnimationManager().removeAnimation(this); + getGlobalAnimationManager().removeAnimation(this); } } diff --git a/cocos/core/animation/cross-fade.ts b/cocos/core/animation/cross-fade.ts index 462f890ab9..acb6d7dd7f 100644 --- a/cocos/core/animation/cross-fade.ts +++ b/cocos/core/animation/cross-fade.ts @@ -32,8 +32,7 @@ import { clamp01 } from '../math/utils'; import { remove } from '../utils/array'; import { AnimationState } from './animation-state'; import { Playable } from './playable'; -import { legacyCC } from '../global-exports'; -import type { AnimationManager } from './animation-manager'; +import { getGlobalAnimationManager } from './global-animation-manager'; interface IManagedState { state: AnimationState | null; @@ -60,7 +59,7 @@ export class CrossFade extends Playable { constructor (scheduler?: CrossFadeScheduler) { super(); - this._scheduler = scheduler ?? legacyCC.director.getAnimationManager() as AnimationManager; + this._scheduler = scheduler ?? getGlobalAnimationManager(); } public update (deltaTime: number) { diff --git a/cocos/core/animation/global-animation-manager.ts b/cocos/core/animation/global-animation-manager.ts new file mode 100644 index 0000000000..d35cfe2e40 --- /dev/null +++ b/cocos/core/animation/global-animation-manager.ts @@ -0,0 +1,7 @@ +import { legacyCC } from "../global-exports"; +import type { AnimationManager } from "./animation-manager"; + +export function getGlobalAnimationManager() { + const animationManager = legacyCC.director.getAnimationManager() as AnimationManager; + return animationManager; +} diff --git a/cocos/core/animation/index.ts b/cocos/core/animation/index.ts index fc83b6b815..5d8e97a0ea 100644 --- a/cocos/core/animation/index.ts +++ b/cocos/core/animation/index.ts @@ -29,7 +29,7 @@ */ import { ccclass } from 'cc.decorator'; import * as animation from './animation'; -import * as easing from './easing'; +import * as easing from '../easing/easing'; import { ComponentPath, HierarchyPath, ICustomTargetPath, TargetPath } from './target-path'; import { IValueProxyFactory } from './value-proxy'; import { UniformProxyFactory } from './value-proxy-factories/uniform'; @@ -38,7 +38,7 @@ import { legacyCC } from '../global-exports'; export * from './deprecated'; legacyCC.easing = easing; -export * from './bezier'; +export * from '../curves/bezier'; export { easing }; export * from './animation-curve'; export { AnimationClip } from './animation-clip'; diff --git a/cocos/core/animation/legacy-clip-data.ts b/cocos/core/animation/legacy-clip-data.ts index 0ea91ea41c..9fcb10376a 100644 --- a/cocos/core/animation/legacy-clip-data.ts +++ b/cocos/core/animation/legacy-clip-data.ts @@ -1,7 +1,7 @@ import { ComponentPath, HierarchyPath, isPropertyPath, TargetPath } from './target-path'; import { IValueProxyFactory } from './value-proxy'; -import * as easing from './easing'; -import { BezierControlPoints } from './bezier'; +import * as easing from '../easing/easing'; +import { BezierControlPoints } from '../curves/bezier'; import { CompactValueTypeArray } from '../data/utils/compact-value-type-array'; import { serializable } from '../data/decorators'; import { AnimCurve, RatioSampler } from './animation-curve'; diff --git a/cocos/core/animation/bezier.ts b/cocos/core/curves/bezier.ts similarity index 100% rename from cocos/core/animation/bezier.ts rename to cocos/core/curves/bezier.ts diff --git a/cocos/core/curves/easing-method.ts b/cocos/core/curves/easing-method.ts index bee67122cb..8e1aba02af 100644 --- a/cocos/core/curves/easing-method.ts +++ b/cocos/core/curves/easing-method.ts @@ -1,4 +1,4 @@ -import * as easing from '../animation/easing'; +import * as easing from '../easing/easing'; import { assertIsTrue } from '../data/utils/asserts'; export enum EasingMethod { diff --git a/cocos/core/curves/quat-curve.ts b/cocos/core/curves/quat-curve.ts index bd4392664f..7ac660e7c5 100644 --- a/cocos/core/curves/quat-curve.ts +++ b/cocos/core/curves/quat-curve.ts @@ -7,7 +7,7 @@ import { ccclass, serializable, uniquelyReferenced } from '../data/decorators'; import { deserializeTag, SerializationContext, SerializationInput, SerializationOutput, serializeTag } from '../data'; import { DeserializationContext } from '../data/custom-serializable'; import { getEasingFn } from './easing-method'; -import { bezierByTime } from '../animation/bezier'; +import { bezierByTime } from './bezier'; /** * The method used for interpolation between values of a keyframe and its next keyframe. diff --git a/cocos/core/animation/easing.ts b/cocos/core/easing/easing.ts similarity index 100% rename from cocos/core/animation/easing.ts rename to cocos/core/easing/easing.ts diff --git a/cocos/core/easing/index.ts b/cocos/core/easing/index.ts new file mode 100644 index 0000000000..dcaee9b759 --- /dev/null +++ b/cocos/core/easing/index.ts @@ -0,0 +1,3 @@ +import * as easing from './easing'; + +export { easing }; diff --git a/cocos/core/game.ts b/cocos/core/game.ts index 9ec504a5e6..ea9e599208 100644 --- a/cocos/core/game.ts +++ b/cocos/core/game.ts @@ -38,7 +38,7 @@ import * as debug from './platform/debug'; import { Device, DeviceInfo, Swapchain, SwapchainInfo } from './gfx'; import { sys } from './platform/sys'; import { macro } from './platform/macro'; -import { ICustomJointTextureLayout } from '../3d/skeletal-animation/skeletal-animation-utils'; +import type { ICustomJointTextureLayout } from '../3d/skeletal-animation/skeletal-animation-utils'; import { legacyCC, VERSION } from './global-exports'; import { IPhysicsConfig } from '../physics/framework/physics-config'; import { bindingMappingInfo } from './pipeline/define'; diff --git a/cocos/core/index.ts b/cocos/core/index.ts index 1637201e7a..c42480ff17 100644 --- a/cocos/core/index.ts +++ b/cocos/core/index.ts @@ -60,5 +60,4 @@ export * from './asset-manager'; export * from './scene-graph'; export * from './components'; export * from './builtin'; -export * from './animation'; export * from './curves'; diff --git a/cocos/core/root.ts b/cocos/core/root.ts index 1806a6df2c..c243cc96f4 100644 --- a/cocos/core/root.ts +++ b/cocos/core/root.ts @@ -33,7 +33,7 @@ import { builtinResMgr } from './builtin'; import { Pool } from './memop'; import { RenderPipeline, createDefaultPipeline, DeferredPipeline } from './pipeline'; import { Camera, Light, Model, NativeRoot } from './renderer/scene'; -import { DataPoolManager } from '../3d/skeletal-animation/data-pool-manager'; +import type { DataPoolManager } from '../3d/skeletal-animation/data-pool-manager'; import { LightType } from './renderer/scene/light'; import { IRenderSceneInfo, RenderScene } from './renderer/scene/render-scene'; import { SphereLight } from './renderer/scene/sphere-light'; diff --git a/cocos/core/splash-screen.ts b/cocos/core/splash-screen.ts index 87323438cd..c3da8d9bb4 100644 --- a/cocos/core/splash-screen.ts +++ b/cocos/core/splash-screen.ts @@ -28,7 +28,7 @@ * @hidden */ -import * as easing from './animation/easing'; +import * as easing from './easing/easing'; import { Material } from './assets/material'; import { clamp01 } from './math/utils'; import { diff --git a/cocos/tween/tween-action.ts b/cocos/tween/tween-action.ts index 40222a0213..4933bd06c8 100644 --- a/cocos/tween/tween-action.ts +++ b/cocos/tween/tween-action.ts @@ -28,7 +28,7 @@ * @hidden */ -import { easing } from '../core/animation'; +import { easing } from '../core/easing/index'; import { warnID, warn } from '../core'; import { ActionInterval } from './actions/action-interval'; import { ITweenOption } from './export-api'; diff --git a/editor/engine-features/render-config.json b/editor/engine-features/render-config.json index 8e23daabfd..700914f482 100644 --- a/editor/engine-features/render-config.json +++ b/editor/engine-features/render-config.json @@ -27,6 +27,18 @@ } } }, + "animation": { + "label": "i18n:ENGINE.features.animation.label", + "description": "i18n:ENGINE.features.animation.description", + "default": ["animation"], + "category": "animation" + }, + "skeletal-animation": { + "label": "i18n:ENGINE.features.skeletal_animation.label", + "description": "i18n:ENGINE.features.skeletal_animation.description", + "default": ["skeletal-animation"], + "category": "animation" + }, "3d": { "default": ["3d"], "label": "i18n:ENGINE.features.base_3d.label", @@ -184,7 +196,8 @@ "default": ["marionette"], "label": "Marionette 动画系统", "description": "启用 Marionette 动画系统。", - "wechatPlugin": false + "wechatPlugin": false, + "category": "animation" } }, "categories": { @@ -195,6 +208,10 @@ "3d": { "label": "i18n:ENGINE.features.categories.3d.label", "description": "i18n:ENGINE.features.categories.3d.description" + }, + "animation": { + "label": "i18n:ENGINE.features.categories.animation.label", + "description": "i18n:ENGINE.features.categories.animation.description" } } } diff --git a/editor/engine-features/schema.json b/editor/engine-features/schema.json index c75d84a50a..060d10e5ac 100644 --- a/editor/engine-features/schema.json +++ b/editor/engine-features/schema.json @@ -58,6 +58,9 @@ "3d": { "$ref": "#/definitions/Item" }, + "animation": { + "$ref": "#/definitions/Item" + }, "audio": { "$ref": "#/definitions/Item" }, @@ -118,6 +121,9 @@ "profiler": { "$ref": "#/definitions/Item" }, + "skeletal-animation": { + "$ref": "#/definitions/Item" + }, "spine": { "$ref": "#/definitions/Item" }, @@ -193,6 +199,9 @@ "3d": { "$ref": "#/definitions/BaseItem" }, + "animation": { + "$ref": "#/definitions/BaseItem" + }, "audio": { "$ref": "#/definitions/BaseItem" }, @@ -253,6 +262,9 @@ "profiler": { "$ref": "#/definitions/BaseItem" }, + "skeletal-animation": { + "$ref": "#/definitions/BaseItem" + }, "spine": { "$ref": "#/definitions/BaseItem" }, diff --git a/editor/engine-features/types.ts b/editor/engine-features/types.ts index 1732777596..34c07b84b4 100644 --- a/editor/engine-features/types.ts +++ b/editor/engine-features/types.ts @@ -29,7 +29,9 @@ export type EngineFeature = | 'dragon-bones' | 'primitive' | 'profiler' - | 'marionette'; + | 'marionette' + | 'animation' + | 'skeletal-animation'; export interface ModuleRenderConfig { $schema?: string; diff --git a/editor/i18n/en/localization.js b/editor/i18n/en/localization.js index 8934a75803..b49f3e73ff 100755 --- a/editor/i18n/en/localization.js +++ b/editor/i18n/en/localization.js @@ -767,6 +767,10 @@ module.exports = { label: '3D', description: '3D', }, + animation: { + label: 'Animation', + description: 'Animation System.', + }, }, core: { label: "Core", @@ -884,6 +888,14 @@ module.exports = { label: "DragonBones", description: "DragonBones support.", }, + animation: { + label: "Basic Animation", + description: "Basic animation support.", + }, + skeletal_animation: { + label: "Skeletal Animation", + description: "Skeletal animation support.", + }, }, renderable_2d: { srcBlendFactor: 'Specifies the source blend mode, it will clone a new material object.', diff --git a/editor/i18n/zh/localization.js b/editor/i18n/zh/localization.js index 5942c27094..5041f8e400 100755 --- a/editor/i18n/zh/localization.js +++ b/editor/i18n/zh/localization.js @@ -748,6 +748,10 @@ module.exports = { label: '3D', description: '3D', }, + animation: { + label: '动画', + description: '动画系统。', + }, }, core: { label: "核心功能", @@ -865,6 +869,14 @@ module.exports = { label: "DragonBones", description: "DragonBones 支持。", }, + animation: { + label: "基础动画功能", + description: "基础动画功能支持。", + }, + skeletal_animation: { + label: "骨骼动画", + description: "骨骼动画支持。", + }, }, renderable_2d: { srcBlendFactor: '指定源的混合模式,这会克隆一个新的材质对象,注意这带来的性能和内存损耗', diff --git a/exports/animation.ts b/exports/animation.ts new file mode 100644 index 0000000000..d35f7ab47c --- /dev/null +++ b/exports/animation.ts @@ -0,0 +1 @@ +export * from '../cocos/core/animation'; diff --git a/exports/skeletal-animation.ts b/exports/skeletal-animation.ts new file mode 100644 index 0000000000..8f04263583 --- /dev/null +++ b/exports/skeletal-animation.ts @@ -0,0 +1 @@ +export * from '../cocos/3d/skeletal-animation'; diff --git a/gulpfile.js b/gulpfile.js index 3edba7ba65..75c21a01c9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -52,7 +52,10 @@ gulp.task('build-source', async () => { }); }); -gulp.task('build-h5-source', gulp.series('build-debug-infos', () => { +gulp.task('build-h5-source', gulp.series('build-debug-infos', async () => { + const outDir = ps.join('bin', 'dev', 'cc'); + await fs.ensureDir(outDir); + await fs.emptyDir(outDir); const cli = require.resolve('@cocos/build-engine/dist/cli'); return cp.spawn('node', [ cli, @@ -61,7 +64,7 @@ gulp.task('build-h5-source', gulp.series('build-debug-infos', () => { '--build-mode=BUILD', '--platform=HTML5', '--physics=cannon', - '--out=./bin/dev/cc', + `--out=${outDir}`, ], { shell: true, stdio: 'inherit', @@ -69,7 +72,10 @@ gulp.task('build-h5-source', gulp.series('build-debug-infos', () => { }); })); -gulp.task('build-h5-minified', gulp.series('build-debug-infos', () => { +gulp.task('build-h5-minified', gulp.series('build-debug-infos', async () => { + const outDir = ps.join('bin', 'dev', 'cc-min'); + await fs.ensureDir(outDir); + await fs.emptyDir(outDir); const cli = require.resolve('@cocos/build-engine/dist/cli'); return cp.spawn('node', [ cli, @@ -80,7 +86,7 @@ gulp.task('build-h5-minified', gulp.series('build-debug-infos', () => { '--build-mode=BUILD', '--platform=HTML5', '--physics=cannon', - '--out=./bin/dev/cc-min', + `--out=${outDir}`, ], { shell: true, stdio: 'inherit', diff --git a/tests/animation/animation-component.test.ts b/tests/animation/animation-component.test.ts index ae180f565e..93461b48bc 100644 --- a/tests/animation/animation-component.test.ts +++ b/tests/animation/animation-component.test.ts @@ -1,4 +1,4 @@ -import { AnimationClip } from '../../cocos/core'; +import { AnimationClip } from '../../cocos/core/animation/animation-clip'; import { Animation } from '../../cocos/core/animation/animation-component'; describe('Animation Component', () => { diff --git a/tests/animation/newgenanim.test.ts b/tests/animation/newgenanim.test.ts index 1c34616513..67424933ff 100644 --- a/tests/animation/newgenanim.test.ts +++ b/tests/animation/newgenanim.test.ts @@ -1,5 +1,5 @@ -import { AnimationClip, Component, Node, Vec2, Vec3, warnID } from '../../cocos/core'; +import { Component, Node, Vec2, Vec3, warnID } from '../../cocos/core'; import { AnimationBlend1D, AnimationBlend2D, Condition, InvalidTransitionError, VariableNotDefinedError, __getDemoGraphs, ClipMotion, AnimationBlendDirect, VariableType } from '../../cocos/core/animation/marionette/asset-creation'; import { LayerBlending, AnimationGraph, StateMachine, Transition, isAnimationTransition, AnimationTransition } from '../../cocos/core/animation/marionette/animation-graph'; import { createEval } from '../../cocos/core/animation/marionette/create-eval'; @@ -22,6 +22,7 @@ import { AnimationController } from '../../cocos/core/animation/marionette/anima import { StateMachineComponent } from '../../cocos/core/animation/marionette/state-machine-component'; import { VectorTrack } from '../../cocos/core/animation/animation'; import 'jest-extended'; +import { AnimationClip } from '../../cocos/core/animation/animation-clip'; describe('NewGen Anim', () => { const demoGraphs = __getDemoGraphs(); diff --git a/tests/init.ts b/tests/init.ts index 6b582cc027..ecbe186a78 100644 --- a/tests/init.ts +++ b/tests/init.ts @@ -64,6 +64,7 @@ import { game, IGameConfig } from '../exports/base'; import './asset-manager/init'; import '../cocos/core/gfx/empty/empty-device'; import '../cocos/3d/skeletal-animation/data-pool-manager'; +import '../cocos/core/animation'; const canvas = document.createElement('canvas'); const div = document.createElement('div'); diff --git a/tests/setup-after-env.ts b/tests/setup-after-env.ts index 0d9770c2ae..a09d735b8d 100644 --- a/tests/setup-after-env.ts +++ b/tests/setup-after-env.ts @@ -1,3 +1,8 @@ // @ts-ignore import * as matchers from 'jest-extended'; expect.extend(matchers); + +const testPath = expect.getState().testPath; +if (testPath.match(/animation/)) { + require('../cocos/core/animation'); +}