Przeglądaj źródła

Merge branch 'feature_UI调整' of http://101.231.166.56:3000/elab-damai-h5/h5-webgl-program into feature_UI调整

zjs_project 1 rok temu
rodzic
commit
7d4fdd8edf
2 zmienionych plików z 34 dodań i 13 usunięć
  1. 33 12
      src/mixins/loadModel.js
  2. 1 1
      src/pages/webgl_rxdz/webgl_rxdz.vue

+ 33 - 12
src/mixins/loadModel.js

@@ -491,6 +491,7 @@ export default {
 			const spaceList = (!this.changeSpaces || this.changeSpaces.length ==0) ? this.spaceList : this.changeSpaces; 
 			for (let index = 0; index < spaceList.length; index++) {
 				const element = spaceList[index];
+				
 				const gltfLayoutModels = this.gltfLayouts.filter(item => {
 					return element.layoutId == item.userData.layoutId && element.spaceId == item.userData.spaceId;
 				})
@@ -501,10 +502,14 @@ export default {
 				gltfLayoutModels.sort(function(a, b) {
 					return a.userData.level - b.userData.level
 				});
+
+				let newSpace = this.spaceList.find(item => {
+					return element.spaceId == item.spaceId;
+				})
 				// console.log("对应空间ID的模型数组", this.gltfLayouts, element.spaceId, gltfLayoutModels)
 				for (let j = 0; j < gltfLayoutModels.length; j++) {
 					const cube = gltfLayoutModels[j];
-					this.drawLayoutModel(element, cube);
+					this.drawLayoutModel(newSpace, cube);
 				}
 			}
 		},
@@ -700,7 +705,9 @@ export default {
 					}
 	
 				}
-	
+
+				console.log("模型计算位置x--", cubeInfo.isStepAsideLeft, cubeInfo.isStepAsideRight)
+
 				if (cubeInfo.isStepAsideLeft == 'true' && cubeInfo.isStepAsideRight == 'true') {
 					// console.log("宽度拉伸11111", spaceWidth / modelWidth)
 					positionX = centerX;
@@ -725,12 +732,17 @@ export default {
 						positionX -= parseFloat(cubeInfo.marginRight) / 2;
 					}
 					// console.log("模型计算位置" , parseFloat(cubeInfo.rotation))
+					
+					console.log("模型计算位置--", spaceWidth, modelWidth, scaleX, cubeInfo)
 					// 计算缩放
 					if (parseFloat(cubeInfo.rotation) == 90 || parseFloat(cubeInfo.rotation) == -90) {
 						scaleX = spaceWidth / modelWidth;
 					} else {
 						scaleY = spaceWidth / modelWidth;
 					}
+
+					
+					console.log("模型计算位置--", spaceWidth, modelWidth, scaleX, cubeInfo)
 	
 				}
 	
@@ -754,6 +766,7 @@ export default {
 						scaleX = newModelHeight / modelHeight;
 					}
 					positionY = wallPositionY + newModelHeight / 2;
+					
 				}
 	
 				if (cubeInfo.isStepAsideBottom == 'true' && parseInt(cubeInfo.referenceModelTop) > 0) {
@@ -781,15 +794,18 @@ export default {
 				if (cubeInfo.isStepAsideLeft == 'true' && parseInt(cubeInfo.referenceModelRight) > 0) {
 					// console.log("左边拉伸")
 	
+					// 墙的位置
+					const wallPositionX = centerX - spaceWidth / 2 + (curSpace.spaceWallInfo.wallW ? 10 : 0) +
+						parseFloat(cubeInfo.marginLeft);
+					// 右边参照模型位置
 					const referenceModel = this.gltfLayouts.find(item => {
 						const layoutModelData = item.userData;
 						return layoutModelData.id == parseInt(cubeInfo.referenceModelRight) && layoutModelData
 							.spaceId == cubeInfo.spaceId && layoutModelData.layoutId == cubeInfo.layoutId;
 					})
 					const referenceModelPositionX = referenceModel.position.x * 100 - referenceModel.userData
-						.modelWidth / 2 - parseFloat(cubeInfo.marginLeft);
-					const wallPositionX = centerX - spaceWidth / 2 + (curSpace.spaceWallInfo.wallE ? 10 : 0) +
-						parseFloat(cubeInfo.marginRight);
+						.modelWidth / 2 - parseFloat(cubeInfo.marginRight);
+					
 	
 					const newModelWidth = Math.abs(referenceModelPositionX - wallPositionX);
 					if (Math.abs(parseFloat(cubeInfo.rotation)) == 90) {
@@ -798,7 +814,7 @@ export default {
 						scaleY = newModelWidth / modelWidth;
 					}
 					positionX = wallPositionX + newModelWidth / 2;
-	
+					
 				}
 	
 				if (cubeInfo.isStepAsideRight == 'true' && parseInt(cubeInfo.referenceModelLeft) > 0) {
@@ -853,7 +869,6 @@ export default {
 					}
 					positionY = referenceModelBottomPositionY - newModelHeight / 2;
 				}
-			
 				if(parseInt(cubeInfo.referenceModelLeft) > 0 && parseInt(cubeInfo.referenceModelRight) > 0){
 			
 					const referenceModelLeft = this.gltfLayouts.find(item => {
@@ -881,13 +896,16 @@ export default {
 					}
 			
 					positionX = referenceModelRightPositionX - newModelWidth / 2;
+
 				}
 			
 			}
 			// console.log("模型计算位置--", positionX, positionY)
-			// console.log("模型计算位置", cubeInfo, centerX, centerY, spaceWidth, spaceHeight, modelWidth, modelHeight, spaceId, scaleX, scaleY, positionX, positionY, cubeInfo.modelName)
+			console.log("模型计算位置", cubeInfo, centerX, centerY, spaceWidth, spaceHeight, modelWidth, modelHeight, spaceId, scaleX, scaleY, positionX, positionY, cubeInfo.modelName)
 			let oldPosition = new THREE.Vector3();//当前几何体的位置参数
 			oldPosition.copy(cube.position);
+			let oldScale = new THREE.Vector3();//当前几何体的位置参数
+			oldScale.copy(cube.scale);
 			cube.position.x = positionX / 100;
 			cube.position.z = positionY / 100;
 			cube.rotation.y = rotationY;
@@ -906,19 +924,21 @@ export default {
 					if(cubeInfo.modelName=='BP_XSPACE_deng_01_C'){//灯光
 						this.lightHandle(cube)
 					}else{
-						this.updateInfo(cube,oldPosition,scaleX,scaleY);//实例化方法
+						this.updateInfo(cube,oldPosition,oldScale);//实例化方法
 					}
 				}
 			}else{
 				if(cubeInfo.modelName=='BP_XSPACE_deng_01_C'){//灯光
 					this.lightHandle(cube)
 				}else{
-					this.updateInfo(cube,oldPosition,scaleX,scaleY);//实例化方法
+					this.updateInfo(cube,oldPosition,oldScale);//实例化方法
 				}
 			}
 		},
 		//更新家具模型到页面中
-		updateInfo(cube,oldPosition,scaleX,scaleY){
+		updateInfo(cube,oldPosition,oldScale){
+			const ssss = cube.scale.x / oldScale.x
+			console.log("XXXXXXXXXXXXXXXXX", cube, oldPosition,oldScale, ssss)
 			let lay = this.gltfLayouts.find(it=>it.uniId==cube.uniId);
 			if(cube.instancedMeshIndexList && cube.instancedMeshIndexList.length>0){
 				cube.instancedMeshIndexList.forEach(item=>{
@@ -936,8 +956,9 @@ export default {
 						// instancedMesh.instanceMatrix.needsUpdate = true;//更新之前,必须开启开关
 						// instancedMesh.setMatrixAt(curMeshIndex,stratMatrix);//更新几何体的世界矩阵
 						// this.scene.add(instancedMesh);
+						
 					}else{//更新形变矩阵
-						scaleMatrix.makeScale(scaleX, 1, scaleY);	//获得缩放变化矩阵
+						scaleMatrix.makeScale(cube.scale.x / oldScale.x, 1, cube.scale.z/oldScale.z);	//获得缩放变化矩阵
 						panMatrix.makeTranslation(cube.position.x - oldPosition.x,0,cube.position.z - oldPosition.z);	//获得平移变化矩阵
 						stratMatrix.multiply(scaleMatrix).premultiply(panMatrix);//通过矩阵计算获得最终的形变矩阵
 						instancedMesh.instanceMatrix.needsUpdate = true;//更新之前,必须开启开关

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

@@ -961,7 +961,7 @@
 					// that.updataPageData();
 					that.overChange = false;
 					that.callBackFun && that.callBackFun(true);
-					that.calculateLayoutModelSize(); //重新计算家具位置
+					// that.calculateLayoutModelSize(); //重新计算家具位置
 					that.updateWallModels(); // 替换墙体模型
 					that.changeLayoutModel(); // 改变空间模型
 					// that.changeLayoutModelState(true); // 显示家具模型