quaternion exp

This commit is contained in:
aarizona 2024-08-28 20:39:21 +03:00
parent 3cb27d9821
commit 204394bb04
1 changed files with 18 additions and 2 deletions

View File

@ -237,6 +237,13 @@ const gotoCenterAndDistance = () => {
def_distance.max * 0.5, def_distance.max * 0.5,
def_distance.max * 0.5 def_distance.max * 0.5
); );
clickable.list.forEach(element => {
const el = seekByName(scene.value, `${element.id}_clickable`);
if (el?.visible == false) {
el.visible = true
}
});
} }
loadModels() loadModels()
@ -251,21 +258,28 @@ watch(() => props.source, () => {
watch(() => sidebar, () => { watch(() => sidebar, () => {
if (sidebar.is_open == false) { if (sidebar.is_open == false) {
gotoCenterAndDistance() gotoCenterAndDistance();
} }
if (sidebar.is_open && sidebar.id_clickable) { if (sidebar.is_open && sidebar.id_clickable) {
const clickable = useClickable() const clickable = useClickable()
clickable.list.forEach(element => {
const el = seekByName(scene.value, `${element.id}_clickable`);
if (el?.visible == false) {
el.visible = true
}
});
const target = clickable.list.find(el => el.id == sidebar.id_clickable) const target = clickable.list.find(el => el.id == sidebar.id_clickable)
if (!target) return if (!target) return
const el = seekByName(scene.value, `${sidebar.id_clickable}_clickable`); const el = seekByName(scene.value, `${sidebar.id_clickable}_clickable`);
if (el) { if (el) {
el.visible = false;
(controls.value as any).maxDistance = 10; (controls.value as any).maxDistance = 10;
(controls.value as any).minDistance = 1; (controls.value as any).minDistance = 1;
const target_vector = new Vector3(); const target_vector = new Vector3();
el.getWorldPosition(target_vector); el.getWorldPosition(target_vector);
controls_targetto.value = target_vector; controls_targetto.value = target_vector;
camera_rotatetoto.value = new Quaternion(0, 1, 0.25, -0.25) camera_rotatetoto.value = new Quaternion(-0.5, -0.25, -0.125, 0.875,)
} }
} }
}, { deep: true }) }, { deep: true })
@ -304,6 +318,7 @@ onAfterRender(() => {
if (camera_rotatetoto.value) { if (camera_rotatetoto.value) {
timer.stopTimer(); timer.stopTimer();
camera.value?.quaternion.slerp(camera_rotatetoto.value, 0.01); camera.value?.quaternion.slerp(camera_rotatetoto.value, 0.01);
camera.value?.quaternion.normalize();
camera_rotatetoto_count.value -= 1; camera_rotatetoto_count.value -= 1;
if (camera_rotatetoto_count.value == 0) { if (camera_rotatetoto_count.value == 0) {
camera_rotatetoto_count.value = CAM_MOVETO_COUNT camera_rotatetoto_count.value = CAM_MOVETO_COUNT
@ -315,6 +330,7 @@ const timer = useTimer()
timer.timer_func = () => { timer.timer_func = () => {
if (timer.seconds_left == 0 && !(controls.value as any).autoRotate && (controls.value as any).enabled) { if (timer.seconds_left == 0 && !(controls.value as any).autoRotate && (controls.value as any).enabled) {
gotoCenterAndDistance(); gotoCenterAndDistance();
sidebar.close();
(controls.value as any).autoRotate = true; (controls.value as any).autoRotate = true;
(controls.value as any).autoRotateSpeed = 0.5; (controls.value as any).autoRotateSpeed = 0.5;
} }