소스 검색

屋顶跟随地方缩放

caodongdong 1 년 전
부모
커밋
0ec4483203
3개의 변경된 파일32개의 추가작업 그리고 2개의 파일을 삭제
  1. 27 1
      src/mixins/floorMethod.js
  2. 4 1
      src/pages/webgl_rxdz/webgl_rxdz.vue
  3. 1 0
      src/pages/webgl_rxdz_roam/webgl_rxdz_roam.vue

+ 27 - 1
src/mixins/floorMethod.js

@@ -113,8 +113,15 @@ export default {
 							const planeMesh = new THREE.Mesh(planeGeometry, planeMaterial)
 							planeMesh.rotation.x =  Math.PI / 2 ;  // 旋转 180 度
 							planeMesh.position.set(positionX, 2.8, -positionY);
-							planeMesh.userType = "mesh";
+							planeMesh.userType = "mesh"
+							const spaceObj = {
+								spaceId:obj.spaceId,
+								spaceWidth:obj.spaceWidth,
+								spaceHeight:obj.spaceHeight
+							}
+							planeMesh.userData = spaceObj;
 							that.scene.add(planeMesh);
+							that.gltfSpaceRoofs.push(planeMesh);
 						}
 					})
 				}
@@ -327,6 +334,25 @@ export default {
 				// 开始动画
 				tween.start();
 			}
+
+			
+			// 屋顶尺寸调整
+			const cubeRoof = this.gltfSpaceRoofs.find((item)=>{
+			    return item.userData.spaceId == curSpace.spaceId;
+			})
+			if(cubeRoof){
+				let roofScaleX =  curSpace.spaceObj.spaceWidth / cubeRoof.userData.spaceWidth
+				let roofScaleY =  curSpace.spaceObj.spaceHeight / cubeRoof.userData.spaceHeight
+				console.log("屋顶尺寸变化", curSpace.spaceObj, cubeRoof, roofScaleX, roofScaleY)
+				// cubeRoof.scale.x = toScaleX / scaleX;
+				// cubeRoof.scale.z = 0.5;
+				// cubeRoof.position.x = toPx;
+				// cubeRoof.position.z = toPz;
+				cubeRoof.scale.set(roofScaleX,roofScaleY,1);//缩小为原来0.5倍
+				cubeRoof.position.x = toPx;
+				cubeRoof.position.z = toPz;
+				// cubeRoof.position.set(toPx - x, 0, 1);
+			}
 		},
 		//所有空间整体缩放-同时同步到数据里面
 		allSpaceScale(){

+ 4 - 1
src/pages/webgl_rxdz/webgl_rxdz.vue

@@ -53,6 +53,7 @@
 				spaceList:[], // 空间列表
 				spaceListBackup:[], // 空间列表原始尺寸备份,用于墙体比例计算
 				gltfSpaces:[], // 场景中地板模型数组
+				gltfSpaceRoofs:[], // 屋顶模型数组
 				curSpaceObj:null, // 当前选中的空间
 				// curSpaceIndex:-1, // 当前选中的空间索引
 				curWallDirection:"", // 当前选中的墙面
@@ -139,6 +140,7 @@
 			}
 			this.gltfWalls = [];
 			this.gltfSpaces = [];
+			this.gltfSpaceRoofs = [];
 			this.instancedMeshList = [];
 			this.instancedSpaceMeshList = [];
 			this.lableItem = [];
@@ -1648,6 +1650,7 @@
 				
 				this.gltfWalls = [];
 				this.gltfSpaces = [];
+				this.gltfSpaceRoofs = [];
 				this.instancedMeshList = [];
 				this.instancedSpaceMeshList = [];
 				this.lableItem = [];
@@ -2192,7 +2195,7 @@
 			    }
 				this.curHouseObj.houseJson = JSON.stringify(this.spaceList);
 			    //空间动画处理-提取到floorMethod.js中
-				this.changeSpacesAnim({spaceId:spaceObj.spaceId,toScaleX,toScaleZ,toPx,toPz})
+				this.changeSpacesAnim({spaceId:spaceObj.spaceId,toScaleX,toScaleZ,toPx,toPz,spaceObj})
 				// 墙体动画处理
 				//// 根据空间尺寸,更新前提数据
 				const wallObj = this.wallList.find((item)=>{

+ 1 - 0
src/pages/webgl_rxdz_roam/webgl_rxdz_roam.vue

@@ -55,6 +55,7 @@
                 id:'',// 户型编号
                 spaceList:[], // 空间列表
                 gltfSpaces:[], // 场景中地板模型数组
+				gltfSpaceRoofs:[],
                 curSpaceObj:null, // 当前选中的空间
                 // curSpaceIndex:-1, // 当前选中的空间索引
 				spaceId:null,