diff --git a/front/src/components/Promo/load_models.vue b/front/src/components/Promo/load_models.vue index 66a4256..d18b930 100644 --- a/front/src/components/Promo/load_models.vue +++ b/front/src/components/Promo/load_models.vue @@ -5,12 +5,8 @@ import { MeshStandardMaterial, MeshStandardMaterialParameters, Vector2, Vector3, CircleGeometry, MeshBasicMaterial, - Quaternion, - RingGeometry, - MultiplyBlending, - AdditiveBlending, + Quaternion, AdditiveBlending, } from 'three'; -import { useRoute, useRouter } from 'vue-router'; import { useTresContext, useSeek, useTexture, useLoop } from '@tresjs/core'; import { useGLTF } from '@tresjs/cientos' @@ -34,6 +30,7 @@ const clickable_items = ref([]) const clickable_refs = ref([]) const envVars = reactive({}) as EnvVars const def_distance = reactive({ max: 10, min: 1 }) +const process_loading = ref(null) const controls_targetto = ref() as Ref; const controls_targetto_count = ref(CON_MOVETO_COUNT) @@ -56,7 +53,13 @@ const groundTexture = await useTexture({ const pointerTexture = await useTexture({ map: '/pointer_texture.png' }) +const clearData = () => { + models.value = [] + clickable_items.value = [] + clickable_refs.value = [] +} const loadModels = async () => { + process_loading.value = props.source const res = await fetch(`${SERVER_URL}/api/obj/scene/${props.source}/`) const raw_data = await res.json() as scene3D loading_store.status = 'other' @@ -245,6 +248,8 @@ const loadModels = async () => { if (controls.value && (controls.value as any).autoRotate) { (controls.value as any).autoRotate = false; } + + // process_loading.value = null } const gotoCenterAndDistance = () => { @@ -265,19 +270,16 @@ const gotoCenterAndDistance = () => { }); } -watch(() => props.source, (s) => { - const loaded = seekByName(scene.value, 'loaded') - if (loaded) { - loaded.children = [] - } - models.value = [] - clickable_items.value = [] - clickable_refs.value = [] - sidebar.close() - try { +watch(() => [props.source, process_loading.value], ([source, process]) => { + if (source !== process) { + const loaded = seekByName(scene.value, 'loaded') + if (loaded) { + loaded.children = [] + } + + sidebar.close() + loadModels() - } catch (error) { - console.log(error) } }) diff --git a/front/src/components/nav.vue b/front/src/components/nav.vue index 3b778e1..837d30e 100644 --- a/front/src/components/nav.vue +++ b/front/src/components/nav.vue @@ -30,13 +30,13 @@ console.log(router)