This commit is contained in:
aarizona 2024-08-29 21:07:50 +03:00
parent f95be5c1f3
commit 2ffcb5daf6
3 changed files with 23 additions and 18 deletions

View File

@ -22,17 +22,17 @@ import { mobileAndTabletCheck } from '../../helpers';
import { useTimer } from '../../stores/timer'; import { useTimer } from '../../stores/timer';
import { useRawData } from '../../stores/raw_data'; import { useRawData } from '../../stores/raw_data';
const props = defineProps(['source', 'loaded', 'loaded_pan']) const props = defineProps(['source', 'loaded_pan'])
const CON_MOVETO_COUNT = 150; const CON_MOVETO_COUNT = 150;
const CAM_MOVETO_COUNT = 100; const CAM_MOVETO_COUNT = 100;
const models = ref<model3DType[]>([]) const models = ref<model3DType[]>([])
const clickable_items = ref<any[]>([]) const clickable_items = ref<any[]>([])
const clickable_refs = ref<any[]>([]) const clickable_refs = ref<any[]>([])
const sidebar_clickable = [] as PromoScene[]
const sidebar_visible = [] as PromoScene[]
const envVars = reactive({}) as EnvVars const envVars = reactive({}) as EnvVars
const process_loading = ref(null) const process_loading = ref(null)
let sidebar_clickable = [] as PromoScene[]
let sidebar_visible = [] as PromoScene[]
let addTexture: any let addTexture: any
const controls_targetto = ref() as Ref<Vector3 | undefined>; const controls_targetto = ref() as Ref<Vector3 | undefined>;
@ -127,11 +127,19 @@ const makeGround = () => {
ground.name = "ground" ground.name = "ground"
models.value.push({ name: 'ground', modelFile: ground }) models.value.push({ name: 'ground', modelFile: ground })
} }
const clearValues = () => {
clickable_items.value = []
clickable_refs.value = []
sidebar_clickable = []
sidebar_visible = []
}
const loadModels = async () => { const loadModels = async () => {
clearValues()
loading_store.status = 'loading' loading_store.status = 'loading'
process_loading.value = props.source process_loading.value = props.source
await raw_data.load(props) await raw_data.load(props)
raw_data.loading = true
loading_store.status = 'env' loading_store.status = 'env'
await setEnv() await setEnv()
@ -239,9 +247,9 @@ const loadModels = async () => {
props.loaded_pan( props.loaded_pan(
new Vector3(box_size.x * 0.5, box_size.y * 0.5, box_size.z * 0.5), new Vector3(box_size.x * 0.5, box_size.y * 0.5, box_size.z * 0.5),
new Vector3(box_size.x * -0.25, box_size.y * -0.25, box_size.z * -0.25), new Vector3(box_size.x * -0.25, box_size.y * -0.25, box_size.z * -0.25),
) );
controls.value.enabled = true; (controls.value as any).enabled = true;
props.loaded(false) raw_data.loading = false;
timer.startTimer() timer.startTimer()
if (controls.value && (controls.value as any).autoRotate) { if (controls.value && (controls.value as any).autoRotate) {

View File

@ -14,6 +14,7 @@ import { PROMOBG } from '../../constants';
import { usePromoSidebar } from '../../stores/promo_sidebar'; import { usePromoSidebar } from '../../stores/promo_sidebar';
import { useLoading } from '../../stores/loading'; import { useLoading } from '../../stores/loading';
import { useItem } from '../../stores/item'; import { useItem } from '../../stores/item';
import { useRawData } from '../../stores/raw_data';
const minPan = ref(new Vector3(-2, -2, -2)) const minPan = ref(new Vector3(-2, -2, -2))
const maxPan = ref(new Vector3(2, 2, 2)) const maxPan = ref(new Vector3(2, 2, 2))
@ -41,20 +42,16 @@ const controlsState = reactive({
maxPolarAngle: (Math.PI / 2) - 0.07, maxPolarAngle: (Math.PI / 2) - 0.07,
minAzimuthAngle: (Math.PI / 2) - 0.20, minAzimuthAngle: (Math.PI / 2) - 0.20,
}) })
const models_loading = ref(true)
const set_model_load_status = (status: boolean) => {
models_loading.value = status
}
const raw_data = useRawData()
const route = useRoute() const route = useRoute()
const source = ref(route.params.target) const source = ref(route.params.target)
watch(() => route.params.target, () => { watch(() => route.params.target, () => {
let t = '1' let t = '1'
if (route.params.target) t = route.params.target if (route.params.target) t = route.params.target as string
if (source.value !== t) { if (source.value !== t) {
source.value = t source.value = t
models_loading.value = true
sidebar.close() sidebar.close()
} }
},) },)
@ -76,19 +73,18 @@ onMounted(() => {
</script> </script>
<template> <template>
<div> <div>
<div v-if="models_loading" <div v-if="raw_data.loading"
style="position: absolute;z-index: 10;font-size: 6rem;text-align: center;top: 50%;left: 50%;transform: translate3d(-50%, -50%, 0);"> style="position: absolute;z-index: 10;font-size: 6rem;text-align: center;top: 50%;left: 50%;transform: translate3d(-50%, -50%, 0);">
{{ loading_store.getStatus() }} {{ loading_store.getStatus() }}
</div> </div>
<div :class="[{ 'loading': models_loading }, 'canvas-wrapper']"> <div :class="[{ 'loading': raw_data.loading }, 'canvas-wrapper']">
<TresCanvas window-size :alpha="false" power-preference="high-performance" :clear-color="PROMOBG" <TresCanvas window-size :alpha="false" power-preference="high-performance" :clear-color="PROMOBG"
:shadows="false"> :shadows="false">
<Stats /> <Stats />
<TresPerspectiveCamera :position="cameraPosition" ref="camera" /> <TresPerspectiveCamera :position="cameraPosition" ref="camera" />
<OrbitControls v-bind="controlsState" @change="onChange" make-default /> <OrbitControls v-bind="controlsState" @change="onChange" make-default />
<Suspense> <Suspense>
<LoadModels :source="source" :loaded="set_model_load_status" :loaded_pan="loadedPan" <LoadModels :source="source" :loaded_pan="loadedPan" :key="source as string" />
:key="source" />
</Suspense> </Suspense>
</TresCanvas> </TresCanvas>
<div class="homelink" :class="[{ open: sidebar.is_open }]"> <div class="homelink" :class="[{ open: sidebar.is_open }]">

View File

@ -23,6 +23,7 @@ interface scene3D {
env_normalmap?: string env_normalmap?: string
clear_color?: string clear_color?: string
} }
loading?: boolean
} }
interface element3DType { interface element3DType {
id: number id: number