This commit is contained in:
Kseninia Mikhaylova 2024-09-25 15:13:07 +03:00
parent 007a4fb014
commit 027fc2e6bf
2 changed files with 4 additions and 19 deletions

View File

@ -3,14 +3,7 @@ import { TresCanvas } from '@tresjs/core'
import { Stats, OrbitControls } from '@tresjs/cientos'
import { degToRad } from 'three/src/math/MathUtils.js';
const section_count = use_section_count()
const fence_section = use_fence_section()
const defDistance = 3
const controlsState = reactive({
distance: section_count.value,
minDistance: defDistance,
maxDistance: defDistance,
position: { x: 0, y: 0, z: 0 },
enablePan: false,
enableZoom: false,
@ -22,16 +15,6 @@ const cameraStat = reactive({
aspect: 1920 / 600,
// fov: 40,
})
const camera = ref("camera")
watch(fence_section, () => {
let v = fence_section.value * 2;
if (v <= defDistance) v = defDistance
controlsState.minDistance = v;
controlsState.maxDistance = v;
(camera.value as any).position.normalize().multiplyScalar(v)
})
</script>
<template>
<ClientOnly fallback-tag="div">

View File

@ -63,13 +63,15 @@ watch(() => [section_count.value, extra_section.value], () => {
});
})
const setTarget = () => {
const f = fence_section.value * 0.5
let f = fence_section.value * lamelles_count.value * lamelle_height.value * 0.75
if (f < 3) f = 3
console.log(f)
const target = new Vector3(0, lamelles_count.value * lamelle_height.value * 0.5, 0);
(controls.value as OrbitControlsProps).target = target
camera.value?.position.set(f, f, f)
}
setTarget()
watch(lamelles_count, setTarget)
watch([lamelles_count, fence_section], setTarget)
</script>
<template>