Files
engine/e2e/case/material-pbr.ts
luzhuang 8541659337 Optimize the e2e test framework (#1973)
* feat: opt e2e test framework
2024-01-17 11:10:12 +08:00

47 lines
1.5 KiB
TypeScript

/**
* @title PBR Base
* @category Material
*/
import { AmbientLight, AssetType, Camera, DirectLight, GLTFResource, Vector3, WebGLEngine } from "@galacean/engine";
import { initScreenshot, updateForE2E } from "./.mockForE2E";
// Create engine
WebGLEngine.create({ canvas: "canvas" }).then((engine) => {
engine.canvas.resizeByClientSize();
const scene = engine.sceneManager.activeScene;
const rootEntity = scene.createRootEntity();
const directLightNode = rootEntity.createChild("dir_light");
const directLight = directLightNode.addComponent(DirectLight);
directLight.intensity = 0.5;
directLightNode.transform.setPosition(5, 5, 5);
directLightNode.transform.lookAt(new Vector3(0, 0, 0));
//Create camera
const cameraNode = rootEntity.createChild("camera_node");
cameraNode.transform.position = new Vector3(0, 5, 20);
const camera = cameraNode.addComponent(Camera);
Promise.all([
engine.resourceManager
.load<GLTFResource>("https://gw.alipayobjects.com/os/bmw-prod/7c7b887c-05d6-43dd-b354-216e738e81ed.gltf")
.then((gltf) => {
const { defaultSceneRoot } = gltf;
rootEntity.addChild(defaultSceneRoot);
}),
engine.resourceManager
.load<AmbientLight>({
type: AssetType.Env,
url: "https://gw.alipayobjects.com/os/bmw-prod/89c54544-1184-45a1-b0f5-c0b17e5c3e68.bin"
})
.then((ambientLight) => {
scene.ambientLight = ambientLight;
})
]).then(() => {
updateForE2E(engine);
initScreenshot(engine, camera);
});
});