auto length
This commit is contained in:
parent
361bca7c67
commit
fdc3f600ca
|
@ -3,16 +3,16 @@ import { getColorNameFromRal } from '@/components/ral'
|
|||
import type { ralTypes } from '@/components/ral'
|
||||
|
||||
const lamelles_count = useState('lamelles_count', () => 14)
|
||||
const fence_section = useState<number>('fence_section', () => 2000 * 0.001)
|
||||
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 section_count = useState('section_count', () => 10)
|
||||
const section_count = useState('section_count', () => 5)
|
||||
const extra_section = useState('extra_section', () => 0)
|
||||
const total_length = useState('total_length', () => (2000 * 8 - 100) * 0.001)
|
||||
const total_length = useState('total_length', () => (1000 * 5 - 100) * 0.001)
|
||||
const min_length = useState('min_length', () => 1000)
|
||||
|
||||
const parametric = {
|
||||
const parametric = reactive({
|
||||
length: {
|
||||
min: min_length.value,
|
||||
max: 2400,
|
||||
|
@ -28,7 +28,7 @@ const parametric = {
|
|||
max: 2400,
|
||||
step: 115,
|
||||
}
|
||||
}
|
||||
})
|
||||
const form_state = reactive({
|
||||
length: fence_section.value * 1000,
|
||||
fence_length: 100,
|
||||
|
@ -37,7 +37,7 @@ const form_state = reactive({
|
|||
total_length_mm: fence_section.value * 1000,
|
||||
full_sections: section_count.value,
|
||||
extra_section: 0,
|
||||
auto_length: false,
|
||||
auto_length: true,
|
||||
remove_pillar: false
|
||||
})
|
||||
const form_refs = {
|
||||
|
@ -63,11 +63,22 @@ const changeParametres = () => {
|
|||
|
||||
form_state.total_length_mm = form_state.total_length * 1000
|
||||
if (form_state.auto_length) {
|
||||
let w = parametric.length.max
|
||||
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)
|
||||
while ((tw_f % iw_f) && w > (parametric.length.min + parametric.length.step * 10)) {
|
||||
w -= parametric.length.step
|
||||
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
|
||||
}
|
||||
|
|
|
@ -20,16 +20,12 @@ const pillar_size = 80 * 0.001
|
|||
const pillar_one_pos = ref(fence_section.value * -0.5 - 0.015)
|
||||
const pillar_two_pos = ref(fence_section.value * 0.5 + pillar_size + bSize - 0.01)
|
||||
|
||||
watch([fence_section, lamelles_count], () => {
|
||||
pillar_one_pos.value = fence_section.value * -0.5 - 0.015
|
||||
pillar_two_pos.value = fence_section.value * 0.5 + pillar_size + bSize - 0.01
|
||||
})
|
||||
const scale_koef = 2.5
|
||||
const show_pillar_one = ref(props.index == 1)
|
||||
const show_pillar_two = ref(true)
|
||||
|
||||
const make_translate_to_section = () => {
|
||||
const one_s = (fence_section.value + pillar_size + bSize)
|
||||
const make_translate_to_section = (source = fence_section.value) => {
|
||||
const one_s = (source + pillar_size + bSize)
|
||||
let r = (props.index - 1) * one_s * scale_koef
|
||||
return r
|
||||
}
|
||||
|
@ -64,19 +60,21 @@ for (let index = 0; index < lamelles_count.value; index++) {
|
|||
}
|
||||
const extra = ref((extra_section && props.index == (section_count.value + 1)) ? extra_section.value * 0.001 : false)
|
||||
if (extra.value) {
|
||||
pillar_two_pos.value = extra.value * 0.5 + pillar_size + bSize - 0.01
|
||||
pillar_one_pos.value = (extra.value as number) * -0.5 - 0.015
|
||||
pillar_two_pos.value = (extra.value as number) * 0.5 + pillar_size + bSize - 0.01
|
||||
}
|
||||
watch([extra_section, section_count], () => {
|
||||
extra.value = (extra_section && props.index == (section_count.value + 1)) ? extra_section.value * 0.001 : false
|
||||
watch([section_count, fence_section, extra_section], (s) => {
|
||||
extra.value = (extra_section.value && props.index == (section_count.value + 1)) ? extra_section.value * 0.001 : false
|
||||
if (extra_section && props.index == (section_count.value + 1)) {
|
||||
// pillar_one_pos.value = extra_section.value * -0.5 - 0.015
|
||||
pillar_two_pos.value = extra.value * 0.5 + pillar_size + bSize - 0.01
|
||||
pillar_one_pos.value = (extra.value as number) * -0.5 - 0.015
|
||||
pillar_two_pos.value = (extra.value as number) * 0.5 + pillar_size + bSize - 0.01
|
||||
translate_to_section.value = make_translate_to_section(extra_section.value)
|
||||
} else {
|
||||
// pillar_one_pos.value = fence_section.value * -0.5 - 0.015
|
||||
pillar_one_pos.value = fence_section.value * -0.5 - 0.015
|
||||
pillar_two_pos.value = fence_section.value * 0.5 + pillar_size + bSize - 0.01
|
||||
translate_to_section.value = make_translate_to_section()
|
||||
}
|
||||
})
|
||||
console.log({ pillar_size, fence_section: fence_section.value })
|
||||
</script>
|
||||
<template>
|
||||
<TresGroup :scale="scale_koef" :position-x="translate_to_section" :name="`fence ${index}`"
|
||||
|
|
|
@ -22,8 +22,8 @@ box.getSize(size)
|
|||
const getMaterial = () => {
|
||||
return new MeshStandardMaterial({
|
||||
color: new Color(props.color || '#9c9c9c'),
|
||||
roughness: 0.2,
|
||||
metalness: 0.5,
|
||||
roughness: 0.3,
|
||||
metalness: 0.3,
|
||||
})
|
||||
}
|
||||
const material = getMaterial()
|
||||
|
|
Loading…
Reference in New Issue