Fetching contributors…
Cannot retrieve contributors at this time
50 lines (39 sloc) 1.51 KB
<!DOCTYPE html>
CubicVR.js: Basic Primitives /w Predefined UVMappers
<script src="../../CubicVR.js" type="text/javascript"></script>
<script type='text/javascript'>
function webGLStart() {
// by default generate a full screen canvas with automatic resize
var gl = CubicVR.init();
var canvas = CubicVR.getCanvas();
if (!gl) {
alert("Sorry, no WebGL support.");
// load scene from XML constructor
var scene = new CubicVR.Scene("scene1.xml");
scene.resize(canvas.width, canvas.height);
// remove ad-hoc cached JSON and Classes from memory
// initialize a mouse view controller
mvc = new CubicVR.MouseViewController(canvas,;
// Add our scene to the window resize list
// Start our main drawing loop, it provides a timer and the gl context as parameters
CubicVR.MainLoop(function(timer, gl) {
var lus = timer.getLastUpdateSeconds();
for (var i = 0; i < scene.sceneObjects.length; i++) {
scene.sceneObjects[i].rotation[0] += lus*2.0+0.1*(i+1);
scene.sceneObjects[i].rotation[2] += lus*2.5+0.2*(i+1);
<body onLoad="webGLStart();"></body>