JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://www.babylonjs.com/babylon.js"></script>
<canvas id="canvas"></canvas>
CSS
html, body, #canvas {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
overflow: hidden;
background-color: black;
}
#canvas {
position: absolute;
left: 0;
top: 0;
}
JavaScript
BABYLON.Engine.ShadersRepository = "/Babylon/Shaders/";
var canvas = document.getElementById("canvas");
// Check support
if (!BABYLON.Engine.isSupported()) {
alert('Browser not supported');
} else {
var engine = new BABYLON.Engine(canvas, true);
var scene = CreateScene();
engine.runRenderLoop(function () {
scene.render();
});
// Resize event
window.addEventListener("resize", function () {
engine.resize();
});
}
// -------- Create Scene ---------
function CreateScene() {
var scene = new BABYLON.Scene(engine);
var camera1 = new BABYLON.ArcRotateCamera("Camera1", 0, 0, 10, BABYLON.Vector3.Zero(), scene);
camera1.attachControl(canvas);
// a Light
var light = new BABYLON.PointLight("hemi", new BABYLON.Vector3(2, 10, 2), scene);
light.diffuse = new BABYLON.Color3(1, 1, 1);
light.specular = new BABYLON.Color3(1, 1, 0);
// Create Main Meshes
var aBox = BABYLON.Mesh.CreateBox("aBox", 1, scene);
return scene;
}