|
@@ -11,6 +11,10 @@ export default {
|
|
|
return {
|
|
|
gltfLayouts: [],
|
|
|
instancedFurList:[],
|
|
|
+
|
|
|
+ graderGltfLayouts: [],
|
|
|
+ graderInstancedFurList:[],
|
|
|
+
|
|
|
arrFrunList:[],
|
|
|
promise_list:[],
|
|
|
dracoLoader:null,
|
|
@@ -18,6 +22,7 @@ export default {
|
|
|
tmpList:[],
|
|
|
realList:[],
|
|
|
nextString:'_simple',
|
|
|
+ lastFrunList:[],
|
|
|
}
|
|
|
},
|
|
|
watch: {},
|
|
@@ -69,20 +74,47 @@ export default {
|
|
|
if (!res.success || !res.list || res.list.length == 0) {
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
this.promise_list = [];
|
|
|
this.arrFrunList = res.list;
|
|
|
+ this.gltfLayouts = [];
|
|
|
|
|
|
- this.furnHandle(this.arrFrunList);
|
|
|
+ this.furnHandle(this.arrFrunList,[]);
|
|
|
+ },
|
|
|
+ loadLastSpaceModel(){
|
|
|
+ if(!this.changeSpaces || this.changeSpaces.length==0){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let layoutIds = this.changeSpaces.map(it=>it.layoutId);
|
|
|
+ let list = this.arrFrunList.filter(item=>{
|
|
|
+ return !layoutIds.includes(item.id)
|
|
|
+ })
|
|
|
+ let spaceIds = this.changeSpaces.map(it=>it.spaceId);
|
|
|
+ let spaceList = this.spaceList.filter(item=>{
|
|
|
+ return !spaceIds.includes(item.spaceId)
|
|
|
+ })
|
|
|
+
|
|
|
+ this.furnHandle(list,spaceList)
|
|
|
+ this.changeSpaces = []
|
|
|
},
|
|
|
|
|
|
- furnHandle(arrFrunList, spaceObj = null){
|
|
|
- console.log("bug修复", arrFrunList, spaceObj)
|
|
|
+ furnHandle(arrFrunList, tmpSpaceList=[]){
|
|
|
+ console.log("bug修复", arrFrunList, tmpSpaceList)
|
|
|
if(!arrFrunList || arrFrunList.length == 0){
|
|
|
return
|
|
|
}
|
|
|
let startTime = new Date().getTime();
|
|
|
let tmpList = [];
|
|
|
- this.gltfLayouts = [];
|
|
|
|
|
|
let allowSpaceId = [this.curSpaceObj.spaceId];
|
|
|
if(this.type == 2){
|
|
@@ -97,14 +129,7 @@ export default {
|
|
|
let list = this.spaceList.filter(it=>it.spaceType==4)
|
|
|
allowSpaceId.push(...list.map(it=>it.spaceId));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
console.warn("重新加载布局", arrFrunList,this.spaceList,this.gltfLayouts,allowSpaceId);
|
|
|
arrFrunList.forEach(signel => {
|
|
|
let spaceId = this.spaceList.find(it => it.layoutId == signel.id).spaceId;
|
|
@@ -117,29 +142,49 @@ export default {
|
|
|
item.layoutId = signel.id;
|
|
|
item.h5Id = signel.id+""+item.id;
|
|
|
if(item.modelName=='BP_furnitureBase_C'){
|
|
|
-
|
|
|
- console.warn("***布局1***", item, signel.id)
|
|
|
+
|
|
|
continue;
|
|
|
}else{
|
|
|
tmpList.push(item);
|
|
|
- console.warn("***布局***", item, signel.id)
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
this.tmpList = tmpList;
|
|
|
if(this.type==2){
|
|
|
- this.fliterList(tmpList);
|
|
|
- console.warn("***fliterList***",this.realList.length ,this.realList);
|
|
|
+ this.fliterList(tmpList);
|
|
|
+ console.warn("***fliterList***",this.realList.length);
|
|
|
tmpList = this.realList;
|
|
|
}
|
|
|
let realFurArr = this.preFurnitureData(tmpList);
|
|
|
- if(spaceObj != null){
|
|
|
- this.calculateLayoutModelSizeBySpace(spaceObj)
|
|
|
+ if(tmpSpaceList && tmpSpaceList.length>0){
|
|
|
+ this.calculateLayoutModelSizeBySpace(tmpSpaceList)
|
|
|
}else{
|
|
|
this.calculateLayoutModelSize()
|
|
|
}
|
|
|
-
|
|
|
console.log("***realFurArr***", realFurArr,this.gltfLayouts);
|
|
|
realFurArr && realFurArr.forEach((item,index) => {
|
|
|
this.promise_list.push(
|
|
@@ -151,6 +196,7 @@ export default {
|
|
|
Promise.all(this.promise_list).then(() => {
|
|
|
let endTime = new Date().getTime();
|
|
|
console.log("家具模型全部加载完成,时间:", endTime - startTime, this.gltfLayouts);
|
|
|
+ this.loadLastSpaceModel();
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -207,7 +253,7 @@ export default {
|
|
|
|
|
|
let layoutModel = modelData.find(it => modelName.indexOf(it.modelName) == 0);
|
|
|
|
|
|
- console.log("要加载的模型数据", item.modelName, layoutModel)
|
|
|
+
|
|
|
if (layoutModel && layoutModel.url) {
|
|
|
let object = realFurnitureArr.find(it=>it.url==layoutModel.url);
|
|
|
|
|
@@ -259,6 +305,11 @@ export default {
|
|
|
if(realData.name.includes('BP_XSPACE_deng_01')){
|
|
|
resolve();
|
|
|
}else{
|
|
|
+
|
|
|
+ if(!globlShowModel.includes(realData.name)){
|
|
|
+ resolve();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
that.loader.setDRACOLoader(this.dracoLoader);
|
|
|
that.loader.load(realData.url, ( gltf ) => {
|
|
|
gltf.scene.traverse((child)=> {
|
|
@@ -324,18 +375,34 @@ export default {
|
|
|
resolve();
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
+ clearAllLayoutData(){
|
|
|
+ let deleList = this.scene && this.scene.children.filter(object=>{
|
|
|
+ if(object.userType=="layoutMesh"){
|
|
|
+ return object
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if(deleList && deleList.length>0){
|
|
|
+ this.scene.remove(...deleList);
|
|
|
+ }
|
|
|
+ this.gltfLayouts = [];
|
|
|
+ this.instancedFurList = [];
|
|
|
+ },
|
|
|
|
|
|
changeLayoutModelState(isShow=false){
|
|
|
if(isShow){
|
|
|
this.instancedFurList.forEach(it=>{
|
|
|
- it.visible = isShow;
|
|
|
+ if(it){
|
|
|
+ it.visible = isShow;
|
|
|
+ }
|
|
|
})
|
|
|
- console.log("移动过程中显示隐藏空间家具", this.gltfLayouts,isShow)
|
|
|
+ console.log("移动过程中显示隐藏空间家具", this.gltfLayouts,isShow,this.changeSpaces)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
const changeSpaceList = this.leftSpaces.concat(this.rightSpaces);
|
|
|
- console.log("移动过程中显示隐藏空间家具", this.gltfLayouts,isShow, this.leftSpaces, this.rightSpaces,changeSpaceList);
|
|
|
+ console.log("移动过程中显示隐藏空间家具", this.gltfLayouts,isShow, this.leftSpaces, this.rightSpaces,this.changeSpaces);
|
|
|
for (let index = 0; index < changeSpaceList.length; index++) {
|
|
|
let element = changeSpaceList[index];
|
|
|
let gltfLayoutModels = this.gltfLayouts.filter(item => {
|
|
@@ -369,50 +436,60 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
deleteLayoutModel(spaceObj, layoutObj){
|
|
|
-
|
|
|
- for (let index = 0; index < this.arrFrunList.length; index++) {
|
|
|
- const element = this.arrFrunList[index];
|
|
|
-
|
|
|
+ if(!layoutObj){
|
|
|
+ spaceObj.delateLayoutId = true;
|
|
|
+ }else{
|
|
|
+ spaceObj.delateLayoutId = false;
|
|
|
}
|
|
|
const oldLayoutIndex = this.arrFrunList.findIndex((item)=>{
|
|
|
return item.id == spaceObj.layoutId
|
|
|
})
|
|
|
-
|
|
|
- if(oldLayoutIndex!=-1){
|
|
|
- this.arrFrunList[oldLayoutIndex] = layoutObj;
|
|
|
+
|
|
|
+ if(oldLayoutIndex!=-1 && layoutObj){
|
|
|
+ this.arrFrunList[oldLayoutIndex] = layoutObj
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- console.log("准备删除模型", spaceObj, this.gltfLayouts, this.arrFrunList);
|
|
|
-
|
|
|
+ console.log("准备删除模型", spaceObj, this.gltfLayouts);
|
|
|
+
|
|
|
const gltfLayoutModels = this.gltfLayouts.filter(item => {
|
|
|
return spaceObj.layoutId == item.userData.layoutId && spaceObj.spaceId == item.userData.spaceId;
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
if (!gltfLayoutModels || gltfLayoutModels.length == 0) {
|
|
|
return;
|
|
|
}
|
|
|
let deleList = []
|
|
|
for (let j = 0; j < gltfLayoutModels.length; j++) {
|
|
|
const cube = gltfLayoutModels[j];
|
|
|
-
|
|
|
+ this.gltfLayouts.splice(this.gltfLayouts.findIndex(it=>it.uniId==cube.uniId),1);
|
|
|
if(cube.instancedMeshIndexList && cube.instancedMeshIndexList.length>0){
|
|
|
cube.instancedMeshIndexList.forEach(item=>{
|
|
|
let index = item.instancedMeshIndex;
|
|
|
let instancedMesh = this.instancedFurList[index];
|
|
|
- deleList.push(instancedMesh)
|
|
|
-
|
|
|
+ if(instancedMesh){
|
|
|
+ instancedMesh.dispose();
|
|
|
+ deleList.push(instancedMesh);
|
|
|
+ this.instancedFurList[index] = null;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- this.scene.remove(...deleList);
|
|
|
+ this.scene.remove(...deleList);
|
|
|
+ console.log("删除模型了", spaceObj, this.gltfLayouts,this.lastFrunList);
|
|
|
},
|
|
|
|
|
|
calculateLayoutModelSize() {
|
|
|
console.log("计算家具的位置", this.gltfLayouts,this.changeSpaces);
|
|
|
|
|
|
- const spaceList = this.changeSpaces.length ==0 ? this.spaceList : this.changeSpaces;
|
|
|
+ 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 => {
|
|
@@ -433,21 +510,16 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- calculateLayoutModelSizeBySpace(spaceObj) {
|
|
|
-
|
|
|
- const element = spaceObj;
|
|
|
+ calculateLayoutModelSizeBySpace(spaceList) {
|
|
|
+ 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;
|
|
|
})
|
|
|
-
|
|
|
- const gltfLayoutModelss = this.gltfLayouts.filter(item => {
|
|
|
- return element.spaceId == item.userData.spaceId;
|
|
|
- })
|
|
|
-
|
|
|
- console.log("计算指定空间的家具的位置", spaceObj, element.layoutId, gltfLayoutModels, gltfLayoutModelss);
|
|
|
+
|
|
|
|
|
|
if (!gltfLayoutModels || gltfLayoutModels.length == 0) {
|
|
|
- return;
|
|
|
+ continue;
|
|
|
}
|
|
|
gltfLayoutModels.sort(function(a, b) {
|
|
|
return a.userData.level - b.userData.level
|
|
@@ -457,7 +529,7 @@ export default {
|
|
|
const cube = gltfLayoutModels[j];
|
|
|
this.drawLayoutModel(element, cube);
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
drawLayoutModel(curSpace, cube) {
|
|
@@ -814,7 +886,7 @@ export default {
|
|
|
|
|
|
}
|
|
|
|
|
|
- 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);
|
|
|
cube.position.x = positionX / 100;
|
|
@@ -1002,9 +1074,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
changeLayoutModel(){
|
|
|
-
|
|
|
let changeSpaces = [];
|
|
|
-
|
|
|
|
|
|
for (let index = 0; index < this.changeSpaces.length; index++) {
|
|
|
const element = this.changeSpaces[index];
|
|
@@ -1015,39 +1085,38 @@ export default {
|
|
|
const findListIndex = this.spaceList.findIndex((item)=>{
|
|
|
return item.spaceId == element.spaceId;
|
|
|
})
|
|
|
- if(findListIndex !=-1){
|
|
|
+ if(findListIndex !=-1 && this.spaceList[findListIndex].spaceType!=14){
|
|
|
changeSpaces.push(this.spaceList[findListIndex])
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
console.log("所有变化的空间", changeSpaces)
|
|
|
this.changeLayouts = [];
|
|
|
let promise_list = [];
|
|
|
-
|
|
|
+ if(!changeSpaces || changeSpaces.length==0){
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this.clearAllLayoutData();
|
|
|
for (let index = 0; index < changeSpaces.length; index++) {
|
|
|
let element = changeSpaces[index];
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
let layoutObj = this.arrFrunList.find((item)=>{
|
|
|
return item.id == element.layoutId;
|
|
|
})
|
|
|
console.log("请求布局的对象", layoutObj, element);
|
|
|
if(layoutObj){
|
|
|
-
|
|
|
promise_list.push(
|
|
|
new Promise((resolve, reject) => {
|
|
|
this.loadlayoutByID(layoutObj.groupType, element, resolve);
|
|
|
})
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
Promise.all(promise_list).then(()=>{
|
|
|
this.$nextTick(()=>{
|
|
|
- console.log("新布局替换完成",this.changeLayouts, changeSpaces);
|
|
|
- this.furnHandle(this.changeLayouts, changeSpaces[0]);
|
|
|
+ console.log("新布局替换完成",this.changeLayouts, changeSpaces,,this.arrFrunList.map(it=>it.id));
|
|
|
+ this.furnHandle(this.changeLayouts, changeSpaces);
|
|
|
})
|
|
|
})
|
|
|
},
|
|
@@ -1077,8 +1146,6 @@ export default {
|
|
|
return (item.minWidth * item.minDepth ) <= (spaceObj.spaceWidth * spaceObj.spaceHeight)
|
|
|
})
|
|
|
console.log("过滤适合的布局02", layouts02)
|
|
|
-
|
|
|
-
|
|
|
|
|
|
let layoutObj = null
|
|
|
for (let index = 0; index < layouts02.length; index++) {
|
|
@@ -1093,29 +1160,27 @@ export default {
|
|
|
}
|
|
|
if(layoutObj==null){
|
|
|
console.warn("没有合适的布局", layoutObj);
|
|
|
+
|
|
|
return resolve()
|
|
|
}
|
|
|
console.log("找出最合适的布局", layoutObj)
|
|
|
- console.log("更新空间的布局ID=", layoutObj.id)
|
|
|
+ console.log("更新空间的布局ID=", spaceObj.layoutId)
|
|
|
|
|
|
-
|
|
|
- if(spaceObj.layoutId == layoutObj.id){
|
|
|
-
|
|
|
-
|
|
|
- return resolve()
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
- for (let index = 0; index < this.spaceList.length; index++) {
|
|
|
- const element = this.spaceList[index];
|
|
|
- if(element.spaceId == spaceObj.spaceId){
|
|
|
- this.deleteLayoutModel(element, layoutObj)
|
|
|
- element.layoutId = layoutObj.id
|
|
|
- console.log("替换空间的布局ID", spaceObj.spaceId, layoutObj.id);
|
|
|
- }
|
|
|
+ const element = this.spaceList.find(it=>it.spaceId == spaceObj.spaceId);
|
|
|
+ if(element){
|
|
|
+ this.deleteLayoutModel(element, layoutObj)
|
|
|
+ element.layoutId = layoutObj.id
|
|
|
+ console.log("替换空间的布局ID", spaceObj.spaceId, layoutObj.id);
|
|
|
}
|
|
|
this.changeLayouts.push(layoutObj)
|
|
|
-
|
|
|
resolve()
|
|
|
}
|
|
|
}
|