Edit in JSFiddle

try {
  var canvas = document.getElementById('cube');

  // Start and init Application
  var app = new pc.Application(canvas);
  app.start();
  app.setCanvasFillMode(pc.FILLMODE_FILL_WINDOW);
  app.setCanvasResolution(pc.RESOLUTION_AUTO);

  // Create camera
  var camera = new pc.Entity();
  camera.addComponent("camera", {
    clearColor: new pc.Color(0.8, 0.8, 0.8)
  });
  app.root.addChild(camera);
  camera.setPosition(0, 0, 7);

  // Create cube
  var cube = new pc.Entity();
  cube.addComponent("model", {
    type: "box"
  });
  app.root.addChild(cube);
  cube.rotate(10, 15, 0);


  // Create light
  var light = new pc.Entity();
  light.addComponent('light');
  light.rotate(45, 0, 0);
  app.root.addChild(light);
  app.scene.ambientLight = new pc.Color(0.2, 0.2, 0.2);

  // Create cube's material
  var boxMaterial = new pc.PhongMaterial();
  boxMaterial.diffuse.set(0, 0.58, 0.86);
  boxMaterial.update();
  cube.model.model.meshInstances[0].material = boxMaterial;

  var timer = 0;
  app.on("update", function(deltaTime) {
    timer += deltaTime;
    cube.rotate(deltaTime * 10, deltaTime * 20, deltaTime * 3);
    cube.setPosition(2, Math.sin(timer * 2), 0);
    cube.setLocalScale(1, Math.abs(Math.sin(timer)), 1);
  });
} catch(e){
	alert(e.message);
}
<canvas id="cube"></canvas>
body {
  margin: 0;
  padding: 0;
}