Fetching contributors…
Cannot retrieve contributors at this time
56 lines (45 sloc) 1.85 KB
<!DOCTYPE html>
CubicVR.js: CubicVR XML Mesh loader test
<script src="../../CubicVR.js" type="text/javascript">
<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 ship model (main ship file from Flight of the Navigator demo)
var shipMesh = new CubicVR.loadMesh("ship-main.xml");
// remove unused data
// New scene with our canvas dimensions and default camera with FOV 70
var scene = new CubicVR.Scene(canvas.width, canvas.height, 70);
// Add a simple directional light
scene.bind(new CubicVR.Light({type:"directional",specular:[1,1,1],direction:CubicVR.vec3.normalize([0.5,-1,0.5])}));
// SceneObject container for the mesh
var shipObject = new CubicVR.SceneObject(shipMesh);
// Add SceneObject containing the mesh to the scene
// set initial camera position and target = [8, 8, 5]; = [0, 0, 0];
// 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) {
<body onLoad="webGLStart();"></body>