From 2f1c6da5e1ee1dc52232f3c202a1d12511815232 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Tue, 28 Nov 2017 15:42:25 +0100 Subject: [PATCH] move function --- src/shape/shapeToPoints.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/shape/shapeToPoints.js b/src/shape/shapeToPoints.js index e2863b0..bcfc049 100644 --- a/src/shape/shapeToPoints.js +++ b/src/shape/shapeToPoints.js @@ -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);