move function

This commit is contained in:
casperlamboo 2017-11-28 15:42:25 +01:00
parent 0acda53661
commit 2f1c6da5e1
1 changed files with 6 additions and 5 deletions

View File

@ -9,6 +9,12 @@ import { SHAPE_CACHE_LIMIT } from '../constants/general.js';
import { createText } from '../utils/textUtils.js';
import { segmentBezierPath } from '../utils/curveUtils.js';
const setDirection = (clockwise) => (path) => {
return (THREE.ShapeUtils.isClockWise(path) === clockwise) ? path : path.reverse();
};
const setDirectionClockWise = setDirection(true);
const setDirectionCounterClockWise = setDirection(false);
const HEART_BEZIER_PATH = [
new Vector(0.0, -0.5),
new Vector(0.1, -1.1),
@ -203,11 +209,6 @@ function shapeToPointsRaw(shapeData) {
// make sure all shapes are clockwise and all holes are counter-clockwise
if (shapeData.fill) {
const setDirection = (clockwise) => (path) => {
return (THREE.ShapeUtils.isClockWise(path) === clockwise) ? path : path.reverse();
};
const setDirectionClockWise = setDirection(true);
const setDirectionCounterClockWise = setDirection(false);
for (const shape of shapes) {
shape.points = setDirectionClockWise(shape.points);
shape.holes = shape.holes.map(setDirectionCounterClockWise);