diff --git a/src/views/oneMap/BIM/WangJiaPIng.vue b/src/views/oneMap/BIM/WangJiaPIng.vue index 5ee592f..f47c386 100644 --- a/src/views/oneMap/BIM/WangJiaPIng.vue +++ b/src/views/oneMap/BIM/WangJiaPIng.vue @@ -164,10 +164,8 @@ gltf.scene.scale.set(1, 1, 1); // gltf.scene.position.x = -70; gltf.scene.position.y = 2; - cameraReset(cameraPosition, cameraLookat); - - Scene.add(gltf.scene); + // Scene.add(gltf.scene); Scene.traverse(function (child) { if (child.isMesh) { child.frustumCulled = false; @@ -175,7 +173,26 @@ granaryArr.value.push(child); } }); + console.log(gltf); + // gltf.scene.forEach((element) => { + // if ((element.name = "布尔")) { + // let material = new THREE.MeshBasicMaterial({ color: 0xCCCCCC }); // 设置路面颜色为灰色 + // element.children[0] + // // 路面 + // // element.children + // } + // }); + // 遍历模型中的所有网格 + gltf.scene.traverse((child) => { + console.log(child); + if (child.name == "立方体1" || child.name == "立方体2") { + // 修改或替换材质 + // child.material = new THREE.MeshBasicMaterial({ color: 0x545d0c}); // 将材质替换为红色基本材质 + } + }); + // 将模型添加到场景中 + Scene.add(gltf.scene); LoadWater(); }, function (xhr) { @@ -289,8 +306,8 @@ // 是否开启右键拖拽 Controls.value.enablePan = true; // AxesHelper:辅助观察的坐标系 - // const axesHelper = new THREE.AxesHelper(3000); - // Scene.add(axesHelper); + const axesHelper = new THREE.AxesHelper(3000); + Scene.add(axesHelper); }; /** @@ -501,13 +518,14 @@ }); Twater.position.set(0, -1.5, 0); //水体位置x Twater.rotation.x = -Math.PI / 2; + // Twater.rotateZ(-110); Scene.add(Twater); animate(); }; const animate = () => { // 配置动画 requestAnimationFrame(animate); - Twater.material.uniforms["time"].value += 1.0 / 10.0; + Twater.material.uniforms["time"].value += 1.0 / 100.0; }; onBeforeMount(() => { // initGltfFloor(); @@ -545,6 +563,7 @@ }); onBeforeUnmount(() => { + cancelAnimationFrame(animationFrameId.value); bus.off("WJP_BIM_flyTo"); // window.removeEventListener("click", BIMClick); @@ -573,8 +592,6 @@ // 清理渲染器和相机 Camera.value = null; - - cancelAnimationFrame(animationFrameId.value); });