|
@@ -38,7 +38,7 @@ window.initHot = function(model){
|
|
|
opacity: 0.8,
|
|
|
side:THREE.DoubleSide
|
|
|
})
|
|
|
-
|
|
|
+ var autoSizeInfo = {minSize : 120, maxSize : 600, nearBound : 1 , farBound : 15}
|
|
|
|
|
|
var hotGroup = new THREE.Object3D; hotGroup.name = "hotGroup"
|
|
|
model.add(hotGroup); model.hotGroup = hotGroup
|
|
@@ -400,6 +400,7 @@ window.initHot = function(model){
|
|
|
}
|
|
|
this.changeShineTex(this.styleImg)
|
|
|
}
|
|
|
+ this.info.texSrc = null
|
|
|
}
|
|
|
if(this.material_.map){
|
|
|
/* this.material_.map.minFilter = THREE.LinearFilter;
|
|
@@ -779,10 +780,11 @@ window.initHot = function(model){
|
|
|
return this.cornerPoints[player.currentPano.id]
|
|
|
}else{
|
|
|
var boundPoint, cornerPoint
|
|
|
+ var center//中心点
|
|
|
if(this.plane){
|
|
|
- var center = this.plane.position.clone()
|
|
|
- boundPoint = [
|
|
|
- center,
|
|
|
+ center = this.plane.getWorldPosition()
|
|
|
+ boundPoint = [
|
|
|
+
|
|
|
new THREE.Vector3(-0.5, 0.5, 0),
|
|
|
new THREE.Vector3(0.5, 0.5, 0),
|
|
|
new THREE.Vector3(0.5, -0.5, 0),
|
|
@@ -811,11 +813,11 @@ window.initHot = function(model){
|
|
|
var maxLat = -Infinity
|
|
|
var minLat = +Infinity
|
|
|
var pos1 = player.currentPano.position.clone();
|
|
|
- var pos2 = this.position.clone()
|
|
|
- var dir = pos2.clone().sub(pos1).normalize()
|
|
|
+ center = this.position.clone() //模型bound的中心点已经位移到了hot中心点。 注意不能用getWorldPosition,得到的会是偏移的
|
|
|
+ var dir = center.clone().sub(pos1).normalize()
|
|
|
var centerDirInfo = { }
|
|
|
player.cameraControls.controls.panorama.lookAt.call( centerDirInfo , null, dir )
|
|
|
-
|
|
|
+
|
|
|
boundPoint.forEach(e=>{//lon左右
|
|
|
var point = e.applyMatrix4(this.mesh.matrixWorld);
|
|
|
var dir = point.clone().sub(pos1).normalize()
|
|
@@ -857,19 +859,19 @@ window.initHot = function(model){
|
|
|
math.getDirByLonLat(minLon, minLat),
|
|
|
math.getDirByLonLat(maxLon, minLat),
|
|
|
math.getDirByLonLat(minLon, maxLat),
|
|
|
- ]
|
|
|
+ ]
|
|
|
|
|
|
cornerPoint = dirs.map(e=>{
|
|
|
return e.clone().add(pos1)
|
|
|
})
|
|
|
-
|
|
|
+ cornerPoint = [center, ...cornerPoint] //最后增加一个中心点
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
- if(this.objObject){
|
|
|
+ /* if(this.objObject){
|
|
|
cornerPoint = [pos2, ...cornerPoint]
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
|
|
|
//addPoints(cornerPoint)
|
|
@@ -941,10 +943,22 @@ window.initHot = function(model){
|
|
|
this.quaternion.copy(player.camera.quaternion)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ this.updateScale()
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ updateScale(e, t) {//自适应调节大小
|
|
|
+ if(!DATA.autoAdjustHotScale || this.texType != 'shine' )return
|
|
|
+ //let renderSize = player.sceneRenderer.renderer.domElement
|
|
|
+ let renderSize = player.sceneRenderer.renderer.getSize()
|
|
|
+
|
|
|
+ var scale = convertTool.getScaleForConstantSize($.extend(autoSizeInfo,{
|
|
|
+ camera:player.camera, resolution:{x:renderSize.width, y:renderSize.height},
|
|
|
+ position: this.position.clone() ,
|
|
|
+ }))
|
|
|
+ this.plane.scale.set(scale,scale,scale)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
switchPlay(state){//手动播放暂停
|
|
@@ -1033,46 +1047,66 @@ window.initHot = function(model){
|
|
|
, n = []
|
|
|
, r = this.mesh.getWorldPosition();
|
|
|
if (e === "panorama") {
|
|
|
- var o = t.position.clone().sub(r).normalize();
|
|
|
- n.push(function(t, i) {//scoreFunctions.direction
|
|
|
+ /* var o = t.position.clone().sub(r).normalize();
|
|
|
+ n.push(function(t, i) {//scoreFunctions.direction 最好这个漫游点在currentPano到热点之间的路径上。但是这样的话可能就看不到热点正面,所以删掉
|
|
|
return function(e) {
|
|
|
- return e.position.clone().sub(t).normalize().dot(i) * window._settings.navigation.directionFactor
|
|
|
+ return e.position.clone().sub(t).normalize().dot(i) * window._settings.navigation.directionFactor
|
|
|
}}(r, o)
|
|
|
- )
|
|
|
+ ) */
|
|
|
}
|
|
|
var a = new THREE.Vector3;
|
|
|
i.push(function(e) {
|
|
|
return Math.abs(e.position.x - r.x) > window._settings.tags.visibility.cameraClearance || Math.abs(e.position.z - r.z) > window._settings.tags.visibility.cameraClearance
|
|
|
- }, function(e) {
|
|
|
+ },
|
|
|
+
|
|
|
+ function(e) {
|
|
|
a.copy(r).sub(e.position);
|
|
|
var t = -THREE.Math.radToDeg(Math.atan(a.y / Math.sqrt(a.x * a.x + a.z * a.z)))
|
|
|
, i = window._settings.tags.navigate.tiltTolerance
|
|
|
return window._settings.insideLookLimitDown - i < t && t < window._settings.insideLookLimitUp + i
|
|
|
- },
|
|
|
+ },
|
|
|
+
|
|
|
(pano)=>{ // add
|
|
|
return player.checkHasNeighbor(pano)
|
|
|
- }
|
|
|
-
|
|
|
- ),
|
|
|
- n.push( function(t, i) {//scoreFunctions.distanceSquared
|
|
|
- return i = i || a.navigation.distanceFactor,
|
|
|
- function(e) {
|
|
|
- return t ? t.position.distanceToSquared(e.position) * i : 0
|
|
|
+ },
|
|
|
+
|
|
|
+ (pano)=>{ // add
|
|
|
+ return this.info.visiblePanos.includes(pano.id)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ n.push(
|
|
|
+ (function(hot, i) { //scoreFunctions.distanceSquared
|
|
|
+ return function(pano) {
|
|
|
+ //i = a.navigation.distanceFactor
|
|
|
+ return hot ? hot.position.distanceToSquared(pano.position) * i : 0
|
|
|
}
|
|
|
- }(this, -2));
|
|
|
+ })(this, -2)
|
|
|
+ ,
|
|
|
+
|
|
|
+ (pano)=>{//尽量正对hot
|
|
|
+ let dir = new THREE.Vector3(0,0,1).applyQuaternion(this.quaternion)
|
|
|
+ let dir2 = new THREE.Vector3().subVectors(pano.position, this.position).normalize();
|
|
|
+ let s = dir.dot(dir2) * 10;
|
|
|
+ //console.log(pano.id + ":" + s)
|
|
|
+ return s
|
|
|
+ }
|
|
|
+
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
var s = t.model.panos.sortByScore(i, n);
|
|
|
- /* if (s && window._settings.tags.navigate.lineOfSight) {
|
|
|
- for (var l = 0; l < s.length; l++) {
|
|
|
- var c = s[l].pano
|
|
|
- , h = c.position.distanceTo(r);
|
|
|
- p.set(c.position, r.clone().sub(c.position).normalize());
|
|
|
- var u = p.intersectObjects(t.model.colliders);
|
|
|
- if (0 === u.length || u[0].distance > h)
|
|
|
- return console.log(l),
|
|
|
- c
|
|
|
- }
|
|
|
- return null
|
|
|
- } */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return s && 0 < s.length && s[0].pano
|
|
|
}
|
|
|
|
|
@@ -1319,14 +1353,18 @@ window.initHot = function(model){
|
|
|
}
|
|
|
}
|
|
|
changeBoxHelperDisplay(show){
|
|
|
- this.visible_ = this.visible
|
|
|
+
|
|
|
if(show){
|
|
|
+ this.visible_ = this.visible
|
|
|
this.visible = true
|
|
|
this.mesh.boxHelper.visible = true
|
|
|
}else{
|
|
|
- this.visible = this.visible_
|
|
|
+ if(this.visible_ != void 0){
|
|
|
+ this.visible = this.visible_
|
|
|
+ }
|
|
|
this.mesh.boxHelper.visible = false
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1343,7 +1381,7 @@ window.initHot = function(model){
|
|
|
|
|
|
if(type == 'photo'){
|
|
|
if(this.photoHasRequestLoad || this.texType != 'photo')return;
|
|
|
- console.log('overlay beginDownload : ' + this.sid)
|
|
|
+ //console.log('overlay beginDownload : ' + this.sid)
|
|
|
|
|
|
|
|
|
/* this.material_.map = */Texture.load(this.info.texSrc, (tex)=>{
|
|
@@ -1359,7 +1397,7 @@ window.initHot = function(model){
|
|
|
if(e.info.texSrc == this.info.texSrc){
|
|
|
e.material_.color.set("#FFFFFF")
|
|
|
e.material_.opacity = 1;
|
|
|
- console.log('overlay loaded: ' + e.sid + " - " + this.info.texSrc.split('/').pop());
|
|
|
+ //console.log('overlay loaded: ' + e.sid + " - " + this.info.texSrc.split('/').pop());
|
|
|
|
|
|
|
|
|
|