Files
engine/e2e/case/gltf-blendshape.ts
luzhuang f728209255 fix(animation, loader): 从 #2983 抽离动画与 GLTF 加载器修复 (#2999)
* fix(animation): add per-instance speed to AnimatorStatePlayData
2026-05-18 16:54:15 +08:00

59 lines
1.8 KiB
TypeScript

/**
* @title Animation BlendShape
* @category Animation
*/
import * as dat from "dat.gui";
import {
Animator,
Camera,
DirectLight,
Logger,
SkinnedMeshRenderer,
SystemInfo,
Vector3,
WebGLEngine,
GLTFResource
} from "@galacean/engine";
import { initScreenshot, updateForE2E } from "./.mockForE2E";
Logger.enable();
WebGLEngine.create({ canvas: "canvas" }).then((engine) => {
engine.canvas.width = window.innerWidth * SystemInfo.devicePixelRatio;
engine.canvas.height = window.innerHeight * SystemInfo.devicePixelRatio;
const scene = engine.sceneManager.activeScene;
const rootEntity = scene.createRootEntity();
// camera
const cameraEntity = rootEntity.createChild("camera_node");
cameraEntity.transform.position = new Vector3(-30, 1, 0);
const camera = cameraEntity.addComponent(Camera);
cameraEntity.transform.lookAt(new Vector3(0, 0, 0));
cameraEntity.transform.lookAt(new Vector3(0, 1, 0));
const lightNode = rootEntity.createChild("light_node");
lightNode.addComponent(DirectLight).intensity = 1.0;
lightNode.transform.lookAt(new Vector3(0, 0, 1));
lightNode.transform.rotate(new Vector3(-45, -135, 0));
engine.resourceManager
.load<GLTFResource>(
"https://mdn.alipayobjects.com/oasis_be/afts/file/A*IEO8T642jMkAAAAAAAAAAAAADkp5AQ/0318导出.glb"
)
.then((asset) => {
const { defaultSceneRoot } = asset;
rootEntity.addChild(defaultSceneRoot);
const animator = defaultSceneRoot.getComponent(Animator)!;
// clipStartTime/clipEndTime are on the shared AnimatorState asset, not the per-Animator instance view.
const state = animator.animatorController.layers[0].stateMachine.findStateByName("Right");
state.clipStartTime = 1;
state.clipEndTime = 1;
animator.play("Right");
updateForE2E(engine);
initScreenshot(engine, camera);
});
});