xzw 4 роки тому
батько
коміт
b82e8fc10c
5 змінених файлів з 317 додано та 299 видалено
  1. 8 3
      css/lzb.css
  2. 2 2
      edit.html
  3. 139 134
      js/edit.js
  4. 77 29
      js/main_2020_edit.js
  5. 91 131
      js/main_2020_show.js

+ 8 - 3
css/lzb.css

@@ -285,7 +285,7 @@ ul.MenuOptions li.chosen {
     height: 100%;
 }
 
-#tourItemList>ul{
+.tourList>ul{
     height: 100%;
     overflow-y: scroll;
     /* overflow-x: hidden; */
@@ -469,6 +469,7 @@ ul.MenuOptions li.chosen {
 
 #tourItemList {
     padding-top: 1.4vw !important;
+    height: calc(100% - 368px); /*  减去在它上面的部分 */
 }
 
  
@@ -848,8 +849,12 @@ ul.MenuOptions li.chosen {
     display: block;
 }
 
-.toolRight .playBox[data-type='music']>div:first-child {
-    background-image: url("../images/soundPlay.png");
+.toolRight .playBox[data-type='music']>div:first-child { 
+    /* background-image: url("../images/soundPlay.png"); */
+    background-image: url("../images/Volume btn_on.png");
+    background-size: 50%;
+    background-repeat:no-repeat;
+    background-position:center;
 }
 
 .toolRight .playBox[data-type='music']>div:first-child.playing {

+ 2 - 2
edit.html

@@ -1238,7 +1238,7 @@
                                 <li style="background-image: url(images/edit/hotStyle_2.png);"
                                     data-val='{"default":"images/point2.png","higt":"images/point2_light.png"}'>
                                 </li>  
-                                <li class="addSpot customizeHotStyle" >
+                                <!-- <li class="addSpot customizeHotStyle" >
                                     <div class="list edit-fun-images clearfix"></div>
                                     <div class="upload" id="SpotStyle">
                                         <div data-type='photo'> 
@@ -1249,7 +1249,7 @@
                                         </div>
                                         <a class="del"></a>
                                     </div>
-                                </li> 
+                                </li>  -->
                             </ul>
                         </li>
                         <li data-name="floorMarkerColor">

+ 139 - 134
js/edit.js

@@ -45,70 +45,7 @@ EditTools.prototype.init = function() {
     $.ajax(g_Prefix + "data/" + window.number + "/someData.json" + "?" + Date.now(), {
         dataType: "json"
     }).done(function(data) {
-        
-        
-                data.model.images = [
-                    {
-                        "metadata": "{\"camera_position\":{\"x\":0.8559,\"y\":-0.1097,\"z\":0.6656},\"camera_quaternion\":{\"x\":-0.1975,\"y\":-0.0952,\"z\":-0.0193,\"w\":0.9755},\"scan_id\":\"11\",\"zoom\":1}",
-                        "name": "1",
-                        "thumbnail_signed_src": "https://super.4dage.com/data/LYW/edit/20201210_175837426.",
-                        "sid": "20201210_175837426"
-                    },
-                    {
-                        "metadata": "{\"camera_position\":{\"x\":1.1559,\"y\":-0.1083,\"z\":1.9191},\"camera_quaternion\":{\"x\":-0.0396,\"y\":0.1251,\"z\":0.005,\"w\":0.9913},\"scan_id\":\"12\",\"zoom\":1}",
-                        "name": "2",
-                        "thumbnail_signed_src": "https://super.4dage.com/data/LYW/edit/20201210_175835333.",
-                        "sid": "20201210_175835333"
-                    },
-                    {
-                        "name": "区域1 hasmusic",
-                        "momentTour": "black",
-                        "musicInfo": {
-                            "name": "一段音乐.mp3",
-                            "music": "///super.4dage.com/data/LYW/edit/20210425_152844547.mp3",
-                            "time": 7818
-                        },
-                        "locations": [
-                            {
-                                "metadata": "{\"camera_position\":{\"x\":-2.4032,\"y\":-0.1215,\"z\":-0.882},\"camera_quaternion\":{\"x\":-0.0898,\"y\":0.9081,\"z\":0.2552,\"w\":0.3196},\"scan_id\":\"5\",\"zoom\":1}",
-                                "sid": "20210425_152818526",
-                                "name": "20210425_152818526",
-                                "thumbnail_signed_src": "https://super.4dage.com/data/LYW/edit/20210425_152818526."
-                            }
-                        ]
-                    },
-                    {
-                        "name": "区域2",
-                        "momentTour": "black",
-                        "locations": [
-                            {
-                                "metadata": "{\"camera_position\":{\"x\":-1.2063,\"y\":-0.1163,\"z\":0.4791},\"camera_quaternion\":{\"x\":0.0326,\"y\":0.9667,\"z\":0.1605,\"w\":-0.1966},\"scan_id\":\"2\",\"zoom\":1}",
-                                "sid": "20210425_152857293",
-                                "name": "20210425_152857293",
-                                "thumbnail_signed_src": "https://super.4dage.com/data/LYW/edit/20210425_152857293."
-                            },
-                            {
-                                "metadata": "{\"camera_position\":{\"x\":-0.2906,\"y\":-0.1122,\"z\":-0.2226},\"camera_quaternion\":{\"x\":-0.258,\"y\":-0.3481,\"z\":-0.1003,\"w\":0.8956},\"scan_id\":\"1\",\"zoom\":1}",
-                                "sid": "20210425_152900502",
-                                "name": "20210425_152900502",
-                                "thumbnail_signed_src": "https://super.4dage.com/data/LYW/edit/20210425_152900502."
-                            }
-                        ]
-                    },
-                    {
-                        "metadata": "{\"camera_position\":{\"x\":-1.2063,\"y\":-0.1163,\"z\":0.4791},\"camera_quaternion\":{\"x\":-0.0023,\"y\":-0.8326,\"z\":-0.0034,\"w\":0.5539},\"scan_id\":\"2\",\"zoom\":1}",
-                        "sid": "20210425_152929593",
-                        "name": "5",
-                        "thumbnail_signed_src": "https://super.4dage.com/data/LYW/edit/20210425_152929593."
-                    }
-                ]
-                
-                
-                
-        
-        
-        
-        
+         
         
         //创建导览
         that.editMiuse.init(data);
@@ -297,13 +234,16 @@ EditTools.prototype.initSaveAll = function() {
      
         
     
-        console.log("保存数据");
+        /* console.log("保存数据");
         console.log({  
             guides: reData(guides, '[]'),
             info: info, 
         })
         console.log(JSON.stringify(guides) )    
- return;           
+             
+             debugger; */
+             
+             
             
             let url = cmp ? ('/api/scene/edit/' + cmp) : '/manage/scene/edit'
             $.ajax({
@@ -629,7 +569,7 @@ Hotpoint.prototype.init = function(n) {
     this.active();
     this.addmedia();
     // 添加多媒体
-    this.addMusic();
+    this.addMusicInit();
     // 添加音乐
     this.addModel();
     // 添加模型
@@ -779,14 +719,16 @@ Hotpoint.prototype.editHot = function(target) {
     this.hotpointDetail.find(".webPage .list").html(iframesHTML);
     let bgName = info.bgName || '热点背景音乐';
     if (info.backgroundMusic) {
-        this.hotpointDetail.find(".audio .playBox").removeClass("hide");
+        /* this.hotpointDetail.find(".audio .playBox").removeClass("hide");
         this.hotpointDetail.find("#upload-hotBgm").attr('data-hotBgm', info.backgroundMusic)
         this.hotpointDetail.find(".audio .playBox a").attr("href", info.backgroundMusic);
         this.hotpointDetail.find('#hotBgName')[0].innerHTML = bgName;
-        this.hotpointDetail.find(".audio .submit").text("替换");
+        this.hotpointDetail.find(".audio .submit").text("替换"); */
+        this.musicBox.show(this.hotpointDetail.find(".audio.mediaUpload"), bgName, info.backgroundMusic)
     } else {
-        this.hotpointDetail.find(".audio .playBox").addClass("hide");
-        this.hotpointDetail.find("#upload-hotBgm").removeAttr('data-hotBgm')
+        this.musicBox.hide()
+        /* this.hotpointDetail.find(".audio .playBox").addClass("hide");
+        this.hotpointDetail.find("#upload-hotBgm").removeAttr('data-hotBgm') */
         // 没有背景音乐,则移除该属性, 避免其他热点的干扰
     }
 
@@ -1088,8 +1030,8 @@ Hotpoint.prototype.addHotList = function(hot) {
 }
 
 //添加热点音乐
-Hotpoint.prototype.addMusic = function() {
-    var mediaUpload = $("#hotpointDetail .audio.mediaUpload");
+Hotpoint.prototype.addMusicInit = function() {
+    /* var mediaUpload = $("#hotpointDetail .audio.mediaUpload");
     mediaUpload.find("input").on("change", function() {
         var file = this.files[0];
         mediaUpload.find(".innerBtn").text("替换");
@@ -1103,7 +1045,8 @@ Hotpoint.prototype.addMusic = function() {
         mediaUpload.find(".playBox").addClass("hide");
         mediaUpload.find(".innerBtn").text("上传");
         mediaUpload.find("input").val("").removeAttr("data-hotbgm");
-    })
+    }) */
+    this.musicBox = musicPlayBoxBind($("#hotpointDetail .audio.mediaUpload"), null )
 }
 //添加热点模型列表dom
 Hotpoint.prototype.inputList = function(text, val) {
@@ -1327,7 +1270,18 @@ Hotpoint.prototype.initSaveHot = function() {
 //背景音乐
 var EditMiuse = function() {
     this.mediaUpload = $(".music .audio.mediaUpload");
-    this.success = function(text, url) {
+    
+    this.musicBox = musicPlayBoxBind(this.mediaUpload, (file)=>{
+        uploadMiuse(file, (rs, file)=>{
+            if (rs.code === 0) { 
+                this.musicBox.show(this.mediaUpload, file.name, rs.data) 
+            }else{
+                this.musicBox.hide()
+            }
+        })
+    }, null)
+     
+    /* this.success = function(text, url) {
         this.mediaUpload.find(".innerBtn").text("替换");
         this.mediaUpload.find(".playBox").removeClass("hide");
         this.mediaUpload.find(".title").text(text);
@@ -1354,12 +1308,13 @@ var EditMiuse = function() {
     //删除音乐
     this.mediaUpload.on("click", ".delete", function() {
         that.delete();
-    })
+    }) */
 }
 EditMiuse.prototype.init = function(data) {
     if (!data.backgroundMusic)
         return;
-    this.success("backgound", data.backgroundMusic);
+    this.musicBox.show(this.mediaUpload, "backgound", data.backgroundMusic);
+    
 }
 
 
@@ -1421,23 +1376,24 @@ EditGuide.prototype.init = function(data, data2) {
     
     
     var that = this;
-
-     
-    
+ 
     
     //点击添加导览
     $('.addTour .innerBtn').eq(0).on("click", function () {
         this.addFolderDom({name:"区域"+($("#tourList .listItem").length+1)  } );//点击增加一段导览
+        $("#tourList ul")[0].scrollTop  = $("#tourList ul")[0].scrollHeight  //scroll to bottom
     }.bind(this));
 
    
     $('.addTour .innerBtn').eq(1).on("click", function () { 
         this.snapATourView()//点击截取视图
+        $("#tourList ul")[0].scrollTop  = $("#tourList ul")[0].scrollHeight
     }.bind(this));
      
     
     $('.snapATourView .innerBtn').on("click", function() { 
-        this.snapATourView(null,true);//点击截取视图
+        this.snapATourView(null,true);//folder内点击截取视图 
+        $("#tourItemList ul")[0].scrollTop  = $("#tourItemList ul")[0].scrollHeight
     }.bind(this));
      
     $('#renewTourBtn').on("click", function() { // 重新截取视图 
@@ -1455,11 +1411,11 @@ EditGuide.prototype.init = function(data, data2) {
     }.bind(this));
     
      //点击导览编辑窗口右上角的关闭按钮
-    $("#tourItemEdit a.close, button.cancel").on("click", function() {
+    /* $("#tourItemEdit a.close, button.cancel").on("click", function() {
         that.targetTourPoint[0].musicSta = true;  ///??????????
         // 取消操作, 重置状态
         that.tourDetail.addClass("atRight");
-    });
+    }); */
     
  
 
@@ -1494,10 +1450,11 @@ EditGuide.prototype.init = function(data, data2) {
         if(!itemDom)return;//可能点到了folder
         if(searchParent(e.target, { className: 'preview' })){
             var choice = confirm("你确定删除吗?"); 
-            if (choice) {
+            if (choice) { 
+                var ul = searchParent(e.target, { className: 'tourList' })
+                
                 target.closest('li').remove();
                 
-                var ul = searchParent(e.target, { className: '.tourList' })
                 reIndexTourList(ul)
             } else {
                 return false
@@ -1571,6 +1528,12 @@ EditGuide.prototype.init = function(data, data2) {
     
     
     //音乐
+    
+    this.musicBox = musicPlayBoxBind($(".snapTour .audio.mediaUpload"), null, ()=>{
+        (that.editingFolderLi || that.editingItemLi).tourData.musicInfo = {}//直接删除 不可逆
+    })
+    
+    /* 
     var mediaUpload = $(".snapTour .audio.mediaUpload");
     var that = this;
     mediaUpload.find("input").on("change", function(e) {
@@ -1596,15 +1559,62 @@ EditGuide.prototype.init = function(data, data2) {
         //that.editingFolderLi.musicSta = false;
         (that.editingFolderLi || that.editingItemLi).data.musicInfo = {}//直接删除 不可逆
         
-    })
-    
-    
-    
-    
+    }) */
+     
+}
+
+
+function musicPlayBoxBind($dom, addCallback, delCallback){
+    var musicBox = {
+        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); 
+        },
+        addMusic : function(e) {
+            if(!e.target.files.length) return;
+            var file = e.target.files[0];
+            
+            if (!/audio\/\w+/.test(file.type)) {
+                alert("文件必须为音乐!");
+                return false;
+            }
+            //限制大小不大于8m
+            if (!restrictedSize(file, _musicMaxWeight)) {
+                return false
+            } 
+            var mediaDom = $(searchParent(e.target, { className: 'mediaUpload' })); 
+            musicBox.show(mediaDom, file.name, URL.createObjectURL(file))
+            
+            addCallback && addCallback(file)
+        },
+        hide : function(e) {
+            var mediaDom = e ? $(searchParent(e.target, { className: 'mediaUpload' })) : $dom
+            
+            mediaDom.find('#query-bgm').attr('href', "");
+            mediaDom.find(".playBox").addClass("hide");
+            mediaDom.find(".innerBtn").text("上传");
+            mediaDom.find("input").val("")//.removeAttr("data-hotbgm");
+
+            delCallback && delCallback()  
+            
+            
+        }
+        
+    }
     
+    $dom.find("input").on("change", musicBox.addMusic)
     
+    /* $dom.find("input").on("click", function() {
+        mediaUpload
+    });  */
+    //删除音乐 
+    $dom.on("click", ".delete", musicBox.hide)
     
     
+    return musicBox;
 }
 
 
@@ -1619,11 +1629,11 @@ function reIndexTourList(ul) {
 
 
 
-EditGuide.prototype.addFolderDom = function( data){
-    var $folder = $("<li class='listItem' draggable='true'>" + "<div class=icon></div>" +    "<div class=title  >" + (data.name || "") + "</div>" + "<div class=DelConfirm>确定删除</div>" + "<div class=del></div>" + "</li>");
+EditGuide.prototype.addFolderDom = function( tourData){
+    var $folder = $("<li class='listItem' draggable='true'>" + "<div class=icon></div>" +    "<div class=title  >" + (tourData.name || "") + "</div>" + "<div class=DelConfirm>确定删除</div>" + "<div class=del></div>" + "</li>");
     
     $folder[0].tourItemDoms = []    //记录所有item的li dom
-    $folder[0].data = data  //注:  data中的locations不会更新,保存时直接读取li
+    $folder[0].tourData = tourData  //注:  data中的locations不会更新,保存时直接读取li
     $("#tourList ul").append($folder);
     
     return $folder 
@@ -1648,20 +1658,21 @@ EditGuide.prototype.createDom = function(data, data2) {
         if(Info.locations){//是folder
             var $folder = this.addFolderDom(Info)
             // 音频链接 
+            Info.locations = Info.locations.filter(e=>e)
             Info.locations.forEach(function(info, index) {
                 if (info.thumbnail_signed_src) {
                     var $li = $(that.getItemDom( info.name, info.thumbnail_signed_src));
-                    $li[0].data = info 
-                    $folder[0].tourItemDoms.push($li)
+                    $li[0].tourData = info 
+                    $folder[0].tourItemDoms.push($li[0])
                     
                 }
             })
         }else{//是散落在外的item
             if (Info.thumbnail_signed_src) {
                 var $li = $(that.getItemDom(Info.name, Info.thumbnail_signed_src));
-                $li[0].data = Info
+                $li[0].tourData = Info
                 // 音频链接
-                $li[0].data.musicInfo = $li[0].data.musicInfo || tourAudio[Info.sid] || {}//新的music数据统一写在每个info下
+                $li[0].tourData.musicInfo = $li[0].tourData.musicInfo || tourAudio[Info.sid] || {}//新的music数据统一写在每个info下
                  
                 $("#tourList ul").append($li)
                 
@@ -1684,35 +1695,37 @@ EditGuide.prototype.createDom = function(data, data2) {
 //暂时不实时更新左侧场景,所以信息全写在UI上,不保存data
  
 
-EditGuide.prototype.editFolder = function(folderDom){
-    //var data = folderDom.data;
+EditGuide.prototype.editFolder = function(folderDom){ 
     
     this.editingFolderLi = folderDom;
     
     $("#tourFolderEdit").removeClass('atRight');
     $("#tourFolderEdit .tourName input").val( $(folderDom).find('.title').text()||'');
-    $("#folderTourSwitch input").prop('checked', folderDom.data.momentTour === 'black');
+    $("#folderTourSwitch input").prop('checked', folderDom.tourData.momentTour === 'black');
     
     folderDom.tourItemDoms.forEach(li=>{
         $("#tourItemList>ul").append(li)
     })
-    
+    reIndexTourList($("#tourItemList>ul")[0])
     //判断当前点是否有导览音频 
     
     //target[0].musicSta = true;
 
 
     //var audio = this.tourAudio[target.closest('li')[0].data.sid];
-    var musicInfo = this.editingFolderLi.data.musicInfo   //audio ? audio.music : null;
-    if (musicInfo) {  // 判断改导览点是否已经已有音乐
+    var musicInfo = this.editingFolderLi.tourData.musicInfo   //audio ? audio.music : null;
+    if (musicInfo && musicInfo.music) {  // 判断改导览点是否已经已有音乐
         var musicName = musicInfo.name || '导览音频.mp3'  // 获取音频的文件名
-        $('#tourFolderEdit').find(".audio .playBox").removeClass("hide"); 
+        /* $('#tourFolderEdit').find(".audio .playBox").removeClass("hide"); 
         $('#tourFolderEdit').find(".audio .playBox a").attr("href", "//" + musicInfo.music);
         $('#tourFolderEdit').find(".audio .submit").text("替换");
-        $('#tourFolderEdit').find(".title").text(musicName);
+        $('#tourFolderEdit').find(".title").text(musicName); */
+        
+        this.musicBox.show($('#tourFolderEdit .mediaUpload'), musicName, "//" + musicInfo.music)
     } else {
-        $('#tourFolderEdit').find(".audio .playBox").addClass("hide");
-        $('#tourFolderEdit').find(".audio .submit").text("上传");
+        /* $('#tourFolderEdit').find(".audio .playBox").addClass("hide");
+        $('#tourFolderEdit').find(".audio .submit").text("上传"); */
+        this.musicBox.hide()
     }
      
 }
@@ -1735,16 +1748,18 @@ EditGuide.prototype.editItem = function(li) {
     
     if(!this.editingFolderLi){//在外的item, 可以上传音乐
         $('#tourItemEdit .mediaUpload').removeClass('hide')
-        var musicInfo = li.data.musicInfo   //audio ? audio.music : null;
-        if (musicInfo) {  // 判断改导览点是否已经已有音乐
+        var musicInfo = li.tourData.musicInfo   //audio ? audio.music : null;
+        if (musicInfo && musicInfo.music) {  // 判断改导览点是否已经已有音乐
             var musicName = musicInfo.name || '导览音频.mp3'  // 获取音频的文件名
-            $('#tourItemEdit').find(".audio .playBox").removeClass("hide"); 
+            /* $('#tourItemEdit').find(".audio .playBox").removeClass("hide"); 
             $('#tourItemEdit').find(".audio .playBox a").attr("href", "//" + musicInfo.music);
             $('#tourItemEdit').find(".audio .submit").text("替换");
-            $('#tourItemEdit').find(".title").text(musicName);
+            $('#tourItemEdit').find(".title").text(musicName); */
+            this.musicBox.show($('#tourItemEdit .mediaUpload'), musicName, "//" + musicInfo.music)
         } else {
-            $('#tourItemEdit').find(".audio .playBox").addClass("hide");
-            $('#tourItemEdit').find(".audio .submit").text("上传");
+            this.musicBox.hide()
+            /* $('#tourItemEdit').find(".audio .playBox").addClass("hide");
+            $('#tourItemEdit').find(".audio .submit").text("上传"); */
         }  
         
     }else{
@@ -1760,7 +1775,7 @@ EditGuide.prototype.completeFolder = function(){//点击完成
     
     var tourName = $('#tourFolderEdit .tourName input').val() //|| this.targetTourPoint.context.innerText;
     $(this.editingFolderLi).find(".title").text(tourName) 
-    this.editingFolderLi.data.momentTour = $("#folderTourSwitch input").is(':checked') ? "black" : 'walk' 
+    this.editingFolderLi.tourData.momentTour = $("#folderTourSwitch input").is(':checked') ? "black" : 'walk' 
     this.editingFolderLi.tourItemDoms = Array.from($('#tourItemList ul li'));
      
     var done = ()=>{
@@ -1797,7 +1812,7 @@ EditGuide.prototype.completeFolder = function(){//点击完成
                 src = srcArr.join('/');
                 //var sid = this.editingFolderLi.data.sid
                 //that.tourAudio[sid] = {
-                this.editingFolderLi.data.musicInfo = {    
+                this.editingFolderLi.tourData.musicInfo = {    
                     "name": musicName,
                     "music": '/' + src,
                     "time": Math.round(audio.duration * 1000 + 1000)
@@ -1847,7 +1862,7 @@ EditGuide.prototype.completeItem = function() {//点击完成
                 srcArr[0] = '';
                 src = srcArr.join('/');
                 //that.tourAudio[sid] = {
-                this.editingItemLi.data.musicInfo = {    
+                this.editingItemLi.tourData.musicInfo = {    
                     "name": musicName,
                     "music": '/' + src,
                     "time": Math.round(audio.duration * 1000 + 1000)
@@ -1906,7 +1921,7 @@ EditGuide.prototype.uploadGuide = function(urlData, guide, renew, insideFolder)
             if (renew/*  && target */) { // 重新录制导览
                 // 更新数据
                  
-                var musicInfo = insideFolder || that.editingItemLi.data.musicInfo;
+                var musicInfo = insideFolder || that.editingItemLi.tourData.musicInfo;
                 musicInfo && (args.musicInfo = musicInfo);
                 $(that.editingItemLi).find('#tourBg')[0].style.backgroundImage = 'url(' + args.thumbnail_signed_src + ')';
                 //args.name = insideFolder $('#tourItemEdit').find('#tourNameInput').val()
@@ -1917,14 +1932,14 @@ EditGuide.prototype.uploadGuide = function(urlData, guide, renew, insideFolder)
                 // 新生成的id指向以前的导览音频
                 delete that.tourAudio[oldId];
                 // 删除导览音频中的旧导览id */
-                that.editingItemLi.data = args;
+                that.editingItemLi.tourData = args;
                 
                 //target.text(args.name);  // 更新导览列表中的导览名称  //不改名字
                 //$('#tourItemEdit').find('#tourNameInput').val(args.name);   // 修改输入框内容
             } else { 
                 var $li = $(that.getItemDom(args.name, args.thumbnail_signed_src));
  
-                $li[0].data = args;
+                $li[0].tourData = args;
                 
                 var $ul = insideFolder ? $("#tourItemList>ul") : $("#tourList>ul")
                 $ul.append($li); 
@@ -1944,12 +1959,12 @@ EditGuide.prototype.getSavingInfo = function(){
      
     Array.from($("#tourList ul li")).forEach(dom=>{
         if(dom.classList.contains("guideItem")){//item
-            dom.data.name = $(dom).find('.guide-name').text()
-            data.push(dom.data)
+            dom.tourData.name = $(dom).find('.guide-name').text()
+            data.push(dom.tourData)
         }else{//folder
-            var dataFolder = dom.data;
+            var dataFolder = dom.tourData;
             dataFolder.name = $(dom).find('.title').text()
-            dataFolder.locations = dom.tourItemDoms.map(li => li.data ) 
+            dataFolder.locations = dom.tourItemDoms.map(li => li.tourData ) 
             data.push(dataFolder)
         }
     })
@@ -2007,17 +2022,7 @@ var restrictedSize = function(file, _size) {
 }
 
 //上传音乐
-var uploadMiuse = function(file, callback) {
-
-    if (!/audio\/\w+/.test(file.type)) {
-        alert("文件必须为音乐!");
-        return false;
-    }
-    //限制大小不大于8m
-    if (!restrictedSize(file, _musicMaxWeight)) {
-        return false
-    }
-
+var uploadMiuse = function(file, callback) { 
     uploadFile(file, 'audio', callback);
 }
 

+ 77 - 29
js/main_2020_edit.js

@@ -4602,15 +4602,16 @@ function o(a, s, l) {
             ,
             t.prototype.goToDestination = function(e, t, i, n) { 
                 //音频
-                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;
-                    g_tourAudio.src = manage.dealURL(o);
-                    g_tourAudio.load()  
+                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;
+                        g_tourAudio.src = manage.dealURL(o);
+                        g_tourAudio.load()  
+                    }
                 }
                 
                 
-                
                 if (this.onTheBus = !0,
                 this.emit("update.controls"),
                 this.player.updateLastView(),
@@ -4768,7 +4769,10 @@ function o(a, s, l) {
                 }
             }
             ,
-            t.prototype.atEndOfTour = function() {
+            
+             
+            
+            t.prototype.atEndOfTour = function(item) {
                 //return this.currentItem >= this.nItems - 1
                 var end = this.currentItem && this.currentItem[0] >= this.nItems - 1; 
                 if(end){
@@ -4808,12 +4812,40 @@ function o(a, s, l) {
                 this.emit("update.controls")
             }
             ,
-            t.prototype.nextItem = function(e) {
-                return null === e ? this.firstDestination() : e >= this.nItems - 1 ? this.endlessLoop ? this.firstDestination() : null : e + 1
+            t.prototype.nextItem = function(currentItem) {
+                //return null === e ? this.firstDestination() : e >= this.nItems - 1 ? this.endlessLoop ? this.firstDestination() : null : e + 1
+                if(currentItem == void 0)return this.firstDestination()
+                var currentLocation = this.model.heroLocations[currentItem[0]];
+                var currentChildNum = currentLocation.heroLocations ? currentLocation.heroLocations.length : 1
+                var item;
+                if(this.currentItem[1] >= currentChildNum - 1){//子目录中最后一个
+                    item = [currentItem[0] + 1, 0] //结果可能超出nItems
+                }else{
+                    item = [currentItem[0] , currentItem[1]+1]
+                }
+                if(item[0]  >= this.nItems ){
+                    item = this.firstDestination()
+                }
+                return item;
+                //暂时不理会endlessLoop,默认为false
             }
             ,
-            t.prototype.prevItem = function(e) {
-                return null === e ? this.firstDestination() : e < 0 ? this.endlessLoop ? this.lastDestination() : null : e - 1
+            t.prototype.prevItem = function(currentItem) {
+                //return null === e ? this.firstDestination() : e < 0 ? this.endlessLoop ? this.lastDestination() : null : e - 1
+                if(currentItem == void 0)return this.firstDestination()//finalDestination?
+                var item;
+                var lastLocation = this.model.heroLocations[currentItem[0]-1];
+                if(!lastLocation) return this.finalDestination()//[-1, 0]//this.setDestinationItem([-1, 0]) //结果小于0
+                else{
+                    var lastChildNum = lastLocation.heroLocations ? lastLocation.heroLocations.length : 1
+            
+                    if(this.currentItem[1] == 0){//子目录中第一个 
+                        return [currentItem[0] - 1, lastChildNum-1]
+                    }else{
+                        return [currentItem[0], currentItem[1]-1]
+                    }
+                }
+            
             }
             , 
             t.prototype.tourAdvance = function(e) {//e是1或-1
@@ -4821,19 +4853,22 @@ function o(a, s, l) {
                 m.debug("tourAdvance(" + e + ")") 
                 if(null === this.currentItem || void 0 === this.currentItem){
                     this.setDestinationItem(this.firstDestination()) 
-                }else{ 
-                     
+                }else{
+                    var item            
                     if(e == 1){
-                        var currentLocation = this.model.heroLocations[this.currentItem[0]];
+                        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){
-                        var lastLocation = this.model.heroLocations[this.currentItem[0]-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
@@ -4843,19 +4878,27 @@ function o(a, s, l) {
                             }else{
                                 this.setDestinationItem([this.currentItem[0], this.currentItem[1]-1]) 
                             }
-                        }    
+                        }    */ 
                         
                     } 
                      
                     //this.setDestinationItem(this.currentItem + e) 
+                    this.setDestinationItem(item) 
+                }
+                
+                if(this.itemCompare(this.destinationItem, this.finalDestination(), 'equal')[0] < 0 ){ 
+                    this.useSpecialTransition("reverse-looping to end") 
+                }else if(this.itemCompare(this.destinationItem, this.firstDestination(), 'equal')){ 
+                    this.useSpecialTransition("looping back to start")
                 }
-                if(this.destinationItem[0] < 0 ){
+                
+                /* if(this.destinationItem[0] < 0 ){
                     this.setDestinationItem(this.finalDestination()) 
                     this.useSpecialTransition("reverse-looping to end") 
                 }else{
                     this.destinationItem[0] >= this.nItems && (this.setDestinationItem(this.firstDestination()),
                     this.useSpecialTransition("looping back to start"))
-                }
+                } */
                  
                 
                 var momentTour = this.getMomentTour(this.destinationItem);
@@ -13899,6 +13942,7 @@ function o(a, s, l) {
                 try{//处理一下导览数据 
                     t.model.images = t.model.images.filter(e=>{
                         if(!e.locations && !e.thumbnail_signed_src)return; //旧的曾有导览数据是错误的,将它删除  
+                        if(e.locations)e.locations = e.locations.filter(e=>e)
                         if(e.locations && e.locations.length == 0)return;
                         return e
                     })    
@@ -21288,7 +21332,7 @@ function o(a, s, l) {
                     }
                     
                 }
-                this.mode == "panorama" && cad.setSign({ x: this.position.x, y: this.position.z },this.cameraControls.controls.panorama.lon);
+                this.mode == "panorama" && window.cad && cad.setSign({ x: this.position.x, y: this.position.z },this.cameraControls.controls.panorama.lon);
                 this.model.supportsTiles && (this.updateTileDownloader(F),
                 this.updatePanoRenderer(F)),
                 this.updatePreRendering(F),
@@ -22451,18 +22495,22 @@ function o(a, s, l) {
                 
                  
                 var currentLocation = this.model.heroLocations[this.director.currentItem[0]] 
-                , n = g_tourAudio ? 1e3 * g_tourAudio.currentTime : 0
-                , r = currentLocation && currentLocation.musicInfo.music ? currentLocation.musicInfo.time - n : 2e3;  
+                var restChildCount = currentLocation.heroLocations ? (currentLocation.heroLocations.length-this.director.currentItem[1]-1) : 0
+                var current = g_tourAudio ? 1e3 * g_tourAudio.currentTime : 0
+                var waitTime = currentLocation && currentLocation.musicInfo.music ? currentLocation.musicInfo.time - current : 2e3;  
+                
+                if(restChildCount){//如果当前folder中还有剩下的item,平分一下时间
+                    var timeEachItem = 2000;//假设每个item飞的时间
+                    var waitTime = Math.max(0, (waitTime-timeEachItem*restChildCount) / (restChildCount+1));
+                     
+                } 
+                
+                console.log("waitTime "+waitTime +" at item "+this.director.currentItem + ",musicCurrentTime:"+current) 
                  
-               /*  var i = g_data2.tourAudio && g_data2.tourAudio[this.model.heroLocations[this.director.currentItem].sid]
-                  , n = g_tourAudio ? 1e3 * g_tourAudio.currentTime : 0
-                  , r = i && i.music ? i.time - n : 2e3; */
-                  
-                   
-                this.path.waitNextStep(e, function() {
+                this.path.waitNextStep(e, function() {//等待音乐播放一段时间再下一步,此时镜头会缓慢旋转
                     t && t()
                 }
-                .bind(this), r)
+                .bind(this), waitTime)
             }
             ,
             t.prototype.stopInterlude = function() {

Різницю між файлами не показано, бо вона завелика
+ 91 - 131
js/main_2020_show.js