2018-09-04 16:51:39 +02:00
|
|
|
export function init(part) {
|
|
|
|
let {store, options, measurements, utils} = part.shorthand();
|
|
|
|
|
2018-09-06 18:34:42 +02:00
|
|
|
if(store.get('init') !== true) {
|
|
|
|
/* Set vertical scale to 1 (no stretch) */
|
|
|
|
store.set('yScale', 1);
|
|
|
|
|
|
|
|
/* Store rise, backRise and legBonus as absolute values */
|
|
|
|
store.set('rise', measurements.hipsToUpperLeg * options.rise * store.get('yScale'));
|
|
|
|
store.set('backRise', measurements.hipsToUpperLeg * options.backRise * store.get('yScale'));
|
|
|
|
store.set('sideRise', store.get('backRise') * 0.75);
|
|
|
|
store.set('frontRise', store.get('backRise') * 0.25);
|
|
|
|
store.set('legBonus', measurements.hipsToUpperLeg * options.legBonus * store.get('yScale'));
|
|
|
|
|
|
|
|
/* Set horizontal scale based on stretch */
|
|
|
|
store.set('xScale', utils.stretchToScale(options.stretch));
|
|
|
|
store.set('xScaleLegs', utils.stretchToScale(options.legStretch));
|
|
|
|
|
|
|
|
/* Ratio of parts at the hips*/
|
|
|
|
store.set('hips', measurements.hipsCircumference * store.get('xScale'));
|
|
|
|
store.set('hipsFront', store.get('hips') * options.hipRatioFront);
|
2018-09-07 16:35:37 +02:00
|
|
|
let hipRatioSide = (1 - (options.hipRatioFront + options.hipRatioBack)) / 2;
|
|
|
|
store.set('hipsSide', store.get('hips') * hipRatioSide);
|
2018-09-06 18:34:42 +02:00
|
|
|
store.set('hipsBack', store.get('hips') * options.hipRatioBack);
|
|
|
|
|
|
|
|
/* Ratio of parts at the legs*/
|
|
|
|
store.set('leg', measurements.upperLegCircumference * store.get('xScaleLegs'));
|
|
|
|
store.set('legInset', store.get('leg') * options.legRatioInset);
|
2018-09-07 16:35:37 +02:00
|
|
|
let legRatioSide = 1 - options.legRatioInset - options.legRatioBack;
|
|
|
|
store.set('legSide', store.get('leg') * legRatioSide);
|
|
|
|
store.set('legBack', store.get('leg') * options.legRatioBack);
|
2018-09-06 18:34:42 +02:00
|
|
|
|
|
|
|
/* Gusset */
|
|
|
|
store.set('gusset', measurements.hipsCircumference * options.gussetRatio);
|
|
|
|
store.set('gussetInsetRatio', options.gussetInsetRatio);
|
|
|
|
|
|
|
|
/* Length helper */
|
|
|
|
store.set('length', measurements.hipsToUpperLeg * store.get('yScale'));
|
|
|
|
store.set('riseLength', measurements.hipsToUpperLeg + store.get('rise'));
|
2018-09-21 12:57:23 +02:00
|
|
|
store.set('fullLength', store.get('riseLength') + store.get('legBonus') * store.get('yScale'));
|
2018-09-06 18:34:42 +02:00
|
|
|
|
|
|
|
/* Height ratio front/inset */
|
2018-09-21 12:57:23 +02:00
|
|
|
store.set('heightInset', store.get('riseLength') * options.heightRatioInset + store.get('legBonus') * store.get('yScale'));
|
2018-09-07 16:35:37 +02:00
|
|
|
store.set('heightFront', store.get('riseLength') * (1 - options.heightRatioInset));
|
2018-09-06 18:34:42 +02:00
|
|
|
|
|
|
|
/* Absolute amount to raise the back */
|
|
|
|
|
|
|
|
store.set('init', true);
|
|
|
|
}
|
|
|
|
|
2018-09-04 16:51:39 +02:00
|
|
|
}
|