Skip to content

Instantly share code, notes, and snippets.

@GraemeFulton
Created July 25, 2015 20:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GraemeFulton/f33349c6dcd9c995ca84 to your computer and use it in GitHub Desktop.
Save GraemeFulton/f33349c6dcd9c995ca84 to your computer and use it in GitHub Desktop.
Three bits of terrain, camera starts in centre
/**
* createTerrainMatrix
* @TODO: create the matrix of terrains - need to add 9 bits of terrain
*/
createTerrainMatrix:function(scene, perlinNoise){
//every 100px on the z axis, add a bit of ground
for ( var z= 100; z > -200; z-=100 ) {
//Create the perlin noise for the surface of the ground
var perlinSurface = new PerlinSurface(perlinNoise, 100, 100);
var ground = perlinSurface.surface;
//rotate 90 degrees around the xaxis so we can see the terrain
ground.rotation.x = -Math.PI/-2;
// Then set the z position to where it is in the loop (distance of camera)
ground.position.z = z;
ground.position.y -=4;
//add the ground to the scene
scene.add(ground);
//finally push it to the floor array
this.floor.push(ground);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment