瀏覽代碼

优化布局切换逻辑

zjs_project 1 年之前
父節點
當前提交
f202bb4104
共有 4 個文件被更改,包括 22 次插入14 次删除
  1. 19 13
      src/mixins/loadModel.js
  2. 1 1
      src/pages/webgl_rxdz/webgl_rxdz.vue
  3. 1 0
      src/static/globlShowModel.js
  4. 1 0
      src/static/layoutModelData.js

+ 19 - 13
src/mixins/loadModel.js

@@ -12,8 +12,8 @@ export default {
 			gltfLayouts: [],
 			instancedFurList:[],
 			
-			graderGltfLayouts: [],//花园地块的模型对象
-			graderInstancedFurList:[],//花园地块的模型
+			// graderGltfLayouts: [],//花园地块的模型对象
+			// graderInstancedFurList:[],//花园地块的模型
 			
 			arrFrunList:[],
 			promise_list:[],
@@ -22,7 +22,7 @@ export default {
 			tmpList:[],
 			realList:[],
 			nextString:'_simple',//精简模型后缀
-			lastFrunList:[],
+			// lastFrunList:[],
 		}
 	},
 	watch: {},
@@ -439,11 +439,6 @@ export default {
 		},
 		// 删除对应空间家具模型
 		deleteLayoutModel(spaceObj, layoutObj){
-			if(!layoutObj){//删除完家具模型后,修改空间的布局id为0,表示当前空间不存在布局了
-				spaceObj.delateLayoutId = true;//当前空间已经删除了家具模型
-			}else{
-				spaceObj.delateLayoutId = false;
-			}
 			const oldLayoutIndex = this.arrFrunList.findIndex((item)=>{
 				return item.id == spaceObj.layoutId
 			})
@@ -452,8 +447,11 @@ export default {
 				this.arrFrunList[oldLayoutIndex] = layoutObj
 				// this.arrFrunList.splice(oldLayoutIndex,1)
 			}
-			
-			console.log("准备删除模型", spaceObj, this.gltfLayouts);
+			if(!layoutObj){//当前空间不存在布局了
+				this.arrFrunList.splice(oldLayoutIndex,1)
+				spaceObj.layoutId = null;//为了确保传递到下一页的空间里面也没有布局信息,确保布局一致
+			}
+			console.log("准备删除模型", spaceObj,oldLayoutIndex, this.gltfLayouts);
 			//寻找当前空间下的所有家具模型对象
 			const gltfLayoutModels = this.gltfLayouts.filter(item => {
 				return spaceObj.layoutId == item.userData.layoutId && spaceObj.spaceId == item.userData.spaceId;
@@ -484,7 +482,7 @@ export default {
 				}
 			}
 			this.scene.remove(...deleList);//释放家具的资源,this.instancedFurList
-			console.log("删除模型了", spaceObj, this.gltfLayouts,this.lastFrunList);
+			console.log("删除模型了", spaceObj, this.gltfLayouts);
 		},
 		// 计算家具的位置
 		calculateLayoutModelSize() {
@@ -1112,12 +1110,19 @@ export default {
 							this.loadlayoutByID(layoutObj.groupType, element, resolve);
 						})
 					)
+				}else{//空间不存在布局,需要请求布局信息
+					promise_list.push(
+						new Promise((resolve, reject) => {
+							this.loadlayoutByID(element.groupType, element, resolve);
+						})
+					)
 				}
 			}
 			Promise.all(promise_list).then(()=>{
 				this.$nextTick(()=>{
 					console.log("新布局替换完成",this.changeLayouts, changeSpaces,this.arrFrunList.map(it=>it.id));
 					this.furnHandle(this.changeLayouts, changeSpaces);//先加载变化的空间的布局
+					this.updataPageData();//更新数据
 				})
 			})
 		},
@@ -1160,8 +1165,9 @@ export default {
 				}
 			}
 			if(layoutObj==null){
-				console.warn("没有合适的布局", layoutObj);
-				// this.deleteLayoutModel(spaceObj, layoutObj);//删除当前的布局
+				console.warn("没有合适的布局", layoutObj,spaceObj.layoutId);
+				spaceObj.groupType = groupType;
+				this.deleteLayoutModel(spaceObj, layoutObj);//删除当前的布局
 				return resolve()
 			}
 			console.log("找出最合适的布局", layoutObj)

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

@@ -958,7 +958,7 @@
 					this.moveSpace(curSpace, 2, 3, isZoomIn, newArea, newWidth, newHeight, changeWidth, changeHeight)
 				}
 				setTimeout(() => {
-					that.updataPageData();
+					// that.updataPageData();
 					that.overChange = false;
 					that.callBackFun && that.callBackFun(true);
 					that.calculateLayoutModelSize(); //重新计算家具位置

+ 1 - 0
src/static/globlShowModel.js

@@ -42,6 +42,7 @@ var globlShowModel = [
 	"BP_L_Teatable03",
 	"BP_L_FloorLamp01",
 	"BP_T_stairs01",
+	"BP_T_OpenShower02",
 ];
 
 module.exports = globlShowModel;

+ 1 - 0
src/static/layoutModelData.js

@@ -71,6 +71,7 @@ var layoutModel = [
 	{url: 'https://dm.static.elab-plus.com/miniProgram/model/BP_X_ReadingArea01.gltf', name: '阅读角01',modelName: 'BP_X_ReadingArea01', type:1},
 	
 	{url: 'https://dm.static.elab-plus.com/miniProgram/model/BP_T_OpenShower01.gltf', name: '开敞侧淋浴间',modelName: 'BP_T_OpenShower01', type:1},
+	{url: 'https://dm.static.elab-plus.com/miniProgram/model/BP_T_OpenShower02.glb', name: '开敞侧淋浴间02',modelName: 'BP_T_OpenShower02', type:1},
 	{url: 'https://dm.static.elab-plus.com/miniProgram/model/BP_T_matong.gltf', name: '马桶',modelName: 'BP_T_matong', type:1},
 	{url: 'https://dm.static.elab-plus.com/miniProgram/model/BP_T_1PeopleBasin01.glb', name: '1人台盆01',modelName: 'BP_T_1PeopleBasin01', type:1},
 	{url: 'https://dm.static.elab-plus.com/miniProgram/model/BP_T_flue001.glb', name: '水井管道01',modelName: 'BP_T_flue001', type:1},