Cube in Babylon.js

Babylon.js Hispano

by realhunts

HTML

<!-- Babylon.js -->
        <script src="https://preview.babylonjs.com/babylon.js"></script>
<canvas id="main"></canvas>

CSS

html, body, canvas{
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

JavaScript

var canvas = document.getElementById("main");
var engine = new BABYLON.Engine(canvas);
var scene = new BABYLON.Scene(engine);
scene.clearColor = new BABYLON.Color3(0.6,0.6,0.6);

function renderLoop(){
 box.rotation.x += 0.01;
 box.rotation.y += 0.01;
 scene.render();
}
engine.runRenderLoop(renderLoop);

var camera = new BABYLON.FreeCamera("camera", new BABYLON.Vector3(0,0,-10),scene);

var light = new BABYLON.PointLight("light", new BABYLON.Vector3(10,10,0),scene);

var box = new BABYLON.Mesh.CreateBox("box",2,scene);
box.rotation.x = -0.2;
box.rotation.y = -0.4;
box.material = new BABYLON.StandardMaterial("material",scene);
box.material.emmisiveColor = new BABYLON.Color3(0, 0.58, 0.86);