From af63f8262c24be0f5cfec186f7494705bfdaeced Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Mon, 19 Aug 2024 10:16:02 +0300 Subject: [PATCH] fix --- front/src/components/Promo/load_models.vue | 24 ++++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/front/src/components/Promo/load_models.vue b/front/src/components/Promo/load_models.vue index 8f1c207..d8807f5 100644 --- a/front/src/components/Promo/load_models.vue +++ b/front/src/components/Promo/load_models.vue @@ -3,7 +3,8 @@ import { onMounted, onUnmounted, reactive, ref, watch } from 'vue'; import { Box3, Color, DoubleSide, Group, Mesh, PlaneGeometry, MeshStandardMaterial, MeshStandardMaterialParameters, - Vector2, Vector3 + Vector2, Vector3, + Object3D } from 'three'; import { useTresContext, useSeek, useTexture, useLoop } from '@tresjs/core'; @@ -210,20 +211,11 @@ const loadModels = async () => { const { onAfterRender } = useLoop() onAfterRender(() => { - let i = 0.01 clickable_refs.value.map(el => { - // i += 2 - if (el.value[0].children[0] && typeof el.value[0].children[0].lookAt == 'function') { + if (el.value[0] && el.value[0].children[0] && typeof el.value[0].children[0].lookAt == 'function') { el.value[0].children[0].lookAt(camera.value?.position); el.value[0].children[1].lookAt(camera.value?.position); } - if (el.value[0].children[1].position.y < 50 && el.value[0].children[1].position.y > 20) { - el.value[0].children[1].position.y -= i - } else if (el.value[0].children[1].position.y > 20) { - el.value[0].children[1].position.y += i - } - // el.value[0].updateMatrixWorld() - el.value[0]._needsUpdate = true }) if (controls.value) { if (timer.value == 0) { @@ -232,12 +224,12 @@ onAfterRender(() => { } }) -let oldObj = [] -const passShader = (obj) => { - if (obj.isMesh) { +let oldObj = [] as { uuid: string, color: Color }[] +const passShader = (obj: Mesh | Group) => { + if (obj instanceof Mesh) { oldObj.push({ uuid: obj.uuid, color: obj.material.color }) obj.material.color = new Color(1, 0, 0) - } else { + } else if (obj instanceof Group) { for (let c in obj.children) { passShader(obj.children[c]) } @@ -337,7 +329,7 @@ watch(() => sidebar_scene.list, () => { watch(() => sidebar.is_open, () => { if (sidebar.is_open == false) { oldObj.forEach(el => { - const obj = seek(scene.value, 'uuid', el.uuid) + const obj = seek(scene.value, 'uuid', el.uuid) as Mesh obj.material.color = el.color }) }