diff --git a/public/static/qm/MainMap_QM_go.js b/public/static/qm/MainMap_QM_go.js index 08a0b92..8dacb7a 100644 --- a/public/static/qm/MainMap_QM_go.js +++ b/public/static/qm/MainMap_QM_go.js @@ -157,7 +157,8 @@ QMUtil = function () { inArea: false, //点击后是否聚焦到店铺 camZoom: 3, //设置我的方向状态地图放大倍数 boxShop: [], //设置box上显示的文字(过滤指),可点击触发onlyShop - deviceAng: false //地图初始化方向是否使用设备角度 + deviceAng: false, //地图初始化方向是否使用设备角度 + facSize: 20 //设施大小 } this.lightOptions = { d_col: '#ffffff', @@ -1329,7 +1330,6 @@ MainMap_QM = function (callBack, options) { this.backObj = { code: 200, msg: '加载成功', data: [] } this.scene = new THREE.Scene() this.scene.name = 'scene' - this.scene.fog = new THREE.Fog(0xe5e5e5, this.util.options.maxDis, this.util.options.maxDis + 500) this.aspect = this.w / this.h this.cameraPerspective = new THREE.PerspectiveCamera(45, this.aspect, 10, 10000) this.cameraPerspective.position.set(this.util.guiOptions.cameraX, this.util.guiOptions.cameraY, this.util.guiOptions.cameraZ) //x 水平 y 垂直旋转 z 展示大小 @@ -1457,7 +1457,6 @@ MainMap_QM.prototype = { try { _space.util.allMap = JSON.parse(LZString.decompressFromBase64(res.data.mapData)) console.log('地图数据更新时间: ' + res.data.updateTime) - _space.initOptions(options) } catch (e) { _space.backObj.code = 404 _space.backObj.msg = '地图数据JSON格式错误' @@ -1487,19 +1486,10 @@ MainMap_QM.prototype = { _space.backObj.code = 500 _space.backObj.msg = '店铺数据解析失败' } - _space.initOutModel() + _space.initOptions(options); }, fail: () => { - try { - _space.initOutModel() - } catch (e) { - _space.backObj.code = 404 - _space.backObj.msg = '地图数据解析失败' - } - if (_space.backObj.code == 404) { - _space.callBackLoadOver(_space.backObj) - _space.callBackLoadOver = null - } + _space.initOptions(options); } }) } else { @@ -1526,13 +1516,13 @@ MainMap_QM.prototype = { _space.util.allMap = JSON.parse(LZString.decompressFromBase64(options.mapData.mapData)) } console.log('地图数据更新时间: ' + options.mapData.updateTime) - _space.initOptions(options) } catch (e) { console.log(e) backObj.code = 404 backObj.msg = '地图数据JSON格式错误' callBack(backObj) callBack = null + return; } _space.util.shopData = options.shopData let backObj = { code: 200, msg: '加载成功', data: [] } @@ -1542,13 +1532,7 @@ MainMap_QM.prototype = { backObj.code = 500 backObj.msg = '店铺数据错误' } - try { - _space.initOutModel() - } catch (e) { - console.log(e) - _space.callBackLoadOver({ code: 404, msg: '地图数据解析失败' }) - _space.callBackLoadOver = null - } + _space.initOptions(options) } else { _space.util.readTextFile(_space.util.beforPath + _space.util.mapServerInfo, function (res) { try { @@ -1558,13 +1542,13 @@ MainMap_QM.prototype = { _space.util.allMap = JSON.parse(LZString.decompressFromBase64(res.data.mapData)) } console.log('地图数据更新时间: ' + res.data.updateTime) - _space.initOptions(options) } catch (e) { console.log(e) _space.backObj.code = 404 _space.backObj.msg = '地图数据JSON格式错误' _space.callBackLoadOver(_space.backObj) _space.callBackLoadOver = null + return; } _space.util.readTextFile(_space.util.beforPath + _space.util.shopServerInfo, function (res) { @@ -1581,12 +1565,7 @@ MainMap_QM.prototype = { _space.callBackLoadOver(backObj) } }) - try { - _space.initOutModel() - } catch (e) { - _space.callBackLoadOver({ code: 404, msg: '地图数据解析失败' }) - _space.callBackLoadOver = null - } + _space.initOptions(options); }) } } @@ -1604,14 +1583,16 @@ MainMap_QM.prototype = { initOptions: function (options) { //初始化参数 if (this.util.allMap[this.util.selectBuild].playSpeed) { - this.util.options.mapScale = this.util.allMap[this.util.selectBuild].hasOwnProperty('scale') ? parseInt(this.util.allMap[this.util.selectBuild].scale) : 18 - this.util.options.playSpeed = this.util.allMap[this.util.selectBuild].hasOwnProperty('playSpeed') ? parseInt(this.util.allMap[this.util.selectBuild].playSpeed) : 6 - this.util.options.collision = this.util.allMap[this.util.selectBuild].hasOwnProperty('collision') ? this.util.allMap[this.util.selectBuild].collision : true - this.util.options.navColor = this.util.allMap[this.util.selectBuild].hasOwnProperty('navColor') ? this.util.allMap[this.util.selectBuild].navColor : 0xee6a50 - this.util.options.aRadius = this.util.allMap[this.util.selectBuild].hasOwnProperty('aRadius') ? parseInt(this.util.allMap[this.util.selectBuild].aRadius) : 2 - this.util.options.boxShop = this.util.allMap[this.util.selectBuild].hasOwnProperty('boxShop') ? this.util.allMap[this.util.selectBuild].boxShop.split(',') : [] - this.util.options.shopStyle = this.util.allMap[this.util.selectBuild].hasOwnProperty('shopStyle') ? this.util.allMap[this.util.selectBuild].shopStyle : 'shopName' - this.util.options.modelIcon = this.util.allMap[this.util.selectBuild].hasOwnProperty('modelIcon') ? this.util.allMap[this.util.selectBuild].modelIcon : true + this.util.allMap[this.util.selectBuild].hasOwnProperty("scale") && (this.util.options.mapScale = parseInt(this.util.allMap[this.util.selectBuild].scale)); + this.util.allMap[this.util.selectBuild].hasOwnProperty("playSpeed") && (this.util.options.playSpeed = parseInt(this.util.allMap[this.util.selectBuild].playSpeed)); + this.util.allMap[this.util.selectBuild].hasOwnProperty("collision") && (this.util.options.collision = this.util.allMap[this.util.selectBuild].collision); + this.util.allMap[this.util.selectBuild].hasOwnProperty("navColor") && (this.util.options.navColor = this.util.allMap[this.util.selectBuild].navColor); + this.util.allMap[this.util.selectBuild].hasOwnProperty("aRadius") && (this.util.options.aRadius = parseInt(this.util.allMap[this.util.selectBuild].aRadius)); + this.util.allMap[this.util.selectBuild].hasOwnProperty("boxShop") && (this.util.options.boxShop = this.util.allMap[this.util.selectBuild].boxShop.split(",")); + this.util.allMap[this.util.selectBuild].hasOwnProperty("shopStyle") && (this.util.options.shopStyle = this.util.allMap[this.util.selectBuild].shopStyle); + this.util.allMap[this.util.selectBuild].hasOwnProperty("modelIcon") && (this.util.options.modelIcon = this.util.allMap[this.util.selectBuild].modelIcon); + this.util.allMap[this.util.selectBuild].hasOwnProperty("facSize") && (this.util.options.facSize = this.util.allMap[this.util.selectBuild].facSize); + this.util.allMap[this.util.selectBuild].hasOwnProperty("m_scale") && (this.util.sceneGap.scale = this.util.allMap[this.util.selectBuild].m_scale); this.hemiLight.color = new THREE.Color(this.util.allMap[this.util.selectBuild].s_col || '#fffff0') this.hemiLight.groundColor = new THREE.Color(this.util.allMap[this.util.selectBuild].g_col || '#ffffff') @@ -1619,16 +1600,22 @@ MainMap_QM.prototype = { this.shawLight.color = new THREE.Color(this.util.allMap[this.util.selectBuild].d_col || '#ffffff') this.shawLight.intensity = this.util.allMap[this.util.selectBuild].d_int || 0.1 - if (this.util.allMap[this.util.selectBuild].c_site && this.util.allMap[this.util.selectBuild].c_site.split(',')) { - this.util.guiOptions.cameraX = this.util.allMap[this.util.selectBuild].c_site.split(',')[0] || 0 - this.util.guiOptions.cameraY = this.util.allMap[this.util.selectBuild].c_site.split(',')[1] ?? 220 - this.util.guiOptions.cameraZ = this.util.allMap[this.util.selectBuild].c_site.split(',')[2] ?? 220 - } - if (this.util.allMap[this.util.selectBuild].m_site && this.util.allMap[this.util.selectBuild].m_site.split(',')) { - this.util.guiOptions.targatX = this.util.allMap[this.util.selectBuild].m_site.split(',')[0] || 0 - this.util.guiOptions.targatY = this.util.allMap[this.util.selectBuild].m_site.split(',')[1] || 0 - this.util.guiOptions.targatZ = this.util.allMap[this.util.selectBuild].m_site.split(',')[2] || 0 - } + if (this.util.allMap[this.util.selectBuild].c_site && this.util.allMap[this.util.selectBuild].c_site.split(",")) { + this.util.guiOptions.cameraX = parseInt(this.util.allMap[this.util.selectBuild].c_site.split(",")[0]) || this.util.guiOptions.cameraX; + this.util.guiOptions.cameraY = parseInt(this.util.allMap[this.util.selectBuild].c_site.split(",")[1]) || this.util.guiOptions.cameraY; + this.util.guiOptions.cameraZ = parseInt(this.util.allMap[this.util.selectBuild].c_site.split(",")[2]) || this.util.guiOptions.cameraZ; + this.controls.object.position.x = this.util.guiOptions.cameraX; + this.controls.object.position.y = this.util.guiOptions.cameraY; + this.controls.object.position.z = this.util.guiOptions.cameraZ; + } + if (this.util.allMap[this.util.selectBuild].m_site && this.util.allMap[this.util.selectBuild].m_site.split(",")) { + this.util.guiOptions.targatX = parseInt(this.util.allMap[this.util.selectBuild].m_site.split(",")[0]) || this.util.guiOptions.targatX; + this.util.guiOptions.targatY = parseInt(this.util.allMap[this.util.selectBuild].m_site.split(",")[1]) || this.util.guiOptions.targatY; + this.util.guiOptions.targatZ = parseInt(this.util.allMap[this.util.selectBuild].m_site.split(",")[2]) || this.util.guiOptions.targatZ; + this.controls.target.x = this.util.guiOptions.targatX; + this.controls.target.y = this.util.guiOptions.targatY; + this.controls.target.z = this.util.guiOptions.targatZ; + } if (this.util.allMap[this.util.selectBuild].m_zoom) { this.util.m_zoom = this.util.allMap[this.util.selectBuild].m_zoom } @@ -1678,6 +1665,12 @@ MainMap_QM.prototype = { } } } + try { + this.initOutModel(); + } catch (e) { + this.callBackLoadOver({ "code": 404, "msg": "地图数据解析失败" }) + this.callBackLoadOver = null; + } }, //加载全局模型 initOutModel: function () { @@ -1800,53 +1793,21 @@ MainMap_QM.prototype = { if (_this.util.options.modelIcon) { let loader = new THREE.GLTFLoader() loader.load(_this.util.beforPath + 'static/img/elevator.gltf', function (collada) { - collada.scene.scale.x = collada.scene.scale.y = collada.scene.scale.z = 15 + collada.scene.scale.x = collada.scene.scale.y = collada.scene.scale.z = _this.util.options.facSize || 20; collada.scene.rotation.x = (-90 * Math.PI) / -180 collada.scene.renderOrder = 300 _this.util.pathStateObj.elevator = collada.scene - collada.scene.children[0].traverse(function (child) { - if (child.isMesh && child.name == 'boli2') { - child.material.color = new THREE.Color(0xffffff) - child.material.opacity = 0.8 - } - if (child.isMesh && child.name == 'pidai') { - child.material.color = new THREE.Color(0xffffff) - child.material.opacity = 0.8 - } - }) new THREE.GLTFLoader().load(_this.util.beforPath + 'static/img/elevatorDown.gltf', function (collada) { - collada.scene.scale.x = collada.scene.scale.y = collada.scene.scale.z = 15 + collada.scene.scale.x = collada.scene.scale.y = collada.scene.scale.z = _this.util.options.facSize || 20; collada.scene.rotation.x = (-90 * Math.PI) / -180 collada.scene.renderOrder = 300 _this.util.pathStateObj.elevatorDown = collada.scene - collada.scene.traverse(function (child) { - if (child.isMesh && child.name == 'boli1') { - child.material.color = new THREE.Color(0xffffff) - child.material.opacity = 0.8 - } - if (child.isMesh && child.name == 'pidai') { - child.material.color = new THREE.Color(0xffffff) - child.material.opacity = 0.8 - } - }) new THREE.GLTFLoader().load(_this.util.beforPath + 'static/img/dt.gltf', function (collada) { - collada.scene.scale.x = collada.scene.scale.y = collada.scene.scale.z = 15 + collada.scene.scale.x = collada.scene.scale.y = collada.scene.scale.z = _this.util.options.facSize || 20; collada.scene.rotation.x = (-90 * Math.PI) / -180 collada.scene.renderOrder = 300 _this.util.pathStateObj.straight = collada.scene - //console.log(Map_QM.util.pathStateObj.straight); - _this.util.pathStateObj.straight.traverse(function (child) { - if (child.isMesh && child.name == 'zhitiboli') { - child.material.color = new THREE.Color(0xffffff) - child.material.opacity = 0.6 - child.material.side = 1 - } - if (child.isMesh && child.name == 'zhitijiegou') { - child.material.color = new THREE.Color(0xffffff) - child.material.opacity = 0.8 - } - }) _this.index = 0 _this.initTreeModel() }) @@ -2026,7 +1987,7 @@ MainMap_QM.prototype = { }, 50) }, initTreeModel: function () { - let url = Map_QM.util.beforPath + Map_QM.util.modelStr[this.index].url + let url = Map_QM.util.beforPath + this.util.modelStr[this.index].url this.gltfLoad(url) }, gltfLoad: function (url) { @@ -2035,31 +1996,32 @@ MainMap_QM.prototype = { //加载路径fbx文件 object.scene.traverse(function (child) { if (child.type === 'Mesh') { - child.castShadow = Map_QM.util.options.shadow - child.receiveShadow = Map_QM.util.options.shadow + child.castShadow = sopce.util.options.shadow + child.receiveShadow = sopce.util.options.shadow if (child.material.map) { child.material.map.encoding = THREE.LinearEncoding //贴图需要转换成 线性编码 } - if (Map_QM.util.modelStr[sopce.index].colorModel === 'gama') { + if (sopce.util.modelStr[sopce.index].colorModel === 'gama') { child.material.color.convertGammaToLinear(0.6) } } }) - object.scene.children[0].scale.set(Map_QM.util.modelStr[sopce.index].size.x, Map_QM.util.modelStr[sopce.index].size.y, Map_QM.util.modelStr[sopce.index].size.z) - Map_QM.util.fbxModels.push({ key: Map_QM.util.modelStr[sopce.index].key, obj: object.scene, operation: Map_QM.util.modelStr[sopce.index] }) - if (sopce.index < Map_QM.util.modelStr.length - 1) { + object.scene.children[0].scale.set(sopce.util.modelStr[sopce.index].size.x, sopce.util.modelStr[sopce.index].size.y, Map_QM.util.modelStr[sopce.index].size.z) + sopce.util.fbxModels.push({ key: sopce.util.modelStr[sopce.index].key, obj: object.scene, operation: Map_QM.util.modelStr[sopce.index] }) + if (sopce.index < sopce.util.modelStr.length - 1) { sopce.index++ sopce.initTreeModel() } else { - if (Map_QM.util.allMap && Map_QM.util.allMap.length > 0) { - Map_QM.loaderOver() + if (sopce.util.allMap && sopce.util.allMap.length > 0) { + sopce.loaderOver() } } }) }, initGuide: function () { - new THREE.GLTFLoader().load(Map_QM.util.beforPath + 'static/img/runman.gltf', function (obj) { - obj.scene.scale.x = obj.scene.scale.y = obj.scene.scale.z = 15 + let _this = this; + new THREE.GLTFLoader().load(_this.util.beforPath + 'static/img/runman.gltf', function (obj) { + obj.scene.scale.x = obj.scene.scale.y = obj.scene.scale.z = _this.util.options.facSize || 20; obj.scene.children[0].children[1].children[0].material.color = new THREE.Color(0xfe9219) Map_QM.sceneGap.add(obj.scene) obj.scene.visible = false @@ -2075,7 +2037,7 @@ MainMap_QM.prototype = { Map_QM.guide = Map_QM.man_3d }) - new THREE.TextureLoader().load(Map_QM.util.beforPath + 'static/img/guide.png', textu => { + new THREE.TextureLoader().load(_this.util.beforPath + 'static/img/guide.png', textu => { let planeMaterial = new THREE.MeshPhongMaterial({ map: textu, depthTest: true, @@ -2090,15 +2052,15 @@ MainMap_QM.prototype = { }) }, initFloor: function () { - if (Map_QM.util.initModelArr && Map_QM.util.initModelArr.length > 0) { + if (this.util.initModelArr && this.util.initModelArr.length > 0) { this.buildObj.visible = false } - Map_QM.changeBuild(Map_QM.util.deviceObj.build, Map_QM.util.deviceObj.floor) - Map_QM.controls.target.set(Map_QM.util.guiOptions.targatX, Map_QM.util.guiOptions.targatY, Map_QM.util.guiOptions.targatZ) + this.changeBuild(this.util.deviceObj.build, this.util.deviceObj.floor) + this.controls.target.set(this.util.guiOptions.targatX, this.util.guiOptions.targatY, this.util.guiOptions.targatZ) //初始化方向为第一人称方向 - let angle = Map_QM.util.options.deviceAng ? Map_QM.util.deviceObj.angle : 0 - Map_QM.rotationAngle(angle) - Map_QM.startRender() + let angle = this.util.options.deviceAng ? this.util.deviceObj.angle : 0 + this.rotationAngle(angle) + this.startRender() setTimeout(() => { Map_QM.cameraPerspective.position.set(parseInt(Map_QM.util.guiOptions.cameraX), parseInt(Map_QM.util.guiOptions.cameraY), parseInt(Map_QM.util.guiOptions.cameraZ)) Map_QM.cameraPerspective.updateProjectionMatrix() //必须update @@ -2120,7 +2082,7 @@ MainMap_QM.prototype = { pathData.nodes.sort(this.util.sortNode) for (let i = 0; i < pathData.nodes.length; i++) { let a = pathData.nodes[i].id - Map_QM.util.pathStateObj.basePath += '"' + buildOrder + '_' + floorOrder + '_' + a + '":{' + this.util.pathStateObj.basePath += '"' + buildOrder + '_' + floorOrder + '_' + a + '":{' for (let n = 0; n < pathData.nodes[i]['list'].length; n++) { let b if (pathData.nodes[i]['list'][n].id || pathData.nodes[i]['list'][n].id == '0') { @@ -2128,12 +2090,12 @@ MainMap_QM.prototype = { } else { b = a == pathData.nodes[i]['list'][n].selfNode.id ? pathData.nodes[i]['list'][n].nextNode.id : pathData.nodes[i]['list'][n].selfNode.id } - Map_QM.util.pathStateObj.basePath += '"' + buildOrder + '_' + floorOrder + '_' + b + '":' + pathData.nodes[i]['list'][n].cost + ',' + this.util.pathStateObj.basePath += '"' + buildOrder + '_' + floorOrder + '_' + b + '":' + pathData.nodes[i]['list'][n].cost + ',' } if (pathData.nodes[i]['list'].length > 0) { - Map_QM.util.pathStateObj.basePath = Map_QM.util.pathStateObj.basePath.substr(0, Map_QM.util.pathStateObj.basePath.length - 1) + this.util.pathStateObj.basePath = this.util.pathStateObj.basePath.substr(0, this.util.pathStateObj.basePath.length - 1) } - Map_QM.util.pathStateObj.basePath += '},' + this.util.pathStateObj.basePath += '},' } } @@ -2141,43 +2103,42 @@ MainMap_QM.prototype = { minupft = -1, mindownft = -1 ///Map_QM.util.pathStateObj.selupftFacNo, Map_QM.util.pathStateObj.seldownftFacNo, if (buildOrder == this.util.deviceObj.build && floorOrder == this.util.deviceObj.floor) { - if (pathData && !this.util.deviceObj.xaxis && pathData.nodes.length > parseInt(this.util.deviceObj.node)) { + if (pathData && !this.util.deviceObj.xaxis && pathData.nodes.length > parseInt(this.util.deviceObj.node) && parseInt(this.util.deviceObj.node)>0) { this.util.deviceObj.xaxis = pathData.nodes[parseInt(this.util.deviceObj.node)].x this.util.deviceObj.yaxis = pathData.nodes[parseInt(this.util.deviceObj.node)].y } for (let h = 0; h < mapData.stairs.length; h++) { - if (mapData.stairs[h].state && mapData.stairs[h].no != '') { - let ms = - Math.abs(parseInt(mapData.stairs[h].x) - parseInt(this.util.deviceObj.xaxis)) + Math.abs(parseInt(mapData.stairs[h].y) - parseInt(this.util.deviceObj.yaxis)) + if (mapData.stairs[h].state && mapData.stairs[h].no != '' && parseInt(mapData.stairs[h].navCode) > 0) { + let ms = Math.abs(parseInt(mapData.stairs[h].x) - parseInt(this.util.deviceObj.xaxis)) + Math.abs(parseInt(mapData.stairs[h].y) - parseInt(this.util.deviceObj.yaxis)) if (mapData.stairs[h].facCode == 'dt') { if (mindt == -1) { mindt = ms - Map_QM.util.pathStateObj.seldtFacNo = mapData.stairs[h].no + this.util.pathStateObj.seldtFacNo = mapData.stairs[h].no } else { if (mindt > ms) { mindt = ms - Map_QM.util.pathStateObj.seldtFacNo = mapData.stairs[h].no + this.util.pathStateObj.seldtFacNo = mapData.stairs[h].no } } } else if (mapData.stairs[h].facCode == 'upft' || mapData.stairs[h].downState) { //上扶梯 if (minupft == -1) { minupft = ms - Map_QM.util.pathStateObj.selupftFacNo = mapData.stairs[h].no + this.util.pathStateObj.selupftFacNo = mapData.stairs[h].no } else { if (minupft > ms) { minupft = ms - Map_QM.util.pathStateObj.selupftFacNo = mapData.stairs[h].no + this.util.pathStateObj.selupftFacNo = mapData.stairs[h].no } } } else if (mapData.stairs[h].facCode == 'upft' || mapData.stairs[h].downState) { if (mindownft == -1) { mindownft = ms - Map_QM.util.pathStateObj.seldownftFacNo = mapData.stairs[h].no + this.util.pathStateObj.seldownftFacNo = mapData.stairs[h].no } else { if (mindownft > ms) { mindownft = ms - Map_QM.util.pathStateObj.seldownftFacNo = mapData.stairs[h].no + this.util.pathStateObj.seldownftFacNo = mapData.stairs[h].no } } } @@ -2187,24 +2148,23 @@ MainMap_QM.prototype = { let noHas for (let j = 0; j < mapData.stairs.length; j++) { - if ((mapData.stairs[j].hasOwnProperty('state') && mapData.stairs[j].state) || !mapData.stairs[j].state) { - //排除禁用的设施 + if (parseInt(mapData.stairs[j].navCode) > 0 && mapData.stairs[j].state) { noHas = true - for (let k = 0; k < Map_QM.util.pathStateObj.facAllArr.length; k++) { + for (let k = 0; k < this.util.pathStateObj.facAllArr.length; k++) { //Map_QM.util.pathStateObj.facAllArr 记录遍历结果 if ( - Map_QM.util.pathStateObj.facAllArr[k][0].no != '' && - Map_QM.util.pathStateObj.facAllArr[k][0].navCode != '' && - Map_QM.util.pathStateObj.facAllArr[k][0].no == mapData.stairs[j].no + this.util.pathStateObj.facAllArr[k][0].no != '' && + this.util.pathStateObj.facAllArr[k][0].navCode != '' && + this.util.pathStateObj.facAllArr[k][0].no == mapData.stairs[j].no ) { if ( - Map_QM.util.pathStateObj.facAllArr[k][0].facCode == mapData.stairs[j].facCode || - (Map_QM.util.pathStateObj.facAllArr[k][0].facCode.search('ft') != -1 && mapData.stairs[j].facCode.search('ft') != -1) + this.util.pathStateObj.facAllArr[k][0].facCode == mapData.stairs[j].facCode || + (this.util.pathStateObj.facAllArr[k][0].facCode.search('ft') != -1 && mapData.stairs[j].facCode.search('ft') != -1) ) { noHas = false mapData.stairs[j].floorOrder = floorOrder mapData.stairs[j].buildOrder = buildOrder - Map_QM.util.pathStateObj.facAllArr[k].push(mapData.stairs[j]) + this.util.pathStateObj.facAllArr[k].push(mapData.stairs[j]) } } } @@ -2212,7 +2172,7 @@ MainMap_QM.prototype = { mapData.stairs[j].buildOrder = buildOrder mapData.stairs[j].floorOrder = floorOrder let array = [mapData.stairs[j]] - Map_QM.util.pathStateObj.facAllArr.push(array) + this.util.pathStateObj.facAllArr.push(array) } } } @@ -2338,6 +2298,7 @@ MainMap_QM.prototype = { * */ showFloor: function (fIndex = -1, callBack = undefined) { + Map_QM.changeMapModel("3D"); Map_QM.resetFloorState() Map_QM.clearFloor(fIndex) if (fIndex != -1) { @@ -2522,13 +2483,17 @@ MainMap_QM.prototype = { changeMapModel: function (model) { if (model == '2D') { Map_QM.util.setModelState('2d') + Map_QM.controls.maxPolarAngle = 0; Map_QM.camera = Map_QM.cameraOrtho Map_QM.controls.object = Map_QM.camera + Map_QM.camera.updateProjectionMatrix(); Map_QM.shawLight.castShadow = false } else { Map_QM.util.setModelState('3d') Map_QM.camera = Map_QM.cameraPerspective Map_QM.controls.object = Map_QM.camera + Map_QM.controls.maxPolarAngle = Math.PI / 2 - 0.02 + Map_QM.camera.updateProjectionMatrix() Map_QM.shawLight.castShadow = Map_QM.util.options.shadow Map_QM.controls.reset() } @@ -2550,28 +2515,21 @@ MainMap_QM.prototype = { * */ onShowLocalSite: function (centerPoint, zoom = 1) { - if (Map_QM.util.initModelArr.length > 0 && Map_QM.util.changeDist.inner > Map_QM.util.options.minDis) { - Map_QM.controls.maxDistance = Map_QM.util.changeDist.inner - } - if (Map_QM.camera == Map_QM.cameraOrtho) { - Map_QM.util.setModelState('3d') - Map_QM.camera = Map_QM.cameraPerspective - Map_QM.controls.setZoom(zoom) - Map_QM.shawLight.castShadow = Map_QM.util.options.shadow - Map_QM.controls.object = Map_QM.camera - Map_QM.controls.enabled = true - Map_QM.controls.enableRotate = true - } - let vat = Map_QM.mapBackToWorld(centerPoint.x, centerPoint.y, 0) - TweenMax.to(Map_QM.controls.object.position, 0.1, { - x: vat.x, - delay: 0.1, - onComplete: function () { - Map_QM.controls.maxDistance = Map_QM.util.options.maxDis - } - }) - TweenMax.to(Map_QM.controls.target, 0.1, { x: vat.x, y: vat.y, z: vat.z }) - isJUZ = true + Map_QM.controls.setZoom(1) + Map_QM.controls.reset() + Map_QM.util.options.deviceAng && Map_QM.rotationAngle(Map_QM.util.deviceObj.angle) + if (Map_QM.util.initModelArr.length > 0 && Map_QM.util.changeDist.inner > Map_QM.util.options.minDis) { + Map_QM.controls.maxDistance = Map_QM.util.changeDist.inner; + } + Map_QM.controls.setZoom(zoom) + let vat = Map_QM.mapBackToWorld(centerPoint.x, centerPoint.y, 0); + TweenMax.to(Map_QM.controls.object.position, 0.1, { + x: vat.x, delay: 0.1, onComplete: function () { + Map_QM.controls.maxDistance = Map_QM.util.options.maxDis; + } + }); + TweenMax.to(Map_QM.controls.target, 0.1, { x: vat.x, y: vat.y, z: vat.z }); + isJUZ = true; }, //底图二维坐标转 3D模型三维坐标 mapBackToWorld: function (mapX, mapY, mapZ) { @@ -5664,7 +5622,6 @@ FloorMap_QM.prototype = { setOverSite: function (shopX, shopY, shopZ) { if (Map_QM.endModel) { Map_QM.endModel.visible = pathCameraState == '2D' ? false : true - Map_QM.endModel.scale.x = Map_QM.endModel.scale.y = Map_QM.endModel.scale.z = 100 Map_QM.endModel.position.set(shopX, shopZ, shopY) //x,z,y Map_QM.endModel.applyMatrix4(Map_QM.sceneGap.matrix) if (Map_QM.endIcon) { @@ -5704,7 +5661,7 @@ FloorMap_QM.prototype = { child2.material = new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true }) } }) - collada2.scene.scale.x = collada2.scene.scale.y = collada2.scene.scale.z = 100 + collada2.scene.scale.x = collada2.scene.scale.y = collada2.scene.scale.z = Map_QM.util.options.facSize*6; if (shopX != 0 && shopY != 0) { collada2.scene.position.set(shopX, shopZ, shopY) //x,z,y } @@ -5756,7 +5713,7 @@ FloorMap_QM.prototype = { child.material = new THREE.MeshBasicMaterial({ color: 0xffffff, transparent: true }) } }) - collada.scene.scale.x = collada.scene.scale.y = collada.scene.scale.z = 100 + collada.scene.scale.x = collada.scene.scale.y = collada.scene.scale.z = Map_QM.util.options.facSize*6; collada.scene.rotateX(Math.PI / 2) if (shopX != 0 && shopY != 0) { collada.scene.position.set(shopX, -1 * shopY, parseInt(Map_QM.util.buildHeight) + 5) //x,z,y