Skip to content

Commit

Permalink
Made misc devicecontrols example WebGL only.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Mar 14, 2014
1 parent 9256546 commit 56316d3
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions examples/misc_controls_deviceorientation.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,17 @@
(function() {
"use strict"

var hasWebGL = (function() {
try {
var canvas = document.createElement( 'canvas' );
return !! window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) );
} catch( e ) {
return false;
}
})();

window.addEventListener('load', function() {

var container, camera, scene, renderer, controls, geometry, mesh;

var animate = function(){
controls.update();
renderer.render(scene, camera);

window.requestAnimationFrame(animate);
window.requestAnimationFrame( animate );

controls.update();
renderer.render(scene, camera);

};

container = document.getElementById( 'container' );
Expand All @@ -75,26 +68,30 @@
geometry.applyMatrix( new THREE.Matrix4().makeScale( -1, 1, 1 ) );

var material = new THREE.MeshBasicMaterial( {
//map: THREE.ImageUtils.loadTexture( 'textures/2294472375_24a3b8ef46_o.jpg' )
wireframe: true
map: THREE.ImageUtils.loadTexture( 'textures/2294472375_24a3b8ef46_o.jpg' )
} );

var mesh = new THREE.Mesh( geometry, material );
scene.add(mesh);
scene.add( mesh );

renderer = hasWebGL ? new THREE.WebGLRenderer() : new THREE.CanvasRenderer( { devicePixelRatio: 1 } );
var geometry = new THREE.BoxGeometry( 100, 100, 100, 4, 4, 4 );
var material = new THREE.MeshBasicMaterial( { color: 0xff00ff, side: THREE.BackSide, wireframe: true } );
var mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );

renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.domElement.style.position = 'absolute';
renderer.domElement.style.top = 0;
container.appendChild(renderer.domElement);

var resizeWindow = function() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
};
window.addEventListener('resize', function() {

camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );

window.addEventListener('resize', resizeWindow, false);
}, false);

controls.connect();

Expand Down

0 comments on commit 56316d3

Please sign in to comment.