bx-1379-redesign #15

Merged
ksenia_mikhailova merged 124 commits from bx-1379-redesign into dev 2024-09-06 15:39:13 +03:00
1 changed files with 42 additions and 36 deletions
Showing only changes of commit 1b5c510de0 - Show all commits

View File

@ -36,12 +36,13 @@ let sidebar_clickable = [] as PromoScene[]
let sidebar_visible = [] as PromoScene[] let sidebar_visible = [] as PromoScene[]
const COUNT = 100 const COUNT = 100
const controls_targetto = ref() as Ref<Vector3 | undefined>; type smooth = {
const controls_targetto_count = ref(COUNT) value: Vector3 | Quaternion | undefined,
const camera_moveto = ref() as Ref<Vector3 | undefined>; count: number
const camera_moveto_count = ref(COUNT) }
const camera_rotatetoto = ref() as Ref<Quaternion | undefined>; const smooth_target = reactive({}) as smooth
const camera_rotatetoto_count = ref(COUNT) const smooth_move = reactive({}) as smooth
const smooth_rotate = reactive({}) as smooth
const vis_target = ref() const vis_target = ref()
@ -58,6 +59,13 @@ const pointerTexture = await useTexture({
map: '/pointer_texture.png' map: '/pointer_texture.png'
}) })
const set_moveto = (obj: smooth, value: Vector3 | Quaternion | undefined) => {
obj.value = value
if (obj.value == undefined) {
obj.count = COUNT
}
}
const setEnv = async () => { const setEnv = async () => {
envVars.focus = raw_dataStore.data.max_distance * 0.5 envVars.focus = raw_dataStore.data.max_distance * 0.5
if (raw_dataStore.data.env) { if (raw_dataStore.data.env) {
@ -223,12 +231,12 @@ const loadModels = async () => {
const gotoCenterAndDistance = () => { const gotoCenterAndDistance = () => {
targetDistance.min = mobileAndTabletCheck() ? raw_dataStore.data.min_distance * 0.5 : raw_dataStore.data.min_distance; targetDistance.min = mobileAndTabletCheck() ? raw_dataStore.data.min_distance * 0.5 : raw_dataStore.data.min_distance;
targetDistance.max = raw_dataStore.data.max_distance; targetDistance.max = raw_dataStore.data.max_distance;
controls_targetto.value = new Vector3(0, 0, 0); set_moveto(smooth_target, new Vector3(0, 0, 0))
camera_moveto.value = new Vector3( set_moveto(smooth_move, new Vector3(
raw_dataStore.data.max_distance * 0.5, raw_dataStore.data.max_distance * 0.5,
raw_dataStore.data.max_distance * 0.5, raw_dataStore.data.max_distance * 0.5,
raw_dataStore.data.max_distance * 0.5 raw_dataStore.data.max_distance * 0.5
); ))
} }
watch(() => props.source, () => { watch(() => props.source, () => {
@ -266,17 +274,18 @@ watch(() => sidebar.is_open && sidebar.id_clickable, () => {
target_vector.y = raw_dataStore.data.min_distance > 50 ? raw_dataStore.data.min_distance / 10 : 1; target_vector.y = raw_dataStore.data.min_distance > 50 ? raw_dataStore.data.min_distance / 10 : 1;
const quaternion = new Quaternion(); const quaternion = new Quaternion();
quaternion.setFromEuler(new Euler( // quaternion.setFromEuler(new Euler(
-45 * 1 * (Math.PI / 180), // -45 * 1 * (Math.PI / 180),
35 * 1 * (Math.PI / 180), // 35 * 1 * (Math.PI / 180),
35 * 1 * (Math.PI / 180) // 35 * 1 * (Math.PI / 180)
)); // ));
quaternion.setFromEuler(new Euler(0, 0, 0).setFromVector3(target_vector))
// quaternion.setFromAxisAngle(new Vector3(0, 1, 0).normalize(), 45 * 4 * (Math.PI / 180)); // quaternion.setFromAxisAngle(new Vector3(0, 1, 0).normalize(), 45 * 4 * (Math.PI / 180));
// quaternion.setFromAxisAngle(new Vector3(0, 0, 1).normalize(), -45 * 4 * (Math.PI / 180)); // quaternion.setFromAxisAngle(new Vector3(0, 0, 1).normalize(), -45 * 4 * (Math.PI / 180));
camera_rotatetoto.value = quaternion set_moveto(smooth_rotate, quaternion)
controls_targetto.value = target_vector; set_moveto(smooth_target, target_vector)
camera_moveto.value = target_vector; set_moveto(smooth_move, target_vector)
vis_target.value = target_vector; vis_target.value = target_vector;
} }
} }
@ -297,33 +306,30 @@ onAfterRender(() => {
} }
}) })
const koef = 0.02 const koef = 0.02
if (controls_targetto.value) { if (smooth_target.value) {
timer.stopTimer(); timer.stopTimer();
(controls.value as any).target.lerp(controls_targetto.value, koef); (controls.value as any).target.lerp(smooth_target.value, koef);
controls_targetto_count.value -= 1 smooth_target.count -= 1
if (controls_targetto_count.value == 0) { if (smooth_target.count == 0) {
controls_targetto_count.value = COUNT; set_moveto(smooth_target, undefined)
controls_targetto.value = undefined;
} }
} }
if (camera_moveto.value) { if (smooth_move.value) {
timer.stopTimer(); timer.stopTimer();
camera.value?.position.lerp(camera_moveto.value, koef); camera.value?.position.lerp(smooth_move.value, koef);
camera_moveto_count.value -= 1 smooth_move.count -= 1
if (camera_moveto_count.value == 0) { if (smooth_move.count == 0) {
camera.value?.lookAt(camera_moveto.value) // camera.value?.lookAt(camera_moveto.value)
camera_moveto.value = undefined; set_moveto(smooth_move, undefined)
camera_moveto_count.value = COUNT;
} }
} }
if (camera_rotatetoto.value) { if (smooth_rotate.value) {
timer.stopTimer(); timer.stopTimer();
camera.value?.quaternion.slerp(camera_rotatetoto.value, koef); camera.value?.quaternion.slerp(smooth_rotate.value as Quaternion, koef);
camera.value?.quaternion.normalize() camera.value?.quaternion.normalize()
camera_rotatetoto_count.value -= 1; smooth_rotate.count -= 1;
if (camera_rotatetoto_count.value == 0) { if (smooth_rotate.count == 0) {
camera_rotatetoto_count.value = COUNT; set_moveto(smooth_rotate, undefined)
camera_rotatetoto.value = undefined
} }
camera.value?.updateMatrixWorld() camera.value?.updateMatrixWorld()
} }