{
const getWidth = () => document.body.clientWidth;
const canvas = html`<canvas width=${getWidth()} height=400>`;
yield canvas;
const engine = new BABYLON.Engine(canvas, true);
const scene = new BABYLON.Scene(engine);
scene.clearColor = new BABYLON.Color3(0.8, 0.8, 0.8);
const camera = new BABYLON.ArcRotateCamera('camera', 0, 0, 3, new BABYLON.Vector3(0, 0, 0), scene);
if(ortho) {
camera.mode = camera.ORTHOGRAPHIC_CAMERA;
const rect = engine.getRenderingCanvasClientRect();
const aspect = rect.height / rect.width;
camera.orthoLeft = -camera.radius;
camera.orthoRight = camera.radius;
camera.orthoBottom = -camera.radius * aspect;
camera.orthoTop = camera.radius * aspect;
}
camera.lowerRadiusLimit = camera.upperRadiusLimit = camera.radius;
camera.attachControl(canvas, true);
const light = new BABYLON.PointLight('light', new BABYLON.Vector3(10, 10, 0), scene);
const boxMaterial = new BABYLON.StandardMaterial('material', scene);
boxMaterial.emissiveColor = new BABYLON.Color3(0, 0.58, 0.86);
const box = BABYLON.Mesh.CreateBox('box', 1, scene);
box.material = boxMaterial;
const renderLoop = () => {
box.rotation.x -= .013;
box.rotation.y += .007;
scene.render();
};
const onResize = () => {
canvas.width = getWidth();
engine.resize();
}
window.addEventListener('resize', onResize);
invalidation.then(() => {
window.removeEventListener('resize', onResize);
engine.dispose();
});
engine.runRenderLoop(renderLoop);
}