1
0
Fork 0

fix(noble): Don't check var prior to initialization

This commit is contained in:
Joost De Cock 2022-06-22 09:32:12 +02:00
parent ab38837816
commit 79f477854b

View file

@ -31,44 +31,48 @@ export default function (part) {
delete points.__scaleboxMetric delete points.__scaleboxMetric
delete points.bustDartLeft delete points.bustDartLeft
delete points.bustDartLeftCp delete points.bustDartLeftCp
points.shoulderDart = points.hps.shiftFractionTowards( points.shoulder, options.shoulderDartPosition ) points.shoulderDart = points.hps.shiftFractionTowards( points.shoulder, options.shoulderDartPosition )
let aUp = points.dartTip.angle( points.shoulderDart ) let aUp = points.dartTip.angle( points.shoulderDart )
let aDown = points.dartBottomRight.angle( points.dartTip ) let aDown = points.dartBottomRight.angle( points.dartTip )
let aDiff = Math.abs( aUp - aDown ) let aDiff = Math.abs( aUp - aDown )
// let dartCpAdjustment = Math.abs( options.shoulderDartPosition -.5) +.05 // let dartCpAdjustment = Math.abs( options.shoulderDartPosition -.5) +.05
let dartCpAdjustment = aDiff /50 let dartCpAdjustment = aDiff /50
points.shoulderDartCpUp = points.shoulderDart.shiftFractionTowards( points.dartTip, 1 - dartCpAdjustment) points.shoulderDartCpUp = points.shoulderDart.shiftFractionTowards( points.dartTip, 1 - dartCpAdjustment)
points.shoulderDartCpDown = points.shoulderDart.shiftFractionTowards( points.dartTip, 1 +dartCpAdjustment ) points.shoulderDartCpDown = points.shoulderDart.shiftFractionTowards( points.dartTip, 1 +dartCpAdjustment )
let iLength = (new Path() const length = {
.move(points.dartBottomLeft) i: new Path()
.curve(points.dartLeftCp, points.shoulderDartCpDown, points.dartTip) .move(points.dartBottomLeft)
.curve(points.shoulderDartCpUp, points.shoulderDart, points.shoulderDart)).length(); .curve(points.dartLeftCp, points.shoulderDartCpDown, points.dartTip)
.curve(points.shoulderDartCpUp, points.shoulderDart, points.shoulderDart)
.length()
}
let iteration = 0 let iteration = 0
let diff = 0 let diff = 0
let angle = 0 let angle = 0
do { do {
angle = diff*( oLength > iLength ? -.1 : .1 ) if (length?.o) angle = diff*( length.o > length.i ? -.1 : .1 )
points.dartBottomRight = points.dartBottomRight.rotate( angle, points.waistSide ) points.dartBottomRight = points.dartBottomRight.rotate( angle, points.waistSide )
let oLength = (new Path() length.o = new Path()
.move(points.shoulderDart) .move(points.shoulderDart)
.curve(points.shoulderDart, points.shoulderDartCpUp, points.dartTip) .curve(points.shoulderDart, points.shoulderDartCpUp, points.dartTip)
.curve(points.shoulderDartCpDown, points.dartRightCp, points.dartBottomRight)).length(); .curve(points.shoulderDartCpDown, points.dartRightCp, points.dartBottomRight)
.length()
diff = oLength -iLength diff = length.o - length.i
iteration ++ iteration ++
} while( diff < -.5 || diff > .5 && iteration < 100 ) } while( diff < -.5 || diff > .5 && iteration < 100 )
if( iteration >= 100 ) { if( iteration >= 100 ) {
raise.error('Something is not quite right here!') raise.error('Something is not quite right here!')
} }
return part return part
} }