Merge branch 'bx-696-startproject' of https://git.svs-tech.pro/ksenia_mikhailova/mns-mini-zabor into bx-696-startproject

This commit is contained in:
commit 9c04e88801
2 changed files with 47 additions and 36 deletions

View File

@ -17,6 +17,7 @@ const parametric = {
}, },
total_length: { total_length: {
min: 1, min: 1,
max: undefined,
step: 0.1, step: 0.1,
}, },
height: { height: {
@ -52,43 +53,47 @@ const changeParametres = () => {
fence_section.value = form_state.length * 0.001 fence_section.value = form_state.length * 0.001
for (const key in form_state) { for (const key in form_state) {
if (parametric.hasOwnProperty(key) && parametric[key].max) { if (parametric.hasOwnProperty(key)) {
if (form_state[key] > parametric[key].max) { const key_p = key as keyof typeof parametric
form_state[key] = parametric[key].max const key_s = key as keyof typeof form_state
if (parametric[key_p].max) {
if (form_state[key_s] > parametric[key_p].max) {
form_state[key_s] = parametric[key_p].max
}
}
if (parametric[key_p].min) {
if (form_state[key_s] < parametric[key_p].min) {
form_state[key_s] = parametric[key_p].min
}
} }
} }
if (parametric.hasOwnProperty(key) && parametric[key].min) {
if (form_state[key] < parametric[key].min) { form_state.total_length_mm = form_state.total_length * 1000
form_state[key] = parametric[key].min if (auto_section_width.value) {
let w = parametric.length.max
while (((form_state.total_length_mm % w) > 0) && w > (parametric.length.min + parametric.length.step * 10)) {
w -= parametric.length.step
} }
form_state.length = w
} }
} if (form_state.total_length_mm < form_state.length) {
form_state.length = form_state.total_length_mm
form_state.total_length_mm = form_state.total_length * 1000
if (auto_section_width.value) {
let w = parametric.length.max
while (((form_state.total_length_mm % w) > 0) && w > (parametric.length.min + parametric.length.step * 10)) {
w -= parametric.length.step
} }
form_state.length = w
}
if (form_state.total_length_mm < form_state.length) {
form_state.length = form_state.total_length_mm
}
const t_f = (form_state.total_length_mm - form_state.fence_length) const t_f = (form_state.total_length_mm - form_state.fence_length)
const i_f = (form_state.length - form_state.fence_length) const i_f = (form_state.length - form_state.fence_length)
form_state.full_sections = Math.floor(t_f / i_f) form_state.full_sections = Math.floor(t_f / i_f)
section_count.value = form_state.full_sections section_count.value = form_state.full_sections
if (t_f % i_f) { if (t_f % i_f) {
form_state.extra_section = Math.round(t_f % i_f) form_state.extra_section = Math.round(t_f % i_f)
} else { } else {
form_state.extra_section = 0 form_state.extra_section = 0
} }
form_refs.total_length.value.setCustomValidity('') form_refs.total_length.value.setCustomValidity('')
if (form_state.extra_section && form_state.extra_section < parametric.length.min) { if (form_state.extra_section && form_state.extra_section < parametric.length.min) {
form_refs.total_length.value.setCustomValidity('Расчет невозможен') form_refs.total_length.value.setCustomValidity('Расчет невозможен')
}
} }
} }
@ -100,13 +105,18 @@ const setPillarColor = (color: ralTypes) => {
} }
const increment = (field: keyof typeof form_state, value: number) => { const increment = (field: keyof typeof form_state, value: number) => {
if (form_state.hasOwnProperty(field)) { if (form_state.hasOwnProperty(field)) {
let v = (form_state[field] + value * parametric[field].step ?? 1) const key_p = field as keyof typeof parametric
let v = (form_state[field] + value * parametric[key_p].step ?? 1)
if (parametric.hasOwnProperty(field)) { if (parametric.hasOwnProperty(field)) {
if (v > parametric[field].max) { if (parametric[key_p].max) {
v = parametric[field].max if (v > parametric[key_p].max) {
v = parametric[key_p].max
}
} }
if (v < parametric[field].min) { if (parametric[key_p].min) {
v = parametric[field].min if (v < parametric[key_p].min) {
v = parametric[key_p].min
}
} }
} }
form_state[field] = parseFloat(v.toFixed(2)) form_state[field] = parseFloat(v.toFixed(2))

View File

@ -23,7 +23,8 @@ const pbrTexture = await useTexture({
const repeat = 5 const repeat = 5
for (const key in pbrTexture) { for (const key in pbrTexture) {
if (Object.prototype.hasOwnProperty.call(pbrTexture, key)) { if (Object.prototype.hasOwnProperty.call(pbrTexture, key)) {
const element = pbrTexture[key]; const key_p = key as keyof typeof pbrTexture
const element = pbrTexture[key_p]
if (element && element.wrapS) { if (element && element.wrapS) {
element.wrapS = RepeatWrapping element.wrapS = RepeatWrapping
element.wrapT = RepeatWrapping element.wrapT = RepeatWrapping