parametric model
This commit is contained in:
parent
5cf35c4882
commit
d4d277eacb
|
@ -44,7 +44,7 @@ a[href^="#"] {
|
||||||
}
|
}
|
||||||
|
|
||||||
&-text {
|
&-text {
|
||||||
@apply col-span-5 text-sm prose;
|
@apply col-span-5 text-sm prose whitespace-break-spaces;
|
||||||
|
|
||||||
&-small {
|
&-small {
|
||||||
@apply col-span-10 text-xs min-w-full prose;
|
@apply col-span-10 text-xs min-w-full prose;
|
||||||
|
|
|
@ -4,9 +4,9 @@ import { OrbitControls } from '@tresjs/cientos'
|
||||||
|
|
||||||
const controlsState = reactive({
|
const controlsState = reactive({
|
||||||
minDistance: 1,
|
minDistance: 1,
|
||||||
maxDistance: 10,
|
maxDistance: 5,
|
||||||
enablePan: false,
|
enablePan: false,
|
||||||
enableZoom: false,
|
// enableZoom: false,
|
||||||
maxPolarAngle: (Math.PI / 2) - 0.2,
|
maxPolarAngle: (Math.PI / 2) - 0.2,
|
||||||
})
|
})
|
||||||
// console.log(controlsState)
|
// console.log(controlsState)
|
||||||
|
|
|
@ -1,23 +1,39 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useScroll } from '@vueuse/core';
|
const lamelles_count = useState('lamelles_count', () => 8)
|
||||||
|
const fence_section = useState<number>('fence_section', () => 2000 * 0.001)
|
||||||
const lamelles_count = useState('lamelles_count', () => 3)
|
const parametric = {
|
||||||
const lamelles = reactive({
|
length: {
|
||||||
min: 3,
|
min: 100,
|
||||||
max: 30,
|
max: 2400,
|
||||||
value: lamelles_count
|
step: 10,
|
||||||
})
|
},
|
||||||
const chanreParametres = () => {
|
height: {
|
||||||
lamelles_count.value = lamelles.value
|
min: 220,
|
||||||
|
max: 2400,
|
||||||
|
step: 115,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
const form_state = reactive({
|
||||||
|
length: fence_section.value * 1000,
|
||||||
|
height: lamelles_count.value * parametric.height.step
|
||||||
|
})
|
||||||
|
const changeParametres = () => {
|
||||||
|
const lamelles = Math.floor(form_state.height / parametric.height.step)
|
||||||
|
lamelles_count.value = lamelles
|
||||||
|
fence_section.value = form_state.length * 0.001
|
||||||
|
}
|
||||||
|
watch(form_state, changeParametres, { deep: true })
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<form class="form">
|
<form class="form">
|
||||||
<div class="form-item">
|
<div class="form-item">
|
||||||
<label for="lanelles_count">Количество ламелей</label>
|
<label for="length">Длина секции, мм</label>
|
||||||
<input id="lanelles_count" type="number" :max="lamelles.max" :min="lamelles.min"
|
<input id="length" type="number" v-bind="parametric.length" v-model="form_state.length" />
|
||||||
v-model="lamelles.value" @change="chanreParametres" />
|
</div>
|
||||||
|
<div class="form-item">
|
||||||
|
<label for="height">Высота забора, мм</label>
|
||||||
|
<input id="height" type="number" v-bind="parametric.height" v-model="form_state.height" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -46,12 +46,13 @@ const axis = [
|
||||||
{ axis: 'y', func: 'translateY', },
|
{ axis: 'y', func: 'translateY', },
|
||||||
{ axis: 'z', func: 'translateZ', },
|
{ axis: 'z', func: 'translateZ', },
|
||||||
]
|
]
|
||||||
|
type vectorType = 'x' | 'y' | 'z';
|
||||||
onLoop(() => {
|
onLoop(() => {
|
||||||
if (model.value && props.target) {
|
if (model.value && props.target) {
|
||||||
axis.forEach(element => {
|
axis.forEach(element => {
|
||||||
const point = model.value.position[element.axis]
|
const point = model.value.position[element.axis]
|
||||||
let step = stepbase * target[element.axis]
|
let step = stepbase * target[element.axis as vectorType]
|
||||||
if (Math.abs(point) >= Math.abs(target[element.axis])) {
|
if (Math.abs(point) >= Math.abs(target[element.axis as vectorType])) {
|
||||||
step = 0
|
step = 0
|
||||||
}
|
}
|
||||||
model.value[element.func](step)
|
model.value[element.func](step)
|
||||||
|
|
|
@ -1,21 +1,42 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Vector3 } from 'three';
|
const lamelles_count = useState<number>('lamelles_count')
|
||||||
import Item from './item.vue';
|
const fence_section = useState<number>('fence_section')
|
||||||
const lSize = 0.1
|
|
||||||
const lamelles_count = useState('lamelles_count')
|
const lSize = 0.115
|
||||||
|
const bSize = 0.0235
|
||||||
|
const pillar_size = 80 * 0.001
|
||||||
|
const { scene, renderer, camera } = useTresContext()
|
||||||
|
watch([lamelles_count, fence_section], () => {
|
||||||
|
// console.log(scene)
|
||||||
|
console.log(lamelles_count)
|
||||||
|
renderer.value.render(scene.value, camera.value)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<TresMesh :position="[0, 0, 0]" :rotate-x="Math.PI * -0.5" receive-shadow cast-shadow v-if="false">
|
|
||||||
<TresCircleGeometry :args="[8, 8, 1]" />
|
|
||||||
<TresMeshStandardMaterial color="pink" />
|
|
||||||
</TresMesh>
|
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<TresGroup :position="[1, 0, 1]">
|
<TresGroup>
|
||||||
<template v-for="i in lamelles_count">
|
<ModelItem model-url="/models_one/bottom.glb" :position="[-fence_section * 0.5 - pillar_size, -bSize, 0]"
|
||||||
<Item model-url="/models_one/planka.glb" :position="[0, (lSize * i), 0]" :remove-pos="true" />
|
|
||||||
</template>
|
|
||||||
<Item model-url="/models_one/verh.glb" :position="[0, (lamelles_count + 1) * lSize, 0]"
|
|
||||||
:remove-pos="true" />
|
:remove-pos="true" />
|
||||||
|
<ModelItem model-url="/models_one/bottom.glb" :position="[fence_section * 0.5 + pillar_size, -bSize, 0]"
|
||||||
|
:remove-pos="true" />
|
||||||
|
<ModelItem model-url="/models_one/verh_100.glb"
|
||||||
|
:position="[-fence_section * 0.5, lamelles_count * lSize, 0]" :remove-pos="true" />
|
||||||
|
<ModelItem model-url="/models_one/verh_100.glb"
|
||||||
|
:position="[fence_section * 0.5, lamelles_count * lSize, 0]" :remove-pos="true" />
|
||||||
|
<template v-for="(n, i) in lamelles_count">
|
||||||
|
<TresGroup :position="[-fence_section * 0.5 - pillar_size, (lSize * i), 0]">
|
||||||
|
<ModelItem model-url="/models_one/stolb.glb" :remove-pos="true" />
|
||||||
|
</TresGroup>
|
||||||
|
<TresGroup :position="[fence_section * 0.5 + pillar_size, (lSize * i), 0]" :scale="[-1, 1, 1]">
|
||||||
|
<ModelItem model-url="/models_one/stolb.glb" :remove-pos="true" />
|
||||||
|
</TresGroup>
|
||||||
|
<TresGroup :scale-x="fence_section * 10" :position="[0, (lSize * i), 0.03]">
|
||||||
|
<ModelItem model-url="/models_one/lamel_100.glb" :remove-pos="true" />
|
||||||
|
</TresGroup>
|
||||||
|
</template>
|
||||||
|
<TresGroup :scale-x="fence_section * 10" :position="[0, lamelles_count * lSize, 0]">
|
||||||
|
<ModelItem model-url="/models_one/verh_100.glb" :remove-pos="true" />
|
||||||
|
</TresGroup>
|
||||||
</TresGroup>
|
</TresGroup>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</template>
|
</template>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue