autorotate fix

This commit is contained in:
Kseninia Mikhaylova 2024-07-30 09:17:00 +03:00
parent 5d79c35439
commit 6456b5fd52
1 changed files with 6 additions and 1 deletions

View File

@ -25,6 +25,7 @@ const clickable_refs = ref<any[]>([])
const sidebar = usePromoSidebar();
const sidebar_scene = usePromoScene()
const { controls, camera, scene, raycaster, renderer } = useTresContext()
const { pause, resume } = useLoop()
const { seekByName, seekAllByName } = useSeek()
const envVars = reactive({}) as {
focus: number,
@ -41,6 +42,7 @@ const groundTexture = await useTexture({
})
const timer = ref(10)
let int
// renderer.value.capabilities.maxTextures = 4
renderer.value.capabilities.maxTextureSize = 512
@ -184,11 +186,13 @@ const loadModels = async () => {
controls.value.enabled = true;
props.loaded(false)
clearInterval(int)
timer.value = 10
setInterval(() => {
int = setInterval(() => {
if (timer.value > 0) {
timer.value -= 1
} else if (timer.value == 0 && !controls.value.autoRotate) {
pause()
camera.value?.position.set(
controls.value.minDistance * 0.5,
controls.value.minDistance * 0.5,
@ -196,6 +200,7 @@ const loadModels = async () => {
);
(controls.value as any).autoRotate = true;
(controls.value as any).autoRotateSpeed = 1;
resume()
}
}, 1000)
}