|
@@ -146,6 +146,73 @@ export default {
|
|
|
this.furnHandle(list,spaceList)
|
|
|
this.changeSpaces = []
|
|
|
},
|
|
|
+ //加载单个空间的家具模型
|
|
|
+ furnSingleSpaceHandle(space){
|
|
|
+ let arrFrunList = this.arrFrunList;
|
|
|
+ // let space = this.curSpaceObj;
|
|
|
+ let allowSpaceId = [space.spaceId];
|
|
|
+ if(!arrFrunList || arrFrunList.length == 0){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.clearAllLayoutData();//清空家具模型
|
|
|
+ this.promise_list = [];
|
|
|
+ this.gltfLayouts = []; //模型列表,所有空间里面的每个模型(家具)对应一条记录
|
|
|
+
|
|
|
+ let startTime = new Date().getTime();
|
|
|
+ let tmpList = [];//临时数据-精简模型数据
|
|
|
+ let curSpaceList = [];//当前空间的数据对象
|
|
|
+ console.warn("重新加载布局", arrFrunList,this.gltfLayouts,allowSpaceId);
|
|
|
+ //每个空间都处理下,确保空间不遗漏,arrFrunList遍历,如果不同空间使用同一个布局,会出现只处理第一个空间
|
|
|
+ let spaceId = space.spaceId;
|
|
|
+ let signel = arrFrunList.find(it => it.id == space.layoutId);
|
|
|
+ if(signel){//只加载允许的空间的布局,其他不加载
|
|
|
+ let md = JSON.parse(signel.modelJson); //获取布局里面的模型信息
|
|
|
+ //遍历模型信息,获取模型列表
|
|
|
+ for (let i = 0; i < md.modelData.length; i++) {
|
|
|
+ let item = md.modelData[i];
|
|
|
+ item.spaceId = spaceId;
|
|
|
+ item.layoutId = signel.id;
|
|
|
+ item.h5Id = signel.id+""+item.id;//唯一标识
|
|
|
+ if(item.modelName=='BP_furnitureBase_C'){
|
|
|
+ continue;
|
|
|
+ }else{
|
|
|
+ if(spaceId==this.curSpaceObj.spaceId){
|
|
|
+ curSpaceList.push(item);
|
|
|
+ }else{
|
|
|
+ tmpList.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.realList = []
|
|
|
+ this.tmpList = tmpList;
|
|
|
+ this.fliterList(tmpList);//精简模式下,只计算白名单里面的模型位置等信息
|
|
|
+ console.warn("***fliterList***",this.type,this.realList.length);
|
|
|
+ tmpList = this.realList;
|
|
|
+ tmpList = tmpList.concat(curSpaceList);//合并详细空间的模型
|
|
|
+
|
|
|
+ let realFurArr = this.preFurnitureData(tmpList);//统一处理家具模型
|
|
|
+ this.calculateLayoutModelSize() // 提前计算模型的位置
|
|
|
+ tmpList = [];
|
|
|
+ this.realList = [];
|
|
|
+ this.tmpList = []
|
|
|
+ console.log("***realFurArr***", realFurArr,this.gltfLayouts);
|
|
|
+ realFurArr && realFurArr.forEach((item,index) => {
|
|
|
+ this.loadLayFlag = true;
|
|
|
+ this.promise_list.push(
|
|
|
+ new Promise((resolve, reject) => {
|
|
|
+ this.loadLayoutModels(item, resolve);
|
|
|
+ })
|
|
|
+ )
|
|
|
+ });
|
|
|
+ Promise.all(this.promise_list).then(() => {
|
|
|
+ let endTime = new Date().getTime();
|
|
|
+ this.loadLayFlag = false;
|
|
|
+ realFurArr = [];
|
|
|
+ console.log("家具模型全部加载完成,时间:", endTime - startTime, this.gltfLayouts);
|
|
|
+ this.loadLastSpaceModel();//加载剩余空间的家具模型
|
|
|
+ })
|
|
|
+ },
|
|
|
//拆分家具模型加载逻辑
|
|
|
furnHandle(arrFrunList, tmpSpaceList=[]){
|
|
|
if(!arrFrunList || arrFrunList.length == 0){
|
|
@@ -201,28 +268,6 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- // 处理删除模型时,其他空间引用了该模型时的重新载入处理
|
|
|
- // if(this.lastFrunList && this.lastFrunList.length>0){
|
|
|
- // let spaceIds = tmpSpaceList.map(it=>it.spaceId);
|
|
|
- // this.arrFrunList.forEach(signel => {
|
|
|
- // let spaceId = this.spaceList.find(it => it.layoutId == signel.id).spaceId;
|
|
|
- // let md = JSON.parse(signel.modelJson); //获取布局里面的模型信息
|
|
|
- // //遍历模型信息,获取模型列表
|
|
|
- // for (let i = 0; i < md.modelData.length; i++) {
|
|
|
- // let item = md.modelData[i];
|
|
|
- // if(this.lastFrunList.includes(item.modelName) && !spaceIds.includes(spaceId)){
|
|
|
- // item.spaceId = spaceId;
|
|
|
- // item.layoutId = signel.id;
|
|
|
- // item.h5Id = signel.id+""+item.id;//唯一标识
|
|
|
- // if(!tmpList.find(it=>it.h5Id==item.h5Id)){
|
|
|
- // // tmpList.push(item);
|
|
|
- // console.warn("***布局xxxx***", item, signel.id)
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // this.lastFrunList = [];
|
|
|
- // }
|
|
|
this.tmpList = tmpList;
|
|
|
if(this.type==2){//全局精简模型;需要的是所有空间的模型
|
|
|
this.fliterList(tmpList);//精简模式下,只计算白名单里面的模型位置等信息
|
|
@@ -1000,7 +1045,7 @@ export default {
|
|
|
|
|
|
}
|
|
|
// 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();//当前几何体的位置参数
|
|
@@ -1335,7 +1380,14 @@ export default {
|
|
|
const element = this.spaceList.find(it=>it.spaceId == spaceObj.spaceId);
|
|
|
if(element){
|
|
|
this.deleteLayoutModel(element, layoutObj)
|
|
|
- element.layoutId = layoutObj.id
|
|
|
+ element.layoutId = layoutObj.id;
|
|
|
+ if(element.spaceType==15){
|
|
|
+ element.layoutSpaceType = layoutObj.type;//更新布局信息到空间对象里面
|
|
|
+ element.layoutSpaceName = layoutObj.spacexName || layoutObj.name;//更新布局信息到空间对象里面
|
|
|
+ if(this.updataLable && typeof(this.updataLable)=='function'){
|
|
|
+ this.updataLable(element.spaceId,layoutObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
console.log("替换空间的布局ID", spaceObj.spaceId, layoutObj.id);
|
|
|
}
|
|
|
this.changeLayouts.push(layoutObj)
|