window.onload = function() { 'use strict'; // create a Scene var scn = new DivSugar.Scene().setSize(800, 600).setImage('#d0d0d0').appendTo(document.body); // maximize the Scene size function resize() { scn.adjustLayout(window.innerWidth, window.innerHeight, 'contain'); } window.addEventListener('resize', resize, true); resize(); // create the root Node and an animation Task to rotate the whole Scene var root = new DivSugar.Node().setPosition(400, 300, 0).rotate(-50, 0, 0).appendTo(scn); var task = new DivSugar.Task().appendTo(DivSugar.rootTask); task.onUpdate = function() { root.rotate(0, this.deltaTime * 0.02, this.deltaTime * 0.015); }; // Define a 3D object class which refrects light and has a text billboard var mat = new DivSugar.Matrix(); var lightDir = new DivSugar.Vector(1, 1, -2).normalize(); function Monolith(name, x, z) { this.constructor.uber.constructor(); this.faces = []; this.colors = []; this.center = new DivSugar.Node().setPosition(x, 0, z).setOpacity(0.6).rotate(0, Math.random() * 360, 0).appendTo(root); for (var i = 0; i < 6; i++) { this.faces[i] = new DivSugar.Node().setImage('#00ff00').appendTo(this.center); } var sx = Math.random() * 30 + 30; var sy = Math.random() * 100 + 50; var sz = Math.random() * 30 + 30; this.faces[0].setSize(sx, sy).setPosition(-sx / 2, -sy / 2, sz / 2); this.faces[1].setSize(sz, sy).setPosition(sx / 2, -sy / 2, sz / 2).rotate(0, 90, 0); this.faces[2].setSize(sx, sy).setPosition(sx / 2, -sy / 2, -sz / 2).rotate(0, 180, 0); this.faces[3].setSize(sz, sy).setPosition(-sx / 2, -sy / 2, -sz / 2).rotate(0, 270, 0); this.faces[4].setSize(sx, sz).setPosition(-sx / 2, -sy / 2, -sz / 2).rotate(90, 0, 0); this.faces[5].setSize(sx, sz).setPosition(-sx / 2, sy / 2, sz / 2).rotate(-90, 0, 0); this.label = new DivSugar.Node().setSize(100, 0).appendTo(scn); this.label.div.innerHTML = '