Browse Source

fix: 导航bug

ShangHai_LongXiang
高志龙 2 years ago
parent
commit
7b6259ad05
  1. 47
      public/static/qm/MainMap_QM_go.js

47
public/static/qm/MainMap_QM_go.js

@ -3880,12 +3880,7 @@ MainMap_QM.prototype = {
} }
}, },
getlocaleToScreen:function(object,vect){ getlocaleToScreen:function(object,vect){
let standardVec;
if(vect){
standardVec = object.localToWorld(vect).project(Map_QM.camera);
}else{
standardVec = object.localToWorld(new THREE.Vector3()).project(Map_QM.camera);
}
let standardVec = object.localToWorld(vect).project(Map_QM.camera);
const screenX = Math.round(Map_QM.w/2 * standardVec.x + Map_QM.w/2); const screenX = Math.round(Map_QM.w/2 * standardVec.x + Map_QM.w/2);
const screenY = Math.round(Map_QM.h/-2 * standardVec.y + Map_QM.h/2); const screenY = Math.round(Map_QM.h/-2 * standardVec.y + Map_QM.h/2);
return {x:screenX, y:screenY}; return {x:screenX, y:screenY};
@ -5519,7 +5514,6 @@ MainMap_QM.prototype = {
* @param {Object} endN * @param {Object} endN
*/ */
onFindPath: function () { onFindPath: function () {
console.log(Map_QM.forShopArr);
TweenMax.killAll(true); TweenMax.killAll(true);
if (Map_QM.util.overObj.floor == Map_QM.util.selectFloor && Map_QM.util.overObj.xaxis) { if (Map_QM.util.overObj.floor == Map_QM.util.selectFloor && Map_QM.util.overObj.xaxis) {
Map_QM.mapArr[Map_QM.util.overObj.build][Map_QM.util.overObj.floor].setOverSite(Map_QM.util.overObj.xaxis, Map_QM.util.overObj.yaxis,parseInt(Map_QM.util.shopHeight)); Map_QM.mapArr[Map_QM.util.overObj.build][Map_QM.util.overObj.floor].setOverSite(Map_QM.util.overObj.xaxis, Map_QM.util.overObj.yaxis,parseInt(Map_QM.util.shopHeight));
@ -5528,23 +5522,28 @@ MainMap_QM.prototype = {
Map_QM.endIcon && (Map_QM.endIcon.visible = false); Map_QM.endIcon && (Map_QM.endIcon.visible = false);
} }
if (Map_QM.forShopArr.length > 0) { if (Map_QM.forShopArr.length > 0) {
const postArr = Map_QM.forShopArr[Map_QM.util._indexPathFloor].PathPoint;
const len = postArr.length;
let leftX = 50000, rightX=-50000, topY=50000, bottomY = -50000;
for(let i=0; i<len; i++){
let screen = Map_QM.getlocaleToScreen(Map_QM.sceneGap, new THREE.Vector3(postArr[i].x, 2, postArr[i].y));
leftX = Math.min(screen.x,leftX);
rightX = Math.max(screen.x,rightX);
topY = Math.min(screen.y,topY);
bottomY = Math.max(screen.y,bottomY);
}
let vw = rightX-leftX;
let vh = bottomY-topY;
let disc = Map_QM.controls.getDistance();
if(vh==0 || vw/vh < Map_QM.w/Map_QM.h){ //按高度计算
Map_QM.setCameraDist((disc*vh/Map_QM.h)+20, Map_QM.moveMapPosition, Map_QM.drawPathStart);
}else{ //按宽度计算
Map_QM.setCameraDist((disc*vw/Map_QM.w)+20, Map_QM.moveMapPosition, Map_QM.drawPathStart);
if(pathCameraState == "3D"){
Map_QM.controls.reset();
const postArr = Map_QM.forShopArr[Map_QM.util._indexPathFloor].PathPoint;
const len = postArr.length;
let leftX = 50000, rightX=-50000, topY=50000, bottomY = -50000;
for(let i=0; i<len; i++){
let screen = Map_QM.getlocaleToScreen(Map_QM.sceneGap, new THREE.Vector3(postArr[i].x, 2, postArr[i].y));
leftX = Math.min(screen.x,leftX);
rightX = Math.max(screen.x,rightX);
topY = Math.min(screen.y,topY);
bottomY = Math.max(screen.y,bottomY);
}
let vw = rightX-leftX;
let vh = bottomY-topY;
let disc = Map_QM.controls.getDistance();
if(vh==0 || vw/vh < Map_QM.w/Map_QM.h){ //按高度计算
Map_QM.setCameraDist((disc*vh/Map_QM.h)+20, Map_QM.moveMapPosition, Map_QM.drawPathStart);
}else{ //按宽度计算
Map_QM.setCameraDist((disc*vw/Map_QM.w)+20, Map_QM.moveMapPosition, Map_QM.drawPathStart);
}
}else{
Map_QM.drawPathStart();
} }
} }
}, },

Loading…
Cancel
Save