Skip to content

Instantly share code, notes, and snippets.

@jsermeno
Created May 22, 2011 21:15
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jsermeno/985901 to your computer and use it in GitHub Desktop.
Save jsermeno/985901 to your computer and use it in GitHub Desktop.
var
camera,
scene,
renderer;
function initialize() {
var
grass,
meshCanvas,
plane,
i, j, uvs;
camera = new THREE.Camera( 3, window.innerWidth / window.innerHeight, -2000, 10000 );
camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 2000, 10000 );
camera.position.x = 100;
camera.position.y = 70.711; // 30 degree angle from the xz plane
camera.position.z = 100;
scene = new THREE.Scene();
grass = THREE.ImageUtils.loadTexture( "textures/grass.gif" );
grass.wrapT = grass.wrapS = THREE.RepeatWrapping;
plane = new THREE.PlaneGeometry(8, 8, 8, 8);
for ( i = 0; i < plane.faceVertexUvs[ 0 ].length; i ++ ) {
uvs = plane.faceVertexUvs[ 0 ][ i ];
for ( j = 0; j < uvs.length; j ++ ) {
uvs[ j ].u *= 8;
uvs[ j ].v *= 8;
}
}
meshCanvas = new THREE.Mesh( plane, new THREE.MeshBasicMaterial( { map: grass, wireframe: false } ));
meshCanvas.rotation.x = -90 * Math.PI / 180;
meshCanvas.scale.x = meshCanvas.scale.y = meshCanvas.scale.z = 100;
scene.addChild( meshCanvas );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild(renderer.domElement);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment