-
Notifications
You must be signed in to change notification settings - Fork 103
/
collada_duck.html
59 lines (45 loc) · 2.21 KB
/
collada_duck.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>
CubicVR.js: Using a COLLADA model from a .dae file
</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;
};
// New scene with our canvas dimensions and default camera with FOV 80
var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
// load the collada file, specify path for images
var colladaScene = CubicVR.loadCollada("Duck/duck_triangulate.dae","Duck/");
// need to know it's name in the default scene
var duckMesh = colladaScene.getSceneObject("LOD3sp").obj;
// SceneObject container for the mesh
var duckObject = new CubicVR.SceneObject(duckMesh);
// Add SceneObject containing the mesh to the scene
scene.bindSceneObject(duckObject);
// set initial camera position and target
scene.camera.position = [100, 100, 100];
scene.camera.target = [0, 70, 0];
// Add a simple directional light
scene.bindLight(new CubicVR.Light({type:CubicVR.enums.light.type.DIRECTIONAL,specular:[1,1,1],direction:CubicVR.vec3.normalize([-0.2,-1,-0.5])}));
// 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>