edit.js 167 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958
  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 = sid;
  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. var bytes = window.atob(urlData.split(',')[1]);
  1968. //去掉url的头,并转换为byte
  1969. //处理异常,将ascii码小于0的转换为大于0
  1970. var ab = new ArrayBuffer(bytes.length);
  1971. var ia = new Uint8Array(ab);
  1972. for (var i = 0; i < bytes.length; i++) {
  1973. ia[i] = bytes.charCodeAt(i);
  1974. }
  1975. var blob = new Blob([ab],{
  1976. type: 'image/jpeg',
  1977. });
  1978. uploadFile(blob, 'hot/images', callback, fileName);
  1979. }
  1980. //上传文件
  1981. function uploadFile(file, type, callback, fileName) {
  1982. $(".edit-loading").removeClass("hide");
  1983. var formData = new FormData()
  1984. formData.append('name', number)
  1985. formData.append('dir', type)
  1986. formData.append('random', true)
  1987. //formData.append('file', file)
  1988. formData.append("file", file, fileName);
  1989. let url = cmp ? ('/api/scene/upload/' + number) : ('/manage/scene/upload/' + number)
  1990. $.ajax({
  1991. url: ceshi + url,
  1992. data: formData,
  1993. headers: {
  1994. token: token
  1995. },
  1996. dataType: 'json',
  1997. type: 'POST',
  1998. cache: false,
  1999. //上传文件无需缓存
  2000. processData: false,
  2001. //用于对data参数进行序列化处理 这里必须false
  2002. contentType: false,
  2003. //必须
  2004. success: function(rs) {
  2005. if (rs.code === 5001) {
  2006. alert('请重新登录')
  2007. localStorage.dcj_token = ''
  2008. location.reload()
  2009. }
  2010. callback(rs, file);
  2011. $(".edit-loading").addClass("hide");
  2012. }
  2013. })
  2014. }
  2015. function _animate(prevRect, target) {
  2016. var ms = 300;
  2017. if (ms) {
  2018. var currentRect = target.getBoundingClientRect();
  2019. if (prevRect.nodeType === 1) {
  2020. prevRect = prevRect.getBoundingClientRect();
  2021. }
  2022. _css(target, 'transition', 'none');
  2023. _css(target, 'transform', 'translate3d(' + (prevRect.left - currentRect.left) + 'px,' + (prevRect.top - currentRect.top) + 'px,0)');
  2024. target.offsetWidth;
  2025. // 触发重绘
  2026. //放在timeout里面也可以
  2027. // setTimeout(function() {
  2028. // _css(target, 'transition', 'all ' + ms + 'ms');
  2029. // _css(target, 'transform', 'translate3d(0,0,0)');
  2030. // }, 0);
  2031. _css(target, 'transition', 'all ' + ms + 'ms');
  2032. _css(target, 'transform', 'translate3d(0,0,0)');
  2033. clearTimeout(target.animated);
  2034. target.animated = setTimeout(function() {
  2035. _css(target, 'transition', '');
  2036. _css(target, 'transform', '');
  2037. target.animated = false;
  2038. }, ms);
  2039. }
  2040. }
  2041. //给元素添加style
  2042. function _css(el, prop, val) {
  2043. var style = el && el.style;
  2044. if (style) {
  2045. if (val === void 0) {
  2046. if (document.defaultView && document.defaultView.getComputedStyle) {
  2047. val = document.defaultView.getComputedStyle(el, '');
  2048. } else if (el.currentStyle) {
  2049. val = el.currentStyle;
  2050. }
  2051. return prop === void 0 ? val : val[prop];
  2052. } else {
  2053. if (!(prop in style)) {
  2054. prop = '-webkit-' + prop;
  2055. }
  2056. style[prop] = val + (typeof val === 'string' ? '' : 'px');
  2057. }
  2058. }
  2059. }
  2060. function upload($files, type, cb) {
  2061. var length = $files.length
  2062. var rcount = 0
  2063. var result = []
  2064. Array.from($files).forEach(function(dFile, index) {
  2065. //a 标签的success 是用来判断是否是已经上传过的文件
  2066. //attr-thum 属性是视频的图片
  2067. //videoURL 是判断是否有视频
  2068. var $file = $(dFile)
  2069. var $image = type == 'videos' ? $file.find('img.play-video') : $file.find('img')
  2070. if ($file.hasClass('success')) {//已经上传过,有链接
  2071. if ($file.attr('attr-thum')) {//视频的封面
  2072. result[index] = $file.attr('attr-thum')
  2073. } else if ($image.attr('videoURL')) {//视频
  2074. result[index] = $image.attr('videoURL')
  2075. } else {
  2076. result[index] = $image.attr('src')
  2077. }
  2078. return success(++rcount);
  2079. } else {
  2080. switch ($file[0].localName) {
  2081. case "input":
  2082. dFile = $file[0]
  2083. break;
  2084. case "span"://封面
  2085. dFile = $file.find('input')[0];
  2086. break;
  2087. case "a"://重传的图or视频
  2088. dFile = {files:[$file[0].file]}
  2089. //dFile = $file.find('input')[0];
  2090. break;
  2091. default:
  2092. dFile = $file.closest("li").find('.upload input')[0];
  2093. break;
  2094. }
  2095. // dFile = $file[0].localName === "input" ? $file[0] : $file[0].localName === "span" ? $file.find('input')[0] : $file.closest("li").find('.upload input')[0];
  2096. }
  2097. var file = (dFile.files && dFile.files[0]) || '';
  2098. if (!file)
  2099. return success(++rcount);
  2100. uploadFile(file, 'hot/' + type, function(rs) {
  2101. //似乎所有图保存路径都是这个hot/前缀。图地址 :"场景id/edit/重新生成的文件名.原后缀", 展示页面也是。
  2102. if (rs.code === 0) {
  2103. result[index] = rs.data
  2104. }
  2105. ;success(++rcount);
  2106. })
  2107. })
  2108. //判断当前队列元素是否处理成功
  2109. function success() {
  2110. if (rcount === length) {
  2111. cb(result)
  2112. }
  2113. }
  2114. success()
  2115. }
  2116. function getIndex(el) {
  2117. let index = 0;
  2118. if (!el || !el.parentNode) {
  2119. return -1;
  2120. }
  2121. while (el && (el = el.previousElementSibling)) {
  2122. index++;
  2123. }
  2124. return index;
  2125. }
  2126. dataURLtoBlob = function(dataurl) {
  2127. //将base64转换blob
  2128. var arr = dataurl.split(',')
  2129. , mime = arr[0].match(/:(.*?);/)[1]
  2130. , bstr = atob(arr[1])
  2131. , n = bstr.length
  2132. , u8arr = new Uint8Array(n);
  2133. while (n--) {
  2134. u8arr[n] = bstr.charCodeAt(n);
  2135. }
  2136. return new Blob([u8arr],{
  2137. type: mime
  2138. });
  2139. }
  2140. ;
  2141. //=========================
  2142. var eachMaxWeights = {
  2143. //大小限制
  2144. "photo": 10,
  2145. "video": 1000,//50, expand size for overlayVideo
  2146. //20,
  2147. "audio": 10 //5
  2148. }
  2149. var supportTypes = {
  2150. //支持后缀
  2151. "photo": ["jpg", "png", "jpeg", "bmp", "gif"],
  2152. "audio": ["mp3", "aac", "ogg", "wav"/* , "m4a" */
  2153. ],
  2154. "video": ["mp4", "mov"/* ,"webm", "rmvb", "wmv" */
  2155. ]//ios:mov
  2156. }
  2157. function getExt(name) {
  2158. //后缀
  2159. if (name.indexOf('.') > -1) {
  2160. var a = name.split(".");
  2161. return a.pop();
  2162. } else {
  2163. return '';
  2164. }
  2165. }
  2166. function detectType(fileName) {
  2167. //检测文件后缀类型
  2168. console.log("名:" + fileName)
  2169. var ext = getExt(fileName);
  2170. console.log("后缀:" + ext)
  2171. //不一定所有浏览器都可以
  2172. var type;
  2173. //仅能根据后缀判断类型,尽管后缀可能被修改。 其他方法如file.type和base64开头的字符串均是根据后缀。
  2174. for (var i in supportTypes) {
  2175. if (supportTypes[i].indexOf(ext.toLowerCase()) > -1) {
  2176. type = i;
  2177. break;
  2178. }
  2179. }
  2180. if (type) {
  2181. return type;
  2182. } else {
  2183. return false;
  2184. }
  2185. }
  2186. //手机上的相片会不会太大?
  2187. var detectWeights = function(file, type) {
  2188. //检测大小
  2189. var size = file.size / 1024 / 1024;
  2190. console.log("weight" + size)
  2191. var over;
  2192. if (size > eachMaxWeights[type]) {
  2193. over = Math.ceil(size * 100) / 100;
  2194. }
  2195. return over;
  2196. }
  2197. var exitUpload = function(input) {
  2198. $('.waiting').removeClass('showloading');
  2199. input.value = "";
  2200. }
  2201. var inputMedia = function(options, type, e) {
  2202. var input = e.target;
  2203. if (!window.FileReader) {
  2204. alert('您的浏览器不支持上传文件');
  2205. exitUpload(input);
  2206. return;
  2207. } else if (e.target.files.length === 0) {
  2208. /* exitUpload(input); */
  2209. return;
  2210. }
  2211. $('.waiting').addClass('showloading');
  2212. var file = e.target.files[0];
  2213. var elemType = type;
  2214. var inputType = detectType(file.name);
  2215. var chType = {
  2216. "photo": '图片',
  2217. "video": '视频',
  2218. "audio": '音乐'
  2219. }
  2220. var overWeight = detectWeights(file, inputType);
  2221. if (elemType) {
  2222. //有指定其中一种类型
  2223. if (inputType != elemType) {
  2224. alert("您选择的不是浏览器支持的" + chType[elemType] + '文件,请重新选择');
  2225. exitUpload(e.target);
  2226. return;
  2227. }
  2228. } else {
  2229. if (!options.enableTypes.includes(inputType)) {
  2230. var text = "";
  2231. options.enableTypes.forEach((type,index)=>{
  2232. text += ((index != 0 ? " / " : "") + chType[elemType])
  2233. }
  2234. )
  2235. alert("您选择的不是浏览器支持的" + text + '文件,请重新选择');
  2236. exitUpload(e.target);
  2237. return;
  2238. }
  2239. }
  2240. if (overWeight) {
  2241. alert(`文件过大(${overWeight}兆),不能大于${eachMaxWeights[inputType]} 兆`)
  2242. exitUpload(e.target);
  2243. return;
  2244. }
  2245. var loadError = function() {
  2246. exitUpload(e.target);
  2247. alert(`文件出错, 无法加载此${chType[inputType]}文件。 文件可能损坏,或者浏览器不支持,或者后缀与文件不匹配。建议在IE以外的浏览器上传`)
  2248. }
  2249. deal();
  2250. function deal(fi) {
  2251. console.log('开始deal文件')
  2252. var reader = new FileReader();
  2253. //reader.name = file.name;
  2254. file = fi || file;
  2255. reader.readAsDataURL(file);
  2256. reader.onload = function(evt) {
  2257. var blob = dataURLtoBlob(evt.target.result);
  2258. var blobSrc = window.URL.createObjectURL(blob);
  2259. if (inputType == "photo") {
  2260. /* EXIF.getData(file, function () {
  2261. //获取相片旋转
  2262. EXIF.getAllTags(this);
  2263. var orient = EXIF.getTag(this, 'Orientation');
  2264. var img = new Image();
  2265. img.src = evt.target.result;
  2266. img.onload = function (e) { //这时img才有宽高,才能赋予texture宽高
  2267. var smallerImg = CompressImg(e.target, {
  2268. weight: blob.size,
  2269. maxWeight: 0.5 * 1024 * 1024,
  2270. maxSize: 1480
  2271. });
  2272. //最大500k
  2273. smallerImg.onload = function () {
  2274. var f = function (resultImg) {//处理结束回调
  2275. options.photoDone(resultImg)
  2276. $('.waiting').removeClass('showloading');
  2277. }
  2278. Rotate(smallerImg, orient, f)
  2279. window.URL.revokeObjectURL(blobSrc);
  2280. }
  2281. }
  2282. .bind(this)
  2283. img.onerror = loadError;
  2284. }); */
  2285. var img = new Image();
  2286. img.src = blobSrc;
  2287. img.base64Src = evt.target.result;
  2288. img.file = file;
  2289. img.onload = function(e) {
  2290. options.photoDone(img)
  2291. $('.waiting').removeClass('showloading');
  2292. }
  2293. } else if (inputType == "video") {
  2294. var video = $('<video controls="controls" x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload"></video>')[0]
  2295. video.setAttribute("crossOrigin", 'Anonymous')
  2296. //要在src设置好前解决跨域
  2297. $(video).on('contextmenu', function() {
  2298. return false;
  2299. });
  2300. //禁止右键点击出现选项(尤其是下载选项)
  2301. $(video).attr('src', blobSrc);
  2302. //华为无法使用blobSrc,否则加载不出来
  2303. //$(video).attr('src', evt.target.result);
  2304. video.base64Src = evt.target.result;
  2305. var hasload = false;
  2306. var error = false;
  2307. var up = function() {
  2308. if (hasload)
  2309. return;
  2310. hasload = true;
  2311. options.videoDone(file, video)
  2312. $('.waiting').removeClass('showloading');
  2313. }
  2314. video.addEventListener('loadeddata', function(e) {
  2315. up()
  2316. })
  2317. //video.onerror = loadError;
  2318. video.onerror = function(e) {
  2319. console.log('error')
  2320. error = true;
  2321. loadError();
  2322. //将mp4改成mov后缀会error
  2323. }
  2324. } else if (inputType == "audio") {
  2325. //林俊波 new Howl For IE&Safari:
  2326. var sound = new Howl({
  2327. src: [blobSrc],
  2328. format: ["mp3"]
  2329. });
  2330. // Clear listener after first call.
  2331. sound.once('load', function() {
  2332. console.log('loaded sound')
  2333. sound.unload()
  2334. console.log("audio.onloadeddata");
  2335. var audio = new Audio;
  2336. audio.controls = "controls";
  2337. audio.src = blobSrc;
  2338. audio.base64Src = evt.target.result;
  2339. options.audioDone(file, audio)
  2340. $('.waiting').removeClass('showloading');
  2341. //}
  2342. });
  2343. sound.once('loaderror', function() {
  2344. loadError.apply(this, arguments)
  2345. console.log('loaderror sound')
  2346. });
  2347. // Fires when the sound finishes playing.
  2348. sound.on('end', function() {
  2349. console.log('Finished sound');
  2350. });
  2351. }
  2352. }
  2353. }
  2354. e.target.value = "";
  2355. //更改value会触发change
  2356. }
  2357. .bind(player)
  2358. //滑动条控件
  2359. var SlideBar = function(o) {
  2360. var scope = this;
  2361. this.name = o.name;
  2362. this.value = o.value;
  2363. //初始值
  2364. this.min = o.min != void 0 ? o.min : 0;
  2365. this.max = this.oriMax = o.max != void 0 ? o.max : 100;
  2366. this.noValue = o.noValue;
  2367. //是否数值输入
  2368. this.precision = o.precision;
  2369. //精度 保留几位小数
  2370. 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>'))
  2371. div.addClass('slider')
  2372. if (o.unitStr) {
  2373. div.find(".BarTxt").append($('<span>' + o.unitStr + '</span>'));
  2374. }
  2375. o.root.append(div);
  2376. this.line = $(".scrollBar", div);
  2377. this.knot = $(".scroll_Thumb", div);
  2378. o.noValue || (this.textArea = $(".scrollBarTxt", div));
  2379. this.track = $(".scroll_Track", div);
  2380. this.unitStr = o.unitStr;
  2381. //unitStr是单位字符串,比如角度的°。不能是数字
  2382. this.onchange = o.onchange;
  2383. this.percent = null;
  2384. this.dragStart = false;
  2385. this.offsetToBody = null;
  2386. this.getOffset();
  2387. this.checkError();
  2388. this.percent = this.getPercent();
  2389. o.noValue || this.displayValue();
  2390. this.moveKnot();
  2391. this.knotWidth = 0;
  2392. this.lineWidth = 0;
  2393. //this.waitValue;//等待要触发事件的值,防止崩溃
  2394. this.avoidCrash = o.avoidCrash;
  2395. this.realMax = !this.noValue ? o.realMax : null;
  2396. //如果传入realMax,代表可以通过输入数字修改最大值范围,最大值不可以超过realMax。
  2397. this.scrollUnit = (scope.max - scope.min) * 0.001;
  2398. if (this.precision != void 0) {
  2399. var prec = Math.pow(10, -this.precision);
  2400. this.scrollUnit < prec && (this.scrollUnit = prec);
  2401. } else {
  2402. //默认化为整数
  2403. this.scrollUnit < 1 && (this.scrollUnit = 1);
  2404. }
  2405. this.dragStartEvent = o.dragStartEvent;
  2406. this.line.on("mousedown touchstart", function(event) {
  2407. scope.dragStart = true;
  2408. scope.dragChange(event);
  2409. if (scope.dragStartEvent)
  2410. scope.dragStartEvent()
  2411. //if(o.avoidCrash && isMobile)scope.dealInterval();
  2412. });
  2413. !window.isMobile && this.line.on("mousewheel DOMMouseScroll wheel", function(event) {
  2414. event.preventDefault();
  2415. var v = event.originalEvent.deltaY > 0 ? -scope.scrollUnit : scope.scrollUnit;
  2416. scope.setValue(scope.value + v);
  2417. });
  2418. this.dragEndEvent = o.dragEndEvent;
  2419. var stop = function() {
  2420. if (scope.dragStart) {
  2421. scope.dragStart = false;
  2422. if (scope.dragEndEvent)
  2423. scope.dragEndEvent()
  2424. }
  2425. }
  2426. $(document).on("mouseup touchend", stop)
  2427. /* isMobile || */
  2428. $("#player").on("mouseup", stop)
  2429. var lastChangeTime = 0;
  2430. $(document).on("mousemove touchmove", function() {
  2431. if (scope.dragStart) {
  2432. /* if(isMobile && o.avoidCrash){
  2433. scope.lastDragEvent = event;
  2434. }else */
  2435. scope.dragChange(event);
  2436. }
  2437. })
  2438. o.noValue || this.textArea.on("change", function() {
  2439. var v = parseFloat(scope.textArea.val());
  2440. if (v != v)
  2441. //NaN
  2442. return;
  2443. scope.setValueFromOutside(v);
  2444. });
  2445. window.addEventListener("resize",()=>{
  2446. if(this.line[0].clientWidth){
  2447. this.getOffset()
  2448. this.moveKnot();
  2449. }
  2450. })
  2451. }
  2452. SlideBar.prototype.dealInterval = function() {
  2453. this.interval = setInterval(function() {
  2454. this.lastDragEvent && this.dragChange(this.lastDragEvent);
  2455. this.lastDragEvent = null
  2456. if (!this.dragStart)
  2457. clearInterval(this.interval)
  2458. }
  2459. .bind(this), 90)
  2460. }
  2461. SlideBar.prototype.changeLimit = function(o) {
  2462. if (o.min)
  2463. this.min = o.min;
  2464. if (o.max)
  2465. this.max = o.max;
  2466. }
  2467. SlideBar.prototype.getOffset = function() {
  2468. //为了检测鼠标位置需要获得相对body的offset
  2469. var left = this.line[0].offsetLeft;
  2470. var element = this.line[0];
  2471. while (element = element.offsetParent) {
  2472. left += element.offsetLeft;
  2473. }
  2474. this.offsetToBody = (left == 0) ? (this.offsetToBody || 0) : left;
  2475. //如果left为0,很可能是它不可见,那么最好使用旧的offsetToBody
  2476. }
  2477. SlideBar.prototype.InitOffset = function() {
  2478. //如果一开始scroller没有显示,要在显示时获取一下offset
  2479. this.getOffset();
  2480. this.getWidth();
  2481. this.moveKnot();
  2482. }
  2483. SlideBar.prototype.checkError = function() {
  2484. if (this.min >= this.max) {
  2485. console.log("scrollbar值有误 " + name);
  2486. return;
  2487. }
  2488. }
  2489. SlideBar.prototype.getPercent = function() {
  2490. return (this.value - this.min) / (this.max - this.min);
  2491. }
  2492. SlideBar.prototype.displayValue = function(value) {
  2493. //this.textArea.val(this.value + (this.unitStr ? " " + this.unitStr : ""));
  2494. if (value != void 0)
  2495. this.value = value;
  2496. this.textArea.val(this.value)
  2497. }
  2498. SlideBar.prototype.getWidth = function() {
  2499. this.knotWidth = this.knot.width();
  2500. this.lineWidth = this.line.width() - this.knotWidth
  2501. }
  2502. SlideBar.prototype.moveKnot = function() {
  2503. //this.getWidth();
  2504. var width = this.percent * this.lineWidth;
  2505. this.knot.css('left', width + "px")
  2506. if (this.track)
  2507. this.track.css('width', (width + this.knotWidth / 2) + "px")
  2508. }
  2509. SlideBar.prototype.bind = function(f) {
  2510. this.onchange = f;
  2511. }
  2512. SlideBar.prototype.setValue = function(v, noEvent, changeMax) {
  2513. //设置数值并改变knot位置 noEvent为true的话就可以不触发回调函数,仅仅改变显示
  2514. //if(this.value==v)return; //因为换选材质需要执行后面onchange才会带动preview的改变,所以这里一样还是执行,而拉动滑动条的部分值不变就不执行
  2515. if (this.precision != void 0) {
  2516. this.value = parseFloat(v.toFixed(this.precision))
  2517. } else {
  2518. //默认化为整数
  2519. this.value = Math.round(v);
  2520. }
  2521. if (changeMax && this.realMax != void 0) {
  2522. if (this.value > this.oriMax) {
  2523. this.value = Math.min(this.value, this.realMax);
  2524. this.changeLimit({
  2525. max: this.value
  2526. })
  2527. } else {
  2528. this.changeLimit({
  2529. max: this.oriMax
  2530. })
  2531. }
  2532. }
  2533. this.percent = this.getPercent();
  2534. var makeit = true;
  2535. if (this.onchange && !noEvent) {
  2536. var result = this.onchange(this.value);
  2537. //如果执行的函数不允许这个值,就不能变
  2538. if (result === false) {
  2539. makeit = false;
  2540. }
  2541. }
  2542. if (makeit) {
  2543. this.moveKnot();
  2544. //console.log("SlideBarV-"+this.name + " : "+this.value)
  2545. this.noValue || this.displayValue();
  2546. }
  2547. }
  2548. SlideBar.prototype.dragChange = function(event) {
  2549. //拖动时触发 计算数值
  2550. //this.getWidth();
  2551. //if(!this.offsetToBody || isNaN(this.offsetToBody)this.getOffset();
  2552. if (event.clientX != void 0) {
  2553. this.percent = (event.clientX - this.knotWidth / 2 - this.offsetToBody) / this.lineWidth;
  2554. } else {
  2555. if (event.touches != void 0) {
  2556. this.percent = (event.touches[0].clientX - this.knotWidth / 2 - this.offsetToBody) / this.lineWidth;
  2557. } else
  2558. this.percent = (event.originalEvent.touches[0].clientX - this.knotWidth / 2 - this.offsetToBody) / this.lineWidth;
  2559. }
  2560. if (this.percent < 0)
  2561. this.percent = 0;
  2562. else if (this.percent > 1)
  2563. this.percent = 1;
  2564. //var v = this.percent * this.max;
  2565. var v = this.percent * (this.max - this.min) + this.min;
  2566. //var v = Math.round(this.percent * this.max * 10)/10; //精度为0.1
  2567. if (this.value == v)
  2568. return;
  2569. this.setValue(v);
  2570. }
  2571. SlideBar.prototype.setValueFromOutside = function(v) {
  2572. //外面的事件触发的
  2573. if (this.line.width() == 0)
  2574. return;
  2575. //不可见就不执行。
  2576. //v = Math.round(v*10)/10;
  2577. if (this.realMax != void 0) {
  2578. v = THREE.Math.clamp(v, this.min, this.realMax);
  2579. if (v > this.max)
  2580. this.changeLimit({
  2581. max: v
  2582. });
  2583. } else
  2584. v = THREE.Math.clamp(v, this.min, this.max);
  2585. this.setValue(v);
  2586. }
  2587. //-----------------------------------------------------
  2588. var LineDraw = {
  2589. createLine: function(posArr, o) {
  2590. var e = new THREE.BufferGeometry
  2591. , p = new Float32Array(6);
  2592. e.addAttribute("position", new THREE.BufferAttribute(p,3));
  2593. //这句新旧版写法不同 旧版这样:e.addAttribute("position",Float32Array,2,3);
  2594. var p = e.attributes.position.array;
  2595. for (var i = 0; i < 2; i++) {
  2596. p[i * 3] = posArr[i].x;
  2597. p[i * 3 + 1] = posArr[i].y;
  2598. p[i * 3 + 2] = posArr[i].z;
  2599. }
  2600. var mat = new THREE[o.deshed ? "LineDashedMaterial" : "LineBasicMaterial"]({
  2601. linewidth: o.width || 1,
  2602. //windows无效。 似乎mac/ios上粗细有效 ?
  2603. color: o.color || defaultColor,
  2604. transparent: o.dontAlwaysSeen ? false : true,
  2605. depthTest: o.dontAlwaysSeen ? true : false
  2606. })
  2607. var line = new THREE.Line(e,mat);
  2608. line.renderOrder = o.renderOrder || 4
  2609. //同tagStem; //如果不加高,可能会部分被model遮住
  2610. return line;
  2611. }
  2612. }
  2613. var toPrecision = function(e, t) {
  2614. function i(e, t) {
  2615. var i = Math.pow(10, t);
  2616. return Math.round(e * i) / i
  2617. }
  2618. if (e instanceof Array) {
  2619. for (var n = 0; n < e.length; n++)
  2620. e[n] = i(e[n], t);
  2621. return e
  2622. }
  2623. return i(e, t)
  2624. }
  2625. var transformControls;
  2626. var initTransformCtl = function(THREE) {
  2627. TransformControls.init(THREE)
  2628. TransformControls.prototype.transCtlChangeMode = function(mode) {
  2629. //if(!this.editing)return;
  2630. if (mode && this.mode != mode) {
  2631. this.mode = mode;
  2632. }
  2633. }
  2634. ,
  2635. transformControls = new TransformControls(player.camera,player.domElement,{
  2636. player: player,
  2637. dontHideWhenFaceCamera: true,
  2638. scaleAxis: ["x", "y"],
  2639. //隐藏了z轴。虽然参数没用上
  2640. NoScaleZ: true //整体缩放时只缩放xy轴。
  2641. });
  2642. transformControls.space = 'local'//为了在当前方向上平移
  2643. transformControls.setSize(1.5)
  2644. player.model.add(transformControls)
  2645. $(".MenuOptions[name='transform'] li").on("click", (e)=>{
  2646. transformControls.transCtlChangeMode($(e.target).attr("index"))
  2647. })
  2648. }
  2649. var EditOverlay = {
  2650. editing: false,
  2651. overlayMaxCount: 10,
  2652. scroller: {
  2653. videoDepth: new SlideBar({
  2654. root: $('#videoDepth').eq(0),
  2655. value: settings.overlay.depth * 100,
  2656. min: 0 * 100,
  2657. max: 1 * 100,
  2658. name: "videoDepth",
  2659. unitStr: "cm",
  2660. avoidCrash: true,
  2661. onchange: function(s) {
  2662. if (s == 0) {
  2663. EditOverlay.editPlane.addBox(false)
  2664. } else {
  2665. EditOverlay.editPlane.addBox(true)
  2666. EditOverlay.editPlane.scale.z = s / 100 / settings.overlay.depth;
  2667. }
  2668. },
  2669. dragEndEvent: function() {
  2670. }
  2671. })
  2672. },
  2673. panoPosSwitch : $('#setOverlayPosForPano input') // 当前漫游点独立调整位置开关
  2674. ,
  2675. init: function(THREE) {
  2676. var mat = new THREE.MeshBasicMaterial({
  2677. wireframe: true,
  2678. opacity: 0.5,
  2679. color: "#57e4f3",
  2680. transparent: true
  2681. })
  2682. var wireframeModel = this.wireframeModel = new THREE.Object3D;
  2683. wireframeModel.name = 'wireframeModel'
  2684. player.model.chunks.forEach((mesh)=>{
  2685. var chunk = mesh.clone();
  2686. chunk.material = mat;
  2687. wireframeModel.add(chunk)
  2688. }
  2689. )
  2690. wireframeModel.visible = false
  2691. player.model.add(wireframeModel)
  2692. //------------------------------
  2693. this.panoPosSwitch.on("change", this.panoPosSwitchOnChange.bind(this))
  2694. $('.overlay .addBtn button').on("click", this.beginToAddPlane.bind(this))
  2695. $("#overlayProp a.close").on("click", ()=>{
  2696. this.closeOverlayPanel("cancel")
  2697. }
  2698. )
  2699. $("#overlayProp button.submit").on("click", (e)=>{
  2700. this.SaveOverlay()
  2701. }
  2702. )
  2703. $("#overlayProp button.delete").on("click", (e)=>{
  2704. this.DeleteOverlay();
  2705. }
  2706. )
  2707. $('#overlayUpload [name="useImgRatio"] button').on("click", this.useImgRatio.bind(this));
  2708. var uploadInputs = {
  2709. video : $('<input type="file" style="display:none" accept="video/*"></input>'),
  2710. photo : $('<input type="file" style="display:none" accept="image/*"></input>')
  2711. }
  2712. $('#overlayUpload [name="upload"] button').on('click', ()=>{
  2713. uploadInputs[this.editType].click()
  2714. })
  2715. uploadInputs.video.on("change", (e)=>{
  2716. inputMedia({
  2717. enableTypes: [this.editType ],
  2718. videoDone: (file,video)=>{
  2719. var plane = this.editPlane.plane
  2720. $(video).css('width', '100%')
  2721. $(video).css('height', '100%')
  2722. plane.material.map = new THREE.VideoTexture(video);
  2723. plane.material.map.image.play();
  2724. plane.material.map.minFilter = THREE.LinearFilter;
  2725. this.editPlane.overlayType = "video";
  2726. $('#overlayUpload .preview video').remove();
  2727. //$('#overlayUpload .preview').css('background-image',"").append($(video));
  2728. video.autoplay = true;
  2729. video.loop = true;
  2730. video.volume = 0
  2731. video.muted = true
  2732. this.useImgRatio()
  2733. //自适应比例
  2734. this.editPlane.file = file;
  2735. plane.material.opacity = 1;
  2736. plane.material.color = new THREE.Color(1,1,1)
  2737. plane.material.needsUpdate = true;
  2738. }
  2739. }, "video", e);
  2740. }
  2741. )
  2742. uploadInputs.photo.on("change", (e)=>{
  2743. inputMedia({
  2744. enableTypes: [this.editType ],
  2745. photoDone: (photo)=>{
  2746. var plane = this.editPlane.plane
  2747. /* $(video).css('width', '100%')
  2748. $(video).css('height', '100%') */
  2749. plane.material.map = new THREE.Texture();
  2750. plane.material.map.image = photo
  2751. plane.material.map.needsUpdate = !0
  2752. plane.material.map.minFilter = THREE.LinearFilter;
  2753. this.editPlane.overlayType = "photo";
  2754. $('#overlayUpload .preview video').remove();
  2755. //$('#overlayUpload .preview').css('background-image',"").append($(video));
  2756. this.useImgRatio()
  2757. //自适应比例
  2758. this.editPlane.file = photo.file;
  2759. plane.material.opacity = 1;
  2760. plane.material.color = new THREE.Color(1,1,1)
  2761. plane.material.needsUpdate = true;
  2762. }
  2763. }, "photo", e);
  2764. }
  2765. )
  2766. player.overlayGroup.children.forEach((overlay)=>{
  2767. if(!overlay.plane.material.map || !overlay.plane.material.map.image){
  2768. overlay._loadDones = [()=>{this.getOverlayInfo(overlay)}]
  2769. }
  2770. else {
  2771. this.getOverlayInfo(overlay)
  2772. }
  2773. this.addToList(overlay)
  2774. }
  2775. )
  2776. },
  2777. enter: function() {
  2778. this.editing = true;
  2779. this.wireframeModel.visible = true;
  2780. },
  2781. leave: function() {
  2782. if (!this.editing)
  2783. return;
  2784. this.editing = false
  2785. $("#overlayProp a.close").click();
  2786. this.endAddPlane();
  2787. this.wireframeModel.visible = false;
  2788. },
  2789. switchEditType : function(type){
  2790. this.editType = type;
  2791. $('#overlayUpload [name="upload"] button').text(type == 'video' ? "上传视频" : "上传图片")
  2792. $('#overlayUpload .preview span').text(type == 'video' ? "支持MP4、MOV等,<20M" : "支持jpg、png等,<20M");
  2793. },
  2794. beginToAddPlane: function(event) {
  2795. this.switchEditType($(event.target).attr("data-type"))
  2796. player.reticule.visible = false;
  2797. this.objCursorType = 'overlay';
  2798. player.currentCursor = 'url(images/edit/box_video.png), auto'
  2799. $('#player').css('cursor', player.currentCursor)
  2800. $('.overlay .addBtn button').addClass("unable")
  2801. //可以加多个视频时的按钮
  2802. },
  2803. endAddPlane: function() {
  2804. this.objCursorType = null;
  2805. player.currentCursor = '';
  2806. $('#player').css('cursor', '')
  2807. $('.overlay .addBtn button').removeClass("unable")
  2808. player.reticule.visible = true
  2809. },
  2810. addPlane: function(o) {
  2811. if(!o.intersect)return;
  2812. var pos = o.intersect.point;
  2813. var overlay = new Overlay({
  2814. sid: new Date().getTime() + ""
  2815. })
  2816. overlay.hasRequestLoad = true
  2817. overlay.position.copy(pos);
  2818. if (player.getMouseDirection().angleTo(o.intersect.face.normal) < Math.PI / 2) {
  2819. overlay.lookAt(o.intersect.face.normal.clone().negate().add(pos));
  2820. overlay.position.add(o.intersect.face.normal.clone().negate().multiplyScalar(0.01))
  2821. //avoid mesh crash with chunks 模型的精度可能和floorplan的不一样,所以chunk即使材质经过处理还是会闪烁但是wallmesh不会
  2822. } else {
  2823. overlay.lookAt(o.intersect.face.normal.clone().add(pos));
  2824. overlay.position.add(o.intersect.face.normal.clone().multiplyScalar(0.01))
  2825. }
  2826. overlay.posCustom = overlay.position.clone();
  2827. overlay.quaCustom = overlay.quaternion.clone();
  2828. overlay.widthCustom = overlay.width;
  2829. overlay.heightCustom = overlay.height;
  2830. overlay.isNew = true
  2831. player.clickOverlay(overlay)
  2832. transformControls.transCtlChangeMode("translate")
  2833. this.addToList(overlay)
  2834. },
  2835. updateOverlayScaleDisplay: function() {
  2836. var overlay = this.editPlane;
  2837. var maxWidth = 193
  2838. , maxHeight = maxWidth
  2839. //maxWidth/2;
  2840. var ratioW = Math.abs(overlay.width) / maxWidth;
  2841. var ratioH = Math.abs(overlay.height) / maxHeight;
  2842. var ratio = 1 / Math.max(ratioW, ratioH);
  2843. //缩放比例
  2844. var w = Math.round(Math.abs(overlay.width) * ratio)
  2845. var h = Math.round(Math.abs(overlay.height) * ratio)
  2846. $('#overlayUpload .preview').css({
  2847. "width": w + 'px',
  2848. "height": h + 'px',
  2849. });
  2850. $('#overlayUpload .preview [attr-type="width"]').text(toPrecision(overlay.width, 2))
  2851. $('#overlayUpload .preview [attr-type="height"]').text(toPrecision(overlay.height, 2))
  2852. },
  2853. updateOverlayPanel: function(overlay) {
  2854. this.editPlane = overlay;
  2855. overlay.requestDownload()
  2856. if(overlay._loadDones){
  2857. $('.waiting').addClass('showloading');
  2858. overlay._loadDones.push(()=>{
  2859. $('.waiting').removeClass('showloading');
  2860. })
  2861. }
  2862. var plane = overlay.plane
  2863. var src = plane.material.map && (plane.material.map.image ? plane.material.map.image.src : overlay.fileSrc );
  2864. $('#overlayUpload .preview video').remove();
  2865. overlay.overlayType && this.switchEditType(overlay.overlayType)
  2866. if (overlay.overlayType == "video") {
  2867. var video = plane.material.map.image
  2868. $('#overlayUpload .preview').css({'background-image':"", 'background-size':""}).append(video);
  2869. } else if(overlay.overlayType == "photo" || overlay.overlayType == "text"){
  2870. $('#overlayUpload .preview').css({
  2871. 'background-image': src ? ("url(" + src + ")") : "",
  2872. 'background-size': "contain"
  2873. })
  2874. }else{
  2875. $('#overlayUpload .preview').css({
  2876. 'background-image': "",
  2877. 'background-size': ""
  2878. })
  2879. }
  2880. if (overlay.overlayType) {
  2881. $('#overlayUpload [name="useImgRatio"]').removeClass("hide")
  2882. $('#overlayUpload .preview').addClass('uploaded')
  2883. } else {
  2884. $('#overlayUpload [name="useImgRatio"]').addClass("hide")
  2885. $('#overlayUpload .preview').removeClass('uploaded')
  2886. }
  2887. this.updateOverlayScaleDisplay()
  2888. if (overlay.hasBox) {
  2889. this.scroller.videoDepth.setValue(overlay.scale.z * settings.overlay.depth * 100, true)
  2890. } else {
  2891. this.scroller.videoDepth.setValue(0, true)
  2892. }
  2893. setTimeout(()=>{
  2894. this.scroller.videoDepth.InitOffset()
  2895. }
  2896. , 201)
  2897. this.updatePano()
  2898. },
  2899. //----------------------------
  2900. panoPosSwitchOnChange : function(){
  2901. var on = this.panoPosSwitch.is(':checked')
  2902. if(!on){
  2903. delete this.editPlane.transformAtPanos[getTransformSid()]
  2904. this.editPlane.position.copy(this.editPlane.posCustom)
  2905. this.editPlane.quaternion.copy(this.editPlane.quaCustom)
  2906. var scale = this.editPlane.getScaleBySize(this.editPlane.widthCustom, this.editPlane.heightCustom)
  2907. this.editPlane.scale.set(scale.x, scale.y, this.editPlane.scale.z)
  2908. //this.editPlane.usingTransformData = false
  2909. }
  2910. }
  2911. ,
  2912. getTransformAtPano : function(){
  2913. var name = getTransformSid()
  2914. this.editPlane.transformAtPanos[name] = {
  2915. pos : this.editPlane.position.clone(),
  2916. qua : this.editPlane.quaternion.clone(),
  2917. width : this.editPlane.width,
  2918. height : this.editPlane.height,
  2919. }
  2920. //this.editPlane.usingTransformData = true
  2921. },
  2922. updatePosition:function(){
  2923. var on = this.panoPosSwitch.is(':checked')
  2924. if(on){
  2925. this.getTransformAtPano()
  2926. }else{
  2927. this.editPlane.posCustom.copy(this.editPlane.position)
  2928. }
  2929. },
  2930. updateScale : function(){
  2931. var on = this.panoPosSwitch.is(':checked')
  2932. var size = this.editPlane.getSizeByScale( )
  2933. this.editPlane.width = size.width
  2934. this.editPlane.height = size.height
  2935. if(on){
  2936. this.getTransformAtPano()
  2937. }else{
  2938. this.editPlane.widthCustom = this.editPlane.width
  2939. this.editPlane.heightCustom = this.editPlane.height
  2940. }
  2941. this.updateOverlayScaleDisplay()
  2942. }
  2943. ,
  2944. updateQua : function(){
  2945. var on = this.panoPosSwitch.is(':checked')
  2946. if(on){
  2947. this.getTransformAtPano()
  2948. }else{
  2949. this.editPlane.quaCustom.copy(this.editPlane.quaternion)
  2950. }
  2951. }
  2952. ,
  2953. updatePano:function(){
  2954. if(!EditOverlay.editPlane ) return;
  2955. this.panoPosSwitch.prop('checked', !!EditOverlay.editPlane.transformAtPanos[ getTransformSid()]);
  2956. },
  2957. //------------------------------
  2958. closeOverlayPanel: function(type) {
  2959. if (!this.editPlane)
  2960. return;
  2961. if (type == 'cancel') {
  2962. if (!this.editPlane.isNew && !this.editPlane.needDelete)
  2963. this.editPlane.setFromInfo(this.editPlane.info)
  2964. //this.setOverlayFromInfo(this.editPlane, this.editPlane.info);//恢复
  2965. else
  2966. this.disposeOverlay(this.editPlane);
  2967. //删除
  2968. }
  2969. this.editPlane = null;
  2970. transformControls.detach()
  2971. $("#overlayProp").addClass("atRight");
  2972. //if(player.model.overlayPlanes.length < this.overlayMaxCount) this.beginToAddPlane()
  2973. },
  2974. useImgRatio: function(o) {
  2975. var plane = this.editPlane.plane;
  2976. if (!plane.material.map)
  2977. return;
  2978. var img = plane.material.map.image;
  2979. var mintranRatio = 200;
  2980. //default is 200 , 防止图片太小时在墙上依旧很大
  2981. var width = this.editPlane.overlayType == "video" ? img.videoWidth : img.width;
  2982. var height = this.editPlane.overlayType == "video" ? img.videoHeight : img.height;
  2983. if (o == "suitSize") {
  2984. var boundWidth = Math.min(Math.max(width, height) / mintranRatio, 1)
  2985. if (width > height) {
  2986. var w = boundWidth;
  2987. var h = boundWidth * height / width
  2988. } else {
  2989. var h = boundWidth;
  2990. var w = boundWidth * width / height;
  2991. }
  2992. } else {
  2993. //假设不变总面积
  2994. var k = Math.sqrt(Math.abs(this.editPlane.width * this.editPlane.height) / (width * height))
  2995. var w = k * width * (this.editPlane.width < 0 ? -1 : 1);
  2996. var h = k * height * (this.editPlane.height < 0 ? -1 : 1);
  2997. }
  2998. this.editPlane.scale.setX(w / settings.overlay.width)
  2999. this.editPlane.scale.setY(h / settings.overlay.height)
  3000. this.editPlane.width = w;
  3001. this.editPlane.height = h;
  3002. this.updateScale()
  3003. this.updateOverlayPanel(this.editPlane)
  3004. },
  3005. getOverlayInfo: function(overlay) {
  3006. //2 编辑前, 从当前状态获取info
  3007. var plane = overlay.plane;
  3008. var transformAtPanos = {}
  3009. for(var i in overlay.transformAtPanos){
  3010. transformAtPanos[i] = {
  3011. width : overlay.transformAtPanos[i].width,
  3012. height : overlay.transformAtPanos[i].height,
  3013. pos : overlay.transformAtPanos[i].pos.clone(),
  3014. qua : overlay.transformAtPanos[i].qua.clone(),
  3015. }
  3016. }
  3017. overlay.info = {
  3018. width: overlay.widthCustom,
  3019. height: overlay.heightCustom,
  3020. depth: settings.overlay.depth * overlay.scale.z,
  3021. pos: overlay.posCustom.clone(),
  3022. qua: overlay.quaCustom.clone(),
  3023. media: plane.material.map.image,
  3024. file: overlay.file,
  3025. type: overlay.overlayType,
  3026. hasBox: overlay.hasBox,
  3027. transformAtPanos: transformAtPanos
  3028. }
  3029. },
  3030. getSavingInfo: function(overlay) {
  3031. if (!overlay.file && (!overlay.plane.material.map || !overlay.plane.material.map.image)) {
  3032. return;
  3033. }
  3034. var transformAtPanos = {}
  3035. for(var i in overlay.transformAtPanos){
  3036. transformAtPanos[i] = {
  3037. width : toPrecision(overlay.transformAtPanos[i].width, 4),
  3038. height : toPrecision(overlay.transformAtPanos[i].height, 4),
  3039. pos : toPrecision(overlay.transformAtPanos[i].pos.toArray(), 3),
  3040. qua : toPrecision(overlay.transformAtPanos[i].qua.toArray(), 5)
  3041. }
  3042. }
  3043. var info = {
  3044. width: toPrecision(overlay.widthCustom, 4),
  3045. height: toPrecision(overlay.heightCustom, 4),
  3046. depth: toPrecision(settings.overlay.depth * overlay.scale.z, 4),
  3047. pos: toPrecision(overlay.posCustom.toArray(), 3),
  3048. qua: toPrecision(overlay.quaCustom.toArray(), 5),
  3049. sid: overlay.sid,
  3050. hasBox: overlay.hasBox ? 1 : 0,
  3051. media: [overlay.overlayType],
  3052. file: overlay.fileSrc || overlay.plane.material.map.image.src,
  3053. transformAtPanos : transformAtPanos
  3054. }
  3055. return info
  3056. },
  3057. SaveOverlay: function() {
  3058. var overlay = this.editPlane;
  3059. if (!overlay.file && (!overlay.plane.material.map || !overlay.plane.material.map.image)) {
  3060. this.editType == "video" ? alert("请上传视频") : alert("请上传图片");
  3061. return;
  3062. }
  3063. var saveInfo = ()=>{
  3064. //overlay.savingInfo = JSON.stringify(info)//准备写入的info
  3065. //saveDone:
  3066. overlay.isNew = false;
  3067. overlay.getVisiblePanos()
  3068. this.getOverlayInfo(overlay);
  3069. this.closeOverlayPanel()
  3070. $('.waiting').removeClass('showloading');
  3071. }
  3072. if (!overlay.info || overlay.file != overlay.info.file) {
  3073. $('.waiting').addClass('showloading');
  3074. uploadFile(overlay.file, 'overlay', function(rs) {
  3075. if (rs.code === 0) {
  3076. overlay.fileSrc = rs.data;
  3077. saveInfo()
  3078. }
  3079. ;
  3080. })
  3081. } else
  3082. saveInfo();
  3083. },
  3084. disposeOverlay: function(overlay) {
  3085. var plane = overlay.plane
  3086. if (overlay == player.hoveringPlane) {
  3087. player.hoverOverlay(null, "soon");
  3088. }
  3089. if (plane.material.map) {//删除视频src
  3090. //overlay.info && common.destroyBlob(overlay.info.media.src)
  3091. //common.destroyBlob(plane.material.map.image.src)
  3092. }
  3093. plane.material.dispose();
  3094. overlay.parent.remove(overlay);
  3095. this.removeFromList(overlay)
  3096. //this.beginToAddPlane()
  3097. },
  3098. DeleteOverlay: function() {
  3099. var overlay = this.editPlane;
  3100. if (!overlay.isNew) {
  3101. if (confirm(overlay.overlayType== "photo" ? "确定删除该图片?" : "确定删除该视频?")) {
  3102. overlay.needDelete = true;
  3103. $("#overlayProp a.close").click()
  3104. //this.closeOverlayPanel()
  3105. }
  3106. } else {
  3107. //刚创建时的删除按钮等同于取消按钮
  3108. $("#overlayProp a.close").click()
  3109. //this.closeOverlayPanel()
  3110. }
  3111. },
  3112. addToList: function(overlay) {
  3113. var li = $(`<li class='listItem'><div class="icon"></div><div class="title">${(overlay.overlayType == "video" ? "视频 ":"图片 ")+ overlay.sid}</div></li>`)
  3114. $(".overlayList ul").append(li);
  3115. li.on("click", ()=>{
  3116. player.clickOverlay(overlay)
  3117. player.focusPoint({aim: overlay.position})
  3118. })
  3119. overlay.domLi = li;
  3120. },
  3121. removeFromList: function(overlay) {
  3122. overlay.domLi.remove();
  3123. }
  3124. }
  3125. //----------------漫游可见性---------------------------------
  3126. var VisiSet = {
  3127. setPanoVisible: false,
  3128. setTagVisible: false,
  3129. panoVLines: {},
  3130. //线条
  3131. panoVTemp: {},
  3132. //修改后还没保存的临时数据
  3133. tagVsetting: null,
  3134. //正在设置的热点中心点
  3135. tagsVLines: {},
  3136. //线条
  3137. //tagVTemp //修改后还没保存的临时数据
  3138. $confirmSnap: $("#camera-start"),
  3139. changeBtn : $(".toolMid .midBottom #midBtns>button").eq(1),
  3140. colors: {
  3141. green: "#00c8ae"
  3142. },
  3143. init: function() {
  3144. this.meshGroup = new THREE.Object3D;
  3145. this.meshGroup.name = "setVisible-group"
  3146. player.model.add(this.meshGroup)
  3147. $("#hotVisible").on("click", ()=>{
  3148. VisiSet.enterSet(VisiSet.beginSetTagVisible.bind(VisiSet))
  3149. })
  3150. this.changeBtn.on("click",()=>{//隐藏与显示该点
  3151. if(this.changeBtn.attr("function") == "hide"){
  3152. for(let i in this.panoVLines){
  3153. this.panoVLines[i].visible && this.dealPanoVisible(i);
  3154. }
  3155. }else{
  3156. //显示该点时,显示周围一定距离内、到该点没有遮挡的pano
  3157. //?????
  3158. var list = player.model.panos.sortByScore([e=>e.isAligned()], [(pano)=>{return -pano.position.distanceTo(this.panoVsetting.position)}])
  3159. if(list.length == 1){
  3160. console.log('仅有一个漫游点')
  3161. return;
  3162. }
  3163. var ifBlock = function(panoA, panoB ){
  3164. var A = panoA.position.clone();
  3165. var B = panoB.position.clone();
  3166. return convertTool.ifIntersectChunks(A, B, {})
  3167. }
  3168. var okList
  3169. var s = Math.max(-list[1].score*2, 4); //i==1的一定显示
  3170. for(var i=1;i<list.length;i++){
  3171. if(-list[i].score < s){
  3172. if(ifBlock(this.panoVsetting, list[i].pano)){
  3173. list[i].block = true //有阻挡
  3174. }
  3175. list[i].good = true
  3176. }else{
  3177. okList || (okList = list.filter(e=>e.good && !e.block));//绝对可以使用的
  3178. if(okList.length <2 ){
  3179. if(!ifBlock(this.panoVsetting, list[i].pano)){
  3180. if(okList.length == 0){
  3181. okList.push(list[i])
  3182. }else{//1
  3183. var lastPos = okList[0].pano.position.clone().sub(this.panoVsetting.position).setY(0);
  3184. var thisPos = list[i].pano.position.clone().sub(this.panoVsetting.position).setY(0);
  3185. if(lastPos.angleTo(thisPos) > Math.PI / 2){
  3186. console.log('再加一个 角度'+THREE.Math.radToDeg(lastPos.angleTo(thisPos)))
  3187. break;
  3188. }
  3189. }
  3190. }
  3191. }else{
  3192. break;
  3193. }
  3194. }
  3195. }
  3196. if(okList.length==0){//如果length为0,至少加一个pano, 虽然是遮挡的
  3197. okList.push(list[0].pano)
  3198. }
  3199. okList.forEach(e=>this.dealPanoVisible(e.pano.id))
  3200. console.log(okList)
  3201. }
  3202. })
  3203. },
  3204. enterSet: function(fun) {
  3205. var enter = function() {
  3206. if (player.modeTran.split('-')[1] != "floorplan") {
  3207. setTimeout(fun, 300)
  3208. //提前一点出现
  3209. }
  3210. player.flyToMode("floorplan", fun);
  3211. }
  3212. permitTranMode(false)
  3213. if (!player.modeTran) {
  3214. player.afterCModeFuc = ()=>{
  3215. enter()
  3216. }
  3217. } else
  3218. enter()
  3219. },
  3220. beginSetPanoVisible: function() {
  3221. player.flying || $(".toolLeft").removeClass("unable")
  3222. if (this.setPanoVisible)
  3223. return;
  3224. this.setPanoVisible = true;
  3225. this.panoVTemp = {};
  3226. this.SetOnePanoVisible(player.currentPano)
  3227. //先设置currentPano
  3228. this.$confirmSnap.text('保存当前设置').removeClass("hide")
  3229. //objects.tagManager.hideAllTags();
  3230. this.setDisplay(true)
  3231. this.updateFootIconSize()
  3232. //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话
  3233. for(let i in player.model.hots){
  3234. player.model.hots[i].visi_ = player.model.hots[i].mesh.visible;
  3235. player.model.hots[i].mesh.visible = false
  3236. }
  3237. },
  3238. SetOnePanoVisible: function(pano) {
  3239. //点击某个pano后就对该pano点进行设置
  3240. if (this.panoVsetting == pano)
  3241. return;
  3242. //if (this.panoVsetting) saveLastPanoVi(this.panoVsetting);
  3243. this.panoVsetting = pano;
  3244. //记录正在修改的
  3245. this.delVisibleLines();
  3246. //删除线
  3247. this.showFootIcons(pano, true);
  3248. this.createPanoVisiLines(pano);
  3249. //创线
  3250. this.changeBtn.removeClass('hide')
  3251. },
  3252. saveLastPanoVi: function() {
  3253. //保存刚设置过的pano
  3254. var change = [];
  3255. for (var r in this.panoVLines) {
  3256. var line = this.panoVLines[r];
  3257. if (line.name.indexOf("new") > -1 && line.visible) {
  3258. //新设置为visible且没有取消
  3259. change.push({
  3260. type: "add",
  3261. id: r
  3262. })
  3263. } else if (line.name.indexOf("new") == -1 && !line.visible) {
  3264. //旧的且已经取消
  3265. change.push({
  3266. type: "sub",
  3267. id: r
  3268. })
  3269. }
  3270. }
  3271. if (change.length) {
  3272. //添加双向的neighbour:
  3273. var self = this.searchNeib(this.panoVsetting.id)
  3274. //var seeMarkers_self = self.seeMarkers;
  3275. var neighbourUUIDs_self = self.neighbourUUIDs
  3276. var neighbourPanos_self = self.neighbourPanos;
  3277. for (var i = 0; i < change.length; i++) {
  3278. var other = this.searchNeib(change[i].id)
  3279. //var seeMarkers = other.seeMarkers;
  3280. var neighbourUUIDs = other.neighbourUUIDs;
  3281. var neighbourPanos = other.neighbourPanos;
  3282. if (change[i].type == "add") {
  3283. //seeMarkers.push(this.panoVsetting.id);
  3284. neighbourUUIDs.push(this.panoVsetting.id);
  3285. neighbourPanos[this.panoVsetting.id] = true;
  3286. //seeMarkers_self.push(change[i].id);
  3287. neighbourUUIDs_self.push(change[i].id);
  3288. neighbourPanos_self[change[i].id] = true;
  3289. } else {
  3290. //var index = seeMarkers.indexOf(this.panoVsetting.id);
  3291. //index > -1 && seeMarkers.splice(index, 1);
  3292. var index = neighbourUUIDs.indexOf(this.panoVsetting.id);
  3293. index > -1 && neighbourUUIDs.splice(index, 1);
  3294. neighbourPanos[this.panoVsetting.id] = false;
  3295. //var index = seeMarkers_self.indexOf(change[i].id);
  3296. //index > -1 && seeMarkers_self.splice(index, 1);
  3297. var index = neighbourUUIDs_self.indexOf(change[i].id);
  3298. index > -1 && neighbourUUIDs_self.splice(index, 1);
  3299. neighbourPanos_self[change[i].id] = false;
  3300. }
  3301. this.panoVTemp[change[i].id] = {
  3302. //后面两个是作为保存到后台的数据存储,临时需要用到的是第一个
  3303. neighbourPanos: neighbourPanos,
  3304. //seeMarkers: seeMarkers,
  3305. neighbourUUIDs: neighbourUUIDs
  3306. }
  3307. }
  3308. this.panoVTemp[this.panoVsetting.id] = {
  3309. //加上自己
  3310. neighbourPanos: neighbourPanos_self,
  3311. //seeMarkers: seeMarkers_self,
  3312. neighbourUUIDs: neighbourUUIDs_self
  3313. }
  3314. }
  3315. },
  3316. pauseSetPanoVisible: function(type) {
  3317. //暂停 因为点击了保存设置 但没有退出设置
  3318. if (!this.setPanoVisible)
  3319. return;
  3320. if (type == "unsaved") {
  3321. //中途点击pano从而停止一个热点的设置
  3322. this.saveLastPanoVi();
  3323. } else {
  3324. this.panoVTemp = {};
  3325. //清空数据
  3326. }
  3327. this.delVisibleLines();
  3328. this.showFootIcons();
  3329. //清空选择
  3330. var lastPanoSetting = this.panoVsetting;
  3331. this.panoVsetting = null;
  3332. lastPanoSetting && this.changeFIconState2(lastPanoSetting.footIcon, this.checkHasNeighbor(lastPanoSetting))
  3333. //这句要放在this.panoVsetting = null后。 根据可见性更改透明度
  3334. this.changeBtn.addClass('hide')
  3335. },
  3336. //按理说改变了neighbourPano,tag的初始visible也要改。但是这样还要考虑已经改过的tag。。很麻烦
  3337. finishSetPanoVisible: function() {
  3338. //结束 退出这个设置
  3339. if (!this.setPanoVisible)
  3340. return;
  3341. //否则会加多个侦听
  3342. this.setPanoVisible = false;
  3343. this.hideFootIcons();
  3344. this.delVisibleLines();
  3345. //objects.tagManager.showAllTags();
  3346. this.recoverAllState2();
  3347. this.panoVsetting = null;
  3348. this.panoVTemp = {};
  3349. player.flyoutType = null
  3350. this.$confirmSnap.addClass("hide")
  3351. permitTranMode(true)
  3352. this.setDisplay(false)
  3353. for(let i in player.model.hots){
  3354. player.model.hots[i].mesh.visible = player.model.hots[i].visi_
  3355. }
  3356. },
  3357. changeVisiBtnState: function(state){
  3358. this.changeBtn.attr("function", state ? "hide" : "show")
  3359. this.changeBtn.html(state ? "隐藏该点位置":"显示该点位置")
  3360. },
  3361. recoverAllState2: function() {
  3362. //为了热点可视恢复成pano全部可见
  3363. if(!this.footIcons)return;
  3364. for (var i = 0; i < this.footIcons.length; i++) {
  3365. this.footIcons[i].material.uniforms.opacity.value = 1;
  3366. this.footIcons[i].material.uniforms.map.value = footTex1;
  3367. }
  3368. },
  3369. afterSavePanoVisibles: function() {
  3370. //实施:
  3371. var panos = player.model.panos;
  3372. for (var i in this.panoVTemp) {
  3373. var pano = panos.index[i];
  3374. //pano.seeMarkers = this.panoVTemp[i].seeMarkers;
  3375. pano.neighbourUUIDs = this.panoVTemp[i].neighbourUUIDs;
  3376. pano.neighbourPanos = this.panoVTemp[i].neighbourPanos;
  3377. }
  3378. if (!this.checkHasNeighbor(player.currentPano)) {
  3379. //currentPano变为孤立点 就要换一个防止飞入
  3380. var list = panos.sortByScore([pano=>{
  3381. return this.checkHasNeighbor(pano)
  3382. }
  3383. ], [function(pano) {
  3384. return -pano.position.distanceTo(player.currentPano.position)
  3385. }
  3386. ])
  3387. if (list && list.length) {
  3388. player.currentPano = list[0].pano;
  3389. //找最近的一非孤立点
  3390. //this.noPanoHasNeighbor = false; //更新状态
  3391. } else {//this.noPanoHasNeighbor = true; //更新状态
  3392. }
  3393. } else {//this.noPanoHasNeighbor = false; //更新状态
  3394. }
  3395. //dataDeal.done();
  3396. //暂时:
  3397. this.pauseSetPanoVisible()
  3398. this.updateFootIconSize()
  3399. //更新一下center大小 写在最后
  3400. },
  3401. //最佳推荐操作顺序: 先设置pano可见性 再创建热点 这样热点的visible正确些,否则之后再设置热点可见性会改更多
  3402. savePanoVisibles: function() {
  3403. //保存
  3404. if (this.panoVsetting)
  3405. this.saveLastPanoVi(this.panoVsetting);
  3406. //获取最后设置的那个热点的改动
  3407. var PanoData = [];
  3408. for (var i in this.panoVTemp) {
  3409. PanoData.push({
  3410. //希望算法部不会更改index排序,或者更改后能将visible信息一并更改
  3411. panoID: i,
  3412. //visibles: this.turnToPanoIndex(this.panoVTemp[i].seeMarkers),
  3413. visibles3: this.turnToPanoIndex(this.panoVTemp[i].neighbourUUIDs)
  3414. })
  3415. }
  3416. if (PanoData.length == 0) {
  3417. //没改变
  3418. alert("保存成功")
  3419. return;
  3420. }
  3421. /* this.afterSavePanoVisibles()
  3422. alert("保存成功")
  3423. console.log(JSON.stringify(PanoData)) */
  3424. let url = cmp ? ('/api/scene/roamViable/' + cmp) : '/manage/scene/roamViable'
  3425. $.ajax({
  3426. method: 'POST',
  3427. url: ceshi + url,
  3428. headers: {
  3429. 'Content-Type': 'application/json',
  3430. token: token
  3431. },
  3432. contentType: 'application/json',
  3433. data: JSON.stringify({
  3434. data: JSON.stringify(PanoData),
  3435. sceneCode: window.number
  3436. }),
  3437. success: (data)=>{
  3438. if (data.code === 0) {
  3439. this.afterSavePanoVisibles()
  3440. alert("保存漫游可行成功")
  3441. } else
  3442. alert("保存漫游可行失败")
  3443. if (data.code === 5001) {
  3444. alert('请重新登录')
  3445. localStorage.dcj_token = ''
  3446. location.reload()
  3447. }
  3448. }
  3449. ,
  3450. fail: function() {
  3451. alert("保存漫游可行失败")
  3452. }
  3453. })
  3454. /* var o = {
  3455. name_t: "panoVisible",
  3456. f: this.pauseSetPanoVisible,
  3457. url: Config.prefixEditProPCApi+"/saveLinkPano",
  3458. dialog: i18n.get('设置'),
  3459. data: { data: JSON.stringify(PanoData) }
  3460. }
  3461. var dataDeal = uploadsSaving.saveFucforPC(o);
  3462. dataDeal.group[0] = function () {
  3463. //实施:
  3464. for (var i in player.panoVTemp) {
  3465. var pano = player.model.panos.index[i];
  3466. pano.seeMarkers = player.panoVTemp[i].seeMarkers;
  3467. pano.neighbourUUIDs = player.panoVTemp[i].neighbourUUIDs;
  3468. pano.neighbourPanos = player.panoVTemp[i].neighbourPanos;
  3469. }
  3470. if(!player.model.checkHasNeighbor(player.currentPano)){//currentPano变为孤立点 就要换一个防止飞入
  3471. var list = player.model.panos.sortByScore([function(pano){return player.model.checkHasNeighbor(pano)}],
  3472. [function(pano){return -pano.position.distanceTo(player.currentPano.position)}])
  3473. if(list && list.length){
  3474. player.currentPano = list[0].pano;//找最近的一非孤立点
  3475. player.model.noPanoHasNeighbor = false; //更新状态
  3476. }else{
  3477. player.model.noPanoHasNeighbor = true; //更新状态
  3478. }
  3479. }else{
  3480. player.model.noPanoHasNeighbor = false; //更新状态
  3481. }
  3482. dataDeal.done();
  3483. player.model.updateFootIconSize(player.cameraControls.activeControl)//更新一下center大小 写在最后
  3484. } */
  3485. },
  3486. searchNeib: function(panoId) {
  3487. //寻找某pano的相关neighbour 可能是修改过的
  3488. var panos = player.model.panos;
  3489. var o = {};
  3490. if (this.panoVTemp[panoId]) {
  3491. //o.seeMarkers = this.panoVTemp[panoId].seeMarkers;
  3492. o.neighbourUUIDs = this.panoVTemp[panoId].neighbourUUIDs;
  3493. o.neighbourPanos = this.panoVTemp[panoId].neighbourPanos;
  3494. } else {
  3495. //o.seeMarkers = panos.index[panoId].seeMarkers.slice(0);
  3496. o.neighbourUUIDs = panos.index[panoId].neighbourUUIDs.slice(0);
  3497. o.neighbourPanos = CloneObject(panos.index[panoId].neighbourPanos);
  3498. }
  3499. return o;
  3500. },
  3501. turnToPanoIndex: function(panoArr) {
  3502. var panos = player.model.panos;
  3503. var array = [];
  3504. for (var i = 0; i < panoArr.length; i++) {
  3505. var pano = panos.index[panoArr[i]];
  3506. var index = panos.list.indexOf(pano)
  3507. array.push(index);
  3508. }
  3509. return array;
  3510. },
  3511. setDisplay: function(state) {
  3512. var panos = player.model.panos;
  3513. if (state) {
  3514. this.$confirmSnap.text('保存当前设置');
  3515. this.$confirmSnap.removeClass('hide');
  3516. } else {
  3517. this.$confirmSnap.addClass('hide');
  3518. this.changeBtn.addClass('hide')
  3519. }
  3520. player.path.currentPanoMarker.mesh.visible = !state;
  3521. player.overlayGroup.visible = !state;
  3522. player.reticule.visible = !state;
  3523. },
  3524. delVisibleLines: function() {
  3525. //xzw add 所有线都删除
  3526. for (var i in this.tagsVLines) {
  3527. this.tagsVLines[i].geometry.dispose();
  3528. this.tagsVLines[i].material.dispose();
  3529. this.meshGroup.remove(this.tagsVLines[i]);
  3530. delete this.tagsVLines[i];
  3531. }
  3532. for (var i in this.panoVLines) {
  3533. this.panoVLines[i].geometry.dispose();
  3534. this.panoVLines[i].material.dispose();
  3535. this.meshGroup.remove(this.panoVLines[i]);
  3536. delete this.panoVLines[i];
  3537. }
  3538. },
  3539. //--------panoVisible
  3540. createPanoVisiLines: function(pano) {
  3541. // pano可见性线条
  3542. var neighbours = this.panoVTemp[pano.id] && this.panoVTemp[pano.id].neighbourPanos || pano.neighbourPanos;
  3543. for (var r in neighbours) {
  3544. if (neighbours[r] && r != pano.id) {
  3545. this.createPanoSingleLine(pano, "old", r)
  3546. }
  3547. }
  3548. },
  3549. createPanoSingleLine: function(pano, type, id) {
  3550. //pano是中心
  3551. var panos = player.model.panos;
  3552. var p2 = panos.index[id].floorPosition.clone()
  3553. /* .sub(player.model.position) */
  3554. var line = LineDraw.createLine([pano.floorPosition.clone()/* .sub(this.position) */
  3555. , p2], {
  3556. color: this.colors.green
  3557. });
  3558. this.meshGroup.add(line);
  3559. line.name = "PanoVL-" + type + "-" + id;
  3560. this.panoVLines[id] = line;
  3561. this.changeFIconState(panos.index[id].footIcon, "linked")
  3562. },
  3563. dealPanoVisible: function(id) {
  3564. //外部调用
  3565. var panos = player.model.panos;
  3566. if (this.panoVsetting) {
  3567. if (id == this.panoVsetting.id) {
  3568. //关闭当前pano设置
  3569. this.pauseSetPanoVisible('unsaved')
  3570. } else {
  3571. var link;
  3572. //结果是否连接
  3573. if (this.panoVLines[id]) {
  3574. this.panoVLines[id].visible = !this.panoVLines[id].visible;
  3575. link = this.panoVLines[id].visible;
  3576. this.changeFIconState(panos.index[id].footIcon, this.panoVLines[id].visible ? "linked" : false)
  3577. } else {
  3578. this.createPanoSingleLine(this.panoVsetting, "new", id)
  3579. link = true;
  3580. }
  3581. if (link) {
  3582. //如果连接上了,直接判断该点是可见的(有附近点),(不能通过checkHasNeighbor来判断,因为新增的线条可能不在它的neighbour中
  3583. this.changeFIconState2(panos.index[id].footIcon, true)
  3584. this.changeFIconState2(panos.index[this.panoVsetting.id].footIcon, true)
  3585. } else {
  3586. //否则需要checkHasNeighbor
  3587. this.changeFIconState2(panos.index[id].footIcon, this.checkHasNeighbor(panos.index[id]))
  3588. this.changeFIconState2(panos.index[this.panoVsetting.id].footIcon, this.checkHasNeighbor(this.panoVsetting))
  3589. }
  3590. /* if(window.routeArray){
  3591. if(this.panoVLines[id].visible)window.routeArray.push(id)
  3592. else{
  3593. let index = window.routeArray.indexOf(id)
  3594. index > -1 && routeArray.splice(index, 1)
  3595. }
  3596. } */
  3597. }
  3598. } else {
  3599. //点击开始设置要设置的pano
  3600. this.SetOnePanoVisible(panos.index[id])
  3601. }
  3602. this.updateFootIconSize()
  3603. },
  3604. showFootIcons: function(pano, isPanovisible) {
  3605. if (!this.footIcons) {
  3606. footTex1 = Texture.load("images/edit/End_128.png");
  3607. //Store.FootIcon);
  3608. footTex2 = Texture.load("images/edit/End_unable_128.png");
  3609. //Store.FootIcon_unable);
  3610. this.footIcons = [];
  3611. var scale = 0.4;
  3612. scale *= 40 / Math.sqrt(Math.min($("#player").width(), $("#player").height()));
  3613. //屏幕越小,放得越大
  3614. scale = THREE.Math.clamp(scale, 0.3, 0.7)
  3615. //console.log("scale"+scale)
  3616. var geo = new THREE.PlaneGeometry(scale,scale,1,1)
  3617. var panos = player.model.panos;
  3618. for (var r in panos.index) {
  3619. if (!panos.index[r].isAligned())
  3620. continue;
  3621. var t = THREE.UniformsUtils.clone(shaders.waypoint.uniforms);
  3622. t.map.value = footTex1
  3623. t.color.value.set("#ffffff");
  3624. var mat = new THREE.RawShaderMaterial({
  3625. vertexShader: shaders.waypoint.vertexShader,
  3626. fragmentShader: shaders.waypoint.fragmentShader,
  3627. uniforms: t,
  3628. side: THREE.DoubleSide,
  3629. transparent: !0,
  3630. depthWrite: !1,
  3631. depthTest: false,
  3632. name: "footIcon"
  3633. })
  3634. var foot = new THREE.Mesh(geo,mat)
  3635. foot.position.copy(panos.index[r].floorPosition.clone()/* .sub(player.model.position) */
  3636. )
  3637. foot.lookAt(foot.position.clone().add(new THREE.Vector3(0,1,0)));
  3638. foot.name = panos.index[r].id;
  3639. foot.visible = false;
  3640. foot.renderOrder = 6,
  3641. panos.index[r].footIcon = foot;
  3642. this.meshGroup.add(foot);
  3643. this.footIcons.push(foot)
  3644. }
  3645. }
  3646. for (var i = 0; i < this.footIcons.length; i++) {
  3647. this.footIcons[i].visible = true;
  3648. this.changeFIconState(this.footIcons[i], false)
  3649. var panos = player.model.panos;
  3650. if (isPanovisible) {
  3651. this.changeFIconState2(this.footIcons[i], this.checkHasNeighbor(panos.index[this.footIcons[i].name], "showFoot"))
  3652. }
  3653. if (pano && (this.footIcons[i].name == pano.id)) {
  3654. //pano为中心 或者 currentPano 所以放大一点
  3655. this.footIcons[i].oriScale = new THREE.Vector3(1.5,1.5,1.5)
  3656. if (isPanovisible) {
  3657. //currentPano特殊些:
  3658. this.changeFIconState(this.footIcons[i], "center")
  3659. //this.footIcons[i].Unclick = true;//不让点击和hover
  3660. }
  3661. } else {
  3662. this.footIcons[i].oriScale = new THREE.Vector3(1,1,1)
  3663. }
  3664. }
  3665. },
  3666. checkHasNeighbor: function(pano, state) {
  3667. //检查当前状态pano点是否有可通行点
  3668. var neighbours = /* this.panoVTemp && */
  3669. this.panoVTemp[pano.id] ? this.panoVTemp[pano.id].neighbourPanos : pano.neighbourPanos;
  3670. if (state != "showFoot" && pano == this.panoVsetting) {
  3671. //是中心点的话。state == "showFoot"代表是showFootIcon时, 这时候线还没创建,无法用线判断中心点有几个相邻点,直接用neighbourPanos
  3672. for (var i in this.panoVLines) {
  3673. if (this.panoVLines[i].visible) {
  3674. return true;
  3675. //有一条线即可
  3676. }
  3677. }
  3678. return;
  3679. }
  3680. for (var i in neighbours) {
  3681. if (i == pano.id)
  3682. continue;
  3683. if (neighbours[i]) {
  3684. if (this.panoVsetting && this.panoVsetting.id == i && this.panoVLines[pano.id] && !this.panoVLines[pano.id].visible)
  3685. continue;
  3686. return true;
  3687. }
  3688. }
  3689. return false;
  3690. },
  3691. /* ifAllPanoNoNeighbor : function(){//检查是否全是孤立点
  3692. var panos = player.model.panos;
  3693. for(var i in panos.index){
  3694. if(this.checkHasNeighbor(panos.index[i])){
  3695. return false;
  3696. }
  3697. }
  3698. this.noPanoHasNeighbor = true;
  3699. return true;//是全部没有neighbour
  3700. }, */
  3701. changeFIconState: function(footIcon, state) {
  3702. var color = state == "linked" ? this.colors.green : (state == "center" ? /* "#d7f244" */
  3703. "#d5f12e" : "#ffffff");
  3704. footIcon.material.uniforms.color.value.set(color)
  3705. },
  3706. changeFIconState2: function(footIcon, state) {
  3707. //是可见点还是不可见点
  3708. if (state) {
  3709. footIcon.material.uniforms.map.value = footTex1;
  3710. if (this.panoVsetting) {
  3711. if (this.panoVsetting.id != footIcon.name) {
  3712. footIcon.material.uniforms.opacity.value = 1;
  3713. } else {
  3714. this.changeVisiBtnState(true)
  3715. }
  3716. }
  3717. } else {
  3718. //不可见
  3719. footIcon.material.uniforms.map.value = footTex2;
  3720. if (!this.panoVsetting || this.panoVsetting.id != footIcon.name) {
  3721. //非中心点时
  3722. footIcon.material.uniforms.opacity.value = 0.5;
  3723. } else {
  3724. //变为中心点时
  3725. footIcon.material.uniforms.opacity.value = 1;
  3726. this.changeVisiBtnState(false)
  3727. }
  3728. }
  3729. },
  3730. hideFootIcons: function() {
  3731. if (!this.footIcons)
  3732. return;
  3733. for (var i = 0; i < this.footIcons.length; i++) {
  3734. this.footIcons[i].visible = false;
  3735. }
  3736. },
  3737. updateFootIconSize: function() {
  3738. //根据相机位置 改变footIcon大小,使在范围内看到的热点大小一致,防止太小点击不到
  3739. if (!this.footIcons)
  3740. return;
  3741. var s = player.cameraControls.controls.floorplan.absoluteScale * 2.8;
  3742. s = THREE.Math.clamp(s, 0.5, 1.4);
  3743. this.footIcons.forEach(function(f) {
  3744. try {
  3745. f.scale.copy(f.oriScale).multiplyScalar(s);
  3746. } catch (e) {
  3747. console.log(e)
  3748. }
  3749. })
  3750. }
  3751. //========热点可见性==============
  3752. ,
  3753. beginSetTagVisible: function() {
  3754. if (this.setTagVisible)
  3755. return;
  3756. $(".toolTop").addClass("unable")
  3757. $("#hotVisible").addClass("unable")
  3758. this.setTagVisible = true;
  3759. this.tagVTemp = {};
  3760. this.$confirmSnap.text('完成设置').removeClass("hide")
  3761. //objects.tagManager.hideAllTags();
  3762. for (let i in player.model.hots) {
  3763. player.model.hots[i]._isSprite = player.model.hots[i].isSprite;
  3764. player.model.hots[i].isSprite = true;
  3765. player.model.hots[i].mesh.material.depthTest = false;
  3766. }
  3767. this.setDisplay(true)
  3768. this.updateFootIconSize()
  3769. //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话
  3770. },
  3771. SetOneTagVisible: function(tag) {
  3772. //点击某个热点后就对该热点进行设置,或者在热点修改时对其进行设置
  3773. if (this.tagVsetting == tag)
  3774. return;
  3775. if (this.tagVsetting) {
  3776. this.saveLastTagVi(this.tagVsetting);
  3777. //this.tagVsetting.setElemType(this.tagVsetting.style, this.tagVsetting.styleImageURL);
  3778. }
  3779. this.tagVsetting = tag;
  3780. //记录正在修改的
  3781. this.delVisibleLines();
  3782. //删除线
  3783. this.showFootIcons(player.currentPano);
  3784. this.createTagVisiLines(tag);
  3785. //创线
  3786. this.updateFootIconSize()
  3787. //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话
  3788. },
  3789. saveLastTagVi: function() {
  3790. //保存刚设置过的tag
  3791. var change = false;
  3792. var newVPs = this.tagVTemp[this.tagVsetting.sid] || this.tagVsetting.visiblePanos.slice(0);
  3793. for (var r in this.tagsVLines) {
  3794. var line = this.tagsVLines[r];
  3795. if (line.name.indexOf("new") > -1 && line.visible) {
  3796. //新设置为visible且没有取消
  3797. newVPs.push(r)
  3798. change = true;
  3799. //console.log("add: "+r)
  3800. } else if (line.name.indexOf("new") == -1 && !line.visible) {
  3801. //旧的且已经取消
  3802. var i = newVPs.indexOf(r);
  3803. if (i == -1) {
  3804. console.log("visiblePanos删除error");
  3805. continue;
  3806. }
  3807. newVPs.splice(i, 1);
  3808. change = true;
  3809. //console.log("sub: "+r)
  3810. }
  3811. }
  3812. if (change) {
  3813. this.tagVTemp[this.tagVsetting.sid] = newVPs;
  3814. }
  3815. },
  3816. pauseSetTagVisible: function() {
  3817. //pc保存后删除连线 但还在继续设置 点选热点即开始
  3818. if (!this.setTagVisible || !this.tagVsetting)
  3819. return;
  3820. //this.tagVsetting.setElemType(this.tagVsetting.style, this.tagVsetting.styleImageURL );
  3821. this.delVisibleLines();
  3822. this.hideFootIcons();
  3823. this.tagVTemp = {};
  3824. this.tagVsetting = null;
  3825. },
  3826. finishSetTagVisible: function() {
  3827. if (!this.setTagVisible)
  3828. return;
  3829. $(".toolTop").removeClass("unable")
  3830. $("#hotVisible").removeClass("unable")
  3831. this.pauseSetTagVisible();
  3832. this.setTagVisible = false;
  3833. this.setDisplay(false)
  3834. this.$confirmSnap.addClass("hide")
  3835. permitTranMode(true)
  3836. /* for (var r in objects.tagManager.tags) {
  3837. if(objects.tagManager.tags[r].state == "videoPanoFlag")continue;
  3838. objects.tagManager.tags[r].disc.visible = false;
  3839. objects.tagManager.tags[r].disc.material.depthTest = true;
  3840. } */
  3841. for (let i in player.model.hots) {
  3842. player.model.hots[i].isSprite = player.model.hots[i]._isSprite;
  3843. player.model.hots[i].isSprite || player.model.hots[i].mesh.quaternion.copy(player.model.hots[i].quaternion)
  3844. player.model.hots[i].mesh.material.depthTest = true;
  3845. }
  3846. },
  3847. /* saveTagVisibles : function () { //保存到服务器
  3848. if (this.tagVsetting) this.saveLastTagVi(this.tagVsetting); //获取最后设置的那个热点的改动
  3849. //可能出现数据没变但保存的情况。比如先改变了然后切换别的热点但切换回来时又改回来。
  3850. var tags = [];
  3851. for (var i in this.tagVTemp) {
  3852. tags.push({
  3853. sid: i,
  3854. value: this.tagVTemp[i]//turnToPanoIndex(this.tagVTemp[i])
  3855. })
  3856. }
  3857. if (tags.length == 0) {//没有需要保存的改动
  3858. this.finishSetTagVisible()
  3859. return;
  3860. }
  3861. return tags;
  3862. } */
  3863. //afterSaveTagVisibles : function(){
  3864. saveTagVisibles: function() {
  3865. if (this.tagVsetting)
  3866. this.saveLastTagVi(this.tagVsetting);
  3867. for (var i in this.tagVTemp) {
  3868. //保持成功于是生效
  3869. player.model.hots[i].visiblePanos = this.tagVTemp[i];
  3870. }
  3871. this.finishSetTagVisible()
  3872. //还是保存完直接结束吧,因为现在热点可视不放在单独的设置页面了
  3873. },
  3874. createTagVisiLines: function(tag) {
  3875. // 热点可见性线条
  3876. var panos = player.model.panos;
  3877. tag.visiblePanos || tag.setVisiblePanos("get")
  3878. var visibleList = this.tagVTemp[tag.sid] || tag.visiblePanos;
  3879. //如果是刚在设置的要读取设置过的数据
  3880. for (var r = 0; r < visibleList.length; r++) {
  3881. var pano = panos.index[visibleList[r]];
  3882. this.createTagSingleLine(pano, "old", tag)
  3883. }
  3884. },
  3885. createTagSingleLine: function(pano, type, tag) {
  3886. var panos = player.model.panos;
  3887. var line = LineDraw.createLine([pano.floorPosition.clone()/* .sub(this.position) */
  3888. , tag.mesh.position.clone()], {
  3889. color: this.colors.green
  3890. });
  3891. this.meshGroup.add(line);
  3892. line.name = "tagVL-" + type + "-" + pano.id;
  3893. this.tagsVLines[pano.id] = line;
  3894. this.changeFIconState(panos.index[pano.id].footIcon, "linked")
  3895. },
  3896. dealTagVisible: function(tag, panoName) {
  3897. //外部调用
  3898. var panos = player.model.panos;
  3899. if (this.tagsVLines[panoName]) {
  3900. this.tagsVLines[panoName].visible = !this.tagsVLines[panoName].visible;
  3901. this.changeFIconState(panos.index[panoName].footIcon, this.tagsVLines[panoName].visible ? "linked" : false)
  3902. } else {
  3903. this.createTagSingleLine(panos.index[panoName], "new", tag)
  3904. }
  3905. },
  3906. delVisibleLines: function() {
  3907. //xzw add 所有线都删除
  3908. for (var i in this.tagsVLines) {
  3909. this.tagsVLines[i].geometry.dispose();
  3910. this.tagsVLines[i].material.dispose();
  3911. this.meshGroup.remove(this.tagsVLines[i]);
  3912. delete this.tagsVLines[i];
  3913. }
  3914. for (var i in this.panoVLines) {
  3915. this.panoVLines[i].geometry.dispose();
  3916. this.panoVLines[i].material.dispose();
  3917. this.meshGroup.remove(this.panoVLines[i]);
  3918. delete this.panoVLines[i];
  3919. }
  3920. }
  3921. }
  3922. function permitTranMode(state) {
  3923. state ? $(".pinBottom.left").removeClass('hide') : $(".pinBottom.left").addClass('hide');
  3924. }
  3925. CloneObject = function(copyObj, result, isSimpleCopy) {
  3926. //isSimpleCopy只复制最外层
  3927. //复制json result的可能:普通数字或字符串、普通数组、复杂对象
  3928. result = result || {};
  3929. if (copyObj instanceof Array) {
  3930. if (copyObj[0]instanceof Object) {
  3931. //不支持含有 [[Object]] 这样二级数组里面还是复杂数据的,普通和复杂的数据混合可能也不支持
  3932. console.error("不支持含有 [[Object]] 这样二级数组里面还是复杂数据的...")
  3933. }
  3934. return copyObj.slice(0);
  3935. //如果是数组,直接复制返回(排除数组内是object
  3936. }
  3937. for (var key in copyObj) {
  3938. if (copyObj[key]instanceof Object && !isSimpleCopy)
  3939. result[key] = CloneObject(copyObj[key]);
  3940. else
  3941. result[key] = copyObj[key];
  3942. //如果是函数类同基本数据,即复制引用
  3943. }
  3944. return result;
  3945. }
  3946. ;
  3947. function randomWord(randomFlag, min, max) {
  3948. //随机字符串
  3949. var str = ""
  3950. , range = min
  3951. , 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'];
  3952. if (randomFlag) {
  3953. // 随机长度
  3954. range = Math.round(Math.random() * (max - min)) + min;
  3955. }
  3956. for (var i = 0; i < range; i++) {
  3957. var pos = Math.round(Math.random() * (arr.length - 1));
  3958. str += arr[pos];
  3959. }
  3960. return str;
  3961. }
  3962. function getRandomSid() {
  3963. //5-7位随机字符串 + 6位时间 为热点准备
  3964. var pre = randomWord(true, 5, 7);
  3965. var post = new Date().getTime() + "";
  3966. var len = post.length;
  3967. post = post.substring(len - 8, len - 5) + post.substring(len - 3, len)
  3968. //其实还是有可能重复的....
  3969. return pre + post;
  3970. }
  3971. function searchParent(searchArea, o, maxTimes) {
  3972. //是否是某种元素的下级,并找出该元素
  3973. maxTimes = maxTimes || 20;
  3974. var count = 0
  3975. var f = function(dom) {
  3976. if (o.id && o.id == dom.id)
  3977. return dom
  3978. else if (o.className && dom.classList && dom.classList.contains(o.className))
  3979. return dom
  3980. else if (o.tagName && dom.tagName && o.tagName.toUpperCase() == dom.tagName.toUpperCase())
  3981. return dom
  3982. }
  3983. var find;
  3984. while (searchArea && count < maxTimes) {
  3985. if (find = f(searchArea))
  3986. return find
  3987. searchArea = searchArea.parentNode;
  3988. count++;
  3989. }
  3990. }
  3991. class ListBox{//下拉列表
  3992. //elemArr:初始的列表,内含每项的dom.
  3993. constructor(elemArr, $rootDom, options={}){
  3994. this.listDom = $rootDom.find('ul.list')
  3995. this.listTitle = $rootDom.find('.selection')
  3996. this.chosenItem = null
  3997. this.options = options;
  3998. this.bindEvents()
  3999. elemArr.forEach(($dom, i)=>{
  4000. this.addItem($dom)
  4001. })
  4002. }
  4003. updateSelectDisplay(){
  4004. this.listDom.children().removeClass('selected')
  4005. this.chosenItem && this.chosenItem.addClass("selected")
  4006. this.options.selectFun(this.chosenIndex)
  4007. }
  4008. selectFromOutSide(index ){
  4009. this.chosenIndex = index;
  4010. this.chosenItem = index == void 0 ? null : this.listDom.children().eq(index)
  4011. this.updateSelectDisplay()
  4012. }
  4013. addItem($dom){
  4014. this.listDom.append($dom)
  4015. if(this.options.addFun){
  4016. this.options.addFun($dom)
  4017. }
  4018. $dom.on('click',()=>{
  4019. this.chosenItem = $dom;
  4020. this.chosenIndex = $dom.index();
  4021. this.updateSelectDisplay()
  4022. })
  4023. }
  4024. removeItem($dom){
  4025. $dom.remove()
  4026. if(this.options.delFun){
  4027. this.options.delFun($dom)
  4028. }
  4029. }
  4030. saveTemp(){//编辑热点时保存一份副本
  4031. this.temp = Array.from(this.listDom.children()).map((li)=>{
  4032. return li.outerHTML
  4033. })
  4034. this.options.saveTemp && this.options.saveTemp(this)
  4035. }
  4036. recover(){//取消编辑时恢复
  4037. this.listDom.html('')
  4038. this.temp.forEach(html=>{
  4039. this.addItem($(html));
  4040. })
  4041. this.options.recover && this.options.recover(this)
  4042. this.selectFromOutSide(this.chosenIndex)
  4043. }
  4044. bindEvents(){
  4045. this.listTitle.on('click',(e)=>{
  4046. e.stopPropagation()
  4047. this.listDom.toggleClass('hide')
  4048. })
  4049. document.addEventListener('click',()=>{
  4050. this.listDom.addClass('hide')
  4051. })
  4052. }
  4053. }