66 lines
1.7 KiB
Vue
66 lines
1.7 KiB
Vue
<script setup lang="ts">
|
|
import { reactive } from 'vue';
|
|
import { Vector3 } from 'three';
|
|
import { TresCanvas } from '@tresjs/core';
|
|
import { CameraControls, useProgress } from '@tresjs/cientos'
|
|
|
|
import sunset from '../../assets/promo/models/sunset.hdr'
|
|
console.log(sunset)
|
|
|
|
const minPan = new Vector3(-10, 1, -5);
|
|
const maxPan = new Vector3(5, 1, 5);
|
|
const _v = new Vector3();
|
|
|
|
const onChange = (e: any) => {
|
|
_v.copy(e._target);
|
|
e._target.clamp(minPan, maxPan);
|
|
_v.sub(e._target);
|
|
e._camera.position.sub(_v);
|
|
}
|
|
|
|
const cameraPosition = [-6, 4, 25] as unknown as Vector3
|
|
const lightPosition = [3, 3, 3] as unknown as Vector3
|
|
|
|
const controlsState = reactive({
|
|
minDistance: 1,
|
|
maxDistance: 30,
|
|
maxPolarAngle: (Math.PI / 2) - 0.02,
|
|
maxZoom: 1,
|
|
minZoom: 0.2,
|
|
})
|
|
|
|
|
|
const { hasFinishLoading, progress } = await useProgress()
|
|
|
|
</script>
|
|
<template>
|
|
<div :class="[{ 'invisible': !!hasFinishLoading }, 'loader']">
|
|
Загрузка {{ progress }}%
|
|
</div>
|
|
<div :class="[{ 'invisible': !hasFinishLoading }]">
|
|
<TresCanvas window-size alpha shadows clear-color="#87ceeb">
|
|
<TresPerspectiveCamera :position="cameraPosition" />
|
|
<CameraControls v-bind="controlsState" @change="onChange" make-default />
|
|
|
|
<!-- <TresGridHelper :args="[50, 50]" /> -->
|
|
<Suspense>
|
|
<Models />
|
|
</Suspense>
|
|
<!-- <TresDirectionalLight :position="lightPosition" :intensity="10" cast-shadow /> -->
|
|
<!-- <TresAmbientLight /> -->
|
|
</TresCanvas>
|
|
</div>
|
|
</template>
|
|
<style scoped>
|
|
.invisible {
|
|
visibility: hidden;
|
|
}
|
|
|
|
.loader {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
font-size: 2rem;
|
|
min-height: 100vh;
|
|
}
|
|
</style> |