Discovered a helpful solution over at Bocoup:
function generateGrid(options) {
var settings = options || {
height: 500,
width: 500,
linesHeight: 10,
linesWidth: 10,
color: 0xDD006C
};
var material = new THREE.LineBasicMaterial({
color: settings.color,
opacity: 0.2
});
var gridObj = new THREE.Object3D(),
gridGeometry = new THREE.Geometry(),
stepWidth = 2 * settings.width / settings.linesWidth,
stepHeight = 2 * settings.height / settings.linesHeight;
// Generate grid lines for width
for (var i = -settings.width; i <= settings.width; i += stepWidth) {
gridGeometry.vertices.push(new THREE.Vector3(-settings.height, i, 0));
gridGeometry.vertices.push(new THREE.Vector3(settings.height, i, 0));
}
// Generate grid lines for height
for (var i = -settings.height; i <= settings.height; i += stepHeight) {
gridGeometry.vertices.push(new THREE.Vector3(i, -settings.width, 0));
gridGeometry.vertices.push(new THREE.Vector3(i, settings.width, 0));
}
var line = new THREE.Line(gridGeometry, material, THREE.LinePieces);
gridObj.add(line);
return gridObj;
}
However, it was necessary to modify
var line = new THREE.Line(gridGeometry, material, THREE.LinePieces);
(deprecated) to
var line = new THREE.LineSegments(gridGeometry, material);