Skip to content

Scene

API

Scene

const scene = new BABYLON.Scene(engine);
// 设置场景背景色
scene.clearColor = new BABYLON.Color4(84 / 255, 84 / 255, 84 / 255, 1);
// 设置环境色
scene.ambientColor = new BABYLON.Color4(84 / 255, 84 / 255, 84 / 255, 1);

事件

所有事件可参考 Scene#constructor1 文档

生命周期

// 渲染前事件
scene.onBeforeRenderObservable.add(() => {});
// 渲染后事件
scene.onAfterRenderObservable.add(() => {});

鼠标事件

// 鼠标的所有事件,包含点击,移动等等
scene.onPointerObservable.add((pointerInfo) => {});
// 点击
scene.onPointerPick = () => {};
scene.onPointerUp = () => {};
scene.onPointerDown = () => {};
scene.onPointerMove = () => {};

键盘事件

scene.onPreKeyboardObservable.add(() => {});
scene.onKeyboardObservable.add(() => {});

参考

Footnotes

  1. Scene#constructor