store calculation in const

This commit is contained in:
casperlamboo 2017-05-19 10:49:26 +02:00
parent 93c9040170
commit 0d3ac6525c

View File

@ -1,6 +1,8 @@
import * as THREE from 'three.js'; import * as THREE from 'three.js';
import { PRECISION } from '../constants.js'; import { PRECISION } from '../constants.js';
const inversePrecision = 1 / PRECISION;
export default function removePrecision(slices) { export default function removePrecision(slices) {
console.log('remove precision'); console.log('remove precision');
@ -11,22 +13,22 @@ export default function removePrecision(slices) {
const part = slice.parts[i]; const part = slice.parts[i];
if (part.shape.closed) { if (part.shape.closed) {
part.outerLine.scaleDown(1 / PRECISION); part.outerLine.scaleDown(inversePrecision);
for (let i = 0; i < part.innerLines.length; i ++) { for (let i = 0; i < part.innerLines.length; i ++) {
const innerLine = part.innerLines[i]; const innerLine = part.innerLines[i];
innerLine.scaleDown(1 / PRECISION); innerLine.scaleDown(inversePrecision);
} }
part.fill.scaleDown(1 / PRECISION); part.fill.scaleDown(inversePrecision);
} else { } else {
part.shape.scaleDown(1 / PRECISION); part.shape.scaleDown(inversePrecision);
} }
} }
if (slice.support !== undefined) { if (slice.support !== undefined) {
slice.support.scaleDown(1 / PRECISION); slice.support.scaleDown(inversePrecision);
} }
if (slice.brim !== undefined) { if (slice.brim !== undefined) {
slice.brim.scaleDown(1 / PRECISION); slice.brim.scaleDown(inversePrecision);
} }
} }
} }