144 lines
3.8 KiB
Vue
144 lines
3.8 KiB
Vue
<script setup lang="ts">
|
|
import { reactive, ref, watch } from 'vue';
|
|
import type { Ref } from 'vue'
|
|
import { RouterLink, useRoute } from 'vue-router';
|
|
|
|
import { Vector3 } from 'three';
|
|
import { TresCanvas } from '@tresjs/core';
|
|
import { OrbitControls } from '@tresjs/cientos'
|
|
import '@tresjs/leches/styles'
|
|
|
|
import LoadModels from './load_models.vue'
|
|
import Sidebar from './sidebar.vue'
|
|
import { usePromoSidebar } from '../../stores/promo_sidebar';
|
|
|
|
const minPan = ref(new Vector3(-2, -2, -2))
|
|
const maxPan = ref(new Vector3(2, 2, 2))
|
|
const _v = new Vector3();
|
|
const onChange = (e: any) => {
|
|
if (e.target) {
|
|
_v.copy(e.target);
|
|
e.target.clamp(minPan.value, maxPan.value);
|
|
_v.sub(e.target);
|
|
camera.value.position.sub(_v);
|
|
}
|
|
}
|
|
const loadedPan = (max: any, min: any) => {
|
|
maxPan.value = max
|
|
minPan.value = min
|
|
}
|
|
const sidebar = usePromoSidebar()
|
|
|
|
const camera = ref()
|
|
const cameraPosition = ref([1, 1, 1]) as unknown as Ref<Vector3>
|
|
|
|
const controlsState = reactive({
|
|
enableDamping: false,
|
|
maxPolarAngle: (Math.PI / 2) - 0.05,
|
|
minAzimuthAngle: (Math.PI / 2) - 0.02,
|
|
})
|
|
const models_loading = ref(true)
|
|
const set_model_load_status = (status: boolean) => {
|
|
models_loading.value = status
|
|
}
|
|
|
|
const route = useRoute()
|
|
const source = ref(route.params.target ? (route.params.target.toString() + '/') : '1/')
|
|
watch(() => route.params.target, () => {
|
|
let t = '1/'
|
|
if (route.params.target) t = route.params.target.toString() + '/'
|
|
if (source.value !== t) {
|
|
source.value = t
|
|
models_loading.value = true
|
|
sidebar.close()
|
|
}
|
|
}, { deep: true })
|
|
|
|
import { useControls, TresLeches } from '@tresjs/leches'
|
|
import '@tresjs/leches/dist/style.css'
|
|
const tres_values = useControls({
|
|
focus: {
|
|
value: 150,
|
|
min: 0,
|
|
max: 200,
|
|
step: 1,
|
|
},
|
|
aperture: {
|
|
value: 15,
|
|
min: 1,
|
|
max: 100,
|
|
step: 1,
|
|
},
|
|
maxblur: {
|
|
value: 1,
|
|
min: 0,
|
|
max: 100,
|
|
step: 1,
|
|
},
|
|
})
|
|
</script>
|
|
<template>
|
|
<div>
|
|
<div :class="[{ 'loading': models_loading }, 'canvas-wrapper']">
|
|
<TresCanvas window-size :alpha="false" power-preference="high-performance">
|
|
<TresPerspectiveCamera :position="cameraPosition" ref="camera" />
|
|
<OrbitControls v-bind="controlsState" @change="onChange" make-default />
|
|
<Suspense>
|
|
<LoadModels :source="source" :loaded="set_model_load_status" :loaded_pan="loadedPan"
|
|
:tres_values="tres_values" />
|
|
</Suspense>
|
|
<TresMesh :position-y="-1" :rotate-x="-Math.PI / 2" receive-shadow name="ground" v-if="false">
|
|
<TresPlaneGeometry :args="[200, 200]" />
|
|
<TresShadowMaterial :opacity="0.2" />
|
|
</TresMesh>
|
|
</TresCanvas>
|
|
<div class="homelink">
|
|
<a href="#" @click.prevent="sidebar.open" v-if="!sidebar.is_open">
|
|
<i-mdi-page-previous-outline />
|
|
</a>
|
|
<RouterLink to="/promo/main/">
|
|
<i-mdi-home />
|
|
</RouterLink>
|
|
</div>
|
|
</div>
|
|
<Sidebar />
|
|
</div>
|
|
</template>
|
|
<style scoped lang="scss">
|
|
.canvas-wrapper {
|
|
overflow: hidden;
|
|
height: 100vh;
|
|
width: 100vw;
|
|
position: absolute;
|
|
right: 0;
|
|
left: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
}
|
|
|
|
.loading {
|
|
filter: blur(10px);
|
|
transition: all 300ms linear;
|
|
}
|
|
|
|
.homelink {
|
|
position: absolute;
|
|
right: 2rem;
|
|
bottom: 2rem;
|
|
|
|
svg {
|
|
font-size: 3rem;
|
|
padding: 1.5rem;
|
|
}
|
|
|
|
a {
|
|
margin-top: 2rem;
|
|
border-radius: 50%;
|
|
border: 1px solid white;
|
|
background: white;
|
|
line-height: 1;
|
|
font-size: 0;
|
|
display: block;
|
|
}
|
|
}
|
|
</style> |