|
|
|
@ -33,7 +33,7 @@ QMUtil = function () { |
|
|
|
this.beforPath = "./"; |
|
|
|
this.options = { |
|
|
|
playSpeed: 6, //动画播放速度
|
|
|
|
collision: false, //是否支持名称的碰撞检测
|
|
|
|
collision: true, //是否支持名称的碰撞检测
|
|
|
|
showStyle: false, //是否4K
|
|
|
|
modelIcon: true, //是否使用模型 true 模型 false 图标
|
|
|
|
otherPath: [], //人为干预的路线 [{f:"0_5_10",s:"1_5_47",d:500},{f:"1_5_47",s:"0_5_10",d:500}];
|
|
|
|
@ -77,7 +77,7 @@ QMUtil = function () { |
|
|
|
//debug 参数 相机坐标/ 镜头方向
|
|
|
|
this.guiOptions = { cameraX: 0, cameraY: 220, cameraZ: 220, targatX: 0, targatY: 0, targatZ: 0 }; //this.button = function() {};
|
|
|
|
|
|
|
|
this.sceneGap = { x: 0, y: 0, z: 0, scale: dir ? 0.15 : 0.08 }; //改变地图位置,大小
|
|
|
|
this.sceneGap = { x: 0, y: 0, z: 0, scale: dir ? 0.15 : 0.09 }; //改变地图位置,大小
|
|
|
|
|
|
|
|
this.selectBuild = 0; |
|
|
|
this.selectFloor = 0; |
|
|
|
@ -1440,7 +1440,6 @@ MainMap_QM.prototype = { |
|
|
|
this.util.options.pathColor = pathColor != 0xb47834 ? pathColor : this.util.options.pathColor; |
|
|
|
this.util.options.pathStyle = pathStyle != "3D" ? pathStyle : this.util.options.pathStyle; |
|
|
|
this.util.iconUrl = iconUrl; |
|
|
|
|
|
|
|
if (!isNaN(Number(options.floor))) { |
|
|
|
this.util.startObj.floor = this.util.deviceObj.floor = parseInt(options.floor) || 0; |
|
|
|
} else { |
|
|
|
@ -1457,11 +1456,13 @@ MainMap_QM.prototype = { |
|
|
|
for(let k=0; k<this.util.allMap.length; k++){ |
|
|
|
for (let kk = 0; kk < this.util.allMap[k].buildArr.length; kk++) { |
|
|
|
let floor = this.util.allMap[k].buildArr[kk].mapData; |
|
|
|
for (let t = 0; t < floor.models.length; t++) { |
|
|
|
for (let i = 0; i < this.util.modelStr.length; i++) { |
|
|
|
if (floor.models[t].type == this.util.modelStr[i].key) { |
|
|
|
this.util.modelStr[i].load = true; |
|
|
|
break; |
|
|
|
if(floor.models){ |
|
|
|
for (let t = 0; t < floor.models.length; t++) { |
|
|
|
for (let i = 0; i < this.util.modelStr.length; i++) { |
|
|
|
if (floor.models[t].type == this.util.modelStr[i].key) { |
|
|
|
this.util.modelStr[i].load = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1649,11 +1650,7 @@ MainMap_QM.prototype = { |
|
|
|
} |
|
|
|
}, |
|
|
|
loaderOver: function (e) { |
|
|
|
this.cancelRender(); |
|
|
|
this.util.pathStateObj.basePath = null; |
|
|
|
this.renderer.dispose(); |
|
|
|
this.remove_child(this.sceneGap); |
|
|
|
this.scene.remove(this.sceneGap); |
|
|
|
|
|
|
|
this.sceneGap = new THREE.Group(); |
|
|
|
this.sceneGap.position.set(this.util.sceneGap.x, this.util.sceneGap.y, this.util.sceneGap.z); |
|
|
|
this.sceneGap.scale.set(this.util.sceneGap.scale, this.util.sceneGap.scale, this.util.sceneGap.scale); |
|
|
|
@ -1785,7 +1782,26 @@ MainMap_QM.prototype = { |
|
|
|
} |
|
|
|
}, 50); |
|
|
|
}, |
|
|
|
beforeDestroy:function(options) { |
|
|
|
if (this.scene) { |
|
|
|
this.renderer.dispose() |
|
|
|
this.util.pathStateObj.basePath = null; |
|
|
|
this.remove_child(this.sceneGap); |
|
|
|
this.scene.remove(this.sceneGap); |
|
|
|
let parent = document.getElementById(options.containerId || "mapContainer"); |
|
|
|
while ((elem = parent.firstChild)) { |
|
|
|
elem.remove(); |
|
|
|
} |
|
|
|
this.renderer.domElement = null |
|
|
|
this.renderer = null |
|
|
|
this.scene.clear() |
|
|
|
this.scene = null |
|
|
|
this.camera = null |
|
|
|
this.controls = null |
|
|
|
} |
|
|
|
}, |
|
|
|
initTreeModel: function () { |
|
|
|
|
|
|
|
if(this.index < this.util.modelStr.length - 1 ){ |
|
|
|
if(this.util.modelStr[this.index].load){ |
|
|
|
this.gltfLoad(this.util.beforPath + this.util.modelStr[this.index].url); |
|
|
|
@ -1867,15 +1883,15 @@ MainMap_QM.prototype = { |
|
|
|
//初始化方向为第一人称方向
|
|
|
|
let angle = this.util.options.deviceAng ? this.util.deviceObj.angle : 0; |
|
|
|
this.rotationAngle(angle); |
|
|
|
if(this.util.guiOptions.cameraY == 220 && this.util.guiOptions.cameraZ == 220){ |
|
|
|
let boundBox = new THREE.Box3(); |
|
|
|
boundBox.setFromObject(this.sceneGap); |
|
|
|
let wd = Math.max(boundBox.max.x-boundBox.min.x, boundBox.max.y-boundBox.min.y); |
|
|
|
let cameraDis = Math.sqrt(this.util.guiOptions.cameraY*this.util.guiOptions.cameraY+this.util.guiOptions.cameraZ*this.util.guiOptions.cameraZ); |
|
|
|
this.camera.fov = this.calcFov(cameraDis, wd, this.w / this.h); |
|
|
|
this.camera.aspect = this.w / this.h; |
|
|
|
this.camera.updateProjectionMatrix(); |
|
|
|
} |
|
|
|
// if(this.util.guiOptions.cameraY == 220 && this.util.guiOptions.cameraZ == 220){
|
|
|
|
// let boundBox = new THREE.Box3();
|
|
|
|
// boundBox.setFromObject(this.sceneGap);
|
|
|
|
// let wd = Math.max(boundBox.max.x-boundBox.min.x, boundBox.max.y-boundBox.min.y);
|
|
|
|
// let cameraDis = Math.sqrt(this.util.guiOptions.cameraY*this.util.guiOptions.cameraY+this.util.guiOptions.cameraZ*this.util.guiOptions.cameraZ);
|
|
|
|
// this.camera.fov = this.calcFov(cameraDis, wd, this.w / this.h);
|
|
|
|
// this.camera.aspect = this.w / this.h;
|
|
|
|
// this.camera.updateProjectionMatrix();
|
|
|
|
// }
|
|
|
|
this.startRender(); |
|
|
|
setTimeout(() => { |
|
|
|
Map_QM.controls.saveState(); |
|
|
|
@ -2088,7 +2104,7 @@ MainMap_QM.prototype = { |
|
|
|
Map_QM.controls.enabled = true; |
|
|
|
Map_QM.controls.enableRotate = true; |
|
|
|
Map_QM.util.pathStateObj.forShopArr = { direction: "", wayList: [] }; |
|
|
|
Map_QM.resetMeDir(); |
|
|
|
this.controls.reset(); |
|
|
|
if (Map_QM.guide && Map_QM.guide.visible) { |
|
|
|
Map_QM.guide.visible = false |
|
|
|
} |
|
|
|
@ -2217,7 +2233,7 @@ MainMap_QM.prototype = { |
|
|
|
Map_QM.util.selectBuild = build; |
|
|
|
Map_QM.util.selectFloor = fIndex; |
|
|
|
if (Map_QM.util.options.shadow) { |
|
|
|
TweenMax.fromTo(Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].allObj.position, 0.3, { z: Map_QM.util.options.fSpace }, { |
|
|
|
TweenMax.fromTo(Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].allObj.position, 0.2, { z: Map_QM.util.options.fSpace }, { |
|
|
|
z: 0, ease: Cubic.easeIn, onComplete: function () { |
|
|
|
Map_QM.timeOutInit(); |
|
|
|
if (callBack) callBack(); |
|
|
|
@ -2839,8 +2855,10 @@ MainMap_QM.prototype = { |
|
|
|
Map_QM.controls.update(); |
|
|
|
Map_QM.renderer.render(Map_QM.scene, Map_QM.camera); |
|
|
|
Map_QM.labelRenderer.render(Map_QM.scene, Map_QM.camera); |
|
|
|
Map_QM.labelRenderer.renderObject( Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].labelObj, Map_QM.camera ); |
|
|
|
Map_QM.labelRenderer.renderObject( Map_QM.CSSObject, Map_QM.camera ); |
|
|
|
if(Map_QM.mapArr[Map_QM.util.selectBuild]){ |
|
|
|
Map_QM.labelRenderer.renderObject( Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].labelObj, Map_QM.camera ); |
|
|
|
Map_QM.labelRenderer.renderObject( Map_QM.CSSObject, Map_QM.camera ); |
|
|
|
} |
|
|
|
for (let item of Map_QM.mixers) { |
|
|
|
item.update(T); |
|
|
|
} |
|
|
|
@ -3066,7 +3084,7 @@ MainMap_QM.prototype = { |
|
|
|
} |
|
|
|
}, |
|
|
|
onCallTouchORMouse: function (mouse) { |
|
|
|
if (!Map_QM.mapArr[Map_QM.util.selectBuild] && !Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor] || Map_QM.util.pathStateObj.isPathState) { |
|
|
|
if (!Map_QM.mapArr[Map_QM.util.selectBuild] && !Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor] ) { |
|
|
|
return; |
|
|
|
} |
|
|
|
let raycaster = new THREE.Raycaster(); |
|
|
|
@ -3405,14 +3423,12 @@ MainMap_QM.prototype = { |
|
|
|
if (!Map_QM) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!Map_QM.util.options.collision) { |
|
|
|
return; |
|
|
|
} |
|
|
|
clearTimeout(Map_QM.util.timeObj.collTime); |
|
|
|
Map_QM.util.timeObj.collTime = setTimeout(() => { |
|
|
|
clearTimeout(Map_QM.util.timeObj.collTime); |
|
|
|
Map_QM.labelRenderer.zOrder( Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].labelObj ); |
|
|
|
if (!Map_QM.util.options.collision) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
let checkList = []; |
|
|
|
if (Map_QM.util.options.overlap) { |
|
|
|
for (let i = 0; i < Map_QM.mapArr[Map_QM.util.selectBuild].length; i++) { |
|
|
|
@ -3483,7 +3499,7 @@ MainMap_QM.prototype = { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, 500); |
|
|
|
}, 300); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -5091,6 +5107,10 @@ MainMap_QM.prototype = { |
|
|
|
* MainMap_QM.init(callBackLoadOver,{build : 0, floor : 3, navPoint : 7, angle : 0, perc_H : "-50%",containerId : "mapContainer"}); |
|
|
|
*/ |
|
|
|
MainMap_QM.init = function (callBack, options) { |
|
|
|
if(Map_QM){ |
|
|
|
Map_QM.cancelRender(); |
|
|
|
Map_QM.beforeDestroy(options); |
|
|
|
} |
|
|
|
Map_QM = new MainMap_QM(callBack, options); |
|
|
|
return Map_QM; |
|
|
|
} |
|
|
|
|