Created
July 25, 2015 20:00
-
-
Save GraemeFulton/f33349c6dcd9c995ca84 to your computer and use it in GitHub Desktop.
Three bits of terrain, camera starts in centre
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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