bx-1379-redesign #15
|
@ -23,6 +23,7 @@ import { useTimer } from '../../stores/timer';
|
|||
import { useRawData } from '../../stores/raw_data';
|
||||
import { useTimerHome } from '../../stores/timer_home';
|
||||
import { useItem } from '../../stores/item';
|
||||
import { degToRad } from 'three/src/math/MathUtils.js';
|
||||
|
||||
const props = defineProps(['source', 'loaded_pan', 'push'])
|
||||
|
||||
|
@ -271,17 +272,35 @@ watch(() => sidebar.is_open && sidebar.id_clickable, () => {
|
|||
const el = seekByName(scene.value, `${sidebar.id_clickable}_clickable`);
|
||||
if (el) {
|
||||
targetDistance.max = 10
|
||||
targetDistance.min = raw_dataStore.data.min_distance > 50 ? raw_dataStore.data.min_distance / 7 : 3
|
||||
targetDistance.min = 3
|
||||
|
||||
const target_vector = new Vector3();
|
||||
el.getWorldPosition(target_vector);
|
||||
target_vector.setComponent(1, targetDistance.min)
|
||||
|
||||
const multiply = new Vector3(1.25, 2, 1.25)
|
||||
const target_move = target_vector.multiply(multiply)
|
||||
|
||||
set_moveto(smooth_target, target_vector)
|
||||
// set_moveto(smooth_move, target_move)
|
||||
|
||||
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 })
|
||||
|
@ -305,39 +324,12 @@ onBeforeRender(() => {
|
|||
})
|
||||
// const koef = (1 / COUNT) * 3
|
||||
const koef = 0.05
|
||||
const smoothy = [
|
||||
{
|
||||
el: smooth_target,
|
||||
temp_el: temp_smooth_target,
|
||||
f: () => {
|
||||
(controls.value as any).target.lerp(smooth_target.value as Vector3, koef);
|
||||
},
|
||||
},
|
||||
{
|
||||
el: smooth_move,
|
||||
temp_el: temp_smooth_move,
|
||||
f: () => {
|
||||
camera.value?.position.lerp(smooth_move.value as Vector3, koef);
|
||||
},
|
||||
},
|
||||
]
|
||||
if (smooth_target.value || smooth_move.value) {
|
||||
timer.resetTimer()
|
||||
home_timer.resetTimer()
|
||||
if (smooth_move.value) {
|
||||
camera.value?.position.lerp(smooth_move.value as Vector3, koef);
|
||||
smooth_move.count -=1
|
||||
if (smooth_move.count == 1) {
|
||||
set_moveto(smooth_move, undefined)
|
||||
if (temp_smooth_move.value) {
|
||||
set_moveto(smooth_move, temp_smooth_move.value)
|
||||
set_moveto(temp_smooth_move, undefined)
|
||||
}
|
||||
}
|
||||
}else
|
||||
if (smooth_target.value) {
|
||||
(controls.value as any).target.lerp(smooth_target.value as Vector3, koef);
|
||||
smooth_target.count -=1
|
||||
smooth_target.count -= 1
|
||||
if (smooth_target.count == 1) {
|
||||
set_moveto(smooth_target, undefined)
|
||||
if (temp_smooth_target.value) {
|
||||
|
@ -346,6 +338,18 @@ onBeforeRender(() => {
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (smooth_move.value) {
|
||||
camera.value?.position.lerp(smooth_move.value as Vector3, koef);
|
||||
smooth_move.count -= 1
|
||||
if (smooth_move.count == 1) {
|
||||
set_moveto(smooth_move, undefined)
|
||||
if (temp_smooth_move.value) {
|
||||
set_moveto(smooth_move, temp_smooth_move.value)
|
||||
set_moveto(temp_smooth_move, undefined)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
(controls.value as any).update()
|
||||
camera.value?.updateMatrixWorld()
|
||||
|
@ -447,13 +451,5 @@ onUnmounted(() => {
|
|||
<template v-for="(item, i) in clickable_items">
|
||||
<TresObject3D v-bind="item.clone()" :ref="clickable_refs[i]" />
|
||||
</template>
|
||||
<TresMesh :position="point_1">
|
||||
<TresSphereGeometry :args="[0.1, 32, 32]" />
|
||||
<TresMeshStandardMaterial color="violet" />
|
||||
</TresMesh>
|
||||
<TresMesh :position="point_2">
|
||||
<TresSphereGeometry :args="[0.1, 32, 32]" />
|
||||
<TresMeshStandardMaterial color="darkgreen" />
|
||||
</TresMesh>
|
||||
</TresGroup>
|
||||
</template>
|
Loading…
Reference in New Issue