1
0
Fork 0

fix(models): Fixed issues with some measurements being NaN

This commit is contained in:
Joost De Cock 2022-08-29 13:28:46 +02:00
parent 364e43b635
commit 1c5262222f
4 changed files with 39 additions and 21 deletions

View file

@ -27,15 +27,15 @@
".": "./dist/index.mjs" ".": "./dist/index.mjs"
}, },
"scripts": { "scripts": {
"build": "node --experimental-json-modules build.mjs", "build": "node build.mjs",
"clean": "rimraf dist", "clean": "rimraf dist",
"mbuild": "NO_MINIFY=1 node --experimental-json-modules build.mjs", "mbuild": "NO_MINIFY=1 node build.mjs",
"symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -", "symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -",
"test": "npx mocha tests/*.test.mjs", "test": "npx mocha tests/*.test.mjs",
"vbuild": "VERBOSE=1 node --experimental-json-modules build.mjs", "vbuild": "VERBOSE=1 node build.mjs",
"lab": "cd ../../sites/lab && yarn start", "lab": "cd ../../sites/lab && yarn start",
"tips": "node ../../scripts/help.mjs", "tips": "node ../../scripts/help.mjs",
"cibuild_step6": "node --experimental-json-modules build.mjs" "cibuild_step6": "node build.mjs"
}, },
"peerDependencies": { "peerDependencies": {
"@freesewing/utils": "^3.0.0-alpha.0" "@freesewing/utils": "^3.0.0-alpha.0"

4
packages/models/pkg.mjs Normal file
View file

@ -0,0 +1,4 @@
// This file is auto-generated | All changes you make will be overwritten.
export const name = "@freesewing/models"
export const version = "3.0.0-alpha.0"

View file

@ -2,6 +2,7 @@
* This completes the list of measurements with the ones * This completes the list of measurements with the ones
* we can calculate based on what we already have * we can calculate based on what we already have
*/ */
/*
function complete(m) { function complete(m) {
// Added by plugin-bust: // Added by plugin-bust:
m.bust = m.chest m.bust = m.chest
@ -19,7 +20,7 @@ function complete(m) {
return m return m
} }
*/
/* /*
* These are a set of measurements of an average-sized [woman, man]. * These are a set of measurements of an average-sized [woman, man].
@ -29,7 +30,7 @@ function complete(m) {
* but we are not in the business of standard sizes, so this will do. * but we are not in the business of standard sizes, so this will do.
*/ */
const base = complete({ const base = {
ankle: [245, 235], ankle: [245, 235],
biceps: [270, 350], biceps: [270, 350],
bustFront: [480, 560], // FIXME: Estimate bustFront: [480, 560], // FIXME: Estimate
@ -65,10 +66,12 @@ const base = complete({
waistToHips: [125, 130], waistToHips: [125, 130],
waistToKnee: [600, 640], waistToKnee: [600, 640],
waistToSeat: [250, 270], waistToSeat: [250, 270],
waistToUnderbust: [80, ], waistToUnderbust: [80, 55], // FIXME: Estimate
waistToUpperLeg: [285, 340], waistToUpperLeg: [285, 340],
wrist: [165, 175], wrist: [165, 175],
}) }
// Add auto-calculated measures
//const full = complete(base)
/* /*
* Since linear measurements don't scale the same as circumference * Since linear measurements don't scale the same as circumference
@ -80,8 +83,10 @@ let v = 0.65 // vertical
const ratio = { const ratio = {
// Arc measurements // Arc measurements
bustFront: a, bustFront: a,
bustBack: a,
bustPointToUnderbust: a, bustPointToUnderbust: a,
bustSpan: a, bustSpan: a,
highBustBack: a,
highBustFront: a, highBustFront: a,
// Circumference measurements // Circumference measurements
ankle: c, ankle: c,
@ -96,26 +101,34 @@ const ratio = {
hpsToBust: v, hpsToBust: v,
hpsToWaistBack: v, hpsToWaistBack: v,
hpsToWaistFront: v, hpsToWaistFront: v,
waistToArmhole: v,
waistToHips: v, waistToHips: v,
waistToKnee: v, waistToKnee: v,
waistToSeat: v, waistToSeat: v,
waistToUnderbust: v, waistToUnderbust: v,
waistToUpperLeg: v, waistToUpperLeg: v,
// Other // Other
seatBack: 0.6,
waistBack: 0.85,
crossSeam: 0.6, crossSeam: 0.6,
crossSeamFront: 0.3, crossSeamFront: 0.6,
crossSeamBack: 0.6,
head: 0.35, head: 0.35,
heel: 0.25, heel: 0.25,
inseam: 0.25, inseam: 0.25,
knee: 0.65, knee: 0.65,
seat: 0.6, seat: 0.6,
seatBack: 0.6,
seatBackArc: 0.6,
seatFront: 0.6,
seatFrontArc: 0.6,
shoulderToElbow: 0.5, shoulderToElbow: 0.5,
shoulderToShoulder: 0.65, shoulderToShoulder: 0.65,
shoulderToWrist: 0.3, shoulderToWrist: 0.3,
upperLeg: 0.45, upperLeg: 0.45,
waist: 0.85, waist: 0.85,
waistBack: 0.85,
waistBackArc: 0.85,
waistFront: 0.85,
waistFrontArc: 0.85,
waistToFloor: 0.4, waistToFloor: 0.4,
wrist: 0.5 wrist: 0.5
} }
@ -143,7 +156,7 @@ export const neckstimate = (neck = false, measurement = false, breasts = false,
const i = breasts ? 0 : 1 const i = breasts ? 0 : 1
// Shoulder slope is in degrees. Always return the base. // Shoulder slope is in degrees. Always return the base.
if (measurement === 'shoulderSlope') base.shoulderSlope[i] if (measurement === 'shoulderSlope') return base.shoulderSlope[i]
if (!neck) throw new Error('neckstimate() requires a neck measurement in mm as first parameter') if (!neck) throw new Error('neckstimate() requires a neck measurement in mm as first parameter')

View file

@ -13,14 +13,15 @@ describe('Measurements', () => {
}) })
for (const type in sizes) { for (const type in sizes) {
describe(`Sizes: ${type}`, () => { for (const size of sizes[type]) {
for (const size of sizes[type]) { describe(`${type} size ${size}`, () => {
it(`${type}${size} should have all measurements`, () => { for (const m of measurements) {
for (const m of measurements) { it(`${type}${size} should have the ${m} measurement`, () => {
expect(typeof all[`${type}${size}`][m]).to.equal('number'); expect(typeof all[`${type}${size}`][m]).to.equal('number')
} expect(isNaN(all[`${type}${size}`][m])).to.equal(false)
}) })
} }
}) })
}
} }