move adeline to separate file

This commit is contained in:
casperlamboo 2016-03-29 08:15:30 +02:00 committed by Simon Voordouw
parent ed76a9f255
commit be77d6eeb5

View File

@ -1,12 +1,6 @@
import THREE from 'three.js'; import THREE from 'three.js';
export default function createLines(geometry, settings) { function addLine(geometry, lineLookup, lines, a, b) {
console.log('constructing unique lines from geometry');
var lines = [];
var lineLookup = {};
var addLine = (a, b) => {
var index = lineLookup[`${b}_${a}`]; var index = lineLookup[`${b}_${a}`];
if (index === undefined) { if (index === undefined) {
@ -23,6 +17,12 @@ export default function createLines(geometry, settings) {
return index; return index;
} }
export default function createLines(geometry, settings) {
console.log('constructing unique lines from geometry');
var lines = [];
var lineLookup = {};
for (var i = 0; i < geometry.faces.length; i ++) { for (var i = 0; i < geometry.faces.length; i ++) {
var face = geometry.faces[i]; var face = geometry.faces[i];
if (face.normal.y !== 1 && face.normal.y !== -1) { if (face.normal.y !== 1 && face.normal.y !== -1) {
@ -30,9 +30,9 @@ export default function createLines(geometry, settings) {
// check for only adding unique lines // check for only adding unique lines
// returns index of said line // returns index of said line
var a = addLine(face.a, face.b); var a = addLine(geometry, lineLookup, lines, face.a, face.b);
var b = addLine(face.b, face.c); var b = addLine(geometry, lineLookup, lines, face.b, face.c);
var c = addLine(face.c, face.a); var c = addLine(geometry, lineLookup, lines, face.c, face.a);
// set connecting lines (based on face) // set connecting lines (based on face)
lines[a].connects.push(b, c); lines[a].connects.push(b, c);