xzw 4 年之前
父節點
當前提交
b576e05cef
共有 7 個文件被更改,包括 1150 次插入389 次删除
  1. 30 8
      css/lzb.css
  2. 8 5
      edit.html
  3. 259 149
      js/edit.js
  4. 98 37
      js/main_2020_edit.js
  5. 459 63
      js/main_2020_show.js
  6. 5 0
      js/manage.js
  7. 291 127
      js/overlay.js

+ 30 - 8
css/lzb.css

@@ -1132,6 +1132,10 @@ ul.MenuOptions li.chosen {
     background-repeat: no-repeat;
 }
 
+#userUploadStyle .upload>div{
+    background-position: center center;
+}
+
 .toolRight .sign ul.chose li.upload span, .toolRight .upload span {
     color: #00b4ed;
     margin-top: 46%;
@@ -1223,10 +1227,11 @@ ul.MenuOptions li.chosen {
     color: #fff;
     text-align: center;
     position: relative;
-    display: inline-block;
+    display: block;
     line-height: 90px;
     font-size: 30px;
     font-weight: 300;
+    box-sizing: content-box;
 }
 
 .edit-fun-images a.result>span::after {
@@ -1251,6 +1256,18 @@ ul.MenuOptions li.chosen {
     max-height: 100%;
 }
 
+.edit-fun-images a .play-video{
+    position:absolute;
+    transform: translate(50%,50%); 
+    left: 0; top: 0;
+    opacity:0.3;
+    transition:opacity 0.2s;
+}
+.edit-fun-images a .play-video:hover{
+    opacity:1
+}
+
+
 .edit-fun-images .upload-thum {
     display: block;
     position: relative;
@@ -1564,8 +1581,8 @@ ul.MenuOptions li.chosen {
 
 
 .unable {
-    pointer-events: none!important;
-    opacity: .5
+    pointer-events: none !important;
+    opacity: .5 !important
 }
 
 
@@ -1594,8 +1611,8 @@ ul.MenuOptions li.chosen {
 .slider .scrollBar .scroll_Track {
     width: 0px;
     height: 4px;
-    background-color: #02c8ae;
-    border: 1px solid #02c8ae;
+    background-color: #00b4ed;
+    border: 1px solid #00b4ed;
     margin: -1px 0 0 0;
 }
 
@@ -1650,14 +1667,18 @@ ul.MenuOptions li.chosen {
     /* line-height: 100px; */
     position: relative;
     color: #a0a0a0;
-					
     width: 200px;
-    background-repeat:no-repeat; 
+    background-repeat:no-repeat;
     margin:15px 0 30px 0;
     text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.4);
     background-image:url("../images/img_videoview@2x.png");
     background-position:center 40%;
     background-size: 17%;
+    display: flex;
+    align-items: center;
+    text-align: center;
+    align-content: center;
+    justify-content: center;
 }
  
 .toolRight .hotpointDetail  .preview{
@@ -1677,8 +1698,9 @@ ul.MenuOptions li.chosen {
     transform:translate(-50%,-50%);
 }
 .preview .text{
-    line-height: 144px;
+    display:inline-block;
     color: #a7a7a7;
+    margin-top: 32px;
 }
 .preview.uploaded .text{
     display:none;

+ 8 - 5
edit.html

@@ -955,10 +955,10 @@
                                         <input spellcheck="false" placeholder="热点的标题" class="right" type="text"
                                             minlength="1" maxlength="50" placeholder="">
                                     </div><!-- 必填,限15字 ??-->
-                                    <div class="itemTitle" data-size="500">
+                                    <div class="itemTitle" data-size="800">
                                         <span>简介</span>
                                     </div>
-                                    <textarea placeholder="热点的简介" class="editText" maxlength="500"></textarea>
+                                    <textarea placeholder="热点的简介" class="editText" maxlength="800"></textarea>
 
 
 
@@ -1198,12 +1198,12 @@
                             <!-- <div class="unComplete">请填写项目名称</div> -->
                         </li>
                         <li data-name="description">
-                            <div class="itemTitle" data-size="200" id="project-intro2">
+                            <div class="itemTitle" data-size="1000" id="project-intro2">
                                 <span>简介内容</span>
                             </div>
 
                             <textarea placeholder="大场景的简介" id="info-summary" class="editText"
-                                maxlength="200"></textarea>
+                               maxlength="1000"  ></textarea>
 
                             <div class="itemTitle" data-size="200" id="project-intro2">
                                 <span>分享文字</span>
@@ -1612,7 +1612,10 @@
         // var token = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsInJvbGUiOm51bGwsIm1hbmFnZXIiOm51bGwsImlkIjoxLCJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjE2NTc1MjU5LCJpYXQiOjE2MTY0ODg4NTksImp0aSI6ImJjZGNhZmQxLTU2NGItNGVhMC1hYTE5LWY1ZWRjZThjZTM3ZiJ9.ODMw__rU7GfuGNZNKo14ll7HnOYEG-yNM3Rqh-XYqw4"
         var ceshi = 'http://47.112.166.173:8105/';
         var token = ''
-        /*
+       
+
+
+       /*
        //大场景: 
        var ceshi = '';
        var token = window.localStorage.dcj_token 

+ 259 - 149
js/edit.js

@@ -41,6 +41,15 @@ EditTools.prototype.init = function() {
     var that = this;
     this.initSaveAll();
     this.active();
+    
+    if(player.mode != 'panorama'){
+        $(".toolLeft li[data-name=panoVisible]").addClass('unable')
+        player.once("pano.chosen",()=>{
+            $(".toolLeft li[data-name=panoVisible]").removeClass('unable')
+        })
+    }
+    
+    
     //请求数据someData.js
     $.ajax(g_Prefix + "data/" + window.number + "/someData.json" + "?" + Date.now(), {
         dataType: "json"
@@ -100,8 +109,8 @@ EditTools.prototype.active = function() {
         }
         switch (name) {
         case "panoVisible":
-            VisiSet.enterSet(VisiSet.beginSetPanoVisible.bind(VisiSet))
             $(".toolLeft").addClass("unable")
+            VisiSet.enterSet(VisiSet.beginSetPanoVisible.bind(VisiSet))
 
             break;
         case "screen":
@@ -142,10 +151,10 @@ EditTools.prototype.initSaveAll = function() {
         $(".edit-loading").removeClass("hide");
  
 
-        var $images = $(".information .edit-fun-images a.result");
+        var $shareImages = $(".information .edit-fun-images a.result");
 
-        new Promise(function(resolve, reject) {
-            upload($images, 'images', resolve)
+        new Promise(function(resolve, reject) {//分享图
+            upload($shareImages, 'images', resolve)
         }).then(function(imgUrls) {
             
             //导览的数据
@@ -173,7 +182,7 @@ EditTools.prototype.initSaveAll = function() {
                     order: hotLength++//因为热点保存后在hots里的顺序会被修改,所以使用order来记录顺序 
                 }
                 if (hot.visiblePanos)
-                    hots[sid].visiblePanos = hot.visiblePanos
+                    hots[i].visiblePanos = hot.visiblePanos
 
                 if (hot.infoAttribute) {
                     delete hot.infoAttribute.position;
@@ -189,6 +198,7 @@ EditTools.prototype.initSaveAll = function() {
                 weixinDesc: $('#weixin-summary').val(),
                 shareImgUrl: imgUrls[0] || '',
                 backgroundMusic: $('#query-bgm').attr('href'),
+                bgName:  $(".music .audio.mediaUpload .title").text(),
                 hoticon: JSON.parse($(".hotStyle-item li.active").attr("data-val")),
                 camera_start: $('#camera-start')[0].data,
                 loadlogo: $("#loadlogo").is(':checked'),
@@ -588,7 +598,16 @@ Hotpoint.prototype.init = function(n) {
     });
     //点击热点列表弹出按钮
     this.spotList.on("click", function(e) {
-        var target = $(e.target);
+        var target = $(e.target); 
+        let li = searchParent(e.target, { className: 'listItem' }, 7);
+        if(!li)return;
+        var hotId = $(li).attr("data-spid");
+        var hot = player.model.hots[hotId] 
+        
+        if(VisiSet.setTagVisible){
+            return VisiSet.SetOneTagVisible(hot)
+        }
+        
         if (target.hasClass("del")) {
             e.stopPropagation();
             target.siblings(".DelConfirm").addClass("active");
@@ -596,12 +615,11 @@ Hotpoint.prototype.init = function(n) {
         } else {
             if (target.hasClass("DelConfirm")) {
                 e.stopPropagation();
-                that.removeHot(target, n);
+                that.removeHot(hot, $(li));
             } else {
-                //点击热点列表弹出编辑热点窗口
-                if (target.hasClass("title") || target.hasClass("icon")) {
-                    that.editHot(target)
-                }
+                //点击热点列表弹出编辑热点窗口 
+                that.editHot(hot, $(li))
+                 
             }
         }
     });
@@ -645,20 +663,19 @@ Hotpoint.prototype.init = function(n) {
 /**
  * 显示编辑热点的窗口和初始化热点窗口的数据
  */
-Hotpoint.prototype.editHot = function(target) {
+Hotpoint.prototype.editHot = function(hot, $li) {
     this.hotpointDetail.removeClass("atRight");
 
     $("#hotpointDetail .audio.mediaUpload").find("input").val('');
     // 点击编辑导览清空上一次文件
     var playIcon = 'images/play.png';
     var $layout = $("#hotpointDetail")[0];
-    $layout.targetDOM = target.closest("li")[0];
+    //$layout.targetDOM = target.closest("li")[0];
     //closest匹配选择器的第一个祖先元素
     //编辑时将热点列表唯一标识带入,以便后期保存使用识别
-    var li_id = $($layout.targetDOM).attr("data-spid");
-    this.editSpot = player.model.hots[li_id];
-
-    this.hotpointDetail.attr("data-id", li_id);
+    //var li_id = $li.attr("data-spid");
+    this.editSpot = hot 
+    this.hotpointDetail.attr("data-id", hot.sid);
     var info = this.editSpot.infoAttribute || {}
     //$layout.targetDOM.infoAttribute || {}
     transformControls.transCtlChangeMode("translate")
@@ -674,17 +691,17 @@ Hotpoint.prototype.editHot = function(target) {
     info.noAction = this.editSpot.noAction
 
     try {
-        transformControls.attach(player.model.hots[li_id].mesh)
-        player.model.hots[li_id].examine(player, {
+        transformControls.attach(hot.mesh)
+        hot.examine(player, {
             dontOpen: true
         })
         //add
 
-        info.position = player.model.hots[li_id].position.clone()
-        info.quaternion = player.model.hots[li_id].quaternion.clone()
+        info.position = hot.position.clone()
+        info.quaternion = hot.quaternion.clone()
     } catch (e) {}
 
-    initStyle(player.model.hots[li_id])
+    initStyle(hot)
 
     $("#isSprite")[0].checked = this.editSpot.isSprite
     $("#noAction")[0].checked = this.editSpot.noAction
@@ -702,13 +719,17 @@ Hotpoint.prototype.editHot = function(target) {
     .bind(this))
 
     var imagesHTML = info.images.map(function(image) {
-        return '<div><a class=" result success"><span></span><img src="' + image + '"></a></div>'
+        return '<div><a class=" result success" data-type="photo"><span></span><img src="' + image + '" class="bg"></a></div>'
     })
 
     var videosHTML = info.video.map(function(ly) {
-        var imgDom = (!ly.img || ly.img === "undefined") ? '' : 'success';
-        var imgUrl = (!ly.img || ly.img === "undefined") ? playIcon : ly.img;
-        return '<div><a class=" result success"><span></span><img class="play-video" videoURL="' + ly.url + '" src="' + imgUrl + '"></a  ><span class="upload-thum ' + imgDom + ' result" attr-thum="' + ly.img + '">上传封面<i><input type="file"></i></span></div>'
+        //var imgDom = (!ly.img || ly.img === "undefined") ? '' : 'success';
+        //var imgUrl = (!ly.img || ly.img === "undefined") ? playIcon : ly.img;
+        //return '<div><a class=" result success" data-type="video"><span></span><img class="play-video" videoURL="' + ly.url + '" src="' + imgUrl + '"></a  ><span class="upload-thum ' + imgDom + ' result" attr-thum="' + ly.img + '">上传封面<i><input type="file"></i></span></div>'
+        var thumb = (!ly.img || ly.img === "undefined") ? '' : '<img src='+ ly.img +' class="bg"></img>'
+        var thumbResult = (!ly.img || ly.img === "undefined") ? '' : 'success';
+        var dom = '<div><a class=" result success" data-type="video"><span></span>' + thumb + ' <img class="play-video" videoURL="' + ly.url + '" src="' + playIcon + '"></a>  <span class="upload-thum ' + thumbResult + ' result" attr-thum="' + ly.img + '">上传封面<i><input type="file" accept="image/*"></i></span></div>'
+        return dom
     })
 
     this.hotpointDetail.find(".name > input").val(info.title);
@@ -757,6 +778,7 @@ Hotpoint.prototype.addmedia = function() {
 
         var img = new Image()
         img.src = URL.createObjectURL(file);
+        img.className = 'bg'
         return img
     }
 
@@ -767,13 +789,13 @@ Hotpoint.prototype.addmedia = function() {
             return false;
         }
 
-        $elayout.append('<span class="upload-thum">上传封面<i><input type="file"></i></span>')
+        $elayout.append('<span class="upload-thum">上传封面<i><input type="file" accept="image/*"></i></span>')
 
         return '<img src="./images/play.png" class="play-video" videoURL="' + URL.createObjectURL(file) + '">'
     }
 
     // 视频封面回调
-    function thumSuccess(file, $elayout, $seft) {
+    function thumbSuccess(file, $elayout, $seft) {
         if (!/image\/\w+/.test(file.type)) {
             alert("文件必须为图片!");
             return false;
@@ -781,33 +803,58 @@ Hotpoint.prototype.addmedia = function() {
         if (!restrictedSize(file, 2)) {
             return false;
         }
-
-        $seft.closest('div').find('img').attr('src', URL.createObjectURL(file));
+        
+        var img = $seft.closest('div').find('img.bg');
+        if(!img[0]){
+            img = $("<img class='bg'></img>");
+            $seft.closest('div').find('a').append(img)
+        }
+        img.attr('src', URL.createObjectURL(file));
+        $seft.closest('span').removeClass("success")
+         
+        
     }
 
+
+     
+
     // 图片与视频加载
     function fileHandle() {
-        var $seft = $(this)
-        var $layout = $seft.closest("li");
-        var type = $seft.parent().attr('data-type');
+        var $seft = $(this) //input
+         
         var file = this.files[0];
+        var type = this.activeElem ? this.activeElem.attr('data-type') : $seft.parent().attr('data-type');
         var $din = $(document.createElement('div'));
-        var fnc = type === 'photo' ? imageSuccess : type === 'video' ? videoSuccess : thumSuccess
-        var $dom = fnc(file, $din, $seft)
+        var fnc = type === 'photo' ? imageSuccess : type === 'video' ? videoSuccess : thumbSuccess  
+        var $dom = fnc(file, $din, $seft)// 封面图thumbSuccess的话在此处理
 
         if (type === 'photo' || type === 'video') {
             if (!$dom)
                 return $seft.val('');
-            var $addLayout = $(document.createElement('a'));
-            var $addInput = $('<input type="file">')
-            var $close = $(document.createElement('span'));
-            $addInput[0].files = this.files;
-            $addLayout.append($addInput)
-            $addLayout.append($close);
-            $addLayout.append($dom);
-            $addLayout.addClass("result");
-            $din.prepend($addLayout);
-            $layout.find('.edit-fun-images').append($din);
+            
+            if(!this.activeElem){//创建新的item
+                var $layout = $seft.closest("li"); 
+                var $addLayout = $(document.createElement('a'));
+                $addLayout.attr("data-type", type)
+                var $close = $(document.createElement('span'));
+                $addLayout[0].file = file;
+                
+                $addLayout.append($close);
+                $addLayout.append($dom);
+                $addLayout.addClass("result");
+                $din.prepend($addLayout);
+                $layout.find('.edit-fun-images').append($din);
+            }else{//重传
+                if (type === 'photo'){
+                    this.activeElem.find("img.bg").remove();
+                }else{
+                    this.activeElem.find(".play-video").remove();
+                }
+                this.activeElem.removeClass("success")  
+                this.activeElem.append($dom)
+                this.activeElem[0].file = file;
+                this.value = ''
+            }  
         }
 
         if (searchParent($seft[0], {
@@ -820,37 +867,77 @@ Hotpoint.prototype.addmedia = function() {
         })){
             $("#SpotStyle").addClass("hide")
         }
-
+        
+        
     }
-    ;// 图片与视频加载
+    
+    
+    
+    
+    //用于重传的input
+    var imgInput = $("<input accept='image/*'  type='file'></input>")
+    var videoInput = $("<input accept='video/*' type='file'></input>")
+    
+    
+    
+    // 图片与视频加载
     $('.upload, .edit-fun-images').on('change', function(ev) {
         if (ev.target.tagName.toUpperCase() === 'INPUT') {
             ev.target.files.length && fileHandle.call(ev.target)
-        }
-
+        } 
     })
-    $('.edit-fun-images').on('click', function(ev) {
-        var $tag = $(ev.target)
+    imgInput.on('change', (ev)=>{fileHandle.call(ev.target)})
+    videoInput.on('change', (ev)=>{fileHandle.call(ev.target)})
+    
+    
+    
+    
+    $('.edit-fun-images').on('click', function(ev) {//点击item时
+        var $tag = $(ev.target) 
         var tagName = ev.target.tagName.toUpperCase()
-        if (tagName === 'SPAN') {
-            var $resf = $(ev.target)
-            if (searchParent($resf[0], {
+       
+        if (tagName === 'SPAN') { 
+            if (searchParent($tag[0], {
                 className: 'forShareImg'
             })) {
                 //信息页面的分享图片
                 $("#shareImgUpload").removeClass('hide')
-            }else if(searchParent($resf[0], {
+            }else if(searchParent($tag[0], {
                     className: 'SpotStyle'
                 })){
                 $("#SpotStyle").removeClass('hide')
             }
-            $resf.parent().parent().remove()
-        } else if (tagName === 'IMG' && $tag.hasClass('play-video')) {
+            $tag.parent().parent().remove()
+        }else if (tagName === 'IMG' && $tag.hasClass('play-video')) {
             $videoLayout.css('display', 'flex').find('video').attr('src', $tag.attr('videoURL'))[0].play()
+        }else{// 替换
+            var a = searchParent($tag[0], {
+                tagName: 'a'
+            })
+            if(a) {
+                var input  
+                if(searchParent($tag[0], {
+                    className: 'video'
+                })){
+                    input = videoInput 
+                }else{
+                    input = imgInput
+                    
+                }
+                input[0].activeElem = $(a)
+                input.click()
+            }  
         }
     })
 }
 
+
+
+
+
+
+
+
 //========================xzw=======================更改热点样式图
 
 var currStyle;
@@ -971,15 +1058,11 @@ Hotpoint.prototype.updateNumDisplay = function() {
 }
 
 //删除热点
-Hotpoint.prototype.removeHot = function(that, thisScene) {
-    var hotId = that.closest("li").attr("data-spid");
-
-    player.model.hots[hotId].dispose();
-    delete player.model.hots[hotId]
-
-    that.closest("li").remove();
-    this.updateNumDisplay()
-    console.log("删除成功:" + hotId);
+Hotpoint.prototype.removeHot = function(hot, $li  ) { 
+    hot.dispose();
+    delete player.model.hots[hot.sid] 
+    $li.remove();
+    this.updateNumDisplay() 
 }
 //添加热点模型
 Hotpoint.prototype.addHot = function(that, Hot, fn) {
@@ -1076,12 +1159,14 @@ Hotpoint.prototype.addwebPack = function() {
         $(this).closest(".webPage").find(".list > div:last").remove();
     });
 }
+
+
 // 保存热点信息
 Hotpoint.prototype.initSaveHot = function() {
     var $layout = $(".edit-loading");
     var hotpointDetail = this.hotpointDetail;
     var spotList = this.spotList;
-
+    var that = this
     hotpointDetail.find(".tail .submit").on('click', function() {
 
         //获取唯一标识
@@ -1111,46 +1196,49 @@ Hotpoint.prototype.initSaveHot = function() {
         let $bgName = hotpointDetail.find('.title');
 
         new Promise(function(resolve, reject) {
-            //获取热点图片所有的路径
+            //获取图片路径
             upload($images, 'images', resolve)
         }
         ).then(function(imgUrls) {
             args.images = imgUrls
-            //获取热点视频所有的路径
+            //获取视频路径
             return new Promise(function(resolve, reject) {
                 upload($videos, 'videos', resolve)
-            }
-            )
+            })
         }).then(function(videoUrls) {
             args.video = videoUrls
-            //获取热点视频图片所有的路径
+            //获取视频封面路径
             return new Promise(function(resolve, reject) {
                 upload($thums, 'images', resolve)
-            }
-            )
+            })
         }).then(function(thums) {
-            args.video = args.video.map(function(video, index) {
+            args.video = args.video.map(function(video, index) {//整合视频+封面
                 return {
                     url: video,
                     img: thums[index]
                 }
             })
         }).then(function() {
-            //获取热点音乐所有的路径
+            //获取音乐路径
             //console.log($miusc)
             if ($miusc[0].files.length > 0) {
                 return new Promise(function(resolve) {
                     upload($miusc, 'miusc', function(res) {
                         resolve(res[0])
                     })
-                }
-                )
+                })
             } else {
                 return $miusc.attr('data-hotBgm')
             }
-        }).then(function(src) {
-            args.backgroundMusic = src
-            args.bgName = $bgName[0].innerHTML;
+        }).then(function(src) { 
+            if(that.musicBox.hasMusic && !src){
+                args.backgroundMusic = hot.infoAttribute.backgroundMusic
+                args.bgName = hot.infoAttribute.bgName
+            }else{
+                args.backgroundMusic = src
+                args.bgName = $bgName[0].innerHTML;
+            }
+            
         }).then(function() {
             //上传style图片
             var a = $.Deferred();
@@ -1158,19 +1246,6 @@ Hotpoint.prototype.initSaveHot = function() {
             if (currStyle == "user" && currentHotStyleImg.length) {
                 currentHotStyleImg.forEach((img)=>{
                     if (img.needSave)
-                        /* uploadImg(img.base64Src, function(rs){
-                            if(rs.code == 0){
-                                img.needSave = false;
-                                img.saveURL = rs.data;
-                                if(++doneNum >= currentHotStyleImg.length){
-                                    a.resolve();
-                                } 
-                            }else{
-                               alert("样式图上传失败");
-                               a.reject(); 
-                            }
-                        })  */
-
                         uploadFile(img.file, 'hot/image', function(rs) {
                             if (rs.code === 0) {
                                 img.needSave = false;
@@ -1200,14 +1275,12 @@ Hotpoint.prototype.initSaveHot = function() {
             if (currStyle == "user") {
                 currentHotStyleImg.forEach((img)=>{
                     args.styleImg.push(img.saveURL || img.src)
-                }
-                )
+                })
                 hot.styleTex = currentHotStyleImg.slice(0)
             } else {
                 hot.styleTex = [];
             }
-            hot.changeTex();
-            //更新材质     
+            hot.changeTex();//更新材质     
         }
         ).then(function() {
             //获取热点标题、内容、内嵌网页、模型网页。
@@ -1313,7 +1386,7 @@ var EditMiuse = function() {
 EditMiuse.prototype.init = function(data) {
     if (!data.backgroundMusic)
         return;
-    this.musicBox.show(this.mediaUpload, "backgound", data.backgroundMusic);
+    this.musicBox.show(this.mediaUpload, data.bgName || "backgound", data.backgroundMusic);
     
 }
 
@@ -1566,12 +1639,14 @@ EditGuide.prototype.init = function(data, data2) {
 
 function musicPlayBoxBind($dom, addCallback, delCallback){
     var musicBox = {
+        hasMusic:false,
         show: function(mediaDom, name, url){ 
             mediaDom = mediaDom || $dom
             mediaDom.find(".innerBtn").text("替换");
             mediaDom.find(".playBox").removeClass("hide");
             mediaDom.find(".title").text(name);
             mediaDom.find('#query-bgm').attr('href', url); 
+            musicBox.hasMusic = true
         },
         addMusic : function(e) {
             if(!e.target.files.length) return;
@@ -1597,7 +1672,7 @@ function musicPlayBoxBind($dom, addCallback, delCallback){
             mediaDom.find(".playBox").addClass("hide");
             mediaDom.find(".innerBtn").text("上传");
             mediaDom.find("input").val("")//.removeAttr("data-hotbgm");
-
+            musicBox.hasMusic = false
             delCallback && delCallback()  
             
             
@@ -1745,6 +1820,18 @@ EditGuide.prototype.editItem = function(li) {
     $('#tourItemEdit').removeClass('atRight');
     $('#tourItemEdit .tourName input').val( $(li).find('.guide-name').text() );
     
+    var metadata = JSON.parse(li.tourData.metadata);
+    if(metadata.scan_id != 'outside'){
+        var pano = player.model.panos.index[metadata.scan_id]
+        if(pano){ 
+            var q = new THREE.Quaternion().copy(metadata.camera_quaternion);
+            var lookAtPoint = new THREE.Vector3(0,0,-1).applyQuaternion(q).add(pano.position);
+            player.flyToPano({
+                pano: pano,
+                lookAtPoint: lookAtPoint
+            })
+        }
+    }
     
     if(!this.editingFolderLi){//在外的item, 可以上传音乐
         $('#tourItemEdit .mediaUpload').removeClass('hide')
@@ -2142,22 +2229,21 @@ function _css(el, prop, val) {
     }
 }
 
-function upload($files, type, cb) {
+function upload($files, type, cb) {//保存系列文件
     var length = $files.length
     var rcount = 0
     var result = []
 
     Array.from($files).forEach(function(dFile, index) {
-        //a 标签的success 是用来判断是否是已经上传过的文件
-        //attr-thum 属性是视频的图片
-        //videoURL 是判断是否有视频
+       
+       
         var $file = $(dFile)
-        var $image = $file.find('img')
+        var $image = type == 'videos' ? $file.find('img.play-video') : $file.find('img')
 
-        if ($file.hasClass('success')) {
-            if ($file.attr('attr-thum')) {
+        if ($file.hasClass('success')) {//已经上传过,有链接
+            if ($file.attr('attr-thum')) {//视频的封面
                 result[index] = $file.attr('attr-thum')
-            } else if ($image.attr('videoURL')) {
+            } else if ($image.attr('videoURL')) {//视频
                 result[index] = $image.attr('videoURL')
             } else {
                 result[index] = $image.attr('src')
@@ -2168,11 +2254,12 @@ function upload($files, type, cb) {
             case "input":
                 dFile = $file[0]
                 break;
-            case "span":
+            case "span"://封面
                 dFile = $file.find('input')[0];
                 break;
-            case "a":
-                dFile = $file.find('input')[0];
+            case "a"://重传的图or视频
+                dFile = {files:[$file[0].file]}
+                //dFile = $file.find('input')[0];
                 break;
             default:
                 dFile = $file.closest("li").find('.upload input')[0];
@@ -2583,7 +2670,12 @@ var SlideBar = function(o) {
             return;
         scope.setValueFromOutside(v);
     });
-
+    window.addEventListener("resize",()=>{
+        if(this.line[0].clientWidth){
+            this.getOffset() 
+            this.moveKnot();
+        }
+    })
 }
 
 SlideBar.prototype.dealInterval = function() {
@@ -2956,13 +3048,22 @@ var EditOverlay = {
             }
         )
         
-
+ 
+        
         player.overlayGroup.children.forEach((overlay)=>{
-            if(overlay.plane.material.map.image)this.getOverlayInfo(overlay)
-            else   overlay._loadDone = ()=>{this.getOverlayInfo(overlay)}    
+            if(!overlay.plane.material.map || !overlay.plane.material.map.image){
+                overlay._loadDones = [()=>{this.getOverlayInfo(overlay)}] 
+            }
+            else {
+                this.getOverlayInfo(overlay)
+            }
+              
             this.addToList(overlay)
         }
         )
+        
+        
+        
     },
     enter: function() {
         this.editing = true;
@@ -2999,10 +3100,12 @@ var EditOverlay = {
     },
 
     addPlane: function(o) {
+        if(!o.intersect)return;
         var pos = o.intersect.point;
         var overlay = new Overlay({
             sid: new Date().getTime() + ""
         })
+        overlay.hasRequestLoad = true
         overlay.position.copy(pos);
         if (player.getMouseDirection().angleTo(o.intersect.face.normal) < Math.PI / 2) {
             overlay.lookAt(o.intersect.face.normal.clone().negate().add(pos));
@@ -3046,8 +3149,19 @@ var EditOverlay = {
     },
     updateOverlayPanel: function(overlay) {
         this.editPlane = overlay;
+        overlay.requestDownload()
+        
+        if(overlay._loadDones){
+            $('.waiting').addClass('showloading');
+            overlay._loadDones.push(()=>{
+                $('.waiting').removeClass('showloading');
+            })
+        }
+        
+        
+        
         var plane = overlay.plane
-        var src = plane.material.map && plane.material.map.image.src;
+        var src = plane.material.map && (plane.material.map.image ? plane.material.map.image.src : overlay.fileSrc );
         $('#overlayUpload .preview video').remove();
         
         overlay.overlayType && this.switchEditType(overlay.overlayType)
@@ -3091,7 +3205,7 @@ var EditOverlay = {
         , 201)
         
         
-        this.updatePano(player.currentPano)
+        player.currentPano && this.updatePano(player.currentPano)
     },
     
     //----------------------------
@@ -3206,7 +3320,7 @@ var EditOverlay = {
         
         this.updateScale()
         
-        //this.updateOverlayPanel(this.editPlane)
+        this.updateOverlayPanel(this.editPlane)
     },
      
     getOverlayInfo: function(overlay) {
@@ -3321,7 +3435,7 @@ var EditOverlay = {
         var overlay = this.editPlane;
 
         if (!overlay.isNew) {
-            if (confirm("确定删除该视频?")) {
+            if (confirm(overlay.overlayType== "photo" ? "确定删除该图片?" :  "确定删除该视频?")) {
                 overlay.needDelete = true;
                 $("#overlayProp a.close").click()
                 //this.closeOverlayPanel() 
@@ -3400,9 +3514,9 @@ var VisiSet = {
 
     },
     beginSetPanoVisible: function() {
-        if (this.setPanoVisible)
-            return;
         $(".toolLeft").removeClass("unable")
+        if (this.setPanoVisible)
+            return; 
         this.setPanoVisible = true;
         this.panoVTemp = {};
 
@@ -3413,8 +3527,18 @@ var VisiSet = {
 
         //objects.tagManager.hideAllTags();
 
+        this.setDisplay(true)
+
+
         this.updateFootIconSize()
         //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话 
+        
+        
+        for(let i in player.model.hots){
+            player.model.hots[i].visi_ = player.model.hots[i].mesh.visible;
+            player.model.hots[i].mesh.visible = false
+        }        
+        
     },
 
     SetOnePanoVisible: function(pano) {
@@ -3545,10 +3669,17 @@ var VisiSet = {
         player.flyoutType = null
         this.$confirmSnap.addClass("hide")
         permitTranMode(true)
+        this.setDisplay(false)
+        
+        for(let i in player.model.hots){ 
+            player.model.hots[i].mesh.visible = player.model.hots[i].visi_
+        }        
+        
     },
 
     recoverAllState2: function() {
         //为了热点可视恢复成pano全部可见
+        if(!this.footIcons)return;
         for (var i = 0; i < this.footIcons.length; i++) {
             this.footIcons[i].material.uniforms.opacity.value = 1;
             this.footIcons[i].material.uniforms.map.value = footTex1;
@@ -3722,34 +3853,13 @@ var VisiSet = {
     setDisplay: function(state) {
         var panos = player.model.panos;
         if (state) {
-            player.model.panos.forEach((pano)=>{
-                if (pano.hasVideo) {
-                    pano.marker.visible = false;
-                    pano.flagSpot.disc.visible = false;
-                    pano.flagSpot.markGroup.hide();
-                }
-            }
-            )
-            player.model.cadFloorPlane.changeCadVisible(false)
+             
         } else {
-            player.model.panos.forEach((pano)=>{
-                if (pano.hasVideo) {
-                    pano.marker.visible = true;
-                    pano.flagSpot.disc.visible = true;
-                    pano.flagSpot.markGroup.show();
-                }
-            }
-            )
-            player.model.cadFloorPlane.changeCadVisible(null, {
-                autoJudge: true
-            })
+            
         }
-
-        player.defaultRoomLabels.forEach(function(label) {
-            label.update()
-        })
+ 
         player.path.currentPanoMarker.mesh.visible = !state;
-        objects.overlayManager.group.visible = !state;
+        player.overlayGroup.visible = !state;
         player.reticule.visible = !state;
 
     },
@@ -4013,7 +4123,7 @@ var VisiSet = {
             player.model.hots[i].isSprite = true;
             player.model.hots[i].mesh.material.depthTest = false;
         }
-
+        this.setDisplay(true)
         this.updateFootIconSize()
         //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话 
     },
@@ -4082,7 +4192,7 @@ var VisiSet = {
         this.pauseSetTagVisible();
         this.setTagVisible = false;
 
-        //this.setDisplay(false)
+        this.setDisplay(false)
         this.$confirmSnap.addClass("hide")
         permitTranMode(true)
         /* for (var r in objects.tagManager.tags) {
@@ -4244,7 +4354,7 @@ function searchParent(searchArea, o, maxTimes) {
             return dom
         else if (o.className && dom.classList && dom.classList.contains(o.className))
             return dom
-        else if (o.tagName && o.tagName == dom.tagName)
+        else if (o.tagName && dom.tagName && o.tagName.toUpperCase() == dom.tagName.toUpperCase())
             return dom
     }
     var find;

+ 98 - 37
js/main_2020_edit.js

@@ -1,3 +1,6 @@
+window.common = null;
+window.MathLight = null;
+window.math = null
 
 
 g_playAudio = null
@@ -23,7 +26,19 @@ g_tourAudio.oncanplaythrough = function() {
 
 
 
-
+var sortByScore = function(list, request, rank) {
+    var i = common.filterAll(list, request);
+    return 0 === i.length ? null : i = i.map(function(e) {
+        return {
+            item: e,
+            score: rank.reduce(function(t, i) {
+                return t + i(e);
+            }, 0)
+        };
+    }).sort(function(e, t) {
+        return t.score - e.score;
+    });
+};
 
 
 
@@ -4602,13 +4617,25 @@ function o(a, s, l) {
             ,
             t.prototype.goToDestination = function(e, t, i, n) { 
                 //音频
-                if(this.destinationItem[1] == 0){//如果是每个folder的起始
-                    var musicInfo = this.model.heroLocations[this.destinationItem[0]].musicInfo
-                    if(musicInfo && musicInfo.music){
-                        var o = musicInfo.music.includes(g_Prefix.slice(-10)) ? musicInfo.music :  g_Prefix + musicInfo.music;
+                var musicInfo = this.model.heroLocations[this.destinationItem[0]].musicInfo
+                if(musicInfo && musicInfo.music){
+                    var o = musicInfo.music.includes(g_Prefix.slice(-10)) ? musicInfo.music :  g_Prefix + musicInfo.music;
+                    
+                    let audioSrc1 = g_tourAudio.src.split('/').pop();
+                    let audioSrc2 = o.split('/').pop();
+               
+                    if(audioSrc1 == audioSrc2){//应该是继续播放该folder 
+                        if(this.destinationItem[1] == 0){//从头开始播放 因为可能暂停后然后再点该缩略图播
+                            g_tourAudio.currentTime = 0;  g_tourAudio.play();
+                        }else if(g_tourAudio.paused && g_tourAudio.currentTime < g_tourAudio.duration){//未播完
+                            g_tourAudio.play()
+                        } 
+                        
+                    }else{//很可能是该folder的起始
                         g_tourAudio.src = manage.dealURL(o);
                         g_tourAudio.load()  
                     }
+                    
                 }
                 
                 
@@ -13998,7 +14025,7 @@ function o(a, s, l) {
                     
                     if (window.MP_PREFETCHED_MODELDATA.backgroundMusic) {
                         if(window.isLocal) g_bgAudio.src = manage.dealURL(window.MP_PREFETCHED_MODELDATA.backgroundMusic) ;
-                        else g_bgAudio.src = window.MP_PREFETCHED_MODELDATA.backgroundMusic.substr(0,4)=="http" ? window.MP_PREFETCHED_MODELDATA.backgroundMusic : "//" + window.MP_PREFETCHED_MODELDATA.backgroundMusic;
+                        else g_bgAudio.src = window.MP_PREFETCHED_MODELDATA.backgroundMusic 
                         
                         $("#volume").show();
                     }else if (g_version === "one"){
@@ -17100,22 +17127,15 @@ function o(a, s, l) {
             }
             ,
             t.prototype.loadOverlays = function(overlays){
-                var overlays = window.data2 && window.data2.overlays /* ||
-                 [
-                    { depth: 0.02,
-                    file: "https://super.4dage.com/data/TEST/overlay/b6fe7cb6bd2b6.mp4",
-                    hasBox: 0,
-                    height: 0.8165,
-                    media: ["video"],
-                    pos:  [-4.3132, 0.6788, -13.5162],
-                    qua:  [0, 0.9396, 0, 0.3421],
-                    sid: "1591079418827",
-                    width: 0.6124
-                }]  */
+                var overlays = window.data2 && window.data2.overlays  
+                  
                 
                 overlays && overlays.forEach((info)=>{ 
                     new Overlay(info)  
                 })
+                
+                
+                Overlay.load()
             }
             
             ,
@@ -18107,7 +18127,7 @@ function o(a, s, l) {
                 this.model = e,
                 this.id = t,
                 this.alignmentType = i.alignmentType || c.ALIGNED,
-                this.neighbourUUIDs = i.neighbours || null,
+                this.neighbourUUIDs = i.neighbours,
                 this.neighbourPanos = null,
                 this.floor = null,
                 this.floorIndex = i.floor,
@@ -18240,6 +18260,7 @@ function o(a, s, l) {
                 this.floorPosition = this.floorPosition || this.raycastFloorPosition(),
                 this.neighbourPanos = this.neighbourPanos || this.findNeighourPanos(),
                 a.colorMarkerByFloor && this.marker && this.marker.material.color.set(this.floor.debugColor)
+                this.neighbourUUIDs = this.neighbourUUIDs || [] //add
             }
             ,
             r.prototype.build2 = function() {
@@ -19600,14 +19621,20 @@ function o(a, s, l) {
                 .bind(this);
                 this.startWarpState(),
                 V.start(n, o, c, 0, B.easeInOutQuad, "wait");
-                /* var r = player.model.heroLocations[app.director.currentItem];
-                this.player.zoomEnabled = !0;
-                var h = function(e, t) {
-                    //console.log(e),
-                    this.player.zoomTo(e * r.zoom.toFixed(2), !0)
-                }
-                .bind(this);
-                V.start(h, 2e3, null, 0, B.easeOutQuad, "zoom") */
+                
+                
+                //zoom动画  方奕卓  相机缩放 
+                var currentGuide = player.model.getHeroDescriptorByIndex(player.director.currentItem)  
+                if(currentGuide.zoom && currentGuide.zoom != this.player.zoomLevel){
+                    this.player.zoomEnabled = true;
+                    var startZoom = this.player.zoomLevel
+                    var zoom = function(e, d) { 
+                        var zoomLevel = currentGuide.zoom.toFixed(2) * e + startZoom * (1-e);
+                        this.player.zoomTo( zoomLevel, true)        
+
+                    }.bind(this)
+                    V.start(zoom, 2000, null, 0, B.easeOutQuad, "zoom")
+                } 
             }
             ,
             t.prototype.warpToNonPano = function(e) {
@@ -20380,7 +20407,7 @@ function o(a, s, l) {
                 this.preRenderingEnabled = !1,
                 this.setupCustomProperties(e),
                 this.zoomStats = new v,
-                this.modeTran = ''
+                this.modeTran = 'dollhouse-panorama'
                 this.currentCursor = '';
                 
                
@@ -21558,15 +21585,17 @@ function o(a, s, l) {
                 
             },
             
-            t.prototype.getMouseIntersect = function(e, t) {
-                e = e || this.mouse.clone(),
-                t = t || this.model.floors.reduce(function(e, t) {
+            t.prototype.getMouseIntersect = function(e, t1) {
+                e = e || this.mouse.clone() 
+                var t = t1 || this.model.floors.reduce(function(e, t) {
                         return t.hidden ? e : e.concat(t.collider.children)
                     }, this.mode === V.PANORAMA ? this.panoMarkers : []),
                 t = t.slice(0)
+                
                 for (var i in this.model.hots) t.push(this.model.hots[i].mesh);
                     
                 this.overlayGroup && (t = t.concat(this.overlayGroup.children));   
+                 
                     
                 i = new B.Vector3(e.x,e.y,-1).unproject(this.camera);
                 this.raycaster.set(i, this.getMouseDirection(e));
@@ -21717,6 +21746,8 @@ function o(a, s, l) {
             }
             ,
             t.prototype.updateHotVisible = function(pano){  
+                if (window.VisiSet && (VisiSet.setPanoVisible ))return
+            
                 var hots = this.model.hots;
                 pano = pano || this.currentPano; 
                 
@@ -21822,7 +21853,7 @@ function o(a, s, l) {
                     
                     this.updateHotVisible(n); //更新热点显示
                     this.transitionPos({type:"beforeFlytopano", pano:n, dur:p})//add 
-                    
+                    Overlay.updateVisibles([this.currentPano, n])
                     
                     
                     
@@ -21855,6 +21886,7 @@ function o(a, s, l) {
                         
                         if(this.mode == "panorama" && EditOverlay.editing){
                             EditOverlay.updatePano(this.currentPano)
+                            Overlay.updateVisibles([this.currentPano])
                         }
                         
                     }
@@ -22325,7 +22357,11 @@ function o(a, s, l) {
                         EditOverlay.updatePano(this.currentPano)
                     }
                     //this.mode == u.PANORAMA && this.transitionPos({type:"flyDone", this.currentPano})//add   
-                    
+                    if(this.mode == V.PANORAMA){ 
+                        Overlay.updateVisibles([this.currentPano])
+                    }else{
+                        Overlay.updateVisibles(true)
+                    }
                     
                     c && u !== V.PANORAMA && i === V.PANORAMA ? this.startWarp(M.Retain, S.Retain, R.BLACK, null, null, a) : (a && a(),
                     t.resolve())
@@ -22501,10 +22537,10 @@ function o(a, s, l) {
                 
                 if(restChildCount){//如果当前folder中还有剩下的item,平分一下时间
                     var timeEachItem = 2000;//假设每个item飞的时间
-                    var waitTime = Math.max(0, (waitTime-timeEachItem*restChildCount) / (restChildCount+1));
+                    var waitTime = (waitTime-timeEachItem*restChildCount) / (restChildCount+1);
                      
                 } 
-                
+                waitTime = Math.max(0, waitTime)
                 console.log("waitTime "+waitTime +" at item "+this.director.currentItem + ",musicCurrentTime:"+current) 
                  
                 this.path.waitNextStep(e, function() {//等待音乐播放一段时间再下一步,此时镜头会缓慢旋转
@@ -23306,7 +23342,7 @@ function o(a, s, l) {
                         e.visible = !1
                     })),
                     i.cursor.visible = e,
-                    i.setSize(window.innerWidth, window.innerHeight),
+                    i.setSize($("#player").width(), $("#player").height()),
                     window._vrEnabled = e,
                     setTimeout(function() {
                         console.log(player.cameraControls.activeControl.camera.fov)
@@ -28865,6 +28901,7 @@ function o(a, s, l) {
             getHFOVFromVFOV: r,
             getVFOVFromHFOV: o
         }
+        window.MathLight = t.exports
     }
     , {
         "./MathLight": 176
@@ -28989,11 +29026,33 @@ function o(a, s, l) {
             extend: function(e, t) {
                 for (var i in t.prototype)
                     e.prototype[i] = t.prototype[i]
-            }
+            },
+            
+            getVisiblePano : function(position, options={}){//add
+                var visiblePanos = []; 
+                var B = position.clone(); 
+                var panos = options.panos ||  player.model.panos.list;
+                 
+                panos.forEach((pano)=>{
+                    if(!pano.isAligned())return;
+                    var A = pano.position.clone();
+                      
+                    var ray = new THREE.Raycaster(A.clone(), B.clone().sub(A).normalize(), 0, A.distanceTo(B) - (options.tolerance||0) ) 
+                    var o = ray.intersectObjects(options.model || player.model.colliders, true);
+                     
+                     
+                    if (!o || !o.length)visiblePanos.push(pano );
+                     
+                    
+                })  	  
+             
+                return visiblePanos
+            } 
         },
         Math.sign = function(e) {
             return e < 0 ? -1 : 1
         }
+        window.common = t.exports
     }
     , {
         three: 217
@@ -29431,6 +29490,8 @@ function o(a, s, l) {
                 };
             },
         }
+        
+        window.math = t.exports
     }
     , {
         "../constants": 8,

File diff suppressed because it is too large
+ 459 - 63
js/main_2020_show.js


+ 5 - 0
js/manage.js

@@ -332,6 +332,11 @@ Manage.prototype.dealURL = function(src, type){
         console.error("没有找到合适的本地链接")
         return src
     }else{
+        //add https://
+        var prefix = g_Prefix.replace('https://','').replace('http://','') 
+        if(!src.includes('http:/') && !src.includes('https:/') && src.includes(prefix)){
+            src = 'https://'+src
+        }
         return src
     }
     

+ 291 - 127
js/overlay.js

@@ -1,175 +1,202 @@
+
+
+ 
  
-var initOverlay = function(THREE){
-    var _planeGeometry = new THREE.PlaneGeometry(settings.overlay.width, settings.overlay.height,1,1)
-    var _boxGeometry = new THREE.BoxBufferGeometry(settings.overlay.width, settings.overlay.height, settings.overlay.depth )
-        //ie的mesh 加了polygonOffset也是会重叠。所以去掉前面的face:  (但是突然ie又播放不了videoTexture)
-        var newIndex = [..._boxGeometry.index.array]
-        newIndex.splice(4*6,6)
-        _boxGeometry.setIndex(new THREE.BufferAttribute(new Uint16Array(newIndex), 1))
-     
-
-    var _boxMat = new THREE.MeshBasicMaterial({//MeshStandardMaterial
-            color:"#eeeeee", 
-            transparent: !0 ,
-            opacity:0.8
-        })
-    
-    var overlayGroup = new THREE.Object3D;    player.model.add(overlayGroup);  overlayGroup.name = "overlayGroup"
-    player.overlayGroup = overlayGroup;
 
+var initOverlay = function(THREE) {
+    var _planeGeometry = new THREE.PlaneGeometry(settings.overlay.width,settings.overlay.height,1,1)
+    var _boxGeometry = new THREE.BoxBufferGeometry(settings.overlay.width,settings.overlay.height,settings.overlay.depth)
+    //ie的mesh 加了polygonOffset也是会重叠。所以去掉前面的face:  (但是突然ie又播放不了videoTexture)
+    var newIndex = [..._boxGeometry.index.array]
+    newIndex.splice(4 * 6, 6)
+    _boxGeometry.setIndex(new THREE.BufferAttribute(new Uint16Array(newIndex),1))
 
-    var Overlay = function(info){ 
-        THREE.Object3D.call(this); 
+    var _boxMat = new THREE.MeshBasicMaterial({
+        //MeshStandardMaterial
+        color: "#eeeeee",
+        transparent: !0,
+        opacity: 0.8
+    })
+
+    var overlayGroup = new THREE.Object3D;
+    player.model.add(overlayGroup);
+    overlayGroup.name = "overlayGroup"
+    player.overlayGroup = overlayGroup;
+
+    var Overlay = function(info) {
+        THREE.Object3D.call(this);
         this.sid = info.sid;
-        if(info.media)this.preDeal(info) 
+        if (info.media)
+            this.preDeal(info)
         this.build(info);
-        this.name = "overlay_"+this.sid;
+        this.name = "overlay_" + this.sid;
     }
     Overlay.prototype = Object.create(THREE.Object3D.prototype);
-    
-    Overlay.prototype.build = function(info){
-        
-        var plane = new THREE.Mesh(_planeGeometry, new THREE.MeshBasicMaterial({//MeshStandardMaterial
-            color:"#00c8af",
-            opacity:0.4,
+
+    Overlay.prototype.build = function(info) {
+
+        var plane = new THREE.Mesh(_planeGeometry,new THREE.MeshBasicMaterial({
+            //MeshStandardMaterial
+            color: "#00c8af",
+            opacity: 0.4,
             transparent: !0,
-            polygonOffset : true,//是否开启多边形偏移		//ie不开启时blank也不会闪烁
-            polygonOffsetFactor : -0.9,//多边形偏移因子
-            polygonOffsetUnits : -4.0,//多边形偏移单位  
-        }) )								
+            polygonOffset: true,
+            //是否开启多边形偏移		//ie不开启时blank也不会闪烁
+            polygonOffsetFactor: -0.9,
+            //多边形偏移因子
+            polygonOffsetUnits: -4.0,
+            //多边形偏移单位  
+        }))
         plane.renderOrder = 3
         this.add(plane);
         this.plane = plane;
-        if(info.hasBox){
-            this.addBox(true)  
-        }   
+        if (info.hasBox) {
+            this.addBox(true)
+        }
         overlayGroup.add(this);
-        
-        if(info.media){ 
-            if(info.media.includes('video')){
+
+        if (info.media) {
+            if (info.media.includes('video')) {
                 var video = $('<video controls="controls" loop autoplay x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload"></video>')[0]
-                video.setAttribute("crossOrigin", 'Anonymous')//要在src设置好前解决跨域
-                $(video).on('contextmenu', function () { return false; });//禁止右键点击出
-                 
-                video.src = manage.dealURL(info.file)  ;
+                video.setAttribute("crossOrigin", 'Anonymous')
+                //要在src设置好前解决跨域
+                $(video).on('contextmenu', function() {
+                    return false;
+                });
+                //禁止右键点击出
+
+                video.src = manage.dealURL(info.file);
                 info.media = video;
                 info.type = "video"
-                
+
                 video.addEventListener('loadeddata', ()=>{
                     console.log(this.sid + " loaded!!!")
-                })
+                }
+                )
                 video.volume = 0
                 video.muted = true
-            }else if(info.media.includes('photo')){
+                plane.material.opacity = 1;
+            } else if (info.media.includes('photo')) {
                 /* var img = new Image();
                  
                 img.src = manage.dealURL(info.file) //"https://4dkk.4dage.com/images/images"+Config.projectNum+"/overlay"+this.sid+".jpg?m="+new Date().getTime()
                 info.media = img
                  */
-                
-                info.type = "photo"  
-                
+
+                info.type = "photo"
+                plane.material.opacity = 0.1;
             }
-            plane.material.opacity = 1;
-            plane.material.color = new THREE.Color(1,1,1) 
+
+            plane.material.color = new THREE.Color(1,1,1)
         }
-        if(info.width == void 0) info.width = settings.overlay.width;
-        if(info.height == void 0) info.height = settings.overlay.height;
-        this.setFromInfo(info) 
-        
-        
+        if (info.width == void 0)
+            info.width = settings.overlay.width;
+        if (info.height == void 0)
+            info.height = settings.overlay.height;
+        this.setFromInfo(info)
+        this.fileSrc = info.file
+
     }
 
-     
-      
-    Overlay.prototype.setFromInfo = function(info){//1 恢复到编辑之前 2 初始加载 
-        var plane = this.plane; 
-        this.transformAtPanos = info.transformAtPanos || {} //在每个漫游点独立设置的position。  
-        var curPanoTransform = player.currentPano && this.transformAtPanos[player.currentPano.id] || {} 
-        
-        info.depth && this.scale.setZ(info.depth/settings.overlay.depth)
-        
-         
-        this.posCustom = info.pos ? info.pos.clone() : this.position.clone(); //没有单独设置position的漫游点使用的position
-        this.position.copy(curPanoTransform.pos || this.posCustom )
-        
+    Overlay.prototype.setFromInfo = function(info) {
+        //1 恢复到编辑之前 2 初始加载 
+        var plane = this.plane;
+        this.transformAtPanos = info.transformAtPanos || {}
+        //在每个漫游点独立设置的position。  
+        var curPanoTransform = player.currentPano && this.transformAtPanos[player.currentPano.id] || {}
+
+        info.depth && this.scale.setZ(info.depth / settings.overlay.depth)
+
+        this.posCustom = info.pos ? info.pos.clone() : this.position.clone();
+        //没有单独设置position的漫游点使用的position
+        this.position.copy(curPanoTransform.pos || this.posCustom)
+
         this.quaCustom = info.qua ? info.qua.clone() : this.quaternion.clone()
         this.quaternion.copy(curPanoTransform.qua || this.quaCustom);
-        
-        
-        this.widthCustom = info.width  
-        this.heightCustom = info.height  
+
+        this.widthCustom = info.width
+        this.heightCustom = info.height
         this.width = curPanoTransform.width || this.widthCustom
         this.height = curPanoTransform.height || this.heightCustom
         var a = this.getScaleBySize(this.width, this.height)
-        this.scale.setX( a.x )
-        this.scale.setY( a.y )
-        
-        
-        
-        
-        if(info.type){
-            if(!plane.material.map){
-                if(info.type == "video"){ 
-                    plane.material.map = new THREE.VideoTexture( info.media );  
-                }else{  
-                    plane.material.map = Texture.load(info.file,()=>{
-                        if(this._loadDone)this._loadDone()
-                    }) 
-                } 
-                plane.material.map.wrapS = plane.material.map.wrapT = THREE.ClampToEdgeWrapping;
+        this.scale.setX(a.x)
+        this.scale.setY(a.y)
+
+        if (info.type) {
+            if (!plane.material.map) {
+                if (info.type == "video") {
+                    plane.material.map = new THREE.VideoTexture(info.media);
+                    this.hasRequestLoad = true
+
+                    plane.material.map.wrapS = plane.material.map.wrapT = THREE.ClampToEdgeWrapping;
+                    plane.material.map.minFilter = THREE.LinearFilter;
+                    plane.material.map.magFilter = THREE.LinearFilter;
+                    plane.material.map.generateMipmaps = true;
+
+                } else {
+                    this._loadDones = []
+                    /* plane.material.map = Texture.load(info.file,()=>{
+                        if(this._loadDones){
+                            this._loadDones.forEach(e=>e())
+                            this._loadDones = null
+                        }
+                    })  */
+                }
+                /* plane.material.map.wrapS = plane.material.map.wrapT = THREE.ClampToEdgeWrapping;
                 plane.material.map.minFilter = THREE.LinearFilter;
                 plane.material.map.magFilter = THREE.LinearFilter;
-                plane.material.map.generateMipmaps = true; 
-            }else plane.material.map.image = info.media; 
+                plane.material.map.generateMipmaps = true;  */
+            } else
+                plane.material.map.image = info.media;
             this.file = info.file;
         }
         this.overlayType = info.type;
-         
-        if(!!this.hasBox != !!info.hasBox){
-            this.addBox(!this.hasBox); 
+
+        if (!!this.hasBox != !!info.hasBox) {
+            this.addBox(!this.hasBox);
         }
-        
-        
-        
-    } 
 
-    Overlay.prototype.addBox = function(state){
-        if(state == !!this.hasBox){ 
+        this.updateMatrixWorld()
+        this.getVisiblePanos()
+
+    }
+
+    Overlay.prototype.addBox = function(state) {
+        if (state == !!this.hasBox) {
             return;
-        } 
-        if(state){
-            var box = new THREE.Mesh(_boxGeometry , _boxMat) 
-            box.position.set(0,0,settings.overlay.depth/2);
-            box.renderOrder = 3 
-            this.plane.position.set(0,0,settings.overlay.depth ); 
+        }
+        if (state) {
+            var box = new THREE.Mesh(_boxGeometry,_boxMat)
+            box.position.set(0, 0, settings.overlay.depth / 2);
+            box.renderOrder = 3
+            this.plane.position.set(0, 0, settings.overlay.depth);
             this.add(box);
-            this.box = box;   
-            
-        }else{
-            this.plane.position.set(0,0,0);
+            this.box = box;
+
+        } else {
+            this.plane.position.set(0, 0, 0);
             this.remove(this.box);
             this.box = null;
-        }  
+        }
         this.hasBox = state
     }
-    
-    Overlay.prototype.getSizeByScale = function(){ 
+
+    Overlay.prototype.getSizeByScale = function() {
         return {
-            width : settings.overlay.width * this.scale.x,
-            height : settings.overlay.height * this.scale.y
+            width: settings.overlay.width * this.scale.x,
+            height: settings.overlay.height * this.scale.y
         }
     }
-    Overlay.prototype.getScaleBySize = function(width, height){ 
+    Overlay.prototype.getScaleBySize = function(width, height) {
         return {
-            x : width / settings.overlay.width,
-            y : height / settings.overlay.height,
-        }  
-    } 
-    
-    Overlay.prototype.preDeal = function(info){
+            x: width / settings.overlay.width,
+            y: height / settings.overlay.height,
+        }
+    }
+
+    Overlay.prototype.preDeal = function(info) {
         info.pos = new THREE.Vector3().fromArray(info.pos)
-        info.qua = new THREE.Quaternion().fromArray(info.qua) 
+        info.qua = new THREE.Quaternion().fromArray(info.qua)
         info.width = parseFloat(info.width)
         info.height = parseFloat(info.height)
         info.depth = parseFloat(info.depth)
@@ -181,17 +208,154 @@ var initOverlay = function(THREE){
         info.qua.y = parseFloat(info.qua.y)
         info.qua.z = parseFloat(info.qua.z)
         info.qua.w = parseFloat(info.qua.w)
-        
-        if(!info.transformAtPanos)info.transformAtPanos = {}
-               
-        for(let i in info.transformAtPanos){
+
+        if (!info.transformAtPanos)
+            info.transformAtPanos = {}
+
+        for (let i in info.transformAtPanos) {
             info.transformAtPanos[i].pos = new THREE.Vector3().fromArray(info.transformAtPanos[i].pos)
             info.transformAtPanos[i].qua = new THREE.Quaternion().fromArray(info.transformAtPanos[i].qua)
-                
+
+        }
+
+    }
+
+    Overlay.prototype.getVisiblePanos = function() {
+        this.visiblePanos = common.getVisiblePano(this.plane.getWorldPosition(), {
+            model: null
+        });
+
+    }
+    
+    
+    Overlay.prototype.updateVisibles = function(panos) {
+        this.visible = !!panos.find(pano=>this.visiblePanos.includes(pano))
+        if (!this.visible && this.overlayType == 'video')
+            this.plane.material.map.image.pause()
+    }
+    
+    
+    Overlay.updateVisibles = function(panos) {
+        if (panos === true) {
+            player.overlayGroup.children.forEach(e=>e.visible = true)
+        } else {
+            player.overlayGroup.children.forEach(e=>e.updateVisibles(panos))
         }
+    }
+    
+    /* Overlay.prototype.inSight = function(){
+        var maxAngle = THREE.Math.degToRad( cameraLight.getHFOVFromVFOV(70, player.domElement.clientWidth, app.player.domElement.clientHeight) / 2);
+        //角度为可见范围 
+        var v1 = cameraDir.clone().setY(0);
+        var v2 = overlays[i].plane.getWorldPosition().sub(player.position).setY(0)
+        if(v1.angleTo(v2) <= maxAngle){
+            Overlay.loadQueue.push(overlays[i])
+            if(Overlay.loadQueue.length>=10) break;
+        } 
         
+    } */
+    
+    
+
+    Overlay.prototype.addToLoadQueue = function() {
+        if (this.overlayType == 'photo') {
+            Overlay.loadQueue.includes(this) || Overlay.loadQueue.push(this)
+
+        }
     }
     
     
+    Overlay.prototype.requestDownload = function() {
+        if (this.hasRequestLoad || this.overlayType != 'photo')
+            return
+
+        console.log('overlay beginDownload : ' + this.sid)
+        var plane = this.plane;
+
+        plane.material.map = Texture.load(this.file, ()=>{
+            plane.material.needsUpdate = true
+            if (this._loadDones) {
+                this._loadDones.forEach(e=>e())
+                this._loadDones = null
+            }
+            setTimeout(Overlay.loadNext, 50)
+            plane.material.opacity = 1;
+            console.log('overlay loaded: ' + this.sid)
+        })
+        plane.material.map.wrapS = plane.material.map.wrapT = THREE.ClampToEdgeWrapping;
+        plane.material.map.minFilter = THREE.LinearFilter;
+        plane.material.map.magFilter = THREE.LinearFilter;
+        plane.material.map.generateMipmaps = true;
+
+        this.hasRequestLoad = true
+    }
+
+    Overlay.loadQueue = []; //等待下载的overlay,目前只针对photo
+    Overlay.maxLoadingCount = 3; //同时正在load图片的数量
+    Overlay.loadNext = ()=>{//继续requestDownload  loadQueue中前排的item
+
+        var loadings = player.overlayGroup.children.filter(e=>e.hasRequestLoad && e._loadDones)//开始下载了但是没加载好的
+        
+        Overlay.loadQueue.slice(0, Overlay.maxLoadingCount - loadings.length).forEach(e=>e.requestDownload())
+        Overlay.loadQueue.splice(0, Overlay.maxLoadingCount - loadings.length)
+    }
+    
+    
+    
+
+    Overlay.getNeedLoad = function() {//计算获取loadQueue,每次都重新计算,覆盖旧的
+        if (!player || !player.domElement || !player.mode)
+            return;
+
+        if (player.mode != 'panorama') {
+            if (!Overlay.loadWhenOutside)
+                return; 
+
+            if (Overlay.loadQueue.length == 0) {
+                Overlay.loadQueue = player.overlayGroup.children.filter(e=>!e.hasRequestLoad).slice(0, 5);
+            }
+
+            return;
+        }
+        Overlay.loadWhenOutside = true
+        var overlays = player.overlayGroup.children.filter(e=>!e.hasRequestLoad && e.visiblePanos.includes(player.currentPano))
+        var cameraDir = player.getDirection()
+
+         
+        Overlay.loadQueue = overlays
+        
+
+        var request = [(overlay)=>{
+            return true
+        }
+        ];
+        var rank = [(overlay)=>{
+            var dis = overlay.plane.getWorldPosition().distanceTo(player.position);
+            return -dis
+        }
+        , (overlay)=>{
+            var tagDir = overlay.plane.getWorldPosition().sub(player.position)
+            var angle = tagDir.angleTo(cameraDir)
+            return -angle * 20
+        }
+        ]
+        var result = sortByScore(Overlay.loadQueue, request, rank);
+        Overlay.loadQueue = result ? result.slice(0, 5).map(e=>e.item) : player.overlayGroup.children.filter(e=>!e.hasRequestLoad).slice(0, 2);
+
+    }
+
+    Overlay.load = ()=>{//开始下载图片
+        Overlay.getNeedLoad() 
+        Overlay.loadNext()
+        var unloads = player.overlayGroup.children.filter(e=>!e.hasRequestLoad)
+        if (unloads.length) {
+            setTimeout(Overlay.load, 200)
+        } else {
+            Overlay.allRequestLoad = true
+            console.log('allRequestLoad')
+        }
+    }
+
     window.Overlay = Overlay;
-} 
+
+}