|
@@ -1,6 +1,7 @@
|
|
|
|
|
|
const config = require('@/services/urlConfig.js');
|
|
|
import modelData from '@/static/layoutModelData.js';
|
|
|
+import globlShowModel from '@/static/globlShowModel.js';
|
|
|
|
|
|
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
|
|
|
import * as THREE from 'three';
|
|
@@ -12,22 +13,25 @@ export default {
|
|
|
instancedFurList:[],
|
|
|
arrFrunList:[],
|
|
|
promise_list:[],
|
|
|
- loadFurPromise: new Promise((resolve) => {
|
|
|
- this.loadedCompleteFun = function() {
|
|
|
- console.log('家具模型接口结束');
|
|
|
- resolve()
|
|
|
- }
|
|
|
- }),
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
dracoLoader:null,
|
|
|
+ type:1,
|
|
|
+ tmpList:[],
|
|
|
+ realList:[],
|
|
|
}
|
|
|
},
|
|
|
watch: {},
|
|
|
mounted() {
|
|
|
console.warn("***loadmodel-mounted****")
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ this.dracoLoader = new DRACOLoader();
|
|
|
+ this.dracoLoader.setDecoderPath('/gltf/');
|
|
|
+ this.dracoLoader.setDecoderConfig( { type: 'js' } );
|
|
|
+ this.dracoLoader.preload();
|
|
|
},
|
|
|
methods: {
|
|
|
|
|
@@ -55,25 +59,23 @@ export default {
|
|
|
spaceWallInfo.wallS = wallSIndex == -1 ? false : true;
|
|
|
element.spaceWallInfo = spaceWallInfo;
|
|
|
}
|
|
|
- await this.loadFurPromise;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.calculateLayoutModelSize()
|
|
|
- })
|
|
|
+
|
|
|
},
|
|
|
|
|
|
- async getOverallArrangementDetailsList() {
|
|
|
+ async getOverallArrangementDetailsList(type=1) {
|
|
|
|
|
|
|
|
|
+ this.type = type;
|
|
|
let arr = this.spaceList.map(it => it.layoutId).filter(it => it != 0);
|
|
|
let parmas = {
|
|
|
ids: arr,
|
|
|
};
|
|
|
- this.loadFurPromise = new Promise((resolve, reject) => {
|
|
|
- this.loadedCompleteFun = function() {
|
|
|
- console.log('家具模型接口结束');
|
|
|
- resolve()
|
|
|
- }
|
|
|
- })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
let res = await requestConfig("getOverallArrangementDetailsList", parmas);
|
|
|
if (!res.success || !res.list || res.list.length == 0) {
|
|
|
return false;
|
|
@@ -89,16 +91,21 @@ export default {
|
|
|
this.gltfLayouts = [];
|
|
|
|
|
|
let allowSpaceId = [this.curSpaceObj.spaceId];
|
|
|
-
|
|
|
- if(this.curSpaceObj.spaceId==758){
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- this.spaceList.forEach(it=>{
|
|
|
- if(it.spaceType==14){
|
|
|
-
|
|
|
+ if(this.type == 2){
|
|
|
+ allowSpaceId = this.spaceList.map(it=>it.spaceId)
|
|
|
+ }else{
|
|
|
+ allowSpaceId = [this.curSpaceObj.spaceId];
|
|
|
+ if(this.curSpaceObj.spaceId==758){
|
|
|
+ allowSpaceId.push(735);
|
|
|
}
|
|
|
- })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
this.arrFrunList.forEach(signel => {
|
|
|
let spaceId = this.spaceList.find(it => it.layoutId == signel.id).spaceId;
|
|
|
if(allowSpaceId.includes(spaceId)){
|
|
@@ -109,44 +116,84 @@ export default {
|
|
|
let item = md.modelData[i];
|
|
|
item.spaceId = spaceId;
|
|
|
item.layoutId = signel.id;
|
|
|
- tmpList.push(item);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ item.h5Id = signel.id+""+item.id;
|
|
|
+ if(item.modelName=='BP_furnitureBase_C'){
|
|
|
+ continue;
|
|
|
+ }else{
|
|
|
+ tmpList.push(item);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
})
|
|
|
- let realFurArr = this.preFurnitureData(tmpList);
|
|
|
- let arrLength = realFurArr.length;
|
|
|
- console.log("***realFurArr***", realFurArr);
|
|
|
+ this.tmpList = tmpList;
|
|
|
+ if(this.type==2){
|
|
|
+ this.fliterList(tmpList);
|
|
|
+ console.warn("***fliterList***",this.realList.length ,this.realList);
|
|
|
+ tmpList = this.realList;
|
|
|
+ }
|
|
|
+ let realFurArr = [];
|
|
|
+ realFurArr = this.preFurnitureData(tmpList);
|
|
|
+ this.calculateLayoutModelSize()
|
|
|
+ console.log("***realFurArr***", realFurArr,this.gltfLayouts);
|
|
|
realFurArr && realFurArr.forEach((item,index) => {
|
|
|
this.promise_list.push(
|
|
|
new Promise((resolve, reject) => {
|
|
|
- this.loadLayoutModels(item, arrLength , resolve);
|
|
|
+ this.loadLayoutModels(item, resolve);
|
|
|
})
|
|
|
)
|
|
|
});
|
|
|
Promise.all(this.promise_list).then(() => {
|
|
|
let endTime = new Date().getTime();
|
|
|
console.log("家具模型全部加载完成,时间:", endTime - startTime);
|
|
|
- this.loadedCompleteFun()
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ fliterList(list){
|
|
|
+ this.realList = [];
|
|
|
+
|
|
|
+ list && list.forEach((mod)=>{
|
|
|
+ let name = mod.modelName.substring(0,mod.modelName.length-2);
|
|
|
+ if(globlShowModel.includes(name)){
|
|
|
+ this.realList.push(mod);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.realList.forEach((ref)=>{
|
|
|
+ this.recursionFliter(ref)
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ recursionFliter(item){
|
|
|
+ let _list = [];
|
|
|
+ if(parseInt(item.referenceModelBottom) > 0){
|
|
|
+ _list.push(item.referenceModelBottom)
|
|
|
+ }
|
|
|
+ if(parseInt(item.referenceModelLeft) > 0){
|
|
|
+ _list.push(item.referenceModelLeft)
|
|
|
+ }
|
|
|
+ if(parseInt(item.referenceModelRight) > 0){
|
|
|
+ _list.push(item.referenceModelRight)
|
|
|
+ }
|
|
|
+ if(parseInt(item.referenceModelTop) > 0){
|
|
|
+ _list.push(item.referenceModelTop)
|
|
|
+ }
|
|
|
+ if(_list.length==0){
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ this.tmpList.forEach(tmp=>{
|
|
|
+ if(_list.includes(tmp.id)){
|
|
|
+ if(!this.realList.find(it=>it.h5Id==tmp.h5Id)){
|
|
|
+ this.realList.push(tmp);
|
|
|
+ this.recursionFliter(tmp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
|
|
|
preFurnitureData(list){
|
|
|
let realFurnitureArr = [];
|
|
|
- let dataList = [];
|
|
|
- dataList = list.map(item=>{
|
|
|
- let curSpace = this.spaceList.find(space=>space.spaceId==item.spaceId);
|
|
|
- return this.resetModelParameters(curSpace, item);
|
|
|
- })
|
|
|
- dataList && dataList.forEach((item, index) => {
|
|
|
+ list && list.forEach((item, index) => {
|
|
|
item.uniId = Date.now() + index;
|
|
|
|
|
|
let modelName = item.modelName;
|
|
@@ -165,87 +212,79 @@ export default {
|
|
|
}else{
|
|
|
object.list.push(item);
|
|
|
}
|
|
|
+
|
|
|
+ let position = new THREE.Vector3();
|
|
|
+ let scale = new THREE.Vector3();
|
|
|
+ let rotation = new THREE.Vector3();
|
|
|
+ let md = {
|
|
|
+ uniId:item.uniId,
|
|
|
+ spaceId:item.spaceId,
|
|
|
+ id:item.id,
|
|
|
+ userData:item,
|
|
|
+ position:position,
|
|
|
+ scale:scale,
|
|
|
+ rotation:rotation,
|
|
|
+ loaded:false,
|
|
|
+ };
|
|
|
+ this.gltfLayouts.push(md);
|
|
|
}
|
|
|
});
|
|
|
return realFurnitureArr;
|
|
|
},
|
|
|
|
|
|
- loadLayoutModels(realData, arrLength, resolve){
|
|
|
+ loadLayoutModels(realData, resolve){
|
|
|
var that = this;
|
|
|
if(!realData.url){
|
|
|
console.warn("***家具模型不存在***",realData);
|
|
|
resolve();
|
|
|
return false;
|
|
|
}
|
|
|
- that.loader.setDRACOLoader(this.dracoLoader);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- that.loader.load(realData.url, ( gltf ) => {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- gltf.scene.traverse((child)=> {
|
|
|
- if (child.isMesh && child.visible) {
|
|
|
- let instancedMesh = new THREE.InstancedMesh(child.geometry.clone(), child.material.clone(), realData.list.length);
|
|
|
- this.instancedFurList.push(instancedMesh);
|
|
|
-
|
|
|
- realData.list && realData.list.forEach((it,i)=>{
|
|
|
- let rotationY = Math.PI / 2;
|
|
|
- if (parseFloat(it.rotation) == 90) {
|
|
|
- rotationY = 0;
|
|
|
- }
|
|
|
- if (parseFloat(it.rotation) == 180) {
|
|
|
- rotationY = -Math.PI / 2;
|
|
|
- }
|
|
|
- if (parseFloat(it.rotation) == -90) {
|
|
|
- rotationY = -Math.PI;
|
|
|
- }
|
|
|
- gltf.scene.rotation.y = rotationY;
|
|
|
- gltf.scene.updateMatrixWorld();
|
|
|
- instancedMesh.setMatrixAt(i, child.matrixWorld);
|
|
|
- instancedMesh.instanceMatrix.needsUpdate = true;
|
|
|
-
|
|
|
-
|
|
|
- let gltfFurn = that.gltfLayouts.find(itme=>itme.uniId==it.uniId);
|
|
|
- if(!gltfFurn){
|
|
|
- let position = new THREE.Vector3();
|
|
|
- let scale = new THREE.Vector3();
|
|
|
- let rotation = new THREE.Vector3();
|
|
|
- let md = {
|
|
|
- uniId:it.uniId,
|
|
|
- spaceId:it.spaceId,
|
|
|
- id:it.id,
|
|
|
- instancedMeshIndexList:[
|
|
|
+ if(realData.name.includes('BP_XSPACE_deng_01')){
|
|
|
+ resolve();
|
|
|
+ }else{
|
|
|
+ that.loader.setDRACOLoader(this.dracoLoader);
|
|
|
+ that.loader.load(realData.url, ( gltf ) => {
|
|
|
+ gltf.scene.traverse((child)=> {
|
|
|
+ if (child.isMesh && child.visible) {
|
|
|
+ let instancedMesh = new THREE.InstancedMesh(child.geometry.clone(), child.material.clone(), realData.list.length);
|
|
|
+ this.instancedFurList.push(instancedMesh);
|
|
|
+
|
|
|
+ realData.list && realData.list.forEach((it,i)=>{
|
|
|
+ let gltfFurn = that.gltfLayouts.find(itme=>itme.uniId==it.uniId);
|
|
|
+ if(!gltfFurn){
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+ gltf.scene.rotation.y = gltfFurn.rotation.y;
|
|
|
+ gltf.scene.position.set(gltfFurn.position.x,0,gltfFurn.position.z);
|
|
|
+ gltf.scene.scale.set(gltfFurn.scale.x,1,gltfFurn.scale.z);
|
|
|
+ gltf.scene.updateMatrixWorld();
|
|
|
+ instancedMesh.setMatrixAt(i, child.matrixWorld);
|
|
|
+ instancedMesh.instanceMatrix.needsUpdate = true;
|
|
|
+ gltfFurn.loaded = true;
|
|
|
+ if(!gltfFurn.instancedMeshIndexList){
|
|
|
+ gltfFurn.instancedMeshIndexList = [
|
|
|
{instancedMeshIndex:this.instancedFurList.length-1,instancedAtIndex:i},
|
|
|
- ],
|
|
|
- userData:it,
|
|
|
- position:position,
|
|
|
- scale:scale,
|
|
|
- rotation:rotation,
|
|
|
- loaded:false,
|
|
|
- };
|
|
|
- that.gltfLayouts.push(md);
|
|
|
+ ]
|
|
|
+ }else{
|
|
|
+ gltfFurn.instancedMeshIndexList.push({
|
|
|
+ instancedMeshIndex:this.instancedFurList.length-1,instancedAtIndex:i
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ instancedMesh.userType = "layoutMesh";
|
|
|
+ if(realData.name.includes("BP_L_carpet01")){
|
|
|
+ instancedMesh.receiveShadow = true;
|
|
|
}else{
|
|
|
- gltfFurn.instancedMeshIndexList.push({
|
|
|
- instancedMeshIndex:this.instancedFurList.length-1,instancedAtIndex:i
|
|
|
- })
|
|
|
+ instancedMesh.castShadow = true;
|
|
|
}
|
|
|
- })
|
|
|
- instancedMesh.userType = "layoutMesh";
|
|
|
- if(realData.name.includes("BP_L_carpet01")){
|
|
|
- instancedMesh.receiveShadow = true;
|
|
|
- }else{
|
|
|
- instancedMesh.castShadow = true;
|
|
|
+ this.scene.add(instancedMesh);
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
+ resolve();
|
|
|
});
|
|
|
- resolve();
|
|
|
- });
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
|
|
|
loadLayoutModelsOld(modelObj, resolve) {
|
|
@@ -262,11 +301,11 @@ export default {
|
|
|
that.loader.load(url, (gltf) => {
|
|
|
|
|
|
let model = gltf.scene;
|
|
|
-
|
|
|
+
|
|
|
model.name = layoutModel.modelName;
|
|
|
model.userType = "layoutMesh";
|
|
|
model.userData = modelObj;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
this.gltfLayouts.push(model);
|
|
|
resolve();
|
|
@@ -300,42 +339,42 @@ export default {
|
|
|
centerX,
|
|
|
spaceId
|
|
|
} = curSpace;
|
|
|
-
|
|
|
- const cubeInfo = cube.userData;
|
|
|
+ const cubeInfo = this.resetModelParameters(curSpace, cube.userData);
|
|
|
+
|
|
|
let centerY = curSpace.centerY * -1;
|
|
|
|
|
|
let positionX = centerX;
|
|
|
let positionY = centerY;
|
|
|
-
|
|
|
+ let rotationY = Math.PI / 2;
|
|
|
let scaleX = 1;
|
|
|
let scaleY = 1;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
let spaceWidth = curSpace.spaceWidth;
|
|
|
let spaceHeight = curSpace.spaceHeight;
|
|
|
|
|
|
let modelWidth = cubeInfo.modelWidth;
|
|
|
let modelHeight = cubeInfo.modelHeight;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ if (parseFloat(cubeInfo.rotation) == 90) {
|
|
|
+ rotationY = 0;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ if (parseFloat(cubeInfo.rotation) == 180) {
|
|
|
+ rotationY = -Math.PI / 2;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (parseFloat(cubeInfo.rotation) == -90) {
|
|
|
+ rotationY = -Math.PI;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if (cubeInfo.isStepAsideLeft == 'true') {
|
|
|
positionX = centerX - (spaceWidth / 2 - modelWidth / 2);
|
|
@@ -346,7 +385,7 @@ export default {
|
|
|
positionX += curSpace.spaceWallInfo.wallW ? 10 : 0;
|
|
|
}
|
|
|
if (cubeInfo.isStepAsideRight == 'true') {
|
|
|
- positionX = centerX + (spaceWidth / 2 - modelHeight / 2);
|
|
|
+ positionX = centerX + (spaceWidth / 2 - modelWidth / 2);
|
|
|
if (parseFloat(cubeInfo.rotation) == 90 || parseFloat(cubeInfo.rotation) == -90) {
|
|
|
positionX = centerX + (spaceWidth / 2 - modelWidth / 2);
|
|
|
}
|
|
@@ -354,7 +393,7 @@ export default {
|
|
|
positionX -= curSpace.spaceWallInfo.wallE ? 10 : 0;
|
|
|
}
|
|
|
if (cubeInfo.isStepAsideTop == 'true') {
|
|
|
- positionY = centerY - (spaceHeight / 2 - modelWidth / 2);
|
|
|
+ positionY = centerY - (spaceHeight / 2 - modelHeight / 2);
|
|
|
if (parseFloat(cubeInfo.rotation) == 90 || parseFloat(cubeInfo.rotation) == -90) {
|
|
|
positionY = centerY - (spaceHeight / 2 - modelHeight / 2);
|
|
|
}
|
|
@@ -378,6 +417,10 @@ export default {
|
|
|
return layoutModelData.id == parseInt(cubeInfo.referenceModelTop) && layoutModelData
|
|
|
.spaceId == cubeInfo.spaceId && layoutModelData.layoutId == cubeInfo.layoutId;
|
|
|
})
|
|
|
+ if(!referenceModel){
|
|
|
+ console.warn("***no-data***",cubeInfo.referenceModelTop,cubeInfo)
|
|
|
+ return false
|
|
|
+ }
|
|
|
positionY = referenceModel.position.z * 100 + (referenceModel.userData.modelHeight / 2 + cubeInfo
|
|
|
.modelHeight / 2);
|
|
|
positionY = positionY + parseFloat(cubeInfo.marginTop);
|
|
@@ -388,6 +431,10 @@ export default {
|
|
|
return layoutModelData.id == parseInt(cubeInfo.referenceModelBottom) && layoutModelData
|
|
|
.spaceId == cubeInfo.spaceId && layoutModelData.layoutId == cubeInfo.layoutId;
|
|
|
})
|
|
|
+ if(!referenceModel){
|
|
|
+ console.warn("***no-data***",cubeInfo.referenceModelBottom,cubeInfo)
|
|
|
+ return false
|
|
|
+ }
|
|
|
positionY = referenceModel.position.z * 100 - (referenceModel.userData.modelHeight / 2 + cubeInfo
|
|
|
.modelHeight / 2);
|
|
|
positionY = positionY - parseFloat(cubeInfo.marginBottom);
|
|
@@ -398,6 +445,10 @@ export default {
|
|
|
return layoutModelData.id == parseInt(cubeInfo.referenceModelLeft) && layoutModelData
|
|
|
.spaceId == cubeInfo.spaceId && layoutModelData.layoutId == cubeInfo.layoutId;
|
|
|
})
|
|
|
+ if(!referenceModel){
|
|
|
+ console.warn("***no-data***",cubeInfo.referenceModelLeft,cubeInfo)
|
|
|
+ return false
|
|
|
+ }
|
|
|
positionX = referenceModel.position.x * 100 + (referenceModel.userData.modelWidth / 2 + cubeInfo
|
|
|
.modelWidth / 2);
|
|
|
positionX = positionX + parseFloat(cubeInfo.marginLeft);
|
|
@@ -408,18 +459,22 @@ export default {
|
|
|
return layoutModelData.id == parseInt(cubeInfo.referenceModelRight) && layoutModelData
|
|
|
.spaceId == cubeInfo.spaceId && layoutModelData.layoutId == cubeInfo.layoutId;
|
|
|
})
|
|
|
+ if(!referenceModel){
|
|
|
+ console.warn("***no-data***",cubeInfo.referenceModelRight,cubeInfo)
|
|
|
+ return false
|
|
|
+ }
|
|
|
positionX = referenceModel.position.x * 100 - (referenceModel.userData.modelWidth / 2 + cubeInfo
|
|
|
.modelWidth / 2);
|
|
|
positionX = positionX - parseFloat(cubeInfo.marginRight);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (cubeInfo.isFixedWidth == "false" || cubeInfo.isFixedHeight == "false") {
|
|
|
|
|
|
if (cubeInfo.isStepAsideTop == 'true' && cubeInfo.isStepAsideBottom == 'true') {
|
|
|
|
|
|
-
|
|
|
+
|
|
|
positionY = centerY;
|
|
|
-
|
|
|
+
|
|
|
if (curSpace.spaceWallInfo.wallN && curSpace.spaceWallInfo.wallS) {
|
|
|
spaceHeight -= 20 + parseFloat(cubeInfo.marginTop) + parseFloat(cubeInfo.marginBottom);
|
|
|
} else if (curSpace.spaceWallInfo.wallN) {
|
|
@@ -435,20 +490,20 @@ export default {
|
|
|
positionY += parseFloat(cubeInfo.marginTop) / 2 ;
|
|
|
positionY -= parseFloat(cubeInfo.marginBottom) / 2;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if (parseFloat(cubeInfo.rotation) == 90 || parseFloat(cubeInfo.rotation) == -90) {
|
|
|
scaleY = spaceHeight / modelHeight;
|
|
|
} else {
|
|
|
scaleX = spaceHeight / modelHeight;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (cubeInfo.isStepAsideLeft == 'true' && cubeInfo.isStepAsideRight == 'true') {
|
|
|
|
|
|
positionX = centerX;
|
|
|
-
|
|
|
+
|
|
|
if (curSpace.spaceWallInfo.wallW && curSpace.spaceWallInfo.wallE) {
|
|
|
spaceWidth -= 20 + parseFloat(cubeInfo.marginLeft) + parseFloat(cubeInfo.marginRight);;
|
|
|
} else if (curSpace.spaceWallInfo.wallW) {
|
|
@@ -471,9 +526,9 @@ export default {
|
|
|
} else {
|
|
|
scaleY = spaceWidth / modelWidth;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if (cubeInfo.isStepAsideTop == 'true' && parseInt(cubeInfo.referenceModelBottom) > 0) {
|
|
|
const referenceModel = this.gltfLayouts.find(item => {
|
|
@@ -485,7 +540,7 @@ export default {
|
|
|
.modelHeight / 2 - parseFloat(cubeInfo.marginBottom);
|
|
|
const wallPositionY = centerY - spaceHeight / 2 + (curSpace.spaceWallInfo.wallN ? 10 : 0) +
|
|
|
parseFloat(cubeInfo.marginTop);
|
|
|
-
|
|
|
+
|
|
|
const newModelHeight = Math.abs(referenceModelPositionY - wallPositionY);
|
|
|
|
|
|
if (Math.abs(parseFloat(cubeInfo.rotation)) == 90) {
|
|
@@ -495,9 +550,9 @@ export default {
|
|
|
}
|
|
|
positionY = wallPositionY + newModelHeight / 2;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (cubeInfo.isStepAsideBottom == 'true' && parseInt(cubeInfo.referenceModelTop) > 0) {
|
|
|
-
|
|
|
+
|
|
|
const referenceModel = this.gltfLayouts.find(item => {
|
|
|
const layoutModelData = item.userData;
|
|
|
return layoutModelData.id == parseInt(cubeInfo.referenceModelTop) && layoutModelData
|
|
@@ -505,10 +560,10 @@ export default {
|
|
|
})
|
|
|
const referenceModelPositionY = referenceModel.position.z * 100 + referenceModel.userData
|
|
|
.modelHeight / 2 + parseFloat(cubeInfo.marginTop) + (curSpace.spaceWallInfo.wallN ? 10 : 0);
|
|
|
-
|
|
|
+
|
|
|
const wallPositionY = centerY + spaceHeight / 2 - (curSpace.spaceWallInfo.wallS ? 10 : 0) -
|
|
|
parseFloat(cubeInfo.marginBottom);
|
|
|
-
|
|
|
+
|
|
|
const newModelHeight = Math.abs(referenceModelPositionY - wallPositionY);
|
|
|
if (Math.abs(parseFloat(cubeInfo.rotation)) == 90) {
|
|
|
scaleY = newModelHeight / modelHeight;
|
|
@@ -516,11 +571,11 @@ export default {
|
|
|
scaleX = newModelHeight / modelHeight;
|
|
|
}
|
|
|
positionY = wallPositionY - newModelHeight / 2;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if (cubeInfo.isStepAsideLeft == 'true' && parseInt(cubeInfo.referenceModelRight) > 0) {
|
|
|
|
|
|
-
|
|
|
+
|
|
|
const referenceModel = this.gltfLayouts.find(item => {
|
|
|
const layoutModelData = item.userData;
|
|
|
return layoutModelData.id == parseInt(cubeInfo.referenceModelRight) && layoutModelData
|
|
@@ -530,7 +585,7 @@ export default {
|
|
|
.modelWidth / 2 - parseFloat(cubeInfo.marginLeft);
|
|
|
const wallPositionX = centerX - spaceWidth / 2 + (curSpace.spaceWallInfo.wallE ? 10 : 0) +
|
|
|
parseFloat(cubeInfo.marginRight);
|
|
|
-
|
|
|
+
|
|
|
const newModelWidth = Math.abs(referenceModelPositionX - wallPositionX);
|
|
|
if (Math.abs(parseFloat(cubeInfo.rotation)) == 90) {
|
|
|
scaleX = newModelWidth / modelWidth;
|
|
@@ -538,11 +593,11 @@ export default {
|
|
|
scaleY = newModelWidth / modelWidth;
|
|
|
}
|
|
|
positionX = wallPositionX + newModelWidth / 2;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (cubeInfo.isStepAsideRight == 'true' && parseInt(cubeInfo.referenceModelLeft) > 0) {
|
|
|
-
|
|
|
+
|
|
|
const referenceModel = this.gltfLayouts.find(item => {
|
|
|
const layoutModelData = item.userData;
|
|
|
return layoutModelData.id == parseInt(cubeInfo.referenceModelLeft) && layoutModelData
|
|
@@ -552,63 +607,106 @@ export default {
|
|
|
.modelWidth / 2 + parseFloat(cubeInfo.marginLeft);
|
|
|
const wallPositionX = centerX + spaceWidth / 2 - (curSpace.spaceWallInfo.wallE ? 10 : 0) -
|
|
|
parseFloat(cubeInfo.marginRight);
|
|
|
-
|
|
|
+
|
|
|
const newModelWidth = Math.abs(referenceModelPositionX - wallPositionX);
|
|
|
if (Math.abs(parseFloat(cubeInfo.rotation)) == 90) {
|
|
|
scaleX = newModelWidth / modelWidth;
|
|
|
} else {
|
|
|
scaleY = newModelWidth / modelWidth;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
positionX = wallPositionX - newModelWidth / 2;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ console.log("模型计算位置", cubeInfo, centerX, centerY, spaceWidth, spaceHeight, modelWidth, modelHeight, spaceId, scaleX, scaleY, positionX, positionY)
|
|
|
let oldPosition = new THREE.Vector3();
|
|
|
oldPosition.copy(cube.position);
|
|
|
cube.position.x = positionX / 100;
|
|
|
cube.position.z = positionY / 100;
|
|
|
-
|
|
|
- cube.scale.x = scaleX ;
|
|
|
+ cube.rotation.y = rotationY;
|
|
|
+ cube.scale.x = scaleX;
|
|
|
cube.scale.z = scaleY;
|
|
|
+ cube.scale.y = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- this.updateInfo(cube,oldPosition,scaleX,scaleY);
|
|
|
+ if(this.type==2){
|
|
|
+ let name = cubeInfo.modelName.substring(0, cubeInfo.modelName.length - 2);
|
|
|
+ if(globlShowModel.includes(name)){
|
|
|
+ if(cubeInfo.modelName=='BP_XSPACE_deng_01_C'){
|
|
|
+ this.lightHandle(cube)
|
|
|
+ }else{
|
|
|
+ this.updateInfo(cube,oldPosition,scaleX,scaleY);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(cubeInfo.modelName=='BP_XSPACE_deng_01_C'){
|
|
|
+ this.lightHandle(cube)
|
|
|
+ }else{
|
|
|
+ this.updateInfo(cube,oldPosition,scaleX,scaleY);
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
updateInfo(cube,oldPosition,scaleX,scaleY){
|
|
|
let lay = this.gltfLayouts.find(it=>it.uniId==cube.uniId);
|
|
|
- cube.instancedMeshIndexList.forEach(item=>{
|
|
|
- let index = item.instancedMeshIndex;
|
|
|
- let instancedMesh = this.instancedFurList[index];
|
|
|
- let curMeshIndex = item.instancedAtIndex;
|
|
|
- let stratMatrix = new THREE.Matrix4();
|
|
|
- instancedMesh.getMatrixAt(curMeshIndex,stratMatrix);
|
|
|
- let scaleMatrix = new THREE.Matrix4();
|
|
|
- let panMatrix = new THREE.Matrix4();
|
|
|
- if (!lay.loaded) {
|
|
|
- scaleMatrix.makeScale(scaleX,1,scaleY);
|
|
|
- panMatrix.makeTranslation(cube.position.x,0,cube.position.z);
|
|
|
- stratMatrix.multiply(scaleMatrix).premultiply(panMatrix);
|
|
|
- instancedMesh.instanceMatrix.needsUpdate = true;
|
|
|
- instancedMesh.setMatrixAt(curMeshIndex,stratMatrix);
|
|
|
- this.scene.add(instancedMesh);
|
|
|
- }else{
|
|
|
- panMatrix.makeTranslation(cube.position.x - oldPosition.x,0,cube.position.z - oldPosition.z);
|
|
|
- stratMatrix.premultiply(panMatrix);
|
|
|
- instancedMesh.instanceMatrix.needsUpdate = true;
|
|
|
- instancedMesh.setMatrixAt(curMeshIndex,stratMatrix);
|
|
|
- }
|
|
|
- })
|
|
|
- lay.loaded = true;
|
|
|
+ if(cube.instancedMeshIndexList && cube.instancedMeshIndexList.length>0){
|
|
|
+ cube.instancedMeshIndexList.forEach(item=>{
|
|
|
+ let index = item.instancedMeshIndex;
|
|
|
+ let instancedMesh = this.instancedFurList[index];
|
|
|
+ let curMeshIndex = item.instancedAtIndex;
|
|
|
+ let stratMatrix = new THREE.Matrix4();
|
|
|
+ instancedMesh.getMatrixAt(curMeshIndex,stratMatrix);
|
|
|
+ let scaleMatrix = new THREE.Matrix4();
|
|
|
+ let panMatrix = new THREE.Matrix4();
|
|
|
+ if (!lay.loaded) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+ panMatrix.makeTranslation(cube.position.x - oldPosition.x,0,cube.position.z - oldPosition.z);
|
|
|
+ stratMatrix.premultiply(panMatrix);
|
|
|
+ instancedMesh.instanceMatrix.needsUpdate = true;
|
|
|
+ instancedMesh.setMatrixAt(curMeshIndex,stratMatrix);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ lay.loaded = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ lightHandle(cube){
|
|
|
+ let light = this.gltfLayouts.find(it=>it.uniId==cube.uniId);
|
|
|
+ if(!light.loaded){
|
|
|
+
|
|
|
+ let pointLight = new THREE.PointLight(0xffd7b3, 1.5, 5, 1);
|
|
|
+ pointLight.position.set(cube.position.x, 1.5, cube.position.z);
|
|
|
+ this.scene.add(pointLight);
|
|
|
+ let sphereSize = 0.1;
|
|
|
+ let pointLightHelper = new THREE.PointLightHelper( pointLight, sphereSize );
|
|
|
+ this.scene.add( pointLightHelper);
|
|
|
+
|
|
|
+ pointLight.castShadow = true;
|
|
|
+
|
|
|
+ pointLight.shadow.camera.left = -200;
|
|
|
+ pointLight.shadow.camera.right = 200;
|
|
|
+ pointLight.shadow.camera.top = 200;
|
|
|
+ pointLight.shadow.camera.bottom = -200;
|
|
|
+ this.scene.add(pointLight);
|
|
|
+
|
|
|
+ light.loaded = true;
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
resetModelParameters(curSpace, cubeInfo) {
|
|
@@ -635,25 +733,25 @@ export default {
|
|
|
}
|
|
|
for (let index = 0; index < count; index++) {
|
|
|
let oldCubeInfo = JSON.parse(JSON.stringify(cubeInfo))
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
oldCubeInfo.isStepAsideLeft = "false"
|
|
|
oldCubeInfo.isStepAsideTop = "false"
|
|
|
oldCubeInfo.isStepAsideRight = "false"
|
|
|
oldCubeInfo.isStepAsideBottom = "false"
|
|
|
-
|
|
|
+
|
|
|
oldCubeInfo.referenceModelLeft = "0"
|
|
|
oldCubeInfo.referenceModelTop = "0"
|
|
|
oldCubeInfo.referenceModelRight = "0"
|
|
|
oldCubeInfo.referenceModelBottom = "0"
|
|
|
-
|
|
|
+
|
|
|
oldCubeInfo.rotation = "0"
|
|
|
-
|
|
|
+
|
|
|
oldCubeInfo.marginLeft = "0";
|
|
|
oldCubeInfo.marginTop = "0";
|
|
|
oldCubeInfo.marginRight = "0";
|
|
|
oldCubeInfo.marginBottom = "0";
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if (cubeInfo.isStepAsideLeft == 'true') {
|
|
|
oldCubeInfo.isStepAsideTop = 'true'
|
|
@@ -680,7 +778,7 @@ export default {
|
|
|
if (parseInt(cubeInfo.referenceModelBottom) > 0) {
|
|
|
oldCubeInfo.referenceModelLeft = cubeInfo.referenceModelBottom;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
oldCubeInfo.marginLeft = cubeInfo.marginTop;
|
|
|
oldCubeInfo.marginTop = cubeInfo.marginRight;
|
|
@@ -688,7 +786,7 @@ export default {
|
|
|
oldCubeInfo.marginBottom = cubeInfo.marginLeft;
|
|
|
oldCubeInfo.modelWidth = cubeInfo.modelHeight;
|
|
|
oldCubeInfo.modelHeight = cubeInfo.modelWidth;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
if (parseInt(cubeInfo.rotation) == 0 || parseInt(cubeInfo.rotation) == 90) {
|
|
|
oldCubeInfo.rotation = parseInt(cubeInfo.rotation) + 90;
|
|
@@ -699,14 +797,14 @@ export default {
|
|
|
if (parseInt(cubeInfo.rotation) == -90) {
|
|
|
oldCubeInfo.rotation = "0";
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
+
|
|
|
cubeInfo = oldCubeInfo;
|
|
|
-
|
|
|
+
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return cubeInfo;
|
|
|
},
|
|
|
}
|