Skip to content

Commit

Permalink
Fix animation sholud reset when reenabled (#2252)
Browse files Browse the repository at this point in the history
* fix: animation sholud reset when reenabled
  • Loading branch information
luzhuang authored Jul 22, 2024
1 parent 4a498cd commit fcaf1af
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
38 changes: 38 additions & 0 deletions e2e/case/animator-play-beforeActive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @title Animation Play
* @category Animation
*/
import { Animator, Camera, DirectLight, GLTFResource, Logger, Vector3, WebGLEngine } from "@galacean/engine";
import { OrbitControl } from "@galacean/engine-toolkit";
import { initScreenshot, updateForE2E } from "./.mockForE2E";

Logger.enable();
WebGLEngine.create({ canvas: "canvas" }).then((engine) => {
engine.canvas.resizeByClientSize(2);
const scene = engine.sceneManager.activeScene;
const rootEntity = scene.createRootEntity();

// camera
const cameraEntity = rootEntity.createChild("camera_node");
cameraEntity.transform.position = new Vector3(0, 1, 5);
const camera = cameraEntity.addComponent(Camera);
cameraEntity.addComponent(OrbitControl).target = new Vector3(0, 1, 0);

const lightNode = rootEntity.createChild("light_node");
lightNode.addComponent(DirectLight).intensity = 0.6;
lightNode.transform.lookAt(new Vector3(0, 0, 1));
lightNode.transform.rotate(new Vector3(0, 90, 0));
rootEntity.isActive = false;
engine.resourceManager
.load<GLTFResource>("https://gw.alipayobjects.com/os/bmw-prod/5e3c1e4e-496e-45f8-8e05-f89f2bd5e4a4.glb")
.then((gltfResource) => {
const { defaultSceneRoot } = gltfResource;
rootEntity.addChild(defaultSceneRoot);
const animator = defaultSceneRoot.getComponent(Animator);
animator.play("agree");
rootEntity.isActive = true;
updateForE2E(engine);

initScreenshot(engine, camera);
});
});
5 changes: 5 additions & 0 deletions e2e/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export const E2E_CONFIG = {
caseFileName: "animator-play",
threshold: 0.1
},
playBeforeActive: {
category: "Animator",
caseFileName: "animator-play-beforeActive",
threshold: 0.1
},
reuse: {
category: "Animator",
caseFileName: "animator-reuse",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions packages/core/src/animation/Animator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,7 @@ export class Animator extends Component {
* @internal
*/
override _onEnable(): void {
const layersData = this._animatorLayersData;
for (let i = 0, n = layersData.length; i < n; i++) {
layersData[i].layerState = LayerState.Standby;
}
this._reset();
this._entity.getComponentsIncludeChildren(Renderer, this._controlledRenderers);
}

Expand Down

0 comments on commit fcaf1af

Please sign in to comment.