Merge branch 'bx-696-startproject' of https://git.svs-tech.pro/ksenia_mikhailova/mns-mini-zabor into bx-696-startproject
This commit is contained in:
commit
ac2e31fb1b
|
@ -9,15 +9,33 @@ const controlsState = reactive({
|
|||
enableZoom: false,
|
||||
maxPolarAngle: (Math.PI / 2) - 0.2,
|
||||
})
|
||||
|
||||
const container = ref()
|
||||
const koef = ref()
|
||||
const scrollBlock = (e: Event) => {
|
||||
const { top, bottom, height } = container.value.getBoundingClientRect();
|
||||
const { innerHeight } = window;
|
||||
const partiallyVisible = (top > 0 && top < innerHeight) ||
|
||||
(bottom > 0 && bottom < innerHeight)
|
||||
const visibleHeight = innerHeight - top
|
||||
const h = height * 1.5
|
||||
if (partiallyVisible && visibleHeight < h) {
|
||||
koef.value = visibleHeight / h
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
document.addEventListener('scroll', scrollBlock)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('scroll', scrollBlock)
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="container min-w-full">
|
||||
<div class="container min-w-full outline outline-2" ref="container">
|
||||
<TresCanvas shadows>
|
||||
<TresPerspectiveCamera :position="[-7, 2, 4 ]" />
|
||||
<TresPerspectiveCamera :position="[-7, 2, 4]" />
|
||||
<OrbitControls v-bind="controlsState" make-default />
|
||||
|
||||
<ModelDiagram />
|
||||
<ModelDiagram :koef="koef" />
|
||||
|
||||
<TresDirectionalLight :position="[2, 2, 2]" :intensity="2" color="violet" cast-shadow />
|
||||
<TresDirectionalLight :position="[2, 2, -2]" :intensity="1" color="red" cast-shadow />
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
<script setup lang="ts">
|
||||
const props = defineProps(['koef'])
|
||||
import Item from './item.vue';
|
||||
const k = ref(props.koef || 1)
|
||||
watch(props, () => {
|
||||
k.value = props.koef || 1
|
||||
console.log(k)
|
||||
|
||||
}, { deep: true })
|
||||
</script>
|
||||
<template>
|
||||
<TresMesh :position="[0, 0, 0]" :rotate-x="Math.PI * -0.5" receive-shadow cast-shadow v-if="false">
|
||||
|
@ -8,12 +15,12 @@ import Item from './item.vue';
|
|||
</TresMesh>
|
||||
<Suspense>
|
||||
<TresGroup :translate-y="-2">
|
||||
<Item model-url="/models/kosynka.glb" :target="[0.5, 0.25, 0.5,]" />
|
||||
<Item model-url="/models/kreplaniye_planok.glb" :target="[1, 0.5, 1]" />
|
||||
<Item model-url="/models/planki.glb" :target="[1.5, 1, 1.5,]" />
|
||||
<Item model-url="/models/stolb.glb" :target="[-0.5, 0.25, -0.5,]" />
|
||||
<Item model-url="/models/verh.glb" :target="[-1, 0.5, -1,]" />
|
||||
<Item model-url="/models/zakliopki.glb" :target="[-1.5, 1, -1.5,]" />
|
||||
<Item model-url="/models/kosynka.glb" :position="[0.5 * k, 0.25 * k, 0.5 * k]" />
|
||||
<Item model-url="/models/kreplaniye_planok.glb" :position="[1 * k, 0.5 * k, 1 * k]" />
|
||||
<Item model-url="/models/planki.glb" :position="[1.5 * k, 1 * k, 1.5 * k]" />
|
||||
<Item model-url="/models/stolb.glb" :position="[-0.5 * k, 0.25 * k, -0.5 * k]" />
|
||||
<Item model-url="/models/verh.glb" :position="[-1 * k, 0.5 * k, -1 * k]" />
|
||||
<Item model-url="/models/zakliopki.glb" :position="[-1.5 * k, 1 * k, -1.5 * k]" />
|
||||
</TresGroup>
|
||||
</Suspense>
|
||||
</template>
|
Loading…
Reference in New Issue