|
|
@ -18,6 +18,7 @@ import { usePromoScene } from '../../stores/promo_scene';
|
|
|
|
import { useClickable } from '../../stores/clickable';
|
|
|
|
import { useClickable } from '../../stores/clickable';
|
|
|
|
import { useLoading } from '../../stores/loading';
|
|
|
|
import { useLoading } from '../../stores/loading';
|
|
|
|
import { mobileAndTabletCheck } from '../../helpers';
|
|
|
|
import { mobileAndTabletCheck } from '../../helpers';
|
|
|
|
|
|
|
|
import { useTimer } from '../../stores/timer';
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps(['source', 'loaded', 'loaded_pan'])
|
|
|
|
const props = defineProps(['source', 'loaded', 'loaded_pan'])
|
|
|
|
|
|
|
|
|
|
|
@ -43,26 +44,6 @@ const pointerTexture = await useTexture({
|
|
|
|
map: '/pointer_texture.png'
|
|
|
|
map: '/pointer_texture.png'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const timer = ref(10)
|
|
|
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
|
|
|
if (timer.value > 0) {
|
|
|
|
|
|
|
|
timer.value -= 1
|
|
|
|
|
|
|
|
} else if (timer.value == 0 && !(controls.value as any).autoRotate && (controls.value as any).enabled) {
|
|
|
|
|
|
|
|
pause()
|
|
|
|
|
|
|
|
if (controls.value && camera.value) {
|
|
|
|
|
|
|
|
camera.value?.position.set(
|
|
|
|
|
|
|
|
(controls.value as any).maxDistance * 0.5,
|
|
|
|
|
|
|
|
(controls.value as any).maxDistance * 0.5,
|
|
|
|
|
|
|
|
(controls.value as any).maxDistance * 0.5
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
(controls.value as any).target = new Vector3(0, 0, 0);
|
|
|
|
|
|
|
|
(controls.value as any).autoRotate = true;
|
|
|
|
|
|
|
|
(controls.value as any).autoRotateSpeed = 0.5;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
resume()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const loadModels = async () => {
|
|
|
|
const loadModels = async () => {
|
|
|
|
const res = await fetch(`${SERVER_URL}/api/obj/scene/${props.source}`)
|
|
|
|
const res = await fetch(`${SERVER_URL}/api/obj/scene/${props.source}`)
|
|
|
|
const raw_data = await res.json() as scene3D
|
|
|
|
const raw_data = await res.json() as scene3D
|
|
|
@ -231,7 +212,7 @@ const loadModels = async () => {
|
|
|
|
controls.value.enabled = true;
|
|
|
|
controls.value.enabled = true;
|
|
|
|
props.loaded(false)
|
|
|
|
props.loaded(false)
|
|
|
|
|
|
|
|
|
|
|
|
timer.value = 10
|
|
|
|
timer.startTimer()
|
|
|
|
if (controls.value && (controls.value as any).autoRotate) {
|
|
|
|
if (controls.value && (controls.value as any).autoRotate) {
|
|
|
|
(controls.value as any).autoRotate = false;
|
|
|
|
(controls.value as any).autoRotate = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -245,7 +226,7 @@ onAfterRender(() => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if (controls.value) {
|
|
|
|
if (controls.value) {
|
|
|
|
if (timer.value == 0) {
|
|
|
|
if (timer.seconds_left == 0) {
|
|
|
|
(controls.value as any).update();
|
|
|
|
(controls.value as any).update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -294,16 +275,13 @@ watch(() => sidebar, () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, { deep: true })
|
|
|
|
}, { deep: true })
|
|
|
|
|
|
|
|
const timerEvent = ['click', 'contextmenu', 'mousedown', 'mouseup', 'touchstart', 'touchend', 'touchmove']
|
|
|
|
onMounted(() => {
|
|
|
|
onMounted(() => {
|
|
|
|
document.addEventListener('click', clickEvent)
|
|
|
|
document.addEventListener('click', clickEvent)
|
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener('click', stopTimer)
|
|
|
|
timerEvent.map((event: string) => {
|
|
|
|
document.addEventListener('contextmenu', stopTimer)
|
|
|
|
document.addEventListener(event, stopTimer)
|
|
|
|
|
|
|
|
})
|
|
|
|
document.addEventListener('touchstart', stopTimer)
|
|
|
|
|
|
|
|
document.addEventListener('touchend', stopTimer)
|
|
|
|
|
|
|
|
document.addEventListener('touchmove', stopTimer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sidebar.is_open) {
|
|
|
|
if (sidebar.is_open) {
|
|
|
|
sidebar.close()
|
|
|
|
sidebar.close()
|
|
|
@ -311,21 +289,36 @@ onMounted(() => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
onUnmounted(() => {
|
|
|
|
onUnmounted(() => {
|
|
|
|
document.removeEventListener('click', clickEvent)
|
|
|
|
document.removeEventListener('click', clickEvent)
|
|
|
|
|
|
|
|
timerEvent.map((event: string) => {
|
|
|
|
document.removeEventListener('click', stopTimer)
|
|
|
|
document.removeEventListener(event, stopTimer)
|
|
|
|
document.removeEventListener('contextmenu', stopTimer)
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
document.removeEventListener('touchstart', stopTimer)
|
|
|
|
|
|
|
|
document.removeEventListener('touchend', stopTimer)
|
|
|
|
|
|
|
|
document.removeEventListener('touchmove', stopTimer)
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const pointer = reactive({ x: 0, y: 0 })
|
|
|
|
const pointer = reactive({ x: 0, y: 0 })
|
|
|
|
const stopTimer = () => {
|
|
|
|
|
|
|
|
timer.value = 10;
|
|
|
|
const timer = useTimer()
|
|
|
|
if (controls.value && (controls.value as any).autoRotate) {
|
|
|
|
timer.timer_func = () => {
|
|
|
|
(controls.value as any).autoRotate = false;
|
|
|
|
if (timer.seconds_left == 0 && !(controls.value as any).autoRotate && (controls.value as any).enabled) {
|
|
|
|
|
|
|
|
pause()
|
|
|
|
|
|
|
|
if (controls.value && camera.value) {
|
|
|
|
|
|
|
|
camera.value?.position.set(
|
|
|
|
|
|
|
|
(controls.value as any).maxDistance * 0.5,
|
|
|
|
|
|
|
|
(controls.value as any).maxDistance * 0.5,
|
|
|
|
|
|
|
|
(controls.value as any).maxDistance * 0.5
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
(controls.value as any).target = new Vector3(0, 0, 0);
|
|
|
|
|
|
|
|
(controls.value as any).autoRotate = true;
|
|
|
|
|
|
|
|
(controls.value as any).autoRotateSpeed = 0.5;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
resume()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const stopTimer = () => {
|
|
|
|
|
|
|
|
timer.resetTimer()
|
|
|
|
|
|
|
|
if ((controls.value as any).autoRotate) {
|
|
|
|
|
|
|
|
(controls.value as any).autoRotate = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const clickEvent = (event: MouseEvent) => {
|
|
|
|
const clickEvent = (event: MouseEvent) => {
|
|
|
|
const x = (event.clientX / window.innerWidth) * 2 - 1
|
|
|
|
const x = (event.clientX / window.innerWidth) * 2 - 1
|
|
|
|
const y = - (event.clientY / window.innerHeight) * 2 + 1
|
|
|
|
const y = - (event.clientY / window.innerHeight) * 2 + 1
|
|
|
|