Permalink
Fetching contributors…
Cannot retrieve contributors at this time
73 lines (65 sloc) 2.19 KB
<!DOCTYPE html>
<html>
<head>
<title>
CubicVR.js: Simple Spherical UVMapper application
</title>
<script src="../../CubicVR.js" type="text/javascript">
</script>
<script type='text/javascript'>
function webGLStart(gl,canvas) {
// New scene with our canvas dimensions and default camera with FOV 80
var scene = new CubicVR.Scene(canvas.width, canvas.height, 80);
var light = new CubicVR.Light({
type: "point",
method: "dynamic",
diffuse:[1,1,1],
specular:[1,1,1],
position:[0,5,2],
distance:20
});
scene.bind(light);
var sphereMesh = new CubicVR.Mesh({
primitive: {
type: "sphere",
radius: 0.5,
lat: 24,
lon: 24,
material: {
color: [80/255, 200/255, 120/255],
specular:[1,1,1],
shininess: 0.9,
env_amount: 1.0,
textures: {
color: "../images/2576-diffuse.jpg",
normal: "../images/2576-normal.jpg",
bump: "../images/2576-bump.jpg",
envsphere: "../images/fract_reflections.jpg"
}
},
uv: {
projectionMode: "spherical",
projectionAxis: "y",
wrapW: 5,
wrapH: 2.5
}
},
compile: true
});
scene.bind(new CubicVR.SceneObject({mesh:sphereMesh, position:[0,0,0], scale:[2,2,2]}));
// set initial camera position and target
scene.camera.position = [0, 0, 2];
scene.camera.target = [0, 0, 0];
// initialize a mouse view controller
mvc = new CubicVR.MouseViewController(canvas, scene.camera);
// 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();
});
}
</script>
</head>
<body onLoad="CubicVR.start('auto',webGLStart);"></body>
</html>