From 0102392b3a2463ee988cb0e7d22f997e2a7815f4 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Thu, 20 Jun 2024 17:06:50 +0300 Subject: [PATCH] fix fence calc --- components/model/item.vue | 16 +++++++++------- components/model/parametric.vue | 4 +++- composables/useCalc.ts | 8 +++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/components/model/item.vue b/components/model/item.vue index 8b4906d..b03bc64 100644 --- a/components/model/item.vue +++ b/components/model/item.vue @@ -13,7 +13,7 @@ if (props.modelUrl) { scene.receiveShadow = true scene.castShadow = true -const target = ref(props.target ? new Vector3(...props.target) : new Vector3(0, 0, 0)) +const target = ref(props.target ? new Vector3(...props.target) : null) function shadows_and_pos(scene: any) { scene.children.forEach((el: any) => { @@ -37,13 +37,15 @@ type vectorType = 'x' | 'y' | 'z'; onLoop(() => { if (model.value && target.value) { axis.forEach(element => { - const point = model.value.position[element.axis] - let step = stepbase * target.value[element.axis as vectorType] - if (step !== 0) { - if (Math.abs(point) >= Math.abs(target.value[element.axis as vectorType])) { - step = 0 + if(target.value) { + const point = model.value.position[element.axis] + let step = stepbase * target.value[element.axis as vectorType] + if (step !== 0) { + if (Math.abs(point) >= Math.abs(target.value[element.axis as vectorType])) { + step = 0 + } + model.value[element.func](step) } - model.value[element.func](step) } }); } diff --git a/components/model/parametric.vue b/components/model/parametric.vue index 0744154..4396054 100644 --- a/components/model/parametric.vue +++ b/components/model/parametric.vue @@ -35,6 +35,7 @@ watch(lamelle_color, () => { items.forEach(element => { set_material(element, getColorHexFromRal(lamelle_color.value)) }); + set_material(lamelle, getColorHexFromRal(lamelle_color.value)); }) watch(pillar_color, () => { const items = [ @@ -47,6 +48,7 @@ watch(pillar_color, () => { items.forEach(element => { set_material(element, getColorHexFromRal(pillar_color.value)) }); + [top, fence, fastening].map((el: any) => { set_material(el, getColorHexFromRal(pillar_color.value)) }) }) watch([section_count, extra_section], () => { const base = seek(scene.value, 'name', 'base') @@ -78,7 +80,7 @@ onMounted(() => { diff --git a/composables/useCalc.ts b/composables/useCalc.ts index 5eabb98..15ad0b0 100644 --- a/composables/useCalc.ts +++ b/composables/useCalc.ts @@ -3,14 +3,16 @@ import type { ralTypes } from '@/components/ral' export const predefPillarColors = ['3004', '7043', '6028', '5013', '8016', '1020', '3005', '4009'] export const predefLamelleColors = ['3009', '9003', '6027', '5024', '9001', '1012', '3007', '4007'] +const n = 2 +const min = 1300 export const use_lamelles_count = () => useState('lamelles_count', () => 14) -export const use_fence_section = () => useState('fence_section', () => 1000 * 0.001) +export const use_fence_section = () => useState('fence_section', () => min * 0.001) export const use_remove_pillar = () => useState('remove_pillar', () => false) export const use_pillar_color = () => useState('pillar_color', () => predefPillarColors[Math.floor(Math.random() * predefPillarColors.length)] as ralTypes) export const use_lamelle_color = () => useState('lamelle_color', () => predefLamelleColors[Math.floor(Math.random() * predefLamelleColors.length)] as ralTypes) -export const use_section_count = () => useState('section_count', () => 5) +export const use_section_count = () => useState('section_count', () => n) export const use_extra_section = () => useState('extra_section', () => 0) -export const use_total_length = () => useState('total_length', () => (1000 * 5 - 100) * 0.001) +export const use_total_length = () => useState('total_length', () => ((min * n) - 100) * 0.001) export const use_min_length = () => useState('min_length', () => 1000) export const use_max_size = () => useState('max_size', () => 13) export const use_explosion_state = () => useState('explosion_state', () => false) \ No newline at end of file