Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 57 lines (50 sloc) 1.816 kB
b84ce56 @cjcliffe Sandbox updates, shader syntax patch, sample formatting and doctype c…
authored
1 <!DOCTYPE html>
76840b7 @cjcliffe Updated samples to use CubicVR.MainLoop(), added generic MouseViewCon…
authored
2 <html>
b84ce56 @cjcliffe Sandbox updates, shader syntax patch, sample formatting and doctype c…
authored
3 <head>
4 <title>
5 CubicVR.js: Basic Texured Cube /w Scene and MouseViewController
6 </title>
7 <script src="../../CubicVR.js" type="text/javascript">
8 </script>
9 <script type='text/javascript'>
10 function webGLStart(gl,canvas) {
11 // Add a box to mesh, size 1.0, apply material and UV parameters
12 var boxMesh = new CubicVR.Mesh({
13 primitive: {
14 type: "box",
15 size: 1.0,
16 material: {
17 textures: {
18 color: "../images/6583-diffuse.jpg",
19 bump: "../images/6583-bump.jpg"
20 }
21 },
22 uv: {
23 projectionMode: "cubic",
24 scale: [1, 1, 1]
76840b7 @cjcliffe Updated samples to use CubicVR.MainLoop(), added generic MouseViewCon…
authored
25 }
b84ce56 @cjcliffe Sandbox updates, shader syntax patch, sample formatting and doctype c…
authored
26 },
27 compile: true
28 });
29
30 // New scene with our canvas dimensions and default camera with FOV 80
31 var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
32
33 // SceneObject container for the mesh
34 var boxObject = new CubicVR.SceneObject(boxMesh);
35
36 // Add SceneObject containing the mesh to the scene
37 scene.bind(boxObject);
38
39 // set initial camera position and target
40 scene.camera.position = [1, 1, 1];
41 scene.camera.target = [0, 0, 0];
42
43 // Add our scene to the window resize list
44 CubicVR.addResizeable(scene);
45
46 // Start our main drawing loop, it provides a timer and the gl context as parameters
47 CubicVR.MainLoop(function(timer, gl) {
48 scene.render();
49 });
50
51 // initialize a mouse view controller
52 mvc = new CubicVR.MouseViewController(canvas, scene.camera);
53 }
54 </script>
55 </head>
56 <body onLoad="CubicVR.start('auto',webGLStart);"></body>
57 </html>
Something went wrong with that request. Please try again.