|
@@ -10,8 +10,8 @@ g_currentHot = null
|
|
|
|
|
|
const playVideoWhenFlyOut = false
|
|
const playVideoWhenFlyOut = false
|
|
//同时可播放的最大个数:
|
|
//同时可播放的最大个数:
|
|
-const playVideoMax = window.isEdit ? 4 : browser.isMobile() ? 2 : 3;
|
|
|
|
-const playAniMax = window.isEdit ? 8 : browser.isMobile() ? 3 : 6;
|
|
|
|
|
|
+const playVideoMax = window.isEdit ? 3 : browser.isMobile() ? 1 : 2;
|
|
|
|
+const playAniMax = window.isEdit ? 6 : browser.isMobile() ? 3 : 5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -325,7 +325,7 @@ window.initHot = function(model){
|
|
video = media
|
|
video = media
|
|
}else{
|
|
}else{
|
|
if(!this.info.texSrc)return
|
|
if(!this.info.texSrc)return
|
|
- var video = $(`<video controls="controls" loop autoplay x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload" preload="meta" ></video>`)[0]
|
|
|
|
|
|
+ var video = $(`<video controls="controls" loop x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload" preload="meta" ></video>`)[0]
|
|
if(window.isEdit) video.src = manage.dealURL(this.info.texSrc); //注意,src赋值就会自动加载, preload="meta" 只加载元数据,提高加载速度,否则一开始卡
|
|
if(window.isEdit) video.src = manage.dealURL(this.info.texSrc); //注意,src赋值就会自动加载, preload="meta" 只加载元数据,提高加载速度,否则一开始卡
|
|
video.name = this.info.fileName
|
|
video.name = this.info.fileName
|
|
}
|
|
}
|
|
@@ -342,26 +342,36 @@ window.initHot = function(model){
|
|
|
|
|
|
video.oncanplaythrough = (e)=> {
|
|
video.oncanplaythrough = (e)=> {
|
|
if(this.texMedia == video){
|
|
if(this.texMedia == video){
|
|
- //console.log('oncanplaythrough',e,this.sid)
|
|
|
|
|
|
+ /* if(video.paused) */console.log({str:'oncanplaythrough '+this.sid, level:1})
|
|
//this.material_.map.needsUpdate = !0 //当初为何加这句?
|
|
//this.material_.map.needsUpdate = !0 //当初为何加这句?
|
|
- //this.update(player)
|
|
|
|
-
|
|
|
|
|
|
+ //this.update(player)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ /* video.onloadstart = (e)=> {
|
|
|
|
+ console.log({str:'onloadstart '+this.sid, level:1})
|
|
|
|
+ }
|
|
|
|
+ video.onloadedmetadata = (e)=> {
|
|
|
|
+ console.log({str:'onloadedmetadata '+this.sid, level:1})
|
|
|
|
+ }
|
|
|
|
+ video.onloadeddata = (e)=> {
|
|
|
|
+ console.log({str:'onloadeddata '+this.sid, level:1})
|
|
|
|
+ }
|
|
|
|
+ video.oncanplay = (e)=> {
|
|
|
|
+ console.log({str:'oncanplay '+this.sid, level:1})
|
|
|
|
+ } */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
video.volume = 0
|
|
video.volume = 0
|
|
video.muted = true
|
|
video.muted = true
|
|
video.currentTime = 0
|
|
video.currentTime = 0
|
|
|
|
|
|
|
|
|
|
- if(!window.isEdit) this.material_.opacity = 0.1;
|
|
|
|
|
|
+ if(!window.isEdit) this.material_.opacity = 0.3;
|
|
this.material_.map = new THREE.VideoTexture(video)
|
|
this.material_.map = new THREE.VideoTexture(video)
|
|
this.material_.map.wrapS = this.material_.map.wrapT = THREE.ClampToEdgeWrapping;
|
|
this.material_.map.wrapS = this.material_.map.wrapT = THREE.ClampToEdgeWrapping;
|
|
|
|
|
|
- this.material_.map.generateMipmaps = true;
|
|
|
|
-
|
|
|
|
|
|
+ this.material_.map.generateMipmaps = true;
|
|
}else if(texType == 'photo'){
|
|
}else if(texType == 'photo'){
|
|
|
|
|
|
if(media){
|
|
if(media){
|
|
@@ -693,9 +703,19 @@ window.initHot = function(model){
|
|
|
|
|
|
|
|
|
|
let maxCount = browser.isMobile() ? 2000 : 5000
|
|
let maxCount = browser.isMobile() ? 2000 : 5000
|
|
|
|
+
|
|
|
|
+ let possiblePanos = model.panos.list
|
|
|
|
+ if(this.plane){//目前都是单面,所以只要可以看到的一面的热点
|
|
|
|
+ let dir1 = new THREE.Vector3(0,0,-1).applyQuaternion(this.quaternion).negate()
|
|
|
|
+ possiblePanos = possiblePanos.filter(pano=>{
|
|
|
|
+ let dir2 = new THREE.Vector3().subVectors(pano.position, this.position).normalize();
|
|
|
|
+ return dir1.dot(dir2)>0
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
let c = model.panos.list.length * model.colliders.length
|
|
let c = model.panos.list.length * model.colliders.length
|
|
if(window.isEdit || c < maxCount){ //编辑页面保险起见还是全部算完后才可浏览,就能保证保存全部的visiblePano
|
|
if(window.isEdit || c < maxCount){ //编辑页面保险起见还是全部算完后才可浏览,就能保证保存全部的visiblePano
|
|
- this.info.visiblePanos = common.getVisiblePano(customPositions, model.panos.list, {
|
|
|
|
|
|
+ this.info.visiblePanos = common.getVisiblePano(customPositions, possiblePanos , {
|
|
model: model.colliders , posAtPanos
|
|
model: model.colliders , posAtPanos
|
|
})
|
|
})
|
|
|
|
|
|
@@ -703,17 +723,17 @@ window.initHot = function(model){
|
|
let start = 0
|
|
let start = 0
|
|
let interval = setInterval(()=>{
|
|
let interval = setInterval(()=>{
|
|
let end = start + Hot.visiPanosCountSlice;
|
|
let end = start + Hot.visiPanosCountSlice;
|
|
- end = Math.min(end, model.panos.list.length)
|
|
|
|
|
|
+ end = Math.min(end, possiblePanos.length)
|
|
let i = start
|
|
let i = start
|
|
start = end
|
|
start = end
|
|
- let panos = model.panos.list.slice(i,end)
|
|
|
|
|
|
+ let panos = possiblePanos.slice(i,end)
|
|
|
|
|
|
|
|
|
|
this.info.visiblePanos = this.info.visiblePanos.concat( common.getVisiblePano(customPositions, panos, {
|
|
this.info.visiblePanos = this.info.visiblePanos.concat( common.getVisiblePano(customPositions, panos, {
|
|
model: model.colliders , posAtPanos
|
|
model: model.colliders , posAtPanos
|
|
}));
|
|
}));
|
|
|
|
|
|
- if(end>=model.panos.list.length){
|
|
|
|
|
|
+ if(end>=possiblePanos.length){
|
|
//console.log(window.hotsi ?(++window.hotsi): (window.hotsi = 1))
|
|
//console.log(window.hotsi ?(++window.hotsi): (window.hotsi = 1))
|
|
clearInterval(interval)
|
|
clearInterval(interval)
|
|
}
|
|
}
|
|
@@ -949,32 +969,38 @@ window.initHot = function(model){
|
|
}
|
|
}
|
|
|
|
|
|
loadVideo(video){
|
|
loadVideo(video){
|
|
- if(video.src)return
|
|
|
|
- video.src = manage.dealURL(this.info.texSrc);
|
|
|
|
|
|
+ if(video.src_)return
|
|
|
|
+ video.src = video.src_ = manage.dealURL(this.info.texSrc);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
videoControl(state){
|
|
videoControl(state){
|
|
if(this.texType != "video" || !this.material_.map)return
|
|
if(this.texType != "video" || !this.material_.map)return
|
|
- var video = this.material_.map.image
|
|
|
|
|
|
+ var video = this.texMedia
|
|
this.shouldPlay = state
|
|
this.shouldPlay = state
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
if(!state || state == 'stop'){
|
|
if(!state || state == 'stop'){
|
|
if(!video.paused){
|
|
if(!video.paused){
|
|
video.pause()
|
|
video.pause()
|
|
- console.log("pause " + this.sid)
|
|
|
|
|
|
+ console.log({str: "paused " + this.sid, level:1})
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ /* video.lastCurTime = state == 'stop' ? 0 : video.currentTime //记录
|
|
|
|
+ video.src = video.src_ = '' */
|
|
|
|
+
|
|
if(state == 'stop'){
|
|
if(state == 'stop'){
|
|
video.currentTime = 0;
|
|
video.currentTime = 0;
|
|
}
|
|
}
|
|
}else if(state){
|
|
}else if(state){
|
|
- if(video.paused){
|
|
|
|
|
|
+ if(/* !isVideoPlayed(video) */ video.paused ){
|
|
|
|
+ console.log({str: 'videoControl play ' +", "+ this.sid, level:1})
|
|
this.loadVideo(video)
|
|
this.loadVideo(video)
|
|
video.play()
|
|
video.play()
|
|
|
|
+ //video.currentTime = video.lastCurTime || 0
|
|
this.changeOpaWhenPlay(video)
|
|
this.changeOpaWhenPlay(video)
|
|
|
|
|
|
- console.log("play " + this.sid)
|
|
|
|
|
|
+ if(isVideoPlayed(video))console.log({str:"played " + this.sid + video.duration ,level:1})
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -990,10 +1016,11 @@ window.initHot = function(model){
|
|
const minPlayedTime = Math.min(video.duration/10, 0.1); //到这个时间说明加载成功
|
|
const minPlayedTime = Math.min(video.duration/10, 0.1); //到这个时间说明加载成功
|
|
if(!video.hasInitedOpacity){
|
|
if(!video.hasInitedOpacity){
|
|
setTimeout(e=>{
|
|
setTimeout(e=>{
|
|
|
|
+ //console.log('trychangeOpa ',this.sid,video.currentTime)
|
|
if(video.currentTime>minPlayedTime){
|
|
if(video.currentTime>minPlayedTime){
|
|
this.material_.opacity = 1
|
|
this.material_.opacity = 1
|
|
video.hasInitedOpacity = true
|
|
video.hasInitedOpacity = true
|
|
- console.log('changeOpaWhenPlay',this.sid)
|
|
|
|
|
|
+ //console.log('changeOpaWhenPlay',this.sid)
|
|
}else{
|
|
}else{
|
|
if(!video.paused){//再次尝试
|
|
if(!video.paused){//再次尝试
|
|
return setTimeout(()=>{
|
|
return setTimeout(()=>{
|
|
@@ -1745,15 +1772,16 @@ window.initHot = function(model){
|
|
/* if(hot.texType == 'video' && hot.shouldPlay){
|
|
/* if(hot.texType == 'video' && hot.shouldPlay){
|
|
console.log(1)
|
|
console.log(1)
|
|
} */
|
|
} */
|
|
- if(!hot.clickToPlayInited && hot.texType == 'video' && hot.material_.map.image.paused && hot.shouldPlay){
|
|
|
|
|
|
+ if(!hot.clickToPlayInited && hot.texType == 'video' && !isVideoPlayed(hot.texMedia) && hot.shouldPlay){
|
|
//hot.update(player)
|
|
//hot.update(player)
|
|
- //console.log('clickToPlayInited111')
|
|
|
|
|
|
+ console.log({str:'try mobileAutoPlay '+ hot.sid, level:1})
|
|
hot.videoControl(true)
|
|
hot.videoControl(true)
|
|
|
|
|
|
- if(!hot.material_.map.image.paused){
|
|
|
|
- console.log('clickToPlayInited')
|
|
|
|
- hot.changeOpaWhenPlay(video)
|
|
|
|
|
|
+ if(isVideoPlayed(hot.texMedia)){
|
|
|
|
+ console.log({str:'clickToPlayInited '+ hot.sid, level:1})
|
|
hot.clickToPlayInited = true
|
|
hot.clickToPlayInited = true
|
|
|
|
+ hot.changeOpaWhenPlay(video)
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -1796,7 +1824,7 @@ window.initHot = function(model){
|
|
if(list.length < max){
|
|
if(list.length < max){
|
|
list.forEach(hot=>type == 'video' ? hot.videoControl(true) : GifTexDeal.start(hot.animation))
|
|
list.forEach(hot=>type == 'video' ? hot.videoControl(true) : GifTexDeal.start(hot.animation))
|
|
}else{
|
|
}else{
|
|
- let r = common.sortByScore(list,[],[(hot)=>{
|
|
|
|
|
|
+ /* let r = common.sortByScore(list,[],[(hot)=>{
|
|
let score = 0
|
|
let score = 0
|
|
var cornerPointInfo = hot.getCornerPoint(); //仅支持漫游模式
|
|
var cornerPointInfo = hot.getCornerPoint(); //仅支持漫游模式
|
|
let pos2dSum = 0 //越接近0越接近屏幕中心
|
|
let pos2dSum = 0 //越接近0越接近屏幕中心
|
|
@@ -1806,13 +1834,36 @@ window.initHot = function(model){
|
|
pos2dSum += Math.abs(pos2d.vector.x);
|
|
pos2dSum += Math.abs(pos2d.vector.x);
|
|
pos2dSum += Math.abs(pos2d.vector.y);
|
|
pos2dSum += Math.abs(pos2d.vector.y);
|
|
}else{
|
|
}else{
|
|
- pos2dSum += 2-Math.abs(pos2d.vector.x); //感觉决定背面的只有x,所以忽略y?
|
|
|
|
|
|
+ pos2dSum += 30 - THREE.Math.clamp(Math.abs(pos2d.vector.x), 0, 5); //感觉决定背面的只有x,所以忽略y? //这里无法确定加多少合适,是根据视频大小来的
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- let area = cornerPointInfo.diffLon * cornerPointInfo.diffLat //占据面积
|
|
|
|
- score = -pos2dSum * (type == 'video' ? 100 : 10) + area //gif的面积权重增加些,也就是不一定要靠近中心。因为一般而言gif比较小,起指示作用,即使散落在四角也尽量闪烁;而视频要观看的话一般会凑近居于中心
|
|
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ let area = cornerPointInfo.diffLon * cornerPointInfo.diffLat * ( 8 / pos2dSum ) //占据面积
|
|
|
|
+ //score = -pos2dSum * (type == 'video' ? 100 : 10) + area //gif的面积权重增加些,也就是不一定要靠近中心。因为一般而言gif比较小,起指示作用,即使散落在四角也尽量闪烁;而视频要观看的话一般会凑近居于中心
|
|
|
|
+
|
|
|
|
+ score = area
|
|
|
|
+ return score
|
|
|
|
+ }]) */
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ let playerDir = player.getDirection()
|
|
|
|
+ let r = common.sortByScore(list,[],[(hot)=>{ //方向因素
|
|
|
|
+ var cornerPointInfo = hot.getCornerPoint();
|
|
|
|
+ let dir = new THREE.Vector3().subVectors(hot.position, player.position).normalize()
|
|
|
|
+
|
|
|
|
+ score = dir.dot(playerDir) * Math.pow(cornerPointInfo.diffLat,0.5)// pow降低高度的权重,因为宽度更重要些。之所以两个函数都乘以diffLat,也是为了防止在两个item的分数相同diffLon不同时,diffLat增长相同倍数却能造成分数差异的情况
|
|
|
|
+
|
|
return score
|
|
return score
|
|
- }])
|
|
|
|
|
|
+ },
|
|
|
|
+ (hot)=>{//面积因素
|
|
|
|
+ var cornerPointInfo = hot.getCornerPoint(); //仅支持漫游模式
|
|
|
|
+ let area = cornerPointInfo.diffLon * Math.pow(cornerPointInfo.diffLat,0.5) / 1000 //占据面积
|
|
|
|
+ return area
|
|
|
|
+ } ])
|
|
|
|
+ //getCornerPoint仅支持漫游模式 Lat高度(纬度).
|
|
|
|
+
|
|
//console.log(r)
|
|
//console.log(r)
|
|
r && r.forEach((e,j)=>{
|
|
r && r.forEach((e,j)=>{
|
|
let hot = e.item
|
|
let hot = e.item
|
|
@@ -1837,7 +1888,9 @@ window.initHot = function(model){
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+function isVideoPlayed(video){
|
|
|
|
+ return !video.paused && !isNaN(video.duration) //注意,有的手机首次play时会立即paused为false,但其实没加载好, duration为NAN
|
|
|
|
+}
|
|
|
|
|
|
/*
|
|
/*
|
|
|
|
|
|
@@ -1861,5 +1914,7 @@ window.initHot = function(model){
|
|
|
|
|
|
|
|
|
|
有遇到某张图在ios里显示不出,但在ps重新输出后就可以。这张图的dpi高达500,不知道是否与此有关。
|
|
有遇到某张图在ios里显示不出,但在ps重新输出后就可以。这张图的dpi高达500,不知道是否与此有关。
|
|
|
|
+ 遇到过ios14.8.1、14.7.1 无法播放webm(来自1050)。 onloadedmetadata失败
|
|
|
|
+
|
|
|
|
|
|
- */
|
|
|
|
|
|
+*/
|