edit.js 277 KB

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