Last active
August 29, 2015 14:25
-
-
Save GraemeFulton/b056c781c3aaf4898725 to your computer and use it in GitHub Desktop.
Two pieces of terrain
This file contains 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 | |
//to put the camera in the middle of three bits of terrain, z= 5 | |
for ( var z= -5; z > -200; z-=100 ) { | |
//Create the perlin noise for the surface of the ground | |
var perlinSurface = new PerlinSurface(perlinNoise); | |
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