Created
November 18, 2015 16:59
-
-
Save deathbearbrown/9d89d815e1a663b39e6e to your computer and use it in GitHub Desktop.
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
//---------------------------------------------------------------------------- | |
// createAGrid | |
// | |
// opts | |
// { | |
// height: width, | |
// width: depth, | |
// linesHeight: b, | |
// linesWidth: c, | |
// color: 0xcccccc | |
// } | |
// | |
//____________________________________________________________________________ | |
function createAGrid(opts){ | |
var config = opts || { | |
height: 500, | |
width: 500, | |
linesHeight: 10, | |
linesWidth: 10, | |
color: 0xDD006C | |
}; | |
var material = new THREE.LineBasicMaterial({ | |
color: config.color, | |
opacity: 0.2 | |
}); | |
var gridObject = new THREE.Object3D(), | |
gridGeo= new THREE.Geometry(), | |
stepw = 2*config.width/config.linesWidth, | |
steph = 2*config.height/config.linesHeight; | |
//width | |
for ( var i = - config.width; i <= config.width; i += stepw ) { | |
gridGeo.vertices.push( new THREE.Vector3( - config.height, i,0 ) ); | |
gridGeo.vertices.push( new THREE.Vector3( config.height, i,0 ) ); | |
} | |
//height | |
for ( var i = - config.height; i <= config.height; i += steph ) { | |
gridGeo.vertices.push( new THREE.Vector3( i,- config.width,0 ) ); | |
gridGeo.vertices.push( new THREE.Vector3( i, config.width, 0 ) ); | |
} | |
var line = new THREE.Line( gridGeo, material, THREE.LinePieces ); | |
gridObject.add(line); | |
return gridObject; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment