diff --git a/components/model/fence.vue b/components/model/fence.vue index d62fb0e..b4e5821 100644 --- a/components/model/fence.vue +++ b/components/model/fence.vue @@ -129,7 +129,6 @@ const setBraceCount = () => { setBraceCount() watch(lamelles_count, setBraceCount) - const calculateAddScale = (model: Mesh, k = 1): number => { if (!model.geometry.boundingBox) { model.geometry.computeBoundingBox(); // Вычисляем boundingBox, если он не был вычислен ранее @@ -146,6 +145,19 @@ const calculateAddScale = (model: Mesh, k = 1): number => { return (lamelle_height.value * k) / boundingBoxHeight; }; +const calculateFasteningScale = (model_fastening: Mesh, model_lamelle: Mesh, c = 'z'): number => { + function getWidth(model: Mesh, c) { + if (!model.geometry.boundingBox) { + model.geometry.computeBoundingBox(); // Вычисляем boundingBox, если он не был вычислен ранее + } + + return Math.abs( + model.geometry.boundingBox!.max[c] - model.geometry.boundingBox!.min[c] + ); + } + + return getWidth(model_lamelle, c) / (getWidth(model_fastening, c)) +}; const pillar = ref([]) const setPillar = () => { @@ -159,8 +171,6 @@ const setPillar = () => { pillar_inner.scale.setComponent(1, lamelles_count.value * calculateAddScale(pillar_inner)); const bottom = props.models.pillar_bottom.children[0]; - const bottomHeight = Math.abs(bottom.geometry.boundingBox.max.y - bottom.geometry.boundingBox.min.y) - bottom.position.setComponent(1, bottomHeight * -1); let arr = [top, pillar_outer, pillar_inner, bottom] arr.map(el => { @@ -169,7 +179,7 @@ const setPillar = () => { set_material( { children: [arr[2]] }, getColorHexFromRal(pillar_color.value), - { pattern: pillar_pattern.value, count: lamelles_count.value }, + { pattern: pillar_pattern.value, count: lamelles_count.value * calculateAddScale(pillar_inner) }, true ) pillar.value = arr.map(el => el.clone()) @@ -201,16 +211,20 @@ const setFastening = () => { 0 ); top.scale.setComponent(0, v); + top.scale.setComponent(2, calculateFasteningScale(top, props.models.lamelle.children[0])); + let c = 0.002 * scale_koef const side_one = props.models.fastening_side.clone().children[0]; side_one.name = 'side_one' - side_one.position.set(pillar_one_pos.value, 0, 0.002 * scale_koef); + side_one.position.set(pillar_one_pos.value, 0, c); side_one.scale.set(1, lamelles_count.value * calculateAddScale(side_one), 1) + side_one.scale.setComponent(2, calculateFasteningScale(side_one, props.models.lamelle.children[0])); const side_two = props.models.fastening_side.clone().children[0]; side_two.name = 'side_two' side_two.scale.set(-1, lamelles_count.value * calculateAddScale(side_two), -1) - side_two.position.set(pillar_two_pos.value, 0, -0.005 * scale_koef); + side_two.position.set(pillar_two_pos.value, 0, c); + side_two.scale.setComponent(2, calculateFasteningScale(side_two, props.models.lamelle.children[0])); let arr = [top_one, top_two, top, side_one, side_two]; [top, side_one, side_two, ...braces.value].map(el => { diff --git a/public/models_exp.zip b/public/models_exp.zip new file mode 100644 index 0000000..f5b4655 Binary files /dev/null and b/public/models_exp.zip differ diff --git a/public/models_one/pillar/bottom.glb b/public/models_one/pillar/bottom.glb index 29223b8..a5b5e24 100644 Binary files a/public/models_one/pillar/bottom.glb and b/public/models_one/pillar/bottom.glb differ