fix(animation): stabilize animator coverage path

This commit is contained in:
luzhuang
2026-06-15 19:42:53 +08:00
parent aa541bdbea
commit c975875dee
3 changed files with 15 additions and 8 deletions

View File

@@ -322,7 +322,9 @@ export class Animator extends Component {
_reset(): void {
const layersData = this._animatorLayersData;
for (let i = 0, n = layersData.length; i < n; i++) {
const stateDataList = layersData[i].stateDataList;
const layerData = layersData[i];
if (!layerData) continue;
const stateDataList = layerData.stateDataList;
for (let j = 0, m = stateDataList.length; j < m; j++) {
const layerOwners = stateDataList[j].curveLayerOwner;
for (let k = 0, l = layerOwners.length; k < l; k++) {

View File

@@ -21,7 +21,7 @@ import {
import "@galacean/engine-loader";
import type { GLTFResource } from "@galacean/engine-loader";
import { Quaternion } from "@galacean/engine-math";
import { WebGLEngine } from "@galacean/engine-rhi-webgl";
import { WebGLEngine } from "@galacean/engine";
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from "vitest";
import { glbResource } from "./model/fox";
const canvasDOM = document.createElement("canvas");
@@ -58,8 +58,8 @@ describe("Animator test", function () {
});
afterAll(function () {
animator.destroy();
engine.destroy();
animator?.destroy();
engine?.destroy();
});
afterEach(function () {
@@ -1446,7 +1446,7 @@ describe("Animator test", function () {
animator.engine.time._frameCount++;
animator.update(preExitDeltaTime);
expect(layerData.srcPlayData.state.name).to.eq("Walk");
expect(layerData.destPlayData.state).to.be.undefined;
expect(layerData.destPlayData).to.be.null;
// Update past exitTime, should transition to Run.
// @ts-ignore

View File

@@ -1,8 +1,8 @@
import { Animator, Camera } from "@galacean/engine-core";
import "@galacean/engine-loader";
import type { GLTFResource } from "@galacean/engine-loader";
import { WebGLEngine } from "@galacean/engine-rhi-webgl";
import { beforeAll, describe, expect, it } from "vitest";
import { WebGLEngine } from "@galacean/engine";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { glbResource } from "./model/fox";
const canvasDOM = document.createElement("canvas");
@@ -11,9 +11,10 @@ canvasDOM.height = 1024;
describe("Canvas 1024 test", function () {
let animator: Animator;
let engine: WebGLEngine;
beforeAll(async function () {
const engine = await WebGLEngine.create({ canvas: canvasDOM });
engine = await WebGLEngine.create({ canvas: canvasDOM });
const scene = engine.sceneManager.activeScene;
const rootEntity = scene.createRootEntity();
rootEntity.addComponent(Camera);
@@ -23,6 +24,10 @@ describe("Canvas 1024 test", function () {
animator = defaultSceneRoot.getComponent(Animator);
});
afterAll(function () {
engine?.destroy();
});
it("loaded", () => {
expect(animator).not.eq(null);
});