From 71f00363bdc4bc7c2224d51fc5b0fdc7e512a132 Mon Sep 17 00:00:00 2001 From: wangqiujuan0808 <578331299@qq.com> Date: Sat, 9 Dec 2023 00:53:51 +0800 Subject: [PATCH] 123 --- src/views/bim/bimHome/components/ThreeView.vue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/views/bim/bimHome/components/ThreeView.vue b/src/views/bim/bimHome/components/ThreeView.vue index c7893db..40d4eea 100644 --- a/src/views/bim/bimHome/components/ThreeView.vue +++ b/src/views/bim/bimHome/components/ThreeView.vue @@ -84,10 +84,10 @@ onMounted(() => { }); const init = () => { scene = new THREE.Scene("#00ffff"); - // const texture = new THREE.TextureLoader().load(homeIcon); - // texture.mapping = THREE.EquirectangularReflectionMapping; - // scene.background = texture - // scene.environment = texture + const texture = new THREE.TextureLoader().load(homeIcon); + texture.mapping = THREE.EquirectangularReflectionMapping; + scene.background = texture + scene.environment = texture const canvas = document.querySelector("#three"); var cubeLoader = new THREE.CubeTextureLoader(); @@ -176,6 +176,10 @@ let selectedObject = null; let selectedMaterial = null; const onMouseDown = (event) => { + // 计算鼠标点击位置的归一化设备坐标 + mouse.x = (event.clientX / window.innerWidth) * 2 - 1; + mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; + var raycaster = new THREE.Raycaster() // 恢复之前被选中模型的材质 if (selectedObject && selectedMaterial) { @@ -183,10 +187,6 @@ const onMouseDown = (event) => { selectedObject = null; selectedMaterial = null; } - // 计算鼠标点击位置的归一化设备坐标 - mouse.x = (event.clientX / window.innerWidth) * 2 - 1; - mouse.y = -(event.clientY / window.innerHeight) * 2 + 1; - // 更新射线的起点和方向 raycaster.setFromCamera(mouse, camera); // 计算射线和场景中所有可点击物体的相交情况