|
@@ -4956,7 +4956,7 @@ window.Modernizr = function(n, e, t) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- n.prototype.findNearestItem = function(endToStart=true){//找到离currentPano最近的导览
|
|
|
|
|
|
+ n.prototype.findNearestItem = function(endToStart=true, searchEvery){//找到离currentPano最近的导览
|
|
/* if(this.atDestinationPano(this.player.currentPano)){//在终点直接从头。但有的场景可能不希望如此,就想跳到所属的展区开始。
|
|
/* if(this.atDestinationPano(this.player.currentPano)){//在终点直接从头。但有的场景可能不希望如此,就想跳到所属的展区开始。
|
|
return [0,0] //2023.7.7发现在点击item后播放会从头开始
|
|
return [0,0] //2023.7.7发现在点击item后播放会从头开始
|
|
} */
|
|
} */
|
|
@@ -4971,29 +4971,37 @@ window.Modernizr = function(n, e, t) {
|
|
if(dis<result.dis){
|
|
if(dis<result.dis){
|
|
result.item = item, result.dis = dis
|
|
result.item = item, result.dis = dis
|
|
}else if(dis == result.dis){//如果两个位置相同,优先播放在导览条上离激活的最近的那段导览
|
|
}else if(dis == result.dis){//如果两个位置相同,优先播放在导览条上离激活的最近的那段导览
|
|
- /* if(this.itemCompare(item, this.currentItem, 'equal')){
|
|
|
|
|
|
+
|
|
|
|
+ /* if(this.itemCompare(item, this.currentItem, 'equal')){//优先用当前的
|
|
result.item = item, result.dis = dis
|
|
result.item = item, result.dis = dis
|
|
- } */
|
|
|
|
- if(this.currentItem && Math.abs(item[0]-this.currentItem[0]) < Math.abs(result.item[0]-this.currentItem[0])){
|
|
|
|
|
|
+ }else if(this.currentItem && Math.abs(item[0]-this.currentItem[0]) < Math.abs(result.item[0]-this.currentItem[0])){
|
|
result.item = item, result.dis = dis
|
|
result.item = item, result.dis = dis
|
|
- }
|
|
|
|
|
|
+ } */
|
|
|
|
+ if(this.currentItem){
|
|
|
|
+ let dis1 = [Math.abs(item[0] - this.currentItem[0]), Math.abs(item[1] - this.currentItem[1])] //当前差距
|
|
|
|
+ let dis2 = [Math.abs(result.item[0] - this.currentItem[0]), Math.abs(result.item[1] - this.currentItem[1])]
|
|
|
|
+ if( this.itemCompare(dis1, dis2, 'less')){
|
|
|
|
+ result.item = item, result.dis = dis
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.model.heroLocations.forEach((e,i)=>{
|
|
this.model.heroLocations.forEach((e,i)=>{
|
|
if(e.heroLocations){
|
|
if(e.heroLocations){
|
|
- /* e.heroLocations.forEach((a,j)=>{
|
|
|
|
- compare(a, [i,j])
|
|
|
|
- }) */
|
|
|
|
- var location = e.heroLocations.find(e=>e.panoId != void 0)
|
|
|
|
- location && compare(location, [i,0]) //跳到此区域开头
|
|
|
|
-
|
|
|
|
|
|
+ if(searchEvery){
|
|
|
|
+ e.heroLocations.forEach((a,j)=>{
|
|
|
|
+ compare(a, [i,j])
|
|
|
|
+ })
|
|
|
|
+ }else{
|
|
|
|
+ var location = e.heroLocations.find(e=>e.panoId != void 0)
|
|
|
|
+ location && compare(location, [i,0]) //跳到此区域开头
|
|
|
|
+ }
|
|
}else{
|
|
}else{
|
|
compare(e, [i,0])
|
|
compare(e, [i,0])
|
|
}
|
|
}
|
|
|
|
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
if(endToStart && this.atEndOfTour(result.item)){ //如果是最后一个点,直接跳到开头,否则导览开始就在终点的话不会从头开始
|
|
if(endToStart && this.atEndOfTour(result.item)){ //如果是最后一个点,直接跳到开头,否则导览开始就在终点的话不会从头开始
|
|
@@ -22106,7 +22114,7 @@ window.Modernizr = function(n, e, t) {
|
|
this.updateModel()
|
|
this.updateModel()
|
|
|
|
|
|
|
|
|
|
- //this.guider2 = new PanTransGuide(this)
|
|
|
|
|
|
+ this.guider2 = new PanTransGuide(this)
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -23554,7 +23562,7 @@ window.Modernizr = function(n, e, t) {
|
|
if (this.updateLastView(),
|
|
if (this.updateLastView(),
|
|
this.mode !== u.PANORAMA) {
|
|
this.mode !== u.PANORAMA) {
|
|
var m;
|
|
var m;
|
|
- void this.flyToNewMode({
|
|
|
|
|
|
+ return void this.flyToNewMode({
|
|
mode: u.PANORAMA,
|
|
mode: u.PANORAMA,
|
|
pano: i,
|
|
pano: i,
|
|
duration: o,
|
|
duration: o,
|
|
@@ -59521,7 +59529,6 @@ window.Modernizr = function(n, e, t) {
|
|
}, {}, [116]);
|
|
}, {}, [116]);
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
class PanTransGuide{
|
|
class PanTransGuide{
|
|
constructor(player){
|
|
constructor(player){
|
|
this.player = player
|
|
this.player = player
|
|
@@ -59534,12 +59541,23 @@ class PanTransGuide{
|
|
this.nodes = []
|
|
this.nodes = []
|
|
let path = this.player.path
|
|
let path = this.player.path
|
|
let last
|
|
let last
|
|
- this.player.model.heroLocations.forEach((e,i)=>{
|
|
|
|
-
|
|
|
|
- if(i>0){
|
|
|
|
-
|
|
|
|
- if(e.cameraMode != 'panorama')return
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ let index = this.player.model.heroLocations.findIndex(e=>e.name == '沉浸看展') //先去掉之前旧的数据
|
|
|
|
+ if(index>-1){
|
|
|
|
+ let locations = this.player.model.heroLocations[index].heroLocations
|
|
|
|
+ this.player.model.heroLocations.splice(index,1)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let get = (e, originItem)=>{
|
|
|
|
+ if(e.cameraMode != 'panorama'){
|
|
|
|
+ e.originItem = originItem
|
|
|
|
+ this.nodes.push(e)
|
|
|
|
+ return last = null //断连
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(last){
|
|
|
|
+ e.visited = true
|
|
path.setWarpDestination(e)
|
|
path.setWarpDestination(e)
|
|
path.setWarpDestPano()
|
|
path.setWarpDestPano()
|
|
let A = path.getHeroPano(last),
|
|
let A = path.getHeroPano(last),
|
|
@@ -59548,12 +59566,13 @@ class PanTransGuide{
|
|
path.nodes = [A.id,B.id];//直接加入
|
|
path.nodes = [A.id,B.id];//直接加入
|
|
}else{
|
|
}else{
|
|
path.nodes = path.findShortestPath(A, B)
|
|
path.nodes = path.findShortestPath(A, B)
|
|
-
|
|
|
|
if(path.nodes == null){//两个点之间不相通
|
|
if(path.nodes == null){//两个点之间不相通
|
|
console.log('两个点之间不相通',A.id,B.id)
|
|
console.log('两个点之间不相通',A.id,B.id)
|
|
path.nodes = [A.id,B.id];//直接加入
|
|
path.nodes = [A.id,B.id];//直接加入
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
let wholeDis = 0, disSections = []
|
|
let wholeDis = 0, disSections = []
|
|
path.nodes.forEach((cur,i)=>{
|
|
path.nodes.forEach((cur,i)=>{
|
|
if(i==0)return
|
|
if(i==0)return
|
|
@@ -59570,7 +59589,7 @@ class PanTransGuide{
|
|
path.nodes.forEach((panoId,j)=>{
|
|
path.nodes.forEach((panoId,j)=>{
|
|
if(j == 0){
|
|
if(j == 0){
|
|
if(path.nodes.length == 1)return this.nodes.push({panoId,quaternion:quaEnd})//原地旋转
|
|
if(path.nodes.length == 1)return this.nodes.push({panoId,quaternion:quaEnd})//原地旋转
|
|
- if(i > 0)return //和上一段末尾重复
|
|
|
|
|
|
+ if(!last) return //和上一段末尾重复
|
|
return this.nodes.push({panoId,quaternion:quaStart})
|
|
return this.nodes.push({panoId,quaternion:quaStart})
|
|
}
|
|
}
|
|
let r = disSections[j-1] / wholeDis
|
|
let r = disSections[j-1] / wholeDis
|
|
@@ -59578,21 +59597,33 @@ class PanTransGuide{
|
|
lerp.quaternion(quaternion, quaEnd)(r)
|
|
lerp.quaternion(quaternion, quaEnd)(r)
|
|
this.nodes.push({panoId, quaternion})
|
|
this.nodes.push({panoId, quaternion})
|
|
})
|
|
})
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
last = e
|
|
last = e
|
|
- })
|
|
|
|
-
|
|
|
|
- //path.setWarpDestinationByHeroIndex()
|
|
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.player.model.heroLocations.forEach((e,i)=>{
|
|
|
|
+ if(e.heroLocations){
|
|
|
|
+ e.heroLocations.forEach((a,j)=> get(a, [i,j]))
|
|
|
|
+ }else{
|
|
|
|
+ get(e,[i,0])
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ //补 因为last前一个可能不是panorama,导致last没加进nodes
|
|
|
|
+ if(last && !last.visited){
|
|
|
|
+ get(last)
|
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
go(axis){
|
|
go(axis){
|
|
if(this.player.flying)return
|
|
if(this.player.flying)return
|
|
let aimNode
|
|
let aimNode
|
|
let cur = this.nodes[this.currentIndex]
|
|
let cur = this.nodes[this.currentIndex]
|
|
- if(cur.panoId != this.player.currentPano.id){//已走动
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if(cur.panoId != this.player.currentPano.id && player.mode == 'panorama'){//已走动){//已走动
|
|
let curs = this.nodes.filter(e=>e.panoId == this.player.currentPano)
|
|
let curs = this.nodes.filter(e=>e.panoId == this.player.currentPano)
|
|
curs.sort((a,b)=>{ //如果有多个,找到和currentIndex最接近的,可能是刚走过的
|
|
curs.sort((a,b)=>{ //如果有多个,找到和currentIndex最接近的,可能是刚走过的
|
|
let indexA = this.nodes.indexOf(a)
|
|
let indexA = this.nodes.indexOf(a)
|
|
@@ -59602,28 +59633,40 @@ class PanTransGuide{
|
|
cur = curs[0]
|
|
cur = curs[0]
|
|
if(!cur){//不在道上 . 找离当前位置最近的node
|
|
if(!cur){//不在道上 . 找离当前位置最近的node
|
|
let disMap = new Map
|
|
let disMap = new Map
|
|
- this.nodes.forEach(e=>{
|
|
|
|
|
|
+ let nodes_ = this.nodes.filter(e=>!e.originItem)
|
|
|
|
+
|
|
|
|
+ nodes_.forEach(e=>{
|
|
disMap.set(e,player.currentPano.position.distanceToSquared(this.player.model.panos.get(e.panoId).position))
|
|
disMap.set(e,player.currentPano.position.distanceToSquared(this.player.model.panos.get(e.panoId).position))
|
|
})
|
|
})
|
|
- let sorted = this.nodes.slice().sort((a,b)=>{
|
|
|
|
|
|
+ let sorted = nodes_.slice().sort((a,b)=>{
|
|
return disMap.get(a) - disMap.get(b)
|
|
return disMap.get(a) - disMap.get(b)
|
|
})
|
|
})
|
|
|
|
|
|
this.currentIndex = this.nodes.indexOf(sorted[0])//next
|
|
this.currentIndex = this.nodes.indexOf(sorted[0])//next
|
|
- if(axis == 'prev'){
|
|
|
|
|
|
+ if(axis == -1){
|
|
this.moveIndex(-1)
|
|
this.moveIndex(-1)
|
|
}
|
|
}
|
|
aimNode = this.nodes[this.currentIndex]
|
|
aimNode = this.nodes[this.currentIndex]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ let lastIndex = this.currentIndex
|
|
if(!aimNode){
|
|
if(!aimNode){
|
|
- this.moveIndex(axis == 'prev' ? -1 : 1)
|
|
|
|
- aimNode = this.nodes[this.currentIndex]
|
|
|
|
|
|
+ this.moveIndex(axis)
|
|
|
|
+ aimNode = this.nodes[this.currentIndex]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(aimNode.originItem){//要飞出的,直接用导览飞
|
|
|
|
+ player.director.setDestinationItem(aimNode.originItem)
|
|
|
|
+ player.director.goToDestination()
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
- let dis = this.player.model.panos.get(aimNode.panoId).position.distanceTo(this.player.position)
|
|
|
|
- let moveStyle = dis < 10 ? "flyToPano" : "blackToPano"
|
|
|
|
- this.player[moveStyle]({pano: this.player.model.panos.get(aimNode.panoId),quaternion:aimNode.quaternion})
|
|
|
|
|
|
+ //let dis = this.player.model.panos.get(aimNode.panoId).position.distanceTo(this.player.position)
|
|
|
|
+ let moveStyle = (lastIndex == 0 && axis == -1 || this.currentIndex == 0 && axis != -1) ? "blackToPano" : "flyToPano"
|
|
|
|
+ this.player[moveStyle]({pano: this.player.model.panos.get(aimNode.panoId), quaternion:aimNode.quaternion}, ()=>{
|
|
|
|
+ //更新导览进度条
|
|
|
|
+ player.director.setDestinationItem( player.director.findNearestItem(true,true) )
|
|
|
|
+ })
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -59633,13 +59676,24 @@ class PanTransGuide{
|
|
this.currentIndex %= this.nodes.length
|
|
this.currentIndex %= this.nodes.length
|
|
return this.currentIndex
|
|
return this.currentIndex
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+//2025新的需求 沉浸看展直接使用导览
|
|
|
|
+window.tourPlayCtl = {
|
|
|
|
+ go(axis){
|
|
|
|
+ player.guider2.go(axis)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
/*
|
|
/*
|
|
function getWebXRManager(){
|
|
function getWebXRManager(){
|