Browse Source

fix: 增加根据导航路线动态显示效果

ShangHai_LongXiang
高志龙 2 years ago
parent
commit
234b97f5c0
  1. 72
      public/static/qm/MainMap_QM_go.js

72
public/static/qm/MainMap_QM_go.js

@ -158,8 +158,8 @@ var QMUtil = function () {
otherPath: [], //人为干预的路线 [{f:"0_5_10",s:"1_5_47",d:500},{f:"1_5_47",s:"0_5_10",d:500}]; otherPath: [], //人为干预的路线 [{f:"0_5_10",s:"1_5_47",d:500},{f:"1_5_47",s:"0_5_10",d:500}];
bSpace: 5000, bSpace: 5000,
fSpace: 500, //双叠层状态下楼层的间距 fSpace: 500, //双叠层状态下楼层的间距
maxDis: 1000,
minDis: 60,
maxDis: 700,
minDis: 100,
shadow: true, //是否显示阴影 shadow: true, //是否显示阴影
navColor: 0xee6a50, //途径店铺颜色 navColor: 0xee6a50, //途径店铺颜色
aRadius: 2, //圆角半径 大于2 则店铺box显示圆角 aRadius: 2, //圆角半径 大于2 则店铺box显示圆角
@ -3215,18 +3215,25 @@ MainMap_QM.prototype = {
* Map_QM.setCameraDist(150); * Map_QM.setCameraDist(150);
* *
*/ */
setCameraDist: function (cDist) {
if (Map_QM.util.options.minDis < parseInt(cDist) && parseInt(cDist) < Map_QM.util.options.maxDis) {
setCameraDist: function (cDist, updateFun, callBack) {
cDist = Map_QM.util.options.minDis > parseInt(cDist) ? Map_QM.util.options.minDis : parseInt(cDist);
cDist = parseInt(cDist) > Map_QM.util.options.maxDis ? Map_QM.util.options.minDis : parseInt(cDist);
let oldObj = { dis: Map_QM.controls.getDistance() }; let oldObj = { dis: Map_QM.controls.getDistance() };
TweenMax.killAll(true); TweenMax.killAll(true);
TweenMax.to(oldObj, 0.5, { TweenMax.to(oldObj, 0.5, {
dis: cDist, dis: cDist,
onUpdate: function () { onUpdate: function () {
updateFun && updateFun(); //实时更新地图位置
Map_QM.controls.setDistance(oldObj.dis); Map_QM.controls.setDistance(oldObj.dis);
Map_QM.controlsChock(); Map_QM.controlsChock();
}, },
});
onComplete:function(){
updateFun && updateFun();
callBack && callBack();
Map_QM.collLabel();
} }
});
}, },
/** /**
* @api {方法} startRender() 启动地图渲染 * @api {方法} startRender() 启动地图渲染
@ -3872,6 +3879,17 @@ MainMap_QM.prototype = {
}, 300); }, 300);
} }
}, },
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);
}
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);
return {x:screenX, y:screenY};
},
runTaskQueue: function (){ runTaskQueue: function (){
if (Map_QM.mapArr[Map_QM.util.selectBuild] && Map_QM.buildObj.visible && Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor]) { if (Map_QM.mapArr[Map_QM.util.selectBuild] && Map_QM.buildObj.visible && Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor]) {
if (Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].allObj.visible && (!Map_QM.buildObj.userData.hasOwnProperty("visible") || Map_QM.buildObj.userData.visible)) { if (Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].allObj.visible && (!Map_QM.buildObj.userData.hasOwnProperty("visible") || Map_QM.buildObj.userData.visible)) {
@ -5501,6 +5519,7 @@ 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));
@ -5509,6 +5528,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)+30, Map_QM.moveMapPosition, Map_QM.drawPathStart);
}else{ //按宽度计算
Map_QM.setCameraDist((disc*vw/Map_QM.w)+30, Map_QM.moveMapPosition, Map_QM.drawPathStart);
}
}
},
drawPathStart:function(){
console.log("**********");
document.addEventListener("pathOver", Map_QM.onFindPathFloor, true); document.addEventListener("pathOver", Map_QM.onFindPathFloor, true);
if (Map_QM.util.isMorePath) { if (Map_QM.util.isMorePath) {
Map_QM.mapArr[Map_QM.forShopArr[Map_QM.util._indexPathFloor].build][Map_QM.forShopArr[Map_QM.util._indexPathFloor].floor].findPath.onFindPathAnimation(pathNodes[Map_QM.util._indexPathFloor].pathNode, Map_QM.util.isMorePath,pathNodes[Map_QM.util._indexPathFloor].floor); //传入数组 Map_QM.mapArr[Map_QM.forShopArr[Map_QM.util._indexPathFloor].build][Map_QM.forShopArr[Map_QM.util._indexPathFloor].floor].findPath.onFindPathAnimation(pathNodes[Map_QM.util._indexPathFloor].pathNode, Map_QM.util.isMorePath,pathNodes[Map_QM.util._indexPathFloor].floor); //传入数组
@ -5518,7 +5559,26 @@ MainMap_QM.prototype = {
} }
Map_QM.mapArr[Map_QM.forShopArr[Map_QM.util._indexPathFloor].build][Map_QM.forShopArr[Map_QM.util._indexPathFloor].floor].findPath.guidePathPlay(Map_QM.forShopArr[Map_QM.util._indexPathFloor]); Map_QM.mapArr[Map_QM.forShopArr[Map_QM.util._indexPathFloor].build][Map_QM.forShopArr[Map_QM.util._indexPathFloor].floor].findPath.guidePathPlay(Map_QM.forShopArr[Map_QM.util._indexPathFloor]);
Map_QM.controlsChock(); Map_QM.controlsChock();
}
},
//根据屏幕坐标平移地图
moveMapPosition:function(){
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 panStart = new THREE.Vector2((leftX+rightX)/2, (bottomY+topY)/2); //映射的屏幕中心点
let panEnd = new THREE.Vector2(Map_QM.w/2, Map_QM.h/2);
let panDelta = new THREE.Vector2();
panDelta.subVectors(panEnd, panStart).multiplyScalar(1);
Map_QM.controls.pan(panDelta.x, panDelta.y);
Map_QM.controls.update();
}, },
/** /**

Loading…
Cancel
Save