This commit is contained in:
Kseninia Mikhaylova 2024-09-06 12:08:56 +03:00
parent ccf64bfe52
commit 39e56e8663
1 changed files with 21 additions and 41 deletions

View File

@ -36,7 +36,7 @@ const targetDistance = reactive({ max: 10, min: 0 })
let sidebar_clickable = [] as PromoScene[] let sidebar_clickable = [] as PromoScene[]
let sidebar_visible = [] as PromoScene[] let sidebar_visible = [] as PromoScene[]
const COUNT = 50 const COUNT = 30
type smooth = { type smooth = {
value: Vector3 | Quaternion | undefined, value: Vector3 | Quaternion | undefined,
count: number count: number
@ -279,28 +279,7 @@ watch(() => sidebar.is_open && sidebar.id_clickable, () => {
target_vector.setComponent(1, targetDistance.min) target_vector.setComponent(1, targetDistance.min)
set_moveto(smooth_target, target_vector) set_moveto(smooth_target, target_vector)
set_moveto(smooth_move, target_vector.multiply(new Vector3(1.25, 1, 1.25)))
const lerp_vector = new Vector3(0, 0, 0)
lerp_vector.lerpVectors(camera.value?.position, target_vector, 0.5)
lerp_vector.setComponent(1, targetDistance.max * 0.5)
// if (
// camera.value?.position
// && (
// camera.value?.position.distanceTo(lerp_vector) > targetDistance.max * 0.5
// || camera.value?.position.distanceTo(target_vector) > raw_dataStore.data.min_distance
// )
// ) {
// set_moveto(smooth_target, lerp_vector)
// set_moveto(smooth_move, lerp_vector)
// set_moveto(temp_smooth_target, target_vector)
// set_moveto(temp_smooth_move, target_vector)
// } else {
set_moveto(smooth_target, target_vector)
set_moveto(smooth_move, target_vector)
// }
} }
} }
}, { deep: true }) }, { deep: true })
@ -327,20 +306,10 @@ onBeforeRender(() => {
if (smooth_target.value || smooth_move.value) { if (smooth_target.value || smooth_move.value) {
timer.resetTimer() timer.resetTimer()
home_timer.resetTimer() home_timer.resetTimer()
if (smooth_target.value) {
(controls.value as any).target.lerp(smooth_target.value as Vector3, koef);
smooth_target.count -= 1
if (smooth_target.count == 1) {
set_moveto(smooth_target, undefined)
if (temp_smooth_target.value) {
set_moveto(smooth_target, temp_smooth_target.value)
set_moveto(temp_smooth_target, undefined)
}
}
}
else
if (smooth_move.value) { if (smooth_move.value) {
camera.value?.position.lerp(smooth_move.value as Vector3, koef); camera.value?.position.lerp(smooth_move.value as Vector3, koef);
camera.value?.updateMatrixWorld()
smooth_move.count -= 1 smooth_move.count -= 1
if (smooth_move.count == 1) { if (smooth_move.count == 1) {
set_moveto(smooth_move, undefined) set_moveto(smooth_move, undefined)
@ -350,9 +319,20 @@ onBeforeRender(() => {
} }
} }
} }
} else
if (smooth_target.value) {
(controls.value as any).target.lerp(smooth_target.value as Vector3, koef);
(controls.value as any).update() (controls.value as any).update()
camera.value?.updateMatrixWorld() smooth_target.count -= 1
if (smooth_target.count == 1) {
set_moveto(smooth_target, undefined)
if (temp_smooth_target.value) {
set_moveto(smooth_target, temp_smooth_target.value)
set_moveto(temp_smooth_target, undefined)
}
}
}
}
}) })
watch(() => targetDistance.min, () => { watch(() => targetDistance.min, () => {