This commit is contained in:
Kseninia Mikhaylova 2024-06-18 12:15:50 +03:00
parent 519bc3f4f0
commit 36d77b3e22
2 changed files with 30 additions and 35 deletions

View File

@ -7,7 +7,7 @@ const section_count = useState<number>('section_count')
const fence_section = useState<number>('fence_section')
const controlsState = reactive({
minDistance: 5,
minDistance: section_count.value * 5,
maxDistance: 12,
enablePan: false,
maxPolarAngle: (Math.PI / 2) - 0.2,

View File

@ -2,11 +2,14 @@
import { getColorNameFromRal } from '@/components/ral'
import type { ralTypes } from '@/components/ral'
const predefPillarColors = ['3004', '7043', '6028', '5013', '8016', '1020', '3005', '4009']
const predefLamelleColors = ['3009', '9003', '6027', '5024', '9001', '1012', '3007', '4007']
const lamelles_count = useState('lamelles_count', () => 14)
const fence_section = useState<number>('fence_section', () => 1000 * 0.001)
const remove_pillar = useState<boolean>('remove_pillar', () => false)
const pillar_color = useState<ralTypes>('pillar_color', () => '3009')
const lamelle_color = useState<ralTypes>('lamelle_color', () => '3004')
const pillar_color = useState<ralTypes>('pillar_color', () => predefPillarColors[Math.floor(Math.random() * predefPillarColors.length)] as ralTypes)
const lamelle_color = useState<ralTypes>('lamelle_color', () => predefLamelleColors[Math.floor(Math.random() * predefLamelleColors.length)] as ralTypes)
const section_count = useState('section_count', () => 5)
const extra_section = useState('extra_section', () => 0)
const total_length = useState('total_length', () => (1000 * 5 - 100) * 0.001)
@ -61,36 +64,33 @@ const changeParametres = () => {
}
}
form_state.total_length_mm = form_state.total_length * 1000
if (form_state.auto_length) {
let w = parametric.length.min
let tw_f = (form_state.total_length_mm - form_state.fence_length)
let iw_f = (w - form_state.fence_length)
for (let index = parametric.length.max; index > parametric.length.min; index--) {
w = index
iw_f = (w - form_state.fence_length)
console.log({
tw_f:tw_f,
iw_f:iw_f,
'tw_f % iw_f':tw_f % iw_f
})
if (tw_f % iw_f == 0) {
break
} else {
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 i_f = (form_state.length - form_state.fence_length)
form_state.full_sections = Math.floor(t_f / i_f)
if (t_f % i_f) {
form_state.extra_section = Math.round(t_f % i_f)
form_state.total_length_mm = form_state.total_length * 1000
const total_without_pillar = form_state.total_length_mm - form_state.fence_length
if (form_state.auto_length) {
let w = parametric.length.min
const max_sections = Math.ceil(total_without_pillar / parametric.length.min)
const min_sections = Math.ceil(total_without_pillar / parametric.length.max)
for (let index = min_sections; index <= max_sections; index++) {
w = (total_without_pillar / index) + form_state.fence_length
if (w >= parametric.length.min && w <= parametric.length.max) {
break
}
}
form_state.length = w
}
const section_without_pillar = form_state.length - form_state.fence_length
form_state.full_sections = Math.ceil(total_without_pillar / section_without_pillar)
if (section_without_pillar * form_state.full_sections == form_state.full_sections) {
form_state.extra_section = Math.ceil(total_without_pillar % section_without_pillar)
} else {
form_state.extra_section = 0
}
@ -120,10 +120,6 @@ const setLamelleColor = (color: ralTypes) => {
const setPillarColor = (color: ralTypes) => {
pillar_color.value = color
}
const predefLamelleColors = ['3009', '9003', '6027', '5024', '9001', '1012', '3007', '4007']
const predefPillarColors = ['3004', '7043', '6028', '5013', '8016', '1020', '3005', '4009']
watch(form_state, changeParametres, { deep: true })
const isModalOpen = useState('modal_open', () => false)
@ -213,8 +209,7 @@ const plurals = {
</template>
{{ section_count * lamelles_count }}
<Plural :n="section_count * lamelles_count" :forms="plurals.lamelle" />
{{ `длиной ${form_state.length}\xa0мм` }}
<template v-if="form_state.extra_section">и
{{ `длиной ${form_state.length}\xa0мм` }}<template v-if="form_state.extra_section">и
{{ ~~(!!form_state.extra_section) * lamelles_count }}
<Plural :n="~~(!!form_state.extra_section) * lamelles_count" :forms="plurals.lamelle" />
{{ `длиной ${form_state.extra_section}\xa0мм` }}