store rename
This commit is contained in:
parent
73a1dcb7f1
commit
99b8c6149e
|
@ -42,7 +42,7 @@ const controlsState = reactive({
|
||||||
minAzimuthAngle: (Math.PI / 2) - 0.20,
|
minAzimuthAngle: (Math.PI / 2) - 0.20,
|
||||||
})
|
})
|
||||||
|
|
||||||
const raw_data = useRawData()
|
const raw_dataStore = useRawData()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const source = ref(route.params.target)
|
const source = ref(route.params.target)
|
||||||
|
@ -65,18 +65,18 @@ const sidebarFunc = () => {
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div v-if="raw_data.loading"
|
<div v-if="raw_dataStore.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': raw_data.loading }, 'canvas-wrapper']">
|
<div :class="[{ 'loading': raw_dataStore.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_pan="loadedPan" :key="source as string" />
|
<LoadModels :source="source" :loaded_pan="loadedPan" />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</TresCanvas>
|
</TresCanvas>
|
||||||
<div class="homelink" :class="[{ open: sidebar.is_open }]">
|
<div class="homelink" :class="[{ open: sidebar.is_open }]">
|
||||||
|
|
|
@ -46,7 +46,7 @@ const sidebar = usePromoSidebar();
|
||||||
const sidebar_scene = usePromoScene();
|
const sidebar_scene = usePromoScene();
|
||||||
const clickable = useClickable()
|
const clickable = useClickable()
|
||||||
const loading_store = useLoading()
|
const loading_store = useLoading()
|
||||||
const raw_data = useRawData()
|
const raw_dataStore = useRawData()
|
||||||
|
|
||||||
const { controls, camera, scene, raycaster, renderer } = useTresContext()
|
const { controls, camera, scene, raycaster, renderer } = useTresContext()
|
||||||
const { seekByName, seekAllByName } = useSeek()
|
const { seekByName, seekAllByName } = useSeek()
|
||||||
|
@ -59,9 +59,9 @@ const pointerTexture = await useTexture({
|
||||||
})
|
})
|
||||||
|
|
||||||
const setEnv = async () => {
|
const setEnv = async () => {
|
||||||
envVars.focus = raw_data.max_distance * 0.5
|
envVars.focus = raw_dataStore.data.max_distance * 0.5
|
||||||
if (raw_data.env) {
|
if (raw_dataStore.data.env) {
|
||||||
Object.assign(envVars, raw_data.env)
|
Object.assign(envVars, raw_dataStore.data.env)
|
||||||
} else {
|
} else {
|
||||||
delete envVars.env_displacementmap
|
delete envVars.env_displacementmap
|
||||||
delete envVars.env_normalmap
|
delete envVars.env_normalmap
|
||||||
|
@ -88,8 +88,8 @@ const setEnv = async () => {
|
||||||
const setControls = () => {
|
const setControls = () => {
|
||||||
if (!controls.value) return;
|
if (!controls.value) return;
|
||||||
controls.value.enabled = false;
|
controls.value.enabled = false;
|
||||||
(controls.value as any).minDistance = mobileAndTabletCheck() ? raw_data.min_distance * 0.5 : raw_data.min_distance;
|
(controls.value as any).minDistance = mobileAndTabletCheck() ? raw_dataStore.data.min_distance * 0.5 : raw_dataStore.data.min_distance;
|
||||||
(controls.value as any).maxDistance = raw_data.max_distance;
|
(controls.value as any).maxDistance = raw_dataStore.data.max_distance;
|
||||||
|
|
||||||
camera.value?.position.set(
|
camera.value?.position.set(
|
||||||
(controls.value as any).maxDistance * 0.5,
|
(controls.value as any).maxDistance * 0.5,
|
||||||
|
@ -138,8 +138,8 @@ const loadModels = async () => {
|
||||||
|
|
||||||
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_dataStore.load(props)
|
||||||
raw_data.loading = true
|
raw_dataStore.data.loading = true
|
||||||
|
|
||||||
loading_store.status = 'env'
|
loading_store.status = 'env'
|
||||||
await setEnv()
|
await setEnv()
|
||||||
|
@ -147,13 +147,13 @@ const loadModels = async () => {
|
||||||
loading_store.status = 'other'
|
loading_store.status = 'other'
|
||||||
setControls()
|
setControls()
|
||||||
|
|
||||||
sidebar_scene.setName({ name: raw_data.name, description: raw_data.name })
|
sidebar_scene.setName({ name: raw_dataStore.data.name, description: raw_dataStore.data.name })
|
||||||
|
|
||||||
loading_store.status = 'model'
|
loading_store.status = 'model'
|
||||||
for (let index = 0; index < raw_data.elements.length; index++) {
|
for (let index = 0; index < raw_dataStore.data.elements.length; index++) {
|
||||||
if (process_loading.value !== props.source) return
|
if (process_loading.value !== props.source) return
|
||||||
loading_store.count = index
|
loading_store.count = index
|
||||||
const element = raw_data.elements[index];
|
const element = raw_dataStore.data.elements[index];
|
||||||
const item = {} as model3DType
|
const item = {} as model3DType
|
||||||
|
|
||||||
item.modelUrl = `${IMAGE_URL}/${element.model_file}`
|
item.modelUrl = `${IMAGE_URL}/${element.model_file}`
|
||||||
|
@ -201,7 +201,7 @@ const loadModels = async () => {
|
||||||
((find_element as Mesh).geometry.boundingBox as any).getCenter(world_position);
|
((find_element as Mesh).geometry.boundingBox as any).getCenter(world_position);
|
||||||
(find_element as Mesh).localToWorld(world_position);
|
(find_element as Mesh).localToWorld(world_position);
|
||||||
|
|
||||||
const p = raw_data.min_distance * 0.05
|
const p = raw_dataStore.data.min_distance * 0.05
|
||||||
|
|
||||||
const point_mesh = new Mesh(
|
const point_mesh = new Mesh(
|
||||||
new CircleGeometry(2, 32),
|
new CircleGeometry(2, 32),
|
||||||
|
@ -249,7 +249,7 @@ const loadModels = async () => {
|
||||||
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 as any).enabled = true;
|
(controls.value as any).enabled = true;
|
||||||
raw_data.loading = false;
|
raw_dataStore.data.loading = false;
|
||||||
|
|
||||||
timer.startTimer()
|
timer.startTimer()
|
||||||
if (controls.value && (controls.value as any).autoRotate) {
|
if (controls.value && (controls.value as any).autoRotate) {
|
||||||
|
@ -260,13 +260,13 @@ const loadModels = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const gotoCenterAndDistance = () => {
|
const gotoCenterAndDistance = () => {
|
||||||
(controls.value as any).minDistance = mobileAndTabletCheck() ? raw_data.min_distance * 0.5 : raw_data.min_distance;
|
(controls.value as any).minDistance = mobileAndTabletCheck() ? raw_dataStore.data.min_distance * 0.5 : raw_dataStore.data.min_distance;
|
||||||
(controls.value as any).maxDistance = raw_data.max_distance;
|
(controls.value as any).maxDistance = raw_dataStore.data.max_distance;
|
||||||
controls_targetto.value = new Vector3(0, 0, 0);
|
controls_targetto.value = new Vector3(0, 0, 0);
|
||||||
camera_moveto.value = new Vector3(
|
camera_moveto.value = new Vector3(
|
||||||
raw_data.max_distance * 0.5,
|
raw_dataStore.data.max_distance * 0.5,
|
||||||
raw_data.max_distance * 0.5,
|
raw_dataStore.data.max_distance * 0.5,
|
||||||
raw_data.max_distance * 0.5
|
raw_dataStore.data.max_distance * 0.5
|
||||||
);
|
);
|
||||||
|
|
||||||
clickable.list.forEach(element => {
|
clickable.list.forEach(element => {
|
||||||
|
@ -279,7 +279,7 @@ const gotoCenterAndDistance = () => {
|
||||||
|
|
||||||
watch(() => [props.source, process_loading.value], ([source, process]) => {
|
watch(() => [props.source, process_loading.value], ([source, process]) => {
|
||||||
if (source !== process) {
|
if (source !== process) {
|
||||||
raw_data.$reset()
|
raw_dataStore.$reset()
|
||||||
const loaded = seekByName(scene.value, 'loaded')
|
const loaded = seekByName(scene.value, 'loaded')
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
loaded.children = []
|
loaded.children = []
|
||||||
|
|
|
@ -22,10 +22,11 @@ export const useLoading = defineStore('loading', {
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
getStatus() {
|
getStatus() {
|
||||||
if (this.status == 'model') {
|
const key = this.status as keyof typeof lines;
|
||||||
return `${lines[this.status]}${this.count ? (' ' + (this.count + 1)) : ''}`
|
if (key == 'model') {
|
||||||
|
return `${lines[key]}${this.count ? (' ' + (this.count + 1)) : ''}`
|
||||||
}
|
}
|
||||||
return lines[this.status]
|
return lines[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,16 +4,14 @@ import { SERVER_URL } from '../constants'
|
||||||
export const useRawData = defineStore('raw_data', {
|
export const useRawData = defineStore('raw_data', {
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
} as scene3D
|
data: {} as scene3D
|
||||||
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async load(params: any) {
|
async load(params: any) {
|
||||||
const res = await fetch(`${SERVER_URL}/api/obj/scene/${params.source}/`)
|
const res = await fetch(`${SERVER_URL}/api/obj/scene/${params.source}/`)
|
||||||
const raw_data = await res.json() as scene3D
|
const raw_data = await res.json() as scene3D
|
||||||
// this.$state = Object.assign(this.$state, page)
|
this.data = raw_data
|
||||||
for (const key in raw_data) {
|
|
||||||
this[key] = raw_data[key]
|
|
||||||
}
|
|
||||||
return raw_data
|
return raw_data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue