test position

This commit is contained in:
Kseninia Mikhaylova 2024-09-19 17:28:08 +03:00
parent 9c0dca4946
commit a2ec1326bc
4 changed files with 39 additions and 14 deletions

View File

@ -12,10 +12,10 @@ const max_size = use_max_size()
const controlsState = reactive({
distance: section_count.value,
minDistance: 20,
maxDistance: 20,
minDistance: 10,
maxDistance: 10,
position: { x: 0, y: 0, z: 0 },
enablePan: false,
// enablePan: false,
minPolarAngle: degToRad(30),
maxPolarAngle: degToRad(80),
})

View File

@ -18,7 +18,7 @@ const pillar_size = 104 * 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)
const scale_koef = 2.5
const scale_koef = 1
const show_pillar_one = ref(props.index == 1)
const show_pillar_two = ref(true)
@ -71,8 +71,8 @@ watch([instanced_lamelle, fence_section, extra_section, lamelles_count, extra],
if (i >= lamelles_count.value) {
instanced_lamelle.value.setMatrixAt(i, new Matrix4().makeTranslation(new Vector3(0, 20, 20)));
}
instanced_lamelle.value.instanceMatrix.needsUpdate = true
}
instanced_lamelle.value.instanceMatrix.needsUpdate = true
}
});

View File

@ -22,14 +22,19 @@ const section_count = use_section_count()
const extra_section = use_extra_section()
const size = ref(new Vector3())
const position = ref(new Vector3())
const total = ref((section_count.value + ~~(!!extra_section.value)))
const count_pos = () => {
console.log('line count pos')
total.value = (section_count.value + ~~(!!extra_section.value))
const line = seekByName(scene.value, `line_${props.number}`)
const ssize = new Vector3()
if (line && line.children.length) {
line.updateMatrixWorld()
const bbox = new Box3()
bbox.expandByObject(line)
bbox.getSize(ssize)
const fence = line.children[0];
if (fence) {
const box = new Box3();
@ -38,20 +43,40 @@ const count_pos = () => {
});
box.getSize(size.value)
}
line.updateMatrixWorld()
}
console.log(`${props.number} ${JSON.stringify(size.value)} ${JSON.stringify(ssize)}`)
switch (props.number) {
case 1: break;
case 2:
// position.value.x = size.value.z * props.count
// position.value.z = size.value.z * props.count
position.value.x = ssize.z * -1
position.value.z = ssize.z
break;
case 3:
// position.value.x = size.value.x * props.count * 3
// position.value.z = size.value.x * props.count * 1 * -1
position.value.x = ssize.x
position.value.z = ssize.x * -1
break;
case 4:
// position.value.x = size.value.y * props.count * 0.25 * -1
// position.value.z = size.value.y * props.count * 3 * -1
position.value.x = ssize.y
position.value.z = ssize.y * -1
break;
}
}
onMounted(() => {
count_pos()
})
watch(() => [props.count, section_count.value, extra_section.value],
count_pos
)
watch(() => [props.count, section_count.value, extra_section.value], count_pos)
</script>
<template>
<TresGroup :name="`line_${props.number}`">
<TresGroup :name="`line_${props.number}`" :rotate-y="rotate()" :position-z="position.z" :position-x="position.x">
<template v-for="i in props.count">
<template v-if="(i + (props.number - 1) * props.count) <= total" :key="(i + (props.number - 1) * props.count)">
<template v-if="(i + (props.number - 1) * props.count) <= total"
:key="(i + (props.number - 1) * props.count)">
<ModelFence :index="i + (props.number - 1) * props.count" :models="props.models" />
</template>
</template>

View File

@ -135,9 +135,9 @@ watch(lamelle_count, () => {
</script>
<template>
<TresGroup name="base">
<template v-for="line in (total >= 4) ? 4 : 1" :key="count">
<template v-for="line in (total >= 4) ? 4 : 1" :key="`${line}_${count}`">
<ModelLine :models="{ top, fence, fence_top, fence_bottom, fence_inner, fastening, lamelle }" :number="line"
:count="count" :position-z="line * 2" />
:count="count" />
</template>
</TresGroup>
</template>