mirror of
https://github.com/galacean/engine.git
synced 2026-05-07 15:27:19 +08:00
56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
/**
|
|
* @title PBR Base
|
|
* @category Material
|
|
*/
|
|
import {
|
|
AmbientLight,
|
|
AssetType,
|
|
Camera,
|
|
Color,
|
|
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.color = new Color(0.21404114048223255, 0.21404114048223255, 0.21404114048223255, 1);
|
|
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);
|
|
});
|
|
});
|