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">
<html>
<head>
<title>
CubicVR.js: Basic Texured Cube /w Scene and MouseViewController
</title>
<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.");
return;
};
// 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 = CubicVR.primitives.box({
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
boxMesh.prepare();
// 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
scene.bindSceneObject(boxObject);
// set initial camera position and target
scene.camera.position = [1, 1, 1];
scene.camera.target = [0, 0, 0];
// Add our scene to the window resize list
CubicVR.addResizeable(scene);
// Start our main drawing loop, it provides a timer and the gl context as parameters
CubicVR.MainLoop(function(timer, gl) {
scene.render();
});
// initialize a mouse view controller
mvc = new CubicVR.MouseViewController(canvas, scene.camera);
}
</script>
</head>
<body onLoad="webGLStart();"></body>
</html>
Jump to Line
Something went wrong with that request. Please try again.