From c6b97830fa9384cef559c551bd06a73c6da8d8c9 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Wed, 18 Sep 2024 16:29:45 +0300 Subject: [PATCH 1/5] Second light --- components/calcModels.vue | 28 +++++++++++++++++----------- components/model/parametric.vue | 12 ++++++------ utils/material.ts | 4 ++-- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/components/calcModels.vue b/components/calcModels.vue index 78d0687..81218b5 100644 --- a/components/calcModels.vue +++ b/components/calcModels.vue @@ -3,6 +3,7 @@ import { TresCanvas } from '@tresjs/core' import { OrbitControls } from '@tresjs/cientos' //@ts-ignore import { useGLTF } from '@tresjs/cientos' +import { degToRad, radToDeg } from 'three/src/math/MathUtils.js'; const fence_section = use_fence_section() const section_count = use_section_count() @@ -11,11 +12,12 @@ const max_size = use_max_size() const controlsState = reactive({ distance: section_count.value, - minDistance: 7, - maxDistance: 20, + minDistance: 10, + maxDistance: 10, position: { x: 0, y: 0, z: 0 }, enablePan: false, - maxPolarAngle: (Math.PI / 2) - 0.2, + minPolarAngle: degToRad(30), + maxPolarAngle: degToRad(90), }) const cameraStat = reactive({ position: [-4, 2, 8], @@ -26,18 +28,19 @@ const cameraStat = reactive({ const pointLight = ref() const loadAll = async () => { const { scene: light } = await useGLTF('/models_light/zabor_so_svetom.glb') - pointLight.value = light.children[2] - pointLight.value.color = '#f0dea9' - pointLight.value.intensity = pointLight.value.intensity * 0.1 - pointLight.value.shadow.camera.near = 50 + pointLight.value = light.children[2].clone() + pointLight.value.intensity = pointLight.value.intensity * 0.05 pointLight.value.shadow.bias = -0.002 const j = 4 pointLight.value.shadow.mapSize.x = 512 * j pointLight.value.shadow.mapSize.y = 512 * j - const k = 3 + const k = 1 + // pointLight.value.position.x = pointLight.value.position.x * k + // pointLight.value.position.y = pointLight.value.position.y * k + // pointLight.value.position.z = pointLight.value.position.z * k pointLight.value.position.x = pointLight.value.position.x * k - pointLight.value.position.y = pointLight.value.position.y * k + pointLight.value.position.y = pointLight.value.position.z * k pointLight.value.position.z = pointLight.value.position.z * k } const camera = ref("camera") @@ -62,7 +65,7 @@ watch([section_count, extra_section], () => { - + @@ -76,8 +79,11 @@ watch([section_count, extra_section], () => { + diff --git a/components/model/parametric.vue b/components/model/parametric.vue index d9cd34e..4a8db9f 100644 --- a/components/model/parametric.vue +++ b/components/model/parametric.vue @@ -114,12 +114,12 @@ onMounted(async () => { if (renderer.value && camera.value) { renderer.value.render(scene.value, camera.value) } - scene.value.environment = result.renderTarget.texture - scene.value.background = result.renderTarget.texture - scene.value.background.mapping = EquirectangularReflectionMapping - scene.value.backgroundRotation = new Euler(0, 10, 0) - scene.value.backgroundIntensity = 1.5 - scene.value.backgroundBlurriness = 0.06 + // scene.value.environment = result.renderTarget.texture + // scene.value.background = result.renderTarget.texture + // scene.value.background.mapping = EquirectangularReflectionMapping + // scene.value.backgroundRotation = new Euler(0, 10, 0) + // scene.value.backgroundIntensity = 1.5 + // scene.value.backgroundBlurriness = 0.06 result.renderTarget.texture.dispose(); }) diff --git a/utils/material.ts b/utils/material.ts index b9a6cdf..9a40cdd 100644 --- a/utils/material.ts +++ b/utils/material.ts @@ -1,5 +1,5 @@ import { Color, DoubleSide, MeshBasicMaterial, MeshStandardMaterial, RepeatWrapping, TextureLoader, Vector2 } from "three" -import { useLoader } from '@tresjs/core' +import { useLoader, type TresLoader } from '@tresjs/core' const set_metaril_func = (scene: any, material: any) => { scene.children.forEach((el: any) => { @@ -31,7 +31,7 @@ export const set_material = (scene: any, color: any, count: number | undefined = color: new Color(c || '#9c9c00'), alphaMap: count ? texture : null, transparent: true, - opacity: 0.75, + opacity: 1, // roughness: 0.5, // metalness: 0, side: DoubleSide, From 6a25442c191028015b0bb657037c82cace4b5651 Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Wed, 18 Sep 2024 17:01:13 +0300 Subject: [PATCH 2/5] sides --- components/model/fence.vue | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/components/model/fence.vue b/components/model/fence.vue index 2729f5e..f17004f 100644 --- a/components/model/fence.vue +++ b/components/model/fence.vue @@ -87,6 +87,26 @@ watch([section_count, fence_section, extra_section], () => { pillar_two_pos.value = fence_section.value * 0.5 + pillar_size + bSize - 0.01 // translate_to_section.value = make_translate_to_section() } + + if ((section_count.value + ~~(!!extra_section.value)) > 3) { + const total = (section_count.value + ~~(!!extra_section.value)) + const size = Math.ceil(total / 4) + console.log({ total, size, index: props.index }); + switch(Math.ceil(props.index / size)) { + case 1: + console.log('1') + break; + case 2: + console.log('2') + break; + case 3: + console.log('3') + break; + case 4: + console.log('4') + break; + } + } })