Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
72 lines (57 sloc) 2.55 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
CubicVR.js: Basic Texured Cube /w Scene and MouseViewController
<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.");
// Create a material for the mesh
var boxMaterial = new CubicVR.Material({
textures: {
color: new CubicVR.Texture("../images/6583-diffuse.jpg"),
bump: new CubicVR.Texture("../images/6583-bump.jpg")
// Add a box to mesh, size 1.0, apply material and UV parameters
var boxMesh ={
size: 1.0,
material: boxMaterial,
uvmapper: {
projectionMode: CubicVR.enums.uv.projection.CUBIC,
scale: [1, 1, 1]
// triangulate and buffer object to GPU, remove unused data
// New scene with our canvas dimensions and default camera with FOV 80
var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
// SceneObject container for the mesh
var boxObject = new CubicVR.SceneObject(boxMesh);
// Add SceneObject containing the mesh to the scene
// set initial camera position and target = [1, 1, 1]; = [0, 0, 0];
// 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) {
// initialize a mouse view controller
mvc = new CubicVR.MouseViewController(canvas,;
<body onLoad="webGLStart();"></body>
Jump to Line
Something went wrong with that request. Please try again.