Procházet zdrojové kódy

fix: 准备升级一下4k放大的cube,减少在用贴图数

xzw před 2 roky
rodič
revize
f2e3030eb4
6 změnil soubory, kde provedl 199 přidání a 81 odebrání
  1. 14 6
      index.html
  2. 8 5
      js/Hot.js
  3. 7 0
      js/lib/flv.min.js
  4. 4 26
      js/main_2020_edit.js
  5. 19 17
      js/main_2020_show.js
  6. 147 27
      js/manage.js

+ 14 - 6
index.html

@@ -793,7 +793,7 @@
     <script>
      
         var changeLog = ()=>{
-            browser
+             
             if((number == "TEST" || browser.valueFromHash('TEST')) && browser.isMobile()){
             
                 
@@ -870,18 +870,26 @@
     <script src="js/lib/Tween.js"></script>
     <!-- <script src="js/app-preheater.js?v=2.25.6-0-gd87e5b1"></script> --> 
     <script src="js/SpecialScene.js"></script>
+    
+    
     <script src="js/manage.js"></script> 
     <!-- <script src="js/lib/stats.min.js"></script> -->
     <script src="js/Hot.js?m=1"></script>  
     <script src="js/main_2020_show.js"></script>
     <script src="js/lib/OBJLoader.js"></script>
-    <script src="/CAD/bundle.js"></script>
-
-
+    <script src="/CAD/bundle.js"></script> 
     <script src="js/loadCAD.js"></script>
+    <script id='flvJs' type='text/javascript' ></script>
+    <script>
+         /*if(window.browser.detectAndroidMobile()){
+            let scriptdom = document.querySelector('#flvJs')
+            //scriptdom.setAttribute('src','js/lib/flv.min.js')
+            scriptdom.setAttribute('type','text/javascript')
+            scriptdom.src = 'js/lib/flv.min.js'
+         }*/
+          
     
-    
-    
+    </script>
 </body>
 
 </html>

+ 8 - 5
js/Hot.js

@@ -325,8 +325,15 @@ window.initHot = function(model){
                     video = media
                 }else{
                     if(!this.info.texSrc)return
+                  
                     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" 只加载元数据,提高加载速度,否则一开始卡 
+                     
+                    /* let src = this.info.texSrc
+                    if(window.isEdit)  src = manage.dealURL(src);   
+                    var video = window.videoPlayer.getVideo(src)*/
+                  
+                    
                     video.name = this.info.fileName
                 } 
                 
@@ -407,11 +414,7 @@ window.initHot = function(model){
                 this.material_.color.set("#FFFFFF"); 
                 
                 this.material_.needsUpdate = true
-            }
-             
-            
-            
-            
+            } 
             
         } 
 

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 7 - 0
js/lib/flv.min.js


+ 4 - 26
js/main_2020_edit.js

@@ -4765,7 +4765,7 @@ function o(a, s, l) {
                     this.emit(u.TourStart),
                     this.player.enablePreRendering(),
                     this.walkingSectionPaused ? (this.clearWalkingSectionPaused(),
-                    this.goToDestination()) : this.goNext()))
+                    this.goToDestination()) : /* this.goNext() */(this.tourAdvance(0) ,this.goToDestination()))) //xzw: 不要直接跳到下一个点开始,从当前点开始,否则当一段区域内只有一个导览时播放会立刻跳到下一个缩略图进行。
             }
             ,
             
@@ -4929,41 +4929,19 @@ function o(a, s, l) {
             
             }
             , 
-            t.prototype.tourAdvance = function(e) {//e是1或-1
+            t.prototype.tourAdvance = function(e) {//e是1或-1或0
                 
                 m.debug("tourAdvance(" + e + ")") 
                 if(null === this.currentItem || void 0 === this.currentItem){
                     this.setDestinationItem(this.firstDestination()) 
                 }else{
-                    var item            
+                    var item = this.currentItem          
                     if(e == 1){
                         item = this.nextItem(this.currentItem)
-                        
-                        /* var currentLocation = this.model.heroLocations[this.currentItem[0]];
-                        var currentChildNum = currentLocation.heroLocations ? currentLocation.heroLocations.length : 1
-                    
-                        if(this.currentItem[1] >= currentChildNum - 1){//子目录中最后一个
-                            this.setDestinationItem([this.currentItem[0] + 1, 0]) //结果可能超出nItems
-                        }else{
-                            this.setDestinationItem([this.currentItem[0] , this.currentItem[1]+1]) 
-                        } */
                     }else if(e == -1){
                         item = this.prevItem(this.currentItem)
-                        /* var lastLocation = this.model.heroLocations[this.currentItem[0]-1];
-                        if(!lastLocation) this.setDestinationItem([-1, 0]) //结果小于0
-                        else{
-                            var lastChildNum = lastLocation.heroLocations ? lastLocation.heroLocations.length : 1
-                    
-                            if(this.currentItem[1] == 0){//子目录中第一个 
-                                this.setDestinationItem([this.currentItem[0] - 1, lastChildNum-1]) 
-                            }else{
-                                this.setDestinationItem([this.currentItem[0], this.currentItem[1]-1]) 
-                            }
-                        }    */ 
-                        
                     } 
-                     
-                    //this.setDestinationItem(this.currentItem + e) 
+                    
                     this.setDestinationItem(item) 
                 }
                 

+ 19 - 17
js/main_2020_show.js

@@ -6,7 +6,7 @@
 
 
 
-let highMapAddColor// =  true
+let highMapAddColor =  true
 
 !function() {
     "use strict";
@@ -4926,9 +4926,9 @@ window.Modernizr = function(n, e, t) {
             
             
             n.prototype.findNearestItem = function(endToStart=true){//找到离currentPano最近的导览
-                if(this.atDestinationPano(this.player.currentPano)){//在终点直接从头。但有的场景可能不希望如此,就想跳到所属的展区开始。
-                    return [0,0]
-                }
+                /* if(this.atDestinationPano(this.player.currentPano)){//在终点直接从头。但有的场景可能不希望如此,就想跳到所属的展区开始。
+                    return [0,0]   //2023.7.7发现在点击item后播放会从头开始
+                } */
                 //注:没有判断此刻是否在panorama模式,就使用currentPano
             
                 var result = {item:[0,0], dis:Infinity};
@@ -5021,7 +5021,7 @@ window.Modernizr = function(n, e, t) {
                     this.player.enablePreRendering(),
                     // this.currentItem[1] = null,
                     this.walkingSectionPaused ? (this.clearWalkingSectionPaused(),
-                    this.goToDestination()) : this.goNext()))
+                    this.goToDestination()) : /* this.goNext() */(this.tourAdvance(0) ,this.goToDestination()))) //xzw: 不要直接跳到下一个点开始,从当前点开始,否则当一段区域内只有一个导览时播放会立刻跳到下一个缩略图进行。
                 }
             } 
             
@@ -5218,7 +5218,7 @@ window.Modernizr = function(n, e, t) {
             
             
             
-            n.prototype.tourAdvance = function(e) {//e是1或-1
+            n.prototype.tourAdvance = function(e) {//e是1或-1 或 0
                 
                 A.debug("tourAdvance(" + e + ")") 
 
@@ -5231,16 +5231,15 @@ window.Modernizr = function(n, e, t) {
                 // else if(this.currentItem[1] == null) {
                 //     this.setDestinationItem([this.currentItem[0], 0])
                 // }
-                else{ 
-                    
-                        var item    
-                        if(e == 1){
-                            item = this.nextItem(this.currentItem)
-                        }else if(e == -1){
-                            item = this.prevItem(this.currentItem)    
-                            
-                        }
-                        this.setDestinationItem(item) 
+                else{  
+                    var item = this.currentItem
+                    if(e == 1){
+                        item = this.nextItem(this.currentItem)
+                    }else if(e == -1){
+                        item = this.prevItem(this.currentItem)    
+                        
+                    }
+                    this.setDestinationItem(item) 
                 }
                 
                 if(this.itemCompare(this.destinationItem, this.finalDestination(), 'equal')){ 
@@ -27908,7 +27907,10 @@ window.Modernizr = function(n, e, t) {
             Base: 0,
             Remaining: 1
         }
-          , M = [];
+          ,M = [];
+          
+        window.targetList = M
+          
         l.prototype = Object.create(E.prototype),
         l.prototype.init = function(e, t, i) {
             this.sceneRenderer = e,

+ 147 - 27
js/manage.js

@@ -105,7 +105,7 @@ var settings = {
         },
         mobile:{
             nav: '1k',  //不放大时
-            max: '2k',  //放大最大
+            max: '4k',  //放大最大
         }
     }, //可以稍后自行修改
 }
@@ -1564,39 +1564,141 @@ function initByTHREE(THREE){
     }
     window.RoomLabel = RoomLabel
 
+    
+    
+    
+    /* class VideoPlayer extends THREE.EventDispatcher{
+        constructor(player) {
+            super() 
+            this.instances = new Map() 
+            this.isFlv = false 
+             
+        }
+ 
+        addVideo(src) {
+            let video = this._createVideo(src)
+            this.instances.set(src, video)
+            return video
+        }
 
+        getVideo(src) {
+            let video = this.instances.get(src)
 
-    let f = ()=>{
-        window.bus.removeEventListener('playerAndModelReady',f)
-         
-        player.on("mode.changing",(currentMode, mode, pano, duration)=>{ 
-            let noLine = mode == 'floorplan';
-            if(noLine){
-                $('.widgets-doll-labels').addClass('noLine').addClass('noCorner')
-            }else{
-                $('.widgets-doll-labels').removeClass('noLine').removeClass('noCorner')
-            } 
-        })
+            if (!video) {
+                video = this.addVideo(src)
+            }
+
+            return video
+        }
+
+        _createVideo(src) {
+            let video = document.createElement('video')
+            video.setAttribute('crossOrigin', 'anonymous')
+            video.setAttribute('playsinline', 'true')
+            video.setAttribute('x5-playsinline', 'true')
+            video.setAttribute('webkit-playsinline', 'true')
+            video.setAttribute('x5-video-player-type', 'h5')
+            video.setAttribute('controls', 'true')
+            video.setAttribute('controlslist', 'nodownload')
+            video.setAttribute('preload', 'meta') //注意,src赋值就会自动加载, preload="meta" 只加载元数据,提高加载速度,否则一开始卡 
+            
+            video.autoplay = false
+            video.muted = true
+            video.loop = true
+            video.style.position = 'fixed'
+            video.style.left = '0'
+            video.style.top = '0'
+            video.style.zIndex = '1000'
+            video.style.width = '200px'
+            video.style.display = 'none'
+            //document.body.appendChild(video) 
+            //video.style.display = browser.urlHasValue('debug') ? 'block' : 'none'
+            video.src = src
+            
+            if(this.isFlv) this.attachFlv(video)
+            
+            return video
+        }
+
+        attachFlv(video){  四维看看的会把视频转码成flv和mp4存在服务器, 但是大场景不会,所以安卓(如vivo)加载不了。flv必须用flvjs播放,且苹果有的支持不了
+            if(video.flvjsPlayer)return
+            let player = flvjs.createPlayer({ type: 'flv', url: video.src })  //需要是flv格式才行
+            player.videoElement = video
+            player.attachMediaElement(video)
+            player.on(flvjs.Events.ERROR, this._onPlayerError.bind(this))
+            player.load()
+            video.flvjsPlayer = player; 
+        }
+
+        _onPlayerError() {
+            console.warn('视频加载失败')
+        }
         
+        changeTypeToFlv(){
+            this.isFlv = true
+            for(let [key,value] of this.instances){ 
+                this.attachFlv(value) 
+            }  
+        }
         
-        player.on("view.changed",(e)=>{ 
-             if(e.cameraChanged){
-                 //if(needUpdateZIndex){ //如果某个label显示时需要更新index的话,加个参数
-                     let label_ = labels.filter(e=>e.elem[0].style.display == 'block')
-                     label_.sort((a,b)=>b.pos2d.z - a.pos2d.z)
-                     label_.forEach((e,index)=>e.elem.css('z-index', index+1000)); 
-                     
-                 //} 
-             } 
-        }) 
         
-        player.model.hotGroup.children.length ? logSth() : player.on('gotHotAndStartload',logSth)    
-    } 
-    window.bus.addEventListener('playerAndModelReady',f) //player model currentPano都已有
-     
-    window.bus.dispatchEvent({type: 'THREE_inited'})
+    } */
     
      
+ 
+
+    {
+        let f = ()=>{
+            window.bus.removeEventListener('playerAndModelReady',f)
+             
+            player.on("mode.changing",(currentMode, mode, pano, duration)=>{ 
+                let noLine = mode == 'floorplan';
+                if(noLine){
+                    $('.widgets-doll-labels').addClass('noLine').addClass('noCorner')
+                }else{
+                    $('.widgets-doll-labels').removeClass('noLine').removeClass('noCorner')
+                } 
+            })
+            
+            
+            player.on("view.changed",(e)=>{ 
+                 if(e.cameraChanged){
+                     //if(needUpdateZIndex){ //如果某个label显示时需要更新index的话,加个参数
+                         let label_ = labels.filter(e=>e.elem[0].style.display == 'block')
+                         label_.sort((a,b)=>b.pos2d.z - a.pos2d.z)
+                         label_.forEach((e,index)=>e.elem.css('z-index', index+1000)); 
+                         
+                     //} 
+                 } 
+            }) 
+            
+            player.model.hotGroup.children.length ? logSth() : player.on('gotHotAndStartload',logSth); 
+
+
+            /* {//如果是flv格式的话  
+                window.videoPlayer = new VideoPlayer() 
+                
+                if(browser.detectAndroidMobile()){//安卓常常播放不了
+                    let scriptdom = document.querySelector('#flvJs')
+                    if(scriptdom){ 
+                        scriptdom.src = 'js/lib/flv.min.js'
+                        scriptdom.onload = ()=>{ 
+                            window.videoPlayer.changeTypeToFlv()
+                            window.bus.dispatchEvent('VideoPlayerReady' ) 
+                        //Hot.startLoad()
+                        }
+                    }
+                }    
+                
+            } */
+     
+            
+        } 
+        
+        
+        window.bus.addEventListener('playerAndModelReady',f) //player model currentPano都已有 
+    }
+    window.bus.dispatchEvent({type: 'THREE_inited'})
 }
 
 
@@ -1995,6 +2097,24 @@ var CursorDeal = {
      
 }
 
+
+
+
+
+ 
+
+
+
+
+
+
+
+
+
+
+
+
+
 function logSth(){
     let hotCount = player.model.hotGroup.children.length