edit.js 277 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078
  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 ceshi = 'http://47.112.166.173:8105';
  8. var confirmSnap = $(".confirmSnap.innerBtn");
  9. var snapshotGui = $(".snapshotGui.overlayGui");
  10. var _musicMaxWeight = 20 //8
  11. //M
  12. var cmp = getQueryVariable('cmp') || ''
  13. var _hotNum = 0
  14. function reData(data, type) {
  15. return JSON.stringify(data) == type ? null : data
  16. }
  17. let strictInputNum = function(e, precision, min=0,max){//precision:保留小数位数
  18. var value = e.target.value.trim();
  19. var lastOne = value[value.length-1];
  20. var preContent = value.substr(0,value.length-1)
  21. var hasPoint = precision > 0 && lastOne == '.' ;
  22. var a = Math.pow(10, precision)
  23. value = parseFloat(value) || 0;
  24. if(isNaN(value)){
  25. e.target.value = preContent //还原
  26. return
  27. }
  28. e.target.value = Math.max(min, parseInt(value * a) / a )
  29. hasPoint && (e.target.value += '.')//补小数点
  30. }
  31. //新编辑界面
  32. var EditTools = function(n) {
  33. //main2018 里面的主要对象
  34. this.n = n;
  35. //当前状态
  36. this.atPanel = null;
  37. //场景信息
  38. this.sceneInformation = new SceneInformation();
  39. //热点
  40. this.hotpoint = new Hotpoint();
  41. //导览
  42. this.editGuide = new EditGuide();
  43. //音乐
  44. this.EditBGM = new EditBGM();
  45. //初始化界面
  46. //this.init();
  47. this.data = {}
  48. this.editLabel = new EditLabel();
  49. }
  50. EditTools.prototype.loadDone = function(name, data){
  51. this.data[name] = data
  52. if('data' in this.data && 'data2' in this.data){
  53. this.init();
  54. }
  55. }
  56. EditTools.prototype.init = function() {
  57. this.ifLogin();
  58. this.hotpoint.init(/* this.n */);
  59. var that = this;
  60. this.initSaveAll();
  61. this.active();
  62. if(player.mode != 'panorama'){
  63. $(".toolLeft li[data-name=panoVisible]").addClass('unable')
  64. $(".toolLeft li[data-name=routeArrow]").addClass('unable')
  65. player.once("pano.chosen",()=>{//playerAndModelReady
  66. $(".toolLeft li[data-name=panoVisible]").removeClass('unable')
  67. $(".toolLeft li[data-name=routeArrow]").removeClass('unable')
  68. })
  69. }
  70. //创建导览
  71. that.EditBGM.init(this.data.data);
  72. that.sceneInformation.init(this.data.data, this.data.data2)
  73. // fyz 初始化导览需要两部分数据, 其中data2为data.js中的数据
  74. that.editGuide.init(this.data.data, this.data.data2);
  75. that.editLabel.init()
  76. VisiSet.init()
  77. $("body").on("click", function() {
  78. $(".DelConfirm").removeClass("active");
  79. })
  80. player.on("mode.changing",(currentMode, mode, pano)=>{ //起飞
  81. if(this.atPanel != "screen" && !editTool.hotpoint.gettingCameraData) return
  82. if(currentMode == "panorama") confirmSnap.addClass("unable")
  83. })
  84. player.on("flying.ended",(/* toPos, fromPos, pano */)=>{ //飞结束
  85. if(this.atPanel != "screen" && !editTool.hotpoint.gettingCameraData) return
  86. if(player.mode == "panorama") confirmSnap.removeClass("unable")
  87. })
  88. /* $(" .MenuOptions li").on("click", (e)=>{
  89. var $elem = $(e.target);
  90. $elem.closest('.MenuOptions').find('li').removeClass("chosen");
  91. $elem.addClass("chosen");
  92. }) */
  93. //fyz 拖拽以改变顺序
  94. {
  95. let tourListNode = $("#tourList>ul")[0];
  96. let tourItemListNode = $("#tourItemList>ul")[0];
  97. let callback = function(ul){
  98. reIndexTourList(ul)
  99. }
  100. //导览拖拽
  101. setDraggable({ul:tourListNode, dragItemClassName:['guideItem', 'listItem'], callback})
  102. setDraggable({ul:tourItemListNode, dragItemClassName:['guideItem'], callback })
  103. //热点媒体拖拽
  104. setDraggable({ul:$('#hotpointDetail [name="video"] .list')[0], dragItemClassName:['mediaItem'] })
  105. setDraggable({ul:$('#hotpointDetail [name="photo"] .list')[0], dragItemClassName:['mediaItem'] })
  106. //热点列表拖拽
  107. setDraggable({ul:$('.toolRight .spotList')[0], dragItemClassName:['listItem']})
  108. //roomLabel列表拖拽
  109. setDraggable({ul:$('.toolRight .roomLabels [name="list"]>ul')[0], dragItemClassName:['listItem']})
  110. }
  111. $(".toolRight .panoVisible [name=autoCompute]").on('click',()=>{
  112. VisiSet.resetPanosVisiByModel()
  113. })
  114. //平面图方向固定
  115. this.fpAngleOptions = new MenuOptions({
  116. dom: $(".toolRight .information [data-name=floorPlanAngle] .MenuOptions"),
  117. uiCallBack : (o)=>{
  118. var name = o.name == void 0 ? o.$li.attr('index') : o.name
  119. _settings.floorPlanAngle = parseFloat(name) * Math.PI/2 //设置好方向 (0是无效的,将不设置)
  120. if(/* name != 0 && */player.ready){
  121. if(player.mode != 'floorplan' && player.modeTran.split('-')!= 'floorplan'){
  122. player.flyToMode('floorplan')
  123. }else{
  124. player.flyToMode('floorplan',()=>{
  125. //player.cameraControls.controls.floorplan.rotateToAngle(_settings.floorPlanAngle)
  126. player.cameraControls.controls.floorplan.updateRotate()
  127. })
  128. }
  129. }
  130. },
  131. callbackWhenChose:(o)=>{
  132. var name = o.$li.attr('index')
  133. }
  134. })
  135. this.fpAngleOptions.updateChoseAtUI({name: Math.round(_settings.floorPlanAngle/(Math.PI/2))})
  136. /* let restrictAngle = (e)=>{
  137. let index = $(e.target).index()
  138. let str = e.target.value
  139. let value = Math.round(e.target.value)
  140. if(e.type == 'input'){
  141. if(isNaN(value) || str == '') return //继续修改
  142. }
  143. if(isNaN(value)){//取消更改
  144. return e.target.value = index == 0 ? _settings.insideLookLimitDown : _settings.insideLookLimitUp
  145. }
  146. if(index == 0){
  147. if(value>0)value *= -1; //直接帮加-,因为容易写错
  148. value = THREE.Math.clamp(value, -90, 0);
  149. _settings.insideLookLimitDown = value
  150. }else{
  151. value = THREE.Math.clamp(value, 0, 90);
  152. _settings.insideLookLimitUp = value
  153. }
  154. e.target.value = value
  155. } */
  156. let restrictAngle = (e, min, max)=>{
  157. let index = $(e.target).index()
  158. let str = e.target.value
  159. let value = Math.round(e.target.value)
  160. if(e.type == 'input'){
  161. if(isNaN(value) || str == '') return //继续修改
  162. }
  163. if(isNaN(value)){//取消更改
  164. return e.target.value = index == 0 ? _settings.insideLookLimitDown : _settings.insideLookLimitUp
  165. }
  166. if(index == 0){
  167. if(value>0)value *= -1; //直接帮加-,因为容易写错
  168. value = THREE.Math.clamp(value, -90, 0);
  169. _settings.insideLookLimitDown = value
  170. }else{
  171. value = THREE.Math.clamp(value, 0, 90);
  172. _settings.insideLookLimitUp = value
  173. }
  174. e.target.value = value
  175. }
  176. $('.toolRight .information [data-name=upDownAngleLimit] input')[0].value = _settings.insideLookLimitDown
  177. $('.toolRight .information [data-name=upDownAngleLimit] input')[1].value = _settings.insideLookLimitUp
  178. $('.toolRight .information [data-name=upDownAngleLimit] input').on('input', restrictAngle.bind())
  179. $('.toolRight .information [data-name=upDownAngleLimit] input').on('change', restrictAngle)
  180. //角度偏移(极个别场景模型如SG-ebhiLPJ6Ktb在floorplan时歪的,要矫正)
  181. let angleShiftInput = $(".toolRight .information [data-name=floorPlanAngle] [name=angleShift] input")
  182. angleShiftInput.val(_settings.angleShift2d || 0)
  183. angleShiftInput.on('input',(e)=>{
  184. let v = parseFloat(e.target.value)
  185. if(isNaN(v) || e.target.value == '') return //继续修改
  186. let value = toPrecision(THREE.Math.clamp(v,0,90),2)
  187. _settings.angleShift2d = value
  188. if(player.ready){
  189. if(player.mode != 'floorplan' && player.modeTran.split('-')!= 'floorplan'){
  190. player.flyToMode('floorplan')
  191. }else{
  192. player.flyToMode('floorplan',()=>{
  193. player.cameraControls.controls.floorplan.updateRotate()
  194. })
  195. }
  196. }
  197. })
  198. angleShiftInput.on('change',(e)=>{
  199. e.target.value = _settings.angleShift2d
  200. })
  201. }
  202. //点击的时候激活状态
  203. EditTools.prototype.active = function() {
  204. var that = this;
  205. $('.toolBottom .toolLeft li').click(async function() {
  206. var name = $(this).data("name");
  207. $('.toolLeft li[data-name=' + name + ']').addClass("active").siblings().removeClass("active");
  208. $('.toolRight .' + name).removeClass("hide").siblings().addClass("hide");
  209. if (name == that.atPanel)
  210. return;
  211. console.log(`atPanel ${that.atPanel} name ${name}`)
  212. switch (that.atPanel) {
  213. //退出
  214. case "music":
  215. VisiSet.finishSetPanoArea()
  216. break;
  217. case "panoVisible":
  218. await VisiSet.unsaveWarn()
  219. VisiSet.finishSetPanoVisible()
  220. break;
  221. case "panoLog":
  222. VisiSet.finishSetPanoLog()
  223. break;
  224. case "groundAdjust":
  225. VisiSet.finishSetGroundAdjust()
  226. break;
  227. case "routeArrow":
  228. VisiSet.finishSetRoute()
  229. break;
  230. case "screen":
  231. confirmSnap.addClass("hide").removeClass("unable");
  232. snapshotGui.hide();
  233. break;
  234. /* case "overlay":
  235. EditOverlay.leave()
  236. break; */
  237. case "hotpoint":
  238. await that.hotpoint.unsaveWarn()
  239. $("#hotpointDetail").hasClass("atRight") || $("#hotpointDetail a.close").click();
  240. VisiSet.finishSetTagVisible()
  241. that.hotpoint.wireframeModel.visible = false
  242. break;
  243. case 'roomLabels':
  244. that.editLabel.leave()
  245. break;
  246. }
  247. switch (name) {
  248. case "hotpoint":
  249. that.hotpoint.wireframeModel.visible = that.hotpoint.wireframeModel.shouldShow
  250. break;
  251. case "music":
  252. VisiSet.enterSet(VisiSet.beginSetPanoArea.bind(VisiSet))
  253. break;
  254. case "panoVisible":
  255. $(".toolLeft").addClass("unable")
  256. VisiSet.enterSet(VisiSet.beginSetPanoVisible.bind(VisiSet))
  257. break;
  258. case "panoLog":
  259. $(".toolLeft").addClass("unable")
  260. VisiSet.enterSet(VisiSet.beginSetPanoLog.bind(VisiSet))
  261. break;
  262. case "groundAdjust":
  263. $(".toolLeft").addClass("unable")
  264. VisiSet.enterPanoSet(VisiSet.beginSetGroundAdjust.bind(VisiSet))
  265. break;
  266. case 'routeArrow':
  267. VisiSet.enterSet(VisiSet.beginSetRoute.bind(VisiSet))
  268. break;
  269. case "screen":
  270. confirmSnap.removeClass("hide");
  271. $('#camera-start').text("点此设置为初始画面")
  272. snapshotGui.show();
  273. if (player.mode != "panorama")
  274. confirmSnap.addClass("unable")
  275. break;
  276. /* case "overlay":
  277. EditOverlay.enter()
  278. break; */
  279. case 'snapTour':
  280. that.editGuide.scroller.tourBlackSpeed.InitOffset()
  281. that.editGuide.scroller.tourWalkSpeed.InitOffset()
  282. break;
  283. case 'roomLabels':
  284. that.editLabel.enter()
  285. break;
  286. }
  287. that.atPanel = name;
  288. /* if(name != "hotpoint"){
  289. $("#hotpointDetail").hasClass("atRight") || $("#hotpointDetail a.close").click()
  290. } */
  291. })
  292. //滚动阻止事件
  293. $(".toolRight div.content").on("mousewheel", function(event) {
  294. event.stopPropagation()
  295. });
  296. // 输入框阻止事件
  297. $('.toolRight').on('keydown', function(ev) {
  298. ev.stopPropagation();
  299. })
  300. //加空格和回车字符
  301. $(".buttons[name='addSign'] button").on('click',function(e){
  302. let forAttr = $(this).parent().attr('for')
  303. let textarea = forAttr ? $('#'+forAttr) : $(this).parent().parent().find('textarea')
  304. let sign = $(this).attr('name') == 'space' ? '&nbsp;' : '<br>'
  305. var v = textarea.val();
  306. textarea.val(v + sign)
  307. })
  308. }
  309. //保存按钮
  310. EditTools.prototype.initSaveAll = function() {
  311. var that = this;
  312. $('#save').on('click', function() {
  313. $(".edit-loading").removeClass("hide");
  314. var $shareImages = $(".information .edit-fun-images a.result");
  315. new Promise(function(resolve, reject) {//分享图
  316. upload($shareImages, 'images', resolve)
  317. }).then(function(imgUrls) {
  318. //导览的数据
  319. var guides = that.editGuide.getSavingInfo()/* Array.from($('.tourFolderList ul li')).map(function(dom) {
  320. return dom.data
  321. }) */
  322. let tourRotTime = parseFloat($('.toolRight .snapTour [name="rotTime"] input').val())
  323. isNaN(tourRotTime) && (tourRotTime = '')
  324. var info = {
  325. name: $('#pjtName').val(),
  326. summary: $('#info-summary').val(),
  327. weixinDesc: $('#weixin-summary').val(),
  328. shareImgUrl: imgUrls[0] || '',
  329. backgroundMusic: that.EditBGM.musicBox.getSrc() || '',
  330. bgName: that.EditBGM.musicBox.getName(),
  331. hoticon: JSON.parse($(".hotStyle-item li.active").attr("data-val")),
  332. camera_start: $(".screen .shotImg.innerBtn")[0].cameraData,
  333. loadlogo: $("#loadlogo").is(':checked'),
  334. topText: $("#topText").is(':checked'),
  335. special: $("#g_specialScene").is(':checked'),
  336. vision_version: $("#twoData").is(':checked') ? "1.1.562.17209" : false,
  337. roomLabels: that.editLabel.getSavingInfo(),
  338. insideLookLimit : [_settings.insideLookLimitDown, _settings.insideLookLimitUp],
  339. /************************************** 方奕卓 场景可配置项 ******************************************/
  340. hotImageScale: $("#hotImgScale").is(':checked'),
  341. // 热点图片可放大
  342. autoAdjustHotScale : $("#autoAdjustHotScale").is(':checked'),
  343. hideFloorMarker: $("#hideFloorMarker").is(':checked'),
  344. // 地面标记
  345. hideMouseMarker: $("#hideMouseMarker").is(':checked'),
  346. showingLabels: $("#showingLabels").is(':checked'),
  347. // 鼠标标记
  348. floorMarkerColor: $('#floorMarkerColor').val(),
  349. // 地面/导览标志颜色
  350. mouseMarkerColor: $('#mouseMarkerColor').val(),
  351. // 鼠标标志颜色
  352. momentTour: $('#tourSwitch input').is(':checked') ? 'black' : 'walk',
  353. tourFromStart: $('#playTourNearBy input').is(':checked') ? 0 : 1,
  354. tourBlackSpeed : that.editGuide.scroller.tourBlackSpeed.value,
  355. tourWalkSpeed : that.editGuide.scroller.tourWalkSpeed.value,
  356. tourRotTime,
  357. momentTourBlackNewType : $('#newBlack').is(':checked'),
  358. showHotListSta: $('#hotListSwitch').is(':checked'),
  359. // 开启热点列表
  360. hotIconScale: DATA.hotIconScale,
  361. // 热点缩放
  362. supportsVR: $('#VRSwitch input').is(':checked'),
  363. // 开启VR功能
  364. /**************** 陈志广 小地图可配置项 *********** */
  365. cadSignColor: $('#cadSignColor').val(),
  366. cadBorderColor: $('#cadBorderColor').val(),
  367. cadBorderWidth: $('#cad-size').val(),
  368. showCad: $('input[name="show-cad"]').is(':checked'),
  369. /**********/
  370. route: VisiSet.saveRoute(),
  371. floorPlanAngle: _settings.floorPlanAngle || 0, //俯视图旋转角
  372. angleShift2d: _settings.angleShift2d || 0,
  373. panoAreas: VisiSet.savePanoAreas()
  374. }
  375. var puckHeight = VisiSet.getPuckHeightSaveInfo()
  376. puckHeight && (info.puckHeight = puckHeight)
  377. var data = {
  378. sceneCode: number,
  379. hots: reData(that.hotpoint.getSavingInfo(), '{}'),
  380. //tourAudio: reData(that.editGuide.tourAudio,'{}'),//for 旧版
  381. name: number,
  382. guides: reData(guides, '[]'),
  383. info: info,
  384. }
  385. console.log(data)
  386. let url = cmp ? ('/api/scene/edit/' + cmp) : '/manage/scene/edit'
  387. $.ajax({
  388. method: 'POST',
  389. headers: {
  390. 'Content-Type': 'application/json',
  391. token: token
  392. },
  393. dataType: 'json',
  394. contentType: 'application/json',
  395. url: ceshi + url,
  396. data: JSON.stringify(data),
  397. success: function(data) {
  398. if (data.code === 0) {//成功
  399. //manage.showInfo("保存成功")
  400. location.reload()
  401. }else if (data.code === 5001) {
  402. alert('请重新登录')
  403. localStorage.dcj_token = ''
  404. location.reload()
  405. }else{
  406. alert(`saveAll (url:${url}) code : ${data.code} \n${data.msg}`)
  407. }
  408. }
  409. })
  410. });
  411. })
  412. }
  413. EditTools.prototype.ifLogin = function() {//先登录
  414. if(window.location.href.includes('&localTest'))return //本地 不登录
  415. let url = cmp ? ('/api/scene/roamViable/' + cmp) : '/manage/scene/roamViable'
  416. //借用漫游可行保存来判断
  417. $.ajax({
  418. method: 'POST',
  419. url: ceshi + url,
  420. headers: {
  421. 'Content-Type': 'application/json',
  422. token: token
  423. },
  424. contentType: 'application/json',
  425. data: JSON.stringify({
  426. data: '[]',
  427. sceneCode: window.number
  428. }),
  429. success: (data)=>{
  430. if (data.code === 5001) {
  431. alert('请重新登录')
  432. localStorage.dcj_token = ''
  433. location.reload()
  434. }
  435. }
  436. ,
  437. fail: function() {
  438. console.log('ifLogin failed')
  439. }
  440. })
  441. }
  442. class EditLabel{
  443. constructor(){
  444. }
  445. init(){
  446. let reverse = player.model.roomLabels.slice(0).reverse()
  447. reverse.forEach(e=>this.addLebelCallback(e))
  448. $('.toolRight .roomLabels .addBtn button').on('click',()=>{//准备添加
  449. if(this.editingLabel){
  450. this.setEditLabel(false, this.editingLabel)
  451. }
  452. this.setAddState(true)
  453. })
  454. $('.toolRight .roomLabels [name="title"] input').on('input',(e)=>{//标题
  455. this.editingLabel.setTitle(e.target.value)
  456. this.editingLabel.$li.find('.title').text(e.target.value)
  457. })
  458. /* $('.toolRight .roomLabels [name="delete"] button').on('click',(e)=>{//删除
  459. this.deleteLabel(this.editingLabel)
  460. this.setEditLabel(false,this.editingLabel)
  461. }) */
  462. player.on('getIntersect',(intersect, consume)=>{//添加
  463. if(this.adding){
  464. var position = intersect.point.clone();
  465. position.y += 0.5
  466. //var floorIndex = player.model.allFloorsVisible ? null : player.model.currentFloor.floorIndex
  467. var floorIndex = intersect.object.parent.parent.floorIndex
  468. var label = new RoomLabel({position, title:'' , floorIndex })
  469. player.model.roomLabels.push(label)
  470. this.setAddState(false)
  471. this.addLebelCallback(label)
  472. this.setEditLabel(true, label) //开始编辑
  473. this.adding = false
  474. label.update()
  475. consume(true)
  476. }
  477. })
  478. //点击列表弹出按钮
  479. $('.toolRight .roomLabels [name="list"]>ul').on("click", (e)=>{
  480. var target = $(e.target);
  481. let li = searchParent(e.target, { className: 'listItem' }, 7);
  482. if(!li)return;
  483. let label = li.label
  484. if (target.hasClass("del")) {
  485. e.stopPropagation();
  486. target.siblings(".DelConfirm").addClass("active");
  487. } else {
  488. if (target.hasClass("DelConfirm")) {
  489. e.stopPropagation();
  490. this.deleteLabel(label);
  491. }else{
  492. this.setEditLabel(true, label) //开始编辑
  493. }
  494. }
  495. });
  496. }
  497. deleteLabel(label){
  498. let index = player.model.roomLabels.indexOf(label)
  499. index > -1 && player.model.roomLabels.splice(index,1)
  500. label.dispose()
  501. label.$li.remove()
  502. if(this.editingLabel == label){
  503. this.setEditLabel(false,this.editingLabel)
  504. }
  505. }
  506. addLebelCallback(label){
  507. this.addLebelEvent(label)
  508. this.addToList(label)
  509. }
  510. addToList(label){
  511. var $li = $("<li class='listItem' draggable='true'><div class='icon'></div><div class=title >" + label.title + "</div><div class=DelConfirm title='删除'>确定删除</div><div class=del></div></li>");
  512. $li[0].label = label
  513. label.$li = $li;
  514. $('.toolRight .roomLabels [name="list"]>ul').prepend($li)
  515. }
  516. setAddState(state){
  517. state ? CursorDeal.add('addLabel') : CursorDeal.remove('addLabel')
  518. this.adding = state
  519. }
  520. setEditLabel(state, label){
  521. let pannel = $('.toolRight .roomLabels li[name="prop"]')
  522. if(state){
  523. if(this.editingLabel){
  524. let old = this.editingLabel
  525. this.setEditLabel(false, this.editingLabel)
  526. if(old == label){
  527. return //点击已打开的就关闭
  528. }
  529. }
  530. label.elem.addClass('selected')
  531. pannel.removeClass('hide')
  532. pannel.find('[name="title"] input').val(label.title)
  533. label.setEditSelect(true)
  534. pannel.insertAfter(label.$li)
  535. this.editingLabel = label
  536. player.focusPoint({aim: label.position, radius: label.position.distanceTo(player.position)})
  537. }else{
  538. label.elem.removeClass('selected')
  539. pannel.addClass('hide')
  540. label.setEditSelect(false)
  541. this.editingLabel = null
  542. }
  543. }
  544. addLebelEvent(label){
  545. //拖拽
  546. let dragElemShift = {}
  547. let dragging = false
  548. const startDrag = (evt) => {
  549. if(!this.editing )return
  550. dragging = true
  551. $('#player').on("mousemove", drag);
  552. label.elem.find('a').css('pointer-events','none')
  553. /* if(player.mode != 'floorplan'){ //换算到elem的底部
  554. let lebelWidth = label.elem.children(0).width()
  555. let lebelHeight = label.elem.children(0).height() * (68+24) / 24 ;//
  556. dragElemShift = {x: -evt.offsetX + lebelWidth/2, y: 100 } //y向不准确,因为原本添加时提高了0.5,而0.5对应的像素需要根据视角,那就算了吧
  557. }else{
  558. dragElemShift = {x:0,y:0}
  559. } */
  560. CursorDeal.add('moveLabel')
  561. };
  562. const endDrag = (evt) => {
  563. dragging = false
  564. $('#player').off("mousemove", drag);
  565. label.elem.find('a').css('pointer-events','')
  566. CursorDeal.remove('moveLabel')
  567. };
  568. const drag = (evt) => {
  569. if (dragging) {
  570. evt.preventDefault();
  571. let mouse = new THREE.Vector3()
  572. let meshes = player.model.allFloorsVisible ? player.model.colliders : player.model.currentFloor.collider.children
  573. math.convertScreenPositionToNDC(evt.offsetX/* +dragElemShift.x */, evt.offsetY/* +dragElemShift.y */, mouse);
  574. var intersect = convertTool.getMouseIntersect(player.camera, meshes, mouse)
  575. if(intersect){
  576. let position = intersect.point.clone()
  577. position.y += 0.5
  578. label.setPos(position)
  579. var floorIndex = intersect.object.parent.parent.floorIndex
  580. label.floorIndex = floorIndex
  581. }
  582. //this.dispatchEvent({type:'dragged', position: this.position})
  583. }
  584. };
  585. label.elem.on('mousedown', startDrag);
  586. $(document).on('mouseup', endDrag);
  587. $("#player").on('mouseup', endDrag);
  588. //点击编辑:
  589. label.elem.on('click',(e)=>{
  590. if(this.editing){
  591. this.setEditLabel(true,label)
  592. }
  593. e.stopPropagation()
  594. })
  595. }
  596. enter(){
  597. this.editing = true
  598. player.roomLebelClickUnabled = true
  599. }
  600. leave(){
  601. this.editing = false
  602. this.editingLabel && this.setEditLabel(false, this.editingLabel)
  603. player.roomLebelClickUnabled = false
  604. this.setAddState(false)
  605. }
  606. getSavingInfo(){
  607. var info = Array.from($('.toolRight .roomLabels [name="list"] .listItem')).map((li,index)=>{
  608. let label = li.label
  609. return {
  610. //order: index,
  611. title : label.title,
  612. position : toPrecision(label.position.toArray(), 4),
  613. floorIndex: label.floorIndex
  614. }
  615. })
  616. console.log(info)
  617. return info
  618. }
  619. }
  620. //场景信息编辑
  621. var SceneInformation = function() {}
  622. SceneInformation.prototype.init = function(data, data2) {
  623. var $options = $('.hotStyle-item li');
  624. var $loadlogo = $("#loadlogo");
  625. var $topText = $("#topText");
  626. var $hotImageScale = $("#hotImgScale");
  627. var $hideFloorMarker = $("#hideFloorMarker");
  628. var $hideMouseMarker = $("#hideMouseMarker");
  629. var $showingLabels = $("#showingLabels");
  630. var $g_specialScene = $("#g_specialScene");
  631. var $twoData = $("#twoData");
  632. /*******************方奕卓 其他项需要用到data来初始化, 故一并放到这里 ******************/
  633. let momentTour = $('#tourSwitch input');
  634. let playTourNearBy = $('#playTourNearBy input');
  635. let hotListSwitch = $('#hotListSwitch');
  636. // 热点图标缩放
  637. let VRSwitch = $('#VRSwitch input');
  638. // VR功能开启
  639. /***********************************************************************************/
  640. $(".model-title2").text(data.name);
  641. $('#pjtName').val(data.name);
  642. $('#info-summary').val(data.summary);
  643. //if (data2) $('#weixin-summary').val(data2.weixinDesc);
  644. $('#weixin-summary').val(data.weixinDesc);
  645. for (var i = 0; i < $options.length; i++) {
  646. if ($options.eq(i).attr('data-val') === JSON.stringify(data.hoticon)) {
  647. $options.eq(i).addClass("active").siblings().removeClass("active");
  648. }
  649. }
  650. let hasCameraStart = !!data.camera_start && data.camera_start.thumbImg //最初始的数据camera_start是默认值,但无thumbImg
  651. $(".screen .shotImg.innerBtn")[0].cameraData = hasCameraStart && data.camera_start;
  652. if(hasCameraStart) $(".screen .itemTitle button").removeClass('hide')
  653. $(".shotImg.innerBtn").on("click", function(){
  654. var EntryInfo = this.cameraData
  655. if (EntryInfo) {
  656. var to = player.model.panos.get(EntryInfo.pano.uuid);
  657. var q = new THREE.Quaternion().fromArray(EntryInfo.camera.quaternion);
  658. var lookAtPoint = new THREE.Vector3(0,0,-1).applyQuaternion(q).add(to.position);
  659. player.flyToPano({
  660. pano: to,
  661. lookAtPoint: lookAtPoint
  662. })
  663. }
  664. })
  665. $(".screen .itemTitle button").on('click',()=>{
  666. $(".screen .itemTitle button").addClass('hide')
  667. $(".screen .shotImg.innerBtn")[0].cameraData = {};
  668. $(".screen .shotImg.innerBtn").addClass('blank').css("background-image", "")
  669. })
  670. if(data.shareImgUrl){
  671. var imagesHTML = '<div><a class=" result success"><span></span><img src="' + data.shareImgUrl + '"></a></div>'
  672. $(".information .edit-fun-images.list ").html(imagesHTML);
  673. $("#shareImgUpload").addClass("hide")
  674. }
  675. if(data.spotImgUrl){
  676. }
  677. /*************方奕卓 其他项的初始化操作 ************/
  678. initColorElem(data);
  679. // 给其他元素绑定事件
  680. if (data.momentTour === 'black') {
  681. momentTour.prop('checked', true);
  682. }
  683. if (!data.tourFromStart) {//导览非从头开始,而是就近
  684. playTourNearBy.prop('checked', true);
  685. }
  686. if (data.showHotListSta) {
  687. hotListSwitch.prop('checked', true);
  688. }
  689. if (data.momentTourBlackNewType) {
  690. $('#newBlack').prop('checked', true);
  691. }
  692. /* if (data.hotIconScale) {
  693. $('#hotIconScale input').val(parseFloat(data.hotIconScale));
  694. } */
  695. /* $('#hotIconScale_2 input').on('change',(e)=>{
  696. var s = THREE.Math.clamp(parseFloat(e.target.value), 0.1, 100)
  697. e.target.value = s
  698. editTool.hotpoint.editSpot.mesh.scale.set(s,s,s)
  699. }) */
  700. if (data.supportsVR) {
  701. VRSwitch.prop('checked', true);
  702. }
  703. /************************************************/
  704. //隐藏公司logo
  705. if (data.loadlogo) {
  706. $loadlogo[0].checked = true
  707. showLogo();
  708. }
  709. // 隐藏顶部介绍
  710. if(data.topText){
  711. $topText[0].checked = true
  712. topTextHide()
  713. }
  714. // 热点图片放大
  715. if (data.hotImageScale) {
  716. $hotImageScale[0].checked = true
  717. }
  718. // 隐藏地面标记
  719. if (data.hideFloorMarker) {
  720. $hideFloorMarker[0].checked = true
  721. }
  722. // 隐藏鼠标标记
  723. if (data.hideMouseMarker) {
  724. $hideMouseMarker[0].checked = true
  725. }
  726. if (data.showingLabels) {
  727. $showingLabels[0].checked = true
  728. }
  729. //特殊大场景
  730. if (data.special) {
  731. $g_specialScene[0].checked = true
  732. }
  733. //启动二代的数据
  734. if (data.vision_version === "1.1.562.17209" || data.vision_version) {
  735. $twoData[0].checked = true
  736. }
  737. }
  738. /**
  739. * 初始化颜色选择的html元素
  740. * @param {*} data
  741. * @param {*} elem
  742. */
  743. function initColorElem(data, elem) {
  744. let $floorMarkerColor = $('#floorMarkerColor');
  745. let $mouseMarkerColor = $('#mouseMarkerColor');
  746. let $floorMarkerColorTex = $('#floorMarkerColorTex');
  747. let $mouseMarkerColorTex = $('#mouseMarkerColorTex');
  748. let $cadSignColor = $('#cadSignColor');
  749. let $cadSignColorTex = $('#cadSignColorTex');
  750. let $cadBorderColor = $('#cadBorderColor');
  751. let $cadBorderColorTex = $('#cadBorderColorTex');
  752. var colorRe = /^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/;
  753. // 事件监听
  754. $floorMarkerColor.on('change', function(e) {
  755. $('#floorMarkerColorTex').val(e.target.value)
  756. })
  757. $floorMarkerColorTex.on('blur keydown', function(e) {
  758. (e.type === 'blur' || e.type === 'keydown' && e.keyCode === 13) && setColor(e, $floorMarkerColor, this);
  759. })
  760. $mouseMarkerColor.on('change', function(e) {
  761. $('#mouseMarkerColorTex').val(e.target.value)
  762. })
  763. $mouseMarkerColorTex.on('blur keydown', function(e) {
  764. (e.type === 'blur' || e.type === 'keydown' && e.keyCode === 13) && setColor(e, $mouseMarkerColor, this);
  765. })
  766. // 事件监听
  767. $cadSignColor.on('change', function(e) {
  768. $('#cadSignColorTex').val( e.target.value)
  769. })
  770. $cadSignColorTex.on('blur keydown', function(e) {
  771. (e.type === 'blur' || e.type === 'keydown' && e.keyCode === 13) && setColor(e, $cadSignColor, this);
  772. })
  773. // 事件监听
  774. $cadBorderColor.on('change', function(e) {
  775. $('#cadBorderColorTex').val( e.target.value)
  776. })
  777. $cadBorderColorTex.on('blur keydown', function(e) {
  778. (e.type === 'blur' || e.type === 'keydown' && e.keyCode === 13) && setColor(e, $cadBorderColor, this);
  779. })
  780. // 设置颜色值
  781. function setColor(e, colorElem, inputElem) {
  782. var isColor = colorRe.test(e.target.value);
  783. isColor && colorElem.val(e.target.value);
  784. // isColor ? colorElem.val(e.target.value): (inputElem.placeholder = colorElem.val());
  785. }
  786. // 判断data中是否有存在的颜色值, 否则设置默认值
  787. data.floorMarkerColor ? $floorMarkerColor.val(data.floorMarkerColor) : $floorMarkerColor.val('#4bcdfc');
  788. data.mouseMarkerColor ? $mouseMarkerColor.val(data.mouseMarkerColor) : $mouseMarkerColor.val('#4bcdfc');
  789. // 判断data中是否有存在的颜色值, 否则设置默认值
  790. data.cadSignColor ? $cadSignColor.val(data.cadSignColor) : $cadSignColor.val('#00c8af');
  791. data.cadBorderColor ? $cadBorderColor.val(data.cadBorderColor) : $cadBorderColor.val('#ffffff');
  792. $('input[name="show-cad"]')[0].checked = !!data.showCad
  793. $('#cad-size > option[value="'+(data.cadBorderWidth ? data.cadBorderWidth : '0.01')+'"]').attr("selected",true);
  794. if (data.showCad) {
  795. $('input[name="show-cad"]').trigger('change')
  796. }
  797. $('#panoIdColor').on('change', function(e) {
  798. $('#panoIdColorTex').val(e.target.value)
  799. VisiSet.changePanoIdColor(e.target.value)
  800. })
  801. $('#panoIdColorTex').on('blur keydown', function(e) {
  802. (e.type === 'blur' || e.type === 'keydown' && e.keyCode === 13) && setColor(e, $('#panoIdColor'), this);
  803. VisiSet.changePanoIdColor(e.target.value)
  804. })
  805. $('#panoIdColor').val('#e8ffa8')//初始颜色
  806. $('#panoIdColorTex').val('#e8ffa8')
  807. }
  808. $('input[name="show-cad"]').on('change', function(ev) {
  809. if (!ev.target.checked) {
  810. return $('.cad').hide()
  811. }
  812. let taht = this
  813. if (!taht.floorJSON) {
  814. $.ajax({
  815. url: '//super.4dage.com/data/'+ window.number +'/floor.json',
  816. method: 'GET',
  817. success(res) {
  818. taht.floorJSON = res
  819. loadCAD(taht.floorJSON)
  820. $('#cadSignColor').on('change', function(ev) {
  821. loadCAD()
  822. })
  823. $('#cadBorderColor').on('change', function(ev) {
  824. loadCAD()
  825. })
  826. $('#cad-size').on('change', function(ev) {
  827. loadCAD()
  828. })
  829. },
  830. error() {
  831. alert('当前场景没有小地图floor.json文件,请联系三维部门添加')
  832. ev.target.checked = false
  833. }
  834. })
  835. } else {
  836. console.log('0000000000000000000')
  837. $('.cad').show()
  838. }
  839. })
  840. function loadCAD(data) {
  841. grendCAD(data, $('#player')[0], $('#cadSignColor').val(), $('#cadBorderColor').val(), $('#cad-size').val())
  842. }
  843. //设置初始界面
  844. function getSeft(seft) {
  845. $('#camera-start').on('click', function(e) {
  846. if (VisiSet.setPanoVisible) {
  847. return VisiSet.savePanoVisibles()
  848. } else if (VisiSet.setTagVisible) {
  849. return VisiSet.saveTagVisibles()
  850. }
  851. var snapType = editTool.hotpoint.editSpot ? 'hot' : 'screen'
  852. var preview = snapType == 'screen' ? $(".screen .shotImg.innerBtn")[0] : $('#hotpointDetail .shotImg.innerBtn')[0]
  853. var snap = JSON.parse("{" + seft.getSnapAngleInfo() + "}")
  854. preview.cameraData = {
  855. camera: {
  856. position: snap.metadata.camera_position,
  857. quaternion: snap.metadata.camera_quaternion// 相机朝向
  858. },
  859. pano: {
  860. uuid: snap.metadata.scan_id // 起始点位的id
  861. }
  862. }
  863. var ev = document.createEvent("MouseEvent");//截取视图
  864. g_snapShotWidth = snapType == 'screen' ? 240 * 4 : 240;
  865. g_snapShotHeight = snapType == 'screen' ? 118 * 4 : 118;
  866. //window.screenSta = 'startScreen';
  867. ev.initMouseEvent("snapshotBegin", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  868. ev.__callback = (imgData,info)=>{
  869. uploadImg(imgData, (rs)=>{
  870. if (rs.code === 0) {
  871. preview.cameraData.thumbImg = rs.data;
  872. preview.style['background-image'] = "url(" + rs.data + ")"
  873. }
  874. }
  875. , "thumbImg.jpg")
  876. }
  877. $(".screen .itemTitle button").removeClass('hide')
  878. window.dispatchEvent(ev);
  879. });
  880. }
  881. //热点编辑
  882. var Hotpoint = function() {
  883. this.spotList = $(".spotList");
  884. this.hotpointDetail = $("#hotpointDetail");
  885. this._scale = {}
  886. this.scroller = {}
  887. this.scroller.boxDepth = new SlideBar({
  888. root: $('#boxDepth').eq(0),
  889. value: 0,
  890. min: 0 * 100,
  891. max: 1 * 100,
  892. name: "boxDepth",
  893. unitStr: "cm",
  894. avoidCrash: true,
  895. onchange: (s)=>{
  896. if (s == 0) {
  897. this.editSpot.addBox(false)
  898. } else {
  899. this.editSpot.addBox(true)
  900. this.editSpot.scale.z = s / 100 ;
  901. this.updateTransform("scale")
  902. }
  903. },
  904. dragEndEvent: function() {
  905. }
  906. })
  907. // fyz 导览编辑页面同样采取热点编辑的样式, 这里确保只查找到热点编辑
  908. }
  909. Hotpoint.prototype.init = function() {
  910. var that = this;
  911. $(".hotStyle-item li").on('click', function() {//默认样式
  912. $(this).addClass('active').siblings().removeClass('active');
  913. })
  914. // 添加多媒体
  915. this.musicBox = musicPlayBoxBind(this.hotpointDetail.find("[name=audio].mediaUpload"), null )
  916. this.addmediaInit();
  917. // 添加音乐
  918. this.addModel();
  919. // 添加模型
  920. this.addwebPack();
  921. // 添加外链
  922. this.wireframeModel = new THREE.Object3D;
  923. if(Hot.allPhotoLoaded && Hot.allModelLoaded) this.initListSelect()
  924. else Hot.whenAllFileLoaded = this.initListSelect.bind(this) //等全部photo加载完
  925. player.model.hotGroup.children.forEach(e=>this.addHotList(e) )//创建列表
  926. this.hotpointDetail.find(".tail .submit").on('click', this.saveHot.bind(this))
  927. this.hotpointDetail.find("[name=info] input").on('change',(e)=>{//标题
  928. this.editSpot.info.title = e.target.value
  929. this.editSpot.setTitleElem()
  930. })
  931. //media简介
  932. {
  933. let textarea = this.hotpointDetail.find('li[name="photo"] textarea, li[name="video"] textarea');
  934. textarea.on('change',(e)=>{
  935. if(!e.target.currentBtn)return
  936. e.target.currentBtn.desc = e.target.value;
  937. this.descBtnUpdate(e.target.currentBtn )
  938. })
  939. //应用到所有
  940. let applyAll = (type)=>{
  941. var choice = confirm(`确定将文字应用到此热点的所有${type == 'photo' ? '图片' : '视频'}吗?`);
  942. if (choice) {
  943. Array.from(that.hotpointDetail.find(`[name=${type}] .list .descBtn`)).forEach(btn=>{
  944. btn.desc = this.hotpointDetail.find(`li[name=${type}] textarea`)[0].value
  945. this.descBtnUpdate(btn)
  946. })
  947. }
  948. }
  949. this.hotpointDetail.find('li[name="photo"] button').on('click',()=>{
  950. applyAll("photo")
  951. })
  952. this.hotpointDetail.find('li[name="video"] button').on('click',()=>{
  953. applyAll("video")
  954. })
  955. }
  956. /* {
  957. let ui = $('#hotIconScale input')
  958. let min = parseFloat(ui.attr('min'));
  959. let max = parseFloat(ui.attr('max'));
  960. ui.on("change", function(e) {
  961. var s = THREE.Math.clamp(parseFloat(e.target.value), min, max)
  962. if(isNaN(s))s = 1
  963. e.target.value = s
  964. DATA.hotIconScale = s
  965. })
  966. } */
  967. $(".hotpoint [name='adjustSize'] button").on('click',(e)=>{
  968. let type = $(e.target).attr('index')
  969. var c = 1.1
  970. if(type == '-'){
  971. s = 1/c
  972. }else{
  973. s = c
  974. }
  975. s = Math.max(0.001, s)
  976. let sid = player.mode == 'panorama' ? player.currentPano.id : "outside";
  977. player.model.hotGroup.children.forEach(hot=>{
  978. if(hot.texType == 'shine'){
  979. hot.info.scale.multiplyScalar(s)
  980. let s1 = hot.info.transformAtPanos[sid] ?.scale //跳过独立调整的
  981. s1 || hot.scale.multiplyScalar(s)
  982. }
  983. })
  984. DATA.hotIconScale *= s //没用,兼容旧版代码
  985. })
  986. this.isSpriteCheckBox = new CheckBox({dom: $("#isSprite"),
  987. uiCallBack : (checked)=>{
  988. },
  989. callbackWhenChose:(checked)=>{
  990. that.editSpot.info.isSprite = checked;
  991. if(checked) {
  992. that.editSpot.update(player)
  993. }else{
  994. that.editSpot.quaternion.copy(that.editSpot.info.quaternion)
  995. }
  996. }
  997. })
  998. //clickEvent
  999. this.actionCheckBox = new CheckBox({dom: this.hotpointDetail.find("li[name='clickEvent'] li.editCheckbox input"),
  1000. uiCallBack : (checked, name)=>{
  1001. if(name == 'openHot'){
  1002. var content = that.hotpointDetail.find("li[name='content']")
  1003. checked ? content.removeClass('hide') : content.addClass('hide')
  1004. }else if(name == 'fastTran'){//瞬间过渡
  1005. var fastTran = that.hotpointDetail.find("li[name='fastTran']")
  1006. checked ? fastTran.removeClass('hide') : fastTran.addClass('hide')
  1007. }
  1008. },
  1009. callbackWhenChose:(checked, name)=>{
  1010. that.editSpot.info.actionType[name] = !!checked;
  1011. }
  1012. })
  1013. this.autoOpenCheckBox = new CheckBox({dom: $('#autoOpen input') ,
  1014. uiCallBack : (checked, name)=>{
  1015. let label = $('#hotpointDetail [name=autoOpen] [name=panoId]')
  1016. checked ? label.removeClass('hide') : label.addClass('hide')
  1017. $('#autoOpen span').text(checked ? '自动打开' : '在当前点位自动打开')
  1018. setTimeout(()=>{
  1019. checked && label.find('span').text(this.editSpot.info.autoOpenPanoId )
  1020. },1)
  1021. },
  1022. callbackWhenChose:(checked, name)=>{
  1023. this.editSpot.info.autoOpenPanoId = checked ? player.currentPano.id : null
  1024. $('#autoOpen span').text(checked ? '自动打开' : '在当前点位自动打开')
  1025. }
  1026. })
  1027. this.imgDescCheckBox = new CheckBox({dom: this.hotpointDetail.find("#addImgDesc"),
  1028. uiCallBack : (checked, name)=>{
  1029. var textarea = this.hotpointDetail.find('li[name="photo"] textarea');
  1030. var title = this.hotpointDetail.find('li[name="photo"] [name="descTitle"]')
  1031. if(!checked){
  1032. textarea.addClass('hide'), title.addClass('hide')
  1033. /* textarea.val('');
  1034. textarea[0].currentBtn = null */
  1035. }else{
  1036. textarea.removeClass('hide'), title.removeClass('hide')
  1037. }
  1038. var imgArea = this.hotpointDetail.find('li[name="photo"] .edit-fun-images');
  1039. checked ? imgArea.addClass('hasDescBtn') : imgArea.removeClass('hasDescBtn')
  1040. },
  1041. callbackWhenChose:(checked, name)=>{
  1042. that.editSpot.info.useImgDesc = !!checked;
  1043. }
  1044. })
  1045. this.videoDescCheckBox = new CheckBox({dom: this.hotpointDetail.find("#addVideoDesc"),
  1046. uiCallBack : (checked, name)=>{
  1047. var textarea = this.hotpointDetail.find('li[name="video"] textarea');
  1048. var title = this.hotpointDetail.find('li[name="video"] [name="descTitle"]')
  1049. if(!checked){
  1050. textarea.addClass('hide'), title.addClass('hide')
  1051. /* textarea.val('');
  1052. textarea[0].currentBtn = null */
  1053. }else{
  1054. textarea.removeClass('hide'), title.removeClass('hide')
  1055. }
  1056. var Area = this.hotpointDetail.find('li[name="video"] .edit-fun-images');
  1057. checked ? Area.addClass('hasDescBtn') : Area.removeClass('hasDescBtn')
  1058. },
  1059. callbackWhenChose:(checked, name)=>{
  1060. that.editSpot.info.useVideoDesc = !!checked;
  1061. }
  1062. })
  1063. //点击添加热点按钮
  1064. $('.hotpoint .addBtn button').on("click", function(e) {
  1065. g_HotStatus = $(e.target).attr('data-type');
  1066. //$("#player").css("cursor", "cell");
  1067. CursorDeal.add('addHot' )
  1068. });
  1069. //点击热点列表弹出按钮
  1070. this.spotList.on("click", function(e) {
  1071. var target = $(e.target);
  1072. let li = searchParent(e.target, { className: 'listItem' }, 7);
  1073. if(!li)return;
  1074. var hotId = $(li).attr("data-spid");
  1075. var hot = player.model.hots[hotId]
  1076. if(VisiSet.setTagVisible){
  1077. player.focusPoint({aim: hot.position, radius:hot.position.distanceTo(player.position), dontChangeScale:true})
  1078. return VisiSet.SetOneTagVisible(hot)
  1079. }
  1080. if (target.hasClass("del")) {
  1081. e.stopPropagation();
  1082. target.siblings(".DelConfirm").addClass("active");
  1083. that.spotList.find("i").text(that.spotList.find("ul li").length);
  1084. } else {
  1085. if (target.hasClass("DelConfirm")) {
  1086. e.stopPropagation();
  1087. that.removeHot(hot);
  1088. } else {
  1089. //点击热点列表弹出编辑热点窗口
  1090. that.editHot(hot, $(li))
  1091. }
  1092. }
  1093. });
  1094. this.hotpointDetail.find(".tail button.delete").on("click", ()=>{
  1095. var choice = confirm(`确定删除热点?`);
  1096. if (choice) {
  1097. that.removeHot(this.editSpot);
  1098. cancelEdit(this.editSpot)
  1099. }
  1100. })
  1101. let cancelEdit = (hot)=>{
  1102. this.tempInfos && player.model.hotGroup.children.forEach(hot=>{//还原所有同时修改了的贴图和模型
  1103. var info = this.tempInfos[hot.sid]
  1104. if(hot.texType == 'shine'){
  1105. hot.changeTexType(hot.texType, info.styleImg )
  1106. hot.info.styleImg = info.styleImg.map(e=>e.src)
  1107. }else{
  1108. hot.changeTexType(hot.texType, info.texMedia )
  1109. hot.info.texSrc = info.texMedia.src;
  1110. if(hot.texType == 'photo' && hot.info.animateInfo){
  1111. GifTexDeal.remove(hot.animation)
  1112. hot.animation = GifTexDeal.addAnimation(hot.material_.map, hot, hot.info.animateInfo )
  1113. GifTexDeal.start(hot.animation)
  1114. }
  1115. }
  1116. if(hot.objObject != info.objObject){
  1117. this.switchModel({add:info.objObject, spot:hot})
  1118. hot.info.scale.copy(info.scale)
  1119. hot.scale.copy(info.scale)
  1120. }
  1121. })
  1122. if(this.texLists){
  1123. for(let i in this.texLists){this.texLists[i].recover()}
  1124. this.modelList.recover()
  1125. }
  1126. this.editDone();
  1127. hot.updateVisible([player.currentPano])
  1128. }
  1129. //关闭、取消
  1130. this.hotpointDetail.find(".head a.close, .tail button.cancel").on("click", ()=>{
  1131. var hot = this.editSpot
  1132. if(hot.isNew){
  1133. this.removeHot(hot)
  1134. }else{
  1135. this.recoverInfo(hot)
  1136. }
  1137. cancelEdit(hot)
  1138. });
  1139. this.linkTypeMenuOptions = new MenuOptions({ //链接打开方式切换
  1140. dom: this.hotpointDetail.find(" .MenuOptions[name=linkType] "),
  1141. uiCallBack : (o)=>{
  1142. },
  1143. callbackWhenChose:(o)=>{
  1144. this.editSpot.info.linkType = o.$li.attr("index")
  1145. }
  1146. })
  1147. this.panoTransformCheckBox = new CheckBox({dom: $('#setPosForPano input') ,
  1148. uiCallBack : (checked, name)=>{
  1149. },
  1150. callbackWhenChose:(checked, name)=>{
  1151. if(!checked){
  1152. delete this.editSpot.info.transformAtPanos[getTransformSid()]
  1153. this.editSpot.position.copy(this.editSpot.info.position)
  1154. this.editSpot.quaternion.copy(this.editSpot.info.quaternion)
  1155. this.editSpot.scale.copy(this.editSpot.info.scale)
  1156. }else{
  1157. this.getTransformAtPano(['position'])
  1158. }
  1159. }
  1160. })
  1161. /* $('#setPosForPano input').on("change", ()=>{
  1162. var on = $('#setPosForPano input').is(':checked')
  1163. if(!on){
  1164. delete this.editSpot.info.transformAtPanos[getTransformSid()]
  1165. this.editSpot.position.copy(this.editSpot.info.position)
  1166. //this.editSpot.quaternion.copy(this.editSpot.quaternion)
  1167. }else{
  1168. this.getTransformAtPano(['position'])
  1169. }
  1170. }) */
  1171. //是否显示模型线框
  1172. this.wireframeModel = new THREE.Object3D;
  1173. $('#wireframeSwitch input').on('change',(e)=>{
  1174. var visi = e.target.checked;
  1175. if(visi && this.wireframeModel.children.length == 0){
  1176. var mat = new THREE.MeshBasicMaterial({
  1177. wireframe: true,
  1178. opacity: 0.5,
  1179. color: "#57e4f3",
  1180. transparent: true
  1181. })
  1182. this.wireframeModel.name = 'wireframeModel'
  1183. player.model.chunks.forEach((mesh)=>{
  1184. var chunk = mesh.clone();
  1185. chunk.material = mat;
  1186. this.wireframeModel.add(chunk)
  1187. })
  1188. this.wireframeModel.visible = false
  1189. player.model.add(this.wireframeModel)
  1190. }
  1191. this.wireframeModel.visible = visi
  1192. this.wireframeModel.shouldShow = visi
  1193. })
  1194. $("#autoAdjustHotScale")[0].checked = !!DATA.autoAdjustHotScale;
  1195. new CheckBox({dom: $("#autoAdjustHotScale"),
  1196. uiCallBack : (checked )=>{
  1197. },
  1198. callbackWhenChose:(checked )=>{
  1199. DATA.autoAdjustHotScale = checked
  1200. if(!checked){//恢复大小
  1201. player.model.hotGroup.children.forEach(e=>e.texType == 'shine' && e.plane?.scale.set(1,1,1))
  1202. }
  1203. }
  1204. })
  1205. //动画
  1206. this.gifCheckBox = new CheckBox({dom: $("#gifSwitch input"),
  1207. uiCallBack : (checked )=>{
  1208. $("#gifInfoEdit").css({display: checked ? 'block' : 'none'})
  1209. },
  1210. callbackWhenChose:(checked )=>{
  1211. if(checked){
  1212. that.editSpot.info.animateInfo = {
  1213. cellXcount : parseInt($("#gifXCount").val()),
  1214. cellYcount : parseInt($("#gifYCount").val()),
  1215. voidCount : parseInt($("#voidCount").val()),
  1216. loop : true,
  1217. duration : parseFloat($("#gifDuration").val()) * 1000
  1218. }
  1219. that.editSpot.animation = GifTexDeal.addAnimation(that.editSpot.material_.map, that.editSpot, this.editSpot.info.animateInfo, this.editSpot.sid)
  1220. GifTexDeal.start(that.editSpot.animation)
  1221. }else{
  1222. GifTexDeal.remove(that.editSpot.animation)
  1223. that.editSpot.info.animateInfo = null
  1224. }
  1225. }
  1226. })
  1227. {//gif动画 input
  1228. let changeAnimation = function(){
  1229. GifTexDeal.setRepeart(that.editSpot.animation.animation)
  1230. that.useSuitableRatio()
  1231. }
  1232. let restartAnimation = function(){
  1233. GifTexDeal.stop(that.editSpot.animation)
  1234. GifTexDeal.start(that.editSpot.animation)
  1235. }
  1236. let changeFrameCount = function(){
  1237. var a = that.editSpot.info.animateInfo
  1238. var frameCount = a.cellXcount * a.cellYcount - (a.voidCount||0)
  1239. $("#gifFrameCount").text(frameCount)
  1240. var fps = parseFloat($("#gifFps").val())
  1241. a.duration = frameCount / fps * 1000
  1242. $("#gifDuration").val(toPrecision(a.duration/1000, 2))
  1243. }
  1244. let gifXCountFun = function(value){
  1245. that.editSpot.info.animateInfo.cellXcount = value
  1246. var gifImgWidth = parseFloat($("#gifImgWidth").text())
  1247. var gifCellWidth = toPrecision(gifImgWidth / that.editSpot.info.animateInfo.cellXcount,1);
  1248. $("#gifCellWidth").text(gifCellWidth)
  1249. changeFrameCount()
  1250. changeAnimation()
  1251. }
  1252. $("#gifXCount").on('input',(e)=>{
  1253. strictInputNum(e, 0, 1)
  1254. gifXCountFun(parseFloat(e.target.value))
  1255. })
  1256. $("#gifXCount").on('change',(e)=>{
  1257. strictInputNum(e, 0, 1)
  1258. gifXCountFun(parseFloat(e.target.value))
  1259. restartAnimation()
  1260. })
  1261. let gifYCountFun = function(value){
  1262. that.editSpot.info.animateInfo.cellYcount = value
  1263. var gifImgHeight = parseFloat($("#gifImgHeight").text())
  1264. var gifCellHeight = toPrecision(gifImgHeight / that.editSpot.info.animateInfo.cellYcount,1);
  1265. $("#gifCellHeight").text(gifCellHeight)
  1266. changeFrameCount()
  1267. changeAnimation()
  1268. }
  1269. $("#gifYCount").on('input',(e)=>{
  1270. strictInputNum(e, 0, 1)
  1271. gifYCountFun(parseFloat(e.target.value))
  1272. })
  1273. $("#gifYCount").on('change',(e)=>{
  1274. strictInputNum(e, 0, 1)
  1275. gifYCountFun(parseFloat(e.target.value))
  1276. changeAnimation()
  1277. restartAnimation()
  1278. })
  1279. /* let gifCellWidthFun = function(value){
  1280. var gifCellWidth = value;
  1281. var gifImgWidth = parseFloat($("#gifImgWidth").text())
  1282. var cellXcount = toPrecision(gifImgWidth / gifCellWidth,2);
  1283. $("#gifXCount").val(cellXcount)
  1284. changeAnimation()
  1285. }
  1286. $("#gifCellWidth").on('input',(e)=>{
  1287. strictInputNum(e, 0)
  1288. gifCellWidthFun(parseFloat(e.target.value))
  1289. })
  1290. $("#gifCellWidth").on('change',(e)=>{
  1291. strictInputNum(e, 0, 1)
  1292. gifCellWidthFun(parseFloat(e.target.value))
  1293. var cellXcount = $("#gifXCount").val();
  1294. var cellXcountInt = Math.round(cellXcount)
  1295. if(cellXcountInt != cellXcount){
  1296. $("#gifXCount").val(cellXcountInt)
  1297. gifXCountFun(cellXcountInt)
  1298. changeAnimation()
  1299. }
  1300. restartAnimation()
  1301. })
  1302. let gifCellHeightFun = function(value){
  1303. var gifCellHeight = parseFloat(e.target.value);
  1304. var gifImgHeight = parseFloat($("#gifImgHeight").text())
  1305. var cellYcount = toPrecision(gifImgHeight / gifCellHeight,2);
  1306. $("#gifYCount").val(cellYcount)
  1307. }
  1308. $("#gifCellHeight").on('input',(e)=>{
  1309. strictInputNum(e, 0)
  1310. gifCellHeightFun(parseFloat(e.target.value))
  1311. })
  1312. $("#gifCellHeight").on('change',(e)=>{
  1313. strictInputNum(e, 0, 1)
  1314. gifCellHeightFun(parseFloat(e.target.value))
  1315. var cellYcount = $("#gifYCount").val();
  1316. var cellYcountInt = Math.round(cellYcount)
  1317. if(cellYcountInt != cellYcount){
  1318. $("#gifYCount").val(cellYcountInt)
  1319. gifYCountFun(cellYcountInt)
  1320. changeAnimation()
  1321. }
  1322. restartAnimation()
  1323. })*/
  1324. $("#voidCount").on('change',(e)=>{
  1325. strictInputNum(e, 0);
  1326. that.editSpot.info.animateInfo.voidCount = parseInt(e.target.value)
  1327. changeFrameCount()
  1328. restartAnimation()
  1329. })
  1330. let gifDurationFun = function(value){
  1331. var a = that.editSpot.info.animateInfo
  1332. let frameCount = a.cellXcount * a.cellYcount
  1333. a.duration = value
  1334. $("#gifFps").val(toPrecision(frameCount / a.duration * 1000, 1))
  1335. }
  1336. $("#gifDuration").on('input',(e)=>{
  1337. strictInputNum(e, 1);
  1338. gifDurationFun(parseFloat(e.target.value) * 1000)
  1339. })
  1340. $("#gifDuration").on('change',(e)=>{
  1341. strictInputNum(e, 1, 0.01);
  1342. gifDurationFun(parseFloat(e.target.value) * 1000)
  1343. restartAnimation()
  1344. })
  1345. var gifFpsFun = function(e){
  1346. strictInputNum(e, 0, 1);
  1347. var fps = parseFloat(e.target.value)
  1348. var a = that.editSpot.info.animateInfo
  1349. let frameCount = a.cellXcount * a.cellYcount - (a.voidCount||0)
  1350. a.duration = frameCount / fps * 1000
  1351. $("#gifDuration").val(toPrecision(a.duration / 1000, 2))
  1352. }
  1353. $("#gifFps").on('input',(e)=>{
  1354. gifFpsFun(e)
  1355. })
  1356. $("#gifFps").on('change',(e)=>{
  1357. gifFpsFun(e)
  1358. restartAnimation()
  1359. })
  1360. }
  1361. this.modelMenuOptions = new MenuOptions({
  1362. dom: this.hotpointDetail.find(".MenuOptions[name=modelType]"),
  1363. uiCallBack : (o)=>{
  1364. var name = o.name == void 0 ? o.$li.attr('index') : o.name
  1365. if(name == "default"){
  1366. this.hotpointDetail.find('[name=boxDepthPanel]').removeClass('hide')
  1367. this.updateBoxDepthPanel()
  1368. this.hotpointDetail.find('[name=uploadObj]').addClass('hide')
  1369. transformControls.unableScaleZ()
  1370. }else{
  1371. this.hotpointDetail.find('[name=boxDepthPanel]').addClass('hide')
  1372. this.hotpointDetail.find('[name=uploadObj]').removeClass('hide')
  1373. }
  1374. },
  1375. callbackWhenChose:(o)=>{
  1376. var name = o.$li.attr('index')
  1377. if(name == "default"){
  1378. /* transformControls.unableScaleZ()
  1379. this.editSpot.removeModel() */
  1380. this.switchModel({remove:true, spot:this.editSpot})
  1381. if(this._scale[this.editSpot.texType]){//恢复大小
  1382. this.editSpot.scale.copy(this._scale[this.editSpot.texType]);
  1383. this.editSpot.info.scale.copy(this._scale[this.editSpot.texType]);
  1384. }
  1385. }else{
  1386. this.modelList.options.selectFun()
  1387. //this._scale[this.editSpot.texType] = this.editSpot.scale.clone()
  1388. }
  1389. }
  1390. })
  1391. this.titleShowOptions = new MenuOptions({ //何时显示
  1392. dom: this.hotpointDetail.find(".MenuOptions[name=titleShowType]"),
  1393. uiCallBack : (o)=>{
  1394. },
  1395. callbackWhenChose:(o)=>{
  1396. var name = o.name == void 0 ? o.$li.attr('index') : o.name
  1397. this.editSpot.info.titleShowType = name
  1398. this.editSpot.setHoverState(false) //update
  1399. }
  1400. })
  1401. this.titlePosOptions = new MenuOptions({ //相对热点的位置
  1402. dom: this.hotpointDetail.find(".MenuOptions[name=titlePos]"),
  1403. uiCallBack : (o)=>{
  1404. },
  1405. callbackWhenChose:(o)=>{
  1406. var name = o.name == void 0 ? o.$li.attr('index') : o.name
  1407. this.editSpot.info.titlePos = name
  1408. this.editSpot.setTitleDir();
  1409. this.latestTitlePos = this.editSpot.info.titlePos//最近一次设置的,运用到新的热点中
  1410. }
  1411. })
  1412. this.hotpointDetail.find("li[name='fastTran'] button").on('click',(e)=>{
  1413. this.setCameraBtn(!this.gettingCameraData)
  1414. })
  1415. {
  1416. let pos = new THREE.Vector3(Infinity,Infinity,Infinity)
  1417. player.on("view.changed",(e)=>{
  1418. if(e.cameraChanged && !pos.equals(player.position)){
  1419. this.updateDis();
  1420. pos.copy(player.position)
  1421. }
  1422. })
  1423. }
  1424. player.on('flying.ended',()=>{
  1425. player.mode != 'transitioning' && this.updateTranInput() //cause transformAtPanos
  1426. })
  1427. $('.toolRight .hotpoint [name=setPos] .axisValInput input').on('change',(e)=>{
  1428. let v = parseFloat(e.target.value)
  1429. if(isNaN(v) || e.target.value == '') return //继续修改
  1430. let index = $(e.target.parentElement).index()
  1431. let prop = { 'translate' : 'position', 'scale':'scale', 'rotate':'rotation' }[transformControls.mode]
  1432. let axis = ['x','y','z'][index]
  1433. if(prop == 'rotation'){
  1434. v = THREE.Math.degToRad(v)
  1435. }else if(prop == 'scale'){
  1436. if(v == 0){
  1437. v = 0.001 ;//禁止为0
  1438. }
  1439. }
  1440. this.editSpot[prop][axis] = v
  1441. this.updateTransform([prop])
  1442. })
  1443. }
  1444. Hotpoint.prototype.setCameraBtn = function(state){
  1445. let btn = this.hotpointDetail.find("li[name='fastTran'] button")
  1446. if(!state){
  1447. confirmSnap.addClass("hide");
  1448. snapshotGui.hide();
  1449. btn.text('设置')
  1450. this.gettingCameraData = false
  1451. }else{
  1452. confirmSnap.removeClass("hide");
  1453. $('#camera-start').text("点此设置跳转到此方位")
  1454. snapshotGui.show();
  1455. if (player.mode != "panorama"){
  1456. $(".confirmSnap").addClass("unable")
  1457. }else{
  1458. $(".confirmSnap").removeClass("unable")
  1459. }
  1460. btn.text('结束设置')
  1461. this.gettingCameraData = true
  1462. }
  1463. }
  1464. Hotpoint.prototype.updateBoxDepthPanel = function(){
  1465. var hot = this.editSpot
  1466. if (hot.info.hasBox) {
  1467. this.scroller.boxDepth.setValue(hot.scale.z * 100, true)
  1468. } else {
  1469. this.scroller.boxDepth.setValue(0, true)
  1470. }
  1471. setTimeout(()=>{
  1472. this.scroller.boxDepth.InitOffset()
  1473. }, 201)
  1474. }
  1475. /**
  1476. * 显示编辑热点的窗口和初始化热点窗口的数据
  1477. */
  1478. Hotpoint.prototype.editHot = function(hot, $li) {
  1479. try {
  1480. transformControls.attach(hot)
  1481. if(player.mode == 'panorama'){
  1482. hot.examine( {
  1483. dontOpen: true, examine:true,
  1484. dontFastTran: true,
  1485. aimDuration : 600,
  1486. duration : 600
  1487. })
  1488. }else{
  1489. player.focusPoint({aim: hot.position, radius:hot.position.distanceTo(player.position)})
  1490. }
  1491. } catch (e) {console.log(e)}
  1492. if(this.editSpot == hot)return
  1493. this.hotpointDetail.removeClass("atRight");
  1494. $("#hotpointDetail .audio.mediaUpload").find("input").val('');
  1495. var playIcon = 'images/play.png';
  1496. this.editSpot = hot
  1497. transformControls.transformMenuOptions.updateChoseAtUI({name:'translate'}) //$(".MenuOptions[name='transform'] li[index='translate']").click()//transformControls.transCtlChangeMode("translate")
  1498. this.getTempInfo(hot)
  1499. convertTool.updateVisible(hot,'visi',true)
  1500. this.updatePano()
  1501. this.updateListSelect(hot);
  1502. //$("#isSprite")[0].checked = this.editSpot.info.isSprite
  1503. this.isSpriteCheckBox.updateChoseAtUI(this.editSpot.info.isSprite)
  1504. this.imgDescCheckBox.updateChoseAtUI(this.editSpot.info.useImgDesc)
  1505. this.videoDescCheckBox.updateChoseAtUI(this.editSpot.info.useVideoDesc)
  1506. this.linkTypeMenuOptions.updateChoseAtUI({name:this.editSpot.info.linkType})
  1507. this.autoOpenCheckBox.updateChoseAtUI(this.editSpot.info.autoOpenPanoId == void 0 ? false : true)
  1508. this.updateClickEventUI();//根据actionType更新ui
  1509. $('#hotpointDetail li[name=autoOpen] img[name=btn]').on('click',(e)=>{//定位
  1510. let pano = player.model.panos.index[this.editSpot.info.autoOpenPanoId]
  1511. player.flyToPano({pano})
  1512. })
  1513. var iframesHTML = hot.info.iframe.map(function(iframe) {
  1514. return this.inputList("请填写网页链接", iframe)
  1515. }.bind(this))
  1516. var modulesHTML = hot.info.model.map(function(module) {
  1517. return this.inputList("请填写网页链接", module)
  1518. }.bind(this))
  1519. var imagesHTML = hot.info.images.map(function(image,index) {
  1520. return '<div class="mediaItem" draggable="true" ><a class=" result success" data-type="photo"><span></span><img src="' + image + '" class="bg"><div class="descBtn" ></div></a></div>'
  1521. })
  1522. var videosHTML = hot.info.video.map(function(ly) {
  1523. var thumb = (!ly.img || ly.img === "undefined") ? '' : '<img src='+ ly.img +' class="bg"></img>'
  1524. var thumbResult = (!ly.img || ly.img === "undefined") ? '' : 'success';
  1525. var dom = '<div class="mediaItem" draggable="true"><a class=" result success" data-type="video"><span></span>' + thumb + ' <img class="play-video" videoURL="' + ly.url + '" src="' + playIcon + '"><div class="descBtn" ></div></a> <span class="upload-thum ' + thumbResult + ' result" attr-thum="' + ly.img + '">上传封面<i><input type="file" accept="image/*"></i></span></div>'
  1526. return dom
  1527. })
  1528. this.hotpointDetail.find(".name > input").val(hot.info.title);
  1529. this.hotpointDetail.find('[name="intro"] .editText').val(hot.info.content);
  1530. this.hotpointDetail.find("[name=photo] .list").html(imagesHTML);
  1531. this.hotpointDetail.find("[name=video] .list").html(videosHTML);
  1532. this.hotpointDetail.find("[name=modelSrc] .list").html(modulesHTML);
  1533. this.hotpointDetail.find("[name=webPage] .list").html(iframesHTML);
  1534. Array.from(this.hotpointDetail.find("[name=photo] .list .descBtn")).forEach((btn,index)=>{
  1535. this.descBtnBind(btn, 'photo', this.editSpot.info.imagesDesc[index])
  1536. this.descBtnUpdate(btn,index)
  1537. })
  1538. Array.from(this.hotpointDetail.find("[name=video] .list .descBtn")).forEach((btn,index)=>{
  1539. this.descBtnBind(btn, 'video', this.editSpot.info.videosDesc[index])
  1540. this.descBtnUpdate(btn,index)
  1541. })
  1542. this.descBtnChose(null, 'photo')
  1543. this.descBtnChose(null, 'video')
  1544. let bgName = hot.info.bgName || '热点背景音乐';
  1545. if (hot.info.backgroundMusic) {
  1546. this.musicBox.show(/* this.hotpointDetail.find(".audio.mediaUpload"), */bgName, hot.info.backgroundMusic)
  1547. } else {
  1548. this.musicBox.hide()
  1549. }
  1550. {//跳转方位设置
  1551. var preview = $('#hotpointDetail .shotImg.innerBtn')[0]
  1552. preview.cameraData = hot.info.cameraData
  1553. if(hot.info.cameraData){
  1554. preview.style['background-image'] = "url(" + hot.info.cameraData.thumbImg + ")"
  1555. }else{
  1556. preview.style['background-image'] = ''
  1557. }
  1558. }
  1559. {//标题显示
  1560. this.titleShowOptions.updateChoseAtUI({name:this.editSpot.info.titleShowType})
  1561. this.titlePosOptions.updateChoseAtUI({name:this.editSpot.info.titlePos})
  1562. }
  1563. $('#setPosForPano [name="dis"]').removeClass('hide');
  1564. this.updateDis()
  1565. this.updateTranInput()
  1566. }
  1567. Hotpoint.prototype.updateDis = function(){
  1568. if(!this.editSpot)return
  1569. var pos = this.editSpot.position;
  1570. var playerPos = player.position;
  1571. var dis1 = pos.clone().setY(0).distanceTo(playerPos.clone().setY(0))
  1572. var disY = pos.y - playerPos.y
  1573. var dir = disY>0 ? '上' : '下'
  1574. $('#setPosForPano [name="dis"]').html(`与相机水平距离: ${toPrecision(dis1, 2)}m , <br>在相机之${dir}: ${toPrecision(Math.abs(disY), 2)}m`)
  1575. }
  1576. Hotpoint.prototype.recoverInfo = function(hot) { // 恢復
  1577. hot.info = hot.tempInfo;
  1578. hot.setFromInfo(hot.info, hot.tempInfo.media, hot.tempInfo.objObject)
  1579. delete hot.info.media
  1580. delete hot.info.objObject
  1581. }
  1582. Hotpoint.prototype.getTempInfo = function(hot) { // 编辑前, 从当前状态获取info, 用於恢復
  1583. var plane = hot.plane;
  1584. var info = hot.info;
  1585. hot.tempInfo = CloneObject(info);
  1586. hot.tempInfo.media = hot.texMedia
  1587. hot.tempInfo.objObject = hot.objObject
  1588. this.getTempInfos()
  1589. }
  1590. Hotpoint.prototype.getTempInfos = function(){
  1591. if(Hot.allPhotoLoaded && Hot.allModelLoaded){
  1592. this.tempInfos = {}
  1593. player.model.hotGroup.children.forEach(hot=>{
  1594. this.tempInfos[hot.sid] = {
  1595. styleImg : hot.styleImg,
  1596. texMedia : hot.texMedia,
  1597. objObject : hot.objObject,
  1598. scale : hot.scale.clone()
  1599. }
  1600. })
  1601. }
  1602. }
  1603. Hotpoint.prototype.getTransformAtPano = function(types){
  1604. /* var name = getTransformSid()
  1605. var info = {
  1606. pos : this.editSpot.mesh.position.clone()
  1607. }
  1608. if(!this.editSpot.isSprite){
  1609. info.qua = this.editSpot.mesh.quaternion.clone()
  1610. }else{
  1611. if(type == 'quaternion')return; //如果恒朝向相机且调整的是quaternion,不要保存position
  1612. }
  1613. this.editSpot.transformAtPanos[name] = info */
  1614. //this.editSpot.usingTransformData = true
  1615. var name = getTransformSid()
  1616. let info = {
  1617. pos : this.editSpot.position.clone(),
  1618. scale : this.editSpot.scale.clone()
  1619. }
  1620. hot.isSprite || (info.qua = this.editSpot.quaternion.clone())
  1621. this.editSpot.info.transformAtPanos[name] = info
  1622. }
  1623. Hotpoint.prototype.updateTransform = function(types=['position','quaternion','scale']){
  1624. var on = this.panoTransformCheckBox.checked() //$('#setPosForPano input').is(':checked')
  1625. //var name = getTransformSid()
  1626. if(on ){
  1627. this.getTransformAtPano(types)
  1628. }else{
  1629. if(types.includes('position')){
  1630. this.editSpot.info.position.copy(this.editSpot.position)
  1631. }else if(types.includes('quaternion') || types.includes('rotation') ){
  1632. if(!this.editSpot.isSprite){ //如果恒朝向相机就不保存quaternion
  1633. this.editSpot.info.quaternion.copy(this.editSpot.quaternion)
  1634. }
  1635. }else if(types.includes('scale')){
  1636. this.editSpot.info.scale.copy(this.editSpot.scale)
  1637. }
  1638. }
  1639. this.updateTranInput();
  1640. types.includes('position') && this.updateDis()
  1641. }
  1642. Hotpoint.prototype.updateTranInput = function(){//更新xyz输入
  1643. if(!this.editSpot)return
  1644. let prop = { 'translate' : 'position', 'scale':'scale', 'rotate':'rotation' }[transformControls.mode]
  1645. let inputs = $('.toolRight .hotpoint [name=setPos] .axisValInput input')
  1646. let value = this.editSpot[prop].toArray()
  1647. value.forEach((e,index)=>{
  1648. if(prop == 'rotation'){
  1649. e = THREE.Math.radToDeg(e)
  1650. }
  1651. inputs.eq(index).val(e)
  1652. })
  1653. //console.log('updateTranInput')
  1654. }
  1655. Hotpoint.prototype.updatePano = function(){
  1656. if(!this.editSpot ) return;
  1657. //$('#setPosForPano input').prop('checked', !!this.editSpot.info.transformAtPanos[getTransformSid()]);
  1658. this.panoTransformCheckBox.updateChoseAtUI(!!this.editSpot.info.transformAtPanos[getTransformSid()])
  1659. }
  1660. Hotpoint.prototype.unsaveWarn = async function(done){//如果在编辑某个热点时触发了结束编辑,询问是否保存
  1661. if(this.editSpot){
  1662. var sure = confirm("是否保存当前热点?")
  1663. if(sure){
  1664. await this.saveHot()
  1665. }else{
  1666. this.recoverInfo(this.editSpot)
  1667. }
  1668. done && done()
  1669. }else if(VisiSet.setTagVisible && (VisiSet.tagVsetting && VisiSet.saveLastTagVi({getIfChange:true}) || Object.keys(VisiSet.tagVTemp).length)){//修改过
  1670. var sure = confirm("是否保存已编辑的热点可视?")
  1671. if(sure){
  1672. VisiSet.saveTagVisibles()
  1673. }
  1674. done && done()
  1675. }
  1676. }
  1677. var ifSameTex = function(imgs0, imgs1){//是否是相同的图 (两个都是空的不算相同)
  1678. return !!(imgs0[0] && imgs1[0] && imgs0[0].src == imgs1[0].src &&
  1679. (imgs0[1] ? (imgs1[1] && imgs0[1].src == imgs1[1].src) : !imgs1[1] ))
  1680. }
  1681. Hotpoint.prototype.findSpotByContent = (media, type)=>{////使用了该贴图的所有热点
  1682. var spots = []
  1683. if(type == 'shine'){
  1684. media = media || []
  1685. for(var i in player.model.hots){
  1686. if(player.model.hots[i].texType != type)continue
  1687. var styleImg = player.model.hots[i].styleImg?.length ? player.model.hots[i].styleImg : Object.values(g_HotImage).map(e=>{return {src:e}});
  1688. if(ifSameTex(styleImg, media)){
  1689. spots.push(player.model.hots[i])
  1690. }
  1691. }
  1692. }else if(type == 'photo' || type == 'video'){
  1693. if(type == 'photo' && !Hot.allPhotoLoaded)return spots
  1694. for(var i in player.model.hots){
  1695. if(player.model.hots[i].texType != type)continue
  1696. var texMedia = player.model.hots[i].texMedia
  1697. if(media && texMedia && media.src == texMedia.src){
  1698. spots.push(player.model.hots[i])
  1699. }
  1700. }
  1701. }else if(type == 'model'){
  1702. if(!Hot.allModelLoaded)return spots
  1703. for(var i in player.model.hots){
  1704. if(!player.model.hots[i].objObject)continue
  1705. var objObject = player.model.hots[i].objObject
  1706. if(media && objObject && media.src == objObject.src){
  1707. spots.push(player.model.hots[i])
  1708. }
  1709. }
  1710. }
  1711. return spots
  1712. }
  1713. Hotpoint.prototype.initListSelect = function(){//热点样式图列表
  1714. var that = this;
  1715. var countElem = $("<a class='showCount'></a>")
  1716. var uploadInputImage = $('<input type="file" style="display:none" accept="image/*"></input>');
  1717. var uploadInputVideo = $('<input type="file" style="display:none" accept="video/*"></input>');
  1718. var uploadInputModel = $('<input type="file" style="display:none" accept=".obj,.OBJ"></input>');
  1719. var getListItem = ()=>{
  1720. 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>')
  1721. elem[0]._styleImg = []
  1722. return elem
  1723. }
  1724. var editItemInfo = {}
  1725. var setImgContent = function($dom, index, src) {
  1726. var li = $dom.find('li').eq(index)
  1727. var div = li.find('>div');
  1728. if (src) {
  1729. li.addClass("uploaded")
  1730. div.css("background-image", `url(${src})`)
  1731. } else {
  1732. li.removeClass("uploaded")
  1733. div.css("background-image", '')
  1734. }
  1735. }
  1736. var hotIcons = [ Object.values(g_HotImage)]; // 从所有热点tex中搜集 。 g_HotImage是默认
  1737. player.model.hotGroup.children.forEach(e=>{// 从所有热点tex中搜集
  1738. if(e.texType == 'shine'){
  1739. let imgs = e.info.styleImg;
  1740. if(imgs && imgs.length){
  1741. if(!hotIcons.find(e=>e[0] == imgs[0] && e[1] == imgs[1])){
  1742. hotIcons.push(imgs)
  1743. }
  1744. }
  1745. }
  1746. })
  1747. hotIcons = [...hotIcons.slice(1), hotIcons[0]]//默认的放最后, 这样添加完在列表最前
  1748. hotIcons = hotIcons.map(imgs=>imgs = imgs.map((a)=>{return {src:a}}))
  1749. hotIcons.push( [] )//放末尾用来添加的
  1750. var list = hotIcons.map(arr=>{//初始列表
  1751. var elem = getListItem()
  1752. elem[0]._styleImg = arr //每个li上绑定一个 _styleImg,存储它包含的图, 和热点的styleImg对应
  1753. var divs = elem.find("li>div")
  1754. arr.forEach((img,i)=>{
  1755. setImgContent(elem, i, img.src)
  1756. })
  1757. arr.length && elem.find("li").eq(1).removeClass('hide')
  1758. return elem
  1759. })
  1760. list[0].addClass('forbitEdit') //list[list.length - 2].addClass('forbitEdit')
  1761. this.styleList = new ListBox(list, $('#shineTexSelect'), {//列表
  1762. selectFun:(o={})=>{//选中时要改变选中项selection缩略图 以及改变热点
  1763. if(this.styleList.chosenItem == void 0){
  1764. this.styleList.listTitle.find('li').addClass('hide')
  1765. }else{
  1766. this.styleList.listTitle.find('li').removeClass('hide')
  1767. var divs = this.styleList.listTitle.find('li>div')//selection
  1768. var imgs = this.styleList.chosenItem[0]._styleImg;
  1769. if(imgs[0]){
  1770. divs.eq(0).css("background-image", 'url("'+imgs[0].src+'")')
  1771. divs.eq(0).parent().removeClass('hide')
  1772. }else{
  1773. divs.eq(0).parent().addClass('hide')
  1774. }
  1775. if(imgs[1]){
  1776. divs.eq(1).css("background-image", 'url("'+imgs[1].src+'")')
  1777. divs.eq(1).parent().removeClass('hide')
  1778. }else{
  1779. divs.eq(1).parent().addClass('hide')
  1780. }
  1781. //应用到热点:
  1782. o.dontApplyToHot || this.editSpot.changeShineTex(imgs)
  1783. }
  1784. Array.from(this.styleList.listDom.children()).forEach((li,index)=>{//更新一下所有的li的使用的spot
  1785. if(index == 0)return //第一个是upload
  1786. li.sameContentSpots = this.findSpotByContent(li._styleImg, 'shine')
  1787. })
  1788. },
  1789. /* delFun: ()=>{
  1790. }, */
  1791. addFun: ($li)=>{ //列表新增时对li的操作
  1792. $li[0].sameContentSpots = this.findSpotByContent($li[0]._styleImg, 'shine')
  1793. $li.find('li').bind('click', (e)=>{
  1794. e.stopPropagation()
  1795. var index = $(e.currentTarget).index();
  1796. if($li.hasClass('forbitEdit'))return
  1797. if (e.target.classList.contains("del")) { //删除图片
  1798. if ($li[0]._styleImg.length == 2 && index == 0) { //删除第一个 且有第二个的话
  1799. setImgContent($li, 0, $li[0]._styleImg[1].src);
  1800. setImgContent($li, 1, null);
  1801. $li[0]._styleImg = [$li[0]._styleImg[1]]
  1802. } else {
  1803. setImgContent($li, index, null);
  1804. $li[0]._styleImg.pop()
  1805. if ($li[0]._styleImg.length == 0) {
  1806. //$li.find("li").eq(1).addClass("hide");
  1807. this.styleList.removeItem($li)
  1808. }
  1809. }
  1810. $li[0].sameContentSpots.forEach(hot=>{
  1811. hot.changeShineTex($li[0]._styleImg)
  1812. })
  1813. if($li.hasClass('selected')){//是当前spot的
  1814. //this.editSpot.changeTex($li[0]._styleImg)
  1815. this.styleList.options.selectFun()
  1816. }
  1817. } else {
  1818. //添加图片
  1819. uploadInputImage.click()
  1820. editItemInfo = {
  1821. imgs : $li[0]._styleImg, index, $li , type:"shine"
  1822. };
  1823. }
  1824. })
  1825. $li.bind('mouseover', (e)=>{
  1826. /* this.showTitileSpots = $li[0].sameContentSpots;
  1827. this.showTitileSpots.forEach(a=>a.showTitle()) */
  1828. if($li.index() == 0)return
  1829. countElem.text("热点个数:"+$li[0].sameContentSpots.length).removeClass('hide')
  1830. $li.append(countElem)
  1831. $li[0].sameContentSpots.forEach(hot=>{
  1832. hot.changeBoxHelperDisplay(true,'sameTex')
  1833. })
  1834. })
  1835. $li.bind('mouseout', (e)=>{
  1836. /* this.showTitileSpots.forEach(a=>a.hideTitle())
  1837. this.showTitileSpots = null; */
  1838. countElem.addClass('hide')
  1839. $li[0].sameContentSpots.forEach(hot=>{
  1840. hot.changeBoxHelperDisplay(false,'sameTex')
  1841. })
  1842. })
  1843. },
  1844. saveTemp: (list)=>{//编辑热点时保存一份副本
  1845. list._styleImgTemp = Array.from(list.listDom.children()).map((li)=>{
  1846. return li._styleImg.slice()
  1847. })
  1848. },
  1849. recover : (list)=>{//取消编辑时恢复
  1850. Array.from(list.listDom.children()).forEach((li,i)=>{
  1851. li._styleImg = list._styleImgTemp[i]
  1852. li.sameContentSpots = this.findSpotByContent(li._styleImg, 'shine')
  1853. })
  1854. },
  1855. })
  1856. this.styleList.findChosenByContent = (imgs=[])=>{//找到某图对应的li
  1857. var list = Array.from(this.styleList.listDom.children())
  1858. var item = list.find(e=>ifSameTex(e._styleImg, imgs ))
  1859. return {index: item ? list.indexOf(item) : null, item: item }
  1860. }
  1861. /* this.styleList.clearVoid = ()=>{//清理空的
  1862. var length = this.styleList.listDom.children().length;
  1863. Array.from(this.styleList.listDom.children()).forEach((e, i)=>{
  1864. if(i > 0 ){
  1865. if(e._styleImg.length == 0) this.styleList.removeItem($(e))
  1866. }
  1867. })
  1868. } */
  1869. this.styleList.addNew = ()=>{//看是否在第一行增加新的
  1870. /* var lastOne = this.styleList.listDom.children().last();
  1871. if(lastOne[0]._styleImg.length != 0){
  1872. this.styleList.addItem(getListItem())
  1873. } */
  1874. let firstOne = this.styleList.listDom.children().first();
  1875. if(firstOne[0]._styleImg.length != 0){
  1876. this.styleList.addItem(getListItem())
  1877. }
  1878. }
  1879. //-----photo----video-----------------------
  1880. var getPhotoListItem = ()=>{
  1881. var elem = $('<li><div class="upload"><div></div><a class="del hasHover"></a></div></li>')
  1882. return elem
  1883. }
  1884. var getVideoListItem = ()=>{
  1885. var elem = $('<li><div class="upload"><div></div><a class="del hasHover"></a></div></li>')
  1886. return elem
  1887. }
  1888. var photos = [] ,videos = []
  1889. var photoList = [], videoList = []
  1890. player.model.hotGroup.children.forEach(hot=>{
  1891. if(hot.texType == 'photo'){
  1892. var media = hot.texMedia
  1893. if(!photos.find(u=>media == u)){
  1894. photos.push(media)
  1895. var elem = getPhotoListItem()
  1896. elem[0]._media = media
  1897. elem[0].animateInfo = CloneObject(hot.info.animateInfo)
  1898. elem.find(".upload>div").css("background-image", "url(" + hot.info.texSrc + ")")
  1899. elem.find(".upload").addClass("uploaded")
  1900. photoList.push(elem)
  1901. }else{
  1902. //尽量使用带ani的
  1903. if(hot.info.animateInfo){
  1904. let elem = photoList.find(elem=>elem[0]._media == media)
  1905. if(!elem[0].animateInfo) elem[0].animateInfo = CloneObject(hot.info.animateInfo)
  1906. }
  1907. }
  1908. }else if(hot.texType == 'video'){
  1909. var media = hot.texMedia
  1910. if(!videos.find(u=>media.src == u.src)){ //if(!videos.find(u=>media == u)){
  1911. videos.push(media)
  1912. var elem = getVideoListItem()
  1913. elem[0]._media = media
  1914. elem.attr("title", media.name)
  1915. elem.find(".upload>div").text(media.name)
  1916. elem.find(".upload").addClass("uploaded")
  1917. videoList.push(elem)
  1918. }
  1919. }
  1920. })
  1921. photoList.push(getPhotoListItem())//放末尾用来添加的
  1922. this.photoList = new ListBox(photoList, $('#photoTexSelect'), {//列表
  1923. selectFun:(o={})=>{//选中时要改变选中项selection缩略图 以及改变热点
  1924. var div = this.photoList.listTitle.find('.uploaded')//selection
  1925. var media;
  1926. if(this.photoList.chosenItem){
  1927. media = this.photoList.chosenItem[0]._media;
  1928. }
  1929. if(media){
  1930. div.removeClass('hide')
  1931. div.css("background-image", 'url("'+media.src+'")')
  1932. //应用到热点:
  1933. if(!o.dontApplyToHot){
  1934. this.editSpot.changeTexType("photo", media || 'clear' )
  1935. this.updateGifPanel({animateInfo: this.photoList.chosenItem[0].animateInfo })
  1936. this.useSuitableRatio()
  1937. }else{
  1938. this.updateGifPanel({on: !!this.photoList.chosenItem[0].animateInfo })
  1939. }
  1940. $('#gifEdit').removeClass('hide');
  1941. }else{
  1942. !o.dontApplyToHot && this.editSpot.changeTexType("photo", 'clear' )
  1943. this.updateGifPanel({on:false})
  1944. $('#gifEdit').addClass('hide');
  1945. div.addClass('hide')
  1946. }
  1947. Array.from(this.photoList.listDom.children()).forEach(li=>{//更新一下所有的li的使用的spot
  1948. li.sameContentSpots = this.findSpotByContent(li._media, 'photo')
  1949. })
  1950. },
  1951. addFun: ($li)=>{ //photoList列表新增时对li的操作
  1952. $li[0].sameContentSpots = this.findSpotByContent($li[0]._media, 'photo')
  1953. $li.find('.upload').bind('click', (e)=>{
  1954. e.stopPropagation()
  1955. var index = $(e.currentTarget).index();
  1956. if (e.target.classList.contains("del")) { //删除图片
  1957. /* if($li.hasClass('selected')){//(肯定)是当前spot的
  1958. that.editSpot.changeTexType('photo', 'clear')
  1959. }
  1960. $li[0]._media = null */
  1961. this.photoList.removeItem($li)
  1962. } else {
  1963. //添加图片
  1964. uploadInputImage.click()
  1965. editItemInfo = {
  1966. $li , type:"photo"
  1967. };
  1968. }
  1969. })
  1970. $li.bind('mouseover', (e)=>{
  1971. /* this.showTitileSpots = $li[0].sameContentSpots;
  1972. this.showTitileSpots.forEach(a=>a.showTitle()) */
  1973. countElem.text("热点个数:"+$li[0].sameContentSpots.length).removeClass('hide')
  1974. $li.append(countElem)
  1975. $li[0].sameContentSpots.forEach(hot=>{
  1976. hot.changeBoxHelperDisplay(true,'sameTex')
  1977. })
  1978. })
  1979. $li.bind('mouseout', (e)=>{
  1980. /* this.showTitileSpots.forEach(a=>a.hideTitle())
  1981. this.showTitileSpots = null; */
  1982. countElem.addClass('hide')
  1983. $li[0].sameContentSpots.forEach(hot=>{
  1984. hot.changeBoxHelperDisplay(false,'sameTex')
  1985. })
  1986. })
  1987. },
  1988. saveTemp: (list)=>{//编辑热点时保存一份副本
  1989. list._mediaTemp = Array.from(list.listDom.children()).map((li)=>{
  1990. return li._media
  1991. })
  1992. list._animationTemp = Array.from(list.listDom.children()).map((li)=>{
  1993. return li.animateInfo
  1994. })
  1995. },
  1996. recover : (list)=>{//取消编辑时恢复
  1997. Array.from(list.listDom.children()).forEach((li,i)=>{
  1998. li._media = list._mediaTemp[i]
  1999. li.animateInfo = list._animationTemp[i]
  2000. li.sameContentSpots = this.findSpotByContent(li._media, 'photo')
  2001. })
  2002. },
  2003. })
  2004. this.photoList.addNew = ()=>{//看是否在第一行增加新的
  2005. let firstOne = this.photoList.listDom.children().first();
  2006. if(firstOne[0]._media){
  2007. this.photoList.addItem(getPhotoListItem())
  2008. }
  2009. }
  2010. //---videoList-------
  2011. videoList.push(getVideoListItem())//放末尾用来添加的
  2012. this.videoList = new ListBox(videoList, $('#videoTexSelect'), {//列表
  2013. selectFun:(o={})=>{
  2014. var div = this.videoList.listTitle//selection
  2015. var media;
  2016. if(this.videoList.chosenItem){
  2017. media = this.videoList.chosenItem[0]._media;
  2018. }
  2019. if(media){
  2020. //div.removeClass('hide')
  2021. div.text(media ? media.name : '')
  2022. //应用到热点:
  2023. this.editSpot.info.texSrc = media && media.src //视频不能共用一个,否则会一起播放暂停
  2024. this.editSpot.info.fileName = media.name
  2025. this.editSpot.videoWidth = media.videoWidth //记录。因为新new的话要等一会儿才不为0
  2026. this.editSpot.videoHeight = media.videoHeight
  2027. //media.currentTime = 0 //触发oncanplaythrough
  2028. if(!o.dontApplyToHot){
  2029. this.editSpot.changeTexType("video" , media ? null : 'clear' )
  2030. this.useSuitableRatio()
  2031. }
  2032. }else{
  2033. //div.addClass('hide')
  2034. div.text('')
  2035. if(!o.dontApplyToHot){
  2036. this.editSpot.changeTexType("video" , 'clear' )
  2037. }
  2038. }
  2039. Array.from(this.videoList.listDom.children()).forEach(li=>{//更新一下所有的li的使用的spot
  2040. li.sameContentSpots = this.findSpotByContent(li._media, 'video')
  2041. })
  2042. },
  2043. addFun: ($li)=>{
  2044. $li[0].sameContentSpots = this.findSpotByContent($li[0]._media, 'video')
  2045. $li.find('.upload').bind('click', (e)=>{
  2046. e.stopPropagation()
  2047. var index = $(e.currentTarget).index();
  2048. if (e.target.classList.contains("del")) { //删除
  2049. if($li.hasClass('selected')){//是当前spot的
  2050. that.editSpot.changeTexType('video', 'clear')
  2051. }
  2052. $li[0]._media = null
  2053. this.videoList.removeItem($li)
  2054. } else {
  2055. //添加
  2056. uploadInputVideo.click()
  2057. editItemInfo = {
  2058. $li , type:"video"
  2059. };
  2060. }
  2061. })
  2062. $li.bind('mouseover', (e)=>{
  2063. /* this.showTitileSpots = $li[0].sameContentSpots;
  2064. this.showTitileSpots.forEach(a=>a.showTitle()) */
  2065. countElem.text("热点个数:"+$li[0].sameContentSpots.length).removeClass('hide')
  2066. $li.append(countElem)
  2067. $li[0].sameContentSpots.forEach(hot=>{
  2068. hot.changeBoxHelperDisplay(true,'sameTex')
  2069. })
  2070. })
  2071. $li.bind('mouseout', (e)=>{
  2072. /* this.showTitileSpots.forEach(a=>a.hideTitle())
  2073. this.showTitileSpots = null; */
  2074. countElem.addClass('hide')
  2075. $li[0].sameContentSpots.forEach(hot=>{
  2076. hot.changeBoxHelperDisplay(false,'sameTex')
  2077. })
  2078. })
  2079. },
  2080. saveTemp: (list)=>{//编辑热点时保存一份副本
  2081. list._mediaTemp = Array.from(list.listDom.children()).map((li)=>{
  2082. return li._media
  2083. })
  2084. },
  2085. recover : (list)=>{//取消编辑时恢复
  2086. Array.from(list.listDom.children()).forEach((li,i)=>{
  2087. li._media = list._mediaTemp[i]
  2088. li.sameContentSpots = this.findSpotByContent(li._media, 'video')
  2089. })
  2090. },
  2091. })
  2092. this.videoList.addNew = ()=>{//看是否在第一行增加新的
  2093. let firstOne = this.videoList.listDom.children().first();
  2094. if(firstOne[0]._media){
  2095. this.videoList.addItem(getVideoListItem())
  2096. }
  2097. }
  2098. this.photoList.findChosenByContent = this.videoList.findChosenByContent = (list_, media)=>{//找到某图对应的li
  2099. var list = Array.from(list_.listDom.children())
  2100. var item = list.find(e=>e._media && media && e._media.src == media.src)
  2101. return {index: item ? list.indexOf(item) : null, item: item }
  2102. }
  2103. /* this.photoList.clearVoid = this.videoList.clearVoid = (list_)=>{//清理空的
  2104. var length = list_.listDom.children().length;
  2105. Array.from(list_.listDom.children()).forEach((e, i)=>{
  2106. if(i > 0 ){
  2107. if(!e._media ) list_.removeItem($(e))
  2108. }
  2109. })
  2110. } */
  2111. //----modelList---------------------
  2112. var objSrcs = []
  2113. var modelList = []
  2114. var getModelListItem = ()=>{
  2115. var elem = $('<li><div class="upload"><div></div><a class="del hasHover"></a></div></li>')
  2116. return elem
  2117. }
  2118. player.model.hotGroup.children.forEach(e=>{
  2119. if(e.info.objSrc && !objSrcs.find(u=>e.info.objSrc == u)){
  2120. objSrcs.push(e.info.objSrc)
  2121. var elem = getModelListItem()
  2122. elem[0].objObject = e.objObject
  2123. elem.attr("title", e.info.objName)
  2124. elem.find(".upload>div").text(e.info.objName)
  2125. elem.find(".upload").addClass("uploaded")
  2126. modelList.push(elem)
  2127. }
  2128. })
  2129. modelList.push(getModelListItem())//放末尾用来添加的
  2130. this.modelList = new ListBox(modelList, $('#ObjSelect'), {//列表
  2131. selectFun:(o={})=>{
  2132. var div = this.modelList.listTitle//selection
  2133. var model;
  2134. if(this.modelList.chosenItem){
  2135. model = this.modelList.chosenItem[0].objObject;
  2136. }
  2137. if(model){
  2138. //div.removeClass('hide')
  2139. div.text(model ? model.name : '')
  2140. //应用到热点:
  2141. if(!o.dontApplyToHot){
  2142. this.switchModel({add:model,spot:this.editSpot})
  2143. }
  2144. }else{
  2145. //div.addClass('hide')
  2146. div.text('')
  2147. this.switchModel({remove:true,spot:this.editSpot})
  2148. }
  2149. Array.from(this.modelList.listDom.children()).forEach(li=>{//更新一下所有的li的使用的spot
  2150. li.sameContentSpots = this.findSpotByContent(li.objObject, 'model')
  2151. })
  2152. },
  2153. addFun: ($li)=>{
  2154. $li[0].sameContentSpots = this.findSpotByContent($li[0].objObject, 'model')
  2155. $li.find('.upload').bind('click', (e)=>{
  2156. e.stopPropagation()
  2157. var index = $(e.currentTarget).index();
  2158. if (e.target.classList.contains("del")) { //删除
  2159. $li[0].sameContentSpots.forEach(e=>{
  2160. /* e.removeModel() */
  2161. that.switchModel({remove:true, spot:e})
  2162. })
  2163. if($li.hasClass('selected')){//是当前spot的 ui..
  2164. }
  2165. $li[0].objObject = null
  2166. this.modelList.removeItem($li)
  2167. } else {
  2168. //添加
  2169. uploadInputModel.click()
  2170. editItemInfo = {
  2171. $li , type:"model"
  2172. };
  2173. }
  2174. })
  2175. $li.bind('mouseover', (e)=>{
  2176. /* this.showTitileSpots = $li[0].sameContentSpots;
  2177. this.showTitileSpots.forEach(a=>a.showTitle()) */
  2178. countElem.text("热点个数:"+$li[0].sameContentSpots.length).removeClass('hide')
  2179. $li.append(countElem)
  2180. $li[0].sameContentSpots.forEach(hot=>{
  2181. hot.changeBoxHelperDisplay(true,'sameModel')
  2182. })
  2183. })
  2184. $li.bind('mouseout', (e)=>{
  2185. /* this.showTitileSpots.forEach(a=>a.hideTitle())
  2186. this.showTitileSpots = null; */
  2187. countElem.addClass('hide')
  2188. $li[0].sameContentSpots.forEach(hot=>{
  2189. hot.changeBoxHelperDisplay(false,'sameModel')
  2190. })
  2191. })
  2192. },
  2193. saveTemp: (list)=>{//编辑热点时保存一份副本
  2194. list._objTemp = Array.from(list.listDom.children()).map((li)=>{
  2195. return li.objObject
  2196. })
  2197. },
  2198. recover : (list)=>{//取消编辑时恢复
  2199. Array.from(list.listDom.children()).forEach((li,i)=>{
  2200. li.objObject = list._objTemp[i];
  2201. li.sameContentSpots = this.findSpotByContent(li.objObject, 'model')
  2202. })
  2203. },
  2204. })
  2205. this.modelList.addNew = ()=>{//看是否在第一行增加新的
  2206. let firstOne = this.modelList.listDom.children().first();
  2207. if(firstOne[0].objObject){
  2208. this.modelList.addItem(getModelListItem())
  2209. }
  2210. }
  2211. this.modelList.findChosenByContent = (objObject)=>{
  2212. var list = Array.from(this.modelList.listDom.children())
  2213. var item = list.find(e=>e.objObject && e.objObject.src == objObject.src)
  2214. return {index: item ? list.indexOf(item) : null, item: item }
  2215. }
  2216. this.photoList.updateDelBtns = this.videoList.updateDelBtns = (list_)=>{//每次开始编辑热点时更新删除按钮可见性
  2217. Array.from(list_.listDom.children()).forEach(li=>{
  2218. //li.sameContentSpots = this.findSpotByContent(li._media, 'photo')
  2219. if(li.sameContentSpots.find(e=>e!=this.editSpot)){
  2220. $(li).addClass('cannotDelete')
  2221. }else{
  2222. $(li).removeClass('cannotDelete')
  2223. }
  2224. })
  2225. }
  2226. //-----------------------------------
  2227. uploadInputImage.on("change", (e)=>{
  2228. inputMedia({
  2229. enableTypes: ["photo"],
  2230. photoDone: (resultImg)=>{
  2231. if(editItemInfo.type == 'shine'){
  2232. editItemInfo.imgs[editItemInfo.index] = resultImg //{file: resultImg.file, needSave:true, src:resultImg.src}//resultImg
  2233. setImgContent(editItemInfo.$li, editItemInfo.index, resultImg.src)
  2234. if (editItemInfo.index == 0){
  2235. editItemInfo.$li.find('li').eq(1).removeClass("hide");
  2236. }
  2237. resultImg.needSave = true
  2238. editItemInfo.$li[0].sameContentSpots.forEach(hot=>{
  2239. hot.changeShineTex(editItemInfo.$li[0]._styleImg)
  2240. })
  2241. }else{//"photo"
  2242. editItemInfo.$li.find(".upload").addClass("uploaded")
  2243. editItemInfo.$li.find(".upload div").css("background-image", `url(${resultImg.src})`)
  2244. editItemInfo.$li[0]._media = resultImg
  2245. editItemInfo.$li[0].sameContentSpots.forEach(hot=>{
  2246. hot.changeTexType("photo",resultImg)
  2247. })
  2248. resultImg.needSave = true
  2249. }
  2250. /* if(editItemInfo.$li.hasClass('selected')){//是当前spot的
  2251. this.texLists[editItemInfo.type].options.selectFun({dontApplyToHot:true})//更新选中状态
  2252. } */
  2253. this.texLists[editItemInfo.type].addNew()
  2254. this.texLists[editItemInfo.type].selectFromOutSide(editItemInfo.$li.index())
  2255. this.texLists[editItemInfo.type].listDom.addClass('hide')
  2256. }
  2257. }, "photo", e);
  2258. })
  2259. uploadInputVideo.on("change", (e)=>{
  2260. inputMedia({
  2261. enableTypes: ["video"],
  2262. videoDone: (file,video)=>{
  2263. editItemInfo.$li.find(".upload").addClass("uploaded")
  2264. editItemInfo.$li.find(".upload>div").text(file.name)
  2265. editItemInfo.$li.attr("title", file.name)
  2266. video.file = file
  2267. video.name = file.name
  2268. video.needSave = true
  2269. editItemInfo.$li[0]._media = video
  2270. editItemInfo.$li[0].sameContentSpots.forEach(hot=>{
  2271. hot.info.texSrc = video.src //视频不能共用一个,否则会一起播放暂停
  2272. hot.info.fileName = video.name
  2273. hot.videoWidth = video.videoWidth //记录。因为新new的话要等一会儿才不为0
  2274. hot.videoHeight = video.videoHeight
  2275. hot.changeTexType("video" )
  2276. })
  2277. /* if(editItemInfo.$li.hasClass('selected')){//是当前spot的
  2278. this.videoList.options.selectFun({dontApplyToHot:true})//更新选中状态
  2279. } */
  2280. this.videoList.addNew()
  2281. this.videoList.selectFromOutSide(editItemInfo.$li.index())
  2282. }
  2283. }, "video", e);
  2284. })
  2285. uploadInputModel.on("change", (e)=>{
  2286. inputMedia({
  2287. enableTypes: ["model"],
  2288. modelDone: (file,object)=>{
  2289. editItemInfo.$li.find(".upload").addClass("uploaded")
  2290. editItemInfo.$li.find(".upload>div").text(file.name)
  2291. editItemInfo.$li.attr("title", file.name)
  2292. object.file = file
  2293. object.name = file.name
  2294. object.src = object.uuid;//作为标识而已
  2295. object.needSave = true
  2296. {//adjustModelAuto
  2297. let bound = new THREE.Box3
  2298. object.traverse( function ( child ) {
  2299. if(child.geometry){//会不会有child自带了一层matrix呢?如果有要乘以matrix。
  2300. child.geometry.computeBoundingBox();
  2301. //bound.union(child.geometry.boundingBox)
  2302. //potree是这么写的:bound.union(child.geometry.boundingBox.clone().applyMatrix4(child.matrixWorld)) //但感觉如果最外层object大小不为1,要还原下scale再乘
  2303. bound.union(child.geometry.boundingBox.clone().applyMatrix4(child.matrixWorld)) //2025.1.21改
  2304. }
  2305. });
  2306. let standard = 1;
  2307. let size = bound.max.distanceTo(bound.min);
  2308. let s = standard / size
  2309. object.scale.set(s,s,s)
  2310. let center = bound.center()
  2311. object.position.copy(center).negate().multiplyScalar(s)//保证模型的中心点和hot中心点重合
  2312. object.modelBound = {
  2313. bound,
  2314. scaleRatio : s,
  2315. position: object.position.toArray()
  2316. }
  2317. }
  2318. editItemInfo.$li[0].objObject = object
  2319. editItemInfo.$li[0].sameContentSpots.forEach(hot=>{
  2320. //hot.addModel(object)
  2321. this.switchModel({add:object, spot:hot})
  2322. })
  2323. this.modelList.selectFromOutSide(editItemInfo.$li.index())
  2324. /* if(editItemInfo.$li.hasClass('selected')){//是当前spot的
  2325. this.modelList.options.selectFun({dontApplyToHot:true})//更新选中状态
  2326. } */
  2327. this.modelList.addNew()
  2328. }
  2329. }, "model", e);
  2330. })
  2331. this.texLists = {shine: this.styleList, photo:this.photoList, video: this.videoList}
  2332. this.texTypeMenuOptions = new MenuOptions({
  2333. dom: this.hotpointDetail.find(" li[name=style] .MenuOptions"),
  2334. uiCallBack : (o)=>{
  2335. var name = o.name == void 0 ? o.$li.attr('index') : o.name
  2336. for(let i in this.texLists){ this.texLists[i].listDom.parent().addClass("hide")}
  2337. this.texLists[name].listDom.parent().removeClass("hide")
  2338. if(name == 'photo'){
  2339. $('#gifEdit').removeClass('hide')
  2340. }else{
  2341. $('#gifEdit').addClass('hide')
  2342. this.updateGifPanel({on:false})
  2343. }
  2344. },
  2345. callbackWhenChose:(o)=>{
  2346. this.changeType( o.$li.attr('index'))
  2347. }
  2348. })
  2349. //编辑开放
  2350. this.hotpointDetail.find(" li[name=style]").removeClass('unable');
  2351. this.hotpointDetail.find(" li[name=model]").removeClass('unable');
  2352. this.hotpointDetail.find(" li[name=style] .itemTitle").attr('data-size','')
  2353. if(this.editSpot){//已经在编辑了,初始化下
  2354. this.updateListSelect(this.editSpot)
  2355. this.getTempInfos()
  2356. }
  2357. this.hotpointDetail.find(" li[name=setPos] button[name=setSpace] ").on('click',(e)=>{
  2358. var space = transformControls.space == 'world'?'local':'world'
  2359. transformControls.setSpace(space)
  2360. e.target.innerText = space == 'world'?'切换为世界坐标方向':'切换为本地坐标方向'
  2361. })
  2362. this.hotpointDetail.find(" li[name=setPos] button[name=useSuitableRatio] ").on('click',()=>{
  2363. this.useSuitableRatio()
  2364. })
  2365. /* this.hotpointDetail.find(" li[name=setPos] button[name=resetRot] ").on('click',()=>{
  2366. this.editSpot.rotation.x = 0
  2367. this.editSpot.rotation.z = 0
  2368. }) */
  2369. }
  2370. Hotpoint.prototype.switchModel = function(o={}){
  2371. if(o.add){
  2372. if(!$("#remainModelScale")[0].checked || o.spot.plane){//恢复成等大比例,方便用户看清原始比例,否则可能拉伸严重. 但有时换obj后不想重新设置大小可以勾选保持大小。
  2373. var s = 1; //从热点转过来一定恢复比例
  2374. o.spot.scale.set(s,s,s)
  2375. o.spot.info.scale.set(s,s,s)
  2376. }
  2377. var model = o.add.clone();
  2378. o.spot.info.objSrc = o.add.src
  2379. o.spot.info.objName = o.add.name
  2380. o.spot.info.modelBound = o.add.modelBound;
  2381. o.spot.addModel(model)
  2382. if(o.spot == this.editSpot){
  2383. transformControls.enableScaleZ()
  2384. }
  2385. }else if(o.remove){
  2386. //如果没有出现plane,很可能是因为背面朝向镜头了!
  2387. o.spot.addPlane()
  2388. if(o.spot == this.editSpot) transformControls.unableScaleZ()
  2389. }
  2390. }
  2391. Hotpoint.prototype.changeType = function(type){
  2392. var hot = this.editSpot
  2393. var list
  2394. this._scale[hot.texType] = hot.scale.clone()
  2395. if(type == 'shine'){
  2396. hot.changeTexType(type, 'clear')
  2397. if(hot.styleImg){
  2398. hot.changeTexType(type, hot.styleImg )
  2399. }
  2400. list = this.styleList
  2401. list.selectFromOutSide(list.chosenIndex || 1)//触发选择函数
  2402. }else{
  2403. hot.changeTexType(type,'clear')
  2404. if(type == 'photo'){
  2405. list = this.photoList
  2406. }else{
  2407. list = this.videoList
  2408. }
  2409. list.selectFromOutSide(list.chosenIndex)
  2410. }
  2411. this.useSuitableRatio({setScaleAuto:true})
  2412. hot.info.actionType = CloneObject(settings.hotClickEvent[type]);//给一个默认 图和视频不打开热点
  2413. /* if(type == 'video'){
  2414. hot.info.actionType.playAndPause = true;
  2415. }else{
  2416. delete hot.info.actionType.playAndPause
  2417. } */
  2418. if(type != 'video'){
  2419. delete hot.info.fileName
  2420. }
  2421. this.updateClickEventUI();//根据actionType更新ui
  2422. }
  2423. Hotpoint.prototype.updateGifPanel = function(o={}){
  2424. var hot = this.editSpot
  2425. if(!hot.material_.map)return;
  2426. let a = o.animateInfo || hot.info.animateInfo
  2427. //换图时根据图片的animation更改开关,如果有的话还要更改面板,如果图没有animation用自己的
  2428. if(o.animateInfo){//更换animateInfo
  2429. hot.info.animateInfo = CloneObject(o.animateInfo);
  2430. }
  2431. if("animateInfo" in o ){
  2432. o.on = !!o.animateInfo
  2433. }
  2434. if(!a){
  2435. o.on = false
  2436. }
  2437. if(o.on != void 0){
  2438. this.gifCheckBox.updateChoseAtUI(o.on)
  2439. GifTexDeal.remove(hot.animation)
  2440. if(o.on){
  2441. hot.animation = GifTexDeal.addAnimation(hot.material_.map, hot, hot.info.animateInfo, hot.sid)
  2442. GifTexDeal.start(hot.animation)
  2443. }else{
  2444. hot.animation = null
  2445. hot.info.animateInfo = null
  2446. }
  2447. }
  2448. let w = hot.material_.map.image.width
  2449. let h = hot.material_.map.image.height
  2450. if(a){
  2451. $("#gifXCount").val(a.cellXcount);
  2452. $("#gifYCount").val(a.cellYcount);
  2453. $("#gifImgWidth").text(w)
  2454. $("#gifImgHeight").text(h)
  2455. $("#gifCellWidth").text(toPrecision(w / a.cellXcount, 2));
  2456. $("#gifCellHeight").text(toPrecision(h / a.cellYcount, 2));
  2457. $("#voidCount").val(a.voidCount || 0);
  2458. let frameCount = a.cellXcount * a.cellYcount - (a.voidCount || 0)
  2459. $("#gifFrameCount").text(frameCount)
  2460. $("#gifDuration").val(toPrecision(a.duration / 1000, 2));
  2461. $("#gifFps").val(toPrecision(frameCount / a.duration * 1000, 1) );
  2462. }else{
  2463. $("#gifXCount").val(1);
  2464. $("#gifYCount").val(1);
  2465. $("#gifImgWidth").text(w)
  2466. $("#gifImgHeight").text(h)
  2467. $("#gifCellWidth").text(w);
  2468. $("#gifCellHeight").text(h)
  2469. $("#voidCount").val(0);
  2470. $("#gifFrameCount").text(1)
  2471. $("#gifDuration").val(1);
  2472. $("#gifFps").val(1);
  2473. }
  2474. }
  2475. Hotpoint.prototype.updateListSelect = function(hot) { //每次开始编辑热点时更新样式
  2476. if(!Hot.allPhotoLoaded || !Hot.allModelLoaded)return
  2477. var list = this.texLists[hot.texType];
  2478. var chosenIndex = null;
  2479. this.texTypeMenuOptions.updateChoseAtUI({name:hot.texType})
  2480. for(let i in this.texLists){
  2481. //this.texLists[i].clearVoid(this.texLists[i]);
  2482. this.texLists[i].saveTemp(this.texLists[i])
  2483. }
  2484. this.modelList.saveTemp()
  2485. if(hot.texType == 'shine'){
  2486. if (!hot.styleImg) hot.styleImg = [];
  2487. if(hot.styleImg.length){
  2488. var info = this.styleList.findChosenByContent(hot.styleImg)
  2489. chosenIndex = info.index
  2490. }
  2491. }else{
  2492. var info = list.findChosenByContent(list, hot.texMedia)
  2493. chosenIndex = info.index
  2494. }
  2495. list.selectFromOutSide(chosenIndex, {dontApplyToHot:true})
  2496. this.photoList.updateDelBtns(this.photoList)
  2497. this.videoList.updateDelBtns(this.videoList)
  2498. {//model
  2499. let hasModel = !!hot.objObject
  2500. this.modelMenuOptions.updateChoseAtUI({name: hasModel ? 'user' : 'default'})
  2501. if(hasModel){
  2502. var info = this.modelList.findChosenByContent(hot.objObject)
  2503. this.modelList.selectFromOutSide(info.index, {dontApplyToHot:true})
  2504. transformControls.enableScaleZ()
  2505. }
  2506. }
  2507. }
  2508. Hotpoint.prototype.useSuitableRatio = function(o={}) {//自适应素材比例
  2509. var hot = this.editSpot
  2510. var plane = this.editSpot.plane;
  2511. var w, h, defaultS = 1, s, mediaW, mediaH
  2512. if(this._scale[hot.texType] && o.setScaleAuto){
  2513. w = this._scale[hot.texType].x; h = this._scale[hot.texType].y;
  2514. }else{
  2515. if(hot.texType == 'shine'){//默认使用热点大小,正方形
  2516. if(o.setScaleAuto){
  2517. w = h = 1 //DATA.hotIconScale * g_HotMeshSize.g_HotMeshWidth
  2518. }else{
  2519. s = hot.scale.x * hot.scale.y
  2520. w = h = Math.sqrt(Math.abs(s))
  2521. }
  2522. }else{
  2523. if(!hot.texMedia)return
  2524. //假设不变总面积
  2525. if(o.setScaleAuto){
  2526. s = defaultS
  2527. }else{
  2528. s = hot.scale.x * hot.scale.y
  2529. }
  2530. /* if(hot.texType == 'photo'){
  2531. mediaW = hot.texMedia.width;
  2532. mediaH = hot.texMedia.height;
  2533. //动画的话再变
  2534. if(hot.info.animateInfo){
  2535. mediaW /= hot.info.animateInfo.cellXcount
  2536. mediaH /= hot.info.animateInfo.cellYcount
  2537. }
  2538. }else{
  2539. mediaW = hot.texMedia.videoWidth || hot.videoWidth || 1;
  2540. mediaH = hot.texMedia.videoHeight || hot.videoHeight || 1;
  2541. } */
  2542. let size = hot.getMediaSize()
  2543. if(size.x == 0){
  2544. mediaW = mediaH = 1
  2545. }else{
  2546. mediaW = size.x; mediaH = size.y;
  2547. }
  2548. var k = Math.sqrt(Math.abs(s) / (mediaW * mediaH))
  2549. w = k * mediaW * (hot.scale.x < 0 ? -1 : 1);
  2550. h = k * mediaH * (hot.scale.y < 0 ? -1 : 1);
  2551. }
  2552. }
  2553. hot.scale.setX(w)
  2554. hot.scale.setY(h)
  2555. if(hot.isUserModel){
  2556. hot.scale.setZ(z)
  2557. }
  2558. this.updateTransform('scale')
  2559. },
  2560. Hotpoint.prototype.updateClickEventUI = function() {//根据actionType更新ui
  2561. var hot = this.editSpot;
  2562. /* var checkboxs = this.hotpointDetail.find("li[name='clickEvent'] li.editCheckbox");
  2563. checkboxs.addClass('hide');
  2564. for(let i in hot.info.actionType){
  2565. var checkbox = checkboxs.find('[name='+ i +']')
  2566. checkbox.parent().removeClass('hide');
  2567. checkbox[0].checked = !!hot.info.actionType[i]
  2568. }
  2569. var content = this.hotpointDetail.find("li[name='content']")
  2570. hot.info.actionType.openHot ? content.removeClass('hide') : content.addClass('hide') */
  2571. /* for(let i in hot.info.actionType){
  2572. this.actionCheckBox.updateChoseAtUI(hot.info.actionType[i], i)
  2573. } */
  2574. settings.hotClickActions.forEach(e=>{
  2575. this.actionCheckBox.updateChoseAtUI(hot.info.actionType[e], e)
  2576. })
  2577. }
  2578. //添加图片和视频
  2579. Hotpoint.prototype.addmediaInit = function() {
  2580. // 视频预览控制
  2581. var $videoLayout = $('.fun-view-video')
  2582. var that = this
  2583. $videoLayout.find('span').on('click', function() {
  2584. $videoLayout.hide();
  2585. $videoLayout.find('video').attr('src', '')[0].pause()
  2586. });
  2587. // 图片加载回调
  2588. function imageSuccess(file) {
  2589. if (!/image\/\w+/.test(file.type)) {
  2590. alert("文件必须为图片!");
  2591. return false;
  2592. }
  2593. if (!restrictedSize(file, 9)) {
  2594. return false;
  2595. }
  2596. var img = new Image()
  2597. img.src = URL.createObjectURL(file);
  2598. img.className = 'bg'
  2599. return img
  2600. }
  2601. // 视频加载回调
  2602. function videoSuccess(file, $elayout) {
  2603. if (!/video\/\w+/.test(file.type)) {
  2604. alert("视频必须为map4格式!");
  2605. return false;
  2606. }
  2607. $elayout.append('<span class="upload-thum">上传封面<i><input type="file" accept="image/*"></i></span>')
  2608. return '<img src="./images/play.png" class="play-video" videoURL="' + URL.createObjectURL(file) + '">'
  2609. }
  2610. // 视频封面回调
  2611. function thumbSuccess(file, $elayout, $seft) {
  2612. if (!/image\/\w+/.test(file.type)) {
  2613. alert("文件必须为图片!");
  2614. return false;
  2615. }
  2616. if (!restrictedSize(file, 2)) {
  2617. return false;
  2618. }
  2619. var img = $seft.closest('div').find('img.bg');
  2620. if(!img[0]){
  2621. img = $("<img class='bg'></img>");
  2622. $seft.closest('div').find('a').append(img)
  2623. }
  2624. img.attr('src', URL.createObjectURL(file));
  2625. $seft.closest('span').removeClass("success")
  2626. }
  2627. // 图片与视频加载
  2628. function fileHandle(that) {
  2629. var $seft = $(this) //input
  2630. var file = this.files[0];
  2631. var type = this.activeElem ? this.activeElem.attr('data-type') : $seft.parent().attr('data-type');
  2632. var $din = $('<div class="mediaItem" draggable="true"></div>')
  2633. var fnc = type === 'photo' ? imageSuccess : type === 'video' ? videoSuccess : thumbSuccess //再次传都会是thumSuccess
  2634. var $dom = fnc(file, $din, $seft)
  2635. if (type === 'photo' || type === 'video') {
  2636. if (!$dom)
  2637. return $seft.val('');
  2638. if(!this.activeElem){//创建新的item
  2639. var $layout = $seft.closest("li");
  2640. var $addLayout = $(document.createElement('a'));
  2641. $addLayout.attr("data-type", type)
  2642. var $close = $(document.createElement('span'));
  2643. $addLayout[0].file = file;
  2644. $addLayout.append($close);
  2645. $addLayout.append($dom);
  2646. $addLayout.addClass("result");
  2647. $din.prepend($addLayout);
  2648. $layout.find('.edit-fun-images').append($din);
  2649. var $btn = $('<div class="descBtn">添加描述</div>')
  2650. $addLayout.append($btn)
  2651. that.descBtnBind($btn[0], type)
  2652. }else{//重传
  2653. if (type === 'photo'){
  2654. this.activeElem.find("img.bg").remove();
  2655. }else{
  2656. this.activeElem.find(".play-video").remove();
  2657. }
  2658. this.activeElem.removeClass("success")
  2659. this.activeElem.append($dom)
  2660. this.activeElem[0].file = file;
  2661. this.value = ''
  2662. }
  2663. }
  2664. if (searchParent($seft[0], {
  2665. id: 'shareImgUpload'
  2666. })) {
  2667. //信息页面的分享图片
  2668. $("#shareImgUpload").addClass("hide")
  2669. }else if(searchParent($seft[0], {
  2670. id: 'SpotStyle'
  2671. })){
  2672. $("#SpotStyle").addClass("hide")
  2673. }
  2674. }
  2675. //用于重传的input
  2676. var imgInput = $("<input accept='image/*' type='file'></input>")
  2677. var videoInput = $("<input accept='video/*' type='file'></input>")
  2678. // 图片与视频加载
  2679. $('.upload, .edit-fun-images').on('change', function(ev) {
  2680. if (ev.target.tagName.toUpperCase() === 'INPUT') {
  2681. ev.target.files.length && fileHandle.call(ev.target, that)
  2682. }
  2683. })
  2684. imgInput.on('change', (ev)=>{fileHandle.call(ev.target, that)})
  2685. videoInput.on('change', (ev)=>{fileHandle.call(ev.target, that)})
  2686. $('.edit-fun-images').on('click', function(ev) {//点击item时
  2687. var $tag = $(ev.target)
  2688. var tagName = ev.target.tagName.toUpperCase()
  2689. if (tagName === 'SPAN') {
  2690. if (searchParent($tag[0], {
  2691. className: 'forShareImg'
  2692. })) {
  2693. //信息页面的分享图片
  2694. $("#shareImgUpload").removeClass('hide')
  2695. }else if(searchParent($tag[0], {
  2696. className: 'SpotStyle'
  2697. })){
  2698. $("#SpotStyle").removeClass('hide')
  2699. }
  2700. $tag.parent().parent().remove()
  2701. }else if (tagName === 'IMG' && $tag.hasClass('play-video')) {
  2702. $videoLayout.css('display', 'flex').find('video').attr('src', $tag.attr('videoURL'))[0].play()
  2703. }else{// 替换
  2704. if($tag.hasClass('descBtn'))return
  2705. var a = searchParent($tag[0], {
  2706. tagName: 'a'
  2707. })
  2708. if(a) {
  2709. var input
  2710. if(searchParent($tag[0], {
  2711. className: 'video'
  2712. })){
  2713. input = videoInput
  2714. }else{
  2715. input = imgInput
  2716. }
  2717. input[0].activeElem = $(a)
  2718. input.click()
  2719. }
  2720. }
  2721. })
  2722. }
  2723. Hotpoint.prototype.descBtnUpdate = function(btn){//图片描述按钮状态更新
  2724. var $btn = $(btn)
  2725. /* if(index == void 0){
  2726. var btns = Array.from(this.hotpointDetail.find("[name=photo] .list .descBtn"))
  2727. index = btns.indexOf(btn)
  2728. } */
  2729. var desc = btn.desc
  2730. if(desc == void 0 || desc === ''){
  2731. $btn.removeClass('hasDesc')
  2732. $btn.text('添加描述')
  2733. }else{
  2734. $btn.addClass('hasDesc')
  2735. $btn.text('查看描述')
  2736. }
  2737. }
  2738. Hotpoint.prototype.descBtnBind = function(btn, type, desc ){//单个图片or视频描述按钮事件
  2739. //console.log('descBtnBind',btn)
  2740. var textarea = this.hotpointDetail.find(`li[name="${type}"] textarea`);
  2741. var title = this.hotpointDetail.find(`li[name="${type}"] [name="descTitle"]`)
  2742. btn.addEventListener('click',(e)=>{
  2743. this.hotpointDetail.find(`[name=${type}] .list .descBtn`).removeClass('chosen')
  2744. $(btn).addClass('chosen');
  2745. textarea.removeClass('hide')
  2746. title.removeClass('hide')
  2747. /* textarea.val(btn.desc)
  2748. textarea[0].currentBtn = btn */
  2749. this.descBtnChose(btn, type)
  2750. e.preventDefault()
  2751. e.stopPropagation()
  2752. })
  2753. btn.desc = desc || ''
  2754. }
  2755. Hotpoint.prototype.descBtnChose = function(btn, type){
  2756. var textarea = this.hotpointDetail.find(`li[name="${type}"] textarea`);
  2757. textarea[0].currentBtn = btn
  2758. textarea.val(btn ? btn.desc : '');
  2759. }
  2760. //当前处于的状态,比如是否是添加热点的状态
  2761. /* Hotpoint.prototype.state = function(that, Hot) {
  2762. if (g_HotStatus === "add") {
  2763. //console.log(Hot)
  2764. this.addHot(that, Hot, (hot)=>{
  2765. this.addHotList(hot);
  2766. } );
  2767. }
  2768. } */
  2769. Hotpoint.prototype.updateNumDisplay = function() {
  2770. this.spotList.find("i").text(this.spotList.find("ul li").length);
  2771. }
  2772. //删除热点
  2773. Hotpoint.prototype.removeHot = function(hot ) {
  2774. //hot.dispose();
  2775. hot.dispose()
  2776. hot.$li.remove();
  2777. this.updateNumDisplay()
  2778. }
  2779. //添加热点模型
  2780. Hotpoint.prototype.addHot = function(that) {
  2781. if (!player.intersect || !g_HotStatus) return;// 没有正确的热点位置, return
  2782. var sid = getRandomSid()
  2783. var s = g_HotStatus == 'shine' ? Hot.getDefaulScale() : 1
  2784. var hot = new Hot({
  2785. sid,
  2786. texType : g_HotStatus,
  2787. position : player.intersect.point.clone() ,
  2788. rotation : [0,0,0],
  2789. scale: new THREE.Vector3(s,s,0.02),
  2790. actionType : CloneObject(settings.hotClickEvent[g_HotStatus]),
  2791. titlePos: this.latestTitlePos,
  2792. titleShowType: this.latestTitleShowType,
  2793. });
  2794. hot.photoHasRequestLoad = hot.modelHasRequestLoad = true;//防止requestDownload
  2795. player.model.hots[sid] = hot;
  2796. hot.hasRequestLoad = true
  2797. hot.isNew = true
  2798. if (player.getMouseDirection().angleTo(player.intersect.face.normal) < Math.PI / 2) {
  2799. hot.lookAt(player.intersect.face.normal.clone().negate().add(player.intersect.point));
  2800. hot.position.add(player.intersect.face.normal.clone().negate().multiplyScalar(0.01)) //avoid mesh crash with chunks 模型的精度可能和floorplan的不一样,所以chunk即使材质经过处理还是会闪烁但是wallmesh不会
  2801. } else {
  2802. hot.lookAt(player.intersect.face.normal.clone().add(player.intersect.point));
  2803. hot.position.add(player.intersect.face.normal.clone().multiplyScalar(0.01))
  2804. }
  2805. g_HotStatus = false;
  2806. player.mouseCouldBeClickToMove = false;
  2807. //$("#player").css("cursor", "");
  2808. CursorDeal.remove('addHot' )
  2809. CursorDeal.remove('noIntersect' )
  2810. this.addHotList(hot)
  2811. this.editHot(hot)
  2812. this.updateTransform('position');
  2813. this.updateTransform('quaternion');
  2814. }
  2815. //添加热点列表
  2816. Hotpoint.prototype.addHotList = function(hot) {
  2817. var li = $("<li class='listItem' draggable='true' data-spid=" + hot.sid + "><div class='icon'></div>" + /* "<div class=number>" + (++_hotNum) + "</div>" + */ "<div class=title >" + ( hot.info.title ) + "</div>" + "<div class=DelConfirm title='删除'>确定删除</div>" + "<div class=del></div>" + "</li>");
  2818. li.hot = hot
  2819. hot.$li = li
  2820. this.setListLi(hot)
  2821. $(".spotList ul").append(li);
  2822. li.on("mouseover",()=>{
  2823. hot.changeBoxHelperDisplay(true)
  2824. })
  2825. li.on("mouseout",()=>{
  2826. hot.changeBoxHelperDisplay(false)
  2827. })
  2828. this.updateNumDisplay()
  2829. }
  2830. Hotpoint.prototype.setListLi = function(hot){ //暂时用文字展示,最好有图标来表示包含gif和模型
  2831. var name = '';
  2832. if(hot.info.title) name = hot.info.title
  2833. else{
  2834. if(hot.info.objSrc)name = '包含模型的'
  2835. if(hot.texType == 'photo' && hot.info.animateInfo)name+= 'gif'
  2836. else name += (hot.texType == 'shine' ? '热点' : hot.texType == 'photo' ? '图片' : '视频' )
  2837. }
  2838. hot.$li.find(".title").html(name);
  2839. hot.$li.find('.icon').attr("type",hot.texType)
  2840. hot.$li.attr("title", hot.info.title) //显示没显示完的标题
  2841. }
  2842. //添加热点模型列表dom
  2843. Hotpoint.prototype.inputList = function(text, val) {
  2844. var _val = '';
  2845. if (arguments[1]) {
  2846. _val = 'value=' + val;
  2847. }
  2848. return '<div class="link"> <input class="text" type="text" placeholder=' + text + ' spellcheck="false" ' + _val + ' > </div>'
  2849. }
  2850. //添加热点模型
  2851. Hotpoint.prototype.addModel = function() {
  2852. var text = this.inputList("请填写模型链接(https开头)");
  2853. this.hotpointDetail.find("[name=modelSrc] .add").on('click', function() {
  2854. $(this).closest("[name=modelSrc] ").find(".list").append(text)
  2855. });
  2856. this.hotpointDetail.find("[name=modelSrc] .delete").on('click', function() {
  2857. $(this).closest("[name=modelSrc] ").find(".list > div:last").remove();
  2858. });
  2859. }
  2860. //添加网页链接
  2861. Hotpoint.prototype.addwebPack = function() {
  2862. var text = this.inputList("请填写网页链接", "");
  2863. this.hotpointDetail.find("[name=webPage] .add").on('click', function() {
  2864. $(this).closest("[name=webPage]").find(".list").append(text)
  2865. });
  2866. this.hotpointDetail.find("[name=webPage] .delete").on('click', function() {
  2867. $(this).closest("[name=webPage]").find(".list > div:last").remove();
  2868. });
  2869. }
  2870. Hotpoint.prototype.editDone = function(){
  2871. var hot = this.editSpot
  2872. this.editSpot = null;
  2873. hot.isNew = false;
  2874. transformControls.detach()
  2875. this.hotpointDetail.addClass("atRight");
  2876. $('#hotpointDetail .shotImg.innerBtn')[0].cameraData = null
  2877. this.setCameraBtn(false)
  2878. this.imgDescCheckBox.updateChoseAtUI(false)
  2879. this.videoDescCheckBox.updateChoseAtUI(false)
  2880. $('#setPosForPano [name="dis"]').addClass('hide');
  2881. }
  2882. // 保存热点信息
  2883. Hotpoint.prototype.saveHot = async function() {
  2884. var $layout = $(".edit-loading");
  2885. var hotpointDetail = this.hotpointDetail;
  2886. var that = this
  2887. var hot = this.editSpot
  2888. if (hot.texType == "video" && !hot.texMedia ) {
  2889. alert("请添加视频")
  2890. return;
  2891. }else if(hot.texType == 'photo' && !hot.texMedia){
  2892. alert("请添加图片")
  2893. return;
  2894. }
  2895. //显示loading
  2896. $layout.removeClass('hide');
  2897. var args = hot.info//{};
  2898. //热点标题
  2899. var $title = hotpointDetail.find("[name=info] input");
  2900. //热点内容
  2901. var $content = hotpointDetail.find("[name=intro] textarea");
  2902. //热点图片
  2903. var $images = hotpointDetail.find("[name=content] [name=photo] .edit-fun-images a.result");
  2904. //热点视频
  2905. var $videos = hotpointDetail.find("[name=content] [name=video] .edit-fun-images a.result");
  2906. //热点视频的图片
  2907. var $thums = hotpointDetail.find("[name=content] [name=video] .edit-fun-images .upload-thum");
  2908. //热点模型
  2909. var $modules = hotpointDetail.find("[name=content] [name=modelSrc] input");
  2910. //热点内嵌网页
  2911. var $iframes = hotpointDetail.find("[name=content] [name=webPage] input.text");
  2912. //热点音乐
  2913. var $miusc = hotpointDetail.find("[name=content] #upload-hotBgm");
  2914. var promise = new Promise(function(resolve, reject) {
  2915. //获取图片路径
  2916. upload($images, 'images', resolve)
  2917. }).then(function(imgUrls) {
  2918. $layout.removeClass('hide');
  2919. args.images = imgUrls
  2920. //获取视频路径
  2921. return new Promise(function(resolve, reject) {
  2922. upload($videos, 'videos', resolve)
  2923. } )
  2924. }).then(function(videoUrls) {
  2925. $layout.removeClass('hide');
  2926. args.video = videoUrls
  2927. //获取视频封面路径
  2928. return new Promise(function(resolve, reject) {
  2929. upload($thums, 'images', resolve)
  2930. }
  2931. )
  2932. }).then(function(thums) {
  2933. $layout.removeClass('hide');
  2934. args.video = args.video.map(function(video, index) {//整合视频+封面
  2935. return {
  2936. url: video,
  2937. img: thums[index]
  2938. }
  2939. })
  2940. }).then(function() {
  2941. //获取热点音乐所有的路径
  2942. //console.log($miusc)
  2943. $layout.removeClass('hide');
  2944. if ($miusc[0].files.length > 0) {
  2945. return new Promise(function(resolve) {
  2946. upload($miusc, 'miusc', function(res) {
  2947. resolve(res[0])
  2948. })
  2949. })
  2950. } else {
  2951. return $miusc.attr('data-hotBgm')
  2952. }
  2953. }).then(function(src) {
  2954. if(that.musicBox.hasMusic && !src){
  2955. args.backgroundMusic = hot.info.backgroundMusic
  2956. args.bgName = hot.info.bgName
  2957. }else{
  2958. args.backgroundMusic = src
  2959. args.bgName = that.musicBox.getName()
  2960. }
  2961. }).then(function() { //上传所有热点的tex file
  2962. var a = $.Deferred();
  2963. var doneNum = 0;
  2964. var filesNeedSave = [];
  2965. var liNeedSave = [], liNeedSave2 = []
  2966. $layout.removeClass('hide');
  2967. Array.from(that.styleList.listDom.children()).forEach(li=>{
  2968. if(li.sameContentSpots.length == 0)return;//没被热点用到就不保存
  2969. //li.sameContentSpots.forEach(spot=>spot.styleImg = li._styleImg)//提前同步下 等下就都是线上链接了
  2970. li._styleImg.forEach(img=>{
  2971. if(img.needSave && !filesNeedSave.includes(img)){
  2972. filesNeedSave.push(img)
  2973. liNeedSave.includes(li) || liNeedSave.push(li)
  2974. }
  2975. })
  2976. });
  2977. [that.photoList, that.videoList].forEach(list=>{
  2978. Array.from(list.listDom.children()).forEach(li=>{
  2979. if(li.sameContentSpots.length == 0)return;//没被热点用到就不保存
  2980. //li.sameContentSpots.forEach(spot=>spot.texMedia.src = li._media.src)//同步下 video不能同步,只能同步src
  2981. li._media.needSave && (filesNeedSave.push(li._media), liNeedSave.push(li))
  2982. })
  2983. })
  2984. Array.from(that.modelList.listDom.children()).forEach(li=>{
  2985. if(li.sameContentSpots.length == 0)return;//没被热点用到就不保存
  2986. li.objObject.needSave && (filesNeedSave.push(li.objObject), liNeedSave2.push(li))
  2987. })
  2988. if(filesNeedSave.length){
  2989. filesNeedSave.forEach(o=>{
  2990. uploadFile(o.file, 'hot', function(rs) {
  2991. if (rs.code === 0) {
  2992. o.needSave = false;
  2993. //o.saveURL = rs.data;
  2994. o.src = rs.data;
  2995. if (++doneNum >= filesNeedSave.length) {
  2996. a.resolve();
  2997. liNeedSave.forEach(li=>{//将blob更换成线上链接
  2998. li.sameContentSpots.forEach((spot)=>{
  2999. if(spot.texType == 'shine'){
  3000. spot.info.styleImg = li._styleImg.map(img=>img.src)
  3001. }else{
  3002. spot.info.texSrc = li._media.src
  3003. spot.texMedia.src = li._media.src
  3004. }
  3005. })
  3006. })
  3007. liNeedSave2.forEach(li=>{//将blob更换成线上链接
  3008. li.sameContentSpots.forEach((spot)=>{
  3009. spot.info.objSrc = spot.objObject.src = li.objObject.src
  3010. })
  3011. })
  3012. }
  3013. } else {
  3014. alert("文件上传失败");
  3015. a.reject();
  3016. }
  3017. })
  3018. })
  3019. return a.promise()
  3020. }else{
  3021. return a.resolve()
  3022. }
  3023. }).then(function() {
  3024. $layout.removeClass('hide');
  3025. //获取热点标题、内容、内嵌网页、模型网页。
  3026. args.title = $title.val()
  3027. args.content = $content.val()
  3028. var iframes = []
  3029. for (var i = 0; i < $iframes.length; i++) {
  3030. var iframe = $iframes.eq(i).val()
  3031. iframe && iframes.push(iframe)
  3032. }
  3033. args.iframe = iframes
  3034. var modules = [] //热点打开后展示的文物模型
  3035. for (var i = 0; i < $modules.length; i++) {
  3036. var module = $modules.eq(i).val()
  3037. module && modules.push(module)
  3038. }
  3039. args.model = modules
  3040. /* if(!hot.isSprite){
  3041. args.quaternion = hot.quaternion.clone()
  3042. //hot.quaternion.copy(hot.mesh.quaternion)
  3043. }
  3044. args.position = hot.position.clone()
  3045. //hot.position.copy(hot.mesh.position) */
  3046. hot.info.texType = hot.texType
  3047. if(that.ifNeedResetVisi(hot)){
  3048. hot.getVisiblePanos();
  3049. }
  3050. if(hot.texType == 'photo'){//保存时绑定animateInfo到li
  3051. let info = that.photoList.findChosenByContent(that.photoList, hot.texMedia);
  3052. info.item.animateInfo = CloneObject(hot.info.animateInfo)
  3053. }
  3054. if(that.actionCheckBox.checked('fastTran')){
  3055. hot.info.cameraData = $('#hotpointDetail .shotImg.innerBtn')[0].cameraData //快速跳转方位
  3056. }else{
  3057. delete hot.info.cameraData
  3058. }
  3059. hot.info.imagesDesc = Array.from(that.hotpointDetail.find("[name=photo] .list .descBtn")).map(btn=>btn.desc)
  3060. hot.info.videosDesc = Array.from(that.hotpointDetail.find("[name=video] .list .descBtn")).map(btn=>btn.desc)
  3061. //hot.setTitleElem()//更新名称
  3062. that.setListLi(hot);
  3063. $layout.addClass('hide');
  3064. console.log(args);
  3065. that.editDone()
  3066. that._scale[hot.texType] = hot.scale.clone()
  3067. return new Promise(function(resolve, reject) {
  3068. resolve()
  3069. })
  3070. })
  3071. return promise
  3072. }
  3073. Hotpoint.prototype.ifNeedResetVisi = function(hot){//修改过贴图或位置或模型,导致这几个数值改变,就要重新计算可见性(会覆盖用户设置)
  3074. var need = !ifSame({
  3075. hasBox: hot.tempInfo.hasBox,
  3076. position: hot.tempInfo.position,
  3077. quaternion: hot.tempInfo.quaternion,
  3078. scale: hot.tempInfo.scale,
  3079. transformAtPanos: hot.tempInfo.transformAtPanos,
  3080. modelBound:hot.tempInfo.modelBound
  3081. }, {
  3082. hasBox: hot.info.hasBox,
  3083. position: hot.info.position,
  3084. quaternion: hot.info.quaternion,
  3085. scale: hot.info.scale,
  3086. transformAtPanos: hot.info.transformAtPanos,
  3087. modelBound:hot.info.modelBound
  3088. })
  3089. return need
  3090. }
  3091. Hotpoint.prototype.getSavingInfo = function(){//保存全部
  3092. var hots = {} // 热点数据
  3093. /* var shineHots = player.model.hotGroup.children.filter(e=>e.texType == 'shine')
  3094. var photoHots = player.model.hotGroup.children.filter(e=>e.texType == 'photo')
  3095. var videoHots = player.model.hotGroup.children.filter(e=>e.texType == 'video')
  3096. shineHots.concat(photoHots).concat(videoHots).forEach((hot,index)=>{ */
  3097. //按列表顺序存储
  3098. Array.from(this.spotList.find('li.listItem')).forEach((li,index)=>{
  3099. var sid = $(li).attr("data-spid");
  3100. var hot = player.model.hots[sid]
  3101. var hotData = CloneObject(hot.info)
  3102. for(let i in hotData){
  3103. if(hotData[i] == void 0 )delete hotData[i]
  3104. }
  3105. if(hotData.texSrc){
  3106. hotData.texSrc = manage.removeSrcPostMark(hotData.texSrc)
  3107. }
  3108. hotData.position = toPrecision(hot.info.position.toArray(), 3)
  3109. hotData.scale = toPrecision(hot.info.scale.toArray(), 3)
  3110. hotData.rotation = toPrecision(new THREE.Euler().setFromQuaternion(hot.info.quaternion).toArray().slice(0,3), 4)
  3111. hotData.order = index
  3112. hotData.transformAtPanos = {}
  3113. for(let i in hot.info.transformAtPanos){
  3114. hotData.transformAtPanos[i] = {
  3115. pos : toPrecision(hot.info.transformAtPanos[i].pos.toArray(), 4),
  3116. }
  3117. if(hot.info.transformAtPanos[i].qua){
  3118. hotData.transformAtPanos[i].qua = toPrecision(hot.info.transformAtPanos[i].qua.toArray(), 5)
  3119. }
  3120. if(hot.info.transformAtPanos[i].scale){
  3121. hotData.transformAtPanos[i].scale = toPrecision(hot.info.transformAtPanos[i].scale.toArray(), 4)
  3122. }
  3123. }
  3124. hotData.version = 'multi'
  3125. if(hotData.animateInfo && hotData.animateInfo.cellXcount * hotData.animateInfo.cellYcount - (hotData.animateInfo.voidCount || 0)<=1){
  3126. delete hotData.animateInfo
  3127. }
  3128. hotData.model = hotData.model.length ? hotData.model : ''
  3129. hotData.images = hotData.images.length ? hotData.images : ''
  3130. hotData.video = hotData.video.length ? hotData.video : ''
  3131. hotData.iframe = hotData.iframe.length ? hotData.iframe : ''
  3132. hots[hot.sid] = hotData
  3133. })
  3134. return hots
  3135. }
  3136. //背景音乐
  3137. var EditBGM = function() {
  3138. this.mediaUpload = $(".music [name=background].mediaUpload");
  3139. this.musicBox = musicPlayBoxBind(this.mediaUpload, (file)=>{
  3140. uploadMusic(file, (rs, file)=>{
  3141. if (rs.code === 0) {
  3142. this.musicBox.show( file.name, rs.data)
  3143. }else{
  3144. this.musicBox.hide()
  3145. }
  3146. })
  3147. }, null)
  3148. let areaUpload = $(".music [name=prop] .mediaUpload");
  3149. this.areaBGMBox = musicPlayBoxBind(areaUpload, (file)=>{
  3150. uploadMusic(file, (rs, file)=>{
  3151. if (rs.code === 0) {
  3152. this.areaBGMBox.show( file.name, rs.data)
  3153. }else{
  3154. this.areaBGMBox.hide()
  3155. }
  3156. })
  3157. }, null)
  3158. }
  3159. EditBGM.prototype.init = function(data) {
  3160. if ( data.backgroundMusic){
  3161. this.musicBox.show( data.bgName || "backgound", data.backgroundMusic);
  3162. }
  3163. VisiSet.curAreaIndex = 0 //删除区域后数字不改,直到刷新后清空
  3164. VisiSet.panoAreas = data.panoAreas ? CloneObject(data.panoAreas) : []
  3165. VisiSet.panoAreas.forEach((area,i)=>{
  3166. VisiSet.addAreaToList(area)
  3167. area.panos = area.panos.map(e=>{
  3168. let pano = player.model.panos.get(e)
  3169. pano.panoArea = area
  3170. return pano
  3171. })
  3172. })
  3173. //点击列表弹出按钮
  3174. $('.toolRight .music [name="list"]>ul').on("click", (e)=>{
  3175. var target = $(e.target);
  3176. let li = searchParent(e.target, { className: 'listItem' }, 7);
  3177. if(!li)return;
  3178. let area = li.area
  3179. if (target.hasClass("del")) {
  3180. e.stopPropagation();
  3181. target.siblings(".DelConfirm").addClass("active");
  3182. } else {
  3183. if (target.hasClass("DelConfirm")) {
  3184. e.stopPropagation();
  3185. VisiSet.deletePanoArea(area);
  3186. }else{
  3187. VisiSet.switchPanoArea(area,true) //开始编辑
  3188. }
  3189. }
  3190. });
  3191. $(".toolRight .music [name='list'] button").on('click',()=>{ //设置区域
  3192. VisiSet.createPanoArea()
  3193. })
  3194. $('.toolRight .music [name="list"] input[type="text"]').on('input',(e)=>{//标题
  3195. VisiSet.editPanoArea.$li.find('.title').text(e.target.value)
  3196. })
  3197. }
  3198. //导览编辑
  3199. var EditGuide = function() {
  3200. this.$list = $('#guide-list')
  3201. //$('#tourItemEdit') = $('#tourItemEdit');
  3202. this.targetTourPoint = null;
  3203. // fyz 记录当前编辑的导览点
  3204. // fyz 导览音乐队列
  3205. //this.tourAudio = {};
  3206. }
  3207. /**
  3208. * @author fyz 2019.07.31
  3209. * @description 新增参数data2, 表示data2.js中的数据
  3210. */
  3211. EditGuide.prototype.snapATourView = function(renew, insideFolder){
  3212. var ev = document.createEvent("MouseEvent");
  3213. ev.initMouseEvent("snapshotBegin", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  3214. g_snapShotWidth = 200;
  3215. g_snapShotHeight = 140;
  3216. //window.screenSta = 'tour';
  3217. // 记录当前哪个功能截屏, 因为导览截屏需要做额外的校对调整, 初始画面截屏不需要
  3218. ev.__callback = (imgData, info)=> {
  3219. this.uploadGuide(imgData, info, renew, insideFolder)
  3220. };
  3221. window.dispatchEvent(ev);
  3222. }
  3223. EditGuide.prototype.init = function(data, data2) {
  3224. this.createDom(data, data2);
  3225. //this.tourAudio = data2.tourAudio || {};
  3226. var that = this;
  3227. //点击添加导览
  3228. $('.addTour .innerBtn').eq(0).on("click", function () {
  3229. this.addFolderDom({name:"区域"+($("#tourList .listItem").length+1) } );//点击增加一段导览
  3230. $("#tourList ul")[0].scrollTop = $("#tourList ul")[0].scrollHeight //scroll to bottom
  3231. }.bind(this));
  3232. $('.addTour .innerBtn').eq(1).on("click", function () {
  3233. this.snapATourView()//点击截取视图
  3234. $("#tourList ul")[0].scrollTop = $("#tourList ul")[0].scrollHeight
  3235. }.bind(this));
  3236. $('.snapATourView .innerBtn').on("click", function() {
  3237. this.snapATourView(null,true);//folder内点击截取视图
  3238. $("#tourItemList ul")[0].scrollTop = $("#tourItemList ul")[0].scrollHeight
  3239. }.bind(this));
  3240. $('#renewTourBtn').on("click", function() { // 重新截取视图
  3241. this.snapATourView(this, !!this.editingFolderLi);
  3242. }.bind(this));
  3243. // 确认并保存导览信息
  3244. $('#tourFolderEdit .tail .submit').on("click", function() {
  3245. this.completeFolder();
  3246. }.bind(this));
  3247. $('#tourItemEdit .tail .submit').on("click", function() {
  3248. this.completeItem();
  3249. }.bind(this));
  3250. //点击导览编辑窗口右上角的关闭按钮
  3251. $("#tourItemEdit a.close, #tourItemEdit .tail .cancel").on("click", ()=>{
  3252. /* that.targetTourPoint[0].musicSta = true; ///??????????
  3253. // 取消操作, 重置状态
  3254. that.tourDetail.addClass("atRight"); */
  3255. this.cancelItem()
  3256. });
  3257. $("#tourFolderEdit a.close, #tourFolderEdit .tail .cancel").on("click", ()=>{
  3258. /* that.targetTourPoint[0].musicSta = true; ///??????????
  3259. // 取消操作, 重置状态
  3260. that.tourDetail.addClass("atRight"); */
  3261. this.cancelFolder()
  3262. });
  3263. //导览目录
  3264. $("#tourList").on("click", function(e) {
  3265. var target = $(e.target);
  3266. let folder = searchParent(e.target, { className: 'listItem' }, 7);
  3267. if(!folder)return;//可能点到了item
  3268. if (target.hasClass("del")) {
  3269. e.stopPropagation();
  3270. target.siblings(".DelConfirm").addClass("active");
  3271. } else {
  3272. if (target.hasClass("DelConfirm")) {
  3273. e.stopPropagation();
  3274. $(folder).remove()
  3275. //that.removeFolder(folder);//删除
  3276. } else {
  3277. if (target.hasClass("title") || target.hasClass("icon")) {
  3278. that.editFolder(folder)//编辑
  3279. }
  3280. }
  3281. }
  3282. });
  3283. //编辑item
  3284. $('.tourList ul').on('click', function(e) {
  3285. var target = $(e.target);
  3286. let itemDom = searchParent(e.target, { className: 'guideItem' }, 7);
  3287. if(!itemDom)return;//可能点到了folder
  3288. if(searchParent(e.target, { className: 'preview' })){
  3289. var choice = confirm("你确定删除吗?");
  3290. if (choice) {
  3291. var ul = searchParent(e.target, { className: 'tourList' })
  3292. target.closest('li').remove();
  3293. reIndexTourList(ul)
  3294. } else {
  3295. return false
  3296. }
  3297. }else{
  3298. that.editItem(itemDom);
  3299. }
  3300. })
  3301. //音乐
  3302. this.musicBoxFolder = musicPlayBoxBind($("#tourFolderEdit .mediaUpload"), null, ()=>{
  3303. (that.editingFolderLi || that.editingItemLi).tourData.musicInfo = {}//直接删除 不可逆
  3304. })
  3305. this.musicBoxItem = musicPlayBoxBind($("#tourItemEdit .mediaUpload"), null, ()=>{
  3306. (that.editingFolderLi || that.editingItemLi).tourData.musicInfo = {}//直接删除 不可逆
  3307. })
  3308. this.momentFolderMenuOptions = new MenuOptions({ //链接打开方式切换
  3309. dom: $(" #folderTourSwitch ")
  3310. })
  3311. this.momentMenuOptions = new MenuOptions({ //链接打开方式切换
  3312. dom: $(" #tourSwitch_Slice ")
  3313. })
  3314. this.rotCheckBox = new CheckBox({dom: $('#tourItemEdit [name="rotSwitch"] input') ,
  3315. uiCallBack : (checked )=>{
  3316. },
  3317. callbackWhenChose:(checked )=>{
  3318. this.editingItemLi.tourData.dontRot = checked ? 0 : 1
  3319. }
  3320. })
  3321. {
  3322. let ui = $('#tourItemEdit [name="rotTime"] input')
  3323. let min = parseFloat(ui.attr('min'));
  3324. let max = parseFloat(ui.attr('max'));
  3325. ui.on("change", function(e) {
  3326. var s = THREE.Math.clamp(parseFloat(e.target.value), min, max)
  3327. if(isNaN(s))s = ''
  3328. e.target.value = s
  3329. that.editingItemLi.tourData.rotTime = s
  3330. })
  3331. }
  3332. {////////////////
  3333. let ui = $('.toolRight .snapTour [name="rotTime"] input')
  3334. let min = parseFloat(ui.attr('min'));
  3335. let max = parseFloat(ui.attr('max'));
  3336. ui.on("change", function(e) {
  3337. var s = THREE.Math.clamp(parseFloat(e.target.value), min, max)
  3338. if(isNaN(s))s = ''
  3339. e.target.value = s
  3340. })
  3341. ui.val(DATA.tourRotTime)
  3342. }
  3343. {
  3344. this.scroller = {
  3345. tourBlackSpeed : new SlideBar({
  3346. root: $('#tourBlackSpeed').eq(0),
  3347. value: 100,
  3348. min: 10,
  3349. max: 1000,
  3350. name: "tourBlackSpeed",
  3351. unitStr: "%",
  3352. onchange: (s)=>{
  3353. },
  3354. dragEndEvent: function() {
  3355. }
  3356. }),
  3357. tourWalkSpeed : new SlideBar({
  3358. root: $('#tourWalkSpeed').eq(0),
  3359. value: 100,
  3360. min: 10,
  3361. max: 1000,
  3362. name: "tourWalkSpeed",
  3363. unitStr: "%",
  3364. onchange: (s)=>{
  3365. },
  3366. dragEndEvent: function() {
  3367. }
  3368. })
  3369. }
  3370. var tourBlackSpeed = window.DATA.tourBlackSpeed;
  3371. if(tourBlackSpeed == void 0){
  3372. tourBlackSpeed = 100
  3373. }
  3374. var tourWalkSpeed = window.DATA.tourWalkSpeed;
  3375. if(tourWalkSpeed == void 0){
  3376. tourWalkSpeed = 100
  3377. }
  3378. this.scroller.tourBlackSpeed.setValue(tourBlackSpeed, true)
  3379. this.scroller.tourWalkSpeed.setValue(tourWalkSpeed, true)
  3380. }
  3381. }
  3382. function reIndexTourList(ul) {
  3383. Array.from($(ul).find('li.guideItem')).forEach((li,index)=>{
  3384. $(li).find("div:first-child span").text(index + 1);
  3385. })
  3386. }
  3387. EditGuide.prototype.addFolderDom = function( tourData){
  3388. 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>");
  3389. $folder[0].tourItemDoms = [] //记录所有item的li dom
  3390. $folder[0].tourData = tourData //注: data中的locations不会更新,保存时直接读取li
  3391. $("#tourList ul").append($folder);
  3392. return $folder
  3393. }
  3394. EditGuide.prototype.getItemDom = function(title, img) {
  3395. 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 >';
  3396. }
  3397. EditGuide.prototype.createDom = function(data, data2) {
  3398. var that = this;
  3399. var tourAudio = data2.tourAudio || {};
  3400. data.model.images.forEach((Info,index)=>{
  3401. if(Info.locations){//是folder
  3402. var $folder = this.addFolderDom(Info)
  3403. // 音频链接
  3404. Info.locations = Info.locations.filter(e=>e)
  3405. Info.locations.forEach(function(info, index) {
  3406. if (info.thumbnail_signed_src) {
  3407. info.thumbnail_signed_src = manage.dealURL(info.thumbnail_signed_src) //旧场景有的少了https://
  3408. var $li = $(that.getItemDom( info.name, info.thumbnail_signed_src));
  3409. $li[0].tourData = info
  3410. $folder[0].tourItemDoms.push($li[0])
  3411. }
  3412. })
  3413. }else{//是散落在外的item
  3414. if (Info.thumbnail_signed_src) {
  3415. Info.thumbnail_signed_src = manage.dealURL(Info.thumbnail_signed_src)
  3416. var $li = $(that.getItemDom(Info.name, Info.thumbnail_signed_src));
  3417. $li[0].tourData = Info
  3418. // 音频链接
  3419. $li[0].tourData.musicInfo = $li[0].tourData.musicInfo || tourAudio[Info.sid] || {}//新的music数据统一写在每个info下
  3420. $("#tourList ul").append($li)
  3421. }
  3422. }
  3423. })
  3424. reIndexTourList($("#tourList")[0])
  3425. }
  3426. EditGuide.prototype.editFolder = function(folderDom){
  3427. this.editingFolderLi = folderDom;
  3428. this.editingFolderLi.tempData = CloneObject(folderDom.tourData);
  3429. $("#tourFolderEdit").removeClass('atRight');
  3430. $("#tourFolderEdit .tourName input").val( $(folderDom).find('.title').text()||'');
  3431. var momentTour = folderDom.tourData.momentTour || "default"
  3432. this.momentFolderMenuOptions.updateChoseAtUI({name:momentTour})
  3433. folderDom.tourItemDoms.forEach(li=>{
  3434. $("#tourItemList>ul").append(li)
  3435. })
  3436. reIndexTourList($("#tourItemList>ul")[0])
  3437. //判断当前点是否有导览音频
  3438. var musicInfo = this.editingFolderLi.tourData.musicInfo //audio ? audio.music : null;
  3439. if (musicInfo && musicInfo.music) { // 判断改导览点是否已经已有音乐
  3440. var musicName = musicInfo.name || '导览音频.mp3' // 获取音频的文件名
  3441. this.musicBoxFolder.show( musicName, "//" + musicInfo.music)
  3442. } else {
  3443. this.musicBoxFolder.hide()
  3444. }
  3445. }
  3446. EditGuide.prototype.editItem = function(li) {
  3447. this.editingItemLi = li
  3448. this.editingItemLi.tempData = CloneObject(li.tourData);
  3449. // 记录当前编辑的导览点
  3450. var that = this;
  3451. $('#tourItemEdit').removeClass('atRight');
  3452. $('#tourItemEdit .tourName input').val( $(li).find('.guide-name').text() );
  3453. $('#tourItemEdit [name="rotTime"] input').val(parseFloat(li.tourData.rotTime))
  3454. var momentTour = li.tourData.momentTour || "default"
  3455. /* $("#tourSwitch_Slice li").removeClass('chosen')
  3456. $("#tourSwitch_Slice li[index="+ momentTour +"]").addClass('chosen'); */
  3457. this.momentMenuOptions.updateChoseAtUI({name:momentTour})
  3458. this.rotCheckBox.updateChoseAtUI(!li.tourData.dontRot)
  3459. var metadata = JSON.parse(li.tourData.metadata);
  3460. if(metadata.scan_id != 'outside'){
  3461. var pano = player.model.panos.index[metadata.scan_id]
  3462. if(pano){
  3463. var q = new THREE.Quaternion().copy(metadata.camera_quaternion);
  3464. player.flyToPano({
  3465. pano: pano,
  3466. quaternion: q,
  3467. zoomLevel: metadata.zoom
  3468. })
  3469. }
  3470. }
  3471. if(!this.editingFolderLi){//在外的item, 可以上传音乐
  3472. $('#tourItemEdit .mediaUpload').removeClass('hide')
  3473. var musicInfo = li.tourData.musicInfo //audio ? audio.music : null;
  3474. if (musicInfo && musicInfo.music) { // 判断改导览点是否已经已有音乐
  3475. var musicName = musicInfo.name || '导览音频.mp3' // 获取音频的文件名
  3476. this.musicBoxItem.show( musicName, "//" + musicInfo.music)
  3477. } else {
  3478. this.musicBoxItem.hide()
  3479. }
  3480. }else{
  3481. $('#tourItemEdit .mediaUpload').addClass('hide')
  3482. }
  3483. }
  3484. EditGuide.prototype.completeFolder = function(){//点击完成
  3485. var tourName = $('#tourFolderEdit .tourName input').val() //|| this.targetTourPoint.context.innerText;
  3486. $(this.editingFolderLi).find(".title").text(tourName)
  3487. //this.editingFolderLi.tourData.momentTour = $("#folderTourSwitch input").is(':checked') ? "black" : 'walk'
  3488. var momentTour = this.momentFolderMenuOptions.getSelectName()//$("#folderTourSwitch li.chosen").attr("index");
  3489. this.editingFolderLi.tourData.momentTour = momentTour != 'default' ? momentTour : null;
  3490. this.editingFolderLi.tourData.name = tourName
  3491. this.editingFolderLi.tourItemDoms = Array.from($('#tourItemList ul li'));
  3492. var done = ()=>{
  3493. //$("#tourFolderEdit .mediaUpload").find("input").val(''); // 清空 文件
  3494. this.musicBoxFolder.hide()// 清空 文件
  3495. this.editingFolderLi = null
  3496. $("#tourFolderEdit").addClass('atRight');
  3497. $(".edit-loading").addClass('hide');
  3498. $("#tourItemList>ul").html('')
  3499. }
  3500. //save导览音乐
  3501. var musicFile = this.musicBoxFolder.getFile()
  3502. if (musicFile) { //有input文件
  3503. $(".edit-loading").removeClass('hide');
  3504. var musicName = this.musicBoxFolder.getName()
  3505. new Promise( (resolve, reject)=> {
  3506. uploadMusic(musicFile, function(res) {
  3507. resolve(res.data);
  3508. })
  3509. } ).then( (src)=>{
  3510. $(".edit-loading").removeClass('hide'); //上传完继续显示loading
  3511. var audio = new Audio();
  3512. audio.src = src;
  3513. audio.onloadedmetadata = ()=>{
  3514. var srcArr = src.split('/'); // 对返回的src进行处理, 去掉前面域名, 尽量避免修改main.js
  3515. srcArr[0] = '';
  3516. src = srcArr.join('/');
  3517. this.editingFolderLi.tourData.musicInfo = {
  3518. "name": musicName,
  3519. "music": '/' + src,
  3520. "time": Math.round(audio.duration * 1000 + 1000)
  3521. }
  3522. done()
  3523. }
  3524. })
  3525. }else done()
  3526. }
  3527. EditGuide.prototype.completeItem = function() {//点击完成
  3528. var done = ()=>{
  3529. this.musicBoxItem.hide()// 清空 文件
  3530. this.editingItemLi = null
  3531. $("#tourItemEdit").addClass('atRight');
  3532. $(".edit-loading").addClass('hide');
  3533. }
  3534. var tourName = $('#tourItemEdit .tourName input').val()
  3535. $(this.editingItemLi).find('.guide-name').text(tourName)
  3536. var momentTour = this.momentMenuOptions.getSelectName()
  3537. this.editingItemLi.tourData.momentTour = momentTour != 'default' ? momentTour : null;
  3538. this.editingItemLi.tourData.name = tourName
  3539. //save导览音乐
  3540. var musicFile = this.musicBoxItem.getFile()
  3541. if (!this.editingFolderLi && musicFile) { //有input文件
  3542. $(".edit-loading").removeClass('hide');
  3543. var musicName = this.musicBoxItem.getName() //$('#tourItemEdit .mediaUpload .title').text();
  3544. new Promise( (resolve, reject)=>{
  3545. uploadMusic(musicFile, function(res) {
  3546. resolve(res.data);
  3547. })
  3548. } ).then( (src)=>{
  3549. $(".edit-loading").removeClass('hide'); //上传完继续显示loading
  3550. var audio = new Audio();
  3551. audio.src = src;
  3552. audio.onloadedmetadata = ()=>{
  3553. var srcArr = src.split('/'); // 对返回的src进行处理, 去掉前面域名, 尽量避免修改main.js
  3554. srcArr[0] = '';
  3555. src = srcArr.join('/');
  3556. this.editingItemLi.tourData.musicInfo = {
  3557. "name": musicName,
  3558. "music": '/' + src,
  3559. "time": Math.round(audio.duration * 1000 + 1000)
  3560. }
  3561. done()
  3562. }
  3563. })
  3564. }else done()
  3565. }
  3566. EditGuide.prototype.cancelFolder = function(){//放弃编辑
  3567. this.musicBoxFolder.hide()// 清空 文件
  3568. this.editingFolderLi.tourData = this.editingFolderLi.tempData;//还原
  3569. this.editingFolderLi.tourItemDoms.forEach((e,i)=>{
  3570. e.tourData = this.editingFolderLi.tourData.locations[i]
  3571. $(e).find('.guide-name').text(e.tourData.name)
  3572. $(e).find('#tourBg')[0].style.backgroundImage = 'url(' + e.tourData.thumbnail_signed_src + ')';
  3573. })
  3574. this.editingFolderLi = null
  3575. $("#tourFolderEdit").addClass('atRight');
  3576. $("#tourItemList>ul").html('')
  3577. }
  3578. EditGuide.prototype.cancelItem = function(){//放弃编辑
  3579. this.musicBoxItem.hide()// 清空 文件
  3580. this.editingItemLi.tourData = this.editingItemLi.tempData;//还原
  3581. $(this.editingItemLi).find('#tourBg')[0].style.backgroundImage = 'url(' + this.editingItemLi.tourData.thumbnail_signed_src + ')';
  3582. this.editingItemLi = null
  3583. $("#tourItemEdit").addClass('atRight');
  3584. }
  3585. /**
  3586. * @author fyz 2019.07.31
  3587. * @description uploadGuide方法新增参数renew状态码, 表示是否重新录制当前导览, 新增targetTourPoint, 记录当前的导览点元素
  3588. */
  3589. EditGuide.prototype.uploadGuide = function(urlData, guide, renew, insideFolder) {
  3590. var that = this;
  3591. uploadImg(urlData, function(rs) {
  3592. if (rs.code === 0) {
  3593. //var editGuide = new EditGuide();
  3594. var sid = rs.data.substring(rs.data.lastIndexOf('/') + 1, rs.data.lastIndexOf('.'));
  3595. var thumbnail_signed_src = rs.data;
  3596. var args = JSON.parse("{" + guide + "}");
  3597. args.sid = sid;
  3598. args.name = sid;
  3599. args.thumbnail_signed_src = thumbnail_signed_src;
  3600. args.metadata = JSON.stringify({
  3601. camera_mode: args.metadata.camera_mode,
  3602. camera_position: {
  3603. x: args.metadata.camera_position[0],
  3604. y: args.metadata.camera_position[1],
  3605. z: args.metadata.camera_position[2]
  3606. },
  3607. camera_quaternion: {
  3608. x: args.metadata.camera_quaternion[0],
  3609. y: args.metadata.camera_quaternion[1],
  3610. z: args.metadata.camera_quaternion[2],
  3611. w: args.metadata.camera_quaternion[3]
  3612. },
  3613. ortho_zoom: args.metadata.ortho_zoom,
  3614. scan_id: args.metadata.scan_id || "outside",
  3615. //这个"outside"不能随便改成别的
  3616. /* final_angle: 110,
  3617. is_ortho: false, */
  3618. zoom: args.metadata.zoom // fyz zoom是内部计算的zoomLevel, 乘以系数1.06才是实际缩放倍数
  3619. })
  3620. if (renew ) { // 重新录制导览
  3621. // 更新数据
  3622. if(!insideFolder){
  3623. args.musicInfo = that.editingItemLi.tourData.musicInfo;
  3624. }
  3625. args.name = that.editingItemLi.tourData.name
  3626. $(that.editingItemLi).find('#tourBg')[0].style.backgroundImage = 'url(' + args.thumbnail_signed_src + ')';
  3627. that.editingItemLi.tourData = args;
  3628. } else {
  3629. var $li = $(that.getItemDom(args.name, args.thumbnail_signed_src));
  3630. $li[0].tourData = args;
  3631. var $ul = insideFolder ? $("#tourItemList>ul") : $("#tourList>ul")
  3632. $ul.append($li);
  3633. reIndexTourList($ul[0])
  3634. }
  3635. }
  3636. },'tour.jpg');
  3637. }
  3638. EditGuide.prototype.getSavingInfo = function(){
  3639. var data = []
  3640. Array.from($("#tourList ul li")).forEach(dom=>{
  3641. if(dom.classList.contains("guideItem")){//item
  3642. //dom.tourData.name = $(dom).find('.guide-name').text()
  3643. data.push(dom.tourData)
  3644. }else{//folder
  3645. var dataFolder = dom.tourData;
  3646. //dataFolder.name = $(dom).find('.title').text()
  3647. dataFolder.locations = dom.tourItemDoms.map(li => li.tourData )
  3648. data.push(dataFolder)
  3649. }
  3650. })
  3651. return data
  3652. }
  3653. /* -- 以下是一些公用的方法 -- */
  3654. //限制大小
  3655. var restrictedSize = function(file, _size) {
  3656. //限制大小不大于8m
  3657. var fileSize = 0;
  3658. var isIE = /msie/i.test(navigator.userAgent) && !window.opera;
  3659. if (isIE && !file) {
  3660. var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
  3661. var _file = fileSystem.GetFile(filepath);
  3662. fileSize = _file.Size;
  3663. } else {
  3664. fileSize = file.size;
  3665. }
  3666. var size = fileSize / 1024;
  3667. var RSize = _size * 1024;
  3668. if (size > RSize) {
  3669. alert("文件不能大于" + _size + "M");
  3670. return false;
  3671. }
  3672. if (size <= 0) {
  3673. alert("文件大小不能为0M!");
  3674. return false;
  3675. }
  3676. return true
  3677. }
  3678. //上传音乐
  3679. var uploadMusic = function(file, callback) {
  3680. uploadFile(file, 'audio', callback);
  3681. }
  3682. $(".toolRight .music [name='background'] .itemTitle span ").text(`背景音乐 (<${_musicMaxWeight}M)`)
  3683. $(".toolRight .music [name='prop'] .itemTitle span ").text(`区域音频 (<${_musicMaxWeight}M)`)
  3684. //上传图片
  3685. function uploadImg(urlData, callback, fileName) {
  3686. //console.log('urlData',urlData);
  3687. var bytes = window.atob(urlData.split(',')[1]);
  3688. //去掉url的头,并转换为byte
  3689. //处理异常,将ascii码小于0的转换为大于0
  3690. var ab = new ArrayBuffer(bytes.length);
  3691. var ia = new Uint8Array(ab);
  3692. for (var i = 0; i < bytes.length; i++) {
  3693. ia[i] = bytes.charCodeAt(i);
  3694. }
  3695. var blob = new Blob([ab],{
  3696. type: 'image/jpeg',
  3697. });
  3698. uploadFile(blob, 'hot/images', callback, fileName);
  3699. }
  3700. //上传文件
  3701. function uploadFile(file, type, callback, fileName) {
  3702. $(".edit-loading").removeClass("hide");
  3703. var formData = new FormData()
  3704. formData.append('name', number)
  3705. formData.append('dir', type)
  3706. formData.append('random', true)
  3707. //formData.append('file', file)
  3708. formData.append("file", file, fileName);
  3709. let url = cmp ? ('/api/scene/upload/' + number) : ('/manage/scene/upload/' + number)
  3710. $.ajax({
  3711. url: ceshi + url,
  3712. data: formData,
  3713. headers: {
  3714. token: token
  3715. },
  3716. dataType: 'json',
  3717. type: 'POST',
  3718. cache: false,
  3719. //上传文件无需缓存
  3720. processData: false,
  3721. //用于对data参数进行序列化处理 这里必须false
  3722. contentType: false,
  3723. //必须
  3724. success: function(rs) {
  3725. if(rs.code === 0){
  3726. callback(rs, file);
  3727. $(".edit-loading").addClass("hide");
  3728. }else if (rs.code === 5001) {
  3729. alert('请重新登录')
  3730. localStorage.dcj_token = ''
  3731. location.reload()
  3732. }else{
  3733. alert(`uploadFile (url:${url}) code : ${rs.code} \n${rs.msg}`)
  3734. }
  3735. }
  3736. })
  3737. }
  3738. function _animate(prevRect, target) {
  3739. var ms = 300;
  3740. if (ms) {
  3741. var currentRect = target.getBoundingClientRect();
  3742. if (prevRect.nodeType === 1) {
  3743. prevRect = prevRect.getBoundingClientRect();
  3744. }
  3745. _css(target, 'transition', 'none');
  3746. _css(target, 'transform', 'translate3d(' + (prevRect.left - currentRect.left) + 'px,' + (prevRect.top - currentRect.top) + 'px,0)');
  3747. target.offsetWidth;
  3748. // 触发重绘
  3749. //放在timeout里面也可以
  3750. // setTimeout(function() {
  3751. // _css(target, 'transition', 'all ' + ms + 'ms');
  3752. // _css(target, 'transform', 'translate3d(0,0,0)');
  3753. // }, 0);
  3754. _css(target, 'transition', 'all ' + ms + 'ms');
  3755. _css(target, 'transform', 'translate3d(0,0,0)');
  3756. clearTimeout(target.animated);
  3757. target.animated = setTimeout(function() {
  3758. _css(target, 'transition', '');
  3759. _css(target, 'transform', '');
  3760. target.animated = false;
  3761. }, ms);
  3762. }
  3763. }
  3764. //给元素添加style
  3765. function _css(el, prop, val) {
  3766. var style = el && el.style;
  3767. if (style) {
  3768. if (val === void 0) {
  3769. if (document.defaultView && document.defaultView.getComputedStyle) {
  3770. val = document.defaultView.getComputedStyle(el, '');
  3771. } else if (el.currentStyle) {
  3772. val = el.currentStyle;
  3773. }
  3774. return prop === void 0 ? val : val[prop];
  3775. } else {
  3776. if (!(prop in style)) {
  3777. prop = '-webkit-' + prop;
  3778. }
  3779. style[prop] = val + (typeof val === 'string' ? '' : 'px');
  3780. }
  3781. }
  3782. }
  3783. function upload($files, type, cb) {
  3784. var length = $files.length
  3785. var rcount = 0
  3786. var result = []
  3787. Array.from($files).forEach(function(dFile, index) {
  3788. //a 标签的success 是用来判断是否是已经上传过的文件
  3789. //attr-thum 属性是视频的图片
  3790. //videoURL 是判断是否有视频
  3791. var $file = $(dFile)
  3792. var $image = type == 'videos' ? $file.find('img.play-video') : $file.find('img')
  3793. if ($file.hasClass('success')) {//已经上传过,有链接
  3794. if ($file.attr('attr-thum')) {//视频的封面
  3795. result[index] = $file.attr('attr-thum')
  3796. } else if ($image.attr('videoURL')) {//视频
  3797. result[index] = $image.attr('videoURL')
  3798. } else {
  3799. result[index] = $image.attr('src')
  3800. }
  3801. return success(++rcount);
  3802. } else {
  3803. switch ($file[0].localName) {
  3804. case "input":
  3805. dFile = $file[0]
  3806. break;
  3807. case "span"://封面
  3808. dFile = $file.find('input')[0];
  3809. break;
  3810. case "a"://重传的图or视频
  3811. dFile = {files:[$file[0].file]}
  3812. //dFile = $file.find('input')[0];
  3813. break;
  3814. default:
  3815. dFile = $file.closest("li").find('.upload input')[0];
  3816. break;
  3817. }
  3818. // dFile = $file[0].localName === "input" ? $file[0] : $file[0].localName === "span" ? $file.find('input')[0] : $file.closest("li").find('.upload input')[0];
  3819. }
  3820. var file = (dFile.files && dFile.files[0]) || '';
  3821. if (!file)
  3822. return success(++rcount);
  3823. uploadFile(file, 'hot/' + type, function(rs) {
  3824. //似乎所有图保存路径都是这个hot/前缀。图地址 :"场景id/edit/重新生成的文件名.原后缀", 展示页面也是。
  3825. if (rs.code === 0) {
  3826. result[index] = rs.data
  3827. }
  3828. ;success(++rcount);
  3829. })
  3830. })
  3831. //判断当前队列元素是否处理成功
  3832. function success() {
  3833. if (rcount === length) {
  3834. cb(result)
  3835. }
  3836. }
  3837. success()
  3838. }
  3839. function getIndex(el) {
  3840. let index = 0;
  3841. if (!el || !el.parentNode) {
  3842. return -1;
  3843. }
  3844. while (el && (el = el.previousElementSibling)) {
  3845. index++;
  3846. }
  3847. return index;
  3848. }
  3849. dataURLtoBlob = function(dataurl) {
  3850. //将base64转换blob
  3851. var arr = dataurl.split(',')
  3852. , mime = arr[0].match(/:(.*?);/)[1]
  3853. , bstr = atob(arr[1])
  3854. , n = bstr.length
  3855. , u8arr = new Uint8Array(n);
  3856. while (n--) {
  3857. u8arr[n] = bstr.charCodeAt(n);
  3858. }
  3859. return new Blob([u8arr],{
  3860. type: mime
  3861. });
  3862. }
  3863. ;
  3864. //=========================
  3865. var eachMaxWeights = {
  3866. //大小限制
  3867. "photo": 10,
  3868. "video": 1000,//50, expand size for overlayVideo
  3869. //20,
  3870. "audio": 10, //5
  3871. "model": 5
  3872. }
  3873. var supportTypes = {
  3874. //支持后缀
  3875. "photo": ["jpg", "png", "jpeg", "bmp", "gif"],
  3876. "audio": ["mp3", "aac", "ogg", "wav"/* , "m4a" */],
  3877. "video": ["mp4", "mov" ,"webm",/* "rmvb", "wmv" */],//ios:mov
  3878. 'model':["obj"]
  3879. }
  3880. function getExt(name) {
  3881. //后缀
  3882. if (name.indexOf('.') > -1) {
  3883. var a = name.split(".");
  3884. return a.pop();
  3885. } else {
  3886. return '';
  3887. }
  3888. }
  3889. function detectType(fileName) {
  3890. //检测文件后缀类型
  3891. console.log("名:" + fileName)
  3892. var ext = getExt(fileName);
  3893. console.log("后缀:" + ext)
  3894. //不一定所有浏览器都可以
  3895. var type;
  3896. //仅能根据后缀判断类型,尽管后缀可能被修改。 其他方法如file.type和base64开头的字符串均是根据后缀。
  3897. for (var i in supportTypes) {
  3898. if (supportTypes[i].indexOf(ext.toLowerCase()) > -1) {
  3899. type = i;
  3900. break;
  3901. }
  3902. }
  3903. if (type) {
  3904. return type;
  3905. } else {
  3906. return false;
  3907. }
  3908. }
  3909. //手机上的相片会不会太大?
  3910. var detectWeights = function(file, type) {
  3911. //检测大小
  3912. var size = file.size / 1024 / 1024;
  3913. console.log("weight" + size)
  3914. var over;
  3915. if (size > eachMaxWeights[type]) {
  3916. over = Math.ceil(size * 100) / 100;
  3917. }
  3918. return over;
  3919. }
  3920. var exitUpload = function(input) {
  3921. $('.waiting').removeClass('showloading');
  3922. input.value = "";
  3923. }
  3924. var inputMedia = function(options, type, e) {
  3925. var input = e.target;
  3926. if (!window.FileReader) {
  3927. alert('您的浏览器不支持上传文件');
  3928. exitUpload(input);
  3929. return;
  3930. } else if (e.target.files.length === 0) {
  3931. /* exitUpload(input); */
  3932. return;
  3933. }
  3934. $('.waiting').addClass('showloading');
  3935. var file = e.target.files[0];
  3936. var elemType = type;
  3937. var inputType = detectType(file.name);
  3938. var chType = {
  3939. "photo": '图片',
  3940. "video": '视频',
  3941. "audio": '音乐',
  3942. 'model': '模型'
  3943. }
  3944. var overWeight = detectWeights(file, inputType);
  3945. if (elemType) {
  3946. //有指定其中一种类型
  3947. if (inputType != elemType) {
  3948. alert("您选择的不是浏览器支持的" + chType[elemType] + '文件,请重新选择');
  3949. exitUpload(e.target);
  3950. return;
  3951. }
  3952. } else {
  3953. if (!options.enableTypes.includes(inputType)) {
  3954. var text = "";
  3955. options.enableTypes.forEach((type,index)=>{
  3956. text += ((index != 0 ? " / " : "") + chType[elemType])
  3957. }
  3958. )
  3959. alert("您选择的不是浏览器支持的" + text + '文件,请重新选择');
  3960. exitUpload(e.target);
  3961. return;
  3962. }
  3963. }
  3964. if (overWeight) {
  3965. alert(`文件过大(${overWeight}兆),不能大于${eachMaxWeights[inputType]} 兆`)
  3966. exitUpload(e.target);
  3967. return;
  3968. }
  3969. var loadError = function() {
  3970. exitUpload(e.target);
  3971. alert(`文件出错, 无法加载此${chType[inputType]}文件。 文件可能损坏,或者浏览器不支持,或者后缀与文件不匹配。建议在IE以外的浏览器上传`)
  3972. }
  3973. deal(type);
  3974. function deal(type) {
  3975. console.log('开始deal文件')
  3976. var reader = new FileReader();
  3977. //reader.name = file.name;
  3978. if(type == 'model'){
  3979. reader.readAsText( file );
  3980. }else{
  3981. reader.readAsDataURL(file);//readAsDataURL
  3982. }//readAsArrayBuffer readAsBinaryString
  3983. reader.onerror = function(evt) {
  3984. loadError()
  3985. }
  3986. reader.onload = function(evt) {
  3987. if(!evt.target.result){
  3988. $('.waiting').removeClass('showloading');
  3989. return alert('文件出错,可能文件太大')
  3990. }
  3991. if (inputType == "model") {
  3992. var object = new THREE.OBJLoader().parse( evt.target.result );
  3993. options.modelDone(file, object)
  3994. $('.waiting').removeClass('showloading');
  3995. return;
  3996. }
  3997. var blob = dataURLtoBlob(evt.target.result);
  3998. var blobSrc = window.URL.createObjectURL(blob);
  3999. if (inputType == "photo") {
  4000. /* EXIF.getData(file, function () {
  4001. //获取相片旋转
  4002. EXIF.getAllTags(this);
  4003. var orient = EXIF.getTag(this, 'Orientation');
  4004. var img = new Image();
  4005. img.src = evt.target.result;
  4006. img.onload = function (e) { //这时img才有宽高,才能赋予texture宽高
  4007. var smallerImg = CompressImg(e.target, {
  4008. weight: blob.size,
  4009. maxWeight: 0.5 * 1024 * 1024,
  4010. maxSize: 1480
  4011. });
  4012. //最大500k
  4013. smallerImg.onload = function () {
  4014. var f = function (resultImg) {//处理结束回调
  4015. options.photoDone(resultImg)
  4016. $('.waiting').removeClass('showloading');
  4017. }
  4018. Rotate(smallerImg, orient, f)
  4019. window.URL.revokeObjectURL(blobSrc);
  4020. }
  4021. }
  4022. .bind(this)
  4023. img.onerror = loadError;
  4024. }); */
  4025. var img = new Image();
  4026. img.setAttribute("crossOrigin", 'Anonymous')//要在src设置好前解决跨域
  4027. img.src = blobSrc;
  4028. img.base64Src = evt.target.result;
  4029. img.file = file;
  4030. img.onload = function(e) {
  4031. options.photoDone(img)
  4032. $('.waiting').removeClass('showloading');
  4033. img.onload = null //防止src重新赋值后又触发
  4034. }
  4035. } else if (inputType == "video") {
  4036. var video = $('<video controls="controls" x5-playsinline="" webkit-playsinline="true" playsinline="true" controlslist="nodownload"></video>')[0]
  4037. video.setAttribute("crossOrigin", 'Anonymous')
  4038. //要在src设置好前解决跨域
  4039. $(video).on('contextmenu', function() {
  4040. return false;
  4041. });
  4042. //禁止右键点击出现选项(尤其是下载选项)
  4043. $(video).attr('src', blobSrc);
  4044. //华为无法使用blobSrc,否则加载不出来
  4045. //$(video).attr('src', evt.target.result);
  4046. video.base64Src = evt.target.result;
  4047. var hasload = false;
  4048. var error = false;
  4049. var up = function() {
  4050. if (hasload)
  4051. return;
  4052. hasload = true;
  4053. options.videoDone(file, video)
  4054. $('.waiting').removeClass('showloading');
  4055. }
  4056. video.addEventListener('loadeddata', function(e) {
  4057. up()
  4058. })
  4059. //video.onerror = loadError;
  4060. video.onerror = function(e) {
  4061. console.log('error')
  4062. error = true;
  4063. loadError();
  4064. //将mp4改成mov后缀会error
  4065. }
  4066. } else if (inputType == "audio") {
  4067. //林俊波 new Howl For IE&Safari:
  4068. var sound = new Howl({
  4069. src: [blobSrc],
  4070. format: ["mp3"]
  4071. });
  4072. // Clear listener after first call.
  4073. sound.once('load', function() {
  4074. console.log('loaded sound')
  4075. sound.unload()
  4076. console.log("audio.onloadeddata");
  4077. var audio = new Audio;
  4078. audio.controls = "controls";
  4079. audio.src = blobSrc;
  4080. audio.base64Src = evt.target.result;
  4081. options.audioDone(file, audio)
  4082. $('.waiting').removeClass('showloading');
  4083. //}
  4084. });
  4085. sound.once('loaderror', function() {
  4086. loadError.apply(this, arguments)
  4087. console.log('loaderror sound')
  4088. });
  4089. // Fires when the sound finishes playing.
  4090. sound.on('end', function() {
  4091. console.log('Finished sound');
  4092. });
  4093. }
  4094. }
  4095. }
  4096. e.target.value = "";
  4097. //更改value会触发change
  4098. }
  4099. .bind(player)
  4100. //滑动条控件
  4101. var SlideBar = function(o) {
  4102. var scope = this;
  4103. this.name = o.name;
  4104. this.value = o.value;
  4105. //初始值
  4106. this.min = o.min != void 0 ? o.min : 0;
  4107. this.max = this.oriMax = o.max != void 0 ? o.max : 100;
  4108. this.noValue = o.noValue;
  4109. //是否数值输入
  4110. this.precision = o.precision;
  4111. //精度 保留几位小数
  4112. 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>'))
  4113. div.addClass('slider')
  4114. if (o.unitStr) {
  4115. div.find(".BarTxt").append($('<span>' + o.unitStr + '</span>'));
  4116. }
  4117. o.root.append(div);
  4118. this.line = $(".scrollBar", div);
  4119. this.knot = $(".scroll_Thumb", div);
  4120. o.noValue || (this.textArea = $(".scrollBarTxt", div));
  4121. this.track = $(".scroll_Track", div);
  4122. this.unitStr = o.unitStr;
  4123. //unitStr是单位字符串,比如角度的°。不能是数字
  4124. this.onchange = o.onchange;
  4125. this.percent = null;
  4126. this.dragStart = false;
  4127. this.offsetToBody = null;
  4128. this.getOffset();
  4129. this.checkError();
  4130. this.percent = this.getPercent();
  4131. o.noValue || this.displayValue();
  4132. this.moveKnot();
  4133. this.knotWidth = 0;
  4134. this.lineWidth = 0;
  4135. //this.waitValue;//等待要触发事件的值,防止崩溃
  4136. this.avoidCrash = o.avoidCrash;
  4137. this.realMax = !this.noValue ? o.realMax : null;
  4138. //如果传入realMax,代表可以通过输入数字修改最大值范围,最大值不可以超过realMax。
  4139. this.scrollUnit = (scope.max - scope.min) * 0.001;
  4140. if (this.precision != void 0) {
  4141. var prec = Math.pow(10, -this.precision);
  4142. this.scrollUnit < prec && (this.scrollUnit = prec);
  4143. } else {
  4144. //默认化为整数
  4145. this.scrollUnit < 1 && (this.scrollUnit = 1);
  4146. }
  4147. this.dragStartEvent = o.dragStartEvent;
  4148. this.line.on("mousedown touchstart", function(event) {
  4149. scope.dragStart = true;
  4150. scope.dragChange(event);
  4151. if (scope.dragStartEvent)
  4152. scope.dragStartEvent()
  4153. //if(o.avoidCrash && isMobile)scope.dealInterval();
  4154. });
  4155. !window.isMobile && this.line.on("mousewheel DOMMouseScroll wheel", function(event) {
  4156. event.preventDefault();
  4157. var v = event.originalEvent.deltaY > 0 ? -scope.scrollUnit : scope.scrollUnit;
  4158. scope.setValue(scope.value + v);
  4159. });
  4160. this.dragEndEvent = o.dragEndEvent;
  4161. var stop = function() {
  4162. if (scope.dragStart) {
  4163. scope.dragStart = false;
  4164. if (scope.dragEndEvent)
  4165. scope.dragEndEvent()
  4166. }
  4167. }
  4168. $(document).on("mouseup touchend", stop)
  4169. /* isMobile || */
  4170. $("#player").on("mouseup", stop)
  4171. var lastChangeTime = 0;
  4172. $(document).on("mousemove touchmove", function() {
  4173. if (scope.dragStart) {
  4174. /* if(isMobile && o.avoidCrash){
  4175. scope.lastDragEvent = event;
  4176. }else */
  4177. scope.dragChange(event);
  4178. }
  4179. })
  4180. o.noValue || this.textArea.on("change", function() {
  4181. var v = parseFloat(scope.textArea.val());
  4182. if (v != v)
  4183. //NaN
  4184. return;
  4185. scope.setValueFromOutside(v);
  4186. });
  4187. window.addEventListener("resize",()=>{
  4188. if(this.line[0].clientWidth){
  4189. this.getOffset()
  4190. this.moveKnot();
  4191. }
  4192. })
  4193. }
  4194. SlideBar.prototype.dealInterval = function() {
  4195. this.interval = setInterval(function() {
  4196. this.lastDragEvent && this.dragChange(this.lastDragEvent);
  4197. this.lastDragEvent = null
  4198. if (!this.dragStart)
  4199. clearInterval(this.interval)
  4200. }
  4201. .bind(this), 90)
  4202. }
  4203. SlideBar.prototype.changeLimit = function(o) {
  4204. if (o.min)
  4205. this.min = o.min;
  4206. if (o.max)
  4207. this.max = o.max;
  4208. }
  4209. SlideBar.prototype.getOffset = function() {
  4210. //为了检测鼠标位置需要获得相对body的offset
  4211. var left = this.line[0].offsetLeft;
  4212. var element = this.line[0];
  4213. while (element = element.offsetParent) {
  4214. left += element.offsetLeft;
  4215. }
  4216. this.offsetToBody = (left == 0) ? (this.offsetToBody || 0) : left;
  4217. //如果left为0,很可能是它不可见,那么最好使用旧的offsetToBody
  4218. }
  4219. SlideBar.prototype.InitOffset = function() {
  4220. //如果一开始scroller没有显示,要在显示时获取一下offset
  4221. this.getOffset();
  4222. this.getWidth();
  4223. this.moveKnot();
  4224. }
  4225. SlideBar.prototype.checkError = function() {
  4226. if (this.min >= this.max) {
  4227. console.log("scrollbar值有误 " + name);
  4228. return;
  4229. }
  4230. }
  4231. SlideBar.prototype.getPercent = function() {
  4232. return (this.value - this.min) / (this.max - this.min);
  4233. }
  4234. SlideBar.prototype.displayValue = function(value) {
  4235. //this.textArea.val(this.value + (this.unitStr ? " " + this.unitStr : ""));
  4236. if (value != void 0)
  4237. this.value = value;
  4238. this.textArea.val(this.value)
  4239. }
  4240. SlideBar.prototype.getWidth = function() {
  4241. this.knotWidth = this.knot.width();
  4242. this.lineWidth = this.line.width() - this.knotWidth
  4243. }
  4244. SlideBar.prototype.moveKnot = function() {
  4245. //this.getWidth();
  4246. var width = this.percent * this.lineWidth;
  4247. this.knot.css('left', width + "px")
  4248. if (this.track)
  4249. this.track.css('width', (width + this.knotWidth / 2) + "px")
  4250. }
  4251. SlideBar.prototype.bind = function(f) {
  4252. this.onchange = f;
  4253. }
  4254. SlideBar.prototype.setValue = function(v, noEvent, changeMax) {
  4255. //设置数值并改变knot位置 noEvent为true的话就可以不触发回调函数,仅仅改变显示
  4256. //if(this.value==v)return; //因为换选材质需要执行后面onchange才会带动preview的改变,所以这里一样还是执行,而拉动滑动条的部分值不变就不执行
  4257. if (this.precision != void 0) {
  4258. this.value = parseFloat(v.toFixed(this.precision))
  4259. } else {
  4260. //默认化为整数
  4261. this.value = Math.round(v);
  4262. }
  4263. this.value = THREE.Math.clamp(this.value, this.min, this.max)
  4264. if (changeMax && this.realMax != void 0) {
  4265. if (this.value > this.oriMax) {
  4266. this.value = Math.min(this.value, this.realMax);
  4267. this.changeLimit({
  4268. max: this.value
  4269. })
  4270. } else {
  4271. this.changeLimit({
  4272. max: this.oriMax
  4273. })
  4274. }
  4275. }
  4276. this.percent = this.getPercent();
  4277. var makeit = true;
  4278. if (this.onchange && !noEvent) {
  4279. var result = this.onchange(this.value);
  4280. //如果执行的函数不允许这个值,就不能变
  4281. if (result === false) {
  4282. makeit = false;
  4283. }
  4284. }
  4285. if (makeit) {
  4286. this.moveKnot();
  4287. //console.log("SlideBarV-"+this.name + " : "+this.value)
  4288. this.noValue || this.displayValue();
  4289. }
  4290. }
  4291. SlideBar.prototype.dragChange = function(event) {
  4292. //拖动时触发 计算数值
  4293. //this.getWidth();
  4294. //if(!this.offsetToBody || isNaN(this.offsetToBody)this.getOffset();
  4295. if (event.clientX != void 0) {
  4296. this.percent = (event.clientX - this.knotWidth / 2 - this.offsetToBody) / this.lineWidth;
  4297. } else {
  4298. if (event.touches != void 0) {
  4299. this.percent = (event.touches[0].clientX - this.knotWidth / 2 - this.offsetToBody) / this.lineWidth;
  4300. } else
  4301. this.percent = (event.originalEvent.touches[0].clientX - this.knotWidth / 2 - this.offsetToBody) / this.lineWidth;
  4302. }
  4303. if (this.percent < 0)
  4304. this.percent = 0;
  4305. else if (this.percent > 1)
  4306. this.percent = 1;
  4307. //var v = this.percent * this.max;
  4308. var v = this.percent * (this.max - this.min) + this.min;
  4309. //var v = Math.round(this.percent * this.max * 10)/10; //精度为0.1
  4310. if (this.value == v)
  4311. return;
  4312. this.setValue(v);
  4313. }
  4314. SlideBar.prototype.setValueFromOutside = function(v) {
  4315. //外面的事件触发的
  4316. if (this.line.width() == 0)
  4317. return;
  4318. //不可见就不执行。
  4319. //v = Math.round(v*10)/10;
  4320. if (this.realMax != void 0) {
  4321. v = THREE.Math.clamp(v, this.min, this.realMax);
  4322. if (v > this.max)
  4323. this.changeLimit({
  4324. max: v
  4325. });
  4326. } else
  4327. v = THREE.Math.clamp(v, this.min, this.max);
  4328. this.setValue(v);
  4329. }
  4330. //-----------------------------------------------------
  4331. var transformControls;
  4332. var initTransformCtl = function(THREE) {
  4333. TransformControls.init(THREE)
  4334. TransformControls.prototype.transCtlChangeMode = function(mode) {
  4335. //if(!this.editing)return;
  4336. if (mode && this.mode != mode) {
  4337. this.mode = mode;
  4338. transformControls.children[0].showZ = this.mode != 'scale' || transformControls.scaleShowZ
  4339. }
  4340. }
  4341. ,
  4342. transformControls = new TransformControls(player.camera,player.domElement,{
  4343. player: player,
  4344. dontHideWhenFaceCamera: true,
  4345. /* scaleAxis: ["x", "y"],
  4346. //隐藏了z轴。虽然参数没用上
  4347. NoScaleZ: true //整体缩放时只缩放xy轴。 */
  4348. });
  4349. transformControls.space = 'local'//为了在当前方向上平移
  4350. transformControls.setSize(1.5)
  4351. player.model.add(transformControls)
  4352. transformControls.addEventListener('positionChanged',()=>{
  4353. editTool.hotpoint.updateTransform('position');
  4354. })
  4355. transformControls.addEventListener('quaternionChanged',()=>{
  4356. editTool.hotpoint.updateTransform('quaternion');
  4357. })
  4358. transformControls.addEventListener('scaleChanged',()=>{
  4359. editTool.hotpoint.updateTransform('scale');
  4360. })
  4361. let history = new HistoryRecord({
  4362. applyData: (data)=>{
  4363. if(data.object.parent && data.object == editTool.hotpoint.editSpot ){
  4364. //data = Potree.Common.CloneObject(data) //避免使用后更改数据又被使用
  4365. data.matrix.decompose( data.object.position, data.object.quaternion, data.object.scale );
  4366. editTool.hotpoint.updateTransform()
  4367. return true
  4368. }
  4369. },
  4370. getData:(object)=>{
  4371. return {
  4372. object,
  4373. matrix: object.matrixWorld.clone(),
  4374. }
  4375. }
  4376. })
  4377. transformControls.addEventListener('mouseDown', ()=>{ //dragstart
  4378. history.beforeChange(transformControls.object)
  4379. })
  4380. transformControls.addEventListener('mouseUp',()=>{
  4381. history.afterChange(transformControls.object)
  4382. })
  4383. transformControls.history = history
  4384. /* $(".MenuOptions[name='transform'] li").on("click", (e)=>{
  4385. transformControls.transCtlChangeMode($(e.target).attr("index"))
  4386. }) */
  4387. transformControls.transformMenuOptions = new MenuOptions({
  4388. dom: $(".MenuOptions[name='transform'] "),
  4389. uiCallBack : (o)=>{
  4390. var mode = o.name == void 0 ? o.$li.attr('index') : o.name
  4391. transformControls.transCtlChangeMode(mode)
  4392. var hotpointDetail = editTool.hotpoint.hotpointDetail
  4393. hotpointDetail.find(" li[name=setPos] button[name=setSpace] ").css('display',mode == 'scale' ? 'none' : 'block')
  4394. hotpointDetail.find(" li[name=setPos] button[name=useSuitableRatio] ").css('display',mode == 'scale' ? 'block' : 'none')
  4395. hotpointDetail.find(" li[name=setPos] button[name=resetRot] ").css('display',mode == 'rotate' ? 'block' : 'none')
  4396. editTool.hotpoint.updateTranInput()
  4397. },
  4398. callbackWhenChose:(o)=>{
  4399. }
  4400. })
  4401. transformControls.enableScaleZ = ()=>{
  4402. if(transformControls.mode == 'scale'){
  4403. transformControls.children[0].showZ = true
  4404. }
  4405. transformControls.scaleShowZ = true
  4406. }
  4407. transformControls.unableScaleZ = ()=>{
  4408. if(transformControls.mode == 'scale'){
  4409. transformControls.children[0].showZ = false
  4410. }
  4411. transformControls.scaleShowZ = false
  4412. }
  4413. editTool.transformControls = transformControls
  4414. player.on("mode.changed", (e)=>{
  4415. if(player.mode == 'floorplan'){
  4416. transformControls._gizmo.hideAxis = {
  4417. rotate:['x','y','z'] //因为在ortho下旋转不动xyz所以只用e这个轴转
  4418. }
  4419. }else{
  4420. transformControls._gizmo.hideAxis = {}
  4421. }
  4422. })
  4423. }
  4424. //----------------漫游可见性---------------------------------
  4425. var VisiSet = {
  4426. setPanoVisible: false,
  4427. setTagVisible: false,
  4428. setPanoLog:false,
  4429. setGroundAdjust:false,
  4430. inited: false,
  4431. groundAdjustInited: false,
  4432. activePanoId: null,
  4433. panoVLines: {},
  4434. //线条
  4435. panoVTemp: {},
  4436. //修改后还没保存的临时数据
  4437. tagVsetting: null,
  4438. //正在设置的热点中心点
  4439. tagsVLines: {},
  4440. //线条
  4441. //tagVTemp //修改后还没保存的临时数据
  4442. $confirmSnap: $("#camera-start"),
  4443. changeBtn : $(".toolMid .midBottom #midBtns>button").eq(1),
  4444. colors: {
  4445. green: "#00c8ae"
  4446. },
  4447. init: function() {
  4448. if (this.inited) {
  4449. return;
  4450. }
  4451. this.inited = true;
  4452. this.footIconSizeRatio = Math.max(player.model.sizeWithoutPanos.x, player.model.sizeWithoutPanos.z) / 25;
  4453. this.meshGroup = new THREE.Object3D;
  4454. this.meshGroup.name = "setVisible-group"
  4455. player.model.add(this.meshGroup)
  4456. $("#hotVisible button").on("click", ()=>{
  4457. VisiSet.enterSet(VisiSet.beginSetTagVisible.bind(VisiSet))
  4458. })
  4459. /* player.on("mode.changing",(from,to)=>{
  4460. if(to == "panorama" && (VisiSet.setPanoVisible || VisiSet.setTagVisible || VisiSet.setPanoLog)){
  4461. VisiSet.finishSetPanoVisible()
  4462. VisiSet.finishSetTagVisible()
  4463. VisiSet.finishSetPanoLog()
  4464. }
  4465. }) */
  4466. player.model.on("floor.changed",(toFloor)=>{
  4467. if (VisiSet.setPanoVisible || VisiSet.setTagVisible || VisiSet.setPanoLog || VisiSet.setGroundAdjust){
  4468. VisiSet.changePanoVisi(true, toFloor)
  4469. }
  4470. })
  4471. player.on("view.changed",(e)=>{
  4472. if(e.cameraChanged && (VisiSet.setPanoVisible || VisiSet.setTagVisible || VisiSet.setPanoLog || VisiSet.setGroundAdjust || VisiSet.setRoute || VisiSet.setPanoArea)){
  4473. VisiSet.updateFootIconSize();
  4474. }
  4475. })
  4476. this.changeBtn.on("click",()=>{//隐藏与显示该点
  4477. if(this.setPanoVisible){
  4478. if(this.changeBtn.attr("function") == "hide"){
  4479. for(let i in this.panoVLines){
  4480. this.panoVLines[i].visible && this.dealPanoVisible(i);
  4481. }
  4482. }else{
  4483. //显示该点时,显示周围一定距离内、到该点没有遮挡的pano
  4484. //?????
  4485. var list = player.model.panos.sortByScore([e=>e.isAligned()], [(pano)=>{return -pano.position.distanceTo(this.panoVsetting.position)}])
  4486. if(list.length == 1){
  4487. console.log('仅有一个漫游点')
  4488. return;
  4489. }
  4490. var ifBlock = function(panoA, panoB ){
  4491. var A = panoA.position.clone();
  4492. var B = panoB.position.clone();
  4493. return convertTool.ifIntersectChunks(A, B, {})
  4494. }
  4495. var okList
  4496. var s = Math.max(-list[1].score*2, 4); //i==1的一定显示
  4497. for(var i=1;i<list.length;i++){
  4498. if(-list[i].score < s){
  4499. if(ifBlock(this.panoVsetting, list[i].item)){
  4500. list[i].block = true //有阻挡
  4501. }
  4502. list[i].good = true
  4503. }else{
  4504. okList || (okList = list.filter(e=>e.good && !e.block));//绝对可以使用的
  4505. if(okList.length <2 ){
  4506. if(!ifBlock(this.panoVsetting, list[i].item)){
  4507. if(okList.length == 0){
  4508. okList.push(list[i])
  4509. }else{//1
  4510. var lastPos = okList[0].item.position.clone().sub(this.panoVsetting.position).setY(0);
  4511. var thisPos = list[i].item.position.clone().sub(this.panoVsetting.position).setY(0);
  4512. if(lastPos.angleTo(thisPos) > Math.PI / 2){
  4513. console.log('再加一个 角度'+THREE.Math.radToDeg(lastPos.angleTo(thisPos)))
  4514. break;
  4515. }
  4516. }
  4517. }
  4518. }else{
  4519. break;
  4520. }
  4521. }
  4522. }
  4523. if(okList.length==0){//如果length为0,至少加一个pano, 虽然是遮挡的
  4524. okList.push(list[0].item)
  4525. }
  4526. okList.forEach(e=>this.dealPanoVisible(e.item.id))
  4527. console.log(okList)
  4528. }
  4529. }else{//tag
  4530. if(this.changeBtn.attr("function") == "hide"){
  4531. for(let i in this.tagsVLines){
  4532. this.tagsVLines[i].visible && this.dealTagVisible(i);
  4533. }
  4534. }else{
  4535. let temp = this.tagVsetting.info.visiblePanos
  4536. this.tagVsetting.info.isSprite = this.tagVsetting._isSprite //恢复算的才对
  4537. this.tagVsetting.getVisiblePanos()
  4538. if(this.tagVsetting.info.visiblePanos.length == 0){
  4539. alertInfo('找不到不遮挡的点位')
  4540. }
  4541. this.tagVsetting.info.visiblePanos.forEach((id)=>{
  4542. this.dealTagVisible(id)
  4543. })
  4544. this.tagVsetting.info.visiblePanos = temp //数据不能变
  4545. this.tagVsetting.info.isSprite = true
  4546. }
  4547. }
  4548. })
  4549. //----route-------
  4550. if(!window.DATA.route) window.DATA.route = {}
  4551. $('#routeShowSwitch input')[0].checked = !window.DATA.route.hide //默认是否展示。 若隐藏也可以通过函数展示
  4552. $("#routeGradual")[0].checked = !!DATA.route.gradualShow
  4553. $("#routeOpaShine")[0].checked = !!DATA.route.opacityShine
  4554. this.routeOptions = new MenuOptions({
  4555. dom: $(".toolRight .routeArrow .MenuOptions[name=routeLinkTool] "),
  4556. uiCallBack : (o)=>{
  4557. $(".toolRight .routeArrow .remark[name=ctrl]").text(o.$li.attr("index") == 'link' ?
  4558. '按顺序依次点击点位绘制箭头路线,右键结束绘制。' :
  4559. '点击蓝线以删除路线')
  4560. },
  4561. callbackWhenChose:(o)=>{
  4562. this.routeInfo.operation = o.$li.attr("index") == 'link' ? 'addLink' : 'removeLink'
  4563. }
  4564. })
  4565. this.routeOptions.uiCallBack({$li:this.routeOptions.dom.find('.chosen')})
  4566. $(".toolRight .routeArrow button.delete").on("click", ()=>{//清空
  4567. var choice = confirm(`确定删除全部路线吗`);
  4568. if(choice){
  4569. for(let id1 in this.routeInfo.lines){
  4570. for(let id2 in this.routeInfo.lines[id1]){
  4571. this.routeInfo.removeLink(id1,id2)
  4572. }
  4573. }
  4574. }
  4575. })
  4576. },
  4577. initGroundAdjustUi: function() {
  4578. if (this.groundAdjustInited) {
  4579. this.refreshPuckHeightPanel()
  4580. return;
  4581. }
  4582. this.groundAdjustInited = true
  4583. this.ensurePuckHeightDom()
  4584. let puckInputHandler = (handler)=>(e)=>{
  4585. if (e.type === 'keydown' && e.keyCode !== 13) {
  4586. return;
  4587. }
  4588. handler.call(this, e.target.value);
  4589. }
  4590. $('#groundPuckHeightGlobal').on('change blur keydown', puckInputHandler(this.setGlobalPuckHeight))
  4591. $('#groundPuckCurrentX').on('change blur keydown', puckInputHandler((value)=>this.setActivePuckAxis('x', value)))
  4592. $('#groundPuckCurrentY').on('change blur keydown', puckInputHandler((value)=>this.setActivePuckAxis('y', value)))
  4593. $('#groundPuckCurrentZ').on('change blur keydown', puckInputHandler((value)=>this.setActivePuckAxis('z', value)))
  4594. $('#groundPuckAuto').on('click', ()=>this.autoCorrectAllPuckHeights())
  4595. $('#groundPuckResetCurrent').on('click', ()=>this.resetActivePuckHeight())
  4596. $('#groundPuckResetGlobal').on('click', ()=>this.resetGlobalPuckHeight())
  4597. $('#groundPuckResetAll').on('click', ()=>this.resetAllPuckHeights())
  4598. this.refreshPuckHeightPanel()
  4599. },
  4600. enterSet: function(fun) {
  4601. var enter = function() {
  4602. if (player.modeTran.split('-')[1] != "floorplan") {
  4603. setTimeout(fun, 300)
  4604. //提前一点出现
  4605. }
  4606. player.flyToMode("floorplan", fun);
  4607. }
  4608. permitTranMode(['dollhouse','floorplan','inside'])
  4609. player.cameraControls.controls.panorama.insideLookLimitDown = -60
  4610. if ( player.modeTran == void 0) {
  4611. player.afterCModeFuc = ()=>{
  4612. enter()
  4613. }
  4614. } else
  4615. enter()
  4616. },
  4617. enterPanoSet: function(fun) {
  4618. var enter = function() {
  4619. if (player.modeTran.split('-')[1] != "panorama") {
  4620. setTimeout(fun, 300)
  4621. }
  4622. player.flyToMode("panorama", fun);
  4623. }
  4624. permitTranMode(true)
  4625. player.cameraControls.controls.panorama.insideLookLimitDown = null
  4626. if (player.modeTran == void 0) {
  4627. player.afterCModeFuc = ()=>{
  4628. enter()
  4629. }
  4630. } else
  4631. enter()
  4632. },
  4633. beginSetPanoLog: function() {
  4634. player.flying || $(".toolLeft").removeClass("unable")
  4635. if (this.setPanoLog)
  4636. return;
  4637. this.setPanoLog = true
  4638. this.panosSelect = []
  4639. this.showFootIcons(null, true);
  4640. this.updateFootIconSize()
  4641. for(let i in player.model.hots){
  4642. player.model.hots[i].visi_ = player.model.hots[i].mesh.visible;
  4643. player.model.hots[i].mesh.visible = false
  4644. }
  4645. this.changePanoVisi(true)
  4646. },
  4647. beginSetGroundAdjust: function() {
  4648. player.flying || $(".toolLeft").removeClass("unable")
  4649. if (this.setGroundAdjust)
  4650. return;
  4651. this.initGroundAdjustUi()
  4652. this.ensurePuckHeightConfig()
  4653. this.setGroundAdjust = true
  4654. this.panosSelect = []
  4655. this.setActivePuckPano(null)
  4656. this.showFootIcons(null, true);
  4657. this.updateFootIconSize()
  4658. this.refreshPuckHeightPanel()
  4659. for(let i in player.model.hots){
  4660. player.model.hots[i].visi_ = player.model.hots[i].mesh.visible;
  4661. player.model.hots[i].mesh.visible = false
  4662. }
  4663. this.changePanoVisi(true)
  4664. },
  4665. beginSetPanoArea: function() {
  4666. player.flying || $(".toolLeft").removeClass("unable")
  4667. if (this.setPanoArea)
  4668. return;
  4669. this.setPanoArea = true
  4670. this.showFootIcons(null, true);
  4671. this.updateFootIconSize()
  4672. for(let i in player.model.hots){
  4673. player.model.hots[i].visi_ = player.model.hots[i].mesh.visible;
  4674. player.model.hots[i].mesh.visible = false
  4675. }
  4676. this.changePanoVisi(true)
  4677. },
  4678. deletePanoArea(area){
  4679. let index = this.panoAreas.indexOf(area)
  4680. if(index > -1){
  4681. area.panos.forEach(e=>{
  4682. e.panoArea = e.lastPanoArea = null
  4683. this.updateAreaFoot(e)
  4684. })
  4685. this.panoAreas.splice(index, 1)
  4686. area.$li.remove()
  4687. if(this.editPanoArea == area){
  4688. this.switchPanoArea(area,false)
  4689. }
  4690. }
  4691. },
  4692. switchPanoArea(area,state){
  4693. let pannel = $('.toolRight .music li[name="prop"]')
  4694. if(state){
  4695. if(this.editPanoArea){
  4696. let old = this.editPanoArea
  4697. this.switchPanoArea(old,false)
  4698. if(old == area){
  4699. return //点击已打开的就关闭
  4700. }
  4701. }
  4702. pannel.removeClass('hide')
  4703. pannel.find('[name="title"] input').val(area.name)
  4704. pannel.insertAfter(area.$li)
  4705. this.editPanoArea = area
  4706. if(area.audio){
  4707. editTool.EditBGM.areaBGMBox.show( area.audio[0] , area.audio[1]);
  4708. }else{
  4709. editTool.EditBGM.areaBGMBox.hide()
  4710. }
  4711. }else{
  4712. pannel.addClass('hide')
  4713. this.editPanoArea = null
  4714. }
  4715. },
  4716. createPanoArea(){
  4717. if(this.editPanoArea){
  4718. this.saveLastArea()
  4719. }
  4720. let area = {panos:[]}
  4721. this.panoAreas.push(area)
  4722. this.addAreaToList(area)
  4723. this.switchPanoArea(area,true)
  4724. },
  4725. addAreaToList(area){
  4726. //这几项不固定,每次刷新可能变化
  4727. area.color = new THREE.Color().setHSL( math.getSpreadRatio(this.curAreaIndex), 1, 0.7)
  4728. area.index = this.curAreaIndex++
  4729. var $li = $("<li class='listItem' draggable='true'><div class='icon'>"+ area.index +"</div><div class=title >" + (area.name || '') + "</div><div class=DelConfirm title='删除'>确定删除</div><div class=del></div></li>");
  4730. $li[0].area = area
  4731. $li.css('border-left', 'solid 3px #'+area.color.getHexString() )
  4732. area.$li = $li;
  4733. $('.toolRight .music [name="list"]>ul').prepend($li)
  4734. },
  4735. updateAreaFoot(pano){ //changeFIconState
  4736. if(pano.panoArea && this.setPanoArea){
  4737. pano.footIcon.material.uniforms.color.value.copy(pano.panoArea.color)
  4738. pano.addTextSprite(pano.panoArea.index, null, pano.footIcon, 2)
  4739. }else{
  4740. pano.footIcon.material.uniforms.color.value.set('#fff')
  4741. pano.removeTextSprite()
  4742. }
  4743. },
  4744. changePanoArea(pano,area){
  4745. if(area){
  4746. if(pano.panoArea != area){
  4747. this.changePanoArea(pano,null)
  4748. pano.panoArea = area
  4749. area.panos.push(pano)
  4750. }
  4751. }else{
  4752. if(pano.panoArea){
  4753. let index = pano.panoArea.panos.indexOf(pano)
  4754. pano.panoArea.panos.splice(index, 1)
  4755. pano.panoArea = null
  4756. }
  4757. }
  4758. },
  4759. dealPanoAreaClick(object){
  4760. if(!this.editPanoArea)return
  4761. var id = object.name == '' ? object.parent.parent.name : object.name
  4762. var pano = player.model.panos.get(id);
  4763. if(pano){
  4764. if(this.editPanoArea.panos.includes(pano)){//取消
  4765. if(pano.lastPanoArea){ //若原先有,就恢复旧的
  4766. this.changePanoArea(pano, pano.lastPanoArea)
  4767. }else{
  4768. this.changePanoArea(pano, null)
  4769. }
  4770. }else{
  4771. pano.lastPanoArea = pano.panoArea
  4772. this.changePanoArea(pano, this.editPanoArea)
  4773. }
  4774. this.updateAreaFoot(pano)
  4775. }
  4776. },
  4777. saveLastArea(){
  4778. if(!this.editPanoArea)return
  4779. this.editPanoArea.name = $('.music [name=title] input').val()
  4780. if(editTool.EditBGM.areaBGMBox.getSrc()){
  4781. this.editPanoArea.audio = [editTool.EditBGM.areaBGMBox.getName(), editTool.EditBGM.areaBGMBox.getSrc() || '' ]
  4782. }else{
  4783. delete this.editPanoArea.audio
  4784. }
  4785. },
  4786. savePanoAreas(){
  4787. this.saveLastArea()
  4788. //过滤掉什么信息都没有的区域
  4789. let data = this.panoAreas.filter(e=>
  4790. e.panos.length > 0 || (e.name+'').trim() != '' || e.audio
  4791. ).map(e=>{
  4792. return {
  4793. name: e.name,
  4794. audio : e.audio,
  4795. panos: e.panos.map(e=>e.id)
  4796. }
  4797. })
  4798. return data
  4799. },
  4800. finishSetPanoArea(){
  4801. if (!this.setPanoArea)
  4802. return;
  4803. //否则会加多个侦听
  4804. this.changePanoVisi(false)
  4805. this.setPanoArea = false;
  4806. //this.hideFootIcons();
  4807. this.recoverAllState2();
  4808. this.panosSelect = null
  4809. player.flyoutType = null
  4810. permitTranMode(true)
  4811. player.cameraControls.controls.panorama.insideLookLimitDown = null
  4812. for(let i in player.model.hots){
  4813. player.model.hots[i].mesh.visible = player.model.hots[i].visi_
  4814. }
  4815. },
  4816. beginSetRoute: function(){
  4817. if(this.setRoute)return
  4818. this.setRoute = true
  4819. this.showFootIcons(null, true);
  4820. this.updateFootIconSize()
  4821. for(let i in player.model.hots){
  4822. player.model.hots[i].visi_ = player.model.hots[i].mesh.visible;
  4823. player.model.hots[i].mesh.visible = false
  4824. }
  4825. this.changePanoVisi(true)
  4826. //permitTranMode(['inside','dollhouse','floorplan'])
  4827. if(!this.routeInfo){
  4828. let color = '#409eff'
  4829. let lineMat = new THREE.LineBasicMaterial({color,depthTest:false})
  4830. /* let arrow = new THREE.Mesh(new THREE.PlaneGeometry(0.3,0.3,1,1), new THREE.MeshBasicMaterial({
  4831. map: Texture.load("images/introduce_open.png"),//style_jump
  4832. transparent:true,
  4833. depthTest:false,
  4834. color,
  4835. side: 2
  4836. }))
  4837. arrow.rotation.x = Math.PI / 2 //朝上 */
  4838. let moveLine = (line,p1,p2)=>{
  4839. LineDraw.moveLine(line, [p1,p2] )
  4840. //arrow:
  4841. line.children[0].position.copy(new THREE.Vector3().addVectors(p1,p2).multiplyScalar(.5))
  4842. //this.lineAdding.children[0].rotateOnAxis()
  4843. //line.children[0].rotation.y = -new THREE.Vector2(p1.x - p2.x, p1.z - p2.z).angle() + Math.PI/2
  4844. line.children[0].lookAt(p1)
  4845. line.children[1].position.copy(line.children[0].position)
  4846. line.children[1].rotation.copy(line.children[0].rotation)
  4847. }
  4848. this.routeInfo = {
  4849. lines : {},
  4850. panoStart : null,
  4851. plane : new THREE.Plane(),
  4852. lineAdding : null,//用于连接的线
  4853. lineMat,
  4854. operation : 'addLink',//or removeLink
  4855. events : {
  4856. viewChange: (e)=>{
  4857. if(e.cameraChanged && this.routeInfo.panoStart){
  4858. this.routeInfo.updatePlane()
  4859. }
  4860. },
  4861. pointerMove: ()=>{
  4862. if(!this.routeInfo.panoStart)return
  4863. let endPos = player.intersect ? player.intersect.point : player.raycaster.ray.intersectPlane(this.routeInfo.plane)
  4864. moveLine(this.lineAdding, this.routeInfo.panoStart.floorPosition, endPos)
  4865. },
  4866. click: (e)=>{//右键取消 (但拖拽后也会取消,因为右键mousedown不会触发事件,不好写算了)
  4867. e.button == 2 && /*player.mouseCouldBeClickToMove && */ this.routeInfo.cancel()
  4868. }
  4869. },
  4870. updatePlane: ()=>{
  4871. let nor = player.getDirection()
  4872. this.routeInfo.plane.setFromNormalAndCoplanarPoint(nor, this.routeInfo.panoStart.floorPosition)
  4873. },
  4874. cancel: ()=>{
  4875. if(this.lineAdding){
  4876. this.lineAdding.parent.remove(this.lineAdding)
  4877. this.lineAdding = null
  4878. this.routeInfo.panoStart = null;
  4879. }
  4880. },
  4881. addLink: (id1,id2,line)=>{
  4882. this.routeInfo.lines[id1] || (this.routeInfo.lines[id1] = {})
  4883. this.routeInfo.lines[id1][id2] = line
  4884. line.name = 'routeLine:'+ id1 + '->' +id2
  4885. moveLine(line, player.model.panos.index[id1].floorPosition, player.model.panos.index[id2].floorPosition)
  4886. },
  4887. addLine: (startPos=new THREE.Vector3)=>{
  4888. let line = LineDraw.createLine([startPos,startPos], {mat: this.routeInfo.lineMat})
  4889. //let arrow = this.routeInfo.arrow.clone()
  4890. let s = 0.15
  4891. let arrowLeft = LineDraw.createLine([new THREE.Vector3, new THREE.Vector3(-s,0,s)], {mat: lineMat})
  4892. let arrowRight = LineDraw.createLine([new THREE.Vector3, new THREE.Vector3(s,0,s)], {mat: lineMat})
  4893. line.add(arrowLeft), line.add(arrowRight)
  4894. arrowLeft.position.copy(startPos), arrowRight.position.copy(startPos)
  4895. arrowLeft.renderOrder = arrowRight.renderOrder = 7
  4896. this.meshGroup.add(line)
  4897. return line
  4898. },
  4899. removeLink: (id1,id2)=>{
  4900. this.routeInfo.lines[id1][id2].parent.remove(this.routeInfo.lines[id1][id2])
  4901. delete this.routeInfo.lines[id1][id2]
  4902. }
  4903. }
  4904. //初始化绘制
  4905. /* for(let id1 in player.model.panos.routeNextMap){
  4906. for(let pano2 of player.model.panos.routeNextMap[id1]){
  4907. let line = this.routeInfo.addLine()
  4908. this.routeInfo.addLink(id1,pano2.id,line)
  4909. }
  4910. } */
  4911. if(window.DATA.route){
  4912. for(let id1 in window.DATA.route.data){
  4913. for(let id2 of window.DATA.route.data[id1]){
  4914. let line = this.routeInfo.addLine()
  4915. this.routeInfo.addLink(id1,id2,line)
  4916. }
  4917. }
  4918. }
  4919. }else{
  4920. for(let id1 in this.routeInfo.lines){
  4921. for(let id2 in this.routeInfo.lines[id1]){
  4922. let line = this.routeInfo.lines[id1][id2]
  4923. line.visible = true
  4924. }
  4925. }
  4926. }
  4927. player.on("view.changed",this.routeInfo.events.viewChange)
  4928. player.domElement.addEventListener("pointermove",this.routeInfo.events.pointerMove)
  4929. player.domElement.addEventListener("pointerup",this.routeInfo.events.click)
  4930. },
  4931. dealRouteClick: function(object){
  4932. if(this.routeInfo.operation == 'addLink'){
  4933. var id = object.name == '' ? object.parent.parent.name : object.name
  4934. var panos = player.model.panos;
  4935. if(panos.index[id]){
  4936. if(this.routeInfo.panoStart){
  4937. if(this.routeInfo.panoStart == panos.index[id])return
  4938. this.routeInfo.addLink(this.routeInfo.panoStart.id, id, this.lineAdding)
  4939. //this.lineAdding = null
  4940. //this.routeInfo.panoStart = null;
  4941. }
  4942. //}else{
  4943. this.routeInfo.panoStart = panos.index[id]
  4944. this.lineAdding = this.routeInfo.addLine(this.routeInfo.panoStart.floorPosition)
  4945. this.routeInfo.updatePlane()
  4946. //}
  4947. }
  4948. }else if(this.routeInfo.operation == 'removeLink'){
  4949. let name = object.name || object.parent.name
  4950. if(name.slice(0,10) == 'routeLine:'){
  4951. let id = name.slice(10).split('->');
  4952. this.routeInfo.removeLink(id[0], id[1])
  4953. }
  4954. }
  4955. },
  4956. finishSetRoute: function(){
  4957. this.setRoute = false
  4958. player.removeListener("view.changed",this.routeInfo.events.viewChange)
  4959. player.domElement.removeEventListener("pointermove",this.routeInfo.events.pointerMove)
  4960. this.changePanoVisi(false)
  4961. permitTranMode(true)
  4962. player.cameraControls.controls.panorama.insideLookLimitDown = null
  4963. for(let i in player.model.hots){
  4964. player.model.hots[i].mesh.visible = player.model.hots[i].visi_
  4965. }
  4966. for(let id1 in this.routeInfo.lines){
  4967. for(let id2 in this.routeInfo.lines[id1]){
  4968. let line = this.routeInfo.lines[id1][id2]
  4969. //line.parent.removeChild(line)
  4970. line.visible = false
  4971. }
  4972. }
  4973. this.routeInfo.cancel()
  4974. },
  4975. saveRoute : function(){
  4976. let data = {}
  4977. if(this.routeInfo){
  4978. for(let id1 in this.routeInfo.lines){
  4979. let ids = Object.keys(this.routeInfo.lines[id1])
  4980. if(ids.length > 0) data[id1] = Object.keys(this.routeInfo.lines[id1])
  4981. }
  4982. }else{
  4983. return window.DATA.route
  4984. }
  4985. return {
  4986. data,
  4987. hide: $('#routeShowSwitch input').prop('checked') ? 0:1,
  4988. gradualShow: $("#routeGradual").is(':checked') ? 1:0,
  4989. opacityShine: $("#routeOpaShine").is(':checked') ? 1:0,
  4990. }
  4991. //点击总保存按钮后才会保存,然后直接刷新
  4992. },
  4993. changePanoVisi:function(state, toFloor){
  4994. var floor = player.model.allFloorsVisible ? 'all' : (toFloor || player.model.currentFloor)
  4995. if(this.setPanoVisible){
  4996. if(floor != 'all' && this.panoVsetting && floor != this.panoVsetting.floor){//如果切换到其他楼,取消选中该pano
  4997. this.pauseSetPanoVisible('unsaved')
  4998. }
  4999. }
  5000. player.model.panos.forEach(e=>{
  5001. if(!e.footIcon)return
  5002. if(state && !e.footIcon.visible && (floor == 'all' || floor == e.floor)){
  5003. e.footIcon.visible = true
  5004. if(this.setPanoLog)e.addTextSprite(e.id, $('#panoIdColorTex').val(), e.footIcon)
  5005. if(this.setPanoArea){
  5006. this.updateAreaFoot(e)
  5007. }
  5008. }else if(!state || floor != 'all' && floor != e.floor){
  5009. e.footIcon.visible = false
  5010. if(this.setPanoLog || this.setPanoArea)e.removeTextSprite()
  5011. }
  5012. })
  5013. },
  5014. finishSetPanoLog: function() {
  5015. //结束 退出这个设置
  5016. if (!this.setPanoLog)
  5017. return;
  5018. //否则会加多个侦听
  5019. this.changePanoVisi(false)
  5020. this.setPanoLog = false;
  5021. //this.hideFootIcons();
  5022. this.recoverAllState2();
  5023. this.panosSelect = null
  5024. player.flyoutType = null
  5025. permitTranMode(true)
  5026. player.cameraControls.controls.panorama.insideLookLimitDown = null
  5027. for(let i in player.model.hots){
  5028. player.model.hots[i].mesh.visible = player.model.hots[i].visi_
  5029. }
  5030. $("#panosIdShow").val('')
  5031. },
  5032. finishSetGroundAdjust: function() {
  5033. if (!this.setGroundAdjust)
  5034. return;
  5035. this.changePanoVisi(false)
  5036. this.setGroundAdjust = false;
  5037. this.recoverAllState2();
  5038. this.panosSelect = null
  5039. player.flyoutType = null
  5040. permitTranMode(true)
  5041. player.cameraControls.controls.panorama.insideLookLimitDown = null
  5042. for(let i in player.model.hots){
  5043. player.model.hots[i].mesh.visible = player.model.hots[i].visi_
  5044. }
  5045. this.setActivePuckPano(null)
  5046. },
  5047. dealPanoLogClick: function(object) {
  5048. var id = object.name == '' ? object.parent.parent.name : object.name
  5049. var panos = player.model.panos;
  5050. var index = this.panosSelect.indexOf(id)
  5051. if (index==-1) {
  5052. this.changeFIconState(panos.index[id].footIcon, "linked" )
  5053. this.panosSelect.push(id)
  5054. }else{
  5055. this.changeFIconState(panos.index[id].footIcon, false)
  5056. this.panosSelect.splice(index,1)
  5057. }
  5058. $("#panosIdShow").val('"'+this.panosSelect.join('","')+'"');
  5059. }
  5060. ,
  5061. dealGroundAdjustClick: function(object) {
  5062. var id = object.name == '' ? object.parent.parent.name : object.name
  5063. var panos = player.model.panos;
  5064. if (this.panosSelect && this.panosSelect.length) {
  5065. this.panosSelect.forEach((selectedId)=>{
  5066. if (selectedId !== id && panos.index[selectedId] && panos.index[selectedId].footIcon) {
  5067. this.changeFIconState(panos.index[selectedId].footIcon, false)
  5068. }
  5069. })
  5070. }
  5071. this.panosSelect = [id]
  5072. this.changeFIconState(panos.index[id].footIcon, "linked" )
  5073. this.setActivePuckPano(id)
  5074. }
  5075. ,
  5076. changePanoIdColor:function(color){
  5077. player.model.panos.forEach(e=>{
  5078. /* e.removeTextSprite();
  5079. e.addTextSprite(e.id,color, e.footIcon) */
  5080. e.label.sprite.material.color.set(color)
  5081. })
  5082. }
  5083. ,
  5084. ensurePuckHeightConfig: function() {
  5085. if (window.PuckHeightHelper) {
  5086. return window.PuckHeightHelper.getConfig()
  5087. }
  5088. window.DATA.puckHeight = window.DATA.puckHeight || {globalDelta: 0, overrides: {}}
  5089. return window.DATA.puckHeight
  5090. },
  5091. ensurePuckHeightDom: function() {
  5092. let panel = $('.toolRight .groundAdjust .view-setting')
  5093. if (!panel.length) {
  5094. return
  5095. }
  5096. if (!$('#groundPuckHeightGlobal').length) {
  5097. let puckDom = $(
  5098. '<li class="puck-height-block" style="font-family:\'Microsoft YaHei\',\'PingFang SC\',sans-serif;"><div class="itemTitle"><span>全局高度偏移</span></div><div class="remark">仅调整 floorPosition.y,范围 -0.3 到 0.3</div><input id="groundPuckHeightGlobal" class="editText" type="number" step="0.01" min="-0.3" max="0.3" value="0" style="min-height:75px;height:75px;padding:5px 10px;" /></li>' +
  5099. '<li class="puck-height-block" style="font-family:\'Microsoft YaHei\',\'PingFang SC\',sans-serif;"><div class="itemTitle"><span>当前地面点偏移</span></div><div class="remark">当前点位:<span id="groundPuckActiveId">未选择</span></div><div class="remark">基线 X / Y / Z:<span id="groundPuckBaseXYZ">-</span></div><div class="remark">最终 X / Y / Z:<span id="groundPuckFinalXYZ">-</span></div><div class="remark">单点 X / Y / Z 调整范围:-0.3 到 0.3</div><div class="clearfix"><label class="remark" style="display:block;">X值:优先修改Y值,如果Y值贴地后还是有漂浮再调整这个值<input id="groundPuckCurrentX" class="editText" type="number" step="0.01" min="-0.3" max="0.3" value="0" disabled="disabled" placeholder="X 偏移" style="min-height:75px;height:75px;padding:5px 10px;" /></label><label class="remark" style="display:block;">Y值:优先修改该值进行调整漂浮问题<input id="groundPuckCurrentY" class="editText" type="number" step="0.01" min="-0.3" max="0.3" value="0" disabled="disabled" placeholder="Y 偏移" style="min-height:75px;height:75px;padding:5px 10px;" /></label><label class="remark" style="display:block;">Z值:优先修改Y值,如果Y值贴地后还是有漂浮再调整这个值<input id="groundPuckCurrentZ" class="editText" type="number" step="0.01" min="-0.3" max="0.3" value="0" disabled="disabled" placeholder="Z 偏移" style="min-height:75px;height:75px;padding:5px 10px;" /></label></div></li>' +
  5100. '<li class="puck-height-block" style="font-family:\'Microsoft YaHei\',\'PingFang SC\',sans-serif;"><div class="itemTitle"><span>自动贴地与重置</span></div><div class="remark">自动贴地只会写入单点覆盖值</div><div class="clearfix"><button type="button" id="groundPuckAuto" class="innerBtn">自动贴地纠正全部点位</button><button type="button" id="groundPuckResetCurrent" class="innerBtn">重置当前点位</button><button type="button" id="groundPuckResetGlobal" class="innerBtn">重置全局</button><button type="button" id="groundPuckResetAll" class="innerBtn">重置全部覆盖</button></div></li>'
  5101. )
  5102. panel.append(puckDom)
  5103. }
  5104. },
  5105. getPuckHeightSaveInfo: function() {
  5106. let config = window.DATA && window.DATA.puckHeight
  5107. if (!config) {
  5108. return null
  5109. }
  5110. return window.PuckHeightHelper ? window.PuckHeightHelper.cleanConfig(config) : config
  5111. },
  5112. parsePuckHeightValue: function(value) {
  5113. value = parseFloat(value)
  5114. return isFinite(value) ? value : 0
  5115. },
  5116. clampPuckAxisValue: function(value) {
  5117. return THREE.Math.clamp(this.parsePuckHeightValue(value), -.3, .3)
  5118. },
  5119. formatPuckHeightValue: function(value) {
  5120. return isFinite(value) ? (Math.round(value * 1000) / 1000).toString() : '-'
  5121. },
  5122. formatPuckHeightVector: function(vec) {
  5123. if (!vec) {
  5124. return '-'
  5125. }
  5126. return [this.formatPuckHeightValue(vec.x), this.formatPuckHeightValue(vec.y), this.formatPuckHeightValue(vec.z)].join(' / ')
  5127. },
  5128. getPuckOverrideOffset: function(panoId, config) {
  5129. if (window.PuckHeightHelper) {
  5130. return window.PuckHeightHelper.getOverrideOffset(panoId, config)
  5131. }
  5132. let raw = config && config.overrides && config.overrides.hasOwnProperty(panoId) ? config.overrides[panoId] : 0
  5133. if (raw && typeof raw === 'object') {
  5134. return {
  5135. x: this.parsePuckHeightValue(raw.x),
  5136. y: this.parsePuckHeightValue(raw.y),
  5137. z: this.parsePuckHeightValue(raw.z)
  5138. }
  5139. }
  5140. return {x: 0, y: this.parsePuckHeightValue(raw), z: 0}
  5141. },
  5142. getPuckEffectiveOffset: function(panoId, config) {
  5143. if (window.PuckHeightHelper) {
  5144. return window.PuckHeightHelper.getEffectiveOffset(panoId, config)
  5145. }
  5146. let override = this.getPuckOverrideOffset(panoId, config)
  5147. return {
  5148. x: override.x,
  5149. y: this.parsePuckHeightValue(config.globalDelta) + override.y,
  5150. z: override.z
  5151. }
  5152. },
  5153. getActivePuckPano: function() {
  5154. return this.activePanoId ? player.model.panos.index[this.activePanoId] : null
  5155. },
  5156. setActivePuckPano: function(id) {
  5157. this.activePanoId = id || null
  5158. this.refreshPuckHeightPanel()
  5159. },
  5160. refreshPuckHeightPanel: function() {
  5161. let config = this.ensurePuckHeightConfig()
  5162. $('#groundPuckHeightGlobal').val(config.globalDelta || 0)
  5163. let pano = this.getActivePuckPano()
  5164. if (!pano || !pano.baseFloorPosition) {
  5165. $('#groundPuckActiveId').text('未选择')
  5166. $('#groundPuckBaseXYZ').text('-')
  5167. $('#groundPuckFinalXYZ').text('-')
  5168. $('#groundPuckCurrentX').val(0).prop('disabled', !pano)
  5169. $('#groundPuckCurrentY').val(0).prop('disabled', !pano)
  5170. $('#groundPuckCurrentZ').val(0).prop('disabled', !pano)
  5171. return
  5172. }
  5173. let perDelta = this.getPuckOverrideOffset(pano.id, config)
  5174. let effective = this.getPuckEffectiveOffset(pano.id, config)
  5175. $('#groundPuckActiveId').text(pano.id)
  5176. $('#groundPuckBaseXYZ').text(this.formatPuckHeightVector(pano.baseFloorPosition))
  5177. $('#groundPuckFinalXYZ').text(this.formatPuckHeightVector({
  5178. x: pano.baseFloorPosition.x + effective.x,
  5179. y: pano.baseFloorPosition.y + effective.y,
  5180. z: pano.baseFloorPosition.z + effective.z
  5181. }))
  5182. $('#groundPuckCurrentX').val(perDelta.x).prop('disabled', false)
  5183. $('#groundPuckCurrentY').val(perDelta.y).prop('disabled', false)
  5184. $('#groundPuckCurrentZ').val(perDelta.z).prop('disabled', false)
  5185. },
  5186. moveRouteLine: function(line, p1, p2) {
  5187. if (!line || !p1 || !p2) {
  5188. return
  5189. }
  5190. LineDraw.moveLine(line, [p1, p2])
  5191. if (line.children[0]) {
  5192. line.children[0].position.copy(new THREE.Vector3().addVectors(p1, p2).multiplyScalar(.5))
  5193. line.children[0].lookAt(p1)
  5194. }
  5195. if (line.children[1] && line.children[0]) {
  5196. line.children[1].position.copy(line.children[0].position)
  5197. line.children[1].rotation.copy(line.children[0].rotation)
  5198. }
  5199. },
  5200. refreshPuckDependentDisplay: function() {
  5201. let config = this.ensurePuckHeightConfig()
  5202. window.PuckHeightHelper && window.PuckHeightHelper.applyToModel(player.model, config)
  5203. if (this.footIcons) {
  5204. this.footIcons.forEach((foot)=>{
  5205. let pano = player.model.panos.index[foot.name]
  5206. if (!pano || !pano.floorPosition) {
  5207. return
  5208. }
  5209. foot.position.copy(pano.floorPosition)
  5210. foot.lookAt(foot.position.clone().add(new THREE.Vector3(0, 1, 0)))
  5211. })
  5212. }
  5213. if (this.routeInfo) {
  5214. for (let id1 in this.routeInfo.lines) {
  5215. for (let id2 in this.routeInfo.lines[id1]) {
  5216. this.moveRouteLine(this.routeInfo.lines[id1][id2], player.model.panos.index[id1].floorPosition, player.model.panos.index[id2].floorPosition)
  5217. }
  5218. }
  5219. }
  5220. player.path && player.path.placeCpm && player.path.placeCpm()
  5221. this.updateFootIconSize()
  5222. this.refreshPuckHeightPanel()
  5223. },
  5224. clonePuckHeightConfig: function(config) {
  5225. if (window.PuckHeightHelper) {
  5226. return window.PuckHeightHelper.normalizeConfig(config)
  5227. }
  5228. config = config || {globalDelta: 0, overrides: {}}
  5229. return {
  5230. globalDelta: this.parsePuckHeightValue(config.globalDelta),
  5231. overrides: $.extend({}, config.overrides || {})
  5232. }
  5233. },
  5234. setGlobalPuckHeight: function(value) {
  5235. let config = this.ensurePuckHeightConfig()
  5236. let nextConfig = this.clonePuckHeightConfig(config)
  5237. nextConfig.globalDelta = this.clampPuckAxisValue(value)
  5238. window.DATA.puckHeight = window.PuckHeightHelper ? window.PuckHeightHelper.normalizeConfig(nextConfig) : nextConfig
  5239. this.refreshPuckDependentDisplay()
  5240. },
  5241. setActivePuckAxis: function(axis, value) {
  5242. let pano = this.getActivePuckPano()
  5243. if (!pano) {
  5244. this.refreshPuckHeightPanel()
  5245. return
  5246. }
  5247. let config = this.ensurePuckHeightConfig()
  5248. let nextConfig = this.clonePuckHeightConfig(config)
  5249. let current = this.getPuckOverrideOffset(pano.id, nextConfig)
  5250. current[axis] = this.clampPuckAxisValue(value)
  5251. nextConfig.overrides[pano.id] = current
  5252. window.DATA.puckHeight = window.PuckHeightHelper ? window.PuckHeightHelper.normalizeConfig(nextConfig) : nextConfig
  5253. this.refreshPuckDependentDisplay()
  5254. },
  5255. resetActivePuckHeight: function() {
  5256. let pano = this.getActivePuckPano()
  5257. if (!pano) {
  5258. return
  5259. }
  5260. let config = this.ensurePuckHeightConfig()
  5261. delete config.overrides[pano.id]
  5262. window.DATA.puckHeight = window.PuckHeightHelper ? window.PuckHeightHelper.normalizeConfig(config) : config
  5263. this.refreshPuckDependentDisplay()
  5264. },
  5265. resetGlobalPuckHeight: function() {
  5266. let config = this.ensurePuckHeightConfig()
  5267. config.globalDelta = 0
  5268. window.DATA.puckHeight = window.PuckHeightHelper ? window.PuckHeightHelper.normalizeConfig(config) : config
  5269. this.refreshPuckDependentDisplay()
  5270. },
  5271. resetAllPuckHeights: function() {
  5272. window.DATA.puckHeight = {globalDelta: 0, overrides: {}}
  5273. this.refreshPuckDependentDisplay()
  5274. },
  5275. autoCorrectAllPuckHeights: function() {
  5276. let config = this.ensurePuckHeightConfig()
  5277. let corrected = 0
  5278. let skipped = 0
  5279. window.PuckHeightHelper && window.PuckHeightHelper.captureBaseFloorPosition(player.model)
  5280. player.model.panos.forEach((pano)=>{
  5281. let delta = window.PuckHeightHelper ? window.PuckHeightHelper.computeAutoDelta(pano, 0) : null
  5282. if (!isFinite(delta)) {
  5283. skipped++
  5284. return
  5285. }
  5286. config.overrides[pano.id] = this.clampPuckAxisValue(delta)
  5287. corrected++
  5288. })
  5289. window.DATA.puckHeight = window.PuckHeightHelper ? window.PuckHeightHelper.normalizeConfig(config) : config
  5290. this.refreshPuckDependentDisplay()
  5291. manage.showInfo(`自动贴地完成:修正 ${corrected} 个点位,跳过 ${skipped} 个点位`)
  5292. },
  5293. //--------------
  5294. beginSetPanoVisible: function() {
  5295. player.flying || $(".toolLeft").removeClass("unable")
  5296. if (this.setPanoVisible)
  5297. return;
  5298. this.setPanoVisible = true;
  5299. this.panoVTemp = {};
  5300. this.SetOnePanoVisible(player.currentPano)
  5301. //先设置currentPano
  5302. this.$confirmSnap.text('保存当前设置').removeClass("hide")
  5303. //objects.tagManager.hideAllTags();
  5304. this.setDisplay(true)
  5305. this.changePanoVisi(true)
  5306. this.updateFootIconSize()
  5307. //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话
  5308. for(let i in player.model.hots){
  5309. player.model.hots[i].visi_ = player.model.hots[i].mesh.visible;
  5310. player.model.hots[i].mesh.visible = false
  5311. }
  5312. },
  5313. SetOnePanoVisible: function(pano) {
  5314. //点击某个pano后就对该pano点进行设置
  5315. if (this.panoVsetting == pano)
  5316. return;
  5317. //if (this.panoVsetting) saveLastPanoVi(this.panoVsetting);
  5318. this.panoVsetting = pano;
  5319. //记录正在修改的
  5320. this.delVisibleLines();
  5321. //删除线
  5322. this.showFootIcons(pano, true);
  5323. this.createPanoVisiLines(pano);
  5324. //创线
  5325. this.changeBtn.removeClass('hide')
  5326. },
  5327. saveLastPanoVi: function(o={}) {
  5328. //保存刚设置过的pano
  5329. var change = [];
  5330. /* if(o.type == 'autoCompute'){
  5331. }else{ */
  5332. for (var r in this.panoVLines) {
  5333. var line = this.panoVLines[r];
  5334. if (line.name.indexOf("new") > -1 && line.visible) {
  5335. //新设置为visible且没有取消
  5336. change.push({
  5337. type: "add",
  5338. id: r
  5339. })
  5340. } else if (line.name.indexOf("new") == -1 && !line.visible) {
  5341. //旧的且已经取消
  5342. change.push({
  5343. type: "sub",
  5344. id: r
  5345. })
  5346. }
  5347. }
  5348. /* } */
  5349. if(o.onlyGetData){
  5350. return change
  5351. }
  5352. if (change.length) {
  5353. //添加双向的neighbour:
  5354. var self = this.searchNeib(this.panoVsetting.id)
  5355. //var seeMarkers_self = self.seeMarkers;
  5356. var neighbourUUIDs_self = self.neighbourUUIDs
  5357. var neighbourPanos_self = self.neighbourPanos;
  5358. for (var i = 0; i < change.length; i++) {
  5359. var other = this.searchNeib(change[i].id)
  5360. //var seeMarkers = other.seeMarkers;
  5361. var neighbourUUIDs = other.neighbourUUIDs;
  5362. var neighbourPanos = other.neighbourPanos;
  5363. if (change[i].type == "add") {
  5364. //seeMarkers.push(this.panoVsetting.id);
  5365. neighbourUUIDs.push(this.panoVsetting.id);
  5366. neighbourPanos[this.panoVsetting.id] = true;
  5367. //seeMarkers_self.push(change[i].id);
  5368. neighbourUUIDs_self.push(change[i].id);
  5369. neighbourPanos_self[change[i].id] = true;
  5370. } else {
  5371. //var index = seeMarkers.indexOf(this.panoVsetting.id);
  5372. //index > -1 && seeMarkers.splice(index, 1);
  5373. var index = neighbourUUIDs.indexOf(this.panoVsetting.id);
  5374. index > -1 && neighbourUUIDs.splice(index, 1);
  5375. neighbourPanos[this.panoVsetting.id] = false;
  5376. //var index = seeMarkers_self.indexOf(change[i].id);
  5377. //index > -1 && seeMarkers_self.splice(index, 1);
  5378. var index = neighbourUUIDs_self.indexOf(change[i].id);
  5379. index > -1 && neighbourUUIDs_self.splice(index, 1);
  5380. neighbourPanos_self[change[i].id] = false;
  5381. }
  5382. this.panoVTemp[change[i].id] = {
  5383. //后面两个是作为保存到后台的数据存储,临时需要用到的是第一个
  5384. neighbourPanos: neighbourPanos,
  5385. //seeMarkers: seeMarkers,
  5386. neighbourUUIDs: neighbourUUIDs
  5387. }
  5388. }
  5389. this.panoVTemp[this.panoVsetting.id] = {
  5390. //加上自己
  5391. neighbourPanos: neighbourPanos_self,
  5392. //seeMarkers: seeMarkers_self,
  5393. neighbourUUIDs: neighbourUUIDs_self
  5394. }
  5395. }
  5396. },
  5397. pauseSetPanoVisible: function(type) {
  5398. //暂停 因为点击了保存设置 但没有退出设置
  5399. if (!this.setPanoVisible)
  5400. return;
  5401. if (type == "unsaved") {
  5402. //中途点击pano从而停止一个热点的设置
  5403. this.saveLastPanoVi();
  5404. } else {
  5405. this.panoVTemp = {};
  5406. //清空数据
  5407. }
  5408. this.delVisibleLines();
  5409. this.showFootIcons();
  5410. //清空选择
  5411. var lastPanoSetting = this.panoVsetting;
  5412. this.panoVsetting = null;
  5413. lastPanoSetting && this.changeFIconState2(lastPanoSetting.footIcon, this.checkHasNeighbor(lastPanoSetting))
  5414. //这句要放在this.panoVsetting = null后。 根据可见性更改透明度
  5415. this.changeBtn.addClass('hide')
  5416. },
  5417. //按理说改变了neighbourPano,tag的初始visible也要改。但是这样还要考虑已经改过的tag。。很麻烦
  5418. finishSetPanoVisible: function() {
  5419. //结束 退出这个设置
  5420. if (!this.setPanoVisible)
  5421. return;
  5422. //否则会加多个侦听
  5423. this.setPanoVisible = false;
  5424. //this.hideFootIcons();
  5425. this.delVisibleLines();
  5426. //objects.tagManager.showAllTags();
  5427. this.recoverAllState2();
  5428. this.panoVsetting = null;
  5429. this.panoVTemp = {};
  5430. player.flyoutType = null
  5431. this.$confirmSnap.addClass("hide")
  5432. permitTranMode(true)
  5433. player.cameraControls.controls.panorama.insideLookLimitDown = null
  5434. this.setDisplay(false)
  5435. this.changePanoVisi(false)
  5436. for(let i in player.model.hots){
  5437. player.model.hots[i].mesh.visible = player.model.hots[i].visi_
  5438. }
  5439. },
  5440. changeVisiBtnState: function(state){
  5441. let name = this.setPanoVisible ? '该点位置' : '该热点'
  5442. this.changeBtn.attr("function", state ? "hide" : "show")
  5443. this.changeBtn.html(state ? "隐藏"+name : "显示"+name)
  5444. },
  5445. recoverAllState2: function() {
  5446. //为了热点可视恢复成pano全部可见
  5447. if(!this.footIcons)return;
  5448. for (var i = 0; i < this.footIcons.length; i++) {
  5449. this.footIcons[i].material.uniforms.opacity.value = 1;
  5450. this.footIcons[i].material.uniforms.map.value = footTex1;
  5451. }
  5452. },
  5453. afterSavePanoVisibles: function() {
  5454. //实施:
  5455. var panos = player.model.panos;
  5456. for (var i in this.panoVTemp) {
  5457. var pano = panos.index[i];
  5458. //pano.seeMarkers = this.panoVTemp[i].seeMarkers;
  5459. pano.neighbourUUIDs = this.panoVTemp[i].neighbourUUIDs;
  5460. pano.neighbourPanos = this.panoVTemp[i].neighbourPanos;
  5461. }
  5462. if (!this.checkHasNeighbor(player.currentPano)) {
  5463. //currentPano变为孤立点 就要换一个防止飞入
  5464. var list = panos.sortByScore([pano=>{
  5465. return this.checkHasNeighbor(pano)
  5466. }
  5467. ], [function(pano) {
  5468. return -pano.position.distanceTo(player.currentPano.position)
  5469. }
  5470. ])
  5471. if (list && list.length) {
  5472. player.currentPano = list[0].pano;
  5473. //找最近的一非孤立点
  5474. //this.noPanoHasNeighbor = false; //更新状态
  5475. } else {//this.noPanoHasNeighbor = true; //更新状态
  5476. }
  5477. } else {//this.noPanoHasNeighbor = false; //更新状态
  5478. }
  5479. //dataDeal.done();
  5480. //暂时:
  5481. this.pauseSetPanoVisible()
  5482. this.updateFootIconSize()
  5483. //更新一下center大小 写在最后
  5484. },
  5485. //最佳推荐操作顺序: 先设置pano可见性 再创建热点 这样热点的visible正确些,否则之后再设置热点可见性会改更多
  5486. savePanoVisibles: async function() {
  5487. //保存
  5488. if (this.panoVsetting)
  5489. this.saveLastPanoVi(this.panoVsetting);
  5490. //获取最后设置的那个热点的改动
  5491. var PanoData = [];
  5492. for (var i in this.panoVTemp) {
  5493. PanoData.push({
  5494. //希望算法部不会更改index排序,或者更改后能将visible信息一并更改
  5495. panoID: i,
  5496. //visibles: this.turnToPanoIndex(this.panoVTemp[i].seeMarkers),
  5497. visibles3: this.turnToPanoIndex(this.panoVTemp[i].neighbourUUIDs)
  5498. })
  5499. }
  5500. if (PanoData.length == 0) {
  5501. //没改变
  5502. alertInfo("保存成功")
  5503. return;
  5504. }
  5505. /* this.afterSavePanoVisibles()
  5506. alert("保存成功")
  5507. console.log(JSON.stringify(PanoData)) */
  5508. let url = cmp ? ('/api/scene/roamViable/' + cmp) : '/manage/scene/roamViable'
  5509. return new Promise((resolve,reject)=>{
  5510. $.ajax({
  5511. method: 'POST',
  5512. url: ceshi + url,
  5513. headers: {
  5514. 'Content-Type': 'application/json',
  5515. token: token
  5516. },
  5517. contentType: 'application/json',
  5518. data: JSON.stringify({
  5519. data: JSON.stringify(PanoData),
  5520. sceneCode: window.number
  5521. }),
  5522. success: (data)=>{
  5523. if (data.code === 0) {
  5524. this.afterSavePanoVisibles()
  5525. alertInfo("保存漫游可行成功")
  5526. } else
  5527. alert("保存漫游可行失败")
  5528. if (data.code === 5001) {
  5529. alert('请重新登录')
  5530. localStorage.dcj_token = ''
  5531. location.reload()
  5532. }
  5533. resolve()
  5534. }
  5535. ,
  5536. fail: function() {
  5537. alert("保存漫游可行失败")
  5538. reject()
  5539. }
  5540. })
  5541. })
  5542. },
  5543. searchNeib: function(panoId) {
  5544. //寻找某pano的相关neighbour 可能是修改过的
  5545. var panos = player.model.panos;
  5546. var o = {};
  5547. if (this.panoVTemp[panoId]) {
  5548. //o.seeMarkers = this.panoVTemp[panoId].seeMarkers;
  5549. o.neighbourUUIDs = this.panoVTemp[panoId].neighbourUUIDs;
  5550. o.neighbourPanos = this.panoVTemp[panoId].neighbourPanos;
  5551. } else {
  5552. //o.seeMarkers = panos.index[panoId].seeMarkers.slice(0);
  5553. o.neighbourUUIDs = panos.index[panoId].neighbourUUIDs.slice(0);
  5554. o.neighbourPanos = CloneObject(panos.index[panoId].neighbourPanos);
  5555. }
  5556. return o;
  5557. },
  5558. turnToPanoIndex: function(panoArr) {
  5559. var array = [];
  5560. for (var i = 0; i < panoArr.length; i++) {
  5561. var pano = player.model.panos.index[panoArr[i]]//可能undefined,只是存在在panoListOriData中,因在this.data.sweeps[e.uuid].enabled是false
  5562. if(pano){
  5563. var index = window.panoListOriData.indexOf(pano.id)
  5564. array.push(index);
  5565. }
  5566. }
  5567. return array;
  5568. },
  5569. setDisplay: function(state) {
  5570. var panos = player.model.panos;
  5571. if (state) {
  5572. this.$confirmSnap.text('保存当前设置');
  5573. this.$confirmSnap.removeClass('hide');
  5574. } else {
  5575. this.$confirmSnap.addClass('hide');
  5576. this.changeBtn.addClass('hide')
  5577. }
  5578. player.path.currentPanoMarker.mesh.visible = !state;
  5579. player.reticule.visible = !state;
  5580. },
  5581. delVisibleLines: function() {
  5582. //xzw add 所有线都删除
  5583. for (var i in this.tagsVLines) {
  5584. this.tagsVLines[i].geometry.dispose();
  5585. this.tagsVLines[i].material.dispose();
  5586. this.meshGroup.remove(this.tagsVLines[i]);
  5587. delete this.tagsVLines[i];
  5588. }
  5589. for (var i in this.panoVLines) {
  5590. this.panoVLines[i].geometry.dispose();
  5591. this.panoVLines[i].material.dispose();
  5592. this.meshGroup.remove(this.panoVLines[i]);
  5593. delete this.panoVLines[i];
  5594. }
  5595. },
  5596. //--------panoVisible
  5597. createPanoVisiLines: function(pano) {
  5598. // pano可见性线条
  5599. var neighbours = this.panoVTemp[pano.id] && this.panoVTemp[pano.id].neighbourPanos || pano.neighbourPanos;
  5600. for (var r in neighbours) {
  5601. if (neighbours[r] && r != pano.id) {
  5602. this.createPanoSingleLine(pano, "old", r)
  5603. }
  5604. }
  5605. },
  5606. createPanoSingleLine: function(pano, type, id) {
  5607. //pano是中心
  5608. var panos = player.model.panos;
  5609. var p2 = panos.index[id].footIcon.position.clone()
  5610. /* .sub(player.model.position) */
  5611. var line = LineDraw.createLine([pano.footIcon.position.clone()/* .sub(this.position) */
  5612. , p2], {
  5613. color: this.colors.green
  5614. });
  5615. this.meshGroup.add(line);
  5616. line.name = "PanoVL-" + type + "-" + id;
  5617. this.panoVLines[id] = line;
  5618. this.changeFIconState(panos.index[id].footIcon, "linked")
  5619. },
  5620. dealPanoVisible: function(id) {
  5621. //外部调用
  5622. var panos = player.model.panos;
  5623. if (this.panoVsetting) {
  5624. if (id == this.panoVsetting.id) {
  5625. //关闭当前pano设置
  5626. this.pauseSetPanoVisible('unsaved')
  5627. } else {
  5628. var link;
  5629. //结果是否连接
  5630. if (this.panoVLines[id]) {
  5631. this.panoVLines[id].visible = !this.panoVLines[id].visible;
  5632. link = this.panoVLines[id].visible;
  5633. this.changeFIconState(panos.index[id].footIcon, this.panoVLines[id].visible ? "linked" : false)
  5634. } else {
  5635. this.createPanoSingleLine(this.panoVsetting, "new", id)
  5636. link = true;
  5637. }
  5638. if (link) {
  5639. //如果连接上了,直接判断该点是可见的(有附近点),(不能通过checkHasNeighbor来判断,因为新增的线条可能不在它的neighbour中
  5640. this.changeFIconState2(panos.index[id].footIcon, true)
  5641. this.changeFIconState2(panos.index[this.panoVsetting.id].footIcon, true)
  5642. } else {
  5643. //否则需要checkHasNeighbor
  5644. this.changeFIconState2(panos.index[id].footIcon, this.checkHasNeighbor(panos.index[id]))
  5645. this.changeFIconState2(panos.index[this.panoVsetting.id].footIcon, this.checkHasNeighbor(this.panoVsetting))
  5646. }
  5647. /* if(window.routeArray){//箭头路线
  5648. if(this.panoVLines[id].visible)window.routeArray.push(id)
  5649. else{
  5650. let index = window.routeArray.indexOf(id)
  5651. index > -1 && routeArray.splice(index, 1)
  5652. }
  5653. } */
  5654. }
  5655. } else {
  5656. //点击开始设置要设置的pano
  5657. this.SetOnePanoVisible(panos.index[id])
  5658. }
  5659. this.updateFootIconSize()
  5660. },
  5661. showFootIcons: function(pano, isPanovisible) {
  5662. if (!this.footIcons) {
  5663. footTex1 = Texture.load("images/edit/End_128.png");
  5664. footTex2 = Texture.load("images/edit/End_unable_128.png");
  5665. footTex1.anisotropy = footTex2.anisotropy = 4
  5666. this.footIcons = [];
  5667. var scale = 0.4;
  5668. scale *= 40 / Math.sqrt(Math.min($("#player").width(), $("#player").height()));
  5669. //屏幕越小,放得越大
  5670. scale = THREE.Math.clamp(scale, 0.3, 0.7)
  5671. //console.log("scale"+scale)
  5672. var geo = new THREE.PlaneGeometry(scale,scale,1,1)
  5673. var panos = player.model.panos;
  5674. for (var r in panos.index) {
  5675. if (!panos.index[r].isAligned())
  5676. continue;
  5677. var t = THREE.UniformsUtils.clone(shaders.waypoint.uniforms);
  5678. t.map.value = footTex1
  5679. t.color.value.set("#ffffff");
  5680. var mat = new THREE.RawShaderMaterial({
  5681. vertexShader: shaders.waypoint.vertexShader,
  5682. fragmentShader: shaders.waypoint.fragmentShader,
  5683. uniforms: t,
  5684. side: THREE.DoubleSide,
  5685. transparent: !0,
  5686. depthWrite: !1,
  5687. depthTest: false,
  5688. name: "footIcon"
  5689. })
  5690. var foot = new THREE.Mesh(geo,mat)
  5691. foot.position.copy( panos.index[r].floorPosition.clone() ) /* panos.index[r].floorPosition.clone() *///不用floorPosition是因为有出现和position的水平位置不一样的点,一般是偏移很远的不可见点,拍摄的bug
  5692. foot.lookAt(foot.position.clone().add(new THREE.Vector3(0,1,0)));
  5693. foot.name = panos.index[r].id;
  5694. foot.visible = false;
  5695. foot.renderOrder = 6,
  5696. panos.index[r].footIcon = foot;
  5697. this.meshGroup.add(foot);
  5698. this.footIcons.push(foot)
  5699. }
  5700. }
  5701. for (var i = 0; i < this.footIcons.length; i++) {
  5702. this.changeFIconState(this.footIcons[i], false)
  5703. var panos = player.model.panos;
  5704. panos.index[this.footIcons[i].name] && this.footIcons[i].position.copy(panos.index[this.footIcons[i].name].floorPosition)
  5705. if (isPanovisible) {
  5706. this.changeFIconState2(this.footIcons[i], this.checkHasNeighbor(panos.index[this.footIcons[i].name], "showFoot"))
  5707. }
  5708. if (pano && (this.footIcons[i].name == pano.id)) {
  5709. //pano为中心 或者 currentPano 所以放大一点
  5710. this.footIcons[i].oriScale = new THREE.Vector3(1.5,1.5,1.5)
  5711. if (isPanovisible) {
  5712. //currentPano特殊些:
  5713. this.changeFIconState(this.footIcons[i], "center")
  5714. //this.footIcons[i].Unclick = true;//不让点击和hover
  5715. }
  5716. } else {
  5717. this.footIcons[i].oriScale = new THREE.Vector3(1,1,1)
  5718. }
  5719. }
  5720. },
  5721. checkHasNeighbor: function(pano, state) {
  5722. //检查当前状态pano点是否有可通行点
  5723. var neighbours = /* this.panoVTemp && */
  5724. this.panoVTemp[pano.id] ? this.panoVTemp[pano.id].neighbourPanos : pano.neighbourPanos;
  5725. if (state != "showFoot" && pano == this.panoVsetting) {
  5726. //是中心点的话。state == "showFoot"代表是showFootIcon时, 这时候线还没创建,无法用线判断中心点有几个相邻点,直接用neighbourPanos
  5727. for (var i in this.panoVLines) {
  5728. if (this.panoVLines[i].visible) {
  5729. return true;
  5730. //有一条线即可
  5731. }
  5732. }
  5733. return;
  5734. }
  5735. for (var i in neighbours) {
  5736. if (i == pano.id)
  5737. continue;
  5738. if (neighbours[i]) {
  5739. if (this.panoVsetting && this.panoVsetting.id == i && this.panoVLines[pano.id] && !this.panoVLines[pano.id].visible)
  5740. continue;
  5741. return true;
  5742. }
  5743. }
  5744. return false;
  5745. },
  5746. /* ifAllPanoNoNeighbor : function(){//检查是否全是孤立点
  5747. var panos = player.model.panos;
  5748. for(var i in panos.index){
  5749. if(this.checkHasNeighbor(panos.index[i])){
  5750. return false;
  5751. }
  5752. }
  5753. this.noPanoHasNeighbor = true;
  5754. return true;//是全部没有neighbour
  5755. }, */
  5756. changeFIconState: function(footIcon, state) {
  5757. var color = state == "linked" ? this.colors.green : (state == "center" ? /* "#d7f244" */
  5758. "#d5f12e" : "#ffffff");
  5759. footIcon.material.uniforms.color.value.set(color)
  5760. },
  5761. changeFIconState2: function(footIcon, state) {
  5762. //是可见点还是不可见点
  5763. if (state) {
  5764. footIcon.material.uniforms.map.value = footTex1;
  5765. if (this.panoVsetting) {
  5766. if (this.panoVsetting.id != footIcon.name) {
  5767. footIcon.material.uniforms.opacity.value = 1;
  5768. } else {
  5769. this.changeVisiBtnState(true)
  5770. }
  5771. }
  5772. } else {
  5773. //不可见
  5774. footIcon.material.uniforms.map.value = footTex2;
  5775. if (!this.panoVsetting || this.panoVsetting.id != footIcon.name) {
  5776. //非中心点时
  5777. footIcon.material.uniforms.opacity.value = 0.5;
  5778. } else {
  5779. //变为中心点时
  5780. footIcon.material.uniforms.opacity.value = 1;
  5781. this.changeVisiBtnState(false)
  5782. }
  5783. }
  5784. },
  5785. hideFootIcons: function() {
  5786. if (!this.footIcons)
  5787. return;
  5788. for (var i = 0; i < this.footIcons.length; i++) {
  5789. this.footIcons[i].visible = false;
  5790. }
  5791. },
  5792. updateFootIconSize: function() {
  5793. //根据相机位置 改变footIcon大小,使在范围内看到的热点大小一致,防止太小点击不到
  5794. if (!this.footIcons) return;
  5795. if (this.setGroundAdjust) {
  5796. this.footIcons.forEach(function(f) {
  5797. let pano = player.model && player.model.panos && player.model.panos.index ? player.model.panos.index[f.name] : null
  5798. let marker = pano && pano.marker
  5799. let markerWidth = marker && marker.geometry && marker.geometry.parameters ? marker.geometry.parameters.width : 0.35
  5800. let footWidth = f.geometry && f.geometry.parameters ? f.geometry.parameters.width : 1
  5801. let markerScale = marker && marker.scale ? marker.scale.x : 1
  5802. let sizeScale = footWidth ? markerWidth * markerScale / footWidth : 1
  5803. f.scale.copy(f.oriScale).multiplyScalar(sizeScale || 1)
  5804. })
  5805. return
  5806. }
  5807. if(player.mode == 'floorplan'){
  5808. var s = player.cameraControls.controls.floorplan.absoluteScale * 2.8
  5809. s = THREE.Math.clamp(s, 0.5 * this.footIconSizeRatio, 1.4 * this.footIconSizeRatio);
  5810. this.footIcons.forEach(function(f) {
  5811. try {
  5812. f.scale.copy(f.oriScale).multiplyScalar(s);
  5813. } catch (e) {
  5814. console.log(e)
  5815. }
  5816. })
  5817. }else{
  5818. let maxDis = 7, maxScale = 2 * this.footIconSizeRatio, k = maxScale / maxDis
  5819. this.footIcons.forEach(function(f) {
  5820. let s
  5821. let dis = f.position.distanceTo(player.position)
  5822. if(dis >= maxDis) s = maxScale
  5823. else s = dis * k
  5824. f.scale.copy(f.oriScale).multiplyScalar(s);
  5825. //f.quaternion.copy(player.camera.quaternion)
  5826. })
  5827. }
  5828. },
  5829. resetPanosVisiByModel: function() {//一键计算所有漫游可行 (计算后自动连接,但不保存) 多楼层还没试过
  5830. $('.waiting').addClass('showloading');
  5831. $('.pinBottom .allFloorBtn').click()//全部楼层显示
  5832. let begin = ()=>{
  5833. this.pauseSetPanoVisible("unsaved")
  5834. var ifBlock = function(panoA, panoB ){
  5835. var A = panoA.position.clone();
  5836. var B = panoB.position.clone();
  5837. return !!convertTool.ifIntersectChunks(A, B, {})
  5838. }
  5839. player.model.panos.list.forEach(pano1=>{
  5840. this.SetOnePanoVisible(pano1)//开始设置pano1
  5841. player.model.panos.list.forEach(pano2=>{
  5842. if(pano1 == pano2)return
  5843. var visiNew = !ifBlock(pano1,pano2)
  5844. var visiOld = !!(this.panoVLines[pano2.id] && this.panoVLines[pano2.id].visible)
  5845. if(visiNew != visiOld){
  5846. //console.log('修改 '+pano1.id+'-'+pano2.id)
  5847. this.dealPanoVisible(pano2.id)//修改
  5848. }
  5849. })
  5850. this.pauseSetPanoVisible('unsaved')//修改pano1结束
  5851. })
  5852. $('.waiting').removeClass('showloading');
  5853. manage.showInfo("修改成功,可以点击漫游点查看。点击保存当前设置后生效。")
  5854. }
  5855. setTimeout(()=>{
  5856. if(this.setPanoVisible){
  5857. begin()
  5858. }
  5859. },100)
  5860. },
  5861. //========热点可见性==============
  5862. beginSetTagVisible: function() {
  5863. if (this.setTagVisible)
  5864. return;
  5865. $(".toolTop").addClass("unable")
  5866. $("#hotVisible button").addClass("unable")
  5867. $("#hotVisible label").removeClass('hide')
  5868. $(".toolRight .hotpoint .addBtn").addClass("unable")
  5869. this.setTagVisible = true;
  5870. this.tagVTemp = {};
  5871. this.$confirmSnap.text('完成设置').removeClass("hide")
  5872. //objects.tagManager.hideAllTags();
  5873. for (let i in player.model.hots) {
  5874. player.model.hots[i]._isSprite = player.model.hots[i].info.isSprite;
  5875. player.model.hots[i].info.isSprite = true;
  5876. player.model.hots[i].material_.depthTest = false;
  5877. player.model.hots[i].position.copy(player.model.hots[i].info.position);//覆盖transformAtPanos
  5878. player.model.hots[i].scale.copy(player.model.hots[i].info.scale);//覆盖transformAtPanos
  5879. player.model.hots[i].update(player)
  5880. }
  5881. this.setDisplay(true)
  5882. this.updateFootIconSize()
  5883. //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话
  5884. },
  5885. SetOneTagVisible: function(tag) {
  5886. //点击某个热点后就对该热点进行设置,或者在热点修改时对其进行设置
  5887. if (this.tagVsetting == tag)
  5888. return;
  5889. if (this.tagVsetting) {
  5890. this.saveLastTagVi(this.tagVsetting);
  5891. //this.tagVsetting.setElemType(this.tagVsetting.style, this.tagVsetting.styleImageURL);
  5892. }
  5893. this.tagVsetting = tag; //记录正在修改的
  5894. this.delVisibleLines(); //删除线
  5895. this.showFootIcons(player.currentPano);//显示、修改pano颜色
  5896. this.changePanoVisi(true)
  5897. this.createTagVisiLines(tag); //创线
  5898. tag.changeBoxHelperDisplay(true,'visiFocus') //focus highlight
  5899. this.changeBtn.removeClass('hide')
  5900. this.changeVisiBtnState(this.checkCurTagVisi())
  5901. this.updateFootIconSize() //更新一下大小,尤其是上次换了中心点然后退出又进入但是镜头没有变化的话
  5902. },
  5903. saveLastTagVi: function(o={}) {
  5904. //保存刚设置过的tag
  5905. var change = false;
  5906. var newVPs = this.tagVTemp[this.tagVsetting.sid] || this.tagVsetting.info.visiblePanos.slice(0);
  5907. for (var r in this.tagsVLines) {
  5908. var line = this.tagsVLines[r];
  5909. if (line.name.indexOf("new") > -1 && line.visible) {
  5910. //新设置为visible且没有取消
  5911. newVPs.push(r)
  5912. change = true;
  5913. //console.log("add: "+r)
  5914. } else if (line.name.indexOf("new") == -1 && !line.visible) {
  5915. //旧的且已经取消
  5916. var i = newVPs.indexOf(r);
  5917. if (i == -1) {
  5918. console.log("visiblePanos删除error");
  5919. continue;
  5920. }
  5921. newVPs.splice(i, 1);
  5922. change = true;
  5923. //console.log("sub: "+r)
  5924. }
  5925. }
  5926. if(o.getIfChange){
  5927. return change
  5928. }
  5929. if (change) {
  5930. this.tagVTemp[this.tagVsetting.sid] = newVPs;
  5931. }
  5932. this.tagVsetting.changeBoxHelperDisplay(false,'visiFocus')
  5933. },
  5934. pauseSetTagVisible: function() {
  5935. //pc保存后删除连线 但还在继续设置 点选热点即开始
  5936. if (!this.setTagVisible || !this.tagVsetting)
  5937. return;
  5938. //this.tagVsetting.setElemType(this.tagVsetting.style, this.tagVsetting.styleImageURL );
  5939. this.delVisibleLines();
  5940. //this.hideFootIcons();
  5941. this.changePanoVisi(false)
  5942. this.tagVTemp = {};
  5943. this.tagVsetting = null;
  5944. },
  5945. finishSetTagVisible: function() {
  5946. if (!this.setTagVisible)
  5947. return;
  5948. $(".toolTop").removeClass("unable")
  5949. $("#hotVisible button").removeClass("unable")
  5950. $("#hotVisible label").addClass('hide')
  5951. $(".toolRight .hotpoint .addBtn").removeClass("unable")
  5952. this.pauseSetTagVisible();
  5953. this.setTagVisible = false;
  5954. this.setDisplay(false)
  5955. this.$confirmSnap.addClass("hide")
  5956. permitTranMode(true)
  5957. player.cameraControls.controls.panorama.insideLookLimitDown = null
  5958. /* for (var r in objects.tagManager.tags) {
  5959. if(objects.tagManager.tags[r].state == "videoPanoFlag")continue;
  5960. objects.tagManager.tags[r].disc.visible = false;
  5961. objects.tagManager.tags[r].disc.material.depthTest = true;
  5962. } */
  5963. for (let i in player.model.hots) {
  5964. player.model.hots[i].info.isSprite = player.model.hots[i]._isSprite;
  5965. player.model.hots[i].info.isSprite || player.model.hots[i].quaternion.copy(player.model.hots[i].info.quaternion)
  5966. player.model.hots[i].material_.depthTest = true;
  5967. }
  5968. this.changeBtn.addClass('hide')
  5969. },
  5970. saveTagVisibles: function() {
  5971. if (this.tagVsetting)
  5972. this.saveLastTagVi(this.tagVsetting);
  5973. for (var i in this.tagVTemp) {
  5974. //保持成功于是生效
  5975. player.model.hots[i].setVisiblePanos(this.tagVTemp[i])
  5976. }
  5977. this.finishSetTagVisible()
  5978. //还是保存完直接结束吧,因为现在热点可视不放在单独的设置页面了
  5979. },
  5980. createTagVisiLines: function(tag) {
  5981. // 热点可见性线条
  5982. var panos = player.model.panos;
  5983. var visibleList = this.tagVTemp[tag.sid] || tag.info.visiblePanos;
  5984. //如果是刚在设置的要读取设置过的数据
  5985. for (var r = 0; r < visibleList.length; r++) {
  5986. var pano = panos.index[visibleList[r]];
  5987. this.createTagSingleLine(pano, "old", tag)
  5988. }
  5989. },
  5990. createTagSingleLine: function(pano, type, tag) {
  5991. var panos = player.model.panos;
  5992. var line = LineDraw.createLine([pano.footIcon.position.clone()/* .sub(this.position) */
  5993. , tag.info.position.clone()], {
  5994. color: this.colors.green
  5995. });
  5996. this.meshGroup.add(line);
  5997. line.name = "tagVL-" + type + "-" + pano.id;
  5998. this.tagsVLines[pano.id] = line;
  5999. this.changeFIconState(panos.index[pano.id].footIcon, "linked")
  6000. },
  6001. dealTagVisible: function(panoName) {
  6002. //外部调用
  6003. var panos = player.model.panos;
  6004. if (this.tagsVLines[panoName]) {
  6005. this.tagsVLines[panoName].visible = !this.tagsVLines[panoName].visible;
  6006. this.changeFIconState(panos.index[panoName].footIcon, this.tagsVLines[panoName].visible ? "linked" : false)
  6007. } else {
  6008. this.createTagSingleLine(panos.index[panoName], "new", this.tagVsetting)
  6009. }
  6010. this.changeVisiBtnState(this.checkCurTagVisi())
  6011. },
  6012. checkCurTagVisi(){//当前tag是否有可见点。 仅当已经点击了该tag创建了线后获取
  6013. for(let i in this.tagsVLines){
  6014. if(this.tagsVLines[i].visible){
  6015. return true
  6016. }
  6017. }
  6018. return false
  6019. }
  6020. ,
  6021. delVisibleLines: function() {
  6022. //xzw add 所有线都删除
  6023. for (var i in this.tagsVLines) {
  6024. this.tagsVLines[i].geometry.dispose();
  6025. this.tagsVLines[i].material.dispose();
  6026. this.meshGroup.remove(this.tagsVLines[i]);
  6027. delete this.tagsVLines[i];
  6028. }
  6029. for (var i in this.panoVLines) {
  6030. this.panoVLines[i].geometry.dispose();
  6031. this.panoVLines[i].material.dispose();
  6032. this.meshGroup.remove(this.panoVLines[i]);
  6033. delete this.panoVLines[i];
  6034. }
  6035. },
  6036. //------------
  6037. unsaveWarn:async function(done){
  6038. if(VisiSet.setPanoVisible && (VisiSet.panoVsetting && VisiSet.saveLastPanoVi({onlyGetData:true}).length || Object.keys(VisiSet.panoVTemp).length)){//修改过
  6039. var sure = confirm("是否保存已编辑的漫游可视?")
  6040. if(sure){
  6041. await VisiSet.savePanoVisibles()
  6042. }
  6043. done && done()
  6044. }
  6045. }
  6046. /* resetTagVisiByModel : function(){//自动计算所有热点的可视 当模型修改后所有的热点可视都会重新自动计算(用户的设置将被覆盖)
  6047. var visiTags = [];
  6048. for(var i in objects.tagManager.tags){
  6049. var tag = objects.tagManager.tags[i];
  6050. if(tag.state == "videoPanoFlag")continue;
  6051. var visiblePanos = tag.getVisiblePanos();
  6052. visiTags.push({sid:tag.sid, value:visiblePanos})
  6053. }
  6054. return visiTags;
  6055. },
  6056. afterResetTagVisibles : function(visiTags){
  6057. visiTags.forEach((info)=>{
  6058. objects.tagManager.tags[info.sid].setVisiblePanos(info.value);
  6059. })
  6060. if(objects.player.mode == "panorama")objects.tagManager.updateVisible("panorama");
  6061. },
  6062. resetVisiblesByModel : function(){//自动计算所有热点和漫游点的可视
  6063. this.resetTagVisiByModel()
  6064. } */
  6065. }
  6066. function permitTranMode(state ) {
  6067. if(state instanceof Array){//仅显示state包含的模式
  6068. $(".pinBottom.left").removeClass('hide')
  6069. $(".pinBottom.left .viewContainer>*:not(#gui-modes-map)").addClass('hide');
  6070. $(".pinBottom.left #gui-modes-map>*").addClass('hide');
  6071. //注:panorama需转为inside
  6072. state.forEach(m=> $(".pinBottom.left #gui-modes-"+m).removeClass('hide'))
  6073. player.roomLebelClickUnabled = true
  6074. }else{
  6075. if(state){
  6076. player.roomLebelClickUnabled = false
  6077. $(".pinBottom.left").removeClass('hide'),
  6078. $(".pinBottom.left .viewContainer>*").removeClass('hide') ,
  6079. $(".pinBottom.left #gui-modes-map>*").removeClass('hide')
  6080. }else{
  6081. player.roomLebelClickUnabled = true
  6082. $(".pinBottom.left").addClass('hide');
  6083. }
  6084. }
  6085. //一旦存在有隐藏的模式,必定会隐藏导览等其他按钮。
  6086. }
  6087. function randomWord(randomFlag, min, max) {
  6088. //随机字符串
  6089. var str = ""
  6090. , range = min
  6091. , 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'];
  6092. if (randomFlag) {
  6093. // 随机长度
  6094. range = Math.round(Math.random() * (max - min)) + min;
  6095. }
  6096. for (var i = 0; i < range; i++) {
  6097. var pos = Math.round(Math.random() * (arr.length - 1));
  6098. str += arr[pos];
  6099. }
  6100. return str;
  6101. }
  6102. function getRandomSid() {
  6103. //5-7位随机字符串 + 6位时间 为热点准备
  6104. var pre = randomWord(true, 5, 7);
  6105. var post = new Date().getTime() + "";
  6106. var len = post.length;
  6107. post = post.substring(len - 8, len - 5) + post.substring(len - 3, len)
  6108. //其实还是有可能重复的....
  6109. return pre + post;
  6110. }
  6111. function searchParent(searchArea, o, maxTimes) {
  6112. //是否是某种元素的下级,并找出该元素
  6113. maxTimes = maxTimes || 20;
  6114. var count = 0
  6115. var f = function(dom) {
  6116. if (o.id && o.id == dom.id)
  6117. return dom
  6118. else if (o.className && dom.classList && dom.classList.contains(o.className))
  6119. return dom
  6120. else if (o.tagName && dom.tagName && o.tagName.toUpperCase() == dom.tagName.toUpperCase())
  6121. return dom
  6122. }
  6123. var find;
  6124. while (searchArea && count < maxTimes) {
  6125. if (find = f(searchArea))
  6126. return find
  6127. searchArea = searchArea.parentNode;
  6128. count++;
  6129. }
  6130. }
  6131. function musicPlayBoxBind($dom, addCallback, delCallback){
  6132. let audio = new Audio
  6133. var musicBox = {
  6134. hasMusic:false,
  6135. show: function( name, url){
  6136. $dom.find(".innerBtn").text("替换");
  6137. $dom.find(".playBox").removeClass("hide");
  6138. $dom.find(".title").text(name);
  6139. $dom.find('a').attr('href', url);
  6140. audio.src = url
  6141. musicBox.hasMusic = true
  6142. },
  6143. addMusic : function(e) {
  6144. if(!e.target.files.length) return;
  6145. var file = e.target.files[0];
  6146. if (!/audio\/\w+/.test(file.type)) {
  6147. alert("文件必须为音乐!");
  6148. return false;
  6149. }
  6150. //限制大小不大于8m
  6151. if (!restrictedSize(file, _musicMaxWeight)) {
  6152. return false
  6153. }
  6154. //var mediaDom = $(searchParent(e.target, { className: 'mediaUpload' }));
  6155. musicBox.show( file.name, URL.createObjectURL(file))
  6156. addCallback && addCallback(file)
  6157. },
  6158. delMusic:function(){//手动点击删除
  6159. musicBox.hide()
  6160. delCallback && delCallback()
  6161. },
  6162. hide : function(e) {//清空并隐藏
  6163. $dom.find('a').attr('href', "");
  6164. $dom.find(".playBox").addClass("hide");
  6165. $dom.find(".innerBtn").text("上传");
  6166. $dom.find("input").val("")//.removeAttr("data-hotbgm");
  6167. audio.src = ''
  6168. musicBox.hasMusic = false
  6169. },
  6170. getSrc:function(){
  6171. return this.hasMusic && $dom.find('a').attr('href');
  6172. },
  6173. getName:function(){
  6174. return this.hasMusic && $dom.find(".title").text();
  6175. },
  6176. getFile:function(){//获取刚上传的文件
  6177. return this.hasMusic && $dom.find("input")[0].files[0]
  6178. },
  6179. play(){
  6180. if(this.hasMusic){
  6181. audio.play()
  6182. }
  6183. },
  6184. pause(){
  6185. if(this.hasMusic){
  6186. audio.pause()
  6187. }
  6188. }
  6189. }
  6190. $dom.find("input").on("change", musicBox.addMusic)
  6191. //删除音乐
  6192. $dom.on("click", ".delete", musicBox.delMusic)
  6193. $dom.find('.playBox>div:first-child').on('click',(e)=>{
  6194. if($(e.target).hasClass('playing')){
  6195. musicBox.pause()
  6196. }else{
  6197. musicBox.play()
  6198. }
  6199. $(e.target).toggleClass('playing')
  6200. })
  6201. return musicBox;
  6202. }
  6203. class ListBox{//下拉列表
  6204. //elemArr:初始的列表,内含每项的dom.
  6205. constructor(elemArr, $rootDom, options={}){
  6206. this.listDom = $rootDom.find('ul.list')
  6207. this.listTitle = $rootDom.find('.selection')
  6208. this.chosenItem = null
  6209. this.options = options;
  6210. this.bindEvents()
  6211. elemArr.forEach(($dom, i)=>{
  6212. this.addItem($dom)
  6213. })
  6214. }
  6215. updateSelectDisplay(o){
  6216. this.listDom.children().removeClass('selected')
  6217. this.chosenItem && this.chosenItem.addClass("selected")
  6218. this.options.selectFun( o)
  6219. }
  6220. selectFromOutSide(index , o){
  6221. if(index == null){
  6222. var defaultItem = this.listDom.find('.forbitEdit'); //若存在默认选项
  6223. if(defaultItem.length){
  6224. index = defaultItem.index()
  6225. }
  6226. }
  6227. this.chosenIndex = index;
  6228. this.chosenItem = index == void 0 ? null : this.listDom.children().eq(index)
  6229. this.updateSelectDisplay(o)
  6230. }
  6231. addItem($dom){
  6232. this.listDom.prepend($dom)
  6233. if(this.options.addFun){
  6234. this.options.addFun($dom)
  6235. }
  6236. $dom.on('click',()=>{
  6237. this.chosenItem = $dom;
  6238. this.chosenIndex = $dom.index();
  6239. this.updateSelectDisplay()
  6240. })
  6241. }
  6242. removeItem($dom){
  6243. $dom.remove()
  6244. if(this.chosenItem && this.chosenItem[0] == $dom[0]){
  6245. this.selectFromOutSide(null)
  6246. //this.chosenItem = this.chosenIndex = null
  6247. }
  6248. if(this.options.delFun){
  6249. this.options.delFun($dom)
  6250. }
  6251. }
  6252. saveTemp(){//编辑热点时保存一份副本
  6253. this.temp = Array.from(this.listDom.children()).reverse().map((li)=>{
  6254. return li.outerHTML
  6255. })
  6256. this.options.saveTemp && this.options.saveTemp(this)
  6257. }
  6258. recover(){//取消编辑时恢复
  6259. this.listDom.html('')
  6260. this.temp.forEach(html=>{
  6261. this.addItem($(html));
  6262. })
  6263. this.options.recover && this.options.recover(this)
  6264. this.chosenItem = this.chosenIndex = null
  6265. //this.selectFromOutSide(this.chosenIndex)
  6266. }
  6267. bindEvents(){
  6268. this.listTitle.on('click',(e)=>{
  6269. e.stopPropagation()
  6270. this.listDom.toggleClass('hide')
  6271. })
  6272. document.addEventListener('click',()=>{
  6273. this.listDom.addClass('hide')
  6274. })
  6275. }
  6276. }
  6277. class ButtonBase{
  6278. constructor(o={}){
  6279. this.dom = o.dom
  6280. this.uiCallBack = o.uiCallBack
  6281. this.callbackWhenChose = o.callbackWhenChose //只有点击选择才会触发
  6282. }
  6283. }
  6284. class MenuOptions extends ButtonBase{
  6285. constructor(o={}){
  6286. super(o)
  6287. this.dom.find("li").on("click", (e)=>{
  6288. var $elem = $(e.target);
  6289. this.updateChoseAtUI({$li:$elem})
  6290. this.callbackWhenChose && this.callbackWhenChose({$li:$elem})
  6291. })
  6292. }
  6293. updateChoseAtUI(o={}){
  6294. this.dom.find('li').removeClass("chosen");
  6295. if(o.$li){
  6296. o.$li.addClass("chosen");
  6297. }else{
  6298. this.dom.find("li[index="+o.name+"]").addClass("chosen");
  6299. }
  6300. this.uiCallBack && this.uiCallBack(o)
  6301. }
  6302. getSelectName(){
  6303. return this.dom.find('li.chosen').attr('index')
  6304. }
  6305. }
  6306. class CheckBox extends ButtonBase{
  6307. constructor(o={}){
  6308. super(o)
  6309. this.dom.on("change",(e)=>{
  6310. var name = $(e.target).attr('name')
  6311. this.uiCallBack && this.uiCallBack(e.target.checked, name)
  6312. this.callbackWhenChose && this.callbackWhenChose(e.target.checked, name)
  6313. })
  6314. }
  6315. updateChoseAtUI(checked, name){
  6316. var dom
  6317. if(name) dom = this.dom.filter('[name='+name+']')[0]
  6318. else dom = this.dom[0]
  6319. dom.checked = checked //this.dom.prop("checked")
  6320. this.uiCallBack && this.uiCallBack(checked, name)
  6321. }
  6322. checked(name){
  6323. var dom
  6324. if(name) dom = this.dom.filter('[name='+name+']')[0]
  6325. else dom = this.dom[0]
  6326. return dom.checked
  6327. }
  6328. }
  6329. function setDraggable(o={}){
  6330. let findTarget = (event)=>{
  6331. let target;
  6332. for(let name of o.dragItemClassName){
  6333. let tar = searchParent(event.target, { className: name }, o.maxDepth || 7);
  6334. if(tar){
  6335. target = tar; break;
  6336. }
  6337. }
  6338. return target
  6339. }
  6340. let draging = null;
  6341. let dragStart = (event)=> {
  6342. event.dataTransfer.setData("te", event.target.innerText); //不能使用text,firefox会打开新tab
  6343. draging = findTarget(event);
  6344. }
  6345. let dragOver = (event)=>{
  6346. event.preventDefault();
  6347. let target = findTarget(event);
  6348. // 判断dragover是否发生在LI元素上
  6349. if (target && target !== draging ) {
  6350. let dragingIndex = $(draging).index()//draging.querySelector('#index');
  6351. let targetIndex = $(target).index()//target.querySelector('#index');
  6352. var targetRect = target.getBoundingClientRect();
  6353. var dragingRect = draging.getBoundingClientRect();
  6354. if (target && target.animated) {
  6355. return;
  6356. }
  6357. let ulElem = target.parentNode;
  6358. // 寻找到 ul节点
  6359. if (getIndex(draging) < getIndex(target)) {
  6360. //dragingIndex.innerText = [targetIndex.innerText, targetIndex.innerText = dragingIndex.innerText][0];
  6361. // 交换两个节点的序号
  6362. if(event.clientY<targetRect.top+targetRect.height*0.3)return
  6363. ulElem.insertBefore(draging, target.nextSibling);
  6364. //dragingIndex.innerText = [targetIndex.innerText, targetIndex.innerText = dragingIndex.innerText][0];// 交换两个节点的序号
  6365. } else {
  6366. //dragingIndex.innerText = [targetIndex.innerText, targetIndex.innerText = dragingIndex.innerText][0];
  6367. if(event.clientY>targetRect.bottom-targetRect.height*0.3)return
  6368. ulElem.insertBefore(draging, target);
  6369. //dragingIndex.innerText = [targetIndex.innerText, targetIndex.innerText = dragingIndex.innerText][0];
  6370. }
  6371. _animate(dragingRect, draging);
  6372. _animate(targetRect, target);
  6373. o.callback && o.callback(o.ul, target)
  6374. //var ul = searchParent(event.target, { className: 'tourList' })
  6375. //reIndexTourList(ul)
  6376. }
  6377. }
  6378. o.ul.ondragstart = dragStart
  6379. o.ul.ondragover = dragOver
  6380. }
  6381. function rebuildWidget(widget){//改写替换部分UI成可折叠的
  6382. widget = $(widget)
  6383. widget.addClass('group-widget')
  6384. let title = widget.find('.itemTitle span')[0].innerText;
  6385. let group = $(`<div class='group-widget'> <div class='widget-wrapper'><div class='header'> <a>${title}</a> </div><div class='inner'><div class='widget-wrapper'></div></div></div></div>`)
  6386. widget.find('.itemTitle').eq(0).remove()
  6387. let children = Array.from(widget.children())
  6388. children.forEach(child=>{
  6389. group.find('.inner>div').append(child)
  6390. })
  6391. widget.append(group)
  6392. }
  6393. function setToggle(widget){//效果展开
  6394. let header = $(widget).find('.header')
  6395. let inner = $(widget).find('.inner')
  6396. header.on("click", function(e){
  6397. header.toggleClass('closed')
  6398. inner.toggleClass('closed')
  6399. })
  6400. }
  6401. function setWidgeOpen(widget, open){
  6402. let header = widget.find('.header')
  6403. let inner = widget.find('.inner')
  6404. if(open){
  6405. header.removeClass('closed')
  6406. inner.removeClass('closed')
  6407. }else{
  6408. header.addClass('closed')
  6409. inner.addClass('closed')
  6410. }
  6411. }
  6412. function closeWidgets(classes){
  6413. classes.forEach((cla)=>{
  6414. let widge = $(`#hotpointDetail .content>ul>li[name=${cla}]`)
  6415. setWidgeOpen(widge, false)
  6416. })
  6417. }
  6418. Array.from($("#hotpointDetail .content>ul>li")).forEach((group)=>{
  6419. rebuildWidget(group)
  6420. setToggle(group)
  6421. })
  6422. closeWidgets(['setPos', 'model'])
  6423. /* class OnOffSwitch extends CheckBox{
  6424. constructor(o={}){
  6425. super(o)
  6426. }
  6427. }
  6428. */
  6429. /*
  6430. 待加功能:
  6431. //boxhelper改成粗线
  6432. 热点可视时改成一样大小
  6433. 热点可视insight优化
  6434. hover到热点时列表滚动到这一项
  6435. 释放geometry内存 、texture
  6436. */