";
document.getElementById('info').style.display = "block";
return;
}
}
function getHeightData(img)
{
var canvas = document.createElement( 'canvas' );
canvas.width = 128;
canvas.height = 128;
var context = canvas.getContext( '2d' );
var size = 128 * 128, data = new Float32Array( size );
context.drawImage(img,0,0);
for ( var i = 0; i < size; i ++ )
{
data[i] = 0
}
var imgd = context.getImageData(0, 0, 128, 128);
var pix = imgd.data;
var j=0;
for (var i = 0, n = pix.length; i < n; i += (4))
{
var all = pix[i]+pix[i+1]+pix[i+2];
data[j++] = all/30;
}
return data;
}
function getWireframeMaterial ()
{
return new THREE.MeshLambertMaterial( { color:0x231ad4, opacity: 0.65, shading: THREE.FlatShading } );
}
function getTerrainTexture ()
{
var terrainTexture = new THREE.MeshPhongMaterial( { map: new THREE.Texture(null, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping), ambient: 0xaaaaaa, specular: 0xffffff, shininess: 0, shading: THREE.SmoothShading } );
var img = new Image();
terrainTexture.map.image = img;
img.onload = function () {
terrainTexture.map.image.loaded = 1;
};
img.src = "terrain.jpg";
return terrainTexture;
}
function animate() {
requestAnimationFrame( animate );
loop();
}
function loop() {
var dist = 4000;
camera.position.x = dist*Math.cos(r);
camera.position.z = dist*Math.sin(r);
cubeMesh.position.y = FLOOR + 1500 - (Math.sin(r*5)*1000);
cubeMesh.position.x = 500 - (Math.cos(r*5)*1000);
cubeMesh.position.z = 500 - (Math.sin(r*5)*1000);
r -= 0.005;
if ( render_gl && has_gl )
{
webglRenderer.render( scene, camera );
}
}