diff --git a/components/calcModels.vue b/components/calcModels.vue index 78d0687..c7121c9 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, + // enablePan: false, + minPolarAngle: degToRad(30), + maxPolarAngle: degToRad(80), }) 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") @@ -50,7 +53,7 @@ watch([section_count, extra_section], () => { let v = (section_count.value + ~~(!!extra_section.value)) * 2 if (v < controlsState.minDistance) v = controlsState.minDistance; if (v > controlsState.maxDistance) v = controlsState.maxDistance; - (camera.value as any).position.normalize().multiplyScalar(v) + // (camera.value as any).position.normalize().multiplyScalar(v) }) - + - + - + + diff --git a/components/model/fence.vue b/components/model/fence.vue index 2729f5e..63cd5ea 100644 --- a/components/model/fence.vue +++ b/components/model/fence.vue @@ -1,7 +1,7 @@ + \ No newline at end of file diff --git a/components/model/parametric.vue b/components/model/parametric.vue index d9cd34e..7c10e28 100644 --- a/components/model/parametric.vue +++ b/components/model/parametric.vue @@ -12,6 +12,7 @@ import { GainMapLoader, } from '@monogrid/gainmap-js' //@ts-ignore import { useGLTF, } from '@tresjs/cientos' import { getColorHexFromRal, type ralTypes } from '../ral'; +import { degToRad, radToDeg } from 'three/src/math/MathUtils.js'; const pillar_color = use_pillar_color() const lamelle_color = use_lamelle_color() @@ -91,12 +92,39 @@ watch(pillar_color, () => { set_material(element, getColorHexFromRal(pillar_color.value)) }) }) -watch([section_count, extra_section], () => { + +const total = ref((section_count.value + ~~(!!extra_section.value))) +const size = ref(Math.ceil(total.value / 4)) +const count = ref((total.value >= 4) ? size.value : total.value) + +watch(() => [section_count.value, extra_section.value], () => { + console.log('parametric line clear') + total.value = (section_count.value + ~~(!!extra_section.value)) + size.value = Math.ceil(total.value / 4); + count.value = (total.value >= 4) ? size.value : total.value; + + const lines_count = (total.value >= 4) ? 4 : 1 const base = seek(scene.value, 'name', 'base') - const n = (section_count.value as number) + ~~(!!extra_section.value) - if (base?.children && n < base?.children.length) { - base.children = [...base?.children.slice(0, n)] + if (base?.children && base.children.length !== lines_count) { + base.children = [...base?.children.slice(0, lines_count)] } + + const lines = seekAll(scene.value, 'name', 'line') + lines.forEach(line => { + let n = size.value + if (lines_count == 1) { + n = total.value + } + if (line.name.endsWith('_4')) { + n = total.value - size.value * 3 + if (n < 0) { + n = 0 + } + } + if (line?.children && n < line?.children.length) { + line.children = [...line?.children.slice(0, n)] + } + }); }) watch(lamelle_count, () => { @@ -104,30 +132,12 @@ watch(lamelle_count, () => { (el: Ref) => { set_material(el.value, getColorHexFromRal(pillar_color.value), lamelle_count.value) }); }) -onMounted(async () => { - const loader = new GainMapLoader(renderer.value) - const result = await loader.loadAsync([ - 'hdrmaps/hdr.webp', - 'hdrmaps/hdr-gainmap.webp', - 'hdrmaps/hdr.json', - ]) - 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 - result.renderTarget.texture.dispose(); -}) -