|
|
|
@ -225,7 +225,26 @@ QMUtil = function () { |
|
|
|
} |
|
|
|
return newColor; |
|
|
|
} |
|
|
|
|
|
|
|
this.assignUVs = function (geometry) { |
|
|
|
geometry.computeBoundingBox(); |
|
|
|
var max = geometry.boundingBox.max, |
|
|
|
min = geometry.boundingBox.min; |
|
|
|
var offset = new THREE.Vector2(0 - min.x, 0 - min.y); |
|
|
|
var range = new THREE.Vector2(max.x - min.x, max.y - min.y); |
|
|
|
var faces = geometry.faces; |
|
|
|
geometry.faceVertexUvs[0] = []; |
|
|
|
for (var i = 0; i < faces.length ; i++) { |
|
|
|
var v1 = geometry.vertices[faces[i].a], |
|
|
|
v2 = geometry.vertices[faces[i].b], |
|
|
|
v3 = geometry.vertices[faces[i].c]; |
|
|
|
geometry.faceVertexUvs[0].push([ |
|
|
|
new THREE.Vector2((v1.x + offset.x) / range.x, (v1.y + offset.y) / range.y), |
|
|
|
new THREE.Vector2((v2.x + offset.x) / range.x, (v2.y + offset.y) / range.y), |
|
|
|
new THREE.Vector2((v3.x + offset.x) / range.x, (v3.y + offset.y) / range.y) |
|
|
|
]); |
|
|
|
} |
|
|
|
geometry.uvsNeedUpdate = true; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 检测点是否在多边形区域内 |
|
|
|
*/ |
|
|
|
@ -383,11 +402,12 @@ QMUtil = function () { |
|
|
|
* B的中心点和B的宽、高 |
|
|
|
*/ |
|
|
|
this.isCollision = function (A, B) { |
|
|
|
let noCol = false; |
|
|
|
if (Math.abs(A.x - B.x) < (A.width + B.width) / 2 + 25 && Math.abs(A.y - B.y) < (A.height + B.height) / 2 + 20) { |
|
|
|
noCol = true; |
|
|
|
} |
|
|
|
return noCol; |
|
|
|
return ( |
|
|
|
A.x < B.x + B.width && |
|
|
|
A.x + A.width > B.x && |
|
|
|
A.y < B.y + B.height && |
|
|
|
A.y + A.height > B.y |
|
|
|
); |
|
|
|
} |
|
|
|
this.changeParkToString = function (area) { |
|
|
|
let areaArr = []; |
|
|
|
@ -1217,7 +1237,7 @@ MainMap_QM = function (callBack, options) { |
|
|
|
const uniforms = { |
|
|
|
"topColor": { value: new THREE.Color( 0x3385ff ) }, |
|
|
|
"bottomColor": { value: new THREE.Color( 0xffffff ) }, |
|
|
|
"offset": { value: 0 }, |
|
|
|
"offset": { value: 100 }, |
|
|
|
"exponent": { value: 0.6 } |
|
|
|
}; |
|
|
|
const skyGeo = new THREE.SphereGeometry( this.util.options.maxDis*2, 16, 16 ); |
|
|
|
@ -1796,10 +1816,7 @@ MainMap_QM.prototype = { |
|
|
|
if (fIndex >= Map_QM.util.allMap[bIndex].buildArr.length) { |
|
|
|
if (bIndex == Map_QM.util.allMap.length - 1) { |
|
|
|
clearInterval(intTimer); |
|
|
|
this.controls.minPan = new THREE.Vector3(this.w / -10, 0, this.h / -10); |
|
|
|
this.controls.maxPan = new THREE.Vector3(this.w / 10, 0, this.h / 10); |
|
|
|
let pathData = Map_QM.util.allMap[parseInt(Map_QM.util.deviceObj.build)].buildArr[parseInt(Map_QM.util.deviceObj.floor)].mapData.path; |
|
|
|
|
|
|
|
if (Map_QM.util.deviceObj.xaxis) { |
|
|
|
Map_QM.mapArr[parseInt(Map_QM.util.deviceObj.build)][parseInt(Map_QM.util.deviceObj.floor)].setStartSite(Map_QM.util.deviceObj.xaxis, Map_QM.util.deviceObj.yaxis, parseInt(Map_QM.util.shopHeight)); |
|
|
|
} else { |
|
|
|
@ -1919,7 +1936,7 @@ MainMap_QM.prototype = { |
|
|
|
if (this.util.initModelArr && this.util.initModelArr.length > 0) { |
|
|
|
this.buildObj.visible = false; |
|
|
|
} |
|
|
|
Map_QM.controls.saveState(); |
|
|
|
this.controls.saveState(); |
|
|
|
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); |
|
|
|
//初始化方向为第一人称方向
|
|
|
|
@ -1934,6 +1951,11 @@ MainMap_QM.prototype = { |
|
|
|
// this.camera.aspect = this.w / this.h;
|
|
|
|
// this.camera.updateProjectionMatrix();
|
|
|
|
// }
|
|
|
|
let boundBox = new THREE.Box3(); |
|
|
|
boundBox.setFromObject(this.sceneGap); |
|
|
|
console.log(boundBox,this.w / 10,this.h / 10); |
|
|
|
this.controls.minPan = boundBox.min; |
|
|
|
this.controls.maxPan = boundBox.max; |
|
|
|
this.startRender(); |
|
|
|
setTimeout(() => { |
|
|
|
Map_QM.controls.addEventListener('change', this.controlsChock, false); //控制器变化
|
|
|
|
@ -4973,6 +4995,7 @@ MainMap_QM.prototype = { |
|
|
|
TweenMax.killAll(true); |
|
|
|
Map_QM.util.timeObj.pathTime = setTimeout(() => { |
|
|
|
clearTimeout(Map_QM.util.timeObj.pathTime); |
|
|
|
Map_QM.controls.reset(); |
|
|
|
if (Map_QM.util.overObj && Map_QM.forShopArr[0]) { |
|
|
|
Map_QM.util.pathStateObj.isPathPlay = true; |
|
|
|
Map_QM.clearFloor(); |
|
|
|
@ -5001,6 +5024,7 @@ MainMap_QM.prototype = { |
|
|
|
TweenMax.killAll(true); |
|
|
|
Map_QM.util.timeObj.pathTime = setTimeout(() => { |
|
|
|
clearTimeout(Map_QM.util.timeObj.pathTime); |
|
|
|
Map_QM.controls.reset(); |
|
|
|
if (Map_QM.util.overObj) { |
|
|
|
Map_QM.clearFloor(); |
|
|
|
Map_QM.onFindPathModel(Map_QM.util.pathStateObj.ftPath); |
|
|
|
@ -5032,6 +5056,7 @@ MainMap_QM.prototype = { |
|
|
|
TweenMax.killAll(true); |
|
|
|
Map_QM.util.timeObj.pathTime = setTimeout(() => { |
|
|
|
clearTimeout(Map_QM.util.timeObj.pathTime); |
|
|
|
Map_QM.controls.reset(); |
|
|
|
if (Map_QM.util.overObj) { |
|
|
|
Map_QM.clearFloor(); |
|
|
|
Map_QM.onFindPathModel(Map_QM.util.pathStateObj.dtPath); |
|
|
|
@ -5063,6 +5088,7 @@ MainMap_QM.prototype = { |
|
|
|
TweenMax.killAll(true); |
|
|
|
Map_QM.util.timeObj.pathTime = setTimeout(() => { |
|
|
|
clearTimeout(Map_QM.util.timeObj.pathTime); |
|
|
|
Map_QM.controls.reset(); |
|
|
|
if (Map_QM.util.overObj) { |
|
|
|
Map_QM.clearFloor(); |
|
|
|
Map_QM.onFindPathModel(Map_QM.util.pathStateObj.graphPath); |
|
|
|
@ -6133,24 +6159,48 @@ MyModel_QM.prototype.MyPlaneShape = function (areaArr, howllowArr, opObj, entity |
|
|
|
} |
|
|
|
let scanGeometry, meshMaterial; |
|
|
|
scanGeometry = new THREE.ShapeGeometry(shape, 8); |
|
|
|
for (let e = 0; e < Map_QM.util.meshMaterialArr.length; e++) { |
|
|
|
let color2 = new THREE.Color(entityColor); |
|
|
|
if (Map_QM.util.meshMaterialArr[e].color.equals(color2) && Map_QM.util.meshMaterialArr[e].opacity == alphaModle) { |
|
|
|
meshMaterial = Map_QM.util.meshMaterialArr[e]; |
|
|
|
Map_QM.util.assignUVs(scanGeometry); |
|
|
|
if(opObj.map){ |
|
|
|
for (let e = 0; e < Map_QM.util.meshMaterialArr.length; e++) { |
|
|
|
if (Map_QM.util.meshMaterialArr[e].userData.map == opObj.map) { |
|
|
|
meshMaterial = Map_QM.util.meshMaterialArr[e]; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!meshMaterial) { |
|
|
|
let texture = new THREE.TextureLoader().load(Map_QM.util.beforPath + "static/img/map/" + opObj.map + ".jpg"); |
|
|
|
texture.wrapT = THREE.RepeatWrapping; |
|
|
|
texture.repeat.y = -1; |
|
|
|
meshMaterial = new THREE.MeshPhongMaterial({ //MeshStandardMaterial MeshPhongMaterial olor: entityColor,
|
|
|
|
color: entityColor, |
|
|
|
map: texture, |
|
|
|
transparent: true, |
|
|
|
opacity: alphaModle, |
|
|
|
side: THREE.DoubleSide, |
|
|
|
depthTest: true |
|
|
|
}); |
|
|
|
meshMaterial.userData.map = opObj.map; |
|
|
|
Map_QM.util.meshMaterialArr.push(meshMaterial); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
for (let e = 0; e < Map_QM.util.meshMaterialArr.length; e++) { |
|
|
|
let color2 = new THREE.Color(entityColor); |
|
|
|
if (Map_QM.util.meshMaterialArr[e].color.equals(color2) && Map_QM.util.meshMaterialArr[e].opacity == alphaModle) { |
|
|
|
meshMaterial = Map_QM.util.meshMaterialArr[e]; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!meshMaterial) { |
|
|
|
meshMaterial = new THREE.MeshPhongMaterial({ |
|
|
|
color: entityColor, |
|
|
|
transparent: true, |
|
|
|
opacity: alphaModle, |
|
|
|
|
|
|
|
depthTest: true |
|
|
|
}); |
|
|
|
Map_QM.util.meshMaterialArr.push(meshMaterial); |
|
|
|
} |
|
|
|
if (opObj.angleY || opObj.angleZ) { |
|
|
|
Map_QM.util.rotateYZ(scanGeometry, opObj.angleY * Math.PI / 180, opObj.angleZ * Math.PI / 180); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!meshMaterial) { |
|
|
|
meshMaterial = new THREE.MeshPhongMaterial({ |
|
|
|
color: entityColor, |
|
|
|
transparent: true, |
|
|
|
opacity: alphaModle, |
|
|
|
|
|
|
|
depthTest: true |
|
|
|
}); |
|
|
|
Map_QM.util.meshMaterialArr.push(meshMaterial); |
|
|
|
} |
|
|
|
if (opObj.angleY || opObj.angleZ) { |
|
|
|
Map_QM.util.rotateYZ(scanGeometry, opObj.angleY * Math.PI / 180, opObj.angleZ * Math.PI / 180); |
|
|
|
} |
|
|
|
// 创建模型
|
|
|
|
let mesh = new THREE.Mesh(scanGeometry, meshMaterial); |
|
|
|
@ -6272,7 +6322,7 @@ Facilities_QM = function () { |
|
|
|
map: spriteMap, |
|
|
|
depthTest: true, |
|
|
|
transparent: true, |
|
|
|
alphaTest: 0.9 |
|
|
|
alphaTest: 0.7 |
|
|
|
}); |
|
|
|
spriteMaterial.name = obj.facCode; |
|
|
|
Map_QM.util.spriteMaterialArr.push(spriteMaterial); |
|
|
|
|