edit.js 167 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959
  1. /* var ceshi = '';
  2. // var ceshi = 'http://192.168.0.135:8105';
  3. // var ceshi = 'http://47.107.252.54:8105';
  4. // var token = "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsInJvbGUiOm51bGwsIm1hbmFnZXIiOm51bGwsImlkIjoxLCJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNTk2NzAxNjAyLCJpYXQiOjE1OTY2MTUyMDIsImp0aSI6Ijk0YjA5YTg1LWViY2ItNDE1Yy04OGVmLWU0MDM1M2UzYmIxYyJ9.Uzi95n0kYXp7bdpY77MdLtTpPL_Fq-jn0tE7gjg6AzA"
  5. var token = window.localStorage.dcj_token
  6. */
  7. var _musicMaxWeight = 8
  8. //M
  9. var cmp = getQueryVariable('cmp') || ''
  10. var _hotNum = 0
  11. function reData(data, type) {
  12. return JSON.stringify(data) == type ? null : data
  13. }
  14. //新编辑界面
  15. var EditTools = function(n) {
  16. //main2018 里面的主要对象
  17. this.n = n;
  18. //当前状态
  19. this.atPanel = null;
  20. //场景信息
  21. this.sceneInformation = new SceneInformation();
  22. //热点
  23. this.hotpoint = new Hotpoint();
  24. //导览
  25. this.editGuide = new EditGuide();
  26. //音乐
  27. this.editMiuse = new EditMiuse();
  28. //初始化界面
  29. //this.init();
  30. this.data = {}
  31. }
  32. EditTools.prototype.loadDone = function(name, data){
  33. this.data[name] = data
  34. if('data' in this.data && 'data2' in this.data){
  35. this.init();
  36. }
  37. }
  38. EditTools.prototype.init = function() {
  39. this.hotpoint.init(/* this.n */);
  40. var that = this;
  41. this.initSaveAll();
  42. this.active();
  43. if(player.mode != 'panorama'){
  44. $(".toolLeft li[data-name=panoVisible]").addClass('unable')
  45. player.once("pano.chosen",()=>{
  46. $(".toolLeft li[data-name=panoVisible]").removeClass('unable')
  47. })
  48. }
  49. that.hotpoint.initTexSelect( this.data.data2.hots);
  50. //创建导览
  51. that.editMiuse.init(this.data.data);
  52. that.sceneInformation.init(this.data.data, this.data.data2)
  53. // fyz 初始化导览需要两部分数据, 其中data2为data.js中的数据
  54. that.editGuide.init(this.data.data, this.data.data2);
  55. $("body").on("click", function() {
  56. $(".DelConfirm").removeClass("active");
  57. })
  58. $(" .MenuOptions li").on("click", (e)=>{
  59. var $elem = $(e.target);
  60. $elem.closest('.MenuOptions').find('li').removeClass("chosen");
  61. $elem.addClass("chosen");
  62. })
  63. }
  64. //点击的时候激活状态
  65. EditTools.prototype.active = function() {
  66. var that = this;
  67. var confirmSnap = $(".confirmSnap.innerBtn");
  68. var snapshotGui = $(".snapshotGui.overlayGui");
  69. $('.toolBottom .toolLeft li').click(function() {
  70. var name = $(this).data("name");
  71. $('.toolLeft li[data-name=' + name + ']').addClass("active").siblings().removeClass("active");
  72. $('.toolRight .' + name).removeClass("hide").siblings().addClass("hide");
  73. if (name == that.atPanel)
  74. return;
  75. console.log(`atPanel ${that.atPanel} name ${name}`)
  76. switch (that.atPanel) {
  77. //退出
  78. case "panoVisible":
  79. VisiSet.finishSetPanoVisible()
  80. break;
  81. case "screen":
  82. confirmSnap.addClass("hide").removeClass("unable");
  83. snapshotGui.hide();
  84. break;
  85. case "overlay":
  86. EditOverlay.leave()
  87. break;
  88. case "hotpoint":
  89. $("#hotpointDetail").hasClass("atRight") || $("#hotpointDetail a.close").click();
  90. VisiSet.finishSetTagVisible()
  91. break;
  92. }
  93. switch (name) {
  94. case "panoVisible":
  95. $(".toolLeft").addClass("unable")
  96. VisiSet.enterSet(VisiSet.beginSetPanoVisible.bind(VisiSet))
  97. break;
  98. case "screen":
  99. confirmSnap.removeClass("hide");
  100. $('#camera-start').text("点此设置为初始画面")
  101. snapshotGui.show();
  102. if (player.modeTran.split("-")[1] != "panorama")
  103. $(".confirmSnap").addClass("unable")
  104. break;
  105. case "overlay":
  106. EditOverlay.enter()
  107. break;
  108. }
  109. that.atPanel = name;
  110. /* if(name != "hotpoint"){
  111. $("#hotpointDetail").hasClass("atRight") || $("#hotpointDetail a.close").click()
  112. } */
  113. })
  114. //滚动阻止事件
  115. $(".toolRight div.content").on("mousewheel", function(event) {
  116. event.stopPropagation()
  117. });
  118. // 输入框阻止事件
  119. $('.toolRight').on('keydown', function(ev) {
  120. ev.stopPropagation();
  121. })
  122. }
  123. //保存按钮
  124. EditTools.prototype.initSaveAll = function() {
  125. var that = this;
  126. $('#save').on('click', function() {
  127. $(".edit-loading").removeClass("hide");
  128. var $shareImages = $(".information .edit-fun-images a.result");
  129. new Promise(function(resolve, reject) {//分享图
  130. upload($shareImages, 'images', resolve)
  131. }).then(function(imgUrls) {
  132. //导览的数据
  133. var guides = that.editGuide.getSavingInfo()/* Array.from($('.tourFolderList ul li')).map(function(dom) {
  134. return dom.data
  135. }) */
  136. var hots = {}
  137. // 热点数据
  138. var hotLength = 0;
  139. for (let i in player.model.hots) {
  140. let hot = player.model.hots[i];
  141. let hotData = {
  142. position: {
  143. x: toPrecision(hot.position.x, 3),
  144. y: toPrecision(hot.position.y, 3),
  145. z: toPrecision(hot.position.z, 3),
  146. },
  147. //有的定制场景代码是旧的,只能使用rotation,所以不输出quaternion :
  148. rotation: new THREE.Euler().setFromQuaternion(hot.quaternion).toObject(),
  149. isSprite: hot.isSprite ? 1 : 0,
  150. noAction: hot.noAction ? 1 : 0,
  151. linkType: hot.linkType,
  152. actionType: hot.actionType,
  153. infoAttribute: hot.infoAttribute,
  154. order: hotLength++//因为热点保存后在hots里的顺序会被修改,所以使用order来记录顺序
  155. }
  156. if (hot.visiblePanos)
  157. hotData.visiblePanos = hot.visiblePanos
  158. if (hot.hotIconScale)
  159. hotData.hotIconScale = hot.hotIconScale
  160. hotData.transformAtPanos = {}
  161. for(let i in hot.transformAtPanos){
  162. hotData.transformAtPanos[i] = {
  163. pos : toPrecision(hot.transformAtPanos[i].pos.toArray(), 3),
  164. }
  165. if(hot.transformAtPanos[i].qua){
  166. hotData.transformAtPanos[i].qua = toPrecision(hot.transformAtPanos[i].qua.toArray(), 5)
  167. }
  168. }
  169. if (hot.infoAttribute) {
  170. delete hot.infoAttribute.position;
  171. delete hot.infoAttribute.quaternion;
  172. delete hot.infoAttribute.rotation;
  173. delete hot.infoAttribute.transformAtPanos
  174. }
  175. hots[i] = hotData
  176. }
  177. var info = {
  178. name: $('#pjtName').val(),
  179. summary: $('#info-summary').val(),
  180. weixinDesc: $('#weixin-summary').val(),
  181. shareImgUrl: imgUrls[0] || '',
  182. backgroundMusic: $('#query-bgm').attr('href'),
  183. bgName: $(".music .audio.mediaUpload .title").text(),
  184. hoticon: JSON.parse($(".hotStyle-item li.active").attr("data-val")),
  185. camera_start: $('#camera-start')[0].data,
  186. loadlogo: $("#loadlogo").is(':checked'),
  187. special: $("#g_specialScene").is(':checked'),
  188. vision_version: $("#twoData").is(':checked') ? "1.1.562.17209" : false,
  189. /************************************** 方奕卓 场景可配置项 ******************************************/
  190. hotImageScale: $("#hotImgScale").is(':checked'),
  191. // 热点图片可放大
  192. hideFloorMarker: $("#hideFloorMarker").is(':checked'),
  193. // 地面标记
  194. hideMouseMarker: $("#hideMouseMarker").is(':checked'),
  195. // 鼠标标记
  196. floorMarkerColor: $('#floorMarkerColor').val(),
  197. // 地面/导览标志颜色
  198. mouseMarkerColor: $('#mouseMarkerColor').val(),
  199. // 鼠标标志颜色
  200. momentTour: $('#tourSwitch input').is(':checked') ? 'black' : 'walk',
  201. // 导览瞬间过渡
  202. showHotListSta: $('#hotListSwitch input').is(':checked'),
  203. // 开启热点列表
  204. hotIconScale: $('#hotIconScale input').val(),
  205. // 热点缩放
  206. supportsVR: $('#VRSwitch input').is(':checked'),
  207. // 开启VR功能
  208. /**************** 陈志广 小地图可配置项 *********** */
  209. cadSignColor: $('#cadSignColor').val(),
  210. cadBorderColor: $('#cadBorderColor').val(),
  211. cadBorderWidth: $('#cad-size').val(),
  212. showCad: $('input[name="show-cad"]').is(':checked'),
  213. }
  214. var overlayInfo = []
  215. player.overlayGroup.children.forEach((overlay)=>{
  216. var info = EditOverlay.getSavingInfo(overlay)
  217. if (info)
  218. overlayInfo.push(info);
  219. }
  220. )
  221. /* console.log("保存数据");
  222. console.log({
  223. guides: reData(guides, '[]'),
  224. info: info,
  225. })
  226. console.log(JSON.stringify(guides) )
  227. debugger; */
  228. let url = cmp ? ('/api/scene/edit/' + cmp) : '/manage/scene/edit'
  229. $.ajax({
  230. method: 'POST',
  231. headers: {
  232. 'Content-Type': 'application/json',
  233. token: token
  234. },
  235. dataType: 'json',
  236. contentType: 'application/json',
  237. url: ceshi + url,
  238. data: JSON.stringify({
  239. sceneCode: number,
  240. hots: reData(hots, '{}'),
  241. name: number,
  242. guides: reData(guides, '[]'),
  243. info: info,
  244. //tourAudio: reData(that.editGuide.getTourAudio(), '{}'),
  245. overlays: reData(overlayInfo, '[]')
  246. }),
  247. success: function(data) {
  248. if (data.code === 0) {
  249. location.reload()
  250. }
  251. if (data.code === 5001) {
  252. alert('请重新登录')
  253. localStorage.dcj_token = ''
  254. location.reload()
  255. }
  256. }
  257. })
  258. });
  259. })
  260. }
  261. //场景信息编辑
  262. var SceneInformation = function() {}
  263. SceneInformation.prototype.init = function(data, data2) {
  264. var $options = $('.hotStyle-item li');
  265. var $loadlogo = $("#loadlogo");
  266. var $hotImageScale = $("#hotImgScale");
  267. var $hideFloorMarker = $("#hideFloorMarker");
  268. var $hideMouseMarker = $("#hideMouseMarker");
  269. var $g_specialScene = $("#g_specialScene");
  270. var $twoData = $("#twoData");
  271. /*******************方奕卓 其他项需要用到data来初始化, 故一并放到这里 ******************/
  272. let momentTour = $('#tourSwitch input');
  273. // 导览瞬间过渡开关
  274. let hotListSwitch = $('#hotListSwitch input');
  275. // 热点列表开关
  276. let hotIconScale = $('#hotIconScale input');
  277. // 热点图标缩放
  278. let VRSwitch = $('#VRSwitch input');
  279. // VR功能开启
  280. /***********************************************************************************/
  281. $(".model-title2").text(data.name);
  282. $('#pjtName').val(data.name);
  283. $('#info-summary').val(data.summary);
  284. //if (data2) $('#weixin-summary').val(data2.weixinDesc);
  285. $('#weixin-summary').val(data.weixinDesc);
  286. for (var i = 0; i < $options.length; i++) {
  287. if ($options.eq(i).attr('data-val') === JSON.stringify(data.hoticon)) {
  288. $options.eq(i).addClass("active").siblings().removeClass("active");
  289. }
  290. }
  291. $('#camera-start')[0].data = data.camera_start;
  292. $(".shotImg.innerBtn").on("click", ()=>{
  293. var EntryInfo = $('#camera-start')[0].data
  294. if (EntryInfo) {
  295. var to = player.model.panos.get(EntryInfo.pano.uuid);
  296. var q = new THREE.Quaternion().fromArray(EntryInfo.camera.quaternion);
  297. var lookAtPoint = new THREE.Vector3(0,0,-1).applyQuaternion(q).add(to.position);
  298. player.flyToPano({
  299. pano: to,
  300. lookAtPoint: lookAtPoint
  301. })
  302. }
  303. }
  304. )
  305. if(data.shareImgUrl){
  306. var imagesHTML = '<div><a class=" result success"><span></span><img src="' + data.shareImgUrl + '"></a></div>'
  307. $(".information .edit-fun-images.list ").html(imagesHTML);
  308. $("#shareImgUpload").addClass("hide")
  309. }
  310. if(data.spotImgUrl){
  311. }
  312. /*************方奕卓 其他项的初始化操作 ************/
  313. initColorElem(data);
  314. addListener();
  315. // 给其他元素绑定事件
  316. if (data.momentTour === 'black') {
  317. momentTour.prop('checked', true);
  318. }
  319. if (data.showHotListSta) {
  320. hotListSwitch.prop('checked', true);
  321. }
  322. if (data.hotIconScale) {
  323. hotIconScale.val(parseFloat(data.hotIconScale));
  324. }
  325. hotIconScale.on('change',(e)=>{
  326. var s = THREE.Math.clamp(parseFloat(e.target.value), 0.1, 1.5)
  327. e.target.value = s
  328. for(let i in player.model.hots){
  329. if(!player.model.hots[i].hotIconScale){
  330. player.model.hots[i].mesh.scale.set(s,s,s)
  331. }
  332. }
  333. })
  334. $('#hotIconScale_2 input').on('change',(e)=>{
  335. var s = THREE.Math.clamp(parseFloat(e.target.value), 0.1, 1.5)
  336. e.target.value = s
  337. editTool.hotpoint.editSpot.mesh.scale.set(s,s,s)
  338. })
  339. if (data.supportsVR) {
  340. VRSwitch.prop('checked', true);
  341. }
  342. /************************************************/
  343. //隐藏公司logo
  344. if (data.loadlogo) {
  345. $loadlogo[0].checked = true
  346. showLogo();
  347. }
  348. // 热点图片放大
  349. if (data.hotImageScale) {
  350. $hotImageScale[0].checked = true
  351. }
  352. // 隐藏地面标记
  353. if (data.hideFloorMarker) {
  354. $hideFloorMarker[0].checked = true
  355. }
  356. // 隐藏鼠标标记
  357. if (data.hideMouseMarker) {
  358. $hideMouseMarker[0].checked = true
  359. }
  360. //特殊大场景
  361. if (data.special) {
  362. $g_specialScene[0].checked = true
  363. }
  364. //启动二代的数据
  365. if (data.vision_version === "1.1.562.17209" || data.vision_version) {
  366. $twoData[0].checked = true
  367. }
  368. }
  369. /**
  370. * 初始化颜色选择的html元素
  371. * @param {*} data
  372. * @param {*} elem
  373. */
  374. function initColorElem(data, elem) {
  375. let $floorMarkerColor = $('#floorMarkerColor');
  376. let $mouseMarkerColor = $('#mouseMarkerColor');
  377. let $floorMarkerColorTex = $('#floorMarkerColorTex');
  378. let $mouseMarkerColorTex = $('#mouseMarkerColorTex');
  379. let $cadSignColor = $('#cadSignColor');
  380. let $cadSignColorTex = $('#cadSignColorTex');
  381. let $cadBorderColor = $('#cadBorderColor');
  382. let $cadBorderColorTex = $('#cadBorderColorTex');
  383. var colorRe = /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/;
  384. // 事件监听
  385. $floorMarkerColor.on('change', function(e) {
  386. $('#floorMarkerColorTex').attr('placeholder', e.target.value)
  387. })
  388. $floorMarkerColorTex.on('blur keydown', function(e) {
  389. (e.type === 'blur' || e.type === 'keydown' && e.keyCode === 13) && setColor(e, $floorMarkerColor, this);
  390. })
  391. $mouseMarkerColor.on('change', function(e) {
  392. $('#mouseMarkerColorTex').attr('placeholder', e.target.value)
  393. })
  394. $mouseMarkerColorTex.on('blur keydown', function(e) {
  395. (e.type === 'blur' || e.type === 'keydown' && e.keyCode === 13) && setColor(e, $mouseMarkerColor, this);
  396. })
  397. // 事件监听
  398. $cadSignColor.on('change', function(e) {
  399. $('#cadSignColorTex').attr('placeholder', e.target.value)
  400. })
  401. $cadSignColorTex.on('blur keydown', function(e) {
  402. (e.type === 'blur' || e.type === 'keydown' && e.keyCode === 13) && setColor(e, $cadSignColor, this);
  403. })
  404. // 事件监听
  405. $cadBorderColor.on('change', function(e) {
  406. $('#cadBorderColorTex').attr('placeholder', e.target.value)
  407. })
  408. $cadBorderColorTex.on('blur keydown', function(e) {
  409. (e.type === 'blur' || e.type === 'keydown' && e.keyCode === 13) && setColor(e, $cadBorderColor, this);
  410. })
  411. // 设置颜色值
  412. function setColor(e, colorElem, inputElem) {
  413. var isColor = colorRe.test(e.target.value);
  414. isColor && colorElem.val(e.target.value);
  415. // isColor ? colorElem.val(e.target.value): (inputElem.placeholder = colorElem.val());
  416. }
  417. // 判断data中是否有存在的颜色值, 否则设置默认值
  418. data.floorMarkerColor ? $floorMarkerColor.val(data.floorMarkerColor) : $floorMarkerColor.val('#4bcdfc');
  419. data.mouseMarkerColor ? $mouseMarkerColor.val(data.mouseMarkerColor) : $mouseMarkerColor.val('#4bcdfc');
  420. // 判断data中是否有存在的颜色值, 否则设置默认值
  421. data.cadSignColor ? $cadSignColor.val(data.cadSignColor) : $cadSignColor.val('#00c8af');
  422. data.cadBorderColor ? $cadBorderColor.val(data.cadBorderColor) : $cadBorderColor.val('#ffffff');
  423. $('input[name="show-cad"]')[0].checked = !!data.showCad
  424. $('#cad-size > option[value="'+(data.cadBorderWidth ? data.cadBorderWidth : '0.01')+'"]').attr("selected",true);
  425. if (data.showCad) {
  426. $('input[name="show-cad"]').trigger('change')
  427. }
  428. }
  429. $('input[name="show-cad"]').on('change', function(ev) {
  430. if (!ev.target.checked) {
  431. return $('.cad').hide()
  432. }
  433. let taht = this
  434. if (!taht.floorJSON) {
  435. $.ajax({
  436. url: '//super.4dage.com/data/'+ window.number +'/floor.json',
  437. method: 'GET',
  438. success(res) {
  439. taht.floorJSON = res
  440. loadCAD(taht.floorJSON)
  441. $('#cadSignColor').on('change', function(ev) {
  442. loadCAD()
  443. })
  444. $('#cadBorderColor').on('change', function(ev) {
  445. loadCAD()
  446. })
  447. $('#cad-size').on('change', function(ev) {
  448. loadCAD()
  449. })
  450. },
  451. error() {
  452. alert('当前场景没有小地图floor.json文件,请联系三维部门添加')
  453. ev.target.checked = false
  454. }
  455. })
  456. } else {
  457. console.log('0000000000000000000')
  458. $('.cad').show()
  459. }
  460. })
  461. function loadCAD(data) {
  462. grendCAD(data, $('#player')[0], $('#cadSignColor').val(), $('#cadBorderColor').val(), $('#cad-size').val())
  463. }
  464. function addListener() {}
  465. //设置初始界面
  466. function getSeft(seft) {
  467. $('#camera-start').on('click', function() {
  468. if (VisiSet.setPanoVisible) {
  469. return VisiSet.savePanoVisibles()
  470. } else if (VisiSet.setTagVisible) {
  471. return VisiSet.saveTagVisibles()
  472. }
  473. // 这部分内容需要配合main_2018.js中来进行修改
  474. var snap = JSON.parse("{" + seft.getSnapAngleInfo() + "}")
  475. this.data = {
  476. camera: {
  477. position: snap.metadata.camera_position,
  478. quaternion: snap.metadata.camera_quaternion// 相机朝向
  479. },
  480. pano: {
  481. uuid: snap.metadata.scan_id // 起始点位的id
  482. }
  483. }
  484. var ev = document.createEvent("MouseEvent");
  485. //点击截取视图
  486. g_snapShotWidth = 240 * 4;
  487. g_snapShotHeight = 118 * 4;
  488. window.screenSta = 'startScreen';
  489. ev.initMouseEvent("snapshotBegin", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  490. ev.__callback = (imgData,info)=>{
  491. uploadImg(imgData, (rs)=>{
  492. if (rs.code === 0) {
  493. $(".shotImg.innerBtn").css("background-image", "url(" + rs.data + ")")
  494. this.data.thumbImg = rs.data;
  495. }
  496. }
  497. , "thumbImg.jpg")
  498. }
  499. window.dispatchEvent(ev);
  500. });
  501. }
  502. //热点编辑
  503. var Hotpoint = function() {
  504. this.spotList = $(".spotList");
  505. this.hotpointDetail = $("#hotpointDetail");
  506. // fyz 导览编辑页面同样采取热点编辑的样式, 这里确保只查找到热点编辑
  507. }
  508. Hotpoint.prototype.init = function(n) {
  509. var that = this;
  510. this.active();
  511. this.addmedia();
  512. // 添加多媒体
  513. this.addMusicInit();
  514. // 添加音乐
  515. this.addModel();
  516. // 添加模型
  517. this.addwebPack();
  518. // 添加外链
  519. //this.initSaveHot();
  520. // 保存热点
  521. this.hotpointDetail.find(".tail .submit").on('click', this.saveHot.bind(this))
  522. $("#isSprite").on("change", function(e) {
  523. that.editSpot.isSprite = this.checked;
  524. if (this.checked) {
  525. that.editSpot.update(player.camera)
  526. } else {
  527. var curPanoTransform = that.editSpot.transformAtPanos[ getTransformSid()] || {}
  528. that.editSpot.mesh.quaternion.copy(curPanoTransform.qua || that.editSpot.quaternion)
  529. }
  530. })
  531. /* $("#noAction").on("change", function(e) {
  532. that.editSpot.noAction = this.checked;
  533. }) */
  534. let hotIconScale = $('#hotIconScale');
  535. //点击添加热点按钮
  536. $('#addHotSpots').on("click", function() {
  537. //点击添加热点
  538. g_HotStatus = g_HotStatus === "add" ? null : "add";
  539. $("#player").css("cursor", "cell");
  540. });
  541. //点击热点列表弹出按钮
  542. this.spotList.on("click", function(e) {
  543. var target = $(e.target);
  544. let li = searchParent(e.target, { className: 'listItem' }, 7);
  545. if(!li)return;
  546. var hotId = $(li).attr("data-spid");
  547. var hot = player.model.hots[hotId]
  548. if(VisiSet.setTagVisible){
  549. return VisiSet.SetOneTagVisible(hot)
  550. }
  551. if (target.hasClass("del")) {
  552. e.stopPropagation();
  553. target.siblings(".DelConfirm").addClass("active");
  554. that.spotList.find("i").text(that.spotList.find("ul li").length);
  555. } else {
  556. if (target.hasClass("DelConfirm")) {
  557. e.stopPropagation();
  558. that.removeHot(hot, $(li));
  559. } else {
  560. //点击热点列表弹出编辑热点窗口
  561. that.editHot(hot, $(li))
  562. }
  563. }
  564. });
  565. //点击热点编辑窗口右上角的关闭按钮
  566. this.hotpointDetail.find("a.close, button.cancel").on("click", function() {
  567. var spot_id = that.hotpointDetail.attr("data-id");
  568. var hot = player.model.hots[spot_id];
  569. //var info = hot.infoAttribute;
  570. that.styleList.recover()
  571. hot.setFromInfo()
  572. /* if (info) {
  573. info.position && hot.mesh.position.copy(info.position)
  574. info.quaternion && hot.mesh.quaternion.copy(info.quaternion)
  575. hot.isSprite = info.isSprite
  576. hot.noAction = info.noAction
  577. hot.linkOutside = info.linkOutside
  578. } */
  579. that.editSpot = null
  580. that.hotpointDetail.addClass("atRight");
  581. transformControls.detach()
  582. for(let i in player.model.hots){
  583. let hot_ = player.model.hots[i]
  584. hot_.styleImg = hot_.infoAttribute.styleImg.map((e)=>{return {src:e}});
  585. hot_.changeTex() //恢复贴图
  586. }
  587. });
  588. //创建列表
  589. for (let i in player.model.hots) {
  590. this.addHotList(player.model.hots[i]);
  591. }
  592. // 初始话的时候把热点信息添加到对应的热点中 直接使用data2.json的会怎样?
  593. /* $.ajax(g_Prefix + "data/" + window.number + "/hot/js/data.js" + "?" + Date.now(), { dataType: "json" })
  594. .then(function (infos) {
  595. that.infos = infos ;
  596. Object.keys(infos).forEach(function (key) {
  597. //sxm增加热点列表可读性,方便查看删除操作等
  598. that.spotList.find("ul li[data-spid=" + key + "]")[0] && (that.spotList.find("ul li[data-spid=" + key + "]")[0].infoAttribute = infos[key])&& (that.spotList.find("ul li[data-spid=" + key + "] .title").html(infos[key].title));
  599. })
  600. }) */
  601. $("#hotpointDetail .scale .MenuOptions li").on("click", (e)=>{ //更改大小
  602. curr = $(e.target).attr("index")
  603. if (curr == "default") {
  604. $("#userHotScale").addClass("hide")
  605. var s = parseFloat($("#hotIconScale input").val());
  606. editTool.hotpoint.editSpot.mesh.scale.set(s,s,s)
  607. } else {
  608. $("#userHotScale").removeClass("hide")
  609. var s = editTool.hotpoint.editSpot.mesh.scale.x;
  610. $('#hotIconScale_2 input').val(s)
  611. }
  612. })
  613. $("#hotpointDetail .MenuOptions[name='linkType'] li").on("click", (e)=>{ //链接打开方式切换
  614. editTool.hotpoint.editSpot.linkType = $(e.target).attr("index")
  615. $("#hotpointDetail .MenuOptions[name='linkType'] li").removeClass("chosen");
  616. $(e.target).addClass("chosen")
  617. })
  618. $("#hotpointDetail .MenuOptions[name='actionType'] li").on("click", (e)=>{ //
  619. editTool.hotpoint.editSpot.actionType = $(e.target).attr("index")
  620. $("#hotpointDetail .MenuOptions[name='actionType'] li").removeClass("chosen");
  621. $(e.target).addClass("chosen")
  622. })
  623. $('#setHotPosForPano input').on("change", ()=>{
  624. var on = $('#setHotPosForPano input').is(':checked')
  625. if(!on){
  626. delete this.editSpot.transformAtPanos[getTransformSid()]
  627. this.editSpot.mesh.position.copy(this.editSpot.position)
  628. this.editSpot.mesh.quaternion.copy(this.editSpot.quaternion)
  629. //this.editSpot.usingTransformData = false
  630. }
  631. })
  632. }
  633. Hotpoint.prototype.getTransformAtPano = function(type){
  634. var name = getTransformSid()
  635. var info = {
  636. pos : this.editSpot.mesh.position.clone()
  637. }
  638. if(!this.editSpot.isSprite){
  639. info.qua = this.editSpot.mesh.quaternion.clone()
  640. }else{
  641. if(type == 'quaternion')return; //如果恒朝向相机且调整的是quaternion,不要保存position
  642. }
  643. this.editSpot.transformAtPanos[name] = info
  644. //this.editSpot.usingTransformData = true
  645. }
  646. Hotpoint.prototype.updateTransform = function(type){
  647. var on = $('#setHotPosForPano input').is(':checked')
  648. var name = getTransformSid()
  649. if(on){
  650. this.getTransformAtPano(type)
  651. }else{
  652. if(type == 'position'){
  653. this.editSpot.position.copy(this.editSpot.mesh.position)
  654. }else if(type == 'quaternion'){
  655. if(!this.editSpot.isSprite){ //如果恒朝向相机就不保存quaternion
  656. this.editSpot.quaternion.copy(this.editSpot.mesh.quaternion)
  657. }
  658. }
  659. }
  660. }
  661. Hotpoint.prototype.updatePano = function(){
  662. if(!this.editSpot ) return;
  663. $('#setHotPosForPano input').prop('checked', !!this.editSpot.transformAtPanos[getTransformSid()]);
  664. }
  665. var ifSameTex = function(imgs0, imgs1){//是否是相同的图 (两个都是空的不算相同)
  666. return !!(imgs0[0] && imgs1[0] && imgs0[0].src == imgs1[0].src &&
  667. (imgs0[1] ? (imgs1[1] && imgs0[1].src == imgs1[1].src) : !imgs1[1] ))
  668. }
  669. Hotpoint.prototype.findSpotByImgs = (imgs=[])=>{////使用了该贴图的所有热点
  670. var spots = []
  671. for(var i in player.model.hots){
  672. var styleImg = player.model.hots[i].styleImg || [];
  673. if(ifSameTex(styleImg, imgs)){
  674. spots.push(player.model.hots[i])
  675. }
  676. }
  677. return spots
  678. }
  679. Hotpoint.prototype.initTexSelect = function(hots) {//热点样式图列表
  680. var countElem = $("<a></a>").css({"width":'40px','display': 'block', 'color':'#aeaeae', 'white-space':'break-spaces', 'line-height':'25px', 'margin-left':'10px'})
  681. var uploadInput = $('<input type="file" style="display:none" accept="image/*"></input>');
  682. var getListItem = ()=>{
  683. var elem = $('<li><ul class="hotTexUpload"><li class="upload"><div></div><a class="del hasHover"></a></li><li class="upload hide"><div></div><a class="del hasHover"></a></li></ul></li>')
  684. elem[0]._styleImg = []
  685. return elem
  686. }
  687. var editHotStyleInfo = {}
  688. var setImgContent = function($dom, index, src) {
  689. var li = $dom.find('li').eq(index)
  690. var div = li.find('>div');
  691. if (src) {
  692. li.addClass("uploaded")
  693. div.css("background-image", `url(${src})`)
  694. } else {
  695. li.removeClass("uploaded")
  696. div.css("background-image", '')
  697. }
  698. }
  699. var hotIcons = []; // 从所有热点tex中搜集
  700. for(let i in hots){
  701. let imgs = hots[i].infoAttribute.styleImg;
  702. if(imgs && imgs.length){
  703. if(!hotIcons.find(e=>e[0] == imgs[0] && e[1] == imgs[1])){
  704. hotIcons.push(imgs)
  705. }
  706. }
  707. }
  708. hotIcons = hotIcons.map(imgs=>imgs = imgs.map((a)=>{return {src:a}}))
  709. hotIcons.push([])//放末尾用来添加的
  710. var list = hotIcons.map(arr=>{//初始列表
  711. var elem = getListItem()
  712. elem[0]._styleImg = arr //每个li上绑定一个 _styleImg,存储它包含的图, 和热点的styleImg对应
  713. var divs = elem.find("li>div")
  714. arr.forEach((img,i)=>{
  715. setImgContent(elem, i, img.src)
  716. })
  717. arr.length && elem.find("li").eq(1).removeClass('hide')
  718. return elem
  719. })
  720. this.styleList = new ListBox(list, $('#spotTexSelect'), {//列表
  721. selectFun:()=>{//选中时要改变选中项selection缩略图 以及改变热点
  722. if(this.styleList.chosenItem == void 0){
  723. this.styleList.listTitle.find('li').addClass('hide')
  724. }else{
  725. this.styleList.listTitle.find('li').removeClass('hide')
  726. var divs = this.styleList.listTitle.find('li>div')//selection
  727. var imgs = this.styleList.chosenItem[0]._styleImg;
  728. if(imgs[0]){
  729. divs.eq(0).css("background-image", 'url("'+imgs[0].src+'")')
  730. divs.eq(0).parent().removeClass('hide')
  731. }else{
  732. divs.eq(0).parent().addClass('hide')
  733. }
  734. if(imgs[1]){
  735. divs.eq(1).css("background-image", 'url("'+imgs[1].src+'")')
  736. divs.eq(1).parent().removeClass('hide')
  737. }else{
  738. divs.eq(1).parent().addClass('hide')
  739. }
  740. //应用到热点:
  741. this.editSpot.changeTex(imgs)
  742. }
  743. Array.from(this.styleList.listDom.children()).forEach(li=>{//更新一下所有的li的使用的spot
  744. li.sameTexSpots = this.findSpotByImgs(li._styleImg)
  745. })
  746. },
  747. /* delFun: ()=>{
  748. }, */
  749. addFun: ($li)=>{ //列表新增时对li的操作
  750. $li[0].sameTexSpots = this.findSpotByImgs($li[0]._styleImg)
  751. $li.find('li').bind('click', (e)=>{
  752. e.stopPropagation()
  753. var index = $(e.currentTarget).index();
  754. if (e.target.classList.contains("del")) { //删除图片
  755. if ($li[0]._styleImg.length == 2 && index == 0) { //删除第一个 且有第二个的话
  756. setImgContent($li, 0, $li[0]._styleImg[1].src);
  757. setImgContent($li, 1, null);
  758. $li[0]._styleImg = [$li[0]._styleImg[1]]
  759. } else {
  760. setImgContent($li, index, null);
  761. $li[0]._styleImg.pop()
  762. if ($li[0]._styleImg.length == 0) {
  763. $li.find("li").eq(1).addClass("hide");
  764. }
  765. }
  766. $li[0].sameTexSpots.forEach(hot=>{
  767. hot.changeTex($li[0]._styleImg)
  768. })
  769. if($li.hasClass('selected')){//是当前spot的
  770. //this.editSpot.changeTex($li[0]._styleImg)
  771. this.styleList.options.selectFun()
  772. }
  773. } else {
  774. //添加图片
  775. uploadInput.click()
  776. editHotStyleInfo = {
  777. imgs : $li[0]._styleImg, index, $li
  778. };
  779. }
  780. })
  781. $li.bind('mouseover', (e)=>{
  782. this.showTitileSpots = $li[0].sameTexSpots;
  783. this.showTitileSpots.forEach(a=>a.showTitle())
  784. countElem.text("热点个数:"+this.showTitileSpots.length).removeClass('hide')
  785. $li.find("ul").append(countElem)
  786. })
  787. $li.bind('mouseout', (e)=>{
  788. this.showTitileSpots.forEach(a=>a.hideTitle())
  789. this.showTitileSpots = null;
  790. countElem.addClass('hide')
  791. })
  792. },
  793. saveTemp: (list)=>{//编辑热点时保存一份副本
  794. this._styleImgTemp = Array.from(list.listDom.children()).map((li)=>{
  795. return li._styleImg.slice()
  796. })
  797. },
  798. recover : (list)=>{//取消编辑时恢复
  799. Array.from(list.listDom.children()).forEach((li,i)=>{
  800. li._styleImg = this._styleImgTemp[i]
  801. })
  802. },
  803. })
  804. this.styleList.findChosenByImgs = (imgs=[])=>{//找到某图对应的li
  805. var list = Array.from(this.styleList.listDom.children())
  806. var item = list.find(e=>ifSameTex(e._styleImg, imgs ))
  807. return {index: item ? list.indexOf(item) : null, item: item }
  808. }
  809. this.styleList.clearVoid = ()=>{//清理空的
  810. var length = this.styleList.listDom.children().length;
  811. Array.from(this.styleList.listDom.children()).forEach((e, i)=>{
  812. if(i < length-1){
  813. if(e._styleImg.length == 0) this.styleList.removeItem($(e))
  814. }
  815. })
  816. }
  817. this.styleList.addNew = ()=>{//看是否在最后一行增加新的
  818. var lastOne = this.styleList.listDom.children().last();
  819. if(lastOne[0]._styleImg.length != 0){
  820. this.styleList.addItem(getListItem())
  821. }
  822. }
  823. uploadInput.on("change", (e)=>{
  824. inputMedia({
  825. enableTypes: ["photo"],
  826. photoDone: (resultImg)=>{
  827. editHotStyleInfo.imgs[editHotStyleInfo.index] = {file: resultImg.file, needSave:true, src:resultImg.src}//resultImg
  828. setImgContent(editHotStyleInfo.$li, editHotStyleInfo.index, resultImg.src)
  829. if (editHotStyleInfo.index == 0){
  830. editHotStyleInfo.$li.find('li').eq(1).removeClass("hide");
  831. }
  832. //resultImg.needSave = true
  833. editHotStyleInfo.$li[0].sameTexSpots.forEach(hot=>{
  834. hot.changeTex(editHotStyleInfo.$li[0]._styleImg)
  835. })
  836. if(editHotStyleInfo.$li.hasClass('selected')){//是当前spot的
  837. this.styleList.options.selectFun()//更新选中状态
  838. }
  839. this.styleList.addNew()
  840. }
  841. }, "photo", e);
  842. })
  843. $("#hotpointDetail .style .MenuOptions li").on("click", (e)=>{ //切换是默认还是自定义
  844. var currStyle = $(e.target).attr("index")
  845. if (currStyle == "default") {
  846. $("#spotTexSelect").addClass("hide")
  847. $("#hotpointDetail .style label").addClass("hide")
  848. editTool.hotpoint.editSpot.changeTex([])
  849. } else {
  850. this.styleList.options.selectFun()
  851. $("#hotpointDetail .style label").removeClass("hide")
  852. $("#spotTexSelect").removeClass("hide")
  853. }
  854. })
  855. }
  856. Hotpoint.prototype.initStyle = function(hot) { //每次开始编辑热点时更新样式
  857. if (!hot.styleImg)
  858. hot.styleImg = [];
  859. this.styleList.clearVoid();
  860. if(hot.styleImg.length){
  861. var info = this.styleList.findChosenByImgs(hot.styleImg)
  862. var chosenIndex = info.index
  863. this.styleList.selectFromOutSide(chosenIndex)
  864. $("#hotpointDetail .style .MenuOptions li").eq(1).click();
  865. }else{
  866. this.styleList.selectFromOutSide(null)
  867. $("#hotpointDetail .style .MenuOptions li").eq(0).click()
  868. }
  869. this.styleList.saveTemp()
  870. }
  871. /**
  872. * 显示编辑热点的窗口和初始化热点窗口的数据
  873. */
  874. Hotpoint.prototype.editHot = function(hot, $li) {
  875. this.hotpointDetail.removeClass("atRight");
  876. $("#hotpointDetail .audio.mediaUpload").find("input").val('');
  877. // 点击编辑导览清空上一次文件
  878. var playIcon = 'images/play.png';
  879. var $layout = $("#hotpointDetail")[0];
  880. //$layout.targetDOM = target.closest("li")[0];
  881. //closest匹配选择器的第一个祖先元素
  882. //编辑时将热点列表唯一标识带入,以便后期保存使用识别
  883. //var li_id = $li.attr("data-spid");
  884. this.editSpot = hot
  885. this.hotpointDetail.attr("data-id", hot.sid);
  886. var info = this.editSpot.infoAttribute || {}
  887. //$layout.targetDOM.infoAttribute || {}
  888. $(".MenuOptions[name='transform'] li[index='translate']").click()//transformControls.transCtlChangeMode("translate")
  889. // 参数初始化
  890. info.title = info.title || '';
  891. info.content = info.content || '';
  892. info.iframe = info.iframe || [];
  893. info.model = info.model || [];
  894. info.images = info.images || [];
  895. info.video = info.video || [];
  896. info.isSprite = this.editSpot.isSprite
  897. info.actionType = this.editSpot.actionType
  898. info.linkType = this.editSpot.linkType
  899. info.transformAtPanos = {}
  900. for(var i in this.editSpot.transformAtPanos){
  901. info.transformAtPanos[i] = {
  902. pos : this.editSpot.transformAtPanos[i].pos.clone(),
  903. qua : this.editSpot.transformAtPanos[i].qua && this.editSpot.transformAtPanos[i].qua.clone(),
  904. }
  905. }
  906. try {
  907. transformControls.attach(hot.mesh)
  908. if(player.mode == 'panorama'){
  909. hot.examine(player, {
  910. dontOpen: true,
  911. aimDuration : 600,
  912. duration : 600
  913. })
  914. }else{
  915. player.focusPoint({aim: hot.position, radius:hot.position.distanceTo(player.position)})
  916. }
  917. info.position = hot.position.clone()
  918. info.quaternion = hot.quaternion.clone()
  919. } catch (e) {}
  920. this.updatePano()
  921. this.initStyle(hot);
  922. if(hot.infoAttribute.hotIconScale){
  923. $("#hotpointDetail .scale .MenuOptions li[index=user]").click()
  924. }else $("#hotpointDetail .scale .MenuOptions li[index=default]").click()
  925. $("#hotpointDetail .MenuOptions[name='linkType'] li").removeClass("chosen")
  926. $("#hotpointDetail .MenuOptions[name='actionType'] li").removeClass("chosen")
  927. $("#hotpointDetail .MenuOptions[name='linkType'] li[index = " + this.editSpot.linkType+"]").addClass("chosen")
  928. $("#hotpointDetail .MenuOptions[name='actionType'] li[index = " + this.editSpot.actionType+"]").addClass("chosen")
  929. $("#isSprite")[0].checked = this.editSpot.isSprite
  930. //$("#noAction")[0].checked = this.editSpot.noAction
  931. var iframesHTML = info.iframe.map(function(iframe) {
  932. return this.inputList("请填写网页链接", iframe)
  933. }
  934. .bind(this))
  935. var modulesHTML = info.model.map(function(module) {
  936. return this.inputList("请填写网页链接", module)
  937. }
  938. .bind(this))
  939. var imagesHTML = info.images.map(function(image) {
  940. return '<div><a class=" result success" data-type="photo"><span></span><img src="' + image + '" class="bg"></a></div>'
  941. })
  942. var videosHTML = info.video.map(function(ly) {
  943. //var imgDom = (!ly.img || ly.img === "undefined") ? '' : 'success';
  944. //var imgUrl = (!ly.img || ly.img === "undefined") ? playIcon : ly.img;
  945. //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>'
  946. var thumb = (!ly.img || ly.img === "undefined") ? '' : '<img src='+ ly.img +' class="bg"></img>'
  947. var thumbResult = (!ly.img || ly.img === "undefined") ? '' : 'success';
  948. 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>'
  949. return dom
  950. })
  951. this.hotpointDetail.find(".name > input").val(info.title);
  952. this.hotpointDetail.find(".editText").val(info.content);
  953. this.hotpointDetail.find(".photo .list").html(imagesHTML);
  954. this.hotpointDetail.find(".video .list").html(videosHTML);
  955. this.hotpointDetail.find(".model .list").html(modulesHTML);
  956. this.hotpointDetail.find(".webPage .list").html(iframesHTML);
  957. let bgName = info.bgName || '热点背景音乐';
  958. if (info.backgroundMusic) {
  959. /* this.hotpointDetail.find(".audio .playBox").removeClass("hide");
  960. this.hotpointDetail.find("#upload-hotBgm").attr('data-hotBgm', info.backgroundMusic)
  961. this.hotpointDetail.find(".audio .playBox a").attr("href", info.backgroundMusic);
  962. this.hotpointDetail.find('#hotBgName')[0].innerHTML = bgName;
  963. this.hotpointDetail.find(".audio .submit").text("替换"); */
  964. this.musicBox.show(this.hotpointDetail.find(".audio.mediaUpload"), bgName, info.backgroundMusic)
  965. } else {
  966. this.musicBox.hide()
  967. /* this.hotpointDetail.find(".audio .playBox").addClass("hide");
  968. this.hotpointDetail.find("#upload-hotBgm").removeAttr('data-hotBgm') */
  969. // 没有背景音乐,则移除该属性, 避免其他热点的干扰
  970. }
  971. // $layout.targetDOM.infoAttribute = info
  972. this.editSpot.infoAttribute = info
  973. }
  974. //添加图片和视频
  975. Hotpoint.prototype.addmedia = function() {
  976. // 视频预览控制
  977. var $videoLayout = $('.fun-view-video')
  978. $videoLayout.find('span').on('click', function() {
  979. $videoLayout.hide();
  980. $videoLayout.find('video').attr('src', '')[0].pause()
  981. });
  982. // 图片加载回调
  983. function imageSuccess(file) {
  984. if (!/image\/\w+/.test(file.type)) {
  985. alert("文件必须为图片!");
  986. return false;
  987. }
  988. if (!restrictedSize(file, 9)) {
  989. return false;
  990. }
  991. var img = new Image()
  992. img.src = URL.createObjectURL(file);
  993. img.className = 'bg'
  994. return img
  995. }
  996. // 视频加载回调
  997. function videoSuccess(file, $elayout) {
  998. if (!/video\/\w+/.test(file.type)) {
  999. alert("视频必须为map4格式!");
  1000. return false;
  1001. }
  1002. $elayout.append('<span class="upload-thum">上传封面<i><input type="file" accept="image/*"></i></span>')
  1003. return '<img src="./images/play.png" class="play-video" videoURL="' + URL.createObjectURL(file) + '">'
  1004. }
  1005. // 视频封面回调
  1006. function thumbSuccess(file, $elayout, $seft) {
  1007. if (!/image\/\w+/.test(file.type)) {
  1008. alert("文件必须为图片!");
  1009. return false;
  1010. }
  1011. if (!restrictedSize(file, 2)) {
  1012. return false;
  1013. }
  1014. var img = $seft.closest('div').find('img.bg');
  1015. if(!img[0]){
  1016. img = $("<img class='bg'></img>");
  1017. $seft.closest('div').find('a').append(img)
  1018. }
  1019. img.attr('src', URL.createObjectURL(file));
  1020. $seft.closest('span').removeClass("success")
  1021. }
  1022. // 图片与视频加载
  1023. function fileHandle() {
  1024. var $seft = $(this) //input
  1025. var file = this.files[0];
  1026. var type = this.activeElem ? this.activeElem.attr('data-type') : $seft.parent().attr('data-type');
  1027. var $din = $(document.createElement('div'));
  1028. var fnc = type === 'photo' ? imageSuccess : type === 'video' ? videoSuccess : thumbSuccess //再次传都会是thumSuccess
  1029. var $dom = fnc(file, $din, $seft)
  1030. if (type === 'photo' || type === 'video') {
  1031. if (!$dom)
  1032. return $seft.val('');
  1033. if(!this.activeElem){//创建新的item
  1034. var $layout = $seft.closest("li");
  1035. var $addLayout = $(document.createElement('a'));
  1036. $addLayout.attr("data-type", type)
  1037. var $close = $(document.createElement('span'));
  1038. $addLayout[0].file = file;
  1039. $addLayout.append($close);
  1040. $addLayout.append($dom);
  1041. $addLayout.addClass("result");
  1042. $din.prepend($addLayout);
  1043. $layout.find('.edit-fun-images').append($din);
  1044. }else{//重传
  1045. if (type === 'photo'){
  1046. this.activeElem.find("img.bg").remove();
  1047. }else{
  1048. this.activeElem.find(".play-video").remove();
  1049. }
  1050. this.activeElem.removeClass("success")
  1051. this.activeElem.append($dom)
  1052. this.activeElem[0].file = file;
  1053. this.value = ''
  1054. }
  1055. }
  1056. if (searchParent($seft[0], {
  1057. id: 'shareImgUpload'
  1058. })) {
  1059. //信息页面的分享图片
  1060. $("#shareImgUpload").addClass("hide")
  1061. }else if(searchParent($seft[0], {
  1062. id: 'SpotStyle'
  1063. })){
  1064. $("#SpotStyle").addClass("hide")
  1065. }
  1066. }
  1067. //用于重传的input
  1068. var imgInput = $("<input accept='image/*' type='file'></input>")
  1069. var videoInput = $("<input accept='video/*' type='file'></input>")
  1070. // 图片与视频加载
  1071. $('.upload, .edit-fun-images').on('change', function(ev) {
  1072. if (ev.target.tagName.toUpperCase() === 'INPUT') {
  1073. ev.target.files.length && fileHandle.call(ev.target)
  1074. }
  1075. })
  1076. imgInput.on('change', (ev)=>{fileHandle.call(ev.target)})
  1077. videoInput.on('change', (ev)=>{fileHandle.call(ev.target)})
  1078. $('.edit-fun-images').on('click', function(ev) {//点击item时
  1079. var $tag = $(ev.target)
  1080. var tagName = ev.target.tagName.toUpperCase()
  1081. if (tagName === 'SPAN') {
  1082. if (searchParent($tag[0], {
  1083. className: 'forShareImg'
  1084. })) {
  1085. //信息页面的分享图片
  1086. $("#shareImgUpload").removeClass('hide')
  1087. }else if(searchParent($tag[0], {
  1088. className: 'SpotStyle'
  1089. })){
  1090. $("#SpotStyle").removeClass('hide')
  1091. }
  1092. $tag.parent().parent().remove()
  1093. }else if (tagName === 'IMG' && $tag.hasClass('play-video')) {
  1094. $videoLayout.css('display', 'flex').find('video').attr('src', $tag.attr('videoURL'))[0].play()
  1095. }else{// 替换
  1096. var a = searchParent($tag[0], {
  1097. tagName: 'a'
  1098. })
  1099. if(a) {
  1100. var input
  1101. if(searchParent($tag[0], {
  1102. className: 'video'
  1103. })){
  1104. input = videoInput
  1105. }else{
  1106. input = imgInput
  1107. }
  1108. input[0].activeElem = $(a)
  1109. input.click()
  1110. }
  1111. }
  1112. })
  1113. }
  1114. //选择热点的样式
  1115. Hotpoint.prototype.active = function() {
  1116. $(".hotStyle-item li").on('click', function() {
  1117. $(this).addClass('active').siblings().removeClass('active');
  1118. })
  1119. }
  1120. //当前处于的状态,比如是否是添加热点的状态
  1121. Hotpoint.prototype.state = function(that, Hot) {
  1122. if (g_HotStatus === "add") {
  1123. //console.log(Hot)
  1124. this.addHot(that, Hot, (hot)=>{
  1125. this.addHotList(hot);
  1126. }
  1127. );
  1128. }
  1129. }
  1130. Hotpoint.prototype.updateNumDisplay = function() {
  1131. this.spotList.find("i").text(this.spotList.find("ul li").length);
  1132. }
  1133. //删除热点
  1134. Hotpoint.prototype.removeHot = function(hot, $li ) {
  1135. hot.dispose();
  1136. delete player.model.hots[hot.sid]
  1137. $li.remove();
  1138. this.updateNumDisplay()
  1139. }
  1140. //添加热点模型
  1141. Hotpoint.prototype.addHot = function(that, Hot, fn) {
  1142. if (!window.hotIntersect)
  1143. return;
  1144. // 没有正确的热点位置, return
  1145. var position = hotIntersect.point.toArray();
  1146. //var sid = g_HotMeshes.length > 0 ? "sprite_" + (parseInt(g_HotMeshes[g_HotMeshes.length - 1].name.substring(7)) + 1) : "sprite_" + g_HotMeshes.length;//这么写出bug了。因为当前热点名字不是按照从小到大
  1147. var sid = getRandomSid()
  1148. var hot = new Hot(sid,{
  1149. position: position,
  1150. rotation: [0, 0, 0],
  1151. size: 1.05
  1152. },that.model);
  1153. that.model.hots[sid] = hot;
  1154. if (player.getMouseDirection().angleTo(window.hotIntersect.face.normal) < Math.PI / 2) {
  1155. hot.mesh.lookAt(window.hotIntersect.face.normal.clone().negate().add(hotIntersect.point));
  1156. hot.mesh.position.add(window.hotIntersect.face.normal.clone().negate().multiplyScalar(0.01))
  1157. //avoid mesh crash with chunks 模型的精度可能和floorplan的不一样,所以chunk即使材质经过处理还是会闪烁但是wallmesh不会
  1158. } else {
  1159. hot.mesh.lookAt(window.hotIntersect.face.normal.clone().add(hotIntersect.point));
  1160. hot.mesh.position.add(window.hotIntersect.face.normal.clone().multiplyScalar(0.01))
  1161. }
  1162. hot.quaternion.copy(hot.mesh.quaternion)
  1163. hot.position.copy(hot.mesh.position)
  1164. g_HotStatus = false;
  1165. that.mouseCouldBeClickToMove = false;
  1166. $("#player").css("cursor", "");
  1167. //添加完热点之后的回调函数
  1168. if (g_HotMeshes && g_newHot.length === g_newHot.length++) {
  1169. var thisScene = that;
  1170. //fn && fn.call(this, thisScene);
  1171. fn && fn(hot)
  1172. }
  1173. }
  1174. //添加热点列表
  1175. Hotpoint.prototype.addHotList = function(hot) {
  1176. var li = $("<li class='listItem' data-spid=" + hot.sid + ">" + "<div class=icon></div>" + "<div class=number title=热点>" + (++_hotNum) + "</div>" + "<div class=title title=热点>" + (hot.infoAttribute && hot.infoAttribute.title || "") + "</div>" + "<div class=DelConfirm>确定删除</div>" + "<div class=del></div>" + "</li>");
  1177. li.hot = hot
  1178. $(".spotList ul").append(li);
  1179. this.updateNumDisplay()
  1180. }
  1181. //添加热点音乐
  1182. Hotpoint.prototype.addMusicInit = function() {
  1183. /* var mediaUpload = $("#hotpointDetail .audio.mediaUpload");
  1184. mediaUpload.find("input").on("change", function() {
  1185. var file = this.files[0];
  1186. mediaUpload.find(".innerBtn").text("替换");
  1187. mediaUpload.find(".playBox").removeClass("hide");
  1188. mediaUpload.find(".title").text(file.name);
  1189. mediaUpload.find('#query-bgm').attr('href', URL.createObjectURL(file));
  1190. });
  1191. //删除音乐
  1192. mediaUpload.on("click", ".delete", function() {
  1193. mediaUpload.find('#query-bgm').attr('href', "");
  1194. mediaUpload.find(".playBox").addClass("hide");
  1195. mediaUpload.find(".innerBtn").text("上传");
  1196. mediaUpload.find("input").val("").removeAttr("data-hotbgm");
  1197. }) */
  1198. this.musicBox = musicPlayBoxBind($("#hotpointDetail .audio.mediaUpload"), null )
  1199. }
  1200. //添加热点模型列表dom
  1201. Hotpoint.prototype.inputList = function(text, val) {
  1202. var _val = '';
  1203. if (arguments[1]) {
  1204. _val = 'value=' + val;
  1205. }
  1206. return '<div class="link"> <input class="text" type="text" placeholder=' + text + ' spellcheck="false" ' + _val + ' > </div>'
  1207. }
  1208. //添加热点模型
  1209. Hotpoint.prototype.addModel = function() {
  1210. var text = this.inputList("请填写模型链接");
  1211. this.hotpointDetail.find(".model .add").on('click', function() {
  1212. $(this).closest(".model").find(".list").append(text)
  1213. });
  1214. this.hotpointDetail.find(".model .delete").on('click', function() {
  1215. $(this).closest(".model").find(".list > div:last").remove();
  1216. });
  1217. }
  1218. //添加网页链接
  1219. Hotpoint.prototype.addwebPack = function() {
  1220. var text = this.inputList("请填写网页链接", "");
  1221. this.hotpointDetail.find(".webPage .add").on('click', function() {
  1222. $(this).closest(".webPage").find(".list").append(text)
  1223. });
  1224. this.hotpointDetail.find(".webPage .delete").on('click', function() {
  1225. $(this).closest(".webPage").find(".list > div:last").remove();
  1226. });
  1227. }
  1228. // 保存热点信息
  1229. Hotpoint.prototype.saveHot = function() {
  1230. var $layout = $(".edit-loading");
  1231. var hotpointDetail = this.hotpointDetail;
  1232. var that = this
  1233. //获取唯一标识
  1234. var spot_id = hotpointDetail.attr("data-id");
  1235. var spot = this.spotList.find("li[data-spid=" + spot_id + "]");
  1236. var hot = player.model.hots[spot_id];
  1237. //显示loading
  1238. $layout.removeClass('hide');
  1239. var args = {};
  1240. //热点标题
  1241. var $title = hotpointDetail.find(".info input");
  1242. //热点内容
  1243. var $content = hotpointDetail.find(".info textarea");
  1244. //热点图片
  1245. var $images = hotpointDetail.find(".photo .edit-fun-images a.result");
  1246. //热点视频
  1247. var $videos = hotpointDetail.find(".video .edit-fun-images a.result");
  1248. //热点视频的图片
  1249. var $thums = hotpointDetail.find(".video .edit-fun-images .upload-thum");
  1250. //热点模型
  1251. var $modules = hotpointDetail.find(".model input");
  1252. //热点内嵌网页
  1253. var $iframes = hotpointDetail.find(".webPage input.text");
  1254. //热点音乐
  1255. var $miusc = hotpointDetail.find("#upload-hotBgm");
  1256. let $bgName = hotpointDetail.find('.title');
  1257. var promise = new Promise(function(resolve, reject) {
  1258. //获取图片路径
  1259. upload($images, 'images', resolve)
  1260. }).then(function(imgUrls) {
  1261. args.images = imgUrls
  1262. //获取视频路径
  1263. return new Promise(function(resolve, reject) {
  1264. upload($videos, 'videos', resolve)
  1265. }
  1266. )
  1267. }).then(function(videoUrls) {
  1268. args.video = videoUrls
  1269. //获取视频封面路径
  1270. return new Promise(function(resolve, reject) {
  1271. upload($thums, 'images', resolve)
  1272. }
  1273. )
  1274. }).then(function(thums) {
  1275. args.video = args.video.map(function(video, index) {//整合视频+封面
  1276. return {
  1277. url: video,
  1278. img: thums[index]
  1279. }
  1280. })
  1281. }).then(function() {
  1282. //获取热点音乐所有的路径
  1283. //console.log($miusc)
  1284. if ($miusc[0].files.length > 0) {
  1285. return new Promise(function(resolve) {
  1286. upload($miusc, 'miusc', function(res) {
  1287. resolve(res[0])
  1288. })
  1289. }
  1290. )
  1291. } else {
  1292. return $miusc.attr('data-hotBgm')
  1293. }
  1294. }).then(function(src) {
  1295. if(that.musicBox.hasMusic && !src){
  1296. args.backgroundMusic = hot.infoAttribute.backgroundMusic
  1297. args.bgName = hot.infoAttribute.bgName
  1298. }else{
  1299. args.backgroundMusic = src
  1300. args.bgName = $bgName[0].innerHTML;
  1301. }
  1302. }).then(function() {
  1303. //上传所有热点的style图片
  1304. var a = $.Deferred();
  1305. var doneNum = 0;
  1306. var imgsNeedSave = [];
  1307. Array.from(that.styleList.listDom.children()).forEach(li=>{
  1308. if(li.sameTexSpots.length == 0)return;//没被热点用到就不保存
  1309. li.sameTexSpots.forEach(spot=>spot.styleImg = li._styleImg)//同步下
  1310. li._styleImg.forEach(img=>{
  1311. if(img.needSave && !imgsNeedSave.includes(img)){
  1312. imgsNeedSave.push(img)
  1313. }
  1314. })
  1315. })
  1316. if(imgsNeedSave.length){
  1317. imgsNeedSave.forEach(img=>{
  1318. uploadFile(img.file, 'hot/image', function(rs) {
  1319. if (rs.code === 0) {
  1320. img.needSave = false;
  1321. //img.saveURL = rs.data;
  1322. img.src = rs.data;
  1323. if (++doneNum >= imgsNeedSave.length) {
  1324. a.resolve();
  1325. }
  1326. } else {
  1327. alert("样式图上传失败");
  1328. a.reject();
  1329. }
  1330. })
  1331. })
  1332. return a.promise()
  1333. }else{
  1334. return a.resolve()
  1335. }
  1336. }).then(function() {
  1337. //获取热点标题、内容、内嵌网页、模型网页。
  1338. args.title = $title.val()
  1339. args.content = $content.val()
  1340. var iframes = []
  1341. for (var i = 0; i < $iframes.length; i++) {
  1342. var iframe = $iframes.eq(i).val()
  1343. iframe && iframes.push(iframe)
  1344. }
  1345. args.iframe = iframes
  1346. var modules = []
  1347. for (var i = 0; i < $modules.length; i++) {
  1348. var module = $modules.eq(i).val()
  1349. module && modules.push(module)
  1350. }
  1351. args.model = modules
  1352. if(!hot.isSprite){
  1353. args.quaternion = hot.quaternion.clone()
  1354. //hot.quaternion.copy(hot.mesh.quaternion)
  1355. }
  1356. args.position = hot.position.clone()
  1357. //hot.position.copy(hot.mesh.position)
  1358. return args
  1359. }).then(function(args) {
  1360. console.log(args);
  1361. //把获取的所有信息都保存在对应热点的dom元素里面
  1362. //hotpointDetail[0].targetDOM.infoAttribute = args;
  1363. if($("#hotpointDetail .scale .MenuOptions li.chosen").attr('index') == 'user' ){
  1364. args.hotIconScale = $("#hotIconScale_2 input").val();
  1365. }else{
  1366. delete args.hotIconScale
  1367. }
  1368. hot.infoAttribute = args;
  1369. for(let i in player.model.hots){//修改所有的热点贴图数据
  1370. let hot = player.model.hots[i];
  1371. let li = that.styleList.findChosenByImgs(hot.styleImg).item
  1372. if(li) hot.infoAttribute.styleImg = li._styleImg.map(img=> img.src)//将blob更换成线上链接
  1373. }
  1374. hot.setTitleElem()//更新名称
  1375. $layout.addClass('hide');
  1376. hotpointDetail.addClass("atRight");
  1377. spot.find(".title").html(args.title);
  1378. transformControls.detach()
  1379. that.editSpot = null
  1380. })
  1381. return promise
  1382. }
  1383. //背景音乐
  1384. var EditMiuse = function() {
  1385. this.mediaUpload = $(".music .audio.mediaUpload");
  1386. this.musicBox = musicPlayBoxBind(this.mediaUpload, (file)=>{
  1387. uploadMiuse(file, (rs, file)=>{
  1388. if (rs.code === 0) {
  1389. this.musicBox.show(this.mediaUpload, file.name, rs.data)
  1390. }else{
  1391. this.musicBox.hide()
  1392. }
  1393. })
  1394. }, null)
  1395. /* this.success = function(text, url) {
  1396. this.mediaUpload.find(".innerBtn").text("替换");
  1397. this.mediaUpload.find(".playBox").removeClass("hide");
  1398. this.mediaUpload.find(".title").text(text);
  1399. this.mediaUpload.find('#query-bgm').attr('href', url)
  1400. }
  1401. ;
  1402. this.delete = function() {
  1403. this.mediaUpload.find('#query-bgm').attr('href', "");
  1404. this.mediaUpload.find(".playBox").addClass("hide");
  1405. this.mediaUpload.find(".innerBtn").text("上传");
  1406. this.mediaUpload.find("input").val("");
  1407. }
  1408. ;
  1409. var that = this;
  1410. $('#upload-bgm').on('change', function(e) {
  1411. var file = this.files[0];
  1412. uploadMiuse(file, function(rs, file) {
  1413. if (rs.code === 0) {
  1414. that.success(file.name, rs.data)
  1415. }
  1416. })
  1417. e.target.value = null
  1418. });
  1419. //删除音乐
  1420. this.mediaUpload.on("click", ".delete", function() {
  1421. that.delete();
  1422. }) */
  1423. }
  1424. EditMiuse.prototype.init = function(data) {
  1425. if (!data.backgroundMusic)
  1426. return;
  1427. this.musicBox.show(this.mediaUpload, data.bgName || "backgound", data.backgroundMusic);
  1428. }
  1429. //导览编辑
  1430. var EditGuide = function() {
  1431. this.$list = $('#guide-list')
  1432. //$('#tourItemEdit') = $('#tourItemEdit');
  1433. this.targetTourPoint = null;
  1434. // fyz 记录当前编辑的导览点
  1435. // fyz 导览音乐队列
  1436. //this.tourAudio = {};
  1437. }
  1438. /**
  1439. * @author fyz 2019.07.31
  1440. * @description 新增参数data2, 表示data2.js中的数据
  1441. */
  1442. /* function snapATourView(that, renew) {
  1443. var ev = document.createEvent("MouseEvent");
  1444. ev.initMouseEvent("snapshotBegin", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  1445. g_snapShotWidth = 200;
  1446. g_snapShotHeight = 140;
  1447. window.screenSta = 'tour';
  1448. // 记录当前哪个功能截屏, 因为导览截屏需要做额外的校对调整, 初始画面截屏不需要
  1449. ev.__callback = function(imgData, info) {
  1450. that.uploadGuide(imgData, info, renew, that.targetTourPoint)
  1451. }.bind(that);
  1452. window.dispatchEvent(ev);
  1453. } */
  1454. EditGuide.prototype.snapATourView = function(renew, insideFolder){
  1455. var ev = document.createEvent("MouseEvent");
  1456. ev.initMouseEvent("snapshotBegin", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  1457. g_snapShotWidth = 200;
  1458. g_snapShotHeight = 140;
  1459. window.screenSta = 'tour';
  1460. // 记录当前哪个功能截屏, 因为导览截屏需要做额外的校对调整, 初始画面截屏不需要
  1461. ev.__callback = (imgData, info)=> {
  1462. this.uploadGuide(imgData, info, renew, insideFolder)
  1463. };
  1464. window.dispatchEvent(ev);
  1465. }
  1466. EditGuide.prototype.init = function(data, data2) {
  1467. this.createDom(data, data2);
  1468. //this.tourAudio = data2.tourAudio || {};
  1469. var that = this;
  1470. //点击添加导览
  1471. $('.addTour .innerBtn').eq(0).on("click", function () {
  1472. this.addFolderDom({name:"区域"+($("#tourList .listItem").length+1) } );//点击增加一段导览
  1473. $("#tourList ul")[0].scrollTop = $("#tourList ul")[0].scrollHeight //scroll to bottom
  1474. }.bind(this));
  1475. $('.addTour .innerBtn').eq(1).on("click", function () {
  1476. this.snapATourView()//点击截取视图
  1477. $("#tourList ul")[0].scrollTop = $("#tourList ul")[0].scrollHeight
  1478. }.bind(this));
  1479. $('.snapATourView .innerBtn').on("click", function() {
  1480. this.snapATourView(null,true);//folder内点击截取视图
  1481. $("#tourItemList ul")[0].scrollTop = $("#tourItemList ul")[0].scrollHeight
  1482. }.bind(this));
  1483. $('#renewTourBtn').on("click", function() { // 重新截取视图
  1484. this.snapATourView(this, !!this.editingFolderLi);
  1485. }.bind(this));
  1486. // 确认并保存导览信息
  1487. $('#tourFolderEdit .tourSubmit').on("click", function() {
  1488. this.completeFolder();
  1489. }.bind(this));
  1490. $('#tourItemEdit .tourSubmit').on("click", function() {
  1491. this.completeItem();
  1492. }.bind(this));
  1493. //点击导览编辑窗口右上角的关闭按钮
  1494. /* $("#tourItemEdit a.close, button.cancel").on("click", function() {
  1495. that.targetTourPoint[0].musicSta = true; ///??????????
  1496. // 取消操作, 重置状态
  1497. that.tourDetail.addClass("atRight");
  1498. }); */
  1499. //导览目录
  1500. $("#tourList").on("click", function(e) {
  1501. var target = $(e.target);
  1502. let folder = searchParent(e.target, { className: 'listItem' }, 7);
  1503. if(!folder)return;//可能点到了item
  1504. if (target.hasClass("del")) {
  1505. e.stopPropagation();
  1506. target.siblings(".DelConfirm").addClass("active");
  1507. } else {
  1508. if (target.hasClass("DelConfirm")) {
  1509. e.stopPropagation();
  1510. $(folder).remove()
  1511. //that.removeFolder(folder);//删除
  1512. } else {
  1513. if (target.hasClass("title") || target.hasClass("icon")) {
  1514. that.editFolder(folder)//编辑
  1515. }
  1516. }
  1517. }
  1518. });
  1519. //编辑item
  1520. $('.tourList ul').on('click', function(e) {
  1521. var target = $(e.target);
  1522. let itemDom = searchParent(e.target, { className: 'guideItem' }, 7);
  1523. if(!itemDom)return;//可能点到了folder
  1524. if(searchParent(e.target, { className: 'preview' })){
  1525. var choice = confirm("你确定删除吗?");
  1526. if (choice) {
  1527. var ul = searchParent(e.target, { className: 'tourList' })
  1528. target.closest('li').remove();
  1529. reIndexTourList(ul)
  1530. } else {
  1531. return false
  1532. }
  1533. }else{
  1534. that.editItem(itemDom);
  1535. }
  1536. })
  1537. //fyz 拖拽以改变顺序
  1538. let tourListNode = $("#tourList>ul")[0];
  1539. let tourItemListNode = $("#tourItemList>ul")[0];
  1540. let draging = null;
  1541. let dragStart = (event)=> {
  1542. event.dataTransfer.setData("te", event.target.innerText); //不能使用text,firefox会打开新tab
  1543. draging = event.target;
  1544. }
  1545. let dragOver = (event)=>{
  1546. event.preventDefault();
  1547. let target = searchParent(event.target, { tagName: 'LI' }, 7); //event.target.parentNode.parentNode;
  1548. // 判断dragover是否发生在LI元素上
  1549. if ((target.classList.contains('guideItem') || target.classList.contains('listItem')) && target !== draging ) {
  1550. let dragingIndex = $(draging).index()//draging.querySelector('#index');
  1551. let targetIndex = $(target).index()//target.querySelector('#index');
  1552. var targetRect = target.getBoundingClientRect();
  1553. var dragingRect = draging.getBoundingClientRect();
  1554. if (target && target.animated) {
  1555. return;
  1556. }
  1557. let ulElem = target.parentNode;
  1558. // 寻找到 ul节点
  1559. if (getIndex(draging) < getIndex(target)) {
  1560. //dragingIndex.innerText = [targetIndex.innerText, targetIndex.innerText = dragingIndex.innerText][0];
  1561. // 交换两个节点的序号
  1562. if(event.clientY<targetRect.top+targetRect.height*0.3)return
  1563. ulElem.insertBefore(draging, target.nextSibling);
  1564. //dragingIndex.innerText = [targetIndex.innerText, targetIndex.innerText = dragingIndex.innerText][0];// 交换两个节点的序号
  1565. } else {
  1566. //dragingIndex.innerText = [targetIndex.innerText, targetIndex.innerText = dragingIndex.innerText][0];
  1567. if(event.clientY>targetRect.bottom-targetRect.height*0.3)return
  1568. ulElem.insertBefore(draging, target);
  1569. //dragingIndex.innerText = [targetIndex.innerText, targetIndex.innerText = dragingIndex.innerText][0];
  1570. }
  1571. _animate(dragingRect, draging);
  1572. _animate(targetRect, target);
  1573. var ul = searchParent(event.target, { className: 'tourList' })
  1574. reIndexTourList(ul)
  1575. }
  1576. }
  1577. tourListNode.ondragstart = dragStart
  1578. tourItemListNode.ondragstart = dragStart
  1579. tourListNode.ondragover = dragOver
  1580. tourItemListNode.ondragover = dragOver
  1581. //音乐
  1582. this.musicBox = musicPlayBoxBind($(".snapTour .audio.mediaUpload"), null, ()=>{
  1583. (that.editingFolderLi || that.editingItemLi).tourData.musicInfo = {}//直接删除 不可逆
  1584. })
  1585. /*
  1586. var mediaUpload = $(".snapTour .audio.mediaUpload");
  1587. var that = this;
  1588. mediaUpload.find("input").on("change", function(e) {
  1589. if(!e.target.files.length) return;
  1590. var mediaDom = $(searchParent(e.target, { className: 'mediaUpload' }));
  1591. var file = e.target.files[0];
  1592. mediaDom.find(".innerBtn").text("替换");
  1593. mediaDom.find(".playBox").removeClass("hide");
  1594. mediaDom.find(".title").text(file.name);
  1595. mediaDom.find('#query-bgm').attr('href', URL.createObjectURL(file));
  1596. //that.editingFolderLi.musicSta = true;
  1597. });
  1598. mediaUpload.find("input").on("click", function() {
  1599. mediaUpload
  1600. });
  1601. //删除音乐
  1602. mediaUpload.on("click", ".delete", function(e) {
  1603. var mediaDom = $(searchParent(e.target, { className: '.mediaUpload' }));
  1604. mediaDom.find('#query-bgm').attr('href', "");
  1605. mediaDom.find(".playBox").addClass("hide");
  1606. mediaDom.find(".innerBtn").text("上传");
  1607. mediaDom.find("input").val("")//.removeAttr("data-hotbgm");
  1608. //that.editingFolderLi.musicSta = false;
  1609. (that.editingFolderLi || that.editingItemLi).data.musicInfo = {}//直接删除 不可逆
  1610. }) */
  1611. }
  1612. function musicPlayBoxBind($dom, addCallback, delCallback){
  1613. var musicBox = {
  1614. hasMusic:false,
  1615. show: function(mediaDom, name, url){
  1616. mediaDom = mediaDom || $dom
  1617. mediaDom.find(".innerBtn").text("替换");
  1618. mediaDom.find(".playBox").removeClass("hide");
  1619. mediaDom.find(".title").text(name);
  1620. mediaDom.find('#query-bgm').attr('href', url);
  1621. musicBox.hasMusic = true
  1622. },
  1623. addMusic : function(e) {
  1624. if(!e.target.files.length) return;
  1625. var file = e.target.files[0];
  1626. if (!/audio\/\w+/.test(file.type)) {
  1627. alert("文件必须为音乐!");
  1628. return false;
  1629. }
  1630. //限制大小不大于8m
  1631. if (!restrictedSize(file, _musicMaxWeight)) {
  1632. return false
  1633. }
  1634. var mediaDom = $(searchParent(e.target, { className: 'mediaUpload' }));
  1635. musicBox.show(mediaDom, file.name, URL.createObjectURL(file))
  1636. addCallback && addCallback(file)
  1637. },
  1638. hide : function(e) {
  1639. var mediaDom = e ? $(searchParent(e.target, { className: 'mediaUpload' })) : $dom
  1640. mediaDom.find('#query-bgm').attr('href', "");
  1641. mediaDom.find(".playBox").addClass("hide");
  1642. mediaDom.find(".innerBtn").text("上传");
  1643. mediaDom.find("input").val("")//.removeAttr("data-hotbgm");
  1644. musicBox.hasMusic = false
  1645. delCallback && delCallback()
  1646. }
  1647. }
  1648. $dom.find("input").on("change", musicBox.addMusic)
  1649. /* $dom.find("input").on("click", function() {
  1650. mediaUpload
  1651. }); */
  1652. //删除音乐
  1653. $dom.on("click", ".delete", musicBox.hide)
  1654. return musicBox;
  1655. }
  1656. function reIndexTourList(ul) {
  1657. Array.from($(ul).find('li.guideItem')).forEach((li,index)=>{
  1658. $(li).find("div:first-child span").text(index + 1);
  1659. })
  1660. }
  1661. EditGuide.prototype.addFolderDom = function( tourData){
  1662. 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>");
  1663. $folder[0].tourItemDoms = [] //记录所有item的li dom
  1664. $folder[0].tourData = tourData //注: data中的locations不会更新,保存时直接读取li
  1665. $("#tourList ul").append($folder);
  1666. return $folder
  1667. }
  1668. EditGuide.prototype.getItemDom = function(title, img) {
  1669. return '<li draggable="true" class="guideItem">' + '<div>' + '<span id="index"></span>' + '<div class="line"></div>' + '</div>' + '<div>' + '<span class="guide-name" >' + title + '</span>' + '<input maxlength="14" class="hide" data-oper=tour-input>' + '</div>' + '<div class="preview" >' + '<div id="tourBg" style="background-image: url(' + img + ');" >' + '</div>' + '</div>' + '</li >';
  1670. }
  1671. EditGuide.prototype.createDom = function(data, data2) {
  1672. var that = this;
  1673. var tourAudio = data2.tourAudio || {};
  1674. data.model.images.forEach((Info,index)=>{
  1675. if(Info.locations){//是folder
  1676. var $folder = this.addFolderDom(Info)
  1677. // 音频链接
  1678. Info.locations = Info.locations.filter(e=>e)
  1679. Info.locations.forEach(function(info, index) {
  1680. if (info.thumbnail_signed_src) {
  1681. var $li = $(that.getItemDom( info.name, info.thumbnail_signed_src));
  1682. $li[0].tourData = info
  1683. $folder[0].tourItemDoms.push($li[0])
  1684. }
  1685. })
  1686. }else{//是散落在外的item
  1687. if (Info.thumbnail_signed_src) {
  1688. var $li = $(that.getItemDom(Info.name, Info.thumbnail_signed_src));
  1689. $li[0].tourData = Info
  1690. // 音频链接
  1691. $li[0].tourData.musicInfo = $li[0].tourData.musicInfo || tourAudio[Info.sid] || {}//新的music数据统一写在每个info下
  1692. $("#tourList ul").append($li)
  1693. /* if (Info.sid in tourAudio && tourAudio[info.sid].music && tourAudio[info.sid].music !== '') {
  1694. //$li[0].musicUrl = tourAudio[info.sid].music;
  1695. $li[0].musicInfo = tourAudio[info.sid]
  1696. } */
  1697. }
  1698. }
  1699. })
  1700. reIndexTourList($("#tourList")[0])
  1701. }
  1702. //暂时不实时更新左侧场景,所以信息全写在UI上,不保存data
  1703. EditGuide.prototype.editFolder = function(folderDom){
  1704. this.editingFolderLi = folderDom;
  1705. $("#tourFolderEdit").removeClass('atRight');
  1706. $("#tourFolderEdit .tourName input").val( $(folderDom).find('.title').text()||'');
  1707. //$("#folderTourSwitch input").prop('checked', folderDom.tourData.momentTour === 'black');
  1708. var momentTour = folderDom.tourData.momentTour || "default"
  1709. $("#folderTourSwitch li").removeClass('chosen')
  1710. $("#folderTourSwitch li[index="+ momentTour +"]").addClass('chosen');
  1711. folderDom.tourItemDoms.forEach(li=>{
  1712. $("#tourItemList>ul").append(li)
  1713. })
  1714. reIndexTourList($("#tourItemList>ul")[0])
  1715. //判断当前点是否有导览音频
  1716. //target[0].musicSta = true;
  1717. //var audio = this.tourAudio[target.closest('li')[0].data.sid];
  1718. var musicInfo = this.editingFolderLi.tourData.musicInfo //audio ? audio.music : null;
  1719. if (musicInfo && musicInfo.music) { // 判断改导览点是否已经已有音乐
  1720. var musicName = musicInfo.name || '导览音频.mp3' // 获取音频的文件名
  1721. /* $('#tourFolderEdit').find(".audio .playBox").removeClass("hide");
  1722. $('#tourFolderEdit').find(".audio .playBox a").attr("href", "//" + musicInfo.music);
  1723. $('#tourFolderEdit').find(".audio .submit").text("替换");
  1724. $('#tourFolderEdit').find(".title").text(musicName); */
  1725. this.musicBox.show($('#tourFolderEdit .mediaUpload'), musicName, "//" + musicInfo.music)
  1726. } else {
  1727. /* $('#tourFolderEdit').find(".audio .playBox").addClass("hide");
  1728. $('#tourFolderEdit').find(".audio .submit").text("上传"); */
  1729. this.musicBox.hide()
  1730. }
  1731. }
  1732. /**
  1733. * @author fyz 编辑单个导览item
  1734. * @param {any} target 所点击的导览点
  1735. */
  1736. EditGuide.prototype.editItem = function(li) {
  1737. //this.targetTourPoint = target;
  1738. this.editingItemLi = li
  1739. // 记录当前编辑的导览点
  1740. var that = this;
  1741. $('#tourItemEdit').removeClass('atRight');
  1742. $('#tourItemEdit .tourName input').val( $(li).find('.guide-name').text() );
  1743. var momentTour = li.tourData.momentTour || "default"
  1744. $("#tourSwitch_Slice li").removeClass('chosen')
  1745. $("#tourSwitch_Slice li[index="+ momentTour +"]").addClass('chosen');
  1746. var metadata = JSON.parse(li.tourData.metadata);
  1747. if(metadata.scan_id != 'outside'){
  1748. var pano = player.model.panos.index[metadata.scan_id]
  1749. if(pano){
  1750. var q = new THREE.Quaternion().copy(metadata.camera_quaternion);
  1751. player.flyToPano({
  1752. pano: pano,
  1753. quaternion: q,
  1754. zoomLevel: metadata.zoom
  1755. })
  1756. }
  1757. }
  1758. if(!this.editingFolderLi){//在外的item, 可以上传音乐
  1759. $('#tourItemEdit .mediaUpload').removeClass('hide')
  1760. var musicInfo = li.tourData.musicInfo //audio ? audio.music : null;
  1761. if (musicInfo && musicInfo.music) { // 判断改导览点是否已经已有音乐
  1762. var musicName = musicInfo.name || '导览音频.mp3' // 获取音频的文件名
  1763. /* $('#tourItemEdit').find(".audio .playBox").removeClass("hide");
  1764. $('#tourItemEdit').find(".audio .playBox a").attr("href", "//" + musicInfo.music);
  1765. $('#tourItemEdit').find(".audio .submit").text("替换");
  1766. $('#tourItemEdit').find(".title").text(musicName); */
  1767. this.musicBox.show($('#tourItemEdit .mediaUpload'), musicName, "//" + musicInfo.music)
  1768. } else {
  1769. this.musicBox.hide()
  1770. /* $('#tourItemEdit').find(".audio .playBox").addClass("hide");
  1771. $('#tourItemEdit').find(".audio .submit").text("上传"); */
  1772. }
  1773. }else{
  1774. $('#tourItemEdit .mediaUpload').addClass('hide')
  1775. }
  1776. }
  1777. EditGuide.prototype.completeFolder = function(){//点击完成
  1778. var tourName = $('#tourFolderEdit .tourName input').val() //|| this.targetTourPoint.context.innerText;
  1779. $(this.editingFolderLi).find(".title").text(tourName)
  1780. //this.editingFolderLi.tourData.momentTour = $("#folderTourSwitch input").is(':checked') ? "black" : 'walk'
  1781. var momentTour = $("#folderTourSwitch li.chosen").attr("index");
  1782. this.editingFolderLi.tourData.momentTour = momentTour != 'default' ? momentTour : null;
  1783. this.editingFolderLi.tourItemDoms = Array.from($('#tourItemList ul li'));
  1784. var done = ()=>{
  1785. $("#tourFolderEdit .audio.mediaUpload").find("input").val(''); // 清空 文件
  1786. this.editingFolderLi = null
  1787. $("#tourFolderEdit").addClass('atRight');
  1788. $(".edit-loading").addClass('hide');
  1789. $("#tourItemList>ul").html('')
  1790. }
  1791. //save导览音乐
  1792. var tourAudio = $('#tourFolderEdit .mediaUpload input');
  1793. // 记录音频名称
  1794. //判断当前编辑的导览点位是否已上传音乐
  1795. if (tourAudio[0].files.length > 0/* && this.targetTourPoint[0].musicSta */) { //有input文件
  1796. $(".edit-loading").removeClass('hide');
  1797. var musicName = $('#tourFolderEdit .mediaUpload .title').text();
  1798. new Promise( (resolve, reject)=> {
  1799. uploadMiuse(tourAudio[0].files[0], function(res) {
  1800. resolve(res.data);
  1801. })
  1802. } ).then( (src)=>{
  1803. var audio = new Audio();
  1804. audio.src = src;
  1805. audio.onloadedmetadata = ()=>{
  1806. var srcArr = src.split('/'); // 对返回的src进行处理, 去掉前面域名, 尽量避免修改main.js
  1807. srcArr[0] = '';
  1808. src = srcArr.join('/');
  1809. //var sid = this.editingFolderLi.data.sid
  1810. //that.tourAudio[sid] = {
  1811. this.editingFolderLi.tourData.musicInfo = {
  1812. "name": musicName,
  1813. "music": '/' + src,
  1814. "time": Math.round(audio.duration * 1000 + 1000)
  1815. }
  1816. done()
  1817. }
  1818. })
  1819. }else done()
  1820. }
  1821. EditGuide.prototype.completeItem = function() {//点击完成
  1822. var done = ()=>{
  1823. $("#tourItemEdit .audio.mediaUpload").find("input").val(''); // 清空 文件
  1824. this.editingItemLi = null
  1825. $("#tourItemEdit").addClass('atRight');
  1826. $(".edit-loading").addClass('hide');
  1827. }
  1828. var tourName = $('#tourItemEdit .tourName input').val()
  1829. $(this.editingItemLi).find('.guide-name').text(tourName)
  1830. var momentTour = $("#tourSwitch_Slice li.chosen").attr("index");
  1831. this.editingItemLi.tourData.momentTour = momentTour != 'default' ? momentTour : null;
  1832. //save导览音乐
  1833. var tourAudio = $('#tourItemEdit .mediaUpload input');
  1834. //判断当前编辑的导览点位是否已上传音乐
  1835. if (!this.editingFolderLi && tourAudio[0].files.length > 0) { //有input文件
  1836. $(".edit-loading").removeClass('hide');
  1837. var musicName = $('#tourItemEdit .mediaUpload .title').text();
  1838. new Promise( (resolve, reject)=>{
  1839. uploadMiuse(tourAudio[0].files[0], function(res) {
  1840. resolve(res.data);
  1841. })
  1842. } ).then( (src)=>{
  1843. var audio = new Audio();
  1844. audio.src = src;
  1845. audio.onloadedmetadata = ()=>{
  1846. var srcArr = src.split('/'); // 对返回的src进行处理, 去掉前面域名, 尽量避免修改main.js
  1847. srcArr[0] = '';
  1848. src = srcArr.join('/');
  1849. //that.tourAudio[sid] = {
  1850. this.editingItemLi.tourData.musicInfo = {
  1851. "name": musicName,
  1852. "music": '/' + src,
  1853. "time": Math.round(audio.duration * 1000 + 1000)
  1854. }
  1855. done()
  1856. }
  1857. })
  1858. }else done()
  1859. }
  1860. /**
  1861. * @author fyz 2019.07.31
  1862. * @description uploadGuide方法新增参数renew状态码, 表示是否重新录制当前导览, 新增targetTourPoint, 记录当前的导览点元素
  1863. */
  1864. EditGuide.prototype.uploadGuide = function(urlData, guide, renew, insideFolder) {
  1865. var that = this;
  1866. uploadImg(urlData, function(rs) {
  1867. if (rs.code === 0) {
  1868. //var editGuide = new EditGuide();
  1869. var sid = rs.data.substring(rs.data.lastIndexOf('/') + 1, rs.data.lastIndexOf('.'));
  1870. var thumbnail_signed_src = rs.data;
  1871. var args = JSON.parse("{" + guide + "}");
  1872. args.sid = sid;
  1873. args.name = '';
  1874. args.thumbnail_signed_src = thumbnail_signed_src;
  1875. args.metadata = JSON.stringify({
  1876. camera_mode: args.metadata.camera_mode,
  1877. camera_position: {
  1878. x: args.metadata.camera_position[0],
  1879. y: args.metadata.camera_position[1],
  1880. z: args.metadata.camera_position[2]
  1881. },
  1882. camera_quaternion: {
  1883. x: args.metadata.camera_quaternion[0],
  1884. y: args.metadata.camera_quaternion[1],
  1885. z: args.metadata.camera_quaternion[2],
  1886. w: args.metadata.camera_quaternion[3]
  1887. },
  1888. ortho_zoom: args.metadata.ortho_zoom,
  1889. scan_id: args.metadata.scan_id || "outside",
  1890. //这个"outside"不能随便改成别的
  1891. /* final_angle: 110,
  1892. is_ortho: false, */
  1893. zoom: args.metadata.zoom // fyz zoom是内部计算的zoomLevel, 乘以系数1.06才是实际缩放倍数
  1894. })
  1895. if (renew/* && target */) { // 重新录制导览
  1896. // 更新数据
  1897. var musicInfo = insideFolder || that.editingItemLi.tourData.musicInfo;
  1898. musicInfo && (args.musicInfo = musicInfo);
  1899. $(that.editingItemLi).find('#tourBg')[0].style.backgroundImage = 'url(' + args.thumbnail_signed_src + ')';
  1900. //args.name = insideFolder $('#tourItemEdit').find('#tourNameInput').val()
  1901. /* var oldId = target.closest('li')[0].data.sid;
  1902. that.tourAudio[args.sid] = that.tourAudio[oldId];
  1903. // 新生成的id指向以前的导览音频
  1904. delete that.tourAudio[oldId];
  1905. // 删除导览音频中的旧导览id */
  1906. that.editingItemLi.tourData = args;
  1907. //target.text(args.name); // 更新导览列表中的导览名称 //不改名字
  1908. //$('#tourItemEdit').find('#tourNameInput').val(args.name); // 修改输入框内容
  1909. } else {
  1910. var $li = $(that.getItemDom(args.name, args.thumbnail_signed_src));
  1911. $li[0].tourData = args;
  1912. var $ul = insideFolder ? $("#tourItemList>ul") : $("#tourList>ul")
  1913. $ul.append($li);
  1914. reIndexTourList($ul[0])
  1915. }
  1916. }
  1917. })
  1918. }
  1919. EditGuide.prototype.getSavingInfo = function(){
  1920. var data = []
  1921. Array.from($("#tourList ul li")).forEach(dom=>{
  1922. if(dom.classList.contains("guideItem")){//item
  1923. dom.tourData.name = $(dom).find('.guide-name').text()
  1924. data.push(dom.tourData)
  1925. }else{//folder
  1926. var dataFolder = dom.tourData;
  1927. dataFolder.name = $(dom).find('.title').text()
  1928. dataFolder.locations = dom.tourItemDoms.map(li => li.tourData )
  1929. data.push(dataFolder)
  1930. }
  1931. })
  1932. return data
  1933. }
  1934. /* -- 以下是一些公用的方法 -- */
  1935. //限制大小
  1936. var restrictedSize = function(file, _size) {
  1937. //限制大小不大于8m
  1938. var fileSize = 0;
  1939. var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
  1940. if (isIE && !file) {
  1941. var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
  1942. var _file = fileSystem.GetFile(filepath);
  1943. fileSize = _file.Size;
  1944. } else {
  1945. fileSize = file.size;
  1946. }
  1947. var size = fileSize / 1024;
  1948. var RSize = _size * 1024;
  1949. if (size > RSize) {
  1950. alert("文件不能大于" + _size + "M");
  1951. return false;
  1952. }
  1953. if (size <= 0) {
  1954. alert("文件大小不能为0M!");
  1955. return false;
  1956. }
  1957. return true
  1958. }
  1959. //上传音乐
  1960. var uploadMiuse = function(file, callback) {
  1961. uploadFile(file, 'audio', callback);
  1962. }
  1963. $(".toolRight .music .itemTitle span").text(`背景音乐 (<${_musicMaxWeight}M)`)
  1964. //上传图片
  1965. function uploadImg(urlData, callback, fileName) {
  1966. //console.log('urlData',urlData);
  1967. if(!fileName)fileName = getRandomSid() + '.jpg'
  1968. var bytes = window.atob(urlData.split(',')[1]);
  1969. //去掉url的头,并转换为byte
  1970. //处理异常,将ascii码小于0的转换为大于0
  1971. var ab = new ArrayBuffer(bytes.length);
  1972. var ia = new Uint8Array(ab);
  1973. for (var i = 0; i < bytes.length; i++) {
  1974. ia[i] = bytes.charCodeAt(i);
  1975. }
  1976. var blob = new Blob([ab],{
  1977. type: 'image/jpeg',
  1978. });
  1979. uploadFile(blob, 'hot/images', callback, fileName);
  1980. }
  1981. //上传文件
  1982. function uploadFile(file, type, callback, fileName) {
  1983. $(".edit-loading").removeClass("hide");
  1984. var formData = new FormData()
  1985. formData.append('name', number)
  1986. formData.append('dir', type)
  1987. formData.append('random', true)
  1988. //formData.append('file', file)
  1989. formData.append("file", file, fileName);
  1990. let url = cmp ? ('/api/scene/upload/' + number) : ('/manage/scene/upload/' + number)
  1991. $.ajax({
  1992. url: ceshi + url,
  1993. data: formData,
  1994. headers: {
  1995. token: token
  1996. },
  1997. dataType: 'json',
  1998. type: 'POST',
  1999. cache: false,
  2000. //上传文件无需缓存
  2001. processData: false,
  2002. //用于对data参数进行序列化处理 这里必须false
  2003. contentType: false,
  2004. //必须
  2005. success: function(rs) {
  2006. if (rs.code === 5001) {
  2007. alert('请重新登录')
  2008. localStorage.dcj_token = ''
  2009. location.reload()
  2010. }
  2011. callback(rs, file);
  2012. $(".edit-loading").addClass("hide");
  2013. }
  2014. })
  2015. }
  2016. function _animate(prevRect, target) {
  2017. var ms = 300;
  2018. if (ms) {
  2019. var currentRect = target.getBoundingClientRect();
  2020. if (prevRect.nodeType === 1) {
  2021. prevRect = prevRect.getBoundingClientRect();
  2022. }
  2023. _css(target, 'transition', 'none');
  2024. _css(target, 'transform', 'translate3d(' + (prevRect.left - currentRect.left) + 'px,' + (prevRect.top - currentRect.top) + 'px,0)');
  2025. target.offsetWidth;
  2026. // 触发重绘
  2027. //放在timeout里面也可以
  2028. // setTimeout(function() {
  2029. // _css(target, 'transition', 'all ' + ms + 'ms');
  2030. // _css(target, 'transform', 'translate3d(0,0,0)');
  2031. // }, 0);
  2032. _css(target, 'transition', 'all ' + ms + 'ms');
  2033. _css(target, 'transform', 'translate3d(0,0,0)');
  2034. clearTimeout(target.animated);
  2035. target.animated = setTimeout(function() {
  2036. _css(target, 'transition', '');
  2037. _css(target, 'transform', '');
  2038. target.animated = false;
  2039. }, ms);
  2040. }
  2041. }
  2042. //给元素添加style
  2043. function _css(el, prop, val) {
  2044. var style = el && el.style;
  2045. if (style) {
  2046. if (val === void 0) {
  2047. if (document.defaultView && document.defaultView.getComputedStyle) {
  2048. val = document.defaultView.getComputedStyle(el, '');
  2049. } else if (el.currentStyle) {
  2050. val = el.currentStyle;
  2051. }
  2052. return prop === void 0 ? val : val[prop];
  2053. } else {
  2054. if (!(prop in style)) {
  2055. prop = '-webkit-' + prop;
  2056. }
  2057. style[prop] = val + (typeof val === 'string' ? '' : 'px');
  2058. }
  2059. }
  2060. }
  2061. function upload($files, type, cb) {
  2062. var length = $files.length
  2063. var rcount = 0
  2064. var result = []
  2065. Array.from($files).forEach(function(dFile, index) {
  2066. //a 标签的success 是用来判断是否是已经上传过的文件
  2067. //attr-thum 属性是视频的图片
  2068. //videoURL 是判断是否有视频
  2069. var $file = $(dFile)
  2070. var $image = type == 'videos' ? $file.find('img.play-video') : $file.find('img')
  2071. if ($file.hasClass('success')) {//已经上传过,有链接
  2072. if ($file.attr('attr-thum')) {//视频的封面
  2073. result[index] = $file.attr('attr-thum')
  2074. } else if ($image.attr('videoURL')) {//视频
  2075. result[index] = $image.attr('videoURL')
  2076. } else {
  2077. result[index] = $image.attr('src')
  2078. }
  2079. return success(++rcount);
  2080. } else {
  2081. switch ($file[0].localName) {
  2082. case "input":
  2083. dFile = $file[0]
  2084. break;
  2085. case "span"://封面
  2086. dFile = $file.find('input')[0];
  2087. break;
  2088. case "a"://重传的图or视频
  2089. dFile = {files:[$file[0].file]}
  2090. //dFile = $file.find('input')[0];
  2091. break;
  2092. default:
  2093. dFile = $file.closest("li").find('.upload input')[0];
  2094. break;
  2095. }
  2096. // dFile = $file[0].localName === "input" ? $file[0] : $file[0].localName === "span" ? $file.find('input')[0] : $file.closest("li").find('.upload input')[0];
  2097. }
  2098. var file = (dFile.files && dFile.files[0]) || '';
  2099. if (!file)
  2100. return success(++rcount);
  2101. uploadFile(file, 'hot/' + type, function(rs) {
  2102. //似乎所有图保存路径都是这个hot/前缀。图地址 :"场景id/edit/重新生成的文件名.原后缀", 展示页面也是。
  2103. if (rs.code === 0) {
  2104. result[index] = rs.data
  2105. }
  2106. ;success(++rcount);
  2107. })
  2108. })
  2109. //判断当前队列元素是否处理成功
  2110. function success() {
  2111. if (rcount === length) {
  2112. cb(result)
  2113. }
  2114. }
  2115. success()
  2116. }
  2117. function getIndex(el) {
  2118. let index = 0;
  2119. if (!el || !el.parentNode) {
  2120. return -1;
  2121. }
  2122. while (el && (el = el.previousElementSibling)) {
  2123. index++;
  2124. }
  2125. return index;
  2126. }
  2127. dataURLtoBlob = function(dataurl) {
  2128. //将base64转换blob
  2129. var arr = dataurl.split(',')
  2130. , mime = arr[0].match(/:(.*?);/)[1]
  2131. , bstr = atob(arr[1])
  2132. , n = bstr.length
  2133. , u8arr = new Uint8Array(n);
  2134. while (n--) {
  2135. u8arr[n] = bstr.charCodeAt(n);
  2136. }
  2137. return new Blob([u8arr],{
  2138. type: mime
  2139. });
  2140. }
  2141. ;
  2142. //=========================
  2143. var eachMaxWeights = {
  2144. //大小限制
  2145. "photo": 10,
  2146. "video": 1000,//50, expand size for overlayVideo
  2147. //20,
  2148. "audio": 10 //5
  2149. }
  2150. var supportTypes = {
  2151. //支持后缀
  2152. "photo": ["jpg", "png", "jpeg", "bmp", "gif"],
  2153. "audio": ["mp3", "aac", "ogg", "wav"/* , "m4a" */
  2154. ],
  2155. "video": ["mp4", "mov"/* ,"webm", "rmvb", "wmv" */
  2156. ]//ios:mov
  2157. }
  2158. function getExt(name) {
  2159. //后缀
  2160. if (name.indexOf('.') > -1) {
  2161. var a = name.split(".");
  2162. return a.pop();
  2163. } else {
  2164. return '';
  2165. }
  2166. }
  2167. function detectType(fileName) {
  2168. //检测文件后缀类型
  2169. console.log("名:" + fileName)
  2170. var ext = getExt(fileName);
  2171. console.log("后缀:" + ext)
  2172. //不一定所有浏览器都可以
  2173. var type;
  2174. //仅能根据后缀判断类型,尽管后缀可能被修改。 其他方法如file.type和base64开头的字符串均是根据后缀。
  2175. for (var i in supportTypes) {
  2176. if (supportTypes[i].indexOf(ext.toLowerCase()) > -1) {
  2177. type = i;
  2178. break;
  2179. }
  2180. }
  2181. if (type) {
  2182. return type;
  2183. } else {
  2184. return false;
  2185. }
  2186. }
  2187. //手机上的相片会不会太大?
  2188. var detectWeights = function(file, type) {
  2189. //检测大小
  2190. var size = file.size / 1024 / 1024;
  2191. console.log("weight" + size)
  2192. var over;
  2193. if (size > eachMaxWeights[type]) {
  2194. over = Math.ceil(size * 100) / 100;
  2195. }
  2196. return over;
  2197. }
  2198. var exitUpload = function(input) {
  2199. $('.waiting').removeClass('showloading');
  2200. input.value = "";
  2201. }
  2202. var inputMedia = function(options, type, e) {
  2203. var input = e.target;
  2204. if (!window.FileReader) {
  2205. alert('您的浏览器不支持上传文件');
  2206. exitUpload(input);
  2207. return;
  2208. } else if (e.target.files.length === 0) {
  2209. /* exitUpload(input); */
  2210. return;
  2211. }
  2212. $('.waiting').addClass('showloading');
  2213. var file = e.target.files[0];
  2214. var elemType = type;
  2215. var inputType = detectType(file.name);
  2216. var chType = {
  2217. "photo": '图片',
  2218. "video": '视频',
  2219. "audio": '音乐'
  2220. }
  2221. var overWeight = detectWeights(file, inputType);
  2222. if (elemType) {
  2223. //有指定其中一种类型
  2224. if (inputType != elemType) {
  2225. alert("您选择的不是浏览器支持的" + chType[elemType] + '文件,请重新选择');
  2226. exitUpload(e.target);
  2227. return;
  2228. }
  2229. } else {
  2230. if (!options.enableTypes.includes(inputType)) {
  2231. var text = "";
  2232. options.enableTypes.forEach((type,index)=>{
  2233. text += ((index != 0 ? " / " : "") + chType[elemType])
  2234. }
  2235. )
  2236. alert("您选择的不是浏览器支持的" + text + '文件,请重新选择');
  2237. exitUpload(e.target);
  2238. return;
  2239. }
  2240. }
  2241. if (overWeight) {
  2242. alert(`文件过大(${overWeight}兆),不能大于${eachMaxWeights[inputType]} 兆`)
  2243. exitUpload(e.target);
  2244. return;
  2245. }
  2246. var loadError = function() {
  2247. exitUpload(e.target);
  2248. alert(`文件出错, 无法加载此${chType[inputType]}文件。 文件可能损坏,或者浏览器不支持,或者后缀与文件不匹配。建议在IE以外的浏览器上传`)
  2249. }
  2250. deal();
  2251. function deal(fi) {
  2252. console.log('开始deal文件')
  2253. var reader = new FileReader();
  2254. //reader.name = file.name;
  2255. file = fi || file;
  2256. reader.readAsDataURL(file);
  2257. reader.onload = function(evt) {
  2258. var blob = dataURLtoBlob(evt.target.result);
  2259. var blobSrc = window.URL.createObjectURL(blob);
  2260. if (inputType == "photo") {
  2261. /* EXIF.getData(file, function () {
  2262. //获取相片旋转
  2263. EXIF.getAllTags(this);
  2264. var orient = EXIF.getTag(this, 'Orientation');
  2265. var img = new Image();
  2266. img.src = evt.target.result;
  2267. img.onload = function (e) { //这时img才有宽高,才能赋予texture宽高
  2268. var smallerImg = CompressImg(e.target, {
  2269. weight: blob.size,
  2270. maxWeight: 0.5 * 1024 * 1024,
  2271. maxSize: 1480
  2272. });
  2273. //最大500k
  2274. smallerImg.onload = function () {
  2275. var f = function (resultImg) {//处理结束回调
  2276. options.photoDone(resultImg)
  2277. $('.waiting').removeClass('showloading');
  2278. }
  2279. Rotate(smallerImg, orient, f)
  2280. window.URL.revokeObjectURL(blobSrc);
  2281. }
  2282. }
  2283. .bind(this)
  2284. img.onerror = loadError;
  2285. }); */
  2286. var img = new Image();
  2287. img.src = blobSrc;
  2288. img.base64Src = evt.target.result;
  2289. img.file = file;
  2290. img.onload = function(e) {
  2291. options.photoDone(img)
  2292. $('.waiting').removeClass('showloading');
  2293. }
  2294. } else if (inputType == "video") {
  2295. var video = $('<video controls="controls" x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload"></video>')[0]
  2296. video.setAttribute("crossOrigin", 'Anonymous')
  2297. //要在src设置好前解决跨域
  2298. $(video).on('contextmenu', function() {
  2299. return false;
  2300. });
  2301. //禁止右键点击出现选项(尤其是下载选项)
  2302. $(video).attr('src', blobSrc);
  2303. //华为无法使用blobSrc,否则加载不出来
  2304. //$(video).attr('src', evt.target.result);
  2305. video.base64Src = evt.target.result;
  2306. var hasload = false;
  2307. var error = false;
  2308. var up = function() {
  2309. if (hasload)
  2310. return;
  2311. hasload = true;
  2312. options.videoDone(file, video)
  2313. $('.waiting').removeClass('showloading');
  2314. }
  2315. video.addEventListener('loadeddata', function(e) {
  2316. up()
  2317. })
  2318. //video.onerror = loadError;
  2319. video.onerror = function(e) {
  2320. console.log('error')
  2321. error = true;
  2322. loadError();
  2323. //将mp4改成mov后缀会error
  2324. }
  2325. } else if (inputType == "audio") {
  2326. //林俊波 new Howl For IE&Safari:
  2327. var sound = new Howl({
  2328. src: [blobSrc],
  2329. format: ["mp3"]
  2330. });
  2331. // Clear listener after first call.
  2332. sound.once('load', function() {
  2333. console.log('loaded sound')
  2334. sound.unload()
  2335. console.log("audio.onloadeddata");
  2336. var audio = new Audio;
  2337. audio.controls = "controls";
  2338. audio.src = blobSrc;
  2339. audio.base64Src = evt.target.result;
  2340. options.audioDone(file, audio)
  2341. $('.waiting').removeClass('showloading');
  2342. //}
  2343. });
  2344. sound.once('loaderror', function() {
  2345. loadError.apply(this, arguments)
  2346. console.log('loaderror sound')
  2347. });
  2348. // Fires when the sound finishes playing.
  2349. sound.on('end', function() {
  2350. console.log('Finished sound');
  2351. });
  2352. }
  2353. }
  2354. }
  2355. e.target.value = "";
  2356. //更改value会触发change
  2357. }
  2358. .bind(player)
  2359. //滑动条控件
  2360. var SlideBar = function(o) {
  2361. var scope = this;
  2362. this.name = o.name;
  2363. this.value = o.value;
  2364. //初始值
  2365. this.min = o.min != void 0 ? o.min : 0;
  2366. this.max = this.oriMax = o.max != void 0 ? o.max : 100;
  2367. this.noValue = o.noValue;
  2368. //是否数值输入
  2369. this.precision = o.precision;
  2370. //精度 保留几位小数
  2371. var div = $('<div><div class="Main"><div class="scrollBar"><div class="scroll_Track"></div><div class="scroll_Thumb"></div></div>' + (o.noValue ? '' : '<div class="BarTxt"><input class="scrollBarTxt"></div></div>'))
  2372. div.addClass('slider')
  2373. if (o.unitStr) {
  2374. div.find(".BarTxt").append($('<span>' + o.unitStr + '</span>'));
  2375. }
  2376. o.root.append(div);
  2377. this.line = $(".scrollBar", div);
  2378. this.knot = $(".scroll_Thumb", div);
  2379. o.noValue || (this.textArea = $(".scrollBarTxt", div));
  2380. this.track = $(".scroll_Track", div);
  2381. this.unitStr = o.unitStr;
  2382. //unitStr是单位字符串,比如角度的°。不能是数字
  2383. this.onchange = o.onchange;
  2384. this.percent = null;
  2385. this.dragStart = false;
  2386. this.offsetToBody = null;
  2387. this.getOffset();
  2388. this.checkError();
  2389. this.percent = this.getPercent();
  2390. o.noValue || this.displayValue();
  2391. this.moveKnot();
  2392. this.knotWidth = 0;
  2393. this.lineWidth = 0;
  2394. //this.waitValue;//等待要触发事件的值,防止崩溃
  2395. this.avoidCrash = o.avoidCrash;
  2396. this.realMax = !this.noValue ? o.realMax : null;
  2397. //如果传入realMax,代表可以通过输入数字修改最大值范围,最大值不可以超过realMax。
  2398. this.scrollUnit = (scope.max - scope.min) * 0.001;
  2399. if (this.precision != void 0) {
  2400. var prec = Math.pow(10, -this.precision);
  2401. this.scrollUnit < prec && (this.scrollUnit = prec);
  2402. } else {
  2403. //默认化为整数
  2404. this.scrollUnit < 1 && (this.scrollUnit = 1);
  2405. }
  2406. this.dragStartEvent = o.dragStartEvent;
  2407. this.line.on("mousedown touchstart", function(event) {
  2408. scope.dragStart = true;
  2409. scope.dragChange(event);
  2410. if (scope.dragStartEvent)
  2411. scope.dragStartEvent()
  2412. //if(o.avoidCrash && isMobile)scope.dealInterval();
  2413. });
  2414. !window.isMobile && this.line.on("mousewheel DOMMouseScroll wheel", function(event) {
  2415. event.preventDefault();
  2416. var v = event.originalEvent.deltaY > 0 ? -scope.scrollUnit : scope.scrollUnit;
  2417. scope.setValue(scope.value + v);
  2418. });
  2419. this.dragEndEvent = o.dragEndEvent;
  2420. var stop = function() {
  2421. if (scope.dragStart) {
  2422. scope.dragStart = false;
  2423. if (scope.dragEndEvent)
  2424. scope.dragEndEvent()
  2425. }
  2426. }
  2427. $(document).on("mouseup touchend", stop)
  2428. /* isMobile || */
  2429. $("#player").on("mouseup", stop)
  2430. var lastChangeTime = 0;
  2431. $(document).on("mousemove touchmove", function() {
  2432. if (scope.dragStart) {
  2433. /* if(isMobile && o.avoidCrash){
  2434. scope.lastDragEvent = event;
  2435. }else */
  2436. scope.dragChange(event);
  2437. }
  2438. })
  2439. o.noValue || this.textArea.on("change", function() {
  2440. var v = parseFloat(scope.textArea.val());
  2441. if (v != v)
  2442. //NaN
  2443. return;
  2444. scope.setValueFromOutside(v);
  2445. });
  2446. window.addEventListener("resize",()=>{
  2447. if(this.line[0].clientWidth){
  2448. this.getOffset()
  2449. this.moveKnot();
  2450. }
  2451. })
  2452. }
  2453. SlideBar.prototype.dealInterval = function() {
  2454. this.interval = setInterval(function() {
  2455. this.lastDragEvent && this.dragChange(this.lastDragEvent);
  2456. this.lastDragEvent = null
  2457. if (!this.dragStart)
  2458. clearInterval(this.interval)
  2459. }
  2460. .bind(this), 90)
  2461. }
  2462. SlideBar.prototype.changeLimit = function(o) {
  2463. if (o.min)
  2464. this.min = o.min;
  2465. if (o.max)
  2466. this.max = o.max;
  2467. }
  2468. SlideBar.prototype.getOffset = function() {
  2469. //为了检测鼠标位置需要获得相对body的offset
  2470. var left = this.line[0].offsetLeft;
  2471. var element = this.line[0];
  2472. while (element = element.offsetParent) {
  2473. left += element.offsetLeft;
  2474. }
  2475. this.offsetToBody = (left == 0) ? (this.offsetToBody || 0) : left;
  2476. //如果left为0,很可能是它不可见,那么最好使用旧的offsetToBody
  2477. }
  2478. SlideBar.prototype.InitOffset = function() {
  2479. //如果一开始scroller没有显示,要在显示时获取一下offset
  2480. this.getOffset();
  2481. this.getWidth();
  2482. this.moveKnot();
  2483. }
  2484. SlideBar.prototype.checkError = function() {
  2485. if (this.min >= this.max) {
  2486. console.log("scrollbar值有误 " + name);
  2487. return;
  2488. }
  2489. }
  2490. SlideBar.prototype.getPercent = function() {
  2491. return (this.value - this.min) / (this.max - this.min);
  2492. }
  2493. SlideBar.prototype.displayValue = function(value) {
  2494. //this.textArea.val(this.value + (this.unitStr ? " " + this.unitStr : ""));
  2495. if (value != void 0)
  2496. this.value = value;
  2497. this.textArea.val(this.value)
  2498. }
  2499. SlideBar.prototype.getWidth = function() {
  2500. this.knotWidth = this.knot.width();
  2501. this.lineWidth = this.line.width() - this.knotWidth
  2502. }
  2503. SlideBar.prototype.moveKnot = function() {
  2504. //this.getWidth();
  2505. var width = this.percent * this.lineWidth;
  2506. this.knot.css('left', width + "px")
  2507. if (this.track)
  2508. this.track.css('width', (width + this.knotWidth / 2) + "px")
  2509. }
  2510. SlideBar.prototype.bind = function(f) {
  2511. this.onchange = f;
  2512. }
  2513. SlideBar.prototype.setValue = function(v, noEvent, changeMax) {
  2514. //设置数值并改变knot位置 noEvent为true的话就可以不触发回调函数,仅仅改变显示
  2515. //if(this.value==v)return; //因为换选材质需要执行后面onchange才会带动preview的改变,所以这里一样还是执行,而拉动滑动条的部分值不变就不执行
  2516. if (this.precision != void 0) {
  2517. this.value = parseFloat(v.toFixed(this.precision))
  2518. } else {
  2519. //默认化为整数
  2520. this.value = Math.round(v);
  2521. }
  2522. if (changeMax && this.realMax != void 0) {
  2523. if (this.value > this.oriMax) {
  2524. this.value = Math.min(this.value, this.realMax);
  2525. this.changeLimit({
  2526. max: this.value
  2527. })
  2528. } else {
  2529. this.changeLimit({
  2530. max: this.oriMax
  2531. })
  2532. }
  2533. }
  2534. this.percent = this.getPercent();
  2535. var makeit = true;
  2536. if (this.onchange && !noEvent) {
  2537. var result = this.onchange(this.value);
  2538. //如果执行的函数不允许这个值,就不能变
  2539. if (result === false) {
  2540. makeit = false;
  2541. }
  2542. }
  2543. if (makeit) {
  2544. this.moveKnot();
  2545. //console.log("SlideBarV-"+this.name + " : "+this.value)
  2546. this.noValue || this.displayValue();
  2547. }
  2548. }
  2549. SlideBar.prototype.dragChange = function(event) {
  2550. //拖动时触发 计算数值
  2551. //this.getWidth();
  2552. //if(!this.offsetToBody || isNaN(this.offsetToBody)this.getOffset();
  2553. if (event.clientX != void 0) {
  2554. this.percent = (event.clientX - this.knotWidth / 2 - this.offsetToBody) / this.lineWidth;
  2555. } else {
  2556. if (event.touches != void 0) {
  2557. this.percent = (event.touches[0].clientX - this.knotWidth / 2 - this.offsetToBody) / this.lineWidth;
  2558. } else
  2559. this.percent = (event.originalEvent.touches[0].clientX - this.knotWidth / 2 - this.offsetToBody) / this.lineWidth;
  2560. }
  2561. if (this.percent < 0)
  2562. this.percent = 0;
  2563. else if (this.percent > 1)
  2564. this.percent = 1;
  2565. //var v = this.percent * this.max;
  2566. var v = this.percent * (this.max - this.min) + this.min;
  2567. //var v = Math.round(this.percent * this.max * 10)/10; //精度为0.1
  2568. if (this.value == v)
  2569. return;
  2570. this.setValue(v);
  2571. }
  2572. SlideBar.prototype.setValueFromOutside = function(v) {
  2573. //外面的事件触发的
  2574. if (this.line.width() == 0)
  2575. return;
  2576. //不可见就不执行。
  2577. //v = Math.round(v*10)/10;
  2578. if (this.realMax != void 0) {
  2579. v = THREE.Math.clamp(v, this.min, this.realMax);
  2580. if (v > this.max)
  2581. this.changeLimit({
  2582. max: v
  2583. });
  2584. } else
  2585. v = THREE.Math.clamp(v, this.min, this.max);
  2586. this.setValue(v);
  2587. }
  2588. //-----------------------------------------------------
  2589. var LineDraw = {
  2590. createLine: function(posArr, o) {
  2591. var e = new THREE.BufferGeometry
  2592. , p = new Float32Array(6);
  2593. e.addAttribute("position", new THREE.BufferAttribute(p,3));
  2594. //这句新旧版写法不同 旧版这样:e.addAttribute("position",Float32Array,2,3);
  2595. var p = e.attributes.position.array;
  2596. for (var i = 0; i < 2; i++) {
  2597. p[i * 3] = posArr[i].x;
  2598. p[i * 3 + 1] = posArr[i].y;
  2599. p[i * 3 + 2] = posArr[i].z;
  2600. }
  2601. var mat = new THREE[o.deshed ? "LineDashedMaterial" : "LineBasicMaterial"]({
  2602. linewidth: o.width || 1,
  2603. //windows无效。 似乎mac/ios上粗细有效 ?
  2604. color: o.color || defaultColor,
  2605. transparent: o.dontAlwaysSeen ? false : true,
  2606. depthTest: o.dontAlwaysSeen ? true : false
  2607. })
  2608. var line = new THREE.Line(e,mat);
  2609. line.renderOrder = o.renderOrder || 4
  2610. //同tagStem; //如果不加高,可能会部分被model遮住
  2611. return line;
  2612. }
  2613. }
  2614. var toPrecision = function(e, t) {
  2615. function i(e, t) {
  2616. var i = Math.pow(10, t);
  2617. return Math.round(e * i) / i
  2618. }
  2619. if (e instanceof Array) {
  2620. for (var n = 0; n < e.length; n++)
  2621. e[n] = i(e[n], t);
  2622. return e
  2623. }
  2624. return i(e, t)
  2625. }
  2626. var transformControls;
  2627. var initTransformCtl = function(THREE) {
  2628. TransformControls.init(THREE)
  2629. TransformControls.prototype.transCtlChangeMode = function(mode) {
  2630. //if(!this.editing)return;
  2631. if (mode && this.mode != mode) {
  2632. this.mode = mode;
  2633. }
  2634. }
  2635. ,
  2636. transformControls = new TransformControls(player.camera,player.domElement,{
  2637. player: player,
  2638. dontHideWhenFaceCamera: true,
  2639. scaleAxis: ["x", "y"],
  2640. //隐藏了z轴。虽然参数没用上
  2641. NoScaleZ: true //整体缩放时只缩放xy轴。
  2642. });
  2643. transformControls.space = 'local'//为了在当前方向上平移
  2644. transformControls.setSize(1.5)
  2645. player.model.add(transformControls)
  2646. $(".MenuOptions[name='transform'] li").on("click", (e)=>{
  2647. transformControls.transCtlChangeMode($(e.target).attr("index"))
  2648. })
  2649. }
  2650. var EditOverlay = {
  2651. editing: false,
  2652. overlayMaxCount: 10,
  2653. scroller: {
  2654. videoDepth: new SlideBar({
  2655. root: $('#videoDepth').eq(0),
  2656. value: settings.overlay.depth * 100,
  2657. min: 0 * 100,
  2658. max: 1 * 100,
  2659. name: "videoDepth",
  2660. unitStr: "cm",
  2661. avoidCrash: true,
  2662. onchange: function(s) {
  2663. if (s == 0) {
  2664. EditOverlay.editPlane.addBox(false)
  2665. } else {
  2666. EditOverlay.editPlane.addBox(true)
  2667. EditOverlay.editPlane.scale.z = s / 100 / settings.overlay.depth;
  2668. }
  2669. },
  2670. dragEndEvent: function() {
  2671. }
  2672. })
  2673. },
  2674. panoPosSwitch : $('#setOverlayPosForPano input') // 当前漫游点独立调整位置开关
  2675. ,
  2676. init: function(THREE) {
  2677. var mat = new THREE.MeshBasicMaterial({
  2678. wireframe: true,
  2679. opacity: 0.5,
  2680. color: "#57e4f3",
  2681. transparent: true
  2682. })
  2683. var wireframeModel = this.wireframeModel = new THREE.Object3D;
  2684. wireframeModel.name = 'wireframeModel'
  2685. player.model.chunks.forEach((mesh)=>{
  2686. var chunk = mesh.clone();
  2687. chunk.material = mat;
  2688. wireframeModel.add(chunk)
  2689. }
  2690. )
  2691. wireframeModel.visible = false
  2692. player.model.add(wireframeModel)
  2693. //------------------------------
  2694. this.panoPosSwitch.on("change", this.panoPosSwitchOnChange.bind(this))
  2695. $('.overlay .addBtn button').on("click", this.beginToAddPlane.bind(this))
  2696. $("#overlayProp a.close").on("click", ()=>{
  2697. this.closeOverlayPanel("cancel")
  2698. }
  2699. )
  2700. $("#overlayProp button.submit").on("click", (e)=>{
  2701. this.SaveOverlay()
  2702. }
  2703. )
  2704. $("#overlayProp button.delete").on("click", (e)=>{
  2705. this.DeleteOverlay();
  2706. }
  2707. )
  2708. $('#overlayUpload [name="useImgRatio"] button').on("click", this.useImgRatio.bind(this));
  2709. var uploadInputs = {
  2710. video : $('<input type="file" style="display:none" accept="video/*"></input>'),
  2711. photo : $('<input type="file" style="display:none" accept="image/*"></input>')
  2712. }
  2713. $('#overlayUpload [name="upload"] button').on('click', ()=>{
  2714. uploadInputs[this.editType].click()
  2715. })
  2716. uploadInputs.video.on("change", (e)=>{
  2717. inputMedia({
  2718. enableTypes: [this.editType ],
  2719. videoDone: (file,video)=>{
  2720. var plane = this.editPlane.plane
  2721. $(video).css('width', '100%')
  2722. $(video).css('height', '100%')
  2723. plane.material.map = new THREE.VideoTexture(video);
  2724. plane.material.map.image.play();
  2725. plane.material.map.minFilter = THREE.LinearFilter;
  2726. this.editPlane.overlayType = "video";
  2727. $('#overlayUpload .preview video').remove();
  2728. //$('#overlayUpload .preview').css('background-image',"").append($(video));
  2729. video.autoplay = true;
  2730. video.loop = true;
  2731. video.volume = 0
  2732. video.muted = true
  2733. this.useImgRatio()
  2734. //自适应比例
  2735. this.editPlane.file = file;
  2736. plane.material.opacity = 1;
  2737. plane.material.color = new THREE.Color(1,1,1)
  2738. plane.material.needsUpdate = true;
  2739. }
  2740. }, "video", e);
  2741. }
  2742. )
  2743. uploadInputs.photo.on("change", (e)=>{
  2744. inputMedia({
  2745. enableTypes: [this.editType ],
  2746. photoDone: (photo)=>{
  2747. var plane = this.editPlane.plane
  2748. /* $(video).css('width', '100%')
  2749. $(video).css('height', '100%') */
  2750. plane.material.map = new THREE.Texture();
  2751. plane.material.map.image = photo
  2752. plane.material.map.needsUpdate = !0
  2753. plane.material.map.minFilter = THREE.LinearFilter;
  2754. this.editPlane.overlayType = "photo";
  2755. $('#overlayUpload .preview video').remove();
  2756. //$('#overlayUpload .preview').css('background-image',"").append($(video));
  2757. this.useImgRatio()
  2758. //自适应比例
  2759. this.editPlane.file = photo.file;
  2760. plane.material.opacity = 1;
  2761. plane.material.color = new THREE.Color(1,1,1)
  2762. plane.material.needsUpdate = true;
  2763. }
  2764. }, "photo", e);
  2765. }
  2766. )
  2767. player.overlayGroup.children.forEach((overlay)=>{
  2768. if(!overlay.plane.material.map || !overlay.plane.material.map.image){
  2769. overlay._loadDones = [()=>{this.getOverlayInfo(overlay)}]
  2770. }
  2771. else {
  2772. this.getOverlayInfo(overlay)
  2773. }
  2774. this.addToList(overlay)
  2775. }
  2776. )
  2777. },
  2778. enter: function() {
  2779. this.editing = true;
  2780. this.wireframeModel.visible = true;
  2781. },
  2782. leave: function() {
  2783. if (!this.editing)
  2784. return;
  2785. this.editing = false
  2786. $("#overlayProp a.close").click();
  2787. this.endAddPlane();
  2788. this.wireframeModel.visible = false;
  2789. },
  2790. switchEditType : function(type){
  2791. this.editType = type;
  2792. $('#overlayUpload [name="upload"] button').text(type == 'video' ? "上传视频" : "上传图片")
  2793. $('#overlayUpload .preview span').text(type == 'video' ? "支持MP4、MOV等,<20M" : "支持jpg、png等,<20M");
  2794. },
  2795. beginToAddPlane: function(event) {
  2796. this.switchEditType($(event.target).attr("data-type"))
  2797. player.reticule.visible = false;
  2798. this.objCursorType = 'overlay';
  2799. player.currentCursor = 'url(images/edit/box_video.png), auto'
  2800. $('#player').css('cursor', player.currentCursor)
  2801. $('.overlay .addBtn button').addClass("unable")
  2802. //可以加多个视频时的按钮
  2803. },
  2804. endAddPlane: function() {
  2805. this.objCursorType = null;
  2806. player.currentCursor = '';
  2807. $('#player').css('cursor', '')
  2808. $('.overlay .addBtn button').removeClass("unable")
  2809. player.reticule.visible = true
  2810. },
  2811. addPlane: function(o) {
  2812. if(!o.intersect)return;
  2813. var pos = o.intersect.point;
  2814. var overlay = new Overlay({
  2815. sid: new Date().getTime() + ""
  2816. })
  2817. overlay.hasRequestLoad = true
  2818. overlay.position.copy(pos);
  2819. if (player.getMouseDirection().angleTo(o.intersect.face.normal) < Math.PI / 2) {
  2820. overlay.lookAt(o.intersect.face.normal.clone().negate().add(pos));
  2821. overlay.position.add(o.intersect.face.normal.clone().negate().multiplyScalar(0.01))
  2822. //avoid mesh crash with chunks 模型的精度可能和floorplan的不一样,所以chunk即使材质经过处理还是会闪烁但是wallmesh不会
  2823. } else {
  2824. overlay.lookAt(o.intersect.face.normal.clone().add(pos));
  2825. overlay.position.add(o.intersect.face.normal.clone().multiplyScalar(0.01))
  2826. }
  2827. overlay.posCustom = overlay.position.clone();
  2828. overlay.quaCustom = overlay.quaternion.clone();
  2829. overlay.widthCustom = overlay.width;
  2830. overlay.heightCustom = overlay.height;
  2831. overlay.isNew = true
  2832. player.clickOverlay(overlay)
  2833. transformControls.transCtlChangeMode("translate")
  2834. this.addToList(overlay)
  2835. },
  2836. updateOverlayScaleDisplay: function() {
  2837. var overlay = this.editPlane;
  2838. var maxWidth = 193
  2839. , maxHeight = maxWidth
  2840. //maxWidth/2;
  2841. var ratioW = Math.abs(overlay.width) / maxWidth;
  2842. var ratioH = Math.abs(overlay.height) / maxHeight;
  2843. var ratio = 1 / Math.max(ratioW, ratioH);
  2844. //缩放比例
  2845. var w = Math.round(Math.abs(overlay.width) * ratio)
  2846. var h = Math.round(Math.abs(overlay.height) * ratio)
  2847. $('#overlayUpload .preview').css({
  2848. "width": w + 'px',
  2849. "height": h + 'px',
  2850. });
  2851. $('#overlayUpload .preview [attr-type="width"]').text(toPrecision(overlay.width, 2))
  2852. $('#overlayUpload .preview [attr-type="height"]').text(toPrecision(overlay.height, 2))
  2853. },
  2854. updateOverlayPanel: function(overlay) {
  2855. this.editPlane = overlay;
  2856. overlay.requestDownload()
  2857. if(overlay._loadDones){
  2858. $('.waiting').addClass('showloading');
  2859. overlay._loadDones.push(()=>{
  2860. $('.waiting').removeClass('showloading');
  2861. })
  2862. }
  2863. var plane = overlay.plane
  2864. var src = plane.material.map && (plane.material.map.image ? plane.material.map.image.src : overlay.fileSrc );
  2865. $('#overlayUpload .preview video').remove();
  2866. overlay.overlayType && this.switchEditType(overlay.overlayType)
  2867. if (overlay.overlayType == "video") {
  2868. var video = plane.material.map.image
  2869. $('#overlayUpload .preview').css({'background-image':"", 'background-size':""}).append(video);
  2870. } else if(overlay.overlayType == "photo" || overlay.overlayType == "text"){
  2871. $('#overlayUpload .preview').css({
  2872. 'background-image': src ? ("url(" + src + ")") : "",
  2873. 'background-size': "contain"
  2874. })
  2875. }else{
  2876. $('#overlayUpload .preview').css({
  2877. 'background-image': "",
  2878. 'background-size': ""
  2879. })
  2880. }
  2881. if (overlay.overlayType) {
  2882. $('#overlayUpload [name="useImgRatio"]').removeClass("hide")
  2883. $('#overlayUpload .preview').addClass('uploaded')
  2884. } else {
  2885. $('#overlayUpload [name="useImgRatio"]').addClass("hide")
  2886. $('#overlayUpload .preview').removeClass('uploaded')
  2887. }
  2888. this.updateOverlayScaleDisplay()
  2889. if (overlay.hasBox) {
  2890. this.scroller.videoDepth.setValue(overlay.scale.z * settings.overlay.depth * 100, true)
  2891. } else {
  2892. this.scroller.videoDepth.setValue(0, true)
  2893. }
  2894. setTimeout(()=>{
  2895. this.scroller.videoDepth.InitOffset()
  2896. }
  2897. , 201)
  2898. this.updatePano()
  2899. },
  2900. //----------------------------
  2901. panoPosSwitchOnChange : function(){
  2902. var on = this.panoPosSwitch.is(':checked')
  2903. if(!on){
  2904. delete this.editPlane.transformAtPanos[getTransformSid()]
  2905. this.editPlane.position.copy(this.editPlane.posCustom)
  2906. this.editPlane.quaternion.copy(this.editPlane.quaCustom)
  2907. var scale = this.editPlane.getScaleBySize(this.editPlane.widthCustom, this.editPlane.heightCustom)
  2908. this.editPlane.scale.set(scale.x, scale.y, this.editPlane.scale.z)
  2909. //this.editPlane.usingTransformData = false
  2910. }
  2911. }
  2912. ,
  2913. getTransformAtPano : function(){
  2914. var name = getTransformSid()
  2915. this.editPlane.transformAtPanos[name] = {
  2916. pos : this.editPlane.position.clone(),
  2917. qua : this.editPlane.quaternion.clone(),
  2918. width : this.editPlane.width,
  2919. height : this.editPlane.height,
  2920. }
  2921. //this.editPlane.usingTransformData = true
  2922. },
  2923. updatePosition:function(){
  2924. var on = this.panoPosSwitch.is(':checked')
  2925. if(on){
  2926. this.getTransformAtPano()
  2927. }else{
  2928. this.editPlane.posCustom.copy(this.editPlane.position)
  2929. }
  2930. },
  2931. updateScale : function(){
  2932. var on = this.panoPosSwitch.is(':checked')
  2933. var size = this.editPlane.getSizeByScale( )
  2934. this.editPlane.width = size.width
  2935. this.editPlane.height = size.height
  2936. if(on){
  2937. this.getTransformAtPano()
  2938. }else{
  2939. this.editPlane.widthCustom = this.editPlane.width
  2940. this.editPlane.heightCustom = this.editPlane.height
  2941. }
  2942. this.updateOverlayScaleDisplay()
  2943. }
  2944. ,
  2945. updateQua : function(){
  2946. var on = this.panoPosSwitch.is(':checked')
  2947. if(on){
  2948. this.getTransformAtPano()
  2949. }else{
  2950. this.editPlane.quaCustom.copy(this.editPlane.quaternion)
  2951. }
  2952. }
  2953. ,
  2954. updatePano:function(){
  2955. if(!EditOverlay.editPlane ) return;
  2956. this.panoPosSwitch.prop('checked', !!EditOverlay.editPlane.transformAtPanos[ getTransformSid()]);
  2957. },
  2958. //------------------------------
  2959. closeOverlayPanel: function(type) {
  2960. if (!this.editPlane)
  2961. return;
  2962. if (type == 'cancel') {
  2963. if (!this.editPlane.isNew && !this.editPlane.needDelete)
  2964. this.editPlane.setFromInfo(this.editPlane.info)
  2965. //this.setOverlayFromInfo(this.editPlane, this.editPlane.info);//恢复
  2966. else
  2967. this.disposeOverlay(this.editPlane);
  2968. //删除
  2969. }
  2970. this.editPlane = null;
  2971. transformControls.detach()
  2972. $("#overlayProp").addClass("atRight");
  2973. //if(player.model.overlayPlanes.length < this.overlayMaxCount) this.beginToAddPlane()
  2974. },
  2975. useImgRatio: function(o) {
  2976. var plane = this.editPlane.plane;
  2977. if (!plane.material.map)
  2978. return;
  2979. var img = plane.material.map.image;
  2980. var mintranRatio = 200;
  2981. //default is 200 , 防止图片太小时在墙上依旧很大
  2982. var width = this.editPlane.overlayType == "video" ? img.videoWidth : img.width;
  2983. var height = this.editPlane.overlayType == "video" ? img.videoHeight : img.height;
  2984. if (o == "suitSize") {
  2985. var boundWidth = Math.min(Math.max(width, height) / mintranRatio, 1)
  2986. if (width > height) {
  2987. var w = boundWidth;
  2988. var h = boundWidth * height / width
  2989. } else {
  2990. var h = boundWidth;
  2991. var w = boundWidth * width / height;
  2992. }
  2993. } else {
  2994. //假设不变总面积
  2995. var k = Math.sqrt(Math.abs(this.editPlane.width * this.editPlane.height) / (width * height))
  2996. var w = k * width * (this.editPlane.width < 0 ? -1 : 1);
  2997. var h = k * height * (this.editPlane.height < 0 ? -1 : 1);
  2998. }
  2999. this.editPlane.scale.setX(w / settings.overlay.width)
  3000. this.editPlane.scale.setY(h / settings.overlay.height)
  3001. this.editPlane.width = w;
  3002. this.editPlane.height = h;
  3003. this.updateScale()
  3004. this.updateOverlayPanel(this.editPlane)
  3005. },
  3006. getOverlayInfo: function(overlay) {
  3007. //2 编辑前, 从当前状态获取info
  3008. var plane = overlay.plane;
  3009. var transformAtPanos = {}
  3010. for(var i in overlay.transformAtPanos){
  3011. transformAtPanos[i] = {
  3012. width : overlay.transformAtPanos[i].width,
  3013. height : overlay.transformAtPanos[i].height,
  3014. pos : overlay.transformAtPanos[i].pos.clone(),
  3015. qua : overlay.transformAtPanos[i].qua.clone(),
  3016. }
  3017. }
  3018. overlay.info = {
  3019. width: overlay.widthCustom,
  3020. height: overlay.heightCustom,
  3021. depth: settings.overlay.depth * overlay.scale.z,
  3022. pos: overlay.posCustom.clone(),
  3023. qua: overlay.quaCustom.clone(),
  3024. media: plane.material.map.image,
  3025. file: overlay.file,
  3026. type: overlay.overlayType,
  3027. hasBox: overlay.hasBox,
  3028. transformAtPanos: transformAtPanos
  3029. }
  3030. },
  3031. getSavingInfo: function(overlay) {
  3032. if (!overlay.file && (!overlay.plane.material.map || !overlay.plane.material.map.image)) {
  3033. return;
  3034. }
  3035. var transformAtPanos = {}
  3036. for(var i in overlay.transformAtPanos){
  3037. transformAtPanos[i] = {
  3038. width : toPrecision(overlay.transformAtPanos[i].width, 4),
  3039. height : toPrecision(overlay.transformAtPanos[i].height, 4),
  3040. pos : toPrecision(overlay.transformAtPanos[i].pos.toArray(), 3),
  3041. qua : toPrecision(overlay.transformAtPanos[i].qua.toArray(), 5)
  3042. }
  3043. }
  3044. var info = {
  3045. width: toPrecision(overlay.widthCustom, 4),
  3046. height: toPrecision(overlay.heightCustom, 4),
  3047. depth: toPrecision(settings.overlay.depth * overlay.scale.z, 4),
  3048. pos: toPrecision(overlay.posCustom.toArray(), 3),
  3049. qua: toPrecision(overlay.quaCustom.toArray(), 5),
  3050. sid: overlay.sid,
  3051. hasBox: overlay.hasBox ? 1 : 0,
  3052. media: [overlay.overlayType],
  3053. file: overlay.fileSrc || overlay.plane.material.map.image.src,
  3054. transformAtPanos : transformAtPanos
  3055. }
  3056. return info
  3057. },
  3058. SaveOverlay: function() {
  3059. var overlay = this.editPlane;
  3060. if (!overlay.file && (!overlay.plane.material.map || !overlay.plane.material.map.image)) {
  3061. this.editType == "video" ? alert("请上传视频") : alert("请上传图片");
  3062. return;
  3063. }
  3064. var saveInfo = ()=>{
  3065. //overlay.savingInfo = JSON.stringify(info)//准备写入的info
  3066. //saveDone:
  3067. overlay.isNew = false;
  3068. overlay.getVisiblePanos()
  3069. this.getOverlayInfo(overlay);
  3070. this.closeOverlayPanel()
  3071. $('.waiting').removeClass('showloading');
  3072. }
  3073. if (!overlay.info || overlay.file != overlay.info.file) {
  3074. $('.waiting').addClass('showloading');
  3075. uploadFile(overlay.file, 'overlay', function(rs) {
  3076. if (rs.code === 0) {
  3077. overlay.fileSrc = rs.data;
  3078. saveInfo()
  3079. }
  3080. ;
  3081. })
  3082. } else
  3083. saveInfo();
  3084. },
  3085. disposeOverlay: function(overlay) {
  3086. var plane = overlay.plane
  3087. if (overlay == player.hoveringPlane) {
  3088. player.hoverOverlay(null, "soon");
  3089. }
  3090. if (plane.material.map) {//删除视频src
  3091. //overlay.info && common.destroyBlob(overlay.info.media.src)
  3092. //common.destroyBlob(plane.material.map.image.src)
  3093. }
  3094. plane.material.dispose();
  3095. overlay.parent.remove(overlay);
  3096. this.removeFromList(overlay)
  3097. //this.beginToAddPlane()
  3098. },
  3099. DeleteOverlay: function() {
  3100. var overlay = this.editPlane;
  3101. if (!overlay.isNew) {
  3102. if (confirm(overlay.overlayType== "photo" ? "确定删除该图片?" : "确定删除该视频?")) {
  3103. overlay.needDelete = true;
  3104. $("#overlayProp a.close").click()
  3105. //this.closeOverlayPanel()
  3106. }
  3107. } else {
  3108. //刚创建时的删除按钮等同于取消按钮
  3109. $("#overlayProp a.close").click()
  3110. //this.closeOverlayPanel()
  3111. }
  3112. },
  3113. addToList: function(overlay) {
  3114. var li = $(`<li class='listItem'><div class="icon"></div><div class="title">${(overlay.overlayType == "video" ? "视频 ":"图片 ")+ overlay.sid}</div></li>`)
  3115. $(".overlayList ul").append(li);
  3116. li.on("click", ()=>{
  3117. player.clickOverlay(overlay)
  3118. player.focusPoint({aim: overlay.position})
  3119. })
  3120. overlay.domLi = li;
  3121. },
  3122. removeFromList: function(overlay) {
  3123. overlay.domLi.remove();
  3124. }
  3125. }
  3126. //----------------漫游可见性---------------------------------
  3127. var VisiSet = {
  3128. setPanoVisible: false,
  3129. setTagVisible: false,
  3130. panoVLines: {},
  3131. //线条
  3132. panoVTemp: {},
  3133. //修改后还没保存的临时数据
  3134. tagVsetting: null,
  3135. //正在设置的热点中心点
  3136. tagsVLines: {},
  3137. //线条
  3138. //tagVTemp //修改后还没保存的临时数据
  3139. $confirmSnap: $("#camera-start"),
  3140. changeBtn : $(".toolMid .midBottom #midBtns>button").eq(1),
  3141. colors: {
  3142. green: "#00c8ae"
  3143. },
  3144. init: function() {
  3145. this.meshGroup = new THREE.Object3D;
  3146. this.meshGroup.name = "setVisible-group"
  3147. player.model.add(this.meshGroup)
  3148. $("#hotVisible").on("click", ()=>{
  3149. VisiSet.enterSet(VisiSet.beginSetTagVisible.bind(VisiSet))
  3150. })
  3151. this.changeBtn.on("click",()=>{//隐藏与显示该点
  3152. if(this.changeBtn.attr("function") == "hide"){
  3153. for(let i in this.panoVLines){
  3154. this.panoVLines[i].visible && this.dealPanoVisible(i);
  3155. }
  3156. }else{
  3157. //显示该点时,显示周围一定距离内、到该点没有遮挡的pano
  3158. //?????
  3159. var list = player.model.panos.sortByScore([e=>e.isAligned()], [(pano)=>{return -pano.position.distanceTo(this.panoVsetting.position)}])
  3160. if(list.length == 1){
  3161. console.log('仅有一个漫游点')
  3162. return;
  3163. }
  3164. var ifBlock = function(panoA, panoB ){
  3165. var A = panoA.position.clone();
  3166. var B = panoB.position.clone();
  3167. return convertTool.ifIntersectChunks(A, B, {})
  3168. }
  3169. var okList
  3170. var s = Math.max(-list[1].score*2, 4); //i==1的一定显示
  3171. for(var i=1;i<list.length;i++){
  3172. if(-list[i].score < s){
  3173. if(ifBlock(this.panoVsetting, list[i].pano)){
  3174. list[i].block = true //有阻挡
  3175. }
  3176. list[i].good = true
  3177. }else{
  3178. okList || (okList = list.filter(e=>e.good && !e.block));//绝对可以使用的
  3179. if(okList.length <2 ){
  3180. if(!ifBlock(this.panoVsetting, list[i].pano)){
  3181. if(okList.length == 0){
  3182. okList.push(list[i])
  3183. }else{//1
  3184. var lastPos = okList[0].pano.position.clone().sub(this.panoVsetting.position).setY(0);
  3185. var thisPos = list[i].pano.position.clone().sub(this.panoVsetting.position).setY(0);
  3186. if(lastPos.angleTo(thisPos) > Math.PI / 2){
  3187. console.log('再加一个 角度'+THREE.Math.radToDeg(lastPos.angleTo(thisPos)))
  3188. break;
  3189. }
  3190. }
  3191. }
  3192. }else{
  3193. break;
  3194. }
  3195. }
  3196. }
  3197. if(okList.length==0){//如果length为0,至少加一个pano, 虽然是遮挡的
  3198. okList.push(list[0].pano)
  3199. }
  3200. okList.forEach(e=>this.dealPanoVisible(e.pano.id))
  3201. console.log(okList)
  3202. }
  3203. })
  3204. },
  3205. enterSet: function(fun) {
  3206. var enter = function() {
  3207. if (player.modeTran.split('-')[1] != "floorplan") {
  3208. setTimeout(fun, 300)
  3209. //提前一点出现
  3210. }
  3211. player.flyToMode("floorplan", fun);
  3212. }
  3213. permitTranMode(false)
  3214. if (!player.modeTran) {
  3215. player.afterCModeFuc = ()=>{
  3216. enter()
  3217. }
  3218. } else
  3219. enter()
  3220. },
  3221. beginSetPanoVisible: function() {
  3222. player.flying || $(".toolLeft").removeClass("unable")
  3223. if (this.setPanoVisible)
  3224. return;
  3225. this.setPanoVisible = true;
  3226. this.panoVTemp = {};
  3227. this.SetOnePanoVisible(player.currentPano)
  3228. //先设置currentPano
  3229. this.$confirmSnap.text('保存当前设置').removeClass("hide")
  3230. //objects.tagManager.hideAllTags();
  3231. this.setDisplay(true)
  3232. this.updateFootIconSize()
  3233. //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话
  3234. for(let i in player.model.hots){
  3235. player.model.hots[i].visi_ = player.model.hots[i].mesh.visible;
  3236. player.model.hots[i].mesh.visible = false
  3237. }
  3238. },
  3239. SetOnePanoVisible: function(pano) {
  3240. //点击某个pano后就对该pano点进行设置
  3241. if (this.panoVsetting == pano)
  3242. return;
  3243. //if (this.panoVsetting) saveLastPanoVi(this.panoVsetting);
  3244. this.panoVsetting = pano;
  3245. //记录正在修改的
  3246. this.delVisibleLines();
  3247. //删除线
  3248. this.showFootIcons(pano, true);
  3249. this.createPanoVisiLines(pano);
  3250. //创线
  3251. this.changeBtn.removeClass('hide')
  3252. },
  3253. saveLastPanoVi: function() {
  3254. //保存刚设置过的pano
  3255. var change = [];
  3256. for (var r in this.panoVLines) {
  3257. var line = this.panoVLines[r];
  3258. if (line.name.indexOf("new") > -1 && line.visible) {
  3259. //新设置为visible且没有取消
  3260. change.push({
  3261. type: "add",
  3262. id: r
  3263. })
  3264. } else if (line.name.indexOf("new") == -1 && !line.visible) {
  3265. //旧的且已经取消
  3266. change.push({
  3267. type: "sub",
  3268. id: r
  3269. })
  3270. }
  3271. }
  3272. if (change.length) {
  3273. //添加双向的neighbour:
  3274. var self = this.searchNeib(this.panoVsetting.id)
  3275. //var seeMarkers_self = self.seeMarkers;
  3276. var neighbourUUIDs_self = self.neighbourUUIDs
  3277. var neighbourPanos_self = self.neighbourPanos;
  3278. for (var i = 0; i < change.length; i++) {
  3279. var other = this.searchNeib(change[i].id)
  3280. //var seeMarkers = other.seeMarkers;
  3281. var neighbourUUIDs = other.neighbourUUIDs;
  3282. var neighbourPanos = other.neighbourPanos;
  3283. if (change[i].type == "add") {
  3284. //seeMarkers.push(this.panoVsetting.id);
  3285. neighbourUUIDs.push(this.panoVsetting.id);
  3286. neighbourPanos[this.panoVsetting.id] = true;
  3287. //seeMarkers_self.push(change[i].id);
  3288. neighbourUUIDs_self.push(change[i].id);
  3289. neighbourPanos_self[change[i].id] = true;
  3290. } else {
  3291. //var index = seeMarkers.indexOf(this.panoVsetting.id);
  3292. //index > -1 && seeMarkers.splice(index, 1);
  3293. var index = neighbourUUIDs.indexOf(this.panoVsetting.id);
  3294. index > -1 && neighbourUUIDs.splice(index, 1);
  3295. neighbourPanos[this.panoVsetting.id] = false;
  3296. //var index = seeMarkers_self.indexOf(change[i].id);
  3297. //index > -1 && seeMarkers_self.splice(index, 1);
  3298. var index = neighbourUUIDs_self.indexOf(change[i].id);
  3299. index > -1 && neighbourUUIDs_self.splice(index, 1);
  3300. neighbourPanos_self[change[i].id] = false;
  3301. }
  3302. this.panoVTemp[change[i].id] = {
  3303. //后面两个是作为保存到后台的数据存储,临时需要用到的是第一个
  3304. neighbourPanos: neighbourPanos,
  3305. //seeMarkers: seeMarkers,
  3306. neighbourUUIDs: neighbourUUIDs
  3307. }
  3308. }
  3309. this.panoVTemp[this.panoVsetting.id] = {
  3310. //加上自己
  3311. neighbourPanos: neighbourPanos_self,
  3312. //seeMarkers: seeMarkers_self,
  3313. neighbourUUIDs: neighbourUUIDs_self
  3314. }
  3315. }
  3316. },
  3317. pauseSetPanoVisible: function(type) {
  3318. //暂停 因为点击了保存设置 但没有退出设置
  3319. if (!this.setPanoVisible)
  3320. return;
  3321. if (type == "unsaved") {
  3322. //中途点击pano从而停止一个热点的设置
  3323. this.saveLastPanoVi();
  3324. } else {
  3325. this.panoVTemp = {};
  3326. //清空数据
  3327. }
  3328. this.delVisibleLines();
  3329. this.showFootIcons();
  3330. //清空选择
  3331. var lastPanoSetting = this.panoVsetting;
  3332. this.panoVsetting = null;
  3333. lastPanoSetting && this.changeFIconState2(lastPanoSetting.footIcon, this.checkHasNeighbor(lastPanoSetting))
  3334. //这句要放在this.panoVsetting = null后。 根据可见性更改透明度
  3335. this.changeBtn.addClass('hide')
  3336. },
  3337. //按理说改变了neighbourPano,tag的初始visible也要改。但是这样还要考虑已经改过的tag。。很麻烦
  3338. finishSetPanoVisible: function() {
  3339. //结束 退出这个设置
  3340. if (!this.setPanoVisible)
  3341. return;
  3342. //否则会加多个侦听
  3343. this.setPanoVisible = false;
  3344. this.hideFootIcons();
  3345. this.delVisibleLines();
  3346. //objects.tagManager.showAllTags();
  3347. this.recoverAllState2();
  3348. this.panoVsetting = null;
  3349. this.panoVTemp = {};
  3350. player.flyoutType = null
  3351. this.$confirmSnap.addClass("hide")
  3352. permitTranMode(true)
  3353. this.setDisplay(false)
  3354. for(let i in player.model.hots){
  3355. player.model.hots[i].mesh.visible = player.model.hots[i].visi_
  3356. }
  3357. },
  3358. changeVisiBtnState: function(state){
  3359. this.changeBtn.attr("function", state ? "hide" : "show")
  3360. this.changeBtn.html(state ? "隐藏该点位置":"显示该点位置")
  3361. },
  3362. recoverAllState2: function() {
  3363. //为了热点可视恢复成pano全部可见
  3364. if(!this.footIcons)return;
  3365. for (var i = 0; i < this.footIcons.length; i++) {
  3366. this.footIcons[i].material.uniforms.opacity.value = 1;
  3367. this.footIcons[i].material.uniforms.map.value = footTex1;
  3368. }
  3369. },
  3370. afterSavePanoVisibles: function() {
  3371. //实施:
  3372. var panos = player.model.panos;
  3373. for (var i in this.panoVTemp) {
  3374. var pano = panos.index[i];
  3375. //pano.seeMarkers = this.panoVTemp[i].seeMarkers;
  3376. pano.neighbourUUIDs = this.panoVTemp[i].neighbourUUIDs;
  3377. pano.neighbourPanos = this.panoVTemp[i].neighbourPanos;
  3378. }
  3379. if (!this.checkHasNeighbor(player.currentPano)) {
  3380. //currentPano变为孤立点 就要换一个防止飞入
  3381. var list = panos.sortByScore([pano=>{
  3382. return this.checkHasNeighbor(pano)
  3383. }
  3384. ], [function(pano) {
  3385. return -pano.position.distanceTo(player.currentPano.position)
  3386. }
  3387. ])
  3388. if (list && list.length) {
  3389. player.currentPano = list[0].pano;
  3390. //找最近的一非孤立点
  3391. //this.noPanoHasNeighbor = false; //更新状态
  3392. } else {//this.noPanoHasNeighbor = true; //更新状态
  3393. }
  3394. } else {//this.noPanoHasNeighbor = false; //更新状态
  3395. }
  3396. //dataDeal.done();
  3397. //暂时:
  3398. this.pauseSetPanoVisible()
  3399. this.updateFootIconSize()
  3400. //更新一下center大小 写在最后
  3401. },
  3402. //最佳推荐操作顺序: 先设置pano可见性 再创建热点 这样热点的visible正确些,否则之后再设置热点可见性会改更多
  3403. savePanoVisibles: function() {
  3404. //保存
  3405. if (this.panoVsetting)
  3406. this.saveLastPanoVi(this.panoVsetting);
  3407. //获取最后设置的那个热点的改动
  3408. var PanoData = [];
  3409. for (var i in this.panoVTemp) {
  3410. PanoData.push({
  3411. //希望算法部不会更改index排序,或者更改后能将visible信息一并更改
  3412. panoID: i,
  3413. //visibles: this.turnToPanoIndex(this.panoVTemp[i].seeMarkers),
  3414. visibles3: this.turnToPanoIndex(this.panoVTemp[i].neighbourUUIDs)
  3415. })
  3416. }
  3417. if (PanoData.length == 0) {
  3418. //没改变
  3419. alert("保存成功")
  3420. return;
  3421. }
  3422. /* this.afterSavePanoVisibles()
  3423. alert("保存成功")
  3424. console.log(JSON.stringify(PanoData)) */
  3425. let url = cmp ? ('/api/scene/roamViable/' + cmp) : '/manage/scene/roamViable'
  3426. $.ajax({
  3427. method: 'POST',
  3428. url: ceshi + url,
  3429. headers: {
  3430. 'Content-Type': 'application/json',
  3431. token: token
  3432. },
  3433. contentType: 'application/json',
  3434. data: JSON.stringify({
  3435. data: JSON.stringify(PanoData),
  3436. sceneCode: window.number
  3437. }),
  3438. success: (data)=>{
  3439. if (data.code === 0) {
  3440. this.afterSavePanoVisibles()
  3441. alert("保存漫游可行成功")
  3442. } else
  3443. alert("保存漫游可行失败")
  3444. if (data.code === 5001) {
  3445. alert('请重新登录')
  3446. localStorage.dcj_token = ''
  3447. location.reload()
  3448. }
  3449. }
  3450. ,
  3451. fail: function() {
  3452. alert("保存漫游可行失败")
  3453. }
  3454. })
  3455. /* var o = {
  3456. name_t: "panoVisible",
  3457. f: this.pauseSetPanoVisible,
  3458. url: Config.prefixEditProPCApi+"/saveLinkPano",
  3459. dialog: i18n.get('设置'),
  3460. data: { data: JSON.stringify(PanoData) }
  3461. }
  3462. var dataDeal = uploadsSaving.saveFucforPC(o);
  3463. dataDeal.group[0] = function () {
  3464. //实施:
  3465. for (var i in player.panoVTemp) {
  3466. var pano = player.model.panos.index[i];
  3467. pano.seeMarkers = player.panoVTemp[i].seeMarkers;
  3468. pano.neighbourUUIDs = player.panoVTemp[i].neighbourUUIDs;
  3469. pano.neighbourPanos = player.panoVTemp[i].neighbourPanos;
  3470. }
  3471. if(!player.model.checkHasNeighbor(player.currentPano)){//currentPano变为孤立点 就要换一个防止飞入
  3472. var list = player.model.panos.sortByScore([function(pano){return player.model.checkHasNeighbor(pano)}],
  3473. [function(pano){return -pano.position.distanceTo(player.currentPano.position)}])
  3474. if(list && list.length){
  3475. player.currentPano = list[0].pano;//找最近的一非孤立点
  3476. player.model.noPanoHasNeighbor = false; //更新状态
  3477. }else{
  3478. player.model.noPanoHasNeighbor = true; //更新状态
  3479. }
  3480. }else{
  3481. player.model.noPanoHasNeighbor = false; //更新状态
  3482. }
  3483. dataDeal.done();
  3484. player.model.updateFootIconSize(player.cameraControls.activeControl)//更新一下center大小 写在最后
  3485. } */
  3486. },
  3487. searchNeib: function(panoId) {
  3488. //寻找某pano的相关neighbour 可能是修改过的
  3489. var panos = player.model.panos;
  3490. var o = {};
  3491. if (this.panoVTemp[panoId]) {
  3492. //o.seeMarkers = this.panoVTemp[panoId].seeMarkers;
  3493. o.neighbourUUIDs = this.panoVTemp[panoId].neighbourUUIDs;
  3494. o.neighbourPanos = this.panoVTemp[panoId].neighbourPanos;
  3495. } else {
  3496. //o.seeMarkers = panos.index[panoId].seeMarkers.slice(0);
  3497. o.neighbourUUIDs = panos.index[panoId].neighbourUUIDs.slice(0);
  3498. o.neighbourPanos = CloneObject(panos.index[panoId].neighbourPanos);
  3499. }
  3500. return o;
  3501. },
  3502. turnToPanoIndex: function(panoArr) {
  3503. var panos = player.model.panos;
  3504. var array = [];
  3505. for (var i = 0; i < panoArr.length; i++) {
  3506. var pano = panos.index[panoArr[i]];
  3507. var index = panos.list.indexOf(pano)
  3508. array.push(index);
  3509. }
  3510. return array;
  3511. },
  3512. setDisplay: function(state) {
  3513. var panos = player.model.panos;
  3514. if (state) {
  3515. this.$confirmSnap.text('保存当前设置');
  3516. this.$confirmSnap.removeClass('hide');
  3517. } else {
  3518. this.$confirmSnap.addClass('hide');
  3519. this.changeBtn.addClass('hide')
  3520. }
  3521. player.path.currentPanoMarker.mesh.visible = !state;
  3522. player.overlayGroup.visible = !state;
  3523. player.reticule.visible = !state;
  3524. },
  3525. delVisibleLines: function() {
  3526. //xzw add 所有线都删除
  3527. for (var i in this.tagsVLines) {
  3528. this.tagsVLines[i].geometry.dispose();
  3529. this.tagsVLines[i].material.dispose();
  3530. this.meshGroup.remove(this.tagsVLines[i]);
  3531. delete this.tagsVLines[i];
  3532. }
  3533. for (var i in this.panoVLines) {
  3534. this.panoVLines[i].geometry.dispose();
  3535. this.panoVLines[i].material.dispose();
  3536. this.meshGroup.remove(this.panoVLines[i]);
  3537. delete this.panoVLines[i];
  3538. }
  3539. },
  3540. //--------panoVisible
  3541. createPanoVisiLines: function(pano) {
  3542. // pano可见性线条
  3543. var neighbours = this.panoVTemp[pano.id] && this.panoVTemp[pano.id].neighbourPanos || pano.neighbourPanos;
  3544. for (var r in neighbours) {
  3545. if (neighbours[r] && r != pano.id) {
  3546. this.createPanoSingleLine(pano, "old", r)
  3547. }
  3548. }
  3549. },
  3550. createPanoSingleLine: function(pano, type, id) {
  3551. //pano是中心
  3552. var panos = player.model.panos;
  3553. var p2 = panos.index[id].floorPosition.clone()
  3554. /* .sub(player.model.position) */
  3555. var line = LineDraw.createLine([pano.floorPosition.clone()/* .sub(this.position) */
  3556. , p2], {
  3557. color: this.colors.green
  3558. });
  3559. this.meshGroup.add(line);
  3560. line.name = "PanoVL-" + type + "-" + id;
  3561. this.panoVLines[id] = line;
  3562. this.changeFIconState(panos.index[id].footIcon, "linked")
  3563. },
  3564. dealPanoVisible: function(id) {
  3565. //外部调用
  3566. var panos = player.model.panos;
  3567. if (this.panoVsetting) {
  3568. if (id == this.panoVsetting.id) {
  3569. //关闭当前pano设置
  3570. this.pauseSetPanoVisible('unsaved')
  3571. } else {
  3572. var link;
  3573. //结果是否连接
  3574. if (this.panoVLines[id]) {
  3575. this.panoVLines[id].visible = !this.panoVLines[id].visible;
  3576. link = this.panoVLines[id].visible;
  3577. this.changeFIconState(panos.index[id].footIcon, this.panoVLines[id].visible ? "linked" : false)
  3578. } else {
  3579. this.createPanoSingleLine(this.panoVsetting, "new", id)
  3580. link = true;
  3581. }
  3582. if (link) {
  3583. //如果连接上了,直接判断该点是可见的(有附近点),(不能通过checkHasNeighbor来判断,因为新增的线条可能不在它的neighbour中
  3584. this.changeFIconState2(panos.index[id].footIcon, true)
  3585. this.changeFIconState2(panos.index[this.panoVsetting.id].footIcon, true)
  3586. } else {
  3587. //否则需要checkHasNeighbor
  3588. this.changeFIconState2(panos.index[id].footIcon, this.checkHasNeighbor(panos.index[id]))
  3589. this.changeFIconState2(panos.index[this.panoVsetting.id].footIcon, this.checkHasNeighbor(this.panoVsetting))
  3590. }
  3591. /* if(window.routeArray){
  3592. if(this.panoVLines[id].visible)window.routeArray.push(id)
  3593. else{
  3594. let index = window.routeArray.indexOf(id)
  3595. index > -1 && routeArray.splice(index, 1)
  3596. }
  3597. } */
  3598. }
  3599. } else {
  3600. //点击开始设置要设置的pano
  3601. this.SetOnePanoVisible(panos.index[id])
  3602. }
  3603. this.updateFootIconSize()
  3604. },
  3605. showFootIcons: function(pano, isPanovisible) {
  3606. if (!this.footIcons) {
  3607. footTex1 = Texture.load("images/edit/End_128.png");
  3608. //Store.FootIcon);
  3609. footTex2 = Texture.load("images/edit/End_unable_128.png");
  3610. //Store.FootIcon_unable);
  3611. this.footIcons = [];
  3612. var scale = 0.4;
  3613. scale *= 40 / Math.sqrt(Math.min($("#player").width(), $("#player").height()));
  3614. //屏幕越小,放得越大
  3615. scale = THREE.Math.clamp(scale, 0.3, 0.7)
  3616. //console.log("scale"+scale)
  3617. var geo = new THREE.PlaneGeometry(scale,scale,1,1)
  3618. var panos = player.model.panos;
  3619. for (var r in panos.index) {
  3620. if (!panos.index[r].isAligned())
  3621. continue;
  3622. var t = THREE.UniformsUtils.clone(shaders.waypoint.uniforms);
  3623. t.map.value = footTex1
  3624. t.color.value.set("#ffffff");
  3625. var mat = new THREE.RawShaderMaterial({
  3626. vertexShader: shaders.waypoint.vertexShader,
  3627. fragmentShader: shaders.waypoint.fragmentShader,
  3628. uniforms: t,
  3629. side: THREE.DoubleSide,
  3630. transparent: !0,
  3631. depthWrite: !1,
  3632. depthTest: false,
  3633. name: "footIcon"
  3634. })
  3635. var foot = new THREE.Mesh(geo,mat)
  3636. foot.position.copy(panos.index[r].floorPosition.clone()/* .sub(player.model.position) */
  3637. )
  3638. foot.lookAt(foot.position.clone().add(new THREE.Vector3(0,1,0)));
  3639. foot.name = panos.index[r].id;
  3640. foot.visible = false;
  3641. foot.renderOrder = 6,
  3642. panos.index[r].footIcon = foot;
  3643. this.meshGroup.add(foot);
  3644. this.footIcons.push(foot)
  3645. }
  3646. }
  3647. for (var i = 0; i < this.footIcons.length; i++) {
  3648. this.footIcons[i].visible = true;
  3649. this.changeFIconState(this.footIcons[i], false)
  3650. var panos = player.model.panos;
  3651. if (isPanovisible) {
  3652. this.changeFIconState2(this.footIcons[i], this.checkHasNeighbor(panos.index[this.footIcons[i].name], "showFoot"))
  3653. }
  3654. if (pano && (this.footIcons[i].name == pano.id)) {
  3655. //pano为中心 或者 currentPano 所以放大一点
  3656. this.footIcons[i].oriScale = new THREE.Vector3(1.5,1.5,1.5)
  3657. if (isPanovisible) {
  3658. //currentPano特殊些:
  3659. this.changeFIconState(this.footIcons[i], "center")
  3660. //this.footIcons[i].Unclick = true;//不让点击和hover
  3661. }
  3662. } else {
  3663. this.footIcons[i].oriScale = new THREE.Vector3(1,1,1)
  3664. }
  3665. }
  3666. },
  3667. checkHasNeighbor: function(pano, state) {
  3668. //检查当前状态pano点是否有可通行点
  3669. var neighbours = /* this.panoVTemp && */
  3670. this.panoVTemp[pano.id] ? this.panoVTemp[pano.id].neighbourPanos : pano.neighbourPanos;
  3671. if (state != "showFoot" && pano == this.panoVsetting) {
  3672. //是中心点的话。state == "showFoot"代表是showFootIcon时, 这时候线还没创建,无法用线判断中心点有几个相邻点,直接用neighbourPanos
  3673. for (var i in this.panoVLines) {
  3674. if (this.panoVLines[i].visible) {
  3675. return true;
  3676. //有一条线即可
  3677. }
  3678. }
  3679. return;
  3680. }
  3681. for (var i in neighbours) {
  3682. if (i == pano.id)
  3683. continue;
  3684. if (neighbours[i]) {
  3685. if (this.panoVsetting && this.panoVsetting.id == i && this.panoVLines[pano.id] && !this.panoVLines[pano.id].visible)
  3686. continue;
  3687. return true;
  3688. }
  3689. }
  3690. return false;
  3691. },
  3692. /* ifAllPanoNoNeighbor : function(){//检查是否全是孤立点
  3693. var panos = player.model.panos;
  3694. for(var i in panos.index){
  3695. if(this.checkHasNeighbor(panos.index[i])){
  3696. return false;
  3697. }
  3698. }
  3699. this.noPanoHasNeighbor = true;
  3700. return true;//是全部没有neighbour
  3701. }, */
  3702. changeFIconState: function(footIcon, state) {
  3703. var color = state == "linked" ? this.colors.green : (state == "center" ? /* "#d7f244" */
  3704. "#d5f12e" : "#ffffff");
  3705. footIcon.material.uniforms.color.value.set(color)
  3706. },
  3707. changeFIconState2: function(footIcon, state) {
  3708. //是可见点还是不可见点
  3709. if (state) {
  3710. footIcon.material.uniforms.map.value = footTex1;
  3711. if (this.panoVsetting) {
  3712. if (this.panoVsetting.id != footIcon.name) {
  3713. footIcon.material.uniforms.opacity.value = 1;
  3714. } else {
  3715. this.changeVisiBtnState(true)
  3716. }
  3717. }
  3718. } else {
  3719. //不可见
  3720. footIcon.material.uniforms.map.value = footTex2;
  3721. if (!this.panoVsetting || this.panoVsetting.id != footIcon.name) {
  3722. //非中心点时
  3723. footIcon.material.uniforms.opacity.value = 0.5;
  3724. } else {
  3725. //变为中心点时
  3726. footIcon.material.uniforms.opacity.value = 1;
  3727. this.changeVisiBtnState(false)
  3728. }
  3729. }
  3730. },
  3731. hideFootIcons: function() {
  3732. if (!this.footIcons)
  3733. return;
  3734. for (var i = 0; i < this.footIcons.length; i++) {
  3735. this.footIcons[i].visible = false;
  3736. }
  3737. },
  3738. updateFootIconSize: function() {
  3739. //根据相机位置 改变footIcon大小,使在范围内看到的热点大小一致,防止太小点击不到
  3740. if (!this.footIcons)
  3741. return;
  3742. var s = player.cameraControls.controls.floorplan.absoluteScale * 2.8;
  3743. s = THREE.Math.clamp(s, 0.5, 1.4);
  3744. this.footIcons.forEach(function(f) {
  3745. try {
  3746. f.scale.copy(f.oriScale).multiplyScalar(s);
  3747. } catch (e) {
  3748. console.log(e)
  3749. }
  3750. })
  3751. }
  3752. //========热点可见性==============
  3753. ,
  3754. beginSetTagVisible: function() {
  3755. if (this.setTagVisible)
  3756. return;
  3757. $(".toolTop").addClass("unable")
  3758. $("#hotVisible").addClass("unable")
  3759. this.setTagVisible = true;
  3760. this.tagVTemp = {};
  3761. this.$confirmSnap.text('完成设置').removeClass("hide")
  3762. //objects.tagManager.hideAllTags();
  3763. for (let i in player.model.hots) {
  3764. player.model.hots[i]._isSprite = player.model.hots[i].isSprite;
  3765. player.model.hots[i].isSprite = true;
  3766. player.model.hots[i].mesh.material.depthTest = false;
  3767. }
  3768. this.setDisplay(true)
  3769. this.updateFootIconSize()
  3770. //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话
  3771. },
  3772. SetOneTagVisible: function(tag) {
  3773. //点击某个热点后就对该热点进行设置,或者在热点修改时对其进行设置
  3774. if (this.tagVsetting == tag)
  3775. return;
  3776. if (this.tagVsetting) {
  3777. this.saveLastTagVi(this.tagVsetting);
  3778. //this.tagVsetting.setElemType(this.tagVsetting.style, this.tagVsetting.styleImageURL);
  3779. }
  3780. this.tagVsetting = tag;
  3781. //记录正在修改的
  3782. this.delVisibleLines();
  3783. //删除线
  3784. this.showFootIcons(player.currentPano);
  3785. this.createTagVisiLines(tag);
  3786. //创线
  3787. this.updateFootIconSize()
  3788. //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话
  3789. },
  3790. saveLastTagVi: function() {
  3791. //保存刚设置过的tag
  3792. var change = false;
  3793. var newVPs = this.tagVTemp[this.tagVsetting.sid] || this.tagVsetting.visiblePanos.slice(0);
  3794. for (var r in this.tagsVLines) {
  3795. var line = this.tagsVLines[r];
  3796. if (line.name.indexOf("new") > -1 && line.visible) {
  3797. //新设置为visible且没有取消
  3798. newVPs.push(r)
  3799. change = true;
  3800. //console.log("add: "+r)
  3801. } else if (line.name.indexOf("new") == -1 && !line.visible) {
  3802. //旧的且已经取消
  3803. var i = newVPs.indexOf(r);
  3804. if (i == -1) {
  3805. console.log("visiblePanos删除error");
  3806. continue;
  3807. }
  3808. newVPs.splice(i, 1);
  3809. change = true;
  3810. //console.log("sub: "+r)
  3811. }
  3812. }
  3813. if (change) {
  3814. this.tagVTemp[this.tagVsetting.sid] = newVPs;
  3815. }
  3816. },
  3817. pauseSetTagVisible: function() {
  3818. //pc保存后删除连线 但还在继续设置 点选热点即开始
  3819. if (!this.setTagVisible || !this.tagVsetting)
  3820. return;
  3821. //this.tagVsetting.setElemType(this.tagVsetting.style, this.tagVsetting.styleImageURL );
  3822. this.delVisibleLines();
  3823. this.hideFootIcons();
  3824. this.tagVTemp = {};
  3825. this.tagVsetting = null;
  3826. },
  3827. finishSetTagVisible: function() {
  3828. if (!this.setTagVisible)
  3829. return;
  3830. $(".toolTop").removeClass("unable")
  3831. $("#hotVisible").removeClass("unable")
  3832. this.pauseSetTagVisible();
  3833. this.setTagVisible = false;
  3834. this.setDisplay(false)
  3835. this.$confirmSnap.addClass("hide")
  3836. permitTranMode(true)
  3837. /* for (var r in objects.tagManager.tags) {
  3838. if(objects.tagManager.tags[r].state == "videoPanoFlag")continue;
  3839. objects.tagManager.tags[r].disc.visible = false;
  3840. objects.tagManager.tags[r].disc.material.depthTest = true;
  3841. } */
  3842. for (let i in player.model.hots) {
  3843. player.model.hots[i].isSprite = player.model.hots[i]._isSprite;
  3844. player.model.hots[i].isSprite || player.model.hots[i].mesh.quaternion.copy(player.model.hots[i].quaternion)
  3845. player.model.hots[i].mesh.material.depthTest = true;
  3846. }
  3847. },
  3848. /* saveTagVisibles : function () { //保存到服务器
  3849. if (this.tagVsetting) this.saveLastTagVi(this.tagVsetting); //获取最后设置的那个热点的改动
  3850. //可能出现数据没变但保存的情况。比如先改变了然后切换别的热点但切换回来时又改回来。
  3851. var tags = [];
  3852. for (var i in this.tagVTemp) {
  3853. tags.push({
  3854. sid: i,
  3855. value: this.tagVTemp[i]//turnToPanoIndex(this.tagVTemp[i])
  3856. })
  3857. }
  3858. if (tags.length == 0) {//没有需要保存的改动
  3859. this.finishSetTagVisible()
  3860. return;
  3861. }
  3862. return tags;
  3863. } */
  3864. //afterSaveTagVisibles : function(){
  3865. saveTagVisibles: function() {
  3866. if (this.tagVsetting)
  3867. this.saveLastTagVi(this.tagVsetting);
  3868. for (var i in this.tagVTemp) {
  3869. //保持成功于是生效
  3870. player.model.hots[i].visiblePanos = this.tagVTemp[i];
  3871. }
  3872. this.finishSetTagVisible()
  3873. //还是保存完直接结束吧,因为现在热点可视不放在单独的设置页面了
  3874. },
  3875. createTagVisiLines: function(tag) {
  3876. // 热点可见性线条
  3877. var panos = player.model.panos;
  3878. tag.visiblePanos || tag.setVisiblePanos("get")
  3879. var visibleList = this.tagVTemp[tag.sid] || tag.visiblePanos;
  3880. //如果是刚在设置的要读取设置过的数据
  3881. for (var r = 0; r < visibleList.length; r++) {
  3882. var pano = panos.index[visibleList[r]];
  3883. this.createTagSingleLine(pano, "old", tag)
  3884. }
  3885. },
  3886. createTagSingleLine: function(pano, type, tag) {
  3887. var panos = player.model.panos;
  3888. var line = LineDraw.createLine([pano.floorPosition.clone()/* .sub(this.position) */
  3889. , tag.mesh.position.clone()], {
  3890. color: this.colors.green
  3891. });
  3892. this.meshGroup.add(line);
  3893. line.name = "tagVL-" + type + "-" + pano.id;
  3894. this.tagsVLines[pano.id] = line;
  3895. this.changeFIconState(panos.index[pano.id].footIcon, "linked")
  3896. },
  3897. dealTagVisible: function(tag, panoName) {
  3898. //外部调用
  3899. var panos = player.model.panos;
  3900. if (this.tagsVLines[panoName]) {
  3901. this.tagsVLines[panoName].visible = !this.tagsVLines[panoName].visible;
  3902. this.changeFIconState(panos.index[panoName].footIcon, this.tagsVLines[panoName].visible ? "linked" : false)
  3903. } else {
  3904. this.createTagSingleLine(panos.index[panoName], "new", tag)
  3905. }
  3906. },
  3907. delVisibleLines: function() {
  3908. //xzw add 所有线都删除
  3909. for (var i in this.tagsVLines) {
  3910. this.tagsVLines[i].geometry.dispose();
  3911. this.tagsVLines[i].material.dispose();
  3912. this.meshGroup.remove(this.tagsVLines[i]);
  3913. delete this.tagsVLines[i];
  3914. }
  3915. for (var i in this.panoVLines) {
  3916. this.panoVLines[i].geometry.dispose();
  3917. this.panoVLines[i].material.dispose();
  3918. this.meshGroup.remove(this.panoVLines[i]);
  3919. delete this.panoVLines[i];
  3920. }
  3921. }
  3922. }
  3923. function permitTranMode(state) {
  3924. state ? $(".pinBottom.left").removeClass('hide') : $(".pinBottom.left").addClass('hide');
  3925. }
  3926. CloneObject = function(copyObj, result, isSimpleCopy) {
  3927. //isSimpleCopy只复制最外层
  3928. //复制json result的可能:普通数字或字符串、普通数组、复杂对象
  3929. result = result || {};
  3930. if (copyObj instanceof Array) {
  3931. if (copyObj[0]instanceof Object) {
  3932. //不支持含有 [[Object]] 这样二级数组里面还是复杂数据的,普通和复杂的数据混合可能也不支持
  3933. console.error("不支持含有 [[Object]] 这样二级数组里面还是复杂数据的...")
  3934. }
  3935. return copyObj.slice(0);
  3936. //如果是数组,直接复制返回(排除数组内是object
  3937. }
  3938. for (var key in copyObj) {
  3939. if (copyObj[key]instanceof Object && !isSimpleCopy)
  3940. result[key] = CloneObject(copyObj[key]);
  3941. else
  3942. result[key] = copyObj[key];
  3943. //如果是函数类同基本数据,即复制引用
  3944. }
  3945. return result;
  3946. }
  3947. ;
  3948. function randomWord(randomFlag, min, max) {
  3949. //随机字符串
  3950. var str = ""
  3951. , range = min
  3952. , arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
  3953. if (randomFlag) {
  3954. // 随机长度
  3955. range = Math.round(Math.random() * (max - min)) + min;
  3956. }
  3957. for (var i = 0; i < range; i++) {
  3958. var pos = Math.round(Math.random() * (arr.length - 1));
  3959. str += arr[pos];
  3960. }
  3961. return str;
  3962. }
  3963. function getRandomSid() {
  3964. //5-7位随机字符串 + 6位时间 为热点准备
  3965. var pre = randomWord(true, 5, 7);
  3966. var post = new Date().getTime() + "";
  3967. var len = post.length;
  3968. post = post.substring(len - 8, len - 5) + post.substring(len - 3, len)
  3969. //其实还是有可能重复的....
  3970. return pre + post;
  3971. }
  3972. function searchParent(searchArea, o, maxTimes) {
  3973. //是否是某种元素的下级,并找出该元素
  3974. maxTimes = maxTimes || 20;
  3975. var count = 0
  3976. var f = function(dom) {
  3977. if (o.id && o.id == dom.id)
  3978. return dom
  3979. else if (o.className && dom.classList && dom.classList.contains(o.className))
  3980. return dom
  3981. else if (o.tagName && dom.tagName && o.tagName.toUpperCase() == dom.tagName.toUpperCase())
  3982. return dom
  3983. }
  3984. var find;
  3985. while (searchArea && count < maxTimes) {
  3986. if (find = f(searchArea))
  3987. return find
  3988. searchArea = searchArea.parentNode;
  3989. count++;
  3990. }
  3991. }
  3992. class ListBox{//下拉列表
  3993. //elemArr:初始的列表,内含每项的dom.
  3994. constructor(elemArr, $rootDom, options={}){
  3995. this.listDom = $rootDom.find('ul.list')
  3996. this.listTitle = $rootDom.find('.selection')
  3997. this.chosenItem = null
  3998. this.options = options;
  3999. this.bindEvents()
  4000. elemArr.forEach(($dom, i)=>{
  4001. this.addItem($dom)
  4002. })
  4003. }
  4004. updateSelectDisplay(){
  4005. this.listDom.children().removeClass('selected')
  4006. this.chosenItem && this.chosenItem.addClass("selected")
  4007. this.options.selectFun(this.chosenIndex)
  4008. }
  4009. selectFromOutSide(index ){
  4010. this.chosenIndex = index;
  4011. this.chosenItem = index == void 0 ? null : this.listDom.children().eq(index)
  4012. this.updateSelectDisplay()
  4013. }
  4014. addItem($dom){
  4015. this.listDom.append($dom)
  4016. if(this.options.addFun){
  4017. this.options.addFun($dom)
  4018. }
  4019. $dom.on('click',()=>{
  4020. this.chosenItem = $dom;
  4021. this.chosenIndex = $dom.index();
  4022. this.updateSelectDisplay()
  4023. })
  4024. }
  4025. removeItem($dom){
  4026. $dom.remove()
  4027. if(this.options.delFun){
  4028. this.options.delFun($dom)
  4029. }
  4030. }
  4031. saveTemp(){//编辑热点时保存一份副本
  4032. this.temp = Array.from(this.listDom.children()).map((li)=>{
  4033. return li.outerHTML
  4034. })
  4035. this.options.saveTemp && this.options.saveTemp(this)
  4036. }
  4037. recover(){//取消编辑时恢复
  4038. this.listDom.html('')
  4039. this.temp.forEach(html=>{
  4040. this.addItem($(html));
  4041. })
  4042. this.options.recover && this.options.recover(this)
  4043. this.selectFromOutSide(this.chosenIndex)
  4044. }
  4045. bindEvents(){
  4046. this.listTitle.on('click',(e)=>{
  4047. e.stopPropagation()
  4048. this.listDom.toggleClass('hide')
  4049. })
  4050. document.addEventListener('click',()=>{
  4051. this.listDom.addClass('hide')
  4052. })
  4053. }
  4054. }