|
@@ -180,6 +180,7 @@
|
|
this.moveMeshCenterHandle = moveMeshCenterHandle;
|
|
this.moveMeshCenterHandle = moveMeshCenterHandle;
|
|
this.cameraInit = cameraInit;
|
|
this.cameraInit = cameraInit;
|
|
this.resetControl = resetControl;
|
|
this.resetControl = resetControl;
|
|
|
|
+ this.movePositionHandle = movePositionHandle;
|
|
function init() {
|
|
function init() {
|
|
|
|
|
|
scene.background = new THREE.Color("#FFFFFF");
|
|
scene.background = new THREE.Color("#FFFFFF");
|
|
@@ -301,6 +302,38 @@
|
|
updateLables();
|
|
updateLables();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //把摄像机移动到目标点位
|
|
|
|
+ function movePositionHandle(position = null, height=null){
|
|
|
|
+ that.showLables = false;//隐藏
|
|
|
|
+ controls.enable = false;//控制器不响应用户的操作
|
|
|
|
+ let cameraNewPosition ={};
|
|
|
|
+ let targetNewPosition ={};
|
|
|
|
+ let oldUp = {};
|
|
|
|
+ let newUp = {};
|
|
|
|
+ let cy = height ? height : camera.position.y;
|
|
|
|
+ let _juli = cy * Math.tan(Math.PI / 8);
|
|
|
|
+ cameraNewPosition = {
|
|
|
|
+ x:position.x,
|
|
|
|
+ y:cy,
|
|
|
|
+ z:position.z + _juli,//增加偏差,防止极点翻转问题?不知道为啥会有用
|
|
|
|
+ }
|
|
|
|
+ //新的观察点的位置-取模型的中心点坐标,加上高度,由于模型都是贴地的,所以高度设置为0
|
|
|
|
+ targetNewPosition = {
|
|
|
|
+ x:position.x,
|
|
|
|
+ y:position.y,
|
|
|
|
+ z:position.z
|
|
|
|
+ }
|
|
|
|
+ oldUp = camera.up;//俯视状态
|
|
|
|
+ newUp = camera.up;
|
|
|
|
+ // console.warn("**movePositionHandle***",position,JSON.stringify(camera.position),JSON.stringify(controls.target)
|
|
|
|
+ // ,cameraNewPosition,targetNewPosition,JSON.stringify(camera.up))
|
|
|
|
+ tweenCamera(camera.position,controls.target,cameraNewPosition,targetNewPosition,oldUp,newUp,500);
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
+ that.showLables = true;
|
|
|
|
+ updateLables();
|
|
|
|
+ controls.enable = true;//控制器响应用户的操作
|
|
|
|
+ },511);//动画结束后回复原始状态
|
|
|
|
+ }
|
|
//把摄像机移动的选中模型的正上方,观察点也变更为模型中心点,同时选中模型
|
|
//把摄像机移动的选中模型的正上方,观察点也变更为模型中心点,同时选中模型
|
|
function moveMeshCenterHandle(mesh = null,noChangeColor = true){
|
|
function moveMeshCenterHandle(mesh = null,noChangeColor = true){
|
|
if(mesh){//如果传入了模型,则取模型
|
|
if(mesh){//如果传入了模型,则取模型
|
|
@@ -602,12 +635,15 @@
|
|
if(element.wallList){
|
|
if(element.wallList){
|
|
this.wallList.push(JSON.parse(element.wallList));
|
|
this.wallList.push(JSON.parse(element.wallList));
|
|
}
|
|
}
|
|
- if(element.isSelected){ // 默认选中空间
|
|
|
|
- this.curSpaceObj = element;
|
|
|
|
- }
|
|
|
|
|
|
+ // if(element.isSelected){ // 默认选中空间
|
|
|
|
+ // this.curSpaceObj = element;
|
|
|
|
+ // }
|
|
|
|
+ if(element.isSelected && element.spaceName && !element.isSizeLock && !this.curSpaceObj){ // 默认选中空间
|
|
|
|
+ this.curSpaceObj = element;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
if(!this.curSpaceObj && this.spaceList.length > 0){
|
|
if(!this.curSpaceObj && this.spaceList.length > 0){
|
|
- this.curSpaceObj = this.spaceList[0];
|
|
|
|
|
|
+ this.curSpaceObj = this.spaceList.find(it=>it.spaceName && !it.isSizeLock && (it.spaceHeightMax!=0 && it.spaceWidthMax!=0))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(this.curHouseObj.layoutArea<=100){//面积小于100平米,则摄像头靠近一点
|
|
if(this.curHouseObj.layoutArea<=100){//面积小于100平米,则摄像头靠近一点
|
|
@@ -615,6 +651,7 @@
|
|
}else if(this.curHouseObj.layoutArea>100){
|
|
}else if(this.curHouseObj.layoutArea>100){
|
|
this.cameraStarPosition.y = 35;
|
|
this.cameraStarPosition.y = 35;
|
|
}
|
|
}
|
|
|
|
+ this.allSpaceCenter = this.getAllSpaceCenter(this.spaceList);//获取所有空间的中心点
|
|
console.log("该户型空间数据:", this.spaceList);
|
|
console.log("该户型空间数据:", this.spaceList);
|
|
console.log("当前选中的空间:", this.curSpaceObj);
|
|
console.log("当前选中的空间:", this.curSpaceObj);
|
|
this.cameraInit();
|
|
this.cameraInit();
|
|
@@ -622,6 +659,9 @@
|
|
// 获取墙体数据并且绘制墙体
|
|
// 获取墙体数据并且绘制墙体
|
|
this.getHouseTypeSpaceWalls();
|
|
this.getHouseTypeSpaceWalls();
|
|
},
|
|
},
|
|
|
|
+ locationHandle(){
|
|
|
|
+ this.movePositionHandle(this.allSpaceCenter,this.cameraStarPosition.y);//把摄像机移动到所有模型的中心点(水平面中心)
|
|
|
|
+ },
|
|
// 获取墙体数据
|
|
// 获取墙体数据
|
|
async getHouseTypeSpaceWalls(){
|
|
async getHouseTypeSpaceWalls(){
|
|
// let data = {id:this.wallIds}
|
|
// let data = {id:this.wallIds}
|
|
@@ -685,7 +725,8 @@
|
|
this.myLoadingStatus = false;
|
|
this.myLoadingStatus = false;
|
|
// this.$refs.myLoading.hideLoading();
|
|
// this.$refs.myLoading.hideLoading();
|
|
setTimeout(()=>{
|
|
setTimeout(()=>{
|
|
- this.moveMeshCenter(this.curSpaceObj);
|
|
|
|
|
|
+ // this.moveMeshCenter(this.curSpaceObj);
|
|
|
|
+ this.movePositionHandle(this.allSpaceCenter);//把摄像机移动到所有模型的中心点(水平面中心)
|
|
this.addWordLabel(); // 添加文字标签
|
|
this.addWordLabel(); // 添加文字标签
|
|
}, 610);
|
|
}, 610);
|
|
})
|
|
})
|