4dage.js 377 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333
  1. var webview, dom = {},
  2. rotInfo = {
  3. idleTime: 3e3,
  4. speed: .15,
  5. pivot: [],
  6. stopWhenZoom: !1
  7. };
  8. function getQueryVariable(e) {
  9. for (var t = window.location.search.substring(1).split("&"), i = 0; i < t.length; i++) {
  10. var s = t[i].split("=");
  11. if (s[0] == e)
  12. return s[1]
  13. }
  14. return !1
  15. }
  16. dom.addClass = function (e, t) {
  17. if (void 0 === e.className)
  18. e.className = t;
  19. else if (e.className !== t) {
  20. var i = e.className.split(/ +/); -
  21. 1 == i.indexOf(t) && (i.push(t),
  22. e.className = i.join(" ").replace(/^\s+/, "").replace(/\s+$/, ""))
  23. }
  24. },
  25. dom.removeClass = function (e, t) {
  26. if (t)
  27. if (void 0 === e.className)
  28. ;
  29. else if (e.className === t)
  30. e.removeAttribute("class");
  31. else {
  32. var i = e.className.split(/ +/),
  33. s = i.indexOf(t); -
  34. 1 != s && (i.splice(s, 1),
  35. e.className = i.join(" "))
  36. } else
  37. e.className = void 0
  38. },
  39. dom.hasClass = function (e, t) {
  40. return new RegExp("(?:^|\\s+)" + t + "(?:\\s+|$)").test(e.className) || !1
  41. },
  42. dom.id = function (e, t) {
  43. return (t = t || document).getElementById && t.getElementById(e) || document.getElementById(e)
  44. },
  45. dom.Tag = function (e, t) {
  46. return (t = t || document).getElementsByTagName(e)
  47. },
  48. dom.cla = function (e, t) {
  49. return (t = t || document).getElementsByClassName(e)
  50. },
  51. dom.ifVoid = function (e, t) {
  52. return null == e ? t : e
  53. },
  54. dom.objToArray = function (e) {
  55. if (e instanceof Array)
  56. return e;
  57. var t = [];
  58. for (var i in e)
  59. t.push(e[i]);
  60. return t
  61. };
  62. var Clamp = function (e, t, i) {
  63. return void 0 === t && (t = 0),
  64. void 0 === i && (i = 1),
  65. Math.min(i, Math.max(t, e))
  66. },
  67. codeToCh = function (e) {
  68. return unescape(e)
  69. };
  70. fdage = {
  71. // 背景颜色透明
  72. transparentBackground: true
  73. },
  74. function (I) {
  75. function r(e, t, i) {
  76. if (this.name = t.partName,
  77. this.animatedProperties = [],
  78. this.sceneObjectType = t.sceneObjectType,
  79. this.skinningRigIndex = t.skinningRigIndex,
  80. this.id = i,
  81. this.mesh = this.skinningRig = 0,
  82. this.materialIndex = this.lightIndex = this.meshIndex = -1,
  83. this.emissiveProperty = this.offsetVProperty = this.offsetUProperty = this.material = 0,
  84. this.debugMe = t.debugMe,
  85. this.debugString = "",
  86. this.hasTransform = !1,
  87. this.modelPartIndex = t.modelPartIndex,
  88. this.modelPartFPS = t.modelPartFPS,
  89. this.modelPartScale = t.modelPartScale,
  90. this.parentIndex = t.parentIndex,
  91. this.totalFrames = t.totalFrames,
  92. this.animationLength = 1 / this.modelPartFPS * this.totalFrames,
  93. this.turnTableSpinOffset = this.turnTableSpin = this.spinProperty = this.dispersionProperty = this.lightIllumProperty = this.skyIllumProperty = this.opacityProperty = this.spotSharpnessProperty = this.spotAngleProperty = this.distanceProperty = this.brightnessProperty = this.blueProperty = this.greenProperty = this.redProperty = this.visibleProperty = 0,
  94. t.animatedProperties) {
  95. i = t.animatedProperties.length;
  96. for (var s = 0; s < i; ++s) {
  97. var n = t.animatedProperties[s],
  98. r = new a();
  99. r.name = n.name,
  100. this.animatedProperties.push(r),
  101. "Red" != r.name || this.redProperty || (this.redProperty = r),
  102. "Green" != r.name || this.greenProperty || (this.greenProperty = r),
  103. "Blue" != r.name || this.blueProperty || (this.blueProperty = r),
  104. "Brightness" != r.name || this.brightnessProperty || (this.brightnessProperty = r),
  105. "Distance" != r.name || this.distanceProperty || (this.distanceProperty = r),
  106. "Spot Angle" != r.name || this.spotAngleProperty || (this.spotAngleProperty = r),
  107. "Spot Sharpness" != r.name || this.spotSharpnessProperty || (this.spotSharpnessProperty = r),
  108. "Opacity" != r.name || this.opacityProperty || (this.opacityProperty = r),
  109. "Sky Illumination" != r.name || this.skyIllumProperty || (this.skyIllumProperty = r),
  110. "Light Illumination" != r.name || this.lightIllumProperty || (this.lightIllumProperty = r),
  111. "Dispersion" != r.name || this.dispersionProperty || (this.dispersionProperty = r),
  112. "Visible" != r.name || this.visibleProperty || (this.visibleProperty = r),
  113. "Spin Rate" == r.name && (this.spinProperty = r),
  114. "OffsetU" == r.name && (this.offsetUProperty = r),
  115. "OffsetV" == r.name && (this.offsetVProperty = r),
  116. "EmissiveIntensity" == r.name && (this.emissiveProperty = r)
  117. }
  118. }
  119. this.keyframesSharedBufferUShorts = this.keyframesSharedBufferFloats = this.keyFramesByteStream = 0,
  120. (e = e.get(t.file)) && (this.keyFramesByteStream = new u(e.data),
  121. this.unPackKeyFrames()),
  122. this.animatedLocalTransform = new o(this),
  123. this.hasTransform = this.animatedLocalTransform.hasTranslation || this.animatedLocalTransform.hasRotation || this.animatedLocalTransform.hasScale,
  124. this.cachedWorldTransform0 = S.identity(),
  125. this.cachedWorldTransform1 = S.identity(),
  126. this.cachedWorldTransform2 = S.identity(),
  127. this.cachedWorldTransform3 = S.identity(),
  128. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -10,
  129. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  130. this.useFixedLocalTransform = this.useFixedWorldTransform = !1
  131. }
  132. function a() {
  133. this.currentValue = 0,
  134. this.keyframeBufferStartIndexFloat = -1,
  135. this.lastValue = this.interpolationOffsetUShort = this.frameIndexOffsetUShort = this.weighOutOffsetFloat = this.weighInOffsetFloat = this.valueOffsetFloat = this.indexUShortSkip = this.indexFloatSkip = this.interpolationType = this.bytesPerKeyFrame = this.keyframePackingType = 0,
  136. this.lastFramePercent = -10,
  137. this.enable = !0,
  138. this.name = "NONE",
  139. this.splineKF0 = new i(0, 0),
  140. this.splineKF1 = new i(0, 0),
  141. this.splineKF2 = new i(0, 0),
  142. this.splineKF3 = new i(0, 0),
  143. this.debugMe = !0,
  144. this.debugString = "",
  145. this.lastSearchIndex = 1,
  146. this.savedSearchIndex = 0,
  147. this.splineKF0.frameIndex = 0,
  148. this.splineKF1.frameIndex = 1,
  149. this.splineKF2.frameIndex = 2,
  150. this.splineKF3.frameIndex = 3,
  151. this.numKeyframes = 0
  152. }
  153. function o(e) {
  154. var t = e.animatedProperties;
  155. for (this.TX = this.TY = this.TZ = this.RX = this.RY = this.RZ = this.SX = this.SY = this.SZ = 0,
  156. this.hostObject = e,
  157. this.matrix = S.identity(),
  158. this.cachedmatrix0 = S.identity(),
  159. this.cachedmatrix1 = S.identity(),
  160. this.cachedmatrix2 = S.identity(),
  161. this.cachedmatrix3 = S.identity(),
  162. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -1,
  163. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  164. this.debugString = "",
  165. e = 0; e < t.length; e++) {
  166. var i = t[e];
  167. "Translation X" == i.name ? this.TX = i : "Translation Y" == i.name ? this.TY = i : "Translation Z" == i.name ? this.TZ = i : "Rotation X" == i.name ? this.RX = i : "Rotation Y" == i.name ? this.RY = i : "Rotation Z" == i.name ? this.RZ = i : "Scale X" == i.name ? this.SX = i : "Scale Y" == i.name ? this.SY = i : "Scale Z" == i.name && (this.SZ = i)
  168. }
  169. this.hasTranslation = this.TX && this.TY && this.TZ,
  170. this.hasRotation = this.RX && this.RY && this.RZ,
  171. this.hasScale = this.SX && this.SY && this.SZ,
  172. this.lockTransform = !1
  173. }
  174. function c(e, t) {
  175. if (this.originalFPS = 1,
  176. this.name = t.name,
  177. this.totalSeconds = t.length,
  178. this.originalFPS = t.originalFPS,
  179. this.totalFrames = t.totalFrames,
  180. this.expectedNumAnimatedObjects = t.numAnimatedObjects,
  181. this.animatedObjects = [],
  182. this.sceneTransform = S.identity(),
  183. this.debugString = "",
  184. t.animatedObjects)
  185. for (var i = t.animatedObjects.length, s = 0; s < i; ++s) {
  186. var n = new r(e, t.animatedObjects[s], s);
  187. this.animatedObjects.push(n),
  188. this.debugString += n.debugString
  189. }
  190. this.meshObjects = [],
  191. this.lightObjects = [],
  192. this.materialObjects = [],
  193. this.turnTableObjects = [],
  194. this.cameraObjects = []
  195. }
  196. function h(e) {
  197. for (this.files = [],
  198. e = new u(e); !e.empty();) {
  199. var t = {};
  200. t.name = e.readCString(),
  201. t.type = e.readCString();
  202. var i = e.readUint32(),
  203. s = e.readUint32(),
  204. n = e.readUint32();
  205. if (t.data = e.readBytes(s),
  206. !(t.data.length < s)) {
  207. if (1 & i && (t.data = this.decompress(t.data, n),
  208. null === t.data))
  209. continue;
  210. this.files[t.name] = t
  211. }
  212. }
  213. }
  214. function l(e) {
  215. this.digits = new Uint16Array(e || 0)
  216. }
  217. function d(e) {
  218. for (var t = 0; t < e.length; ++t) {
  219. var i = e[t].bounds;
  220. if (void 0 === this.min)
  221. this.min = [i.min[0], i.min[1], i.min[2]],
  222. this.max = [i.max[0], i.max[1], i.max[2]];
  223. else
  224. for (var s = 0; s < 3; ++s)
  225. this.min[s] = Math.min(i.min[s], this.min[s]),
  226. this.max[s] = Math.max(i.max[s], this.max[s])
  227. }
  228. this.min = this.min ? this.min : [0, 0, 0],
  229. this.max = this.max ? this.max : [0, 0, 0],
  230. this.center = [.5 * (this.min[0] + this.max[0]), .5 * (this.min[1] + this.max[1]), .5 * (this.min[2] + this.max[2])],
  231. this.radius = [this.max[0] - this.center[0], this.max[1] - this.center[1], this.max[2] - this.center[2]],
  232. this.radiusDiagonal = Math.sqrt(this.radius[0] * this.radius[0] + this.radius[1] * this.radius[1] + this.radius[2] * this.radius[2])
  233. }
  234. function p(e) {
  235. this.name = "none",
  236. this.text = "default text",
  237. this.title = "none",
  238. this.debugString = this.imagePath = "",
  239. this.controlRect = new s(e),
  240. this.defaultAlpha = .5,
  241. this.focusAlpha = 1,
  242. this.updateAlphas = !0,
  243. this.linkedBackground = this.backgroundOffsetY = this.backgroundOffsetX = this.edgePixelsY = this.edgePixelsX = this.backgroundBottomMiddle = this.backgroundBottomRight = this.backgroundBottomLeft = this.backgroundMiddleMiddle = this.backgroundMiddleRight = this.backgroundMiddleLeft = this.backgroundTopMiddle = this.backgroundTopRight = this.backgroundTopLeft = this.backgroundMiddle = this.backgroundRight = this.backgroundLeft = 0
  244. }
  245. function u(e) {
  246. this.bytes = new Uint8Array(e)
  247. }
  248. function s(e) {
  249. this.name = "none",
  250. this.title = "frame",
  251. this.yPercent = this.xPercent = 0,
  252. this.heightPercent = this.widthPercent = 1,
  253. this.debugString = "",
  254. this.parentControlRect = 0,
  255. this.childControlRects = [],
  256. this.clicked = this.mouseDown = this.mouseOver = !1,
  257. this.localMouseYPercent = this.localMouseXPercent = 0,
  258. this.enabled = this.visible = !0,
  259. this.opacity = 1,
  260. this.guiScreen = e,
  261. this.id = this.callBack = this.linkedControl = 0
  262. }
  263. r.prototype.setFixedWorldTransform = function (e) {
  264. this.useFixedWorldTransform = !0,
  265. S.copy(this.cachedWorldTransform0, e)
  266. },
  267. r.prototype.setFixedLocalTransform = function (e) {
  268. this.useFixedLocalTransform = !0,
  269. this.animatedLocalTransform.lockTransform = !0,
  270. S.copy(this.animatedLocalTransform.cachedmatrix0, e)
  271. },
  272. r.prototype.getCachedWorldTransform = function (e) {
  273. return this.useFixedWorldTransform ? 0 : e == this.cachedFrame0 ? this.cachedmatrix0 : e == this.cachedFrame1 ? this.cachedmatrix1 : e == this.cachedFrame2 ? this.cachedmatrix2 : e == this.cachedFrame3 ? this.cachedmatrix3 : 0
  274. },
  275. r.prototype.getFreeCachedWorldTransform = function (e) {
  276. return this.useFixedWorldTransform ? 0 : (this.cachedFrameUse0--,
  277. this.cachedFrameUse1--,
  278. this.cachedFrameUse2--,
  279. this.cachedFrameUse3--,
  280. this.cachedFrameUse0 <= this.cachedFrameUse1 && this.cachedFrameUse0 <= this.cachedFrameUse2 && this.cachedFrameUse0 <= this.cachedFrameUse3 ? (this.cachedFrame0 = e,
  281. this.cachedFrameUse0 = 0,
  282. this.cachedWorldTransform0) : this.cachedFrameUse1 <= this.cachedFrameUse0 && this.cachedFrameUse1 <= this.cachedFrameUse2 && this.cachedFrameUse1 <= this.cachedFrameUse3 ? (this.cachedFrame1 = e,
  283. this.cachedFrameUse1 = 0,
  284. this.cachedWorldTransform1) : this.cachedFrameUse2 <= this.cachedFrameUse0 && this.cachedFrameUse2 <= this.cachedFrameUse1 && this.cachedFrameUse2 <= this.cachedFrameUse3 ? (this.cachedFrame2 = e,
  285. this.cachedFrameUse2 = 0,
  286. this.cachedWorldTransform2) : (this.cachedFrame3 = e,
  287. this.cachedFrameUse3 = 0,
  288. this.cachedWorldTransform3))
  289. },
  290. r.prototype.unPackKeyFrames = function () {
  291. if (this.keyFramesByteStream) {
  292. var e = new Float32Array(this.keyFramesByteStream.bytes.buffer),
  293. t = new Uint32Array(this.keyFramesByteStream.bytes.buffer),
  294. i = new Uint16Array(this.keyFramesByteStream.bytes.buffer),
  295. s = new Uint8Array(this.keyFramesByteStream.bytes.buffer);
  296. this.keyframesSharedBufferFloats = e;
  297. e = 0,
  298. e = 1 + (t = (this.keyframesSharedBufferUShorts = t)[0]),
  299. t = this.animatedProperties.length;
  300. for (var n = 0; n < t; n++) {
  301. var r = this.animatedProperties[n],
  302. a = 2 + 2 * n,
  303. o = 2 * a;
  304. r.keyframeBufferStartIndexFloat = e,
  305. r.numKeyframes = i[a],
  306. r.keyframePackingType = s[2 + o],
  307. r.interpolationType = s[3 + o],
  308. r.indexFloatSkip = 0,
  309. (r.indexUShortSkip = 0) < r.numKeyframes && (0 == r.keyframePackingType ? (r.bytesPerKeyFrame = 16,
  310. r.indexFloatSkip = 4,
  311. r.indexUShortSkip = 8,
  312. r.valueOffsetFloat = 0,
  313. r.weighInOffsetFloat = 1,
  314. r.weighOutOffsetFloat = 2,
  315. r.frameIndexOffsetUShort = 6,
  316. r.interpolationOffsetUShort = 7) : 1 == r.keyframePackingType ? (r.bytesPerKeyFrame = 8,
  317. r.indexFloatSkip = 2,
  318. r.indexUShortSkip = 4,
  319. r.valueOffsetFloat = 0,
  320. r.weighInOffsetFloat = 0,
  321. r.weighOutOffsetFloat = 0,
  322. r.frameIndexOffsetUShort = 2,
  323. r.interpolationOffsetUShort = 3) : 2 == r.keyframePackingType && (r.bytesPerKeyFrame = 4,
  324. r.indexFloatSkip = 1,
  325. r.indexUShortSkip = 2,
  326. r.valueOffsetFloat = 0,
  327. r.weighInOffsetFloat = 0,
  328. r.weighOutOffsetFloat = 0,
  329. r.frameIndexOffsetUShort = 0,
  330. r.interpolationOffsetUShort = 0)),
  331. e += r.numKeyframes * r.indexFloatSkip
  332. }
  333. }
  334. },
  335. r.prototype.setupSkinningRig = function (e, t, i, s) {
  336. var n = S.identity(),
  337. r = S.identity(),
  338. a = (a = i * (o = e.animatedObjects[t]).modelPartFPS) - Math.floor(a),
  339. o = (i = Math.floor(e.getObjectAnimationFramePercent(o, i))) + 1,
  340. h = 1 - a,
  341. l = s.skinningClusters.length;
  342. if (0 < l)
  343. for (var d = 0; d < l; d++) {
  344. (c = s.skinningClusters[d]).solveClusterTransformAtFrame(e, t, i, n),
  345. c.solveClusterTransformAtFrame(e, t, o, r);
  346. for (var c = c.matrix, u = 0; u < 16; u++)
  347. c[u] = n[u] * h + r[u] * a
  348. }
  349. },
  350. r.prototype.evaluateLocalTransformAtFramePercent = function (e, t, i, s) {
  351. if (this.useFixedLocalTransform)
  352. S.copy(t, this.animatedLocalTransform.cachedmatrix0);
  353. else {
  354. var n = 0;
  355. s && (n = this.animatedLocalTransform.getCachedTransform(e)),
  356. n ? S.copy(t, n) : ((n = this.animatedLocalTransform.getFreeCachedTransform(e)) ? (this.animatedLocalTransform.evaluateMatrix(n, this.totalFrames, e, i),
  357. S.copy(t, n)) : this.animatedLocalTransform.evaluateMatrix(t, this.totalFrames, e, i),
  358. 0 != this.turnTableSpin && (e = S.rotation(S.empty(), this.turnTableSpin, 1),
  359. S.mul(t, t, e)))
  360. }
  361. },
  362. r.prototype.hasAnimatedTransform = function () {
  363. var e = this.animatedLocalTransform;
  364. return !!(e.TX && 1 < e.TX.numKeyframes || e.TY && 1 < e.TY.numKeyframes || e.TZ && 1 < e.TZ.numKeyframes || e.RX && 1 < e.RX.numKeyframes || e.RY && 1 < e.RY.numKeyframes || e.RZ && 1 < e.RZ.numKeyframes || e.SX && 1 < e.SX.numKeyframes || e.SY && 1 < e.SY.numKeyframes || e.SZ && 1 < e.SZ.numKeyframes)
  365. },
  366. a.prototype.evaluateCurve = function (e, t) {
  367. var i = this.splineKF1.frameIndex,
  368. s = this.splineKF2.frameIndex,
  369. n = this.splineKF1.value,
  370. r = this.splineKF2.value,
  371. a = i - (this.splineKF2.frameIndex - this.splineKF0.frameIndex),
  372. o = s - (this.splineKF1.frameIndex - this.splineKF3.frameIndex),
  373. h = n - (this.splineKF2.value - this.splineKF0.value) * this.splineKF1.weighOut,
  374. l = r - (this.splineKF1.value - this.splineKF3.value) * this.splineKF2.weighIn;
  375. return 3 == this.splineKF1.interpolation && (a = i - (this.splineKF2.frameIndex - this.splineKF1.frameIndex),
  376. h = n - this.splineKF1.weighOut),
  377. 3 == this.splineKF2.interpolation && (o = s - (this.splineKF1.frameIndex - this.splineKF2.frameIndex),
  378. l = r + this.splineKF2.weighIn),
  379. a = (e - a) / (i - a),
  380. i = (e - i) / (s - i),
  381. s = (e - s) / (o - s),
  382. ((h * (1 - a) + n * a) * (1 - i) + (o = n * (1 - i) + r * i) * i) * (1 - i) + ((r * (1 - s) + l * s) * i + o * (1 - i)) * i
  383. },
  384. a.prototype.evaluate = function (e, t, i) {
  385. if (!i)
  386. return t;
  387. if (0 == this.numKeyframes)
  388. return this.lastValue = t;
  389. if (1 == this.numKeyframes)
  390. return this.lastValue = 2 == this.keyframePackingType ? i.keyframesSharedBufferFloats[this.keyframeBufferStartIndexFloat] : i.keyframesSharedBufferFloats[this.keyframeBufferStartIndexFloat + this.valueOffsetFloat];
  391. if (this.lastFramePercent == e)
  392. return this.lastValue;
  393. var s = this.keyframeBufferStartIndexFloat,
  394. n = 2 * this.keyframeBufferStartIndexFloat;
  395. if (this.lastValue = t,
  396. this.lastFramePercent = e,
  397. 2 == this.keyframePackingType) {
  398. var r = e - (t = Math.floor(e));
  399. return e >= this.numKeyframes && (t -= Math.floor(e / this.numKeyframes) * this.numKeyframes),
  400. t >= this.numKeyframes ? this.lastValue = i.keyframesSharedBufferFloats[s + (this.numKeyframes - 1)] : t < 0 ? this.lastValue = i.keyframesSharedBufferFloats[s] : 0 == r ? this.lastValue = i.keyframesSharedBufferFloats[s + t] : (e = n = i.keyframesSharedBufferFloats[s + t],
  401. ++t >= this.numKeyframes && (t -= this.numKeyframes),
  402. 0 <= t && t < this.numKeyframes ? e = n * (1 - r) + i.keyframesSharedBufferFloats[s + t] * r : i.debugString += "<br>bad lerp frame " + t + " of " + this.numKeyframes,
  403. this.lastValue = e)
  404. }
  405. var a = this.numKeyframes;
  406. r = i.keyframesSharedBufferUShorts[n + this.frameIndexOffsetUShort];
  407. if (e >= i.keyframesSharedBufferUShorts[n + (a - 1) * this.indexUShortSkip + this.frameIndexOffsetUShort])
  408. return this.lastValue = i.keyframesSharedBufferFloats[s + (a - 1) * this.indexFloatSkip + this.valueOffsetFloat];
  409. if (e < r)
  410. return this.lastValue = i.keyframesSharedBufferFloats[s + this.valueOffsetFloat];
  411. this.lastSearchIndex < this.numKeyframes && e > i.keyframesSharedBufferUShorts[n + this.lastSearchIndex * this.indexUShortSkip + this.frameIndexOffsetUShort] && (this.lastSearchIndex = 1);
  412. for (var o = this.lastSearchIndex; o < a; o++) {
  413. r = s + o * this.indexFloatSkip;
  414. var h = s + (o - 1) * this.indexFloatSkip,
  415. l = n + o * this.indexUShortSkip,
  416. d = n + (o - 1) * this.indexUShortSkip;
  417. if (e >= i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort] && e <= i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort]) {
  418. this.lastSearchIndex = o;
  419. var c = i.keyframesSharedBufferUShorts[d + this.interpolationOffsetUShort];
  420. if (2 == c) {
  421. this.lastValue = e = e >= i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort] ? i.keyframesSharedBufferFloats[r + this.valueOffsetFloat] : i.keyframesSharedBufferFloats[h + this.valueOffsetFloat];
  422. break
  423. }
  424. if (0 == c) {
  425. s = i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort],
  426. t = i.keyframesSharedBufferFloats[h + this.valueOffsetFloat],
  427. n = i.keyframesSharedBufferFloats[r + this.valueOffsetFloat],
  428. r = (e - s) / (i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort] - s),
  429. this.lastValue = e = t * (1 - r) + n * r;
  430. break
  431. }
  432. if (1 == c || 3 == c) {
  433. var u = c = !1,
  434. f = 0,
  435. m = i.keyframesSharedBufferFloats[h + this.valueOffsetFloat],
  436. p = i.keyframesSharedBufferFloats[r + this.valueOffsetFloat],
  437. g = 0,
  438. v = 0,
  439. x = (d = i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort],
  440. l = i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort],
  441. 0),
  442. y = 1,
  443. b = 1,
  444. S = 1,
  445. T = 1,
  446. w = 1,
  447. C = 1,
  448. R = 1,
  449. A = 1;
  450. 0 != this.weighInOffsetFloat && (b = i.keyframesSharedBufferFloats[h + this.weighInOffsetFloat],
  451. S = i.keyframesSharedBufferFloats[r + this.weighInOffsetFloat],
  452. C = i.keyframesSharedBufferFloats[h + this.weighOutOffsetFloat],
  453. R = i.keyframesSharedBufferFloats[r + this.weighOutOffsetFloat]),
  454. 1 < o && (c = !0,
  455. f = i.keyframesSharedBufferFloats[s + (o - 2) * this.indexFloatSkip + this.valueOffsetFloat],
  456. v = i.keyframesSharedBufferUShorts[n + (o - 2) * this.indexUShortSkip + this.frameIndexOffsetUShort],
  457. 0 != this.weighInOffsetFloat && (y = i.keyframesSharedBufferFloats[s + (o - 2) * this.indexFloatSkip + this.weighInOffsetFloat],
  458. w = i.keyframesSharedBufferFloats[s + (o - 2) * this.indexFloatSkip + this.weighOutOffsetFloat])),
  459. o < a - 1 && (u = !0,
  460. g = i.keyframesSharedBufferFloats[s + (o + 1) * this.indexFloatSkip + this.valueOffsetFloat],
  461. x = i.keyframesSharedBufferUShorts[n + (o + 1) * this.indexUShortSkip + this.frameIndexOffsetUShort],
  462. 0 != this.weighInOffsetFloat && (T = i.keyframesSharedBufferFloats[s + (o + 1) * this.indexFloatSkip + this.weighInOffsetFloat],
  463. A = i.keyframesSharedBufferFloats[s + (o + 1) * this.indexFloatSkip + this.weighOutOffsetFloat])),
  464. c && u ? (this.splineKF0.value = f,
  465. this.splineKF1.value = m,
  466. this.splineKF2.value = p,
  467. this.splineKF3.value = g,
  468. this.splineKF0.frameIndex = v,
  469. this.splineKF1.frameIndex = d,
  470. this.splineKF2.frameIndex = l,
  471. this.splineKF3.frameIndex = x,
  472. this.splineKF0.weighIn = y,
  473. this.splineKF0.weighOut = w,
  474. this.splineKF1.weighIn = b,
  475. this.splineKF1.weighOut = C,
  476. this.splineKF2.weighIn = S,
  477. this.splineKF2.weighOut = R,
  478. this.splineKF3.weighIn = T,
  479. this.splineKF3.weighOut = A) : (this.splineKF0.value = m,
  480. this.splineKF1.value = m,
  481. this.splineKF2.value = p,
  482. this.splineKF3.value = p,
  483. this.splineKF0.frameIndex = d,
  484. this.splineKF1.frameIndex = d,
  485. this.splineKF2.frameIndex = l,
  486. this.splineKF3.frameIndex = l,
  487. this.splineKF1.weighIn = b,
  488. this.splineKF2.weighIn = S,
  489. this.splineKF1.weighOut = C,
  490. this.splineKF2.weighOut = R,
  491. u ? (this.splineKF3.value = g,
  492. this.splineKF3.frameIndex = x,
  493. this.splineKF3.weighIn = T,
  494. this.splineKF3.weighOut = A) : (this.splineKF3.frameIndex++,
  495. this.splineKF3.value = this.splineKF1.value,
  496. this.splineKF3.weighIn = 1,
  497. this.splineKF3.weighOut = 1),
  498. c ? (this.splineKF0.value = f,
  499. this.splineKF0.frameIndex = v,
  500. this.splineKF0.weighIn = y,
  501. this.splineKF0.weighOut = w) : (this.splineKF0.value = this.splineKF2.value,
  502. this.splineKF0.weighIn = 1,
  503. this.splineKF0.weighOut = 1,
  504. 0 < this.splineKF0.frameIndex ? this.splineKF0.frameIndex-- : (this.splineKF1.frameIndex++,
  505. this.splineKF2.frameIndex++,
  506. this.splineKF3.frameIndex++,
  507. e++))),
  508. this.lastValue = e = this.evaluateCurve(e, t);
  509. break
  510. }
  511. }
  512. }
  513. return this.lastValue
  514. },
  515. o.prototype.getTRSValue = function (e, t, i) {
  516. return t ? (t.evaluate(e, i, this.hostObject),
  517. "" != t.debugString && (this.debugString += t.debugString),
  518. t.lastValue) : i
  519. },
  520. o.prototype.evaluateMatrix = function (e, t, i, s) {
  521. if (this.lockTransform)
  522. S.copy(e, this.cachedmatrix0);
  523. else {
  524. var n = 0,
  525. r = t = 0;
  526. n = r = t = 0,
  527. n = r = t = 1;
  528. this.hasRotation ? (n = this.getTRSValue(i, this.RX, 0),
  529. t = this.getTRSValue(i, this.RY, 0),
  530. r = this.getTRSValue(i, this.RZ, 0),
  531. s ? (this.matrix = S.rotation(S.empty(), r, 2),
  532. s = S.rotation(S.empty(), n, 0),
  533. S.mul(s, s, this.matrix),
  534. this.matrix = S.rotation(S.empty(), t, 1)) : (this.matrix = S.rotation(S.empty(), n, 0),
  535. s = S.rotation(S.empty(), t, 1),
  536. S.mul(s, s, this.matrix),
  537. this.matrix = S.rotation(S.empty(), r, 2)),
  538. S.mul(this.matrix, this.matrix, s)) : S.copy(this.matrix, S.identity()),
  539. this.hasTranslation && (t = this.getTRSValue(i, this.TX, 0),
  540. r = this.getTRSValue(i, this.TY, 0),
  541. n = this.getTRSValue(i, this.TZ, 0),
  542. this.matrix[12] = t,
  543. this.matrix[13] = r,
  544. this.matrix[14] = n),
  545. this.hasScale && (t = this.getTRSValue(i, this.SX, 1),
  546. r = this.getTRSValue(i, this.SY, 1),
  547. n = this.getTRSValue(i, this.SZ, 1),
  548. this.matrix[0] *= t,
  549. this.matrix[4] *= r,
  550. this.matrix[8] *= n,
  551. this.matrix[1] *= t,
  552. this.matrix[5] *= r,
  553. this.matrix[9] *= n,
  554. this.matrix[2] *= t,
  555. this.matrix[6] *= r,
  556. this.matrix[10] *= n,
  557. this.matrix[3] *= t,
  558. this.matrix[7] *= r,
  559. this.matrix[11] *= n),
  560. S.copy(e, this.matrix)
  561. }
  562. },
  563. o.prototype.clearCachedTransforms = function () {
  564. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -1,
  565. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  566. this.TX && (this.TX.lastFramePercent = -10),
  567. this.TY && (this.TY.lastFramePercent = -10),
  568. this.TZ && (this.TZ.lastFramePercent = -10),
  569. this.RX && (this.RX.lastFramePercent = -10),
  570. this.RY && (this.RY.lastFramePercent = -10),
  571. this.RZ && (this.RZ.lastFramePercent = -10),
  572. this.SX && (this.SX.lastFramePercent = -10),
  573. this.SY && (this.SY.lastFramePercent = -10),
  574. this.SZ && (this.SZ.lastFramePercent = -10),
  575. this.lockTransform = !1
  576. },
  577. o.prototype.getCachedTransform = function (e) {
  578. return this.lockTransform ? 0 : this.cachedFrame0 == e ? this.cachedmatrix0 : this.cachedFrame1 == e ? this.cachedmatrix1 : this.cachedFrame2 == e ? this.cachedmatrix2 : this.cachedFrame3 == e ? this.cachedmatrix3 : 0
  579. },
  580. o.prototype.getFreeCachedTransform = function (e) {
  581. return this.lockTransform ? 0 : (this.cachedFrameUse0--,
  582. this.cachedFrameUse1--,
  583. this.cachedFrameUse2--,
  584. this.cachedFrameUse3--,
  585. this.cachedFrameUse0 <= this.cachedFrameUse1 && this.cachedFrameUse0 <= this.cachedFrameUse2 && this.cachedFrameUse0 <= this.cachedFrameUse3 || this.cachedFrame0 == e ? (this.cachedFrame0 = e,
  586. this.cachedFrameUse0 = 0,
  587. this.cachedmatrix0) : this.cachedFrameUse1 <= this.cachedFrameUse0 && this.cachedFrameUse1 <= this.cachedFrameUse2 && this.cachedFrameUse1 <= this.cachedFrameUse3 || this.cachedFrame1 == e ? (this.cachedFrame1 = e,
  588. this.cachedFrameUse1 = 0,
  589. this.cachedmatrix1) : this.cachedFrameUse2 <= this.cachedFrameUse0 && this.cachedFrameUse2 <= this.cachedFrameUse1 && this.cachedFrameUse2 <= this.cachedFrameUse3 || this.cachedFrame2 == e ? (this.cachedFrame2 = e,
  590. this.cachedFrameUse2 = 0,
  591. this.cachedmatrix2) : (this.cachedFrame3 = e,
  592. this.cachedFrameUse3 = 0,
  593. this.cachedmatrix3))
  594. },
  595. c.prototype.evaluateModelPartTransformAtFrame = function (e, t, i, s) {
  596. S.copy(i, S.identity());
  597. for (var n = 0; n < 100; n++) {
  598. var r = this.animatedObjects[e];
  599. if (e == r.parentIndex)
  600. break;
  601. if (r.useFixedWorldTransform) {
  602. S.mul(i, r.cachedWorldTransform0, i);
  603. break
  604. }
  605. var a = 0;
  606. if (s && (a = r.getCachedWorldTransform(t)),
  607. a) {
  608. S.mul(i, a, i);
  609. break
  610. }
  611. a = S.identity(),
  612. r.evaluateLocalTransformAtFramePercent(t, a, !1, s),
  613. S.mul(i, a, i),
  614. e == r.parentIndex && (n = 100),
  615. e = r.parentIndex
  616. }
  617. },
  618. c.prototype.lerpModelPartTransform = function (e, t, i, s) {
  619. var n = this.animatedObjects[e];
  620. if (n.useFixedWorldTransform)
  621. S.copy(i, n.cachedWorldTransform0);
  622. else {
  623. var r = (r = t * n.modelPartFPS) - Math.floor(r),
  624. a = Math.floor(this.getObjectAnimationFramePercent(n, t)),
  625. o = a + 1,
  626. h = t = 0;
  627. for (s && (t = n.getCachedWorldTransform(a),
  628. h = n.getCachedWorldTransform(o)),
  629. t || ((t = n.getFreeCachedWorldTransform(a)) || (t = S.identity()),
  630. this.evaluateModelPartTransformAtFrame(e, a, t, s)),
  631. h || ((h = n.getFreeCachedWorldTransform(o)) || (h = S.identity()),
  632. this.evaluateModelPartTransformAtFrame(e, o, h, s)),
  633. e = 1 - r,
  634. s = 0; s < 16; s++)
  635. i[s] = t[s] * e + h[s] * r
  636. }
  637. },
  638. c.prototype.getModelPartTransform = function (e, t, i, s) {
  639. this.lerpModelPartTransform(e, t, i, s)
  640. },
  641. c.prototype.getAnimatedLocalTransform = function (e, t, i, s) {
  642. e = this.animatedObjects[e];
  643. var n = this.animatedObjects[e.parentIndex],
  644. r = n.modelPartIndex != n.id,
  645. a = S.identity();
  646. if (this.getModelPartTransform(e.modelPartIndex, t, a, s),
  647. r) {
  648. r = S.identity();
  649. var o = S.identity();
  650. this.getModelPartTransform(n.modelPartIndex, t, r, s),
  651. S.invert(o, r),
  652. S.mul(i, o, a),
  653. i[12] *= e.modelPartScale,
  654. i[13] *= e.modelPartScale,
  655. i[14] *= e.modelPartScale
  656. } else
  657. S.copy(i, a)
  658. },
  659. c.prototype.isVisibleAtFramePercent = function (e, t) {
  660. for (var i = e, s = 0, n = 0; n < 100; n++) {
  661. if ((s = this.animatedObjects[i]).visibleProperty) {
  662. if (s.visibleProperty.evaluate(t, 1, s),
  663. "" != s.debugString || "" != s.visibleProperty.debugString)
  664. return this.debugString += s.debugString,
  665. this.debugString += s.visibleProperty.debugString,
  666. !1;
  667. if (0 == s.visibleProperty.lastValue)
  668. return !1
  669. }
  670. i == s.parentIndex && (n = 100),
  671. i = s.parentIndex
  672. }
  673. return !0
  674. },
  675. c.prototype.getWorldTransform = function (e, t, i, s, n) {
  676. if ((e = this.animatedObjects[e]).useFixedWorldTransform)
  677. S.copy(i, e.cachedWorldTransform0);
  678. else {
  679. var r = this.getObjectAnimationFramePercent(e, t),
  680. a = S.identity();
  681. if (e.evaluateLocalTransformAtFramePercent(r, a, !0, n),
  682. r = e.modelPartIndex != e.id) {
  683. r = S.identity();
  684. var o = S.identity();
  685. S.copy(o, a),
  686. this.getAnimatedLocalTransform(e.id, t, r),
  687. S.mul(a, r, o)
  688. }
  689. if (S.copy(i, a),
  690. e.parentIndex != e.id)
  691. for (var h = e.parentIndex, l = 0; l < 100; l++)
  692. e = this.animatedObjects[h],
  693. r = this.getObjectAnimationFramePercent(e, t),
  694. a = S.identity(),
  695. e.evaluateLocalTransformAtFramePercent(r, a, !0, n),
  696. (r = e.modelPartIndex != e.id) ? (r = S.identity(),
  697. this.getAnimatedLocalTransform(e.id, t, r),
  698. o = S.identity(),
  699. S.mul(o, a, i),
  700. S.mul(i, r, o)) : (o = S.identity(),
  701. S.copy(o, i),
  702. S.mul(i, a, o)),
  703. h == e.parentIndex && (l = 100),
  704. h = e.parentIndex;
  705. i[12] *= s,
  706. i[13] *= s,
  707. i[14] *= s
  708. }
  709. },
  710. c.prototype.hasParentInHierarchy = function (e, t) {
  711. for (var i = e.parentIndex, s = 0; s < 100; s++) {
  712. if ((e = this.animatedObjects[i]).id == t)
  713. return !0;
  714. i == e.parentIndex && (s = 100),
  715. i = e.parentIndex
  716. }
  717. return !1
  718. },
  719. c.prototype.hasParentTypeInHierarchy = function (e, t) {
  720. for (var i = e.parentIndex, s = 0; s < 100; s++) {
  721. if ((e = this.animatedObjects[i]).sceneObjectType == t)
  722. return !0;
  723. i == e.parentIndex && (s = 100),
  724. i = e.parentIndex
  725. }
  726. return !1
  727. },
  728. c.prototype.searchAnimationUpHierarchy = function (e) {
  729. for (var t = e.id, i = 0; i < 100; i++) {
  730. if ((e = this.animatedObjects[t]).animatedLocalTransform && (e.hasAnimatedTransform() || e.id != e.modelPartIndex && this.searchAnimationUpHierarchy(this.animatedObjects[e.modelPartIndex])))
  731. return !0;
  732. t == e.parentIndex && (i = 100),
  733. t = e.parentIndex
  734. }
  735. return !1
  736. },
  737. c.prototype.hasAnimationInHierarchy = function (e) {
  738. return !!(this.searchAnimationUpHierarchy(e) || e.id != e.modelPartIndex && this.searchAnimationUpHierarchy(this.animatedObjects[e.modelPartIndex]) || this.hasParentTypeInHierarchy(e, "TurnTableSO") || this.hasParentTypeInHierarchy(e, "CameraSO") || "CameraSO" == e.sceneObjectType)
  739. },
  740. c.prototype.getObjectAnimationFramePercent = function (e, t) {
  741. if (0 == this.totalFrames || 0 == e.animationLength)
  742. return 0;
  743. var i = t / e.animationLength;
  744. i = Math.floor(i);
  745. return (i = (t -= e.animationLength * i) * e.modelPartFPS) >= e.totalFrames + 1 && (i = e.totalFrames),
  746. i
  747. },
  748. h.prototype.get = function (e) {
  749. return this.files[e]
  750. },
  751. h.prototype.extract = function (e) {
  752. var t = this.files[e];
  753. return delete this.files[e],
  754. t
  755. },
  756. h.prototype.checkSignature = function (e) {
  757. if (!e)
  758. return !1;
  759. var t = this.get(e.name + ".sig");
  760. if (!t)
  761. return !1;
  762. if (!(t = JSON.parse(String.fromCharCode.apply(null, t.data))))
  763. return !1;
  764. for (var i = 5381, s = 0; s < e.data.length; ++s)
  765. i = 33 * i + e.data[s] & 4294967295;
  766. return (e = new l()).setBytes([0, 233, 33, 170, 116, 86, 29, 195, 228, 46, 189, 3, 185, 31, 245, 19, 159, 105, 73, 190, 158, 80, 175, 38, 210, 116, 221, 229, 171, 134, 104, 144, 140, 5, 99, 255, 208, 78, 248, 215, 172, 44, 79, 83, 5, 244, 152, 19, 92, 137, 112, 10, 101, 142, 209, 100, 244, 92, 190, 125, 28, 0, 185, 54, 143, 247, 49, 37, 15, 254, 142, 180, 185, 232, 50, 219, 11, 186, 106, 116, 78, 212, 10, 105, 53, 26, 14, 181, 80, 47, 87, 213, 182, 19, 126, 151, 86, 109, 182, 224, 37, 135, 80, 59, 22, 93, 125, 68, 214, 106, 209, 152, 235, 157, 249, 245, 48, 76, 203, 0, 0, 95, 200, 246, 243, 229, 85, 79, 169], !0),
  767. (s = new l()).setBytes(t[0]),
  768. s.powmod(65537, e).toInt32() == i
  769. },
  770. h.prototype.decompress = function (e, t) {
  771. var i = new Uint8Array(t),
  772. s = 0,
  773. n = new Uint32Array(4096),
  774. r = new Uint32Array(4096),
  775. a = 256,
  776. o = e.length,
  777. h = 0,
  778. l = 1,
  779. d = 0,
  780. c = 1;
  781. i[s++] = e[0];
  782. for (var u = 1; !(o <= (c = u + (u >> 1)) + 1); u++) {
  783. d = e[c + 1],
  784. c = e[c];
  785. if ((f = 1 & u ? d << 4 | c >> 4 : (15 & d) << 8 | c) < a)
  786. if (f < 256)
  787. d = s,
  788. c = 1,
  789. i[s++] = f;
  790. else {
  791. d = s,
  792. c = r[f];
  793. for (var f, m = (f = n[f]) + c; f < m;)
  794. i[s++] = i[f++]
  795. }
  796. else {
  797. if (f != a)
  798. break;
  799. for (d = s,
  800. c = l + 1,
  801. m = (f = h) + l; f < m;)
  802. i[s++] = i[f++];
  803. i[s++] = i[h]
  804. }
  805. n[a] = h,
  806. r[a++] = l + 1,
  807. h = d,
  808. l = c,
  809. a = 4096 <= a ? 256 : a
  810. }
  811. return s == t ? i : null
  812. },
  813. l.prototype.setBytes = function (e, t) {
  814. var i = (e.length + 1) / 2 | 0;
  815. if (this.digits = new Uint16Array(i),
  816. t) {
  817. var s = 0;
  818. for (i = e.length - 1; 0 <= i; i -= 2)
  819. this.digits[s++] = e[i] + (0 < i ? 256 * e[i - 1] : 0)
  820. } else
  821. for (s = 0; s < i; ++s)
  822. this.digits[s] = e[2 * s] + 256 * e[2 * s + 1];
  823. this.trim()
  824. },
  825. l.prototype.toInt32 = function () {
  826. var e = 0;
  827. return 0 < this.digits.length && (e = this.digits[0],
  828. 1 < this.digits.length && (e |= this.digits[1] << 16)),
  829. e
  830. },
  831. l.prototype.lessThan = function (e) {
  832. if (this.digits.length == e.digits.length)
  833. for (var t = this.digits.length - 1; 0 <= t; --t) {
  834. var i = this.digits[t],
  835. s = e.digits[t];
  836. if (i != s)
  837. return i < s
  838. }
  839. return this.digits.length < e.digits.length
  840. },
  841. l.prototype.shiftRight = function () {
  842. for (var e = 0, t = this.digits, i = t.length - 1; 0 <= i; --i) {
  843. var s = t[i];
  844. t[i] = s >> 1 | e << 15,
  845. e = s
  846. }
  847. this.trim()
  848. },
  849. l.prototype.shiftLeft = function (e) {
  850. if (0 < e) {
  851. for (var t = e / 16 | 0, i = 16 - (e %= 16), s = this.digits.length + t + 1, n = new l(s), r = 0; r < s; ++r)
  852. n.digits[r] = 65535 & ((r < t || r >= this.digits.length + t ? 0 : this.digits[r - t]) << e | (r < 1 + t ? 0 : this.digits[r - t - 1]) >>> i);
  853. return n.trim(),
  854. n
  855. }
  856. return new l(this)
  857. },
  858. l.prototype.bitCount = function () {
  859. var e = 0;
  860. if (0 < this.digits.length) {
  861. e = 16 * (this.digits.length - 1);
  862. for (var t = this.digits[this.digits.length - 1]; t;)
  863. t >>>= 1,
  864. ++e
  865. }
  866. return e
  867. },
  868. l.prototype.sub = function (e) {
  869. var t = this.digits,
  870. i = e.digits,
  871. s = this.digits.length;
  872. e = e.digits.length;
  873. for (var n = 0, r = 0; r < s; ++r) {
  874. var a, o = (o = t[r]) + ((n = o < (a = (a = r < e ? i[r] : 0) + n) ? 1 : 0) << 16);
  875. t[r] = o - a & 65535
  876. }
  877. this.trim()
  878. },
  879. l.prototype.mul = function (e) {
  880. for (var t = new l(this.digits.length + e.digits.length), i = t.digits, s = 0; s < this.digits.length; ++s)
  881. for (var n = this.digits[s], r = 0; r < e.digits.length; ++r)
  882. for (var a = n * e.digits[r], o = s + r; a;) {
  883. var h = (65535 & a) + i[o];
  884. i[o] = 65535 & h,
  885. a >>>= 16,
  886. a += h >>> 16,
  887. ++o
  888. }
  889. return t.trim(),
  890. t
  891. },
  892. l.prototype.mod = function (e) {
  893. if (this.digits.length <= 0 || e.digits.length <= 0)
  894. return new l(0);
  895. var t = new l(this.digits);
  896. if (!this.lessThan(e)) {
  897. for (var i = (i = new l(e.digits)).shiftLeft(t.bitCount() - i.bitCount()); !t.lessThan(e);)
  898. i.lessThan(t) && t.sub(i),
  899. i.shiftRight();
  900. t.trim()
  901. }
  902. return t
  903. },
  904. l.prototype.powmod = function (e, t) {
  905. for (var i = new l([1]), s = this.mod(t); e;)
  906. 1 & e && (i = i.mul(s).mod(t)),
  907. e >>>= 1,
  908. s = s.mul(s).mod(t);
  909. return i
  910. },
  911. l.prototype.trim = function () {
  912. for (var e = this.digits.length; 0 < e && 0 == this.digits[e - 1];)
  913. --e;
  914. e != this.digits.length && (this.digits = this.digits.subarray(0, e))
  915. },
  916. p.prototype.setBackground3x1 = function (e, t, i, s, n, r, a) {
  917. this.backgroundOffsetX = t,
  918. this.backgroundOffsetY = i,
  919. this.edgePixelsX = a,
  920. this.backgroundLeft = e.addImage(s),
  921. this.backgroundMiddle = e.addImage(n),
  922. this.backgroundRight = e.addImage(r),
  923. this.backgroundLeft.linkedControl.style.zIndex = "0",
  924. this.backgroundMiddle.linkedControl.style.zIndex = "0",
  925. this.backgroundRight.linkedControl.style.zIndex = "0",
  926. this.setOpacity(this.defaultAlpha)
  927. },
  928. p.prototype.setBackground3x3 = function (e, t, i, s, n, r, a, o, h, l, d, c, u, f) {
  929. this.backgroundOffsetX = t,
  930. this.backgroundOffsetY = i,
  931. this.edgePixelsX = u,
  932. this.edgePixelsY = f,
  933. this.backgroundTopLeft = e.addImage(s),
  934. this.backgroundMiddleLeft = e.addImage(a),
  935. this.backgroundBottomLeft = e.addImage(l),
  936. this.backgroundTopMiddle = e.addImage(n),
  937. this.backgroundMiddleMiddle = e.addImage(o),
  938. this.backgroundBottomMiddle = e.addImage(d),
  939. this.backgroundTopRight = e.addImage(r),
  940. this.backgroundMiddleRight = e.addImage(h),
  941. this.backgroundBottomRight = e.addImage(c),
  942. this.backgroundTopLeft.linkedControl.style.zIndex = "0",
  943. this.backgroundTopRight.linkedControl.style.zIndex = "0",
  944. this.backgroundTopMiddle.linkedControl.style.zIndex = "0",
  945. this.backgroundMiddleLeft.linkedControl.style.zIndex = "0",
  946. this.backgroundMiddleRight.linkedControl.style.zIndex = "0",
  947. this.backgroundMiddleMiddle.linkedControl.style.zIndex = "0",
  948. this.backgroundBottomLeft.linkedControl.style.zIndex = "0",
  949. this.backgroundBottomRight.linkedControl.style.zIndex = "0",
  950. this.backgroundBottomMiddle.linkedControl.style.zIndex = "0",
  951. this.setOpacity(this.defaultAlpha)
  952. },
  953. p.prototype.alignBackground = function () {
  954. var e = (n = (s = this.controlRect).guiScreen).left * (1 - s.getScreenXPercent()),
  955. t = n.bottom * (1 - s.getScreenYPercent()),
  956. i = n.width * s.getScreenWidthPercent(),
  957. s = n.height * s.getScreenHeightPercent();
  958. t += this.backgroundOffsetY,
  959. e += this.backgroundOffsetX;
  960. if (this.backgroundTopLeft && this.backgroundTopRight && this.backgroundTopMiddle && this.backgroundMiddleLeft && this.backgroundMiddleRight && this.backgroundMiddleMiddle && this.backgroundBottomLeft && this.backgroundBottomRight && this.backgroundBottomMiddle) {
  961. var n = i - 2 * this.edgePixelsX,
  962. r = s - 2 * this.edgePixelsY;
  963. this.backgroundTopLeft.linkedControl.style.height = this.edgePixelsY + "px",
  964. this.backgroundTopMiddle.linkedControl.style.height = this.edgePixelsY + "px",
  965. this.backgroundTopRight.linkedControl.style.height = this.edgePixelsY + "px",
  966. this.backgroundBottomLeft.linkedControl.style.height = this.edgePixelsY + "px",
  967. this.backgroundBottomMiddle.linkedControl.style.height = this.edgePixelsY + "px",
  968. this.backgroundBottomRight.linkedControl.style.height = this.edgePixelsY + "px",
  969. this.backgroundMiddleLeft.linkedControl.style.height = r + "px",
  970. this.backgroundMiddleMiddle.linkedControl.style.height = r + "px",
  971. this.backgroundMiddleRight.linkedControl.style.height = r + "px",
  972. this.backgroundTopLeft.linkedControl.style.width = this.edgePixelsX + "px",
  973. this.backgroundBottomLeft.linkedControl.style.width = this.edgePixelsX + "px",
  974. this.backgroundMiddleLeft.linkedControl.style.width = this.edgePixelsX + "px",
  975. this.backgroundTopRight.linkedControl.style.width = this.edgePixelsX + "px",
  976. this.backgroundBottomRight.linkedControl.style.width = this.edgePixelsX + "px",
  977. this.backgroundMiddleRight.linkedControl.style.width = this.edgePixelsX + "px",
  978. this.backgroundTopMiddle.linkedControl.style.width = n + "px",
  979. this.backgroundBottomMiddle.linkedControl.style.width = n + "px",
  980. this.backgroundMiddleMiddle.linkedControl.style.width = n + "px",
  981. this.backgroundTopLeft.linkedControl.style.left = e + "px",
  982. this.backgroundBottomLeft.linkedControl.style.left = e + "px",
  983. this.backgroundMiddleLeft.linkedControl.style.left = e + "px",
  984. e += this.edgePixelsX,
  985. this.backgroundTopMiddle.linkedControl.style.left = e + "px",
  986. this.backgroundBottomMiddle.linkedControl.style.left = e + "px",
  987. this.backgroundMiddleMiddle.linkedControl.style.left = e + "px",
  988. e += n,
  989. this.backgroundTopRight.linkedControl.style.left = e + "px",
  990. this.backgroundBottomRight.linkedControl.style.left = e + "px",
  991. this.backgroundMiddleRight.linkedControl.style.left = e + "px",
  992. this.backgroundBottomLeft.linkedControl.style.bottom = t + "px",
  993. this.backgroundBottomMiddle.linkedControl.style.bottom = t + "px",
  994. this.backgroundBottomRight.linkedControl.style.bottom = t + "px",
  995. t += this.edgePixelsY,
  996. this.backgroundMiddleLeft.linkedControl.style.bottom = t + "px",
  997. this.backgroundMiddleRight.linkedControl.style.bottom = t + "px",
  998. this.backgroundMiddleMiddle.linkedControl.style.bottom = t + "px",
  999. t += r,
  1000. this.backgroundTopLeft.linkedControl.style.bottom = t + "px",
  1001. this.backgroundTopMiddle.linkedControl.style.bottom = t + "px",
  1002. this.backgroundTopRight.linkedControl.style.bottom = t + "px"
  1003. }
  1004. this.backgroundLeft && this.backgroundRight && this.backgroundMiddle && (i -= 2 * this.edgePixelsX,
  1005. this.backgroundLeft.linkedControl.style.bottom = t + "px",
  1006. this.backgroundMiddle.linkedControl.style.bottom = t + "px",
  1007. this.backgroundRight.linkedControl.style.bottom = t + "px",
  1008. this.backgroundLeft.linkedControl.style.height = s + "px",
  1009. this.backgroundMiddle.linkedControl.style.height = s + "px",
  1010. this.backgroundRight.linkedControl.style.height = s + "px",
  1011. this.backgroundLeft.linkedControl.style.width = this.edgePixelsX + "px",
  1012. this.backgroundMiddle.linkedControl.style.width = i + "px",
  1013. this.backgroundRight.linkedControl.style.width = this.edgePixelsX + "px",
  1014. this.backgroundLeft.linkedControl.style.left = e + "px",
  1015. e += this.edgePixelsX,
  1016. this.backgroundMiddle.linkedControl.style.left = e + "px",
  1017. this.backgroundRight.linkedControl.style.left = e + i + "px")
  1018. },
  1019. p.prototype.setOpacity = function (e) {
  1020. this.controlRect.linkedControl.style.opacity = e,
  1021. this.backgroundLeft && (this.backgroundLeft.linkedControl.style.opacity = e),
  1022. this.backgroundRight && (this.backgroundRight.linkedControl.style.opacity = e),
  1023. this.backgroundMiddle && (this.backgroundMiddle.linkedControl.style.opacity = e),
  1024. this.backgroundTopLeft && (this.backgroundTopLeft.linkedControl.style.opacity = e),
  1025. this.backgroundTopRight && (this.backgroundTopRight.linkedControl.style.opacity = e),
  1026. this.backgroundTopMiddle && (this.backgroundTopMiddle.linkedControl.style.opacity = e),
  1027. this.backgroundMiddleLeft && (this.backgroundMiddleLeft.linkedControl.style.opacity = e),
  1028. this.backgroundMiddleRight && (this.backgroundMiddleRight.linkedControl.style.opacity = e),
  1029. this.backgroundMiddleMiddle && (this.backgroundMiddleMiddle.linkedControl.style.opacity = e),
  1030. this.backgroundBottomLeft && (this.backgroundBottomLeft.linkedControl.style.opacity = e),
  1031. this.backgroundBottomRight && (this.backgroundBottomRight.linkedControl.style.opacity = e),
  1032. this.backgroundBottomMiddle && (this.backgroundBottomMiddle.linkedControl.style.opacity = e)
  1033. },
  1034. p.prototype.setBackgroundVisible = function (e) {
  1035. this.backgroundLeft && this.backgroundLeft.showControl(e),
  1036. this.backgroundRight && this.backgroundRight.showControl(e),
  1037. this.backgroundMiddle && this.backgroundMiddle.showControl(e),
  1038. this.backgroundTopLeft && this.backgroundTopLeft.showControl(e),
  1039. this.backgroundTopRight && this.backgroundTopRight.showControl(e),
  1040. this.backgroundTopMiddle && this.backgroundTopMiddle.showControl(e),
  1041. this.backgroundMiddleLeft && this.backgroundMiddleLeft.showControl(e),
  1042. this.backgroundMiddleRight && this.backgroundMiddleRight.showControl(e),
  1043. this.backgroundMiddleMiddle && this.backgroundMiddleMiddle.showControl(e),
  1044. this.backgroundBottomLeft && this.backgroundBottomLeft.showControl(e),
  1045. this.backgroundBottomRight && this.backgroundBottomRight.showControl(e),
  1046. this.backgroundBottomMiddle && this.backgroundBottomMiddle.showControl(e)
  1047. },
  1048. p.prototype.setVisible = function (e) {
  1049. this.controlRect.showControl(e),
  1050. this.setBackgroundVisible(e)
  1051. },
  1052. p.prototype.linkControl = function (e) {
  1053. (this.controlRect.linkedControl = e).onmouseover = function () {
  1054. this.updateAlphas && (this.setOpacity(this.focusAlpha),
  1055. this.controlRect.mouseOver = !0,
  1056. this.linkedBackground && this.linkedBackground.setOpacity(this.focusAlpha))
  1057. }
  1058. .bind(this),
  1059. e.onmouseout = function () {
  1060. this.updateAlphas && (this.setOpacity(this.defaultAlpha),
  1061. this.controlRect.mouseOver = !1,
  1062. this.linkedBackground && this.linkedBackground.setOpacity(this.defaultAlpha))
  1063. }
  1064. .bind(this)
  1065. },
  1066. u.prototype.empty = function () {
  1067. return this.bytes.length <= 0
  1068. },
  1069. u.prototype.readCString = function () {
  1070. for (var e = this.bytes, t = e.length, i = 0; i < t; ++i)
  1071. if (0 == e[i])
  1072. return e = String.fromCharCode.apply(null, this.bytes.subarray(0, i)),
  1073. this.bytes = this.bytes.subarray(i + 1),
  1074. e;
  1075. return null
  1076. },
  1077. u.prototype.asString = function () {
  1078. for (var e = "", t = 0; t < this.bytes.length; ++t)
  1079. e += String.fromCharCode(this.bytes[t]);
  1080. return e
  1081. },
  1082. u.prototype.readBytes = function (e) {
  1083. var t = this.bytes.subarray(0, e);
  1084. return this.bytes = this.bytes.subarray(e),
  1085. t
  1086. },
  1087. u.prototype.readUint32 = function () {
  1088. var e = this.bytes,
  1089. t = e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24;
  1090. return this.bytes = e.subarray(4),
  1091. t
  1092. },
  1093. u.prototype.readUint8 = function () {
  1094. var e = this.bytes,
  1095. t = e[0];
  1096. return this.bytes = e.subarray(1),
  1097. t
  1098. },
  1099. u.prototype.readUint16 = function () {
  1100. var e = this.bytes,
  1101. t = e[0] | e[1] << 8;
  1102. return this.bytes = e.subarray(2),
  1103. t
  1104. },
  1105. u.prototype.readFloat32 = function () {
  1106. var e = new Uint8Array(this.bytes);
  1107. e = new Float32Array(e.buffer);
  1108. return this.bytes = this.bytes.subarray(4),
  1109. e[0]
  1110. },
  1111. u.prototype.seekUint32 = function (e) {
  1112. return (e = this.bytes.subarray(4 * e))[0] | e[1] << 8 | e[2] << 16 | e[3] << 24
  1113. },
  1114. u.prototype.seekFloat32 = function (e) {
  1115. return e = new Uint8Array(this.bytes.subarray(4 * e)),
  1116. new Float32Array(e.buffer)[0]
  1117. },
  1118. u.prototype.getMatrix = function (e) {
  1119. return new Float32Array(this.bytes.buffer, 64 * e, 16)
  1120. },
  1121. s.prototype.getScreenWidth = function () {
  1122. if (this.linkedControl)
  1123. return this.guiScreen.width * this.getScreenWidthPercent()
  1124. },
  1125. s.prototype.getScreenHeight = function () {
  1126. if (this.linkedControl)
  1127. return this.guiScreen.height * this.getScreenHeightPercent()
  1128. },
  1129. s.prototype.updateElement = function () {
  1130. var e = this.linkedControl;
  1131. if (e) {
  1132. var t = this.guiScreen.left * (1 - this.getScreenXPercent()),
  1133. i = this.guiScreen.bottom * (1 - this.getScreenYPercent()),
  1134. s = this.guiScreen.width * this.getScreenWidthPercent(),
  1135. n = this.guiScreen.height * this.getScreenHeightPercent();
  1136. e.style.left = t + "px",
  1137. e.style.bottom = i + "px",
  1138. e.style.width = s + "px",
  1139. e.style.height = n + "px"
  1140. }
  1141. },
  1142. s.prototype.updateElement = function () {
  1143. var e = this.linkedControl;
  1144. if (e) {
  1145. var t = this.guiScreen.left * (1 - this.getScreenXPercent()),
  1146. i = this.guiScreen.bottom * (1 - this.getScreenYPercent()),
  1147. s = this.guiScreen.width * this.getScreenWidthPercent(),
  1148. n = this.guiScreen.height * this.getScreenHeightPercent();
  1149. e.style.left = t + "px",
  1150. e.style.bottom = i + "px",
  1151. e.style.width = s + "px",
  1152. e.style.height = n + "px"
  1153. }
  1154. },
  1155. s.prototype.updateChildElements = function () {
  1156. this.updateElement();
  1157. for (var e = 0; e < this.childControlRects.length; e++)
  1158. this.childControlRects[e].updateChildElements()
  1159. },
  1160. s.prototype.set = function (e, t, i, s) {
  1161. this.xPercent = e,
  1162. this.yPercent = t,
  1163. this.widthPercent = i,
  1164. this.heightPercent = s
  1165. },
  1166. s.prototype.linkControl = function (e) {
  1167. (this.linkedControl = e).onmouseover = function () {
  1168. this.mouseOver = !0
  1169. }
  1170. .bind(this),
  1171. e.onmouseout = function () {
  1172. this.mouseOver = !1
  1173. }
  1174. .bind(this),
  1175. e.onmousedown = function () {
  1176. this.mouseDown = !0
  1177. }
  1178. .bind(this),
  1179. e.onmouseup = function () {
  1180. this.mouseDown = !1
  1181. }
  1182. .bind(this),
  1183. e.onclick = function () {
  1184. this.callBack && this.callBack(this),
  1185. this.clicked = !0
  1186. }
  1187. .bind(this)
  1188. },
  1189. s.prototype.showControl = function (e) {
  1190. this.visible = e,
  1191. this.linkedControl && (this.linkedControl.style.display = e ? "block" : "none")
  1192. },
  1193. s.prototype.setOpacity = function (e) {
  1194. this.opacity = e,
  1195. this.linkedControl && (this.linkedControl.style.opacity = e)
  1196. },
  1197. s.prototype.hasChildControlRect = function (e) {
  1198. for (var t = 0; t < this.childControlRects.length; t++)
  1199. if (this.childControlRects[t] == e)
  1200. return !0;
  1201. return !1
  1202. },
  1203. s.prototype.registerChildControlRect = function (e) {
  1204. this.hasChildControlRect(e) || (this.childControlRects.push(e),
  1205. e.parentControlRect = this)
  1206. },
  1207. s.prototype.getScreenWidthPercent = function () {
  1208. var e = this.widthPercent;
  1209. return this.parentControlRect && (e *= this.parentControlRect.getScreenWidthPercent()),
  1210. e
  1211. },
  1212. s.prototype.getScreenHeightPercent = function () {
  1213. var e = this.heightPercent;
  1214. return this.parentControlRect && (e *= this.parentControlRect.getScreenHeightPercent()),
  1215. e
  1216. },
  1217. s.prototype.getScreenXPercent = function () {
  1218. var e = this.xPercent;
  1219. return this.parentControlRect && (e *= this.parentControlRect.getScreenWidthPercent(),
  1220. e += this.parentControlRect.getScreenXPercent()),
  1221. e
  1222. },
  1223. s.prototype.getScreenYPercent = function () {
  1224. var e = this.yPercent;
  1225. return this.parentControlRect && (e *= this.parentControlRect.getScreenHeightPercent(),
  1226. e += this.parentControlRect.getScreenYPercent()),
  1227. e
  1228. };
  1229. function n(e, t, i, s) {
  1230. var n = !1,
  1231. r = e + (-1 == e.indexOf("?") ? "?" : "&") + "thumb=1",
  1232. a = function (e) {
  1233. return (e = new h(e).extract("thumbnail.jpg")) ? N.parseFile(e, t, s) : n ? i && i() : (n = !0,
  1234. C.fetchBinaryIncremental(r, a, i, 394240)),
  1235. 0
  1236. };
  1237. C.fetchBinaryIncremental(r, a, i, 65536)
  1238. }
  1239. function f(e, t) {
  1240. this.desc = t,
  1241. this.gl = e,
  1242. this.iblShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", ["#define FOG_IBL"]);
  1243. var i = ["#define FOG_DIR"];
  1244. this.dirShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1245. i.push("#define FOG_SHADOWS"),
  1246. this.dirShaderShadow = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1247. i = ["#define FOG_SPOT"],
  1248. this.spotShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1249. i.push("#define FOG_SHADOWS"),
  1250. this.spotShaderShadow = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1251. i = ["#define FOG_OMNI"],
  1252. this.omniShaderShadow = this.omniShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1253. this.fullscreenTriangle = e.createBuffer(),
  1254. e.bindBuffer(e.ARRAY_BUFFER, this.fullscreenTriangle),
  1255. i = new Float32Array([0, 0, 2, 0, 0, 2]),
  1256. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  1257. e.bindBuffer(e.ARRAY_BUFFER, null)
  1258. }
  1259. function m(e, t) {
  1260. this.gl = e,
  1261. this.fbo = e.createFramebuffer(),
  1262. e.bindFramebuffer(e.FRAMEBUFFER, this.fbo),
  1263. t && (this.width = t.width,
  1264. this.height = t.height,
  1265. t.color0 && (this.color0 = t.color0,
  1266. e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, this.color0.id, 0),
  1267. this.width = t.color0.desc.width,
  1268. this.height = t.color0.desc.height),
  1269. t.depth ? (this.depth = t.depth,
  1270. e.framebufferTexture2D(e.FRAMEBUFFER, e.DEPTH_ATTACHMENT, e.TEXTURE_2D, this.depth.id, 0)) : (this.depthBuffer = t.depthBuffer,
  1271. t.createDepth && !this.depthBuffer && (this.depthBuffer = m.createDepthBuffer(e, this.width, this.height)),
  1272. this.depthBuffer && (e.bindRenderbuffer(e.RENDERBUFFER, this.depthBuffer),
  1273. e.framebufferRenderbuffer(e.FRAMEBUFFER, e.DEPTH_ATTACHMENT, e.RENDERBUFFER, this.depthBuffer),
  1274. e.bindRenderbuffer(e.RENDERBUFFER, null)))),
  1275. this.valid = t && t.ignoreStatus || e.checkFramebufferStatus(e.FRAMEBUFFER) == e.FRAMEBUFFER_COMPLETE,
  1276. e.bindFramebuffer(e.FRAMEBUFFER, null)
  1277. }
  1278. (I = void 0 === I ? {} : I).embed = function (e, t) {
  1279. var i, s = (t = function (e) {
  1280. if (e = e || {},
  1281. document.location.search)
  1282. for (var t = document.location.search.substring(1).split("&"), i = 0; i < t.length; ++i) {
  1283. var s = t[i].split("=");
  1284. e[s[0]] = s[1]
  1285. }
  1286. return t = function (e) {
  1287. if (0 | e)
  1288. return !0;
  1289. for (var t = "true True TRUE yes Yes YES".split(" "), i = 0; i < t.length; ++i)
  1290. if (e === t[i])
  1291. return !0;
  1292. return !1
  1293. },
  1294. e.width = e.width || 800,
  1295. e.height = e.height || 600,
  1296. e.autoStart = t(e.autoStart),
  1297. e.pagePreset = t(e.pagePreset),
  1298. e.fullFrame = t(e.fullFrame) || t(e.bare),
  1299. e.fullFrame = !e.pagePreset && e.fullFrame,
  1300. e
  1301. }(t)).thumbnailURL;
  1302. if (t.pagePreset) {
  1303. i = new W(t.width, t.height, e, !!s),
  1304. document.body.style.backgroundColor = "#d7e4da";
  1305. var n = document.createElement("div");
  1306. n.style.position = "relative",
  1307. n.style.backgroundColor = "#e4e7e4",
  1308. n.style.width = t.width + 12 + "px",
  1309. n.style.height = t.height + 6 + 16 + "px",
  1310. n.style.margin = "auto",
  1311. n.style.boxShadow = "3px 5px 12px 0px grey",
  1312. document.body.appendChild(n);
  1313. var r = document.createElement("div");
  1314. if (r.style.position = "relative",
  1315. r.style.left = "6px",
  1316. r.style.top = "6px",
  1317. n.appendChild(r),
  1318. r.appendChild(i.domRoot),
  1319. !i.mobile) {
  1320. n.style.resize = "both",
  1321. n.style.overflow = "hidden";
  1322. var a = [n.style.width, n.style.height],
  1323. o = function () {
  1324. g.active() ? n.style.resize = "none" : (n.style.resize = "both",
  1325. a[0] == n.style.width && a[1] == n.style.height || (a[0] = n.style.width,
  1326. a[1] = n.style.height,
  1327. i.resize(n.clientWidth - 12, n.clientHeight - 6 - 16))),
  1328. window.setTimeout(o, 100)
  1329. };
  1330. o()
  1331. }
  1332. } else
  1333. i = new W(t.fullFrame ? window.innerWidth : t.width, t.fullFrame ? window.innerHeight : t.height, e, !!s),
  1334. document.body.appendChild(i.domRoot),
  1335. t.fullFrame && (i.domRoot.style.position = "absolute",
  1336. i.domRoot.style.left = i.domRoot.style.top = 0,
  1337. window.addEventListener("resize", function () {
  1338. g.active() || i.resize(this.document.body.clientWidth, this.document.body.clientHeight)
  1339. }));
  1340. return (webview = i).ui.setThumbnailURL(s),
  1341. t.autoStart && i.loadScene(),
  1342. i
  1343. },
  1344. I.fetchThumbnail = n,
  1345. f.prototype.draw = function (e, t) {
  1346. var i = this.gl,
  1347. s = e.view,
  1348. n = s.projectionMatrix,
  1349. r = S.empty();
  1350. S.mul(r, s.viewMatrix, s.projectionMatrix),
  1351. S.invert(r, s.viewProjectionMatrix),
  1352. r = [n[10] + n[11], -n[14], -2 * n[11]],
  1353. n = [-2 / n[0], -2 / n[5], (1 - n[8]) / n[0], (1 - n[9]) / n[5]],
  1354. i.enable(i.BLEND),
  1355. i.blendFunc(i.ONE, i.ONE_MINUS_SRC_ALPHA);
  1356. for (var a = 0; a < e.lights.count + 1; ++a) {
  1357. var o, h = a - 1,
  1358. l = h < e.lights.shadowCount;
  1359. (o = 0 == a ? this.iblShader : 0 < e.lights.spot[3 * h] ? l ? this.spotShaderShadow : this.spotShader : 0 < e.lights.getLightPos(h)[3] ? this.omniShader : l ? this.dirShaderShadow : this.dirShader).bind();
  1360. var d = o.params;
  1361. if (i.uniform3fv(d.uDepthToZ, r),
  1362. i.uniform4fv(d.uUnproject, n),
  1363. i.uniformMatrix4fv(d.uInvViewMatrix, !1, s.transform),
  1364. i.uniform1f(d.uFogInvDistance, 1 / this.desc.distance),
  1365. i.uniform1f(d.uFogOpacity, this.desc.opacity * (1 - e.stripData.activeFade())),
  1366. i.uniform1f(d.uFogDispersion, 1 - this.desc.dispersion),
  1367. (u = [0, 0, 0])[this.desc.type] = 1,
  1368. i.uniform3fv(d.uFogType, u),
  1369. i.uniform3fv(d.uFogColor, this.desc.color),
  1370. i.uniform1f(d.uFogIllum, 0 == a ? this.desc.skyIllum : this.desc.lightIllum),
  1371. i.uniformMatrix4fv(d.uLightMatrix, !1, e.lights.invMatrix),
  1372. 0 == a) {
  1373. for (h = new Float32Array(e.sky.diffuseCoefficients),
  1374. l = 4; l < 16; ++l)
  1375. h[l] *= 1 - this.desc.dispersion;
  1376. for (l = 16; l < 36; ++l)
  1377. h[l] *= 1 - this.desc.dispersion * this.desc.dispersion;
  1378. i.uniform4fv(d.uFogLightSphere, h)
  1379. } else {
  1380. var c = e.lights.getLightPos(h),
  1381. u = (c = S.mul4(V.empty(), e.lights.invMatrix, c[0], c[1], c[2], c[3]),
  1382. e.lights.getLightDir(h));
  1383. u = S.mulVec(V.empty(), e.lights.invMatrix, u[0], u[1], u[2]);
  1384. i.uniform4fv(d.uLightPosition, c),
  1385. i.uniform3fv(d.uLightColor, e.lights.getColor(h));
  1386. c = .01745329251 * e.lights.spot[3 * h];
  1387. var f = Math.cos(.5 * c);
  1388. i.uniform4fv(d.uSpotParams, [-u[0], -u[1], -u[2], 0 < c ? f * f : 0]),
  1389. i.uniform4fv(d.uLightAttenuation, [e.lights.parameters[3 * h + 0], e.lights.parameters[3 * h + 1], e.lights.parameters[3 * h + 2], f]),
  1390. l && (l = S.mul(S.empty(), e.lights.finalTransformBuffer.subarray(16 * h), e.lights.matrix),
  1391. i.uniformMatrix4fv(d.uShadowProj, !1, l),
  1392. e.shadow.depthTextures[h].bind(o.samplers.uShadowMap),
  1393. h = 0,
  1394. 1 < e.postRender.sampleCount && (h = e.postRender.currentSample() / e.postRender.sampleCount),
  1395. i.uniform1f(d.uDitherOffset, h),
  1396. i.uniform3fv(d.uAABBMin, e.bounds.min),
  1397. i.uniform3fv(d.uAABBMax, e.bounds.max),
  1398. h = V.lerp(V.empty(), e.bounds.min, e.bounds.max, .5),
  1399. l = V.distance(h, e.bounds.min),
  1400. i.uniform4f(d.uCylinder, h[0], h[1], h[2], l * l))
  1401. }
  1402. t.bind(o.samplers.tDepth),
  1403. o = o.attribs.vCoord,
  1404. i.bindBuffer(i.ARRAY_BUFFER, this.fullscreenTriangle),
  1405. i.enableVertexAttribArray(o),
  1406. i.vertexAttribPointer(o, 2, i.FLOAT, !1, 0, 0),
  1407. i.drawArrays(i.TRIANGLES, 0, 3),
  1408. i.disableVertexAttribArray(o),
  1409. i.bindBuffer(i.ARRAY_BUFFER, null)
  1410. }
  1411. i.disable(i.BLEND)
  1412. },
  1413. f.prototype.complete = function () {
  1414. return this.iblShader.complete() && this.dirShader.complete() && this.dirShaderShadow.complete() && this.spotShader.complete() && this.spotShaderShadow.complete() && this.omniShader.complete() && this.omniShaderShadow.complete()
  1415. },
  1416. m.createDepthBuffer = function (e, t, i) {
  1417. var s = e.createRenderbuffer();
  1418. return e.bindRenderbuffer(e.RENDERBUFFER, s),
  1419. e.renderbufferStorage(e.RENDERBUFFER, e.DEPTH_COMPONENT16, t, i),
  1420. e.bindRenderbuffer(e.RENDERBUFFER, null),
  1421. s
  1422. },
  1423. m.prototype.bind = function () {
  1424. this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.fbo),
  1425. this.gl.viewport(0, 0, this.width, this.height)
  1426. },
  1427. m.bindNone = function (e) {
  1428. e.bindFramebuffer(e.FRAMEBUFFER, null)
  1429. };
  1430. var g = {
  1431. support: function () {
  1432. return !!(document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled)
  1433. },
  1434. begin: function (e, t) {
  1435. var i = e.requestFullscreen || e.webkitRequestFullScreen || e.mozRequestFullScreen || e.msRequestFullscreen;
  1436. if (i) {
  1437. var s = function () {
  1438. g.active() || (document.removeEventListener("fullscreenchange", s),
  1439. document.removeEventListener("webkitfullscreenchange", s),
  1440. document.removeEventListener("mozfullscreenchange", s),
  1441. document.removeEventListener("MSFullscreenChange", s)),
  1442. t && t()
  1443. };
  1444. document.addEventListener("fullscreenchange", s),
  1445. document.addEventListener("webkitfullscreenchange", s),
  1446. document.addEventListener("mozfullscreenchange", s),
  1447. document.addEventListener("MSFullscreenChange", s),
  1448. i.bind(e)()
  1449. }
  1450. },
  1451. end: function () {
  1452. var e = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen;
  1453. e && e.bind(document)()
  1454. },
  1455. active: function () {
  1456. return !!(document.fullscreenElement || document.webkitIsFullScreen || document.mozFullScreenElement || document.msFullscreenElement)
  1457. }
  1458. };
  1459. function v(e) {
  1460. this.debugString = "GUIRegion",
  1461. this.name = "Default",
  1462. this.controlRect = new s(e),
  1463. this.yPercent = this.xPercent = 0,
  1464. this.heightPercent = this.widthPercent = 1,
  1465. this.guiScreen = e
  1466. }
  1467. function t(e) {
  1468. this.init = !1,
  1469. this.ui = e,
  1470. this.bottom = this.left = this.height = this.width = 0,
  1471. this.clicked = this.mouseDown = !1,
  1472. this.playbackControls = 0,
  1473. e = 1,
  1474. window.devicePixelRatio && (2 < window.devicePixelRatio ? e = 4 : 1 < window.devicePixelRatio && (e = 2)),
  1475. this.imageSetNumber = e
  1476. }
  1477. function e(e) {
  1478. this.onTap = [],
  1479. this.onSingleTap = [],
  1480. this.onDoubleTap = [],
  1481. this.onDrag = [],
  1482. this.onZoom = [],
  1483. this.onPan = [],
  1484. this.onPan2 = [],
  1485. this.onAnything = [],
  1486. this.mouseDownCount = 0,
  1487. this.macHax = 0 <= navigator.platform.toUpperCase().indexOf("MAC"),
  1488. e && this.attach(e)
  1489. }
  1490. function i(e, t) {
  1491. e && t ? (this.frameIndex = t.frameIndex,
  1492. this.value = t.value,
  1493. this.interpolation = t.interpolation,
  1494. this.weighIn = t.weighIn,
  1495. this.weighOut = t.weighOut) : (this.interpolation = this.value = this.frameIndex = 0,
  1496. this.weighOut = this.weighIn = 1)
  1497. }
  1498. function x(e, t) {
  1499. for (var i in this.rotation = this.shadowCount = this.count = 0,
  1500. this.positions = [],
  1501. this.directions = [],
  1502. this.matrixWeights = [],
  1503. this.matrix = S.identity(),
  1504. this.invMatrix = S.identity(),
  1505. this.defaultmatrix = S.identity(),
  1506. this.defaultviewmatrix = S.identity(),
  1507. e)
  1508. this[i] = e[i];
  1509. this.count = this.positions.length / 4,
  1510. this.count = Math.min(6, this.count),
  1511. this.shadowCount = Math.min(3, this.shadowCount),
  1512. this.positions = new Float32Array(this.positions),
  1513. this.positionBuffer = new Float32Array(this.positions),
  1514. this.directions = new Float32Array(this.directions),
  1515. this.directionBuffer = new Float32Array(this.directions),
  1516. this.colors = new Float32Array(this.colors),
  1517. this.colorsBuffer = new Float32Array(this.colors),
  1518. this.modelViewBuffer = new Float32Array(16 * this.shadowCount),
  1519. this.projectionBuffer = new Float32Array(16 * this.shadowCount),
  1520. this.finalTransformBuffer = new Float32Array(16 * this.shadowCount),
  1521. this.inverseTransformBuffer = new Float32Array(16 * this.shadowCount),
  1522. this.shadowTexelPadProjections = new Float32Array(4 * this.shadowCount),
  1523. this.shadowsNeedUpdate = new Uint8Array(this.shadowCount);
  1524. for (var s = 0; s < this.shadowsNeedUpdate.length; ++s)
  1525. this.shadowsNeedUpdate[s] = 1;
  1526. for (S.rotation(this.matrix, this.rotation, 1),
  1527. S.transpose(this.invMatrix, this.matrix),
  1528. S.copy(this.defaultmatrix, this.matrix),
  1529. S.copy(this.defaultviewmatrix, t.viewMatrix),
  1530. s = 0; s < this.count; ++s) {
  1531. i = this.positions.subarray(4 * s, 4 * s + 4);
  1532. var n = this.directions.subarray(3 * s, 3 * s + 3);
  1533. 1 == this.matrixWeights[s] ? (S.mul4(i, this.matrix, i[0], i[1], i[2], i[3]),
  1534. S.mulVec(n, this.matrix, n[0], n[1], n[2])) : 2 == this.matrixWeights[s] && (S.mul4(i, t.viewMatrix, i[0], i[1], i[2], i[3]),
  1535. S.mulVec(n, t.viewMatrix, n[0], n[1], n[2]))
  1536. }
  1537. }
  1538. function y(e) {
  1539. this.name = "none",
  1540. this.text = "default text",
  1541. this.title = "none",
  1542. this.debugString = this.imagePath = "",
  1543. this.controlRect = new s(e),
  1544. this.textEntries = [],
  1545. this.textOffsetsX = [],
  1546. this.textOffsetsY = [],
  1547. this.buttons = [],
  1548. this.listBoxEntryHeight = 20,
  1549. this.selectedItemText = "",
  1550. this.selectedIndex = -1,
  1551. this.localPixelsY = 0,
  1552. this.localPixelsX = 100,
  1553. this.labelPixelDrop = 0,
  1554. this.labelPixelInset = 10,
  1555. this.labelTextHeight = 16,
  1556. this.closed = !1,
  1557. this.defaultButtonText = this.spacerMiddle = this.spacerRight = this.spacerLeft = this.spacerControl = 0,
  1558. this.listBoxButtons = [],
  1559. this.listBoxRegion = new v(e),
  1560. this.guiScreen = e,
  1561. this.lastMouseOverIndex = -1,
  1562. this.selectionChangedCallback = 0,
  1563. this.debugString = ""
  1564. }
  1565. function b(e, t, i) {
  1566. this.gl = e,
  1567. this.name = i.name;
  1568. var s = {
  1569. mipmap: !0,
  1570. aniso: e.hints.mobile ? 0 : 4,
  1571. clamp: !!i.textureWrapClamp,
  1572. mirror: !!i.textureWrapMirror
  1573. },
  1574. n = {
  1575. mipmap: s.mipmap,
  1576. clamp: s.clamp,
  1577. mirror: s.mirror,
  1578. nofilter: i.textureFilterNearest || !1
  1579. };
  1580. if (n.nofilter || (n.aniso = e.hints.mobile ? 2 : 4),
  1581. this.textures = {
  1582. albedo: e.textureCache.fromFilesMergeAlpha(t.get(i.albedoTex), t.get(i.alphaTex), n),
  1583. reflectivity: e.textureCache.fromFilesMergeAlpha(t.get(i.reflectivityTex), t.get(i.glossTex), s),
  1584. normal: e.textureCache.fromFile(t.get(i.normalTex), s),
  1585. extras: e.textureCache.fromFilesMergeAlpha(t.get(i.extrasTex), t.get(i.extrasTexA), s)
  1586. },
  1587. this.extrasTexCoordRanges = {},
  1588. i.extrasTexCoordRanges)
  1589. for (var r in i.extrasTexCoordRanges)
  1590. this.extrasTexCoordRanges[r] = new Float32Array(i.extrasTexCoordRanges[r].scaleBias);
  1591. this.textures.extras || ((t = new U(e, {
  1592. width: 1,
  1593. height: 1
  1594. })).loadArray(new Uint8Array([255, 255, 255, 255])),
  1595. this.textures.extras = t);
  1596. var a = i.blendTint || [1, 1, 1];
  1597. t = {
  1598. none: function () {
  1599. e.disable(e.BLEND)
  1600. },
  1601. alpha: function () {
  1602. e.enable(e.BLEND),
  1603. e.blendFuncSeparate(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA, e.ONE_MINUS_DST_ALPHA, e.ONE)
  1604. },
  1605. add: function () {
  1606. e.enable(e.BLEND),
  1607. e.blendColor(a[0], a[1], a[2], 1),
  1608. e.blendFunc(e.ONE, e.CONSTANT_COLOR)
  1609. }
  1610. },
  1611. this.blend = t[i.blend] || t.none,
  1612. this.alphaTest = i.alphaTest || 0,
  1613. this.usesBlending = this.blend !== t.none,
  1614. this.usesRefraction = !!i.refraction,
  1615. this.shadowAlphaTest = this.alphaTest,
  1616. this.shadowAlphaTest <= 0 && this.blend === t.alpha && (this.shadowAlphaTest = .5),
  1617. this.castShadows = this.blend !== t.add,
  1618. this.horizonOcclude = i.horizonOcclude || 0,
  1619. this.fresnel = new Float32Array(i.fresnel ? i.fresnel : [1, 1, 1]),
  1620. this.emissiveIntensity = i.emissiveIntensity || 1,
  1621. n = !(s = []),
  1622. 0 < i.lightCount && s.push("#define LIGHT_COUNT " + i.lightCount),
  1623. 0 < i.shadowCount && (r = Math.min(i.lightCount, i.shadowCount),
  1624. this.usesRefraction && e.limits.textureCount <= 8 && (r = 2 < r ? 2 : r),
  1625. s.push("#define SHADOW_COUNT " + r)),
  1626. 0 < i.alphaTest && s.push("#define ALPHA_TEST"),
  1627. this.blend === t.alpha ? s.push("#define TRANSPARENCY_DITHER") : this.blend === t.none && s.push("#define NOBLEND"),
  1628. e.hints.mobile && s.push("#define MOBILE"),
  1629. e.ext.textureDepth && s.push("#define SHADOW_NATIVE_DEPTH"),
  1630. r = function (e) {
  1631. return 1 / (2 / 3 * 3.1415962 * (e * e + e + 1))
  1632. },
  1633. i.useSkin && (s.push("#define SKIN"),
  1634. this.skinParams = i.skinParams || {
  1635. subdermisColor: [1, 1, 1],
  1636. transColor: [1, 0, 0, 1],
  1637. fresnelColor: [.2, .2, .2, .5],
  1638. fresnelOcc: 1,
  1639. fresnelGlossMask: 1,
  1640. transSky: .5,
  1641. shadowBlur: .5,
  1642. normalSmooth: .5,
  1643. transScatter: 0,
  1644. transDepth: 0,
  1645. millimeterScale: 1
  1646. },
  1647. this.extrasTexCoordRanges.subdermisTex || s.push("#define SKIN_NO_SUBDERMIS_TEX"),
  1648. this.extrasTexCoordRanges.translucencyTex || s.push("#define SKIN_NO_TRANSLUCENCY_TEX"),
  1649. this.extrasTexCoordRanges.fuzzTex || s.push("#define SKIN_NO_FUZZ_TEX"),
  1650. void 0 === this.skinParams.version && (this.skinParams.version = 1),
  1651. 2 == this.skinParams.version ? (s.push("#define SKIN_VERSION_2"),
  1652. this.skinParams.shadowBlur *= 4,
  1653. this.skinParams.shadowBlur = Math.min(this.skinParams.shadowBlur, 40),
  1654. this.skinParams.transIntegral = r(.5 * this.skinParams.transScatter),
  1655. this.skinParams.fresnelIntegral = 1 / 3.14159 * (1 - .5 * this.skinParams.fresnelColor[3]),
  1656. this.skinParams.transSky = 0) : (s.push("#define SKIN_VERSION_1"),
  1657. this.skinParams.shadowBlur = 8 * Math.min(this.skinParams.shadowBlur, 1),
  1658. this.skinParams.transDepth = 0,
  1659. this.skinParams.transScatter = this.skinParams.transColor[3],
  1660. this.skinParams.transIntegral = 1 / 3.14159 * (1 - .5 * this.skinParams.transScatter),
  1661. this.skinParams.fresnelIntegral = 1 / 3.14159 * (1 - .5 * this.skinParams.fresnelColor[3]),
  1662. this.skinParams.transSky *= 1.25,
  1663. this.skinParams.transIntegral *= 1.25)),
  1664. i.aniso && (s.push("#define ANISO"),
  1665. this.anisoParams = i.anisoParams || {
  1666. strength: 1,
  1667. tangent: [1, 0, 0],
  1668. integral: .5
  1669. },
  1670. this.extrasTexCoordRanges.anisoTex || s.push("#define ANISO_NO_DIR_TEX")),
  1671. i.microfiber && (s.push("#define MICROFIBER"),
  1672. this.microfiberParams = i.microfiberParams || {
  1673. fresnelColor: [.2, .2, .2, .5],
  1674. fresnelOcc: 1,
  1675. fresnelGlossMask: 1
  1676. },
  1677. this.microfiberParams.fresnelIntegral = 1 / 3.14159 * (1 - .5 * this.microfiberParams.fresnelColor[3]),
  1678. this.extrasTexCoordRanges.fuzzTex || s.push("#define MICROFIBER_NO_FUZZ_TEX")),
  1679. i.refraction && (s.push("#define REFRACTION"),
  1680. this.refractionParams = i.refractionParams || {
  1681. distantBackground: !1,
  1682. tint: [1, 1, 1],
  1683. useAlbedoTint: !1,
  1684. IOR: 1.5
  1685. },
  1686. this.extrasTexCoordRanges.refractionMaskTex || s.push("#define REFRACTION_NO_MASK_TEX")),
  1687. i.vertexColor && (s.push("#define VERTEX_COLOR"),
  1688. i.vertexColorsRGB && s.push("#define VERTEX_COLOR_SRGB"),
  1689. i.vertexColorAlpha && s.push("#define VERTEX_COLOR_ALPHA")),
  1690. this.horizonSmoothing = i.horizonSmoothing || 0,
  1691. 0 < this.horizonSmoothing && s.push("#define HORIZON_SMOOTHING"),
  1692. i.unlitDiffuse && s.push("#define DIFFUSE_UNLIT"),
  1693. this.extrasTexCoordRanges.emissiveTex && (s.push("#define EMISSIVE"),
  1694. i.emissiveSecondaryUV && (s.push("#define EMISSIVE_SECONDARY_UV"),
  1695. n = !0)),
  1696. this.extrasTexCoordRanges.aoTex && (s.push("#define AMBIENT_OCCLUSION"),
  1697. i.aoSecondaryUV && (s.push("#define AMBIENT_OCCLUSION_SECONDARY_UV"),
  1698. n = !0)),
  1699. i.tangentOrthogonalize && s.push("#define TSPACE_ORTHOGONALIZE"),
  1700. i.tangentNormalize && s.push("#define TSPACE_RENORMALIZE"),
  1701. i.tangentGenerateBitangent && s.push("#define TSPACE_COMPUTE_BITANGENT"),
  1702. n && s.push("#define TEXCOORD_SECONDARY"),
  1703. this.vOffset = this.uOffset = 0,
  1704. s.push("#define UV_OFFSET "),
  1705. this.shader = e.shaderCache.fromURLs("matvert.glsl", "matfrag.glsl", s),
  1706. s.push("#define STRIPVIEW"),
  1707. this.stripShader = e.shaderCache.fromURLs("matvert.glsl", "matfrag.glsl", s),
  1708. this.wireShader = e.shaderCache.fromURLs("wirevert.glsl", "wirefrag.glsl"),
  1709. this.blend === t.alpha && (this.prepassShader = e.shaderCache.fromURLs("alphaprepassvert.glsl", "alphaprepassfrag.glsl"))
  1710. }
  1711. v.prototype.addImageElement = function (e, t) {
  1712. var i = this.guiScreen.ui.menuCluster.contents,
  1713. s = document.createElement("input");
  1714. e.linkControl(s),
  1715. this.guiScreen.updateElement(e),
  1716. s.type = "image",
  1717. s.src = I.dataLocale + t,
  1718. s.style.position = "absolute",
  1719. s.style.border = "none",
  1720. s.style.outline = "0px",
  1721. s.style.zIndex = "1",
  1722. s.title = t,
  1723. s.style.opacity = e.opacity;
  1724. var n = new XMLHttpRequest();
  1725. return n.open("HEAD", s.src, !0),
  1726. n.onload = function (e) {
  1727. e.appendChild(this)
  1728. }
  1729. .bind(s, i),
  1730. n.send(),
  1731. s
  1732. },
  1733. v.prototype.addImage = function (e) {
  1734. var t = new s(this.guiScreen);
  1735. return this.addImageElement(t, e),
  1736. t
  1737. },
  1738. v.prototype.addTextButton = function (e, t, i, s, n, r) {
  1739. var a = new p(this.guiScreen);
  1740. return a.name = "none",
  1741. a.text = e,
  1742. a.controlRect.set(t, i, s, n),
  1743. a.controlRect.opacity = r,
  1744. this.controlRect.registerChildControlRect(a.controlRect),
  1745. t = this.guiScreen.ui.menuCluster.contents,
  1746. (i = document.createElement("text")).style.color = "white",
  1747. i.style.fontFamily = "Arial",
  1748. i.style.fontSize = I.largeUI ? "14px" : "12px",
  1749. i.style.textShadow = "2px 2px 3px #000000",
  1750. t.appendChild(i),
  1751. a.controlRect.linkControl(i),
  1752. this.guiScreen.updateElement(a.controlRect),
  1753. i.type = "text",
  1754. i.name = "text",
  1755. i.style.position = "absolute",
  1756. i.style.border = "none",
  1757. i.style.outline = "0px",
  1758. i.style.zIndex = "2",
  1759. i.innerHTML = e,
  1760. i.style.opacity = a.controlRect.opacity,
  1761. a.linkControl(i),
  1762. a
  1763. },
  1764. t.prototype.setSize = function (e, t) {
  1765. this.width = e,
  1766. this.height = t,
  1767. this.left = -e,
  1768. this.bottom = -t,
  1769. this.playbackControls && this.playbackControls.resize(this)
  1770. },
  1771. t.prototype.setupActiveView = function (e) {
  1772. this.init || (this.init = !0,
  1773. (this.ui = e).viewer.scene.sceneAnimator && (this.playbackControls = new R(this),
  1774. this.playbackControls.resize(this)))
  1775. },
  1776. t.prototype.updateElement = function (e) {
  1777. var t = e.linkedControl;
  1778. if (t) {
  1779. var i = this.left * (1 - e.getScreenXPercent()),
  1780. s = this.bottom * (1 - e.getScreenYPercent()),
  1781. n = this.width * e.getScreenWidthPercent();
  1782. e = this.height * e.getScreenHeightPercent(),
  1783. t.style.left = i + "px",
  1784. t.style.bottom = s + "px",
  1785. t.style.width = n + "px",
  1786. t.style.height = e + "px"
  1787. }
  1788. },
  1789. e.prototype.attach = function (e) {
  1790. this.element = e;
  1791. var m = function (e) {
  1792. for (var t = 0; t < this.onAnything.length; ++t)
  1793. this.onAnything[t]();
  1794. e.preventDefault()
  1795. }
  1796. .bind(this);
  1797. this.mouseStates = [{
  1798. pressed: !1,
  1799. position: [0, 0],
  1800. downPosition: [0, 0]
  1801. }, {
  1802. pressed: !1,
  1803. position: [0, 0],
  1804. downPosition: [0, 0]
  1805. }, {
  1806. pressed: !1,
  1807. position: [0, 0],
  1808. downPosition: [0, 0]
  1809. }],
  1810. this.lastTapPos = [0, 0],
  1811. e = function (e) {
  1812. if (e.target === this.element) {
  1813. this.mouseDownCount++;
  1814. var t = this.mouseStates[e.button];
  1815. if (t) {
  1816. t.pressed = !0;
  1817. var i = this.element.getBoundingClientRect();
  1818. t.position[0] = t.downPosition[0] = e.clientX - i.left,
  1819. t.position[1] = t.downPosition[1] = e.clientY - i.top,
  1820. m(e)
  1821. }
  1822. }
  1823. }
  1824. .bind(this),
  1825. this.element.addEventListener("mousedown", e),
  1826. e = function (e) {
  1827. var t = this.mouseStates[e.button];
  1828. if (t) {
  1829. var i = this.element.getBoundingClientRect(),
  1830. s = e.clientX - i.left;
  1831. i = e.clientY - i.top;
  1832. if (t.pressed = !1,
  1833. t.position[0] = s,
  1834. t.position[1] = i,
  1835. 0 == e.button && e.target == this.element && Math.abs(t.position[0] - t.downPosition[0]) + Math.abs(t.position[1] - t.downPosition[1]) < 10) {
  1836. for (var n = 0; n < this.onTap.length; ++n)
  1837. this.onTap[n](s, i);
  1838. if (this.needSingleClick = !0,
  1839. window.setTimeout(function (e, t) {
  1840. if (this.needSingleClick) {
  1841. for (var i = 0; i < this.onSingleTap.length; ++i)
  1842. this.onSingleTap[i](e, t);
  1843. this.needSingleClick = !1
  1844. }
  1845. }
  1846. .bind(this, s, i), 301),
  1847. t = !1,
  1848. void 0 !== this.doubleClickTimer && (n = Math.abs(s - this.lastTapPos[0]) + Math.abs(i - this.lastTapPos[1]) < 8,
  1849. Date.now() - this.doubleClickTimer < 300 && n))
  1850. for (t = !0,
  1851. this.needSingleClick = !1,
  1852. n = 0; n < this.onDoubleTap.length; ++n)
  1853. this.onDoubleTap[n](s, i);
  1854. this.doubleClickTimer = Date.now(),
  1855. t && (this.doubleClickTimer = -1e9),
  1856. this.lastTapPos[0] = s,
  1857. this.lastTapPos[1] = i
  1858. }
  1859. }
  1860. m(e)
  1861. }
  1862. .bind(this),
  1863. this.element.addEventListener("mouseup", e),
  1864. e = function (e) {
  1865. for (var t = !1, i = this.element.getBoundingClientRect(), s = 0; s < 3; ++s) {
  1866. var n = this.mouseStates[s];
  1867. if (n.pressed) {
  1868. webview.stopRotate();
  1869. t = e.clientX - i.left;
  1870. var r = e.clientY - i.top,
  1871. a = t - n.position[0],
  1872. o = r - n.position[1];
  1873. if (n.position[0] = t,
  1874. n.position[1] = r,
  1875. 2 == s && e.altKey)
  1876. for (n = 0; n < this.onZoom.length; ++n)
  1877. this.onZoom[n](2 * o);
  1878. else if (1 <= s || e.ctrlKey)
  1879. for (n = 0; n < this.onPan.length; ++n)
  1880. this.onPan[n](a, o);
  1881. else if (0 == s)
  1882. if (e.shiftKey)
  1883. for (n = 0; n < this.onPan2.length; ++n)
  1884. this.onPan2[n](a, o);
  1885. else
  1886. for (n = 0; n < this.onDrag.length; ++n)
  1887. this.onDrag[n](t, r, a, o);
  1888. t = !0
  1889. }
  1890. }
  1891. t && m(e)
  1892. }
  1893. .bind(this),
  1894. this.element.addEventListener("mousemove", e),
  1895. e = function (e) {
  1896. var t = 0;
  1897. e.deltaY ? (t = -.4 * e.deltaY,
  1898. 1 == e.deltaMode ? t *= 16 : 2 == e.deltaMode && (t *= this.element.clientHeight)) : e.wheelDelta ? t = this.macHax && 120 == Math.abs(e.wheelDelta) ? .08 * e.wheelDelta : .4 * e.wheelDelta : e.detail && (t = -10 * e.detail);
  1899. for (var i = 0; i < this.onZoom.length; ++i)
  1900. this.onZoom[i](t);
  1901. m(e)
  1902. }
  1903. .bind(this),
  1904. this.element.addEventListener("mousewheel", e),
  1905. this.element.addEventListener("DOMMouseScroll", e),
  1906. this.element.addEventListener("wheel", e),
  1907. e = function (e) {
  1908. for (var t = 0; t < this.mouseStates.length; ++t)
  1909. this.mouseStates[t].pressed = !1;
  1910. e.preventDefault()
  1911. }
  1912. .bind(this),
  1913. this.element.addEventListener("mouseleave", e),
  1914. this.element.addEventListener("contextmenu", function (e) {
  1915. e.preventDefault()
  1916. }),
  1917. this.touches = {},
  1918. this.tapPossible = !1,
  1919. this.touchCountFloor = 0,
  1920. e = function (e) {
  1921. for (var t = this.element.getBoundingClientRect(), i = !1, s = 0; s < e.changedTouches.length; ++s)
  1922. if (e.target === this.element) {
  1923. var n = e.changedTouches[s];
  1924. (i = {
  1925. x: n.clientX - t.left,
  1926. y: n.clientY - t.top
  1927. }).startX = i.x,
  1928. i.startY = i.y,
  1929. this.touches[n.identifier] = i,
  1930. i = !0
  1931. }
  1932. for (this.tapPossible = 1 == e.touches.length,
  1933. n = t = 0; n < this.touches.length; ++n)
  1934. t++;
  1935. t > this.touchCountFloor && (this.touchCountFloor = t),
  1936. i && m(e)
  1937. }
  1938. .bind(this),
  1939. this.element.addEventListener("touchstart", e),
  1940. e = function (e) {
  1941. for (var t = !1, i = 0; i < e.changedTouches.length; ++i) {
  1942. var s = e.changedTouches[i],
  1943. n = this.touches[s.identifier];
  1944. if (n) {
  1945. if (this.tapPossible) {
  1946. var r = this.element.getBoundingClientRect();
  1947. t = s.clientX - r.left,
  1948. r = s.clientY - r.top;
  1949. if (Math.max(Math.abs(t - n.startX), Math.abs(r - n.startY)) < 24) {
  1950. for (i = 0; i < this.onTap.length; ++i)
  1951. this.onTap[i](t, r);
  1952. if (this.needSingleTap = !0,
  1953. window.setTimeout(function (e, t) {
  1954. if (this.needSingleTap) {
  1955. for (var i = 0; i < this.onSingleTap.length; ++i)
  1956. this.onSingleTap[i](e, t);
  1957. this.needSingleTap = !1
  1958. }
  1959. }
  1960. .bind(this, t, r), 501),
  1961. n = !1,
  1962. void 0 !== this.doubleTapTimer) {
  1963. var a = Math.max(Math.abs(t - this.lastTapPos[0]), Math.abs(r - this.lastTapPos[1])) < 24,
  1964. o = Date.now() - this.doubleTapTimer < 500;
  1965. if (a && o)
  1966. for (n = !0,
  1967. i = 0; i < this.onDoubleTap.length; ++i)
  1968. this.onDoubleTap[i](t, r)
  1969. }
  1970. this.doubleTapTimer = Date.now(),
  1971. n && (this.doubleTapTimer = -1e9),
  1972. this.lastTapPos[0] = t,
  1973. this.lastTapPos[1] = r
  1974. }
  1975. this.tapPossible = !1
  1976. }
  1977. delete this.touches[s.identifier],
  1978. t = !0
  1979. }
  1980. }
  1981. for (s = i = 0; s < this.touches.length; ++s)
  1982. i++;
  1983. i <= 0 && (this.touchCountFloor = 0),
  1984. t && m(e)
  1985. }
  1986. .bind(this),
  1987. this.element.addEventListener("touchend", e),
  1988. this.element.addEventListener("touchcancel", e),
  1989. this.element.addEventListener("touchleave", e),
  1990. e = function (e) {
  1991. webview.stopRotate();
  1992. for (var t = [], i = 0; i < e.touches.length; ++i)
  1993. e.touches[i].target === this.element && t.push(e.touches[i]);
  1994. var s = this.element.getBoundingClientRect();
  1995. if (1 == t.length && this.touchCountFloor <= 1) {
  1996. var n = t[0],
  1997. r = this.touches[n.identifier];
  1998. if (r) {
  1999. var a = n.clientX - s.left,
  2000. o = (n = n.clientY - s.top,
  2001. s = a - r.x,
  2002. n - r.y);
  2003. for (r.x = a,
  2004. r.y = n,
  2005. i = 0; i < this.onDrag.length; ++i)
  2006. this.onDrag[i](a, n, s, o, e.shiftKey)
  2007. }
  2008. } else if (2 == t.length && this.touchCountFloor <= 2) {
  2009. if (o = t[0],
  2010. i = this.touches[o.identifier],
  2011. n = t[1],
  2012. r = this.touches[n.identifier],
  2013. i && r) {
  2014. a = o.clientX - s.left,
  2015. o = o.clientY - s.top;
  2016. var h = n.clientX - s.left,
  2017. l = n.clientY - s.top,
  2018. d = Math.sqrt((a - h) * (a - h) + (o - l) * (o - l)),
  2019. c = Math.sqrt((i.x - r.x) * (i.x - r.x) + (i.y - r.y) * (i.y - r.y)),
  2020. u = Math.abs(d - c),
  2021. f = (s = (a - i.x + h - r.x) / 2,
  2022. n = (o - i.y + l - r.y) / 2,
  2023. Math.sqrt(s * s + n * n));
  2024. if (i.x = a,
  2025. i.y = o,
  2026. r.x = h,
  2027. r.y = l,
  2028. 0 < u)
  2029. for (r = u / (u + f),
  2030. i = 0; i < this.onZoom.length; ++i)
  2031. this.onZoom[i](2 * (d - c) * r);
  2032. if (0 < f)
  2033. for (r = f / (u + f),
  2034. i = 0; i < this.onDrag.length; ++i)
  2035. this.onPan[i](s * r, n * r)
  2036. }
  2037. } else if (3 <= t.length) {
  2038. for (i = c = d = h = o = 0; i < t.length; ++i)
  2039. n = t[i],
  2040. r = this.touches[n.identifier],
  2041. d += a = n.clientX - s.left,
  2042. c += n = n.clientY - s.top,
  2043. r && (o += r.x,
  2044. h += r.y,
  2045. r.x = a,
  2046. r.y = n);
  2047. for (o /= t.length,
  2048. h /= t.length,
  2049. d /= t.length,
  2050. c /= t.length,
  2051. i = 0; i < this.onPan2.length; ++i)
  2052. this.onPan2[i](d - o, c - h)
  2053. }
  2054. 0 < t.length && m(e)
  2055. }
  2056. .bind(this),
  2057. this.element.addEventListener("touchmove", e)
  2058. },
  2059. x.prototype.getLightPos = function (e) {
  2060. return this.positionBuffer.subarray(4 * e, 4 * e + 4)
  2061. },
  2062. x.prototype.setLightDistance = function (e, t) {
  2063. t <= 0 && (t = 1e-5),
  2064. this.parameters[3 * e + 2] = 1 / t
  2065. },
  2066. x.prototype.setLightSpotAngle = function (e, t) {
  2067. t <= 0 && (t = 1e-6),
  2068. this.spot[3 * e] = t;
  2069. var i = Math.sin(3.1415926 / 180 * t / 2);
  2070. this.spot[3 * e + 2] = 1 / (i * i) * this.spot[3 * e + 1]
  2071. },
  2072. x.prototype.setLightSpotSharpness = function (e, t) {
  2073. this.spot[3 * e + 1] = t,
  2074. this.setLightSpotAngle(this.spot[3 * e])
  2075. },
  2076. x.prototype.setLightPos = function (e, t) {
  2077. this.positions[4 * e + 0] = t[0],
  2078. this.positions[4 * e + 1] = t[1],
  2079. this.positions[4 * e + 2] = t[2];
  2080. var i = this.positions.subarray(4 * e, 4 * e + 4);
  2081. 1 == this.matrixWeights[e] ? S.mul4(i, this.defaultmatrix, t[0], t[1], t[2], i[3]) : 2 == this.matrixWeights[e] && S.mul4(i, this.defaultviewmatrix, t[0], t[1], t[2], i[3])
  2082. },
  2083. x.prototype.setLightDir = function (e, t) {
  2084. this.directions[3 * e + 0] = t[0],
  2085. this.directions[3 * e + 1] = t[1],
  2086. this.directions[3 * e + 2] = t[2];
  2087. var i = this.directions.subarray(3 * e, 3 * e + 3);
  2088. 1 == this.matrixWeights[e] ? S.mulVec(i, this.defaultmatrix, t[0], t[1], t[2]) : 2 == this.matrixWeights[e] && S.mulVec(i, this.defaultviewmatrix, t[0], t[1], t[2])
  2089. },
  2090. x.prototype.getLightColor = function (e) {
  2091. return this.colors.subarray(3 * e, 3 * e + 3)
  2092. },
  2093. x.prototype.setLightColor = function (e, t) {
  2094. this.colors[3 * e + 0] = t[0],
  2095. this.colors[3 * e + 1] = t[1],
  2096. this.colors[3 * e + 2] = t[2]
  2097. },
  2098. x.prototype.getLightDir = function (e) {
  2099. return this.directionBuffer.subarray(3 * e, 3 * e + 3)
  2100. },
  2101. x.prototype.getColor = function (e) {
  2102. return e *= 3,
  2103. [this.colors[e], this.colors[e + 1], this.colors[e + 2]]
  2104. },
  2105. x.prototype.update = function (e, t) {
  2106. var i = new S.type(this.matrix);
  2107. S.rotation(this.matrix, this.rotation, 1),
  2108. S.transpose(this.invMatrix, this.matrix);
  2109. for (var s = 0; s < this.count; ++s) {
  2110. var n = this.positions.subarray(4 * s, 4 * s + 4),
  2111. r = this.directions.subarray(3 * s, 3 * s + 3),
  2112. a = this.getLightPos(s),
  2113. o = this.getLightDir(s);
  2114. 1 == this.matrixWeights[s] ? (a[0] = n[0],
  2115. a[1] = n[1],
  2116. a[2] = n[2],
  2117. a[3] = n[3],
  2118. o[0] = r[0],
  2119. o[1] = r[1],
  2120. o[2] = r[2]) : 2 == this.matrixWeights[s] ? (S.mul4(a, e.transform, n[0], n[1], n[2], n[3]),
  2121. S.mulVec(o, e.transform, r[0], r[1], r[2]),
  2122. S.mul4(a, this.matrix, a[0], a[1], a[2], a[3]),
  2123. S.mulVec(o, this.matrix, o[0], o[1], o[2])) : (S.mul4(a, this.matrix, n[0], n[1], n[2], n[3]),
  2124. S.mulVec(o, this.matrix, r[0], r[1], r[2])),
  2125. V.normalize(o, o)
  2126. }
  2127. r = new Float32Array(this.finalTransformBuffer),
  2128. a = S.empty(),
  2129. o = S.empty();
  2130. var h = S.empty(),
  2131. l = V.empty(),
  2132. d = V.empty(),
  2133. c = V.empty(),
  2134. u = V.empty(),
  2135. f = (n = V.empty(),
  2136. []),
  2137. m = [],
  2138. p = S.create(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1);
  2139. for (s = 0; s < this.count; ++s) {
  2140. for (l = this.getLightPos(s),
  2141. d = this.getLightDir(s),
  2142. .99 < Math.abs(d[1]) ? V.set(c, 1, 0, 0) : V.set(c, 0, 1, 0),
  2143. V.cross(u, c, d),
  2144. V.normalize(u, u),
  2145. V.cross(c, d, u),
  2146. V.normalize(c, c),
  2147. S.set(a, u[0], u[1], u[2], -V.dot(u, l), c[0], c[1], c[2], -V.dot(c, l), d[0], d[1], d[2], -V.dot(d, l), 0, 0, 0, 1),
  2148. l = 0; l < 8; ++l)
  2149. n[0] = 1 & l ? t.max[0] : t.min[0],
  2150. n[1] = 2 & l ? t.max[1] : t.min[1],
  2151. n[2] = 4 & l ? t.max[2] : t.min[2],
  2152. S.mulPoint(n, this.matrix, 1.005 * n[0], 1.005 * n[1], 1.005 * n[2]),
  2153. S.mulPoint(n, a, n[0], n[1], n[2]),
  2154. 0 == l ? (f[0] = m[0] = n[0],
  2155. f[1] = m[1] = n[1],
  2156. f[2] = m[2] = n[2]) : (f[0] = Math.min(f[0], n[0]),
  2157. f[1] = Math.min(f[1], n[1]),
  2158. f[2] = Math.min(f[2], n[2]),
  2159. m[0] = Math.max(m[0], n[0]),
  2160. m[1] = Math.max(m[1], n[1]),
  2161. m[2] = Math.max(m[2], n[2]));
  2162. l = -f[2],
  2163. d = -m[2];
  2164. var g = this.spot[3 * s];
  2165. 0 < g ? (l = Math.min(l, 1 / this.parameters[3 * s + 2]),
  2166. d = Math.max(.04 * l, d),
  2167. S.perspective(o, g, 1, d, l),
  2168. s < this.shadowCount && (l = 2 * -Math.tan(.00872664625 * g),
  2169. this.shadowTexelPadProjections[4 * s + 0] = this.modelViewBuffer[16 * s + 2] * l,
  2170. this.shadowTexelPadProjections[4 * s + 1] = this.modelViewBuffer[16 * s + 6] * l,
  2171. this.shadowTexelPadProjections[4 * s + 2] = this.modelViewBuffer[16 * s + 10] * l,
  2172. this.shadowTexelPadProjections[4 * s + 3] = this.modelViewBuffer[16 * s + 14] * l)) : (S.ortho(o, f[0], m[0], f[1], m[1], d, l),
  2173. s < this.shadowCount && (this.shadowTexelPadProjections[4 * s + 0] = this.shadowTexelPadProjections[4 * s + 1] = this.shadowTexelPadProjections[4 * s + 2] = 0,
  2174. this.shadowTexelPadProjections[4 * s + 3] = Math.max(m[0] - f[0], m[1] - f[1]))),
  2175. S.mul(h, o, a),
  2176. S.mul(h, p, h),
  2177. S.copyToBuffer(this.modelViewBuffer, 16 * s, a),
  2178. S.copyToBuffer(this.projectionBuffer, 16 * s, o),
  2179. S.copyToBuffer(this.finalTransformBuffer, 16 * s, h),
  2180. S.invert(h, h),
  2181. S.copyToBuffer(this.inverseTransformBuffer, 16 * s, h)
  2182. }
  2183. for (n = !1,
  2184. s = 0; s < i.length; ++s)
  2185. if (i[s] != this.matrix[s]) {
  2186. n = !0;
  2187. break
  2188. }
  2189. for (s = 0; s < this.shadowCount; s++)
  2190. if (n && 1 == this.matrixWeights[s])
  2191. this.shadowsNeedUpdate[s] = 1;
  2192. else
  2193. for (i = 16 * s; i < 16 * s + 16; ++i)
  2194. if (r[i] != this.finalTransformBuffer[i]) {
  2195. this.shadowsNeedUpdate[s] = 1;
  2196. break
  2197. }
  2198. },
  2199. x.prototype.flagUpdateAnimatedLighting = function () {
  2200. for (var e = 0; e < this.shadowCount; e++)
  2201. this.shadowsNeedUpdate[e] = 1
  2202. },
  2203. y.prototype.linkControl = function (e) {
  2204. this.controlRect.linkControl(e)
  2205. },
  2206. y.prototype.spawnControl = function (e, t, i, s, n, r) {
  2207. var a = "backgroundTopLE" + (w = this.guiScreen.imageSetNumber) + "x.png",
  2208. o = "backgroundTopM" + w + "x.png",
  2209. h = "backgroundTopRE" + w + "x.png",
  2210. l = "backgroundMiddleLE" + w + "x.png",
  2211. d = "backgroundMiddleM" + w + "x.png",
  2212. c = "backgroundMiddleRE" + w + "x.png",
  2213. u = "backgroundBottomLE" + w + "x.png",
  2214. f = "backgroundBottomM" + w + "x.png",
  2215. m = "backgroundBottomRE" + w + "x.png",
  2216. p = 3 * w,
  2217. g = "backgroundLE" + w + "x.png",
  2218. v = "backgroundM" + w + "x.png",
  2219. x = "backgroundRE" + w + "x.png",
  2220. y = 2 * w,
  2221. b = "spacerLE" + w + "x.png",
  2222. S = "spacerM" + w + "x.png",
  2223. T = "spacerRE" + w + "x.png",
  2224. w = 2 * w,
  2225. C = this.controlRect.guiScreen.width,
  2226. R = this.controlRect.guiScreen.height;
  2227. if (n) {
  2228. n = this.textEntries.length;
  2229. var A = i;
  2230. for (i = 0; i < n; i++) {
  2231. var k = 8 * (this.textEntries[i] ? this.textEntries[i].length : 0);
  2232. A < k && (A = k)
  2233. }
  2234. i = A + r
  2235. }
  2236. for (r = 1 / (n = this.textEntries.length + 1),
  2237. this.localPixelsX = i,
  2238. this.listBoxEntryHeight = s,
  2239. this.localPixelsY = (this.textEntries.length + 1) * this.listBoxEntryHeight,
  2240. i = 8 / this.localPixelsY,
  2241. s = 6 / this.localPixelsX,
  2242. A = 4 / this.localPixelsX,
  2243. k = r - i / 4,
  2244. this.labelTextHeight = I.largeUI ? 20 : 16,
  2245. this.labelPixelDrop = (this.listBoxEntryHeight - this.labelTextHeight) / 2,
  2246. this.listBoxRegion.controlRect.widthPercent = this.localPixelsX / C,
  2247. this.listBoxRegion.controlRect.heightPercent = this.localPixelsY / R,
  2248. this.listBoxRegion.controlRect.xPercent = e / C,
  2249. this.listBoxRegion.controlRect.yPercent = t / R,
  2250. this.openBackground = this.listBoxRegion.addTextButton("", 0, 0, 1, 1 + i, 1),
  2251. this.openBackground.setBackground3x3(this.listBoxRegion, 0, 0, a, o, h, l, d, c, u, f, m, p, p),
  2252. this.closedBackground = this.listBoxRegion.addTextButton("", 0, 0, 1, r, 1),
  2253. this.closedBackground.setBackground3x1(this.listBoxRegion, 0, 0, g, v, x, y),
  2254. e = this.labelPixelInset + this.textOffsetsX[0],
  2255. t = this.labelPixelDrop + this.textOffsetsY[0],
  2256. t /= this.localPixelsY,
  2257. e /= this.localPixelsX,
  2258. this.defaultButton = this.listBoxRegion.addTextButton("Selected", e, -t, 1, r, .5),
  2259. this.selectedIndex = 0,
  2260. this.defaultButton.controlRect.linkedControl.innerHTML = this.textEntries[this.selectedIndex],
  2261. this.defaultButton.linkedBackground = this.closedBackground,
  2262. this.spacerControl = this.listBoxRegion.addTextButton("", s, k, 1 - (s + A), i, 1),
  2263. this.spacerControl.defaultAlpha = 1,
  2264. this.spacerControl.setBackground3x1(this.listBoxRegion, 0, 0, b, S, T, w),
  2265. this.spacerControl.setVisible(!1),
  2266. this.spacerControl.linkedBackground = this.openBackground,
  2267. i = 1; i < n; i++)
  2268. e = this.labelPixelInset + this.textOffsetsX[i - 1],
  2269. t = this.labelPixelDrop + this.textOffsetsY[i - 1] - 4,
  2270. e /= this.localPixelsX,
  2271. t /= this.localPixelsY,
  2272. b = this.listBoxRegion.addTextButton(this.textEntries[i - 1], e, r * i - t, 1 - e, r, .5),
  2273. this.listBoxButtons.push(b),
  2274. b.linkedBackground = this.openBackground;
  2275. this.showList(!1),
  2276. this.setupCallbacks()
  2277. },
  2278. y.prototype.setControl = function (e, t, i, s, n, r) {
  2279. var a = this.controlRect.guiScreen.width,
  2280. o = this.controlRect.guiScreen.height;
  2281. if (n) {
  2282. n = this.textEntries.length;
  2283. for (var h = 0; h < n; h++) {
  2284. var l = 8 * (this.textEntries[h] ? this.textEntries[h].length : 0);
  2285. i < l && (i = l)
  2286. }
  2287. i += r
  2288. }
  2289. this.localPixelsX = i,
  2290. this.listBoxEntryHeight = s,
  2291. this.localPixelsY = (this.textEntries.length + 1) * this.listBoxEntryHeight,
  2292. this.listBoxRegion.controlRect.widthPercent = this.localPixelsX / a,
  2293. this.listBoxRegion.controlRect.heightPercent = this.localPixelsY / o,
  2294. this.listBoxRegion.controlRect.xPercent = e / a,
  2295. this.listBoxRegion.controlRect.yPercent = t / o,
  2296. this.listBoxRegion.controlRect.updateChildElements(),
  2297. this.spacerControl.alignBackground(),
  2298. this.openBackground.alignBackground(),
  2299. this.closedBackground.alignBackground()
  2300. },
  2301. y.prototype.addItem = function (e, t, i) {
  2302. this.textEntries.push(e),
  2303. this.textOffsetsX.push(t),
  2304. this.textOffsetsY.push(i)
  2305. },
  2306. y.prototype.showList = function (e) {
  2307. for (var t = this.listBoxButtons.length, i = 0; i < t; i++)
  2308. this.listBoxButtons[i].setVisible(e);
  2309. this.closed = !e,
  2310. this.spacerControl && this.spacerControl.setVisible(e),
  2311. this.openBackground && this.openBackground.setVisible(e),
  2312. this.closedBackground && this.closedBackground.setVisible(!e),
  2313. e ? (this.defaultButton.linkedBackground = this.openBackground,
  2314. this.openBackground.setOpacity(1),
  2315. this.closedBackground.setOpacity(.5)) : this.defaultButton.linkedBackground = this.closedBackground
  2316. },
  2317. y.prototype.selectItem = function (e) {
  2318. this.selectedItemText = this.textEntries[e],
  2319. this.selectedIndex = e,
  2320. this.defaultButton.controlRect.linkedControl.innerHTML = this.textEntries[this.selectedIndex],
  2321. e = (this.labelTextHeight - this.listBoxEntryHeight + 3) / this.localPixelsY,
  2322. this.defaultButton.controlRect.xPercent = (this.labelPixelInset + this.textOffsetsX[this.selectedIndex]) / this.localPixelsX,
  2323. this.defaultButton.controlRect.yPercent = e,
  2324. this.defaultButton.controlRect.updateElement()
  2325. },
  2326. y.prototype.setupCallbacks = function () {
  2327. var e = function (e) {
  2328. if (this.closed) {
  2329. var t = (t = this.closedBackground.controlRect.linkedControl).getBoundingClientRect(),
  2330. i = e.clientX - t.left;
  2331. e = e.clientY - t.top,
  2332. i /= t.width,
  2333. t = e / t.height,
  2334. 0 <= i && i <= 1 && 0 <= t && t <= 1 ? this.closedBackground.setOpacity(1) : this.closedBackground.setOpacity(.5)
  2335. } else
  2336. t = (t = this.openBackground.controlRect.linkedControl).getBoundingClientRect(),
  2337. i = e.clientX - t.left,
  2338. e = e.clientY - t.top,
  2339. i /= t.width,
  2340. t = e / t.height,
  2341. 0 <= i && i <= 1 && 0 <= t && t <= 1 ? this.openBackground.setOpacity(1) : this.openBackground.setOpacity(.5)
  2342. }
  2343. .bind(this);
  2344. this.defaultButton.controlRect.linkedControl.onclick = function () {
  2345. this.closed ? this.showList(!0) : (this.showList(this.closed),
  2346. this.closedBackground.setOpacity(1),
  2347. this.defaultButton.setOpacity(1))
  2348. }
  2349. .bind(this);
  2350. for (var t = function (e) {
  2351. this.selectItem(e.id),
  2352. this.showList(!1),
  2353. this.defaultButton.setOpacity(.5),
  2354. this.selectionChangedCallback && this.selectionChangedCallback(this)
  2355. }
  2356. .bind(this), i = function (e) {
  2357. e = this.listBoxButtons.length;
  2358. for (var t = 0; t < e; t++)
  2359. this.listBoxButtons[t].controlRect.mouseOver && (this.selectItem(t),
  2360. t = e,
  2361. this.selectionChangedCallback && this.selectionChangedCallback(this));
  2362. this.showList(!1)
  2363. }
  2364. .bind(this), s = this.listBoxButtons.length, n = 0; n < s; n++)
  2365. this.listBoxButtons[n].controlRect.callBack = t,
  2366. this.listBoxButtons[n].controlRect.id = n,
  2367. this.listBoxButtons[n].controlRect.linkedControl.addEventListener("mousemove", e);
  2368. this.guiScreen.ui.viewer.input.element.addEventListener("mousemove", e),
  2369. this.openBackground.controlRect.linkedControl.addEventListener("mousemove", e),
  2370. this.closedBackground.controlRect.linkedControl.addEventListener("mousemove", e),
  2371. this.guiScreen.ui.viewer.input.element.addEventListener("mousedown", i)
  2372. },
  2373. b.prototype.bind = function (e, t) {
  2374. if (!this.complete())
  2375. return !1;
  2376. var i, s = e.view,
  2377. n = e.lights,
  2378. r = e.sky,
  2379. a = e.shadow,
  2380. o = e.stripData.active() ? this.stripShader : this.shader,
  2381. h = this.skinParams,
  2382. l = this.anisoParams,
  2383. d = this.microfiberParams,
  2384. c = this.gl,
  2385. u = o.params,
  2386. f = this.textures,
  2387. m = o.samplers;
  2388. o.bind(),
  2389. this.blend();
  2390. var p = t.mesh.displayMatrix,
  2391. g = S.mul(S.empty(), s.viewMatrix, p),
  2392. v = S.mul(S.empty(), s.projectionMatrix, s.viewMatrix);
  2393. g = S.mul(S.empty(), s.projectionMatrix, g),
  2394. p = S.mul(S.empty(), n.matrix, p);
  2395. return c.uniformMatrix4fv(u.uModelViewProjectionMatrix, !1, g),
  2396. c.uniformMatrix4fv(u.uSkyMatrix, !1, p),
  2397. p = S.mulPoint(V.empty(), n.matrix, s.transform[12], s.transform[13], s.transform[14]),
  2398. c.uniform3f(u.uCameraPosition, p[0], p[1], p[2]),
  2399. c.uniform3fv(u.uFresnel, this.fresnel),
  2400. c.uniform1f(u.uAlphaTest, this.alphaTest),
  2401. c.uniform1f(u.uHorizonOcclude, this.horizonOcclude),
  2402. c.uniform1f(u.uHorizonSmoothing, this.horizonSmoothing),
  2403. c.uniform4fv(u.uDiffuseCoefficients, r.diffuseCoefficients),
  2404. 0 < n.count && (c.uniform4fv(u.uLightPositions, n.positionBuffer),
  2405. c.uniform3fv(u.uLightDirections, n.directionBuffer),
  2406. c.uniform3fv(u.uLightColors, n.colors),
  2407. c.uniform3fv(u.uLightParams, n.parameters),
  2408. c.uniform3fv(u.uLightSpot, n.spot),
  2409. p = .392699 * e.postRender.currentSample(),
  2410. c.uniform2f(u.uShadowKernelRotation, .5 * Math.cos(p), .5 * Math.sin(p)),
  2411. 0 < n.shadowCount && (p = a.depthTextures[0].desc.width,
  2412. c.uniform2f(u.uShadowMapSize, p, 1 / p),
  2413. c.uniformMatrix4fv(u.uShadowMatrices, !1, n.finalTransformBuffer),
  2414. c.uniformMatrix4fv(u.uInvShadowMatrices, !1, n.inverseTransformBuffer),
  2415. c.uniform4fv(u.uShadowTexelPadProjections, n.shadowTexelPadProjections),
  2416. a.bindDepthTexture(m.tDepth0, 0),
  2417. a.bindDepthTexture(m.tDepth1, 1),
  2418. a.bindDepthTexture(m.tDepth2, 2))),
  2419. h && (c.uniform3fv(u.uSubdermisColor, h.subdermisColor),
  2420. c.uniform4fv(u.uTransColor, h.transColor),
  2421. c.uniform1f(u.uTransScatter, h.transScatter),
  2422. c.uniform4fv(u.uFresnelColor, h.fresnelColor),
  2423. c.uniform1f(u.uFresnelOcc, h.fresnelOcc),
  2424. c.uniform1f(u.uFresnelGlossMask, h.fresnelGlossMask),
  2425. c.uniform1f(u.uFresnelIntegral, h.fresnelIntegral),
  2426. c.uniform1f(u.uTransIntegral, h.transIntegral),
  2427. c.uniform1f(u.uSkinTransDepth, h.transDepth),
  2428. c.uniform1f(u.uTransSky, h.transSky),
  2429. c.uniform1f(u.uSkinShadowBlur, h.shadowBlur),
  2430. c.uniform1f(u.uNormalSmooth, h.normalSmooth),
  2431. (i = this.extrasTexCoordRanges.subdermisTex) && c.uniform4fv(u.uTexRangeSubdermis, i),
  2432. (i = this.extrasTexCoordRanges.translucencyTex) && c.uniform4fv(u.uTexRangeTranslucency, i),
  2433. (i = this.extrasTexCoordRanges.fuzzTex) && c.uniform4fv(u.uTexRangeFuzz, i)),
  2434. d && (c.uniform4fv(u.uFresnelColor, d.fresnelColor),
  2435. c.uniform1f(u.uFresnelOcc, d.fresnelOcc),
  2436. c.uniform1f(u.uFresnelGlossMask, d.fresnelGlossMask),
  2437. c.uniform1f(u.uFresnelIntegral, d.fresnelIntegral),
  2438. (i = this.extrasTexCoordRanges.fuzzTex) && c.uniform4fv(u.uTexRangeFuzz, i)),
  2439. l && (c.uniform3fv(u.uAnisoTangent, l.tangent),
  2440. c.uniform1f(u.uAnisoStrength, l.strength),
  2441. c.uniform1f(u.uAnisoIntegral, l.integral),
  2442. (i = this.extrasTexCoordRanges.anisoTex) && c.uniform4fv(u.uTexRangeAniso, i)),
  2443. this.usesRefraction && (e.refractionSurface && e.refractionSurface.bind(m.tRefraction),
  2444. n = S.mul(S.empty(), v, n.invMatrix),
  2445. c.uniformMatrix4fv(u.uRefractionViewProjection, !1, n),
  2446. c.uniform1f(u.uRefractionRayDistance, this.refractionParams.distantBackground ? 1e10 : 4 * t.mesh.bounds.maxExtent),
  2447. c.uniform3fv(u.uRefractionTint, this.refractionParams.tint),
  2448. c.uniform1f(u.uRefractionAlbedoTint, this.refractionParams.useAlbedoTint ? 1 : 0),
  2449. c.uniform1f(u.uRefractionIOREntry, 1 / this.refractionParams.IOR),
  2450. (i = this.extrasTexCoordRanges.refractionMaskTex) && c.uniform4fv(u.uTexRangeRefraction, i)),
  2451. (i = this.extrasTexCoordRanges.emissiveTex) && (c.uniform4fv(u.uTexRangeEmissive, i),
  2452. c.uniform1f(u.uEmissiveScale, this.emissiveIntensity)),
  2453. (i = this.extrasTexCoordRanges.aoTex) && c.uniform4fv(u.uTexRangeAO, i),
  2454. f.albedo.bind(m.tAlbedo),
  2455. f.reflectivity.bind(m.tReflectivity),
  2456. f.normal.bind(m.tNormal),
  2457. f.extras.bind(m.tExtras),
  2458. r.specularTexture.bind(m.tSkySpecular),
  2459. o === this.stripShader && (c.uniform1fv(u.uStrips, e.stripData.strips),
  2460. c.uniform2f(u.uStripRes, 2 / s.size[0], 2 / s.size[1])),
  2461. c.uniform2f(u.uUVOffset, this.uOffset, this.vOffset),
  2462. !0
  2463. },
  2464. b.prototype.bindAlphaPrepass = function (e, t) {
  2465. if (!this.complete() || !this.prepassShader)
  2466. return !1;
  2467. var i = this.gl,
  2468. s = this.prepassShader.params,
  2469. n = this.prepassShader.samplers;
  2470. this.prepassShader.bind();
  2471. var r = S.mul(S.empty(), e.view.viewMatrix, t.mesh.displayMatrix);
  2472. r = S.mul(S.empty(), e.view.projectionMatrix, r);
  2473. return i.uniformMatrix4fv(s.uModelViewProjectionMatrix, !1, r),
  2474. i.uniform2f(s.uUVOffset, this.uOffset, this.vOffset),
  2475. this.textures.albedo.bind(n.tAlbedo),
  2476. !0
  2477. },
  2478. b.prototype.bindWire = function (e, t) {
  2479. if (!this.complete())
  2480. return !1;
  2481. var i = this.gl,
  2482. s = this.wireShader.params,
  2483. n = e.view;
  2484. i.enable(i.BLEND),
  2485. i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA),
  2486. i.depthMask(!1),
  2487. this.wireShader.bind();
  2488. var r = S.mul(S.empty(), e.view.viewMatrix, t.mesh.displayMatrix);
  2489. r = S.mul(S.empty(), e.view.projectionMatrix, r);
  2490. return i.uniformMatrix4fv(s.uModelViewProjectionMatrix, !1, r),
  2491. i.uniform4f(s.uStripParams, 2 / n.size[0], 2 / n.size[1], e.stripData.strips[3], e.stripData.strips[4]),
  2492. !0
  2493. },
  2494. b.prototype.complete = function () {
  2495. return this.wireShader.complete() && this.shader.complete() && this.stripShader.complete() && (!this.prepassShader || this.prepassShader.complete()) && (!this.refractionShader || this.refractionShader.complete()) && this.textures.albedo.complete() && this.textures.reflectivity.complete() && this.textures.normal.complete()
  2496. };
  2497. var S = {
  2498. type: Float32Array,
  2499. create: function (e, t, i, s, n, r, a, o, h, l, d, c, u, f, m, p) {
  2500. var g = new S.type(16);
  2501. return g[0] = e,
  2502. g[4] = t,
  2503. g[8] = i,
  2504. g[12] = s,
  2505. g[1] = n,
  2506. g[5] = r,
  2507. g[9] = a,
  2508. g[13] = o,
  2509. g[2] = h,
  2510. g[6] = l,
  2511. g[10] = d,
  2512. g[14] = c,
  2513. g[3] = u,
  2514. g[7] = f,
  2515. g[11] = m,
  2516. g[15] = p,
  2517. g
  2518. },
  2519. empty: function () {
  2520. return new S.type(16)
  2521. },
  2522. identity: function () {
  2523. var e = new S.type(16);
  2524. return e[0] = 1,
  2525. e[4] = 0,
  2526. e[8] = 0,
  2527. e[12] = 0,
  2528. e[1] = 0,
  2529. e[5] = 1,
  2530. e[9] = 0,
  2531. e[13] = 0,
  2532. e[2] = 0,
  2533. e[6] = 0,
  2534. e[10] = 1,
  2535. e[14] = 0,
  2536. e[3] = 0,
  2537. e[7] = 0,
  2538. e[11] = 0,
  2539. e[15] = 1,
  2540. e
  2541. },
  2542. set: function (e, t, i, s, n, r, a, o, h, l, d, c, u, f, m, p, g) {
  2543. e[0] = t,
  2544. e[4] = i,
  2545. e[8] = s,
  2546. e[12] = n,
  2547. e[1] = r,
  2548. e[5] = a,
  2549. e[9] = o,
  2550. e[13] = h,
  2551. e[2] = l,
  2552. e[6] = d,
  2553. e[10] = c,
  2554. e[14] = u,
  2555. e[3] = f,
  2556. e[7] = m,
  2557. e[11] = p,
  2558. e[15] = g
  2559. },
  2560. translation: function (e, t, i, s) {
  2561. return S.set(e, 1, 0, 0, t, 0, 1, 0, i, 0, 0, 1, s, 0, 0, 0, 1),
  2562. e
  2563. },
  2564. rotation: function (e, t, i) {
  2565. e[0] = 1,
  2566. e[4] = 0,
  2567. e[8] = 0,
  2568. e[12] = 0,
  2569. e[1] = 0,
  2570. e[5] = 1,
  2571. e[9] = 0,
  2572. e[13] = 0,
  2573. e[2] = 0,
  2574. e[6] = 0,
  2575. e[10] = 1,
  2576. e[14] = 0,
  2577. e[3] = 0,
  2578. e[7] = 0,
  2579. e[11] = 0,
  2580. e[15] = 1;
  2581. var s = .0174532925 * t;
  2582. switch (t = Math.sin(s),
  2583. s = Math.cos(s),
  2584. i) {
  2585. case 0:
  2586. e[5] = s,
  2587. e[9] = -t,
  2588. e[6] = t,
  2589. e[10] = s;
  2590. break;
  2591. case 1:
  2592. e[0] = s,
  2593. e[8] = t,
  2594. e[2] = -t,
  2595. e[10] = s;
  2596. break;
  2597. case 2:
  2598. e[0] = s,
  2599. e[4] = -t,
  2600. e[1] = t,
  2601. e[5] = s
  2602. }
  2603. return e
  2604. },
  2605. mul: function (e, t, i) {
  2606. var s = t[0],
  2607. n = t[1],
  2608. r = t[2],
  2609. a = t[3],
  2610. o = t[4],
  2611. h = t[5],
  2612. l = t[6],
  2613. d = t[7],
  2614. c = t[8],
  2615. u = t[9],
  2616. f = t[10],
  2617. m = t[11],
  2618. p = t[12],
  2619. g = t[13],
  2620. v = t[14];
  2621. t = t[15];
  2622. var x = i[0],
  2623. y = i[1],
  2624. b = i[2],
  2625. S = i[3];
  2626. return e[0] = x * s + y * o + b * c + S * p,
  2627. e[1] = x * n + y * h + b * u + S * g,
  2628. e[2] = x * r + y * l + b * f + S * v,
  2629. e[3] = x * a + y * d + b * m + S * t,
  2630. x = i[4],
  2631. y = i[5],
  2632. b = i[6],
  2633. S = i[7],
  2634. e[4] = x * s + y * o + b * c + S * p,
  2635. e[5] = x * n + y * h + b * u + S * g,
  2636. e[6] = x * r + y * l + b * f + S * v,
  2637. e[7] = x * a + y * d + b * m + S * t,
  2638. x = i[8],
  2639. y = i[9],
  2640. b = i[10],
  2641. S = i[11],
  2642. e[8] = x * s + y * o + b * c + S * p,
  2643. e[9] = x * n + y * h + b * u + S * g,
  2644. e[10] = x * r + y * l + b * f + S * v,
  2645. e[11] = x * a + y * d + b * m + S * t,
  2646. x = i[12],
  2647. y = i[13],
  2648. b = i[14],
  2649. S = i[15],
  2650. e[12] = x * s + y * o + b * c + S * p,
  2651. e[13] = x * n + y * h + b * u + S * g,
  2652. e[14] = x * r + y * l + b * f + S * v,
  2653. e[15] = x * a + y * d + b * m + S * t,
  2654. e
  2655. },
  2656. invert: function (e, t) {
  2657. var i = t[0],
  2658. s = t[1],
  2659. n = t[2],
  2660. r = t[3],
  2661. a = t[4],
  2662. o = t[5],
  2663. h = t[6],
  2664. l = t[7],
  2665. d = t[8],
  2666. c = t[9],
  2667. u = t[10],
  2668. f = t[11],
  2669. m = t[12],
  2670. p = t[13],
  2671. g = t[14],
  2672. v = t[15],
  2673. x = i * o - s * a,
  2674. y = i * h - n * a,
  2675. b = i * l - r * a,
  2676. S = s * h - n * o,
  2677. T = s * l - r * o,
  2678. w = n * l - r * h,
  2679. C = d * p - c * m,
  2680. R = d * g - u * m,
  2681. A = d * v - f * m,
  2682. k = c * g - u * p,
  2683. I = c * v - f * p,
  2684. P = u * v - f * g,
  2685. F = x * P - y * I + b * k + S * A - T * R + w * C;
  2686. return F ? (F = 1 / F,
  2687. e[0] = (o * P - h * I + l * k) * F,
  2688. e[1] = (n * I - s * P - r * k) * F,
  2689. e[2] = (p * w - g * T + v * S) * F,
  2690. e[3] = (u * T - c * w - f * S) * F,
  2691. e[4] = (h * A - a * P - l * R) * F,
  2692. e[5] = (i * P - n * A + r * R) * F,
  2693. e[6] = (g * b - m * w - v * y) * F,
  2694. e[7] = (d * w - u * b + f * y) * F,
  2695. e[8] = (a * I - o * A + l * C) * F,
  2696. e[9] = (s * A - i * I - r * C) * F,
  2697. e[10] = (m * T - p * b + v * x) * F,
  2698. e[11] = (c * b - d * T - f * x) * F,
  2699. e[12] = (o * R - a * k - h * C) * F,
  2700. e[13] = (i * k - s * R + n * C) * F,
  2701. e[14] = (p * y - m * S - g * x) * F,
  2702. e[15] = (d * S - c * y + u * x) * F,
  2703. e) : null
  2704. },
  2705. transpose: function (e, t) {
  2706. return e[0] = t[0],
  2707. e[4] = t[1],
  2708. e[8] = t[2],
  2709. e[12] = t[3],
  2710. e[1] = t[4],
  2711. e[5] = t[5],
  2712. e[9] = t[6],
  2713. e[13] = t[7],
  2714. e[2] = t[8],
  2715. e[6] = t[9],
  2716. e[10] = t[10],
  2717. e[14] = t[11],
  2718. e[3] = t[12],
  2719. e[7] = t[13],
  2720. e[11] = t[14],
  2721. e[15] = t[15],
  2722. e
  2723. },
  2724. mul4: function (e, t, i, s, n, r) {
  2725. return e[0] = t[0] * i + t[4] * s + t[8] * n + t[12] * r,
  2726. e[1] = t[1] * i + t[5] * s + t[9] * n + t[13] * r,
  2727. e[2] = t[2] * i + t[6] * s + t[10] * n + t[14] * r,
  2728. e[3] = t[3] * i + t[7] * s + t[11] * n + t[15] * r,
  2729. e
  2730. },
  2731. mulPoint: function (e, t, i, s, n) {
  2732. return e[0] = t[0] * i + t[4] * s + t[8] * n + t[12],
  2733. e[1] = t[1] * i + t[5] * s + t[9] * n + t[13],
  2734. e[2] = t[2] * i + t[6] * s + t[10] * n + t[14],
  2735. e
  2736. },
  2737. mulVec: function (e, t, i, s, n) {
  2738. return e[0] = t[0] * i + t[4] * s + t[8] * n,
  2739. e[1] = t[1] * i + t[5] * s + t[9] * n,
  2740. e[2] = t[2] * i + t[6] * s + t[10] * n,
  2741. e
  2742. },
  2743. perspective: function (e, t, i, s, n, r) {
  2744. return r = r || 0,
  2745. t = 1 / Math.tan(.00872664625 * t),
  2746. e[0] = t / i,
  2747. e[1] = e[2] = e[3] = 0,
  2748. e[5] = t,
  2749. e[4] = e[6] = e[7] = 0,
  2750. e[8] = e[9] = 0,
  2751. e[10] = (n + s) / (s - n) - 30518044e-12 * r,
  2752. e[11] = -1,
  2753. e[14] = 2 * n * s / (s - n),
  2754. e[12] = e[13] = e[15] = 0,
  2755. e
  2756. },
  2757. perspectiveInfinite: function (e, t, i, s, n) {
  2758. return n = n || 0,
  2759. t = 1 / Math.tan(.00872664625 * t),
  2760. e[0] = t / i,
  2761. e[1] = e[2] = e[3] = 0,
  2762. e[5] = t,
  2763. e[4] = e[6] = e[7] = 0,
  2764. e[8] = e[9] = 0,
  2765. e[10] = e[11] = -1 - 30518044e-12 * n,
  2766. e[14] = -2 * s,
  2767. e[12] = e[13] = e[15] = 0,
  2768. e
  2769. },
  2770. ortho: function (e, t, i, s, n, r, a, o) {
  2771. var h = 1 / (i - t),
  2772. l = 1 / (n - s),
  2773. d = 1 / (a - r);
  2774. return e[0] = h + h,
  2775. e[1] = e[2] = e[3] = 0,
  2776. e[5] = l + l,
  2777. e[4] = e[6] = e[7] = 0,
  2778. e[12] = -(i + t) * h,
  2779. e[13] = -(n + s) * l,
  2780. e[10] = -(d + d) - 30518044e-12 * (o || 0),
  2781. e[14] = -(a + r) * d,
  2782. e[8] = e[9] = e[11] = 0,
  2783. e[15] = 1,
  2784. e
  2785. },
  2786. lookAt: function (e, t, i, s) {
  2787. var n = e.subarray(0, 3),
  2788. r = e.subarray(4, 7),
  2789. a = e.subarray(8, 11);
  2790. V.sub(a, t, i),
  2791. V.cross(n, s, a),
  2792. V.normalize(a, a),
  2793. V.normalize(n, n),
  2794. V.cross(r, a, n),
  2795. S.set(e, n[0], n[1], n[2], -V.dot(n, t), r[0], r[1], r[2], -V.dot(r, t), a[0], a[1], a[2], -V.dot(a, t), 0, 0, 0, 1)
  2796. },
  2797. copy: function (e, t) {
  2798. for (var i = 0; i < 16; ++i)
  2799. e[i] = t[i]
  2800. },
  2801. copyToBuffer: function (e, t, i) {
  2802. for (var s = 0; s < 16; ++s)
  2803. e[t + s] = i[s]
  2804. }
  2805. };
  2806. function T(e, t, i) {
  2807. this.gl = e;
  2808. var s = (this.desc = t).isDynamicMesh;
  2809. this.numSubMeshes = this.dynamicVertexData = 0,
  2810. this.displayMatrix = S.identity(),
  2811. this.name = t.name,
  2812. this.modelMatrix = S.identity(),
  2813. this.origin = t.transform ? V.create(t.transform[12], t.transform[13], t.transform[14], 1) : V.create(0, 5, 0, 1),
  2814. this.stride = 32,
  2815. (this.vertexColor = t.vertexColor) && (this.stride += 4),
  2816. (this.secondaryTexCoord = t.secondaryTexCoord) && (this.stride += 8),
  2817. i = new u(i.data),
  2818. this.indexCount = t.indexCount,
  2819. this.indexTypeSize = t.indexTypeSize,
  2820. this.indexType = 4 == this.indexTypeSize ? e.UNSIGNED_INT : e.UNSIGNED_SHORT,
  2821. this.indexBuffer = e.createBuffer(),
  2822. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
  2823. var n = i.readBytes(this.indexCount * this.indexTypeSize);
  2824. e.bufferData(e.ELEMENT_ARRAY_BUFFER, n, e.STATIC_DRAW),
  2825. this.wireCount = t.wireCount,
  2826. this.wireBuffer = e.createBuffer(),
  2827. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.wireBuffer),
  2828. n = i.readBytes(this.wireCount * this.indexTypeSize),
  2829. e.bufferData(e.ELEMENT_ARRAY_BUFFER, n, e.STATIC_DRAW),
  2830. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null),
  2831. this.vertexCount = t.vertexCount,
  2832. this.vertexBuffer = e.createBuffer(),
  2833. e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer),
  2834. i = i.readBytes(this.vertexCount * this.stride),
  2835. s ? (this.dynamicVertexData = new Uint8Array(i),
  2836. e.bufferData(e.ARRAY_BUFFER, i, e.DYNAMIC_DRAW)) : e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  2837. e.bindBuffer(e.ARRAY_BUFFER, null),
  2838. this.bounds = void 0 === t.minBound || void 0 === t.maxBound ? {
  2839. min: V.create(-10, -10, -10, 1),
  2840. max: V.create(10, 10, -0, 1)
  2841. } : {
  2842. min: V.create(t.minBound[0], t.minBound[1], t.minBound[2], 1),
  2843. max: V.create(t.maxBound[0], t.maxBound[1], t.maxBound[2], 1)
  2844. },
  2845. this.bounds.maxExtent = Math.max(Math.max(t.maxBound[0] - t.minBound[0], t.maxBound[1] - t.minBound[1]), t.maxBound[2] - t.minBound[2]),
  2846. this.bounds.averageExtent = (t.maxBound[0] - t.minBound[0] + (t.maxBound[1] - t.minBound[1]) + (t.maxBound[2] - t.minBound[2])) / 3
  2847. }
  2848. function w(e, t, i) {
  2849. this.mesh = e,
  2850. this.gl = this.mesh.gl,
  2851. this.indexOffset = t.firstIndex * e.indexTypeSize,
  2852. this.indexCount = t.indexCount,
  2853. this.wireIndexOffset = t.firstWireIndex * e.indexTypeSize,
  2854. this.wireIndexCount = t.wireIndexCount,
  2855. this.material = i,
  2856. this.visible = !0
  2857. }
  2858. w.prototype.draw = function (e) {
  2859. var t = this.gl;
  2860. if (this.material.bind(e, this)) {
  2861. e = this.material.shader.attribs;
  2862. var i = this.mesh.stride;
  2863. this.mesh.desc.cullBackFaces ? (t.enable(t.CULL_FACE),
  2864. t.cullFace(t.BACK)) : t.disable(t.CULL_FACE),
  2865. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  2866. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2867. t.enableVertexAttribArray(e.vPosition),
  2868. t.enableVertexAttribArray(e.vTexCoord),
  2869. t.enableVertexAttribArray(e.vTangent),
  2870. t.enableVertexAttribArray(e.vBitangent),
  2871. t.enableVertexAttribArray(e.vNormal);
  2872. var s = this.mesh.vertexColor && void 0 !== e.vColor;
  2873. s && t.enableVertexAttribArray(e.vColor);
  2874. var n = this.mesh.secondaryTexCoord && void 0 !== e.vTexCoord2;
  2875. n && t.enableVertexAttribArray(e.vTexCoord2);
  2876. var r = 0;
  2877. t.vertexAttribPointer(e.vPosition, 3, t.FLOAT, !1, i, r),
  2878. r += 12,
  2879. t.vertexAttribPointer(e.vTexCoord, 2, t.FLOAT, !1, i, r),
  2880. r += 8,
  2881. this.mesh.secondaryTexCoord && (n && t.vertexAttribPointer(e.vTexCoord2, 2, t.FLOAT, !1, i, r),
  2882. r += 8),
  2883. t.vertexAttribPointer(e.vTangent, 2, t.UNSIGNED_SHORT, !0, i, r),
  2884. r += 4,
  2885. t.vertexAttribPointer(e.vBitangent, 2, t.UNSIGNED_SHORT, !0, i, r),
  2886. r += 4,
  2887. t.vertexAttribPointer(e.vNormal, 2, t.UNSIGNED_SHORT, !0, i, r),
  2888. s && t.vertexAttribPointer(e.vColor, 4, t.UNSIGNED_BYTE, !0, i, r + 4),
  2889. t.drawElements(t.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  2890. t.disableVertexAttribArray(e.vPosition),
  2891. t.disableVertexAttribArray(e.vTexCoord),
  2892. t.disableVertexAttribArray(e.vTangent),
  2893. t.disableVertexAttribArray(e.vBitangent),
  2894. t.disableVertexAttribArray(e.vNormal),
  2895. s && t.disableVertexAttribArray(e.vColor),
  2896. n && t.disableVertexAttribArray(e.vTexCoord2)
  2897. }
  2898. },
  2899. w.prototype.drawShadow = function (e) {
  2900. var t = this.gl;
  2901. this.mesh.desc.cullBackFaces ? (t.enable(t.CULL_FACE),
  2902. t.cullFace(t.BACK)) : t.disable(t.CULL_FACE),
  2903. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  2904. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2905. t.enableVertexAttribArray(e),
  2906. t.vertexAttribPointer(e, 3, t.FLOAT, !1, this.mesh.stride, 0),
  2907. t.drawElements(t.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  2908. t.disableVertexAttribArray(e)
  2909. },
  2910. w.prototype.drawAlphaShadow = function (e, t) {
  2911. var i = this.gl;
  2912. this.mesh.desc.cullBackFaces ? (i.enable(i.CULL_FACE),
  2913. i.cullFace(i.BACK)) : i.disable(i.CULL_FACE),
  2914. i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  2915. i.bindBuffer(i.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2916. i.enableVertexAttribArray(e),
  2917. i.enableVertexAttribArray(t),
  2918. i.vertexAttribPointer(e, 3, i.FLOAT, !1, this.mesh.stride, 0),
  2919. i.vertexAttribPointer(t, 2, i.FLOAT, !1, this.mesh.stride, 12),
  2920. i.drawElements(i.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  2921. i.disableVertexAttribArray(e),
  2922. i.disableVertexAttribArray(t)
  2923. },
  2924. w.prototype.drawAlphaPrepass = function (e) {
  2925. var t = this.gl;
  2926. if (this.material.bindAlphaPrepass(e, this)) {
  2927. e = this.material.prepassShader.attribs;
  2928. var i = this.mesh.stride;
  2929. this.mesh.desc.cullBackFaces ? (t.enable(t.CULL_FACE),
  2930. t.cullFace(t.BACK)) : t.disable(t.CULL_FACE),
  2931. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  2932. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2933. t.enableVertexAttribArray(e.vPosition),
  2934. t.enableVertexAttribArray(e.vTexCoord),
  2935. t.vertexAttribPointer(e.vPosition, 3, t.FLOAT, !1, i, 0),
  2936. t.vertexAttribPointer(e.vTexCoord, 2, t.FLOAT, !1, i, 12),
  2937. t.drawElements(t.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  2938. t.disableVertexAttribArray(e.vPosition),
  2939. t.disableVertexAttribArray(e.vTexCoord)
  2940. }
  2941. },
  2942. w.prototype.drawWire = function (e) {
  2943. var t = this.material.wireShader.attribs,
  2944. i = this.gl;
  2945. this.material.bindWire(e, this) && (i.enableVertexAttribArray(t.vPosition),
  2946. i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.mesh.wireBuffer),
  2947. i.bindBuffer(i.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2948. i.vertexAttribPointer(t.vPosition, 3, i.FLOAT, !1, this.mesh.stride, 0),
  2949. i.drawElements(i.LINES, this.wireIndexCount, this.mesh.indexType, this.wireIndexOffset),
  2950. i.disableVertexAttribArray(t.vPosition))
  2951. },
  2952. w.prototype.complete = function () {
  2953. return this.material.complete()
  2954. };
  2955. var C = {
  2956. fetchImage: function (e, t, i) {
  2957. var s = new Image();
  2958. s.crossOrigin = "Anonymous",
  2959. s.onload = function () {
  2960. 0 < s.width && 0 < s.height ? t(s) : i && i()
  2961. },
  2962. i && (req.onerror = function () {
  2963. i()
  2964. }),
  2965. s.src = e
  2966. },
  2967. fetchText: function (e, t, i, s) {
  2968. var n = new XMLHttpRequest();
  2969. n.open("GET", e, !0),
  2970. n.onload = function () {
  2971. 200 == n.status ? t(n.responseText) : i && i()
  2972. },
  2973. i && (n.onerror = function () {
  2974. i()
  2975. }),
  2976. s && (n.onprogress = function (e) {
  2977. s(e.loaded, e.total)
  2978. }),
  2979. n.send()
  2980. },
  2981. fetchBinary: function (e, t, i, s) {
  2982. var n = new XMLHttpRequest();
  2983. n.open("GET", e, !0),
  2984. n.responseType = "arraybuffer",
  2985. n.onload = function () {
  2986. 200 == n.status ? t(n.response) : i && i()
  2987. },
  2988. i && (n.onerror = function () {
  2989. i()
  2990. }),
  2991. s && (n.onprogress = function (e) {
  2992. s(e.loaded, e.total)
  2993. }),
  2994. n.send()
  2995. },
  2996. fetchBinaryIncremental: function (r, a, t, o) {
  2997. var i = new XMLHttpRequest();
  2998. i.open("HEAD", r, !0),
  2999. i.onload = function () {
  3000. if (200 == i.status) {
  3001. var e = i.getResponseHeader("Accept-Ranges");
  3002. if (e && "none" != e) {
  3003. var s = 0 | i.getResponseHeader("Content-Length"),
  3004. n = function (e, t) {
  3005. var i = new XMLHttpRequest();
  3006. i.open("GET", r, !0),
  3007. i.setRequestHeader("Range", "bytes=" + e + "-" + t),
  3008. i.responseType = "arraybuffer",
  3009. i.onload = function () {
  3010. (206 == i.status || 200 == i.status) && a(i.response) && t < s && n(e += o, t = (t += o) < s - 1 ? t : s - 1)
  3011. },
  3012. i.send()
  3013. };
  3014. n(0, o - 1)
  3015. } else
  3016. t && t()
  3017. } else
  3018. t && t()
  3019. },
  3020. t && (i.onerror = function () {
  3021. t()
  3022. }),
  3023. i.send()
  3024. }
  3025. };
  3026. function R(e) {
  3027. this.debugString = "",
  3028. this.init = !1,
  3029. this.speedList = this.cameraList = this.animationList = this.playButton = this.timelineSlider = this.playbackRegion = this.previousFrameButton = this.nextFrameButton = this.pauseButton = this.playButton = 0,
  3030. this.visible = !1,
  3031. this.backgroundRegion = this.screenButton = 0,
  3032. this.guiScreen = e,
  3033. this.playbackRegion = new v(e),
  3034. this.idealSliderWidth = 650,
  3035. this.totalListBoxPixelsX = 0,
  3036. this.minWidth = 500,
  3037. this.compactMode = !1,
  3038. this.ui = e.ui;
  3039. var t = "animationpause" + e.imageSetNumber + "x.png",
  3040. i = "animationplay" + e.imageSetNumber + "x.png",
  3041. s = "timelineLE" + e.imageSetNumber + "x.png",
  3042. n = "timelineM" + e.imageSetNumber + "x.png",
  3043. r = "timelineRE" + e.imageSetNumber + "x.png",
  3044. a = e.ui.viewer.scene.sceneAnimator.animations.length;
  3045. if (0 != a) {
  3046. var o = this.idealSliderWidth;
  3047. this.bottomOffset = 85,
  3048. this.centerOffset = 60;
  3049. var h, l = (h = e.width / 2 + this.centerOffset) - o / 2,
  3050. d = l - 14 - 32,
  3051. c = (h = h + o / 2) - d,
  3052. u = 32 / e.height,
  3053. f = this.bottomOffset / e.height,
  3054. m = this.playbackRegion;
  3055. if (m.controlRect.widthPercent = c / e.width,
  3056. m.controlRect.heightPercent = u,
  3057. m.controlRect.xPercent = d / e.width,
  3058. m.controlRect.yPercent = f,
  3059. u = 32 / c,
  3060. this.pauseButton = new p(this.guiScreen),
  3061. this.pauseButton.controlRect.set(0, .125, u, .75),
  3062. this.pauseButton.controlRect.opacity = .5,
  3063. m.controlRect.registerChildControlRect(this.pauseButton.controlRect),
  3064. this.pauseButton.linkControl(m.addImageElement(this.pauseButton.controlRect, t)),
  3065. this.playButton = new p(this.guiScreen),
  3066. this.playButton.controlRect.set(0, .125, u, .75),
  3067. this.playButton.controlRect.opacity = .5,
  3068. m.controlRect.registerChildControlRect(this.playButton.controlRect),
  3069. this.playButton.linkControl(m.addImageElement(this.playButton.controlRect, i)),
  3070. t = o / c,
  3071. c = (l - d) / c,
  3072. this.timelineSlider = new z(this.guiScreen, m),
  3073. this.timelineSlider.controlRect.set(c, .03125, t, 1),
  3074. m.controlRect.registerChildControlRect(this.timelineSlider.controlRect),
  3075. this.timelineSlider.setBackground3x1(m, s, n, r),
  3076. this.pauseButton.controlRect.showControl(!e.ui.viewer.scene.sceneAnimator.paused),
  3077. this.playButton.controlRect.showControl(e.ui.viewer.scene.sceneAnimator.paused),
  3078. s = h + 14,
  3079. n = this.bottomOffset + 4,
  3080. r = e.ui.viewer.scene.sceneAnimator.animations[0].cameraObjects.length,
  3081. e.ui.viewer.scene.sceneAnimator.selectDefaultCamera(),
  3082. e.ui.viewer.scene.sceneAnimator.setViewFromSelectedCamera(),
  3083. this.maxListPixelsX = 0,
  3084. 1 < r) {
  3085. for (this.cameraList = new y(e),
  3086. c = 0; c < r; c++)
  3087. this.cameraList.addItem(e.ui.viewer.scene.sceneAnimator.animations[0].cameraObjects[c].name, 0, 0);
  3088. this.cameraList.spawnControl(s, n, 10, 24, !0, 8),
  3089. this.cameraList.selectItem(e.ui.viewer.scene.sceneAnimator.selectedCameraIndex),
  3090. this.maxListPixelsX = this.cameraList.localPixelsX,
  3091. this.totalListBoxPixelsX += this.cameraList.localPixelsX + 14
  3092. }
  3093. if (1 < a) {
  3094. for (this.animationList = new y(e),
  3095. c = 0; c < a; c++)
  3096. this.animationList.addItem(e.ui.viewer.scene.sceneAnimator.animations[c].name, 0, 0);
  3097. this.animationList.spawnControl(s, n, 10, 24, !0, 8),
  3098. this.maxListPixelsX < this.animationList.localPixelsX && (this.maxListPixelsX = this.animationList.localPixelsX),
  3099. this.totalListBoxPixelsX += this.animationList.localPixelsX + 14,
  3100. this.animationList.selectItem(e.ui.viewer.scene.sceneAnimator.selectedAnimationIndex)
  3101. }
  3102. c = h - (s = d - 44 - 14) + this.totalListBoxPixelsX,
  3103. this.speedList = new y(e),
  3104. this.speedList.addItem("4.0x", 4, 0),
  3105. this.speedList.addItem("2.0x", 4, 0),
  3106. this.speedList.addItem("1.0x", 4, 0),
  3107. this.speedList.addItem("0.5x", 4, 0),
  3108. this.speedList.addItem("0.25x", -2, 0),
  3109. this.speedList.spawnControl(s, n, 44, 24, !1, 0),
  3110. this.speedList.selectItem(2),
  3111. c > e.width && (this.idealSliderWidth = e.width - (118 + (this.totalListBoxPixelsX + 14)) - this.centerOffset,
  3112. e = 0,
  3113. this.cameraList && e++,
  3114. this.animationList && e++,
  3115. 1 == e && (this.idealSliderWidth += 56,
  3116. this.centerOffset -= 14),
  3117. 2 == e && (this.idealSliderWidth += 63,
  3118. this.centerOffset -= 63)),
  3119. this.setupCallbacks()
  3120. }
  3121. }
  3122. function A(e, t, i) {
  3123. if (this.gl = e,
  3124. this.desc = t,
  3125. t = [],
  3126. 0 != this.desc.sharpen && t.push("#define SHARPEN"),
  3127. (this.useBloom = 0 < this.desc.bloomColor[0] * this.desc.bloomColor[3] || 0 < this.desc.bloomColor[1] * this.desc.bloomColor[3] || 0 < this.desc.bloomColor[2] * this.desc.bloomColor[3]) && t.push("#define BLOOM"),
  3128. 0 != this.desc.vignette[3] && t.push("#define VIGNETTE"),
  3129. 1 == this.desc.saturation[0] * this.desc.saturation[3] && 1 == this.desc.saturation[1] * this.desc.saturation[3] && 1 == this.desc.saturation[2] * this.desc.saturation[3] || t.push("#define SATURATION"),
  3130. 1 == this.desc.contrast[0] * this.desc.contrast[3] && 1 == this.desc.contrast[1] * this.desc.contrast[3] && 1 == this.desc.contrast[2] * this.desc.contrast[3] && 1 == this.desc.brightness[0] * this.desc.brightness[3] && 1 == this.desc.brightness[1] * this.desc.brightness[3] && 1 == this.desc.brightness[2] * this.desc.brightness[3] || t.push("#define CONTRAST"),
  3131. 0 != this.desc.grain && t.push("#define GRAIN"),
  3132. 1 == this.desc.toneMap ? t.push("#define REINHARD") : 2 == this.desc.toneMap && t.push("#define HEJL"),
  3133. this.desc.colorLUT && t.push("#define COLOR_LUT"),
  3134. this.sampleIndex = 0,
  3135. this.sampleCount = 1,
  3136. i && (this.sampleCount = 4,
  3137. this.sampleOffsets = [
  3138. [-.5, -.5],
  3139. [.5, -.5],
  3140. [-.5, .5],
  3141. [.5, .5]
  3142. ]),
  3143. this.aaShader = e.shaderCache.fromURLs("postvert.glsl", "postaa.glsl"),
  3144. this.shader = e.shaderCache.fromURLs("postvert.glsl", "postfrag.glsl", t),
  3145. this.plainShader = e.shaderCache.fromURLs("postvert.glsl", "postfrag.glsl", []),
  3146. this.fullscreenTriangle = e.createBuffer(),
  3147. e.bindBuffer(e.ARRAY_BUFFER, this.fullscreenTriangle),
  3148. i = new Float32Array([0, 0, 2, 0, 0, 2]),
  3149. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3150. e.bindBuffer(e.ARRAY_BUFFER, null),
  3151. this.useBloom) {
  3152. for (this.bloomTextures = [],
  3153. this.bloomTargets = [],
  3154. i = 0; i < 2; ++i)
  3155. t = {
  3156. width: 256,
  3157. height: 256,
  3158. clamp: !0
  3159. },
  3160. this.bloomTextures[i] = new U(e, t),
  3161. this.bloomTextures[i].loadArray(null, e.RGBA, e.ext.textureHalf && e.ext.textureHalfLinear ? e.ext.textureHalf.HALF_FLOAT_OES : e.UNSIGNED_BYTE),
  3162. this.bloomTargets[i] = new m(e, {
  3163. width: t.width,
  3164. height: t.height,
  3165. color0: this.bloomTextures[i]
  3166. });
  3167. for (this.bloomSamples = 64; this.bloomSamples + 16 >= e.limits.fragmentUniforms;)
  3168. this.bloomSamples /= 2;
  3169. this.bloomShader = e.shaderCache.fromURLs("postvert.glsl", "bloom.glsl", ["#define BLOOM_SAMPLES " + this.bloomSamples]),
  3170. this.shrinkShader = e.shaderCache.fromURLs("postvert.glsl", "bloomshrink.glsl")
  3171. }
  3172. for (e = new Uint8Array(16384),
  3173. i = 0; i < 16384; i++) {
  3174. t = 255 * Math.random();
  3175. var s = 255 * Math.random();
  3176. e[i] = .5 * (t + s)
  3177. }
  3178. this.noiseTexture = new U(this.gl, {
  3179. width: 128,
  3180. height: 128
  3181. }),
  3182. this.noiseTexture.loadArray(e, this.gl.LUMINANCE),
  3183. this.desc.colorLUT && (e = this.desc.colorLUT,
  3184. this.colorLUT = new U(this.gl, {
  3185. width: e.length / 3 | 0,
  3186. height: 1,
  3187. clamp: !0
  3188. }),
  3189. this.colorLUT.loadArray(new Uint8Array(e), this.gl.RGB)),
  3190. this.blackTexture = new U(this.gl, {
  3191. width: 1,
  3192. height: 1
  3193. }),
  3194. this.blackTexture.loadArray(new Uint8Array([0, 0, 0, 0])),
  3195. this.bloomResult = this.blackTexture
  3196. }
  3197. function k(e) {
  3198. this.gl = e,
  3199. this.name = "untitled",
  3200. this.meshes = [],
  3201. this.meshRenderables = [],
  3202. this.materials = {},
  3203. this.sky = this.view = null,
  3204. this.selectedPartIndex = 0,
  3205. this.soloPart = !1,
  3206. this.miscnotes = "",
  3207. this.nextView = null,
  3208. this.viewFade = 0,
  3209. this.refractionSurface = this.shadow = this.stripData = this.lights = null,
  3210. this.sceneAnimator = this.frameCounter = 0,
  3211. this.sceneLoaded = !1,
  3212. this.debugString = ""
  3213. }
  3214. function P(e, t, i) {
  3215. if (this.scene = e,
  3216. this.animations = [],
  3217. this.skinningRigs = [],
  3218. this.meshIDs = [],
  3219. this.lightIDs = [],
  3220. this.materialIDs = [],
  3221. this.views = [],
  3222. this.viewYawOffsets = [],
  3223. this.viewPitchOffsets = [],
  3224. this.cameraObjectIndices = [],
  3225. this.cameraChildrenIndices = [],
  3226. this.subMeshObjectIndices = [],
  3227. this.subMeshLiveIndices = [],
  3228. this.scene = e,
  3229. this.selectedCameraIndex = -1,
  3230. this.selectedAnimationIndex = 0,
  3231. this.debugString = "",
  3232. this.scenePlaybackSpeed = this.playbackSpeed = 1,
  3233. this.animationProgress = this.totalSeconds = 0,
  3234. this.paused = this.autoAdvanceNextAnimation = !1,
  3235. this.animateVisibility = this.drawAnimated = this.linkSceneObjects = this.loadSkinningRigs = this.animateMaterials = this.animateTurntables = this.enableSkinning = this.animateMeshes = this.animateLights = this.playAnimations = this.loadAnimations = !0,
  3236. this.showDebugInfo = !1,
  3237. this.loopCount = 0,
  3238. this.loopTurntables = this.lockPlayback = !1,
  3239. this.fogObjectIndex = -1,
  3240. this.unitScaleSkinnedMeshes = !0,
  3241. this.sceneScale = i.sceneScale,
  3242. this.defaultCameraGlobalIndex = i.selectedCamera,
  3243. this.selectedAnimationIndex = i.selectedAnimation,
  3244. this.autoPlayAnims = i.autoPlayAnims,
  3245. this.showPlayControls = i.showPlayControls,
  3246. i.scenePlaybackSpeed && (this.scenePlaybackSpeed = i.scenePlaybackSpeed,
  3247. 0 == this.scenePlaybackSpeed && (this.scenePlaybackSpeed = 1)),
  3248. this.autoPlayAnims || (this.paused = !0),
  3249. this.loadAnimations) {
  3250. if (i.meshIDs)
  3251. for (var s = i.meshIDs.length, n = 0; n < s; ++n) {
  3252. var r = i.meshIDs[n].partIndex;
  3253. this.meshIDs.push(r)
  3254. }
  3255. if (i.lightIDs)
  3256. for (s = i.lightIDs.length,
  3257. n = 0; n < s; ++n)
  3258. r = (r = i.lightIDs[n]).partIndex,
  3259. this.lightIDs.push(r);
  3260. if (i.materialIDs)
  3261. for (s = i.materialIDs.length,
  3262. n = 0; n < s; ++n)
  3263. r = (r = i.materialIDs[n]).partIndex,
  3264. this.materialIDs.push(r);
  3265. if (this.numMatricesInTable = i.numMatrices,
  3266. r = new u((n = t.get("MatTable.bin")).data),
  3267. n || (this.numMatricesInTable = 0,
  3268. this.debugString += "<br>No mattable?"),
  3269. i.skinningRigs && this.loadSkinningRigs)
  3270. for (s = i.skinningRigs.length,
  3271. n = 0; n < s; ++n) {
  3272. "" == (a = new M(t, i.skinningRigs[n], r)).debugString ? this.skinningRigs.push(a) : (this.debugString += "<br>Error loading skinning rig " + n + " :" + a.debugString,
  3273. this.debugString += "<br>Skipping the rest",
  3274. n = s)
  3275. }
  3276. if (i.animations)
  3277. for (r = i.animations.length,
  3278. n = 0; n < r; ++n)
  3279. s = new c(t, i.animations[n]),
  3280. this.animations.push(s);
  3281. if (this.startMS = Date.now(),
  3282. r = this.animations.length,
  3283. this.linkSceneObjects && 0 != r) {
  3284. for (n = 0; n < r; n++)
  3285. for (s = (t = this.animations[n]).animatedObjects.length,
  3286. i = 0; i < s; i++)
  3287. "LightSO" == (a = t.animatedObjects[i]).sceneObjectType && (a.lightIndex = this.findLightIndexByPartIndex(i),
  3288. -1 != a.lightIndex ? t.lightObjects.push(a) : this.debugString += "<br> got light not in scene " + a.name),
  3289. "FogSO" == a.sceneObjectType && (this.fogObjectIndex = i),
  3290. "SubMeshSO" == a.sceneObjectType && 0 == n && (this.subMeshObjectIndices.push(i),
  3291. this.subMeshLiveIndices.push(-1)),
  3292. "Material" == a.sceneObjectType && (a.materialIndex = this.findMaterialIndexByPartIndex(i),
  3293. -1 == a.materialIndex ? this.debugString += "<br> can't find material index for object " + i : t.materialObjects.push(a)),
  3294. "TurnTableSO" == a.sceneObjectType && t.turnTableObjects.push(a),
  3295. "MeshSO" == a.sceneObjectType && (a.meshIndex = this.findMeshIndexByPartIndex(this.scene.meshes, i),
  3296. -1 == a.meshIndex ? (this.debugString += "<br> can't find mesh index for object " + i,
  3297. this.logObjectInfo(i, 0)) : (t.meshObjects.push(a),
  3298. a.mesh = this.scene.meshes[a.meshIndex],
  3299. -1 != a.skinningRigIndex && a.mesh && a.skinningRigIndex < this.skinningRigs.length && (a.skinningRig = this.skinningRigs[a.skinningRigIndex],
  3300. a.skinningRig.isRigidSkin || (a.mesh.dynamicVertexData ? a.skinningRig.useOriginalMeshVertices(a.mesh) : (this.debugString += "Skinning object - but mesh is not dynamic",
  3301. this.debugString += "<br>Rig index " + a.skinningRigIndex,
  3302. this.debugString += " not tagged as rigid"))))),
  3303. "CameraSO" == a.sceneObjectType && (a.modelPartIndex = a.id,
  3304. t.cameraObjects.push(a));
  3305. for (i = (t = this.animations[0]).cameraObjects.length,
  3306. n = 0; n < i; n++)
  3307. r = t.cameraObjects[n],
  3308. (s = this.scene.cameras[r.name]) ? (s = s.view) && (s = new H(s),
  3309. this.cameraObjectIndices.push(r.id),
  3310. this.views.push(s),
  3311. this.viewYawOffsets.push(0),
  3312. this.viewPitchOffsets.push(0)) : (this.debugString += "<br>no camDesc for " + r.name,
  3313. this.views.push(e.view));
  3314. for (e = this.scene.meshes.length,
  3315. r = this.subMeshObjectIndices.length,
  3316. n = s = 0; n < e; n++) {
  3317. var a = this.scene.meshes[n],
  3318. o = !1;
  3319. for (i = 0; i < r; i++) {
  3320. var h = this.subMeshObjectIndices[i],
  3321. l = t.animatedObjects[h],
  3322. d = t.animatedObjects[l.parentIndex];
  3323. if (d.mesh || (this.debugString += "<br>submesh parent object has no mesh?",
  3324. this.debugString += "<br>obj.name " + l.name,
  3325. this.debugString += "<br>parent.name " + d.name,
  3326. this.debugString += "<br>submesh index " + i,
  3327. this.debugString += "<br>obj.index " + h),
  3328. d.mesh == a) {
  3329. for (o = 0; o < a.numSubMeshes; o++)
  3330. this.subMeshLiveIndices[i + (a.numSubMeshes - 1 - o)] = s,
  3331. s++;
  3332. i = r,
  3333. o = !0
  3334. }
  3335. }
  3336. o || (this.debugString += "<br>Missing submesh? - no matches for mesh " + n + " of " + e)
  3337. }
  3338. for (n = 0; n < r; n++)
  3339. -
  3340. 1 == this.subMeshLiveIndices[n] && (this.debugString += "<br>Missing mesh? Unused submesh " + n + " of " + r);
  3341. this.showDebugInfo = this.stopEverything = this.runDebugMode = !1,
  3342. this.selectDefaultCamera(),
  3343. this.findCameraChildren(),
  3344. this.findFixedTransforms(),
  3345. this.runDebugMode && (this.setAnimationProgress(0, !0),
  3346. "" != this.debugString ? this.stopEverything = !0 : this.checkDebug())
  3347. }
  3348. } else
  3349. this.debugString += "<br>Skip loading animation data"
  3350. }
  3351. function F(e) {
  3352. this.gl = e,
  3353. this.program = null,
  3354. this.params = {},
  3355. this.samplers = {},
  3356. this.attribs = {}
  3357. }
  3358. function O(e) {
  3359. this.gl = e,
  3360. this.cache = []
  3361. }
  3362. function E(e, t) {
  3363. if (this.gl = e,
  3364. this.shadowCount = t,
  3365. this.nativeDepth = !!e.ext.textureDepth,
  3366. this.desc = i,
  3367. i = this.nativeDepth ? ["#define SHADOW_NATIVE_DEPTH"] : [],
  3368. this.shaderSolid = e.shaderCache.fromURLs("shadowvert.glsl", "shadowfrag.glsl", i),
  3369. i.push("#define ALPHA_TEST 1"),
  3370. this.shaderAlphaTest = e.shaderCache.fromURLs("shadowvert.glsl", "shadowfrag.glsl", i),
  3371. this.depthTextures = [],
  3372. this.depthTargets = [],
  3373. 0 < this.shadowCount) {
  3374. var i = {
  3375. width: 2048,
  3376. height: 2048,
  3377. clamp: !0,
  3378. mipmap: !1,
  3379. nofilter: !0
  3380. };
  3381. e.hints.mobile && (i.width = i.height = 1536);
  3382. var s, n, r = {
  3383. width: i.width,
  3384. height: i.height
  3385. };
  3386. n = this.nativeDepth ? (s = e.DEPTH_COMPONENT,
  3387. e.UNSIGNED_SHORT) : (r.depthBuffer = m.createDepthBuffer(e, i.width, i.height),
  3388. s = e.RGB,
  3389. e.UNSIGNED_BYTE);
  3390. for (var a = 0; a < this.shadowCount; ++a)
  3391. this.depthTextures[a] = new U(e, i),
  3392. this.depthTextures[a].loadArray(null, s, n),
  3393. this.nativeDepth ? r.depth = this.depthTextures[a] : r.color0 = this.depthTextures[a],
  3394. this.depthTargets[a] = new m(e, r)
  3395. }
  3396. }
  3397. function B(e, t, i, s) {
  3398. this.gl = e,
  3399. this.desc = t,
  3400. this.lightCount = s.count,
  3401. this.shadowCount = i.shadowCount,
  3402. (t = this.nativeDepth ? ["#define SHADOW_NATIVE_DEPTH"] : []).push("#define LIGHT_COUNT " + this.lightCount),
  3403. t.push("#define SHADOW_COUNT " + this.shadowCount),
  3404. e.hints.mobile && t.push("#define MOBILE"),
  3405. this.shader = e.shaderCache.fromURLs("shadowfloorvert.glsl", "shadowfloorfrag.glsl", t),
  3406. t = new Float32Array([-1, 0, -1, -1, 0, 1, 1, 0, 1, -1, 0, -1, 1, 0, 1, 1, 0, -1]),
  3407. this.quadGeom = e.createBuffer(),
  3408. e.bindBuffer(e.ARRAY_BUFFER, this.quadGeom),
  3409. e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW),
  3410. e.bindBuffer(e.ARRAY_BUFFER, null)
  3411. }
  3412. function L() {
  3413. this.associateObjectIndex = this.linkObjectIndex = this.linkMode = 0,
  3414. this.vertexIndices = [],
  3415. this.vertexWeights = [],
  3416. this.matrix = S.identity(),
  3417. this.defaultAssociateWorldTransform = this.defaultClusterWorldTransform = this.defaultClusterBaseTransform = 0,
  3418. this.defaultClusterWorldTransformInvert = S.identity(),
  3419. this.defaultAssociateWorldTransformInvert = S.identity(),
  3420. this.debugString = ""
  3421. }
  3422. function M(e, t, i) {
  3423. if (this.debugString = "",
  3424. this.skinningClusters = [],
  3425. this.srcVFile = t.file,
  3426. e = e.get(this.srcVFile))
  3427. if (e.data) {
  3428. this.rigByteStream = new u(e.data),
  3429. e = new Uint32Array(this.rigByteStream.bytes.buffer, 0, this.rigByteStream.bytes.length / 4),
  3430. this.expectedNumClusters = e[0],
  3431. this.expectedNumVertices = e[1],
  3432. this.numClusterLinks = e[2],
  3433. this.originalObjectIndex = e[3],
  3434. this.isRigidSkin = e[4],
  3435. this.tangentMethod = e[5],
  3436. t = 6 + 7 * this.expectedNumClusters;
  3437. for (var s = 0; s < this.expectedNumClusters; s++) {
  3438. var n = new L();
  3439. this.skinningClusters.push(n);
  3440. var r = 6 + 7 * s;
  3441. n.linkMode = e[1 + r],
  3442. n.linkObjectIndex = e[2 + r],
  3443. n.associateObjectIndex = e[3 + r];
  3444. var a = e[5 + r];
  3445. n.defaultClusterWorldTransform = i.getMatrix(e[4 + r]),
  3446. n.defaultClusterBaseTransform = i.getMatrix(a),
  3447. S.invert(n.defaultClusterWorldTransformInvert, n.defaultClusterWorldTransform),
  3448. 1 == n.linkMode && (n.defaultAssociateWorldTransform = i.getMatrix(e[6 + r]),
  3449. S.invert(n.defaultAssociateWorldTransformInvert, n.defaultAssociateWorldTransform))
  3450. }
  3451. e = (t = (i = 4 * t) + this.expectedNumVertices) + 2 * this.numClusterLinks,
  3452. t = new Uint8Array(this.rigByteStream.bytes.subarray(t)),
  3453. e = new Uint8Array(this.rigByteStream.bytes.subarray(e)),
  3454. this.linkMapCount = new Uint8Array(this.rigByteStream.bytes.buffer, i, this.expectedNumVertices),
  3455. this.linkMapClusterIndices = new Uint16Array(t.buffer),
  3456. this.linkMapWeights = new Float32Array(e.buffer)
  3457. } else
  3458. this.debugString += "<br>No data in " + this.srcVFile;
  3459. else
  3460. this.debugString += "<br>Error loading buffer for skinning rig " + this.srcVFile
  3461. }
  3462. function _(e, t, i) {
  3463. if (this.gl = e,
  3464. void 0 !== (s = t.extract("sky.dat") || t.extract("sky.png"))) {
  3465. this.specularTexture = new U(e, {
  3466. width: 256,
  3467. height: 2048,
  3468. clamp: !0
  3469. }),
  3470. t = s.data;
  3471. for (var s, n = (s = s.data.length) / 4, r = new Uint8Array(s), a = 0, o = 0; a < s; ++o)
  3472. r[a++] = t[o + 2 * n],
  3473. r[a++] = t[o + n],
  3474. r[a++] = t[o],
  3475. r[a++] = t[o + 3 * n];
  3476. this.specularTexture.loadArray(r)
  3477. }
  3478. if (this.diffuseCoefficients = new Float32Array(i.diffuseCoefficients),
  3479. this.backgroundMode = i.backgroundMode || 0,
  3480. this.backgroundBrightness = i.backgroundBrightness || 1,
  3481. this.backgroundColor = new Float32Array(i.backgroundColor),
  3482. 1 <= this.backgroundMode)
  3483. if (this.backgroundShader = e.shaderCache.fromURLs("skyvert.glsl", 3 == this.backgroundMode ? "skySH.glsl" : "sky.glsl", ["#define SKYMODE " + this.backgroundMode]),
  3484. this.vertexBuffer = e.createBuffer(),
  3485. e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer),
  3486. i = 1 / 256,
  3487. s = 2.8 * (t = .5 / 256),
  3488. n = .5 * t,
  3489. i = new Float32Array([0, 1, 0, .49609375 + i, .49609375 + i, 1, 0, 0, .9921875 + i, .49609375 + i, 0, 0, 1, .49609375 + i, .9921875 + i, -1, 0, 0, 0 + i, .49609375 + i, 0, 0, -1, .49609375 + i, 0 + i, 0, -1, 0, .9921875 + i, 0 + i, 0, -1, 0, .9921875 + i, .9921875 + i, 0, -1, 0, 0 + i, .9921875 + i, 0, -1, 0, 0 + i, 0 + i, s, 1 - s, -s, .5 + t, .5 - t, s, 1 - s, s, .5 + t, .5 + t, -s, 1 - s, s, .5 - t, .5 + t, -s, 1 - s, -s, .5 - t, .5 - t, -s, 0, -1 + s, .5 - t, 0 + i + t, s, 0, -1 + s, .5 + t, 0 + i + t, 1 - s, 0, -s, .9921875 + i - t, .5 - t, 1 - s, 0, s, .9921875 + i - t, .5 + t, s, 0, 1 - s, .5 + t, .9921875 + i - t, -s, 0, 1 - s, .5 - t, .9921875 + i - t, -1 + s, 0, s, 0 + i + t, .5 + t, -1 + s, 0, -s, 0 + i + t, .5 - t, 1, 0, 0, .9921875 + i - n, .49609375 + i, 0, 0, 1, .49609375 + i, .9921875 + i - n, -1, 0, 0, 0 + i + n, .49609375 + i, 0, 0, -1, .49609375 + i, 0 + i + n, 0, 1, 0, .49609375 + i - n, .49609375 + i, 0, 1, 0, .49609375 + i, .49609375 + i - n, 0, 1, 0, .49609375 + i + n, .49609375 + i, 0, 1, 0, .49609375 + i, .49609375 + i + n]),
  3490. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3491. e.bindBuffer(e.ARRAY_BUFFER, null),
  3492. this.indexBuffer = e.createBuffer(),
  3493. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer),
  3494. i = new Uint16Array([2, 1, 6, 3, 2, 7, 8, 4, 3, 4, 5, 1, 9, 14, 15, 17, 10, 16, 18, 19, 11, 20, 13, 12, 28, 12, 13, 13, 24, 28, 28, 24, 9, 9, 24, 14, 25, 9, 15, 25, 15, 21, 10, 25, 21, 10, 21, 16, 22, 26, 10, 22, 10, 17, 18, 11, 26, 22, 18, 26, 19, 23, 27, 19, 27, 11, 23, 20, 27, 27, 20, 12]),
  3495. this.skyIndexCount = i.length,
  3496. e.bufferData(e.ELEMENT_ARRAY_BUFFER, i, e.STATIC_DRAW),
  3497. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null),
  3498. 3 == this.backgroundMode)
  3499. for (this.backgroundCoefficients = new Float32Array(this.diffuseCoefficients),
  3500. a = 0; a < this.backgroundCoefficients.length; ++a)
  3501. this.backgroundCoefficients[a] *= this.backgroundBrightness;
  3502. else {
  3503. var h;
  3504. this.backgroundTexture = new U(e, {
  3505. width: 256,
  3506. height: 256,
  3507. clamp: !0
  3508. }),
  3509. i = !1,
  3510. e.ext.textureHalf && e.ext.textureHalfLinear && (this.backgroundTexture.loadArray(null, e.RGB, e.ext.textureHalf.HALF_FLOAT_OES),
  3511. i = (h = new m(e, {
  3512. color0: this.backgroundTexture
  3513. })).valid),
  3514. !i && e.ext.textureFloat && e.ext.textureFloatLinear && !e.hints.mobile && (this.backgroundTexture.loadArray(null, e.RGB, e.FLOAT),
  3515. i = (h = new m(e, {
  3516. color0: this.backgroundTexture
  3517. })).valid),
  3518. i || (this.backgroundTexture.loadArray(),
  3519. h = new m(e, {
  3520. color0: this.backgroundTexture
  3521. })),
  3522. h.bind(),
  3523. (h = new F(e)).build("precision highp float; varying vec2 tc; attribute vec4 p; void main(){ gl_Position=p; tc=vec2(0.5,0.5/8.0)*p.xy+vec2(0.5,6.5/8.0); }", "precision highp float; varying vec2 tc; uniform sampler2D tex; uniform float b; void main(){vec4 s=texture2D(tex,tc); gl_FragColor.xyz=s.xyz*(b*s.w);}"),
  3524. h.bind(),
  3525. e.uniform1f(h.params.b, 7 * Math.sqrt(this.backgroundBrightness)),
  3526. this.specularTexture.bind(h.samplers.tex),
  3527. i = e.createBuffer(),
  3528. e.bindBuffer(e.ARRAY_BUFFER, i),
  3529. i = new Float32Array([-1, -1, .5, 1, 3, -1, .5, 1, -1, 3, .5, 1]),
  3530. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3531. e.enableVertexAttribArray(h.attribs.p),
  3532. e.vertexAttribPointer(h.attribs.p, 4, e.FLOAT, !1, 0, 0),
  3533. e.drawArrays(e.TRIANGLES, 0, 3),
  3534. e.disableVertexAttribArray(h.attribs.p)
  3535. }
  3536. }
  3537. function D() {
  3538. this.STRIP_NONE = -2,
  3539. this.STRIP_MENU = -1,
  3540. this.stripCount = 5,
  3541. this.strips = [0, 0, 0, 0, 0],
  3542. this.labels = ["Normals", "Albedo", "Reflectivity", "Gloss", "Topology"],
  3543. this.stripSlant = .25,
  3544. this.selectedStrip = this.STRIP_NONE,
  3545. this.animationActive = !1,
  3546. this.timestamp = Date.now(),
  3547. this.update(!0)
  3548. }
  3549. function U(e, t) {
  3550. this.gl = e,
  3551. this.id = null,
  3552. this.type = e.TEXTURE_2D,
  3553. this.format = e.RGBA,
  3554. this.componentType = e.UNSIGNED_BYTE,
  3555. t = t || {},
  3556. this.desc = {
  3557. width: t.width || 1,
  3558. height: t.height || 1,
  3559. mipmap: t.mipmap,
  3560. clamp: t.clamp,
  3561. mirror: t.mirror,
  3562. aniso: t.aniso,
  3563. nofilter: t.nofilter
  3564. }
  3565. }
  3566. function N(e) {
  3567. this.gl = e,
  3568. this.cache = []
  3569. }
  3570. function z(e, t) {
  3571. this.name = "none",
  3572. this.debugString = "",
  3573. this.knobControlRect = new s(e),
  3574. this.controlRect = new s(e);
  3575. var i = document.createElement("div");
  3576. i.id = "sliderUI",
  3577. i.style.position = "absolute",
  3578. i.style.overflow = "hidden",
  3579. i.style["-moz-user-select"] = "none",
  3580. i.style["-khtml-user-select"] = "none",
  3581. i.style["-webkit-user-select"] = "none",
  3582. i.style["-ms-user-select"] = "none",
  3583. this.controlRect.linkedControl = i,
  3584. this.backgroundControl = 0,
  3585. this.controlRect.registerChildControlRect(this.knobControlRect),
  3586. this.knobControlRect.setOpacity(.65),
  3587. this.sliderPercent = this.pixelsY = this.pixelsX = 0,
  3588. this.draggingSlider = !1,
  3589. this.guiScreen = e,
  3590. t.addImageElement(this.knobControlRect, "animationknob" + e.imageSetNumber + "x.png")
  3591. }
  3592. function j(e) {
  3593. this.viewer = e,
  3594. this.stripData = e.stripData,
  3595. (e = this.container = document.createElement("div")).id = "fdageUI",
  3596. e.style.position = "absolute",
  3597. e.style.overflow = "hidden",
  3598. e.style["-moz-user-select"] = "none",
  3599. e.style["-khtml-user-select"] = "none",
  3600. e.style["-webkit-user-select"] = "none",
  3601. e.style["-ms-user-select"] = "none",
  3602. this.viewer.domRoot.appendChild(e),
  3603. this.guiScreen = new t(this)
  3604. }
  3605. R.prototype.resize = function (e) {
  3606. e.ui.viewer.scene.sceneAnimator.showPlayControls || (e.width = 1,
  3607. e.height = 1),
  3608. this.compactMode = e.width < this.minWidth;
  3609. var t = this.bottomOffset,
  3610. i = this.bottomOffset + 4,
  3611. s = 0;
  3612. this.cameraList && this.animationList ? s += 42 + this.cameraList.localPixelsX + this.animationList.localPixelsX : this.cameraList ? s += 28 + this.cameraList.localPixelsX : this.animationList && (s += 28 + this.animationList.localPixelsX);
  3613. var n = e.width - s - 72;
  3614. 0 == s && (n -= 14);
  3615. var r = 116,
  3616. a = r + n + 14;
  3617. this.compactMode && (r = 58,
  3618. n += 44 + s,
  3619. 0 < s && (t += 32),
  3620. s || (i += 32));
  3621. var o = (s = 32 / n) + 14 / n,
  3622. h = 1 - o,
  3623. l = this.playbackRegion;
  3624. l.controlRect.widthPercent = n / e.width,
  3625. l.controlRect.heightPercent = 32 / e.height,
  3626. l.controlRect.xPercent = r / e.width,
  3627. l.controlRect.yPercent = t / e.height,
  3628. this.pauseButton.controlRect.set(0, .125, s, .75),
  3629. this.playButton.controlRect.set(0, .125, s, .75),
  3630. this.timelineSlider.controlRect.set(o, .03125, h, 1),
  3631. this.timelineSlider.setSize(n - 46, 32),
  3632. l.controlRect.updateElement(),
  3633. l.controlRect.updateChildElements(),
  3634. this.speedList.setControl(58, i, 44, 24, !1),
  3635. this.cameraList && (this.cameraList.setControl(a, i, 10, 24, !0, 8),
  3636. a += this.cameraList.localPixelsX + 14),
  3637. this.animationList && this.animationList.setControl(a, i, 10, 24, !0, 8),
  3638. this.timelineSlider.backgroundControl.alignBackground()
  3639. },
  3640. R.prototype.setupCallbacks = function () {
  3641. var e = function (e) {
  3642. "0.01x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.01),
  3643. "0.05x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.05),
  3644. "0.25x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.25),
  3645. "0.5x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.5),
  3646. "1.0x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(1),
  3647. "2.0x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(2),
  3648. "4.0x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(4)
  3649. }
  3650. .bind(this),
  3651. t = function (e) {
  3652. this.ui.viewer.scene.sceneAnimator.selectCamera(this.cameraList.selectedIndex),
  3653. this.ui.viewer.wake()
  3654. }
  3655. .bind(this),
  3656. i = function (e) {
  3657. this.ui.viewer.scene.sceneAnimator.selectAnimation(this.animationList.selectedIndex),
  3658. this.ui.viewer.wake()
  3659. }
  3660. .bind(this);
  3661. this.speedList && (this.speedList.selectionChangedCallback = e),
  3662. this.cameraList && (this.cameraList.selectionChangedCallback = t),
  3663. this.animationList && (this.animationList.selectionChangedCallback = i),
  3664. this.playButton.controlRect.linkedControl.onclick = function () {
  3665. this.ui.viewer.scene.sceneAnimator.pause(!1),
  3666. this.playButton.controlRect.showControl(!1),
  3667. this.pauseButton.controlRect.showControl(!0),
  3668. this.ui.viewer.wake()
  3669. }
  3670. .bind(this),
  3671. this.pauseButton.controlRect.linkedControl.onclick = function () {
  3672. this.ui.viewer.scene.sceneAnimator.pause(!0),
  3673. this.playButton.controlRect.showControl(!0),
  3674. this.pauseButton.controlRect.showControl(!1)
  3675. }
  3676. .bind(this)
  3677. },
  3678. A.prototype.prepareBloom = function (e) {
  3679. if (this.useBloom && this.bloomShader.complete() && this.shrinkShader.complete()) {
  3680. this.shrinkShader.bind(),
  3681. this.bloomTargets[1].bind(),
  3682. e.bind(this.shrinkShader.samplers.tInput),
  3683. this.fillScreen(this.shrinkShader.attribs.vCoord),
  3684. this.bloomShader.bind();
  3685. var t = [];
  3686. this.bloomTargets[0].bind(),
  3687. this.bloomTextures[1].bind(this.bloomShader.samplers.tInput);
  3688. for (var i = 0, s = 0; s < this.bloomSamples; ++s) {
  3689. var n, r = 2 * s / (this.bloomSamples - 1) - 1;
  3690. n = 4 * r,
  3691. i += n = Math.exp(-.5 * n * n / 1) / 2.50662827463,
  3692. t[4 * s + 0] = r * this.desc.bloomSize,
  3693. t[4 * s + 1] = 0,
  3694. t[4 * s + 2] = n,
  3695. t[4 * s + 3] = 0
  3696. }
  3697. for (s = 0; s < this.bloomSamples; ++s)
  3698. t[4 * s + 2] /= i;
  3699. for (this.gl.uniform4fv(this.bloomShader.params.uKernel, t),
  3700. this.fillScreen(this.bloomShader.attribs.vCoord),
  3701. this.bloomTargets[1].bind(),
  3702. this.bloomTextures[0].bind(this.bloomShader.samplers.tInput),
  3703. s = 0; s < this.bloomSamples; ++s)
  3704. i = t[4 * s + 0],
  3705. i *= e.desc.width / e.desc.height,
  3706. t[4 * s + 0] = 0,
  3707. t[4 * s + 1] = i;
  3708. this.gl.uniform4fv(this.bloomShader.params.uKernel, t),
  3709. this.fillScreen(this.bloomShader.attribs.vCoord),
  3710. this.bloomResult = this.bloomTextures[1]
  3711. } else
  3712. this.bloomResult = this.blackTexture
  3713. },
  3714. A.prototype.computeParams = function (e, t) {
  3715. var i = this.desc,
  3716. s = {};
  3717. s.scale = [i.contrast[0] * i.contrast[3], i.contrast[1] * i.contrast[3], i.contrast[2] * i.contrast[3]],
  3718. s.bias = [i.bias[0] * i.bias[3], i.bias[1] * i.bias[3], i.bias[2] * i.bias[3]],
  3719. s.bias = [-s.bias[0] * s.scale[0] + s.bias[0], -s.bias[1] * s.scale[1] + s.bias[1], -s.bias[2] * s.scale[2] + s.bias[2]];
  3720. var n = [i.brightness[0] * i.brightness[3], i.brightness[1] * i.brightness[3], i.brightness[2] * i.brightness[3]];
  3721. s.scale = [s.scale[0] * n[0], s.scale[1] * n[1], s.scale[2] * n[2]],
  3722. s.bias = [s.bias[0] * n[0], s.bias[1] * n[1], s.bias[2] * n[2]],
  3723. s.saturation = [i.saturation[0] * i.saturation[3], i.saturation[1] * i.saturation[3], i.saturation[2] * i.saturation[3]],
  3724. s.bloomColor = [i.bloomColor[0] * i.bloomColor[3], i.bloomColor[1] * i.bloomColor[3], i.bloomColor[2] * i.bloomColor[3]],
  3725. s.sharpen = [i.sharpen, .25 * i.sharpen, i.sharpenLimit],
  3726. s.sharpenKernel = [1 / e, 0, 0, 1 / t],
  3727. n = t < e ? e : t,
  3728. s.vignetteAspect = [e / n, t / n, .5 * e / n, .5 * t / n],
  3729. s.vignette = [2 * (1 - i.vignette[0]) * i.vignette[3], 2 * (1 - i.vignette[1]) * i.vignette[3], 2 * (1 - i.vignette[2]) * i.vignette[3], i.vignetteCurve];
  3730. n = 1 / this.noiseTexture.desc.width;
  3731. var r = 1 / this.noiseTexture.desc.height,
  3732. a = 1 - i.grainSharpness;
  3733. return s.grainCoord = [n * e, r * t, .5 * a * n, .5 * a * r],
  3734. s.grainScaleBias = [2 * i.grain, -i.grain],
  3735. s
  3736. },
  3737. A.prototype.present = function (e, t, i, s) {
  3738. if (s || this.prepareBloom(e),
  3739. 1 < this.sampleCount && this.allocAABuffer(t, i),
  3740. (s = s ? this.plainShader : this.shader).bind()) {
  3741. var n = this.gl,
  3742. r = s.samplers,
  3743. a = s.params,
  3744. o = this.computeParams(t, i);
  3745. if (e.bind(r.tInput),
  3746. this.bloomResult.bind(r.tBloom),
  3747. this.noiseTexture.bind(r.tGrain),
  3748. this.colorLUT && this.colorLUT.bind(r.tLUT),
  3749. n.uniform3fv(a.uScale, o.scale),
  3750. n.uniform3fv(a.uBias, o.bias),
  3751. n.uniform3fv(a.uSaturation, o.saturation),
  3752. n.uniform4fv(a.uSharpenKernel, o.sharpenKernel),
  3753. n.uniform3fv(a.uSharpness, o.sharpen),
  3754. n.uniform3fv(a.uBloomColor, o.bloomColor),
  3755. n.uniform4fv(a.uVignetteAspect, o.vignetteAspect),
  3756. n.uniform4fv(a.uVignette, o.vignette),
  3757. n.uniform4fv(a.uGrainCoord, o.grainCoord),
  3758. n.uniform2fv(a.uGrainScaleBias, o.grainScaleBias),
  3759. e = 1 < this.sampleCount && 0 <= this.sampleIndex) {
  3760. var h = 1 / (1 + this.sampleIndex);
  3761. this.sampleIndex += 1,
  3762. h < 1 && (n.enable(n.BLEND),
  3763. n.blendColor(h, h, h, h),
  3764. n.blendFunc(n.CONSTANT_ALPHA, n.ONE_MINUS_CONSTANT_ALPHA)),
  3765. this.aaTarget.bind()
  3766. } else
  3767. m.bindNone(n),
  3768. 1 < this.sampleCount && (this.sampleIndex += 1);
  3769. n.viewport(0, 0, t, i),
  3770. this.fillScreen(s.attribs.vCoord),
  3771. e && (h < 1 && n.disable(n.BLEND),
  3772. m.bindNone(n),
  3773. this.aaShader.bind(),
  3774. this.aaBuffer.bind(this.aaShader.samplers.tInput),
  3775. this.fillScreen(this.aaShader.attribs.vCoord))
  3776. }
  3777. },
  3778. A.prototype.allocAABuffer = function (e, t) {
  3779. this.aaBuffer && this.aaBuffer.desc.width == e && this.aaBuffer.desc.height == t || (this.aaBuffer && this.aaBuffer.destroy(),
  3780. this.aaBuffer = new U(this.gl, {
  3781. width: e,
  3782. height: t,
  3783. clamp: !0
  3784. }),
  3785. this.aaBuffer.loadArray(),
  3786. this.aaTarget = new m(this.gl, {
  3787. color0: this.aaBuffer,
  3788. ignoreStatus: !0
  3789. }))
  3790. },
  3791. A.prototype.adjustProjectionForSupersampling = function (e) {
  3792. if (1 < this.sampleCount) {
  3793. var t = this.currentSample(),
  3794. i = this.sampleOffsets[t][0] / e.size[0];
  3795. t = this.sampleOffsets[t][1] / e.size[1],
  3796. i = S.translation(S.empty(), i, t, 0);
  3797. S.mul(e.projectionMatrix, i, e.projectionMatrix)
  3798. }
  3799. },
  3800. A.prototype.discardAAHistory = function () {
  3801. this.sampleIndex = -1
  3802. },
  3803. A.prototype.currentSample = function () {
  3804. return (this.sampleIndex < 0 ? 0 : this.sampleIndex) % this.sampleCount
  3805. },
  3806. A.prototype.fillScreen = function (e) {
  3807. var t = this.gl;
  3808. t.bindBuffer(t.ARRAY_BUFFER, this.fullscreenTriangle),
  3809. t.enableVertexAttribArray(e),
  3810. t.vertexAttribPointer(e, 2, t.FLOAT, !1, 0, 0),
  3811. t.drawArrays(t.TRIANGLES, 0, 3),
  3812. t.disableVertexAttribArray(e),
  3813. t.bindBuffer(t.ARRAY_BUFFER, null)
  3814. },
  3815. A.prototype.blitTexture = function (e) {
  3816. this.aaShader.bind(),
  3817. e.bind(this.aaShader.samplers.tInput),
  3818. this.fillScreen(this.aaShader.attribs.vCoord)
  3819. },
  3820. k.prototype.load = function (e) {
  3821. var t, i = this.gl,
  3822. s = e.extract("scene.json");
  3823. if (void 0 === s)
  3824. return !1;
  3825. if (!e.checkSignature(s))
  3826. return !1;
  3827. if (null == (s = new u(s.data).asString()) || s.length <= 0)
  3828. return !1;
  3829. try {
  3830. t = JSON.parse(s)
  3831. } catch (e) {
  3832. return console.error(e),
  3833. !1
  3834. }
  3835. for (var n in this.metaData = t.metaData,
  3836. this.view = new H(t.mainCamera.view),
  3837. this.sky = new _(this.gl, e, t.sky),
  3838. this.lights = new x(t.lights, this.view),
  3839. this.materialsList = [],
  3840. this.materials = {},
  3841. t.materials) {
  3842. var r = t.materials[n];
  3843. r.lightCount = this.lights.count,
  3844. r.shadowCount = this.lights.shadowCount,
  3845. s = new b(this.gl, e, r),
  3846. this.materials[r.name] = s,
  3847. this.materialsList.push(s)
  3848. }
  3849. if (t.meshes)
  3850. for (r = 0; r < t.meshes.length; ++r) {
  3851. n = t.meshes[r],
  3852. n = new T(this.gl, n, e.extract(n.file)),
  3853. this.meshes.push(n);
  3854. for (var a = 0; a < n.desc.subMeshes.length; ++a) {
  3855. var o = n.desc.subMeshes[a];
  3856. (s = this.materials[o.material]) && (n.numSubMeshes++,
  3857. this.meshRenderables.push(new w(n, o, s)))
  3858. }
  3859. }
  3860. return this.bounds = new d(this.meshes),
  3861. this.postRender = new A(this.gl, t.mainCamera.post, !0),
  3862. this.shadow = new E(i, this.lights.shadowCount),
  3863. this.cameras = t.Cameras,
  3864. t.AnimData && (this.sceneAnimator = new P(this, e, t.AnimData)),
  3865. t.fog && (this.fog = new f(i, t.fog)),
  3866. t.shadowFloor && (this.shadowFloor = new B(i, t.shadowFloor, this.shadow, this.lights)),
  3867. this.sceneLoaded = !0
  3868. },
  3869. k.prototype.update = function () {
  3870. this.sceneAnimator && (this.frameCounter++,
  3871. this.lights.flagUpdateAnimatedLighting(),
  3872. this.sceneAnimator.drawAnimated && (1 == this.frameCounter ? this.sceneAnimator.resetPlayback() : this.sceneAnimator.updateAnimationPlayback())),
  3873. this.lights.update(this.view, this.bounds)
  3874. },
  3875. k.prototype.collectShadows = function (e) {
  3876. this.shadow.collect(this, e)
  3877. },
  3878. k.prototype.draw = function (e) {
  3879. var t = this.gl;
  3880. if (this.sceneLoaded) {
  3881. this.sky.setClearColor(),
  3882. t.clear(t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT | t.STENCIL_BUFFER_BIT),
  3883. t.enable(t.DEPTH_TEST),
  3884. this.sky.draw(this),
  3885. this.shadowFloor && this.shadowFloor.draw(this);
  3886. for (var i = 0; i < this.meshRenderables.length; ++i)
  3887. this.meshRenderables[i].material.usesBlending || this.meshRenderables[i].material.usesRefraction || !this.meshRenderables[i].visible || this.meshRenderables[i].draw(this);
  3888. for (t.enable(t.POLYGON_OFFSET_FILL),
  3889. t.polygonOffset(1, 1),
  3890. t.colorMask(!1, !1, !1, !1),
  3891. i = 0; i < this.meshRenderables.length; ++i)
  3892. this.meshRenderables[i].drawAlphaPrepass(this);
  3893. for (t.colorMask(!0, !0, !0, !0),
  3894. t.disable(t.POLYGON_OFFSET_FILL),
  3895. t.depthFunc(t.LEQUAL),
  3896. t.depthMask(!1),
  3897. i = 0; i < this.meshRenderables.length; ++i)
  3898. this.meshRenderables[i].material.usesBlending && this.meshRenderables[i].visible && this.meshRenderables[i].draw(this);
  3899. t.disable(t.BLEND),
  3900. t.depthMask(!0),
  3901. t.depthFunc(t.LESS);
  3902. var s = !1;
  3903. for (i = 0; i < this.meshRenderables.length; ++i)
  3904. if (this.meshRenderables[i].material.usesRefraction) {
  3905. s = !0;
  3906. break
  3907. }
  3908. if (s)
  3909. for (this.refractionSurface && this.refractionSurface.desc.width == e.color0.desc.width && this.refractionSurface.desc.height == e.color0.desc.height || (this.refractionSurface = new U(t, e.color0.desc),
  3910. this.refractionSurface.loadArray(null, e.color0.format, e.color0.componentType),
  3911. this.refractionBuffer = new m(this.gl, {
  3912. color0: this.refractionSurface
  3913. })),
  3914. this.refractionBuffer.bind(),
  3915. this.postRender.blitTexture(e.color0),
  3916. e.bind(),
  3917. i = 0; i < this.meshRenderables.length; ++i)
  3918. this.meshRenderables[i].material.usesRefraction && this.meshRenderables[i].visible && this.meshRenderables[i].draw(this);
  3919. if (this.stripData.activeWireframe() && 0 < this.meshRenderables.length) {
  3920. for (i = 0; i < this.meshRenderables.length; ++i)
  3921. this.meshRenderables[i].visible && this.meshRenderables[i].drawWire(this);
  3922. t.depthMask(!0)
  3923. }
  3924. t.disable(t.BLEND)
  3925. }
  3926. },
  3927. k.prototype.drawSecondary = function (e) {
  3928. this.fog && this.fog.draw(this, e)
  3929. },
  3930. k.prototype.complete = function () {
  3931. if (!this.sky.complete() || !this.shadow.complete() || this.fog && !this.fog.complete() || this.shadowFloor && !this.shadowFloor.complete())
  3932. return !1;
  3933. for (var e = 0; e < this.meshRenderables.length; ++e)
  3934. if (!this.meshRenderables[e].complete())
  3935. return !1;
  3936. return !0
  3937. },
  3938. P.prototype.flagAllForDebugging = function () {
  3939. for (var e = this.animations.length, t = 0; t < e; t++)
  3940. for (var i = this.animations[t], s = i.animatedObjects.length, n = 0; n < s; n++)
  3941. i.animatedObjects[n].debugMe = !0
  3942. },
  3943. P.prototype.checkDebug = function () {
  3944. this.debugString = "<br>--------------------------------------Debug Info:",
  3945. this.debugString += "<br>this.selectedAnimationIndex :" + this.selectedAnimationIndex;
  3946. var e = this.animations[this.selectedAnimationIndex],
  3947. t = e.animatedObjects.length;
  3948. this.debugString += "<br>numAnimatedObjects :" + t,
  3949. "" != e.debugString && (this.debugString += "<br>--------------------------------------------------Got animation bug info:",
  3950. this.debugString += e.debugString,
  3951. this.showDebugInfo = this.stopEverything = !0,
  3952. e.debugString = "");
  3953. for (var i = 0; i < t; i++) {
  3954. var s = e.animatedObjects[i];
  3955. "" == s.debugString && "" == s.animatedLocalTransform.debugString || (this.debugString += "<br>--------------------------------------------------Got object bug info:",
  3956. this.debugString += s.debugString,
  3957. this.debugString += s.animatedLocalTransform.debugString,
  3958. this.showDebugInfo = this.stopEverything = !0,
  3959. s.debugString = "",
  3960. s.animatedLocalTransform.debugString = ""),
  3961. s.skinningRig && "" != s.skinningRig.debugString && (this.debugString += "<br>--------------------------------------------------Got skin rig info:",
  3962. this.debugString += s.skinningRig.debugString,
  3963. s.skinningRig.debugString = "",
  3964. this.showDebugInfo = this.stopEverything = !0)
  3965. }
  3966. this.debugString += "<br>--------------------------------------Done Debug Info:"
  3967. },
  3968. P.prototype.logObjectInfo = function (e, t) {
  3969. var i = t * (o = this.animations[this.selectedAnimationIndex]).originalFPS;
  3970. if (e >= o.animatedObjects.length)
  3971. this.debugString += "object index " + e + " exceeds " + o.animatedObjects.length;
  3972. else {
  3973. var s = o.animatedObjects[e],
  3974. n = o.animatedObjects[s.modelPartIndex],
  3975. r = o.getObjectAnimationFramePercent(s, t),
  3976. a = o.getObjectAnimationFramePercent(n, t);
  3977. this.debugString = "",
  3978. this.debugString += "<br>Object Name: " + s.name,
  3979. this.debugString += "<br>Object Type: " + s.sceneObjectType,
  3980. this.debugString += "<br>Object Index: " + s.id,
  3981. this.debugString += "<br>Part Index: " + s.modelPartIndex,
  3982. this.debugString += "<br>Part Scale: " + s.modelPartScale,
  3983. this.debugString += "<br>Mesh Index: " + s.meshIndex,
  3984. this.debugString += "<br>Light Index: " + s.lightIndex,
  3985. this.debugString += "<br>Deformer Index: " + s.skinningRigIndex,
  3986. this.debugString += "<br>Parent Index: " + s.parentIndex,
  3987. this.debugString += "<br>Scene time " + t,
  3988. this.debugString += "<br>Scene framepercent " + i,
  3989. this.debugString += "<br>Object looped framepercent " + r,
  3990. this.debugString += "<br>Model looped framepercent " + a,
  3991. this.debugString += "<br>Object Anim length " + s.animationLength,
  3992. this.debugString += "<br>Object Total frames " + s.totalFrames,
  3993. this.debugString += "<br>Object FPS " + s.modelPartFPS,
  3994. this.debugString += "<br>Model Part Anim length " + n.animationLength,
  3995. this.debugString += "<br>Model total frames " + n.totalFrames,
  3996. this.debugString += "<br>Model Part FPS " + n.modelPartFPS,
  3997. i = S.identity(),
  3998. o.getWorldTransform(s.id, t, i, this.sceneScale, !0),
  3999. this.debugString += s.debugString;
  4000. var o = i[0],
  4001. h = (s = i[1],
  4002. n = i[2],
  4003. r = i[4],
  4004. a = i[5],
  4005. i[6]),
  4006. l = i[8],
  4007. d = i[9];
  4008. i = i[10];
  4009. Math.sqrt(o * o + s * s + n * n),
  4010. Math.sqrt(r * r + a * a + h * h),
  4011. Math.sqrt(l * l + d * d + i * i)
  4012. }
  4013. },
  4014. P.prototype.resetPlayback = function () {
  4015. this.startMS = Date.now(),
  4016. this.animationProgress = this.totalSeconds = 0,
  4017. this.setAnimationProgress(0, !0)
  4018. },
  4019. P.prototype.pause = function (e) {
  4020. this.paused = e,
  4021. this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed)
  4022. },
  4023. P.prototype.setAnimationProgress = function (e, t) {
  4024. var i = this.animations[this.selectedAnimationIndex];
  4025. this.animationProgress = e,
  4026. this.totalSeconds = i.totalSeconds * this.animationProgress,
  4027. this.totalSeconds -= 1 / i.originalFPS,
  4028. this.totalSeconds < 0 && (this.totalSeconds = 0),
  4029. this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed),
  4030. t && this.updateScene()
  4031. },
  4032. P.prototype.setPlaybackSpeed = function (e) {
  4033. this.playbackSpeed = e,
  4034. this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed)
  4035. },
  4036. P.prototype.resetCustomView = function () {
  4037. 0 <= this.selectedCameraIndex && this.selectedCameraIndex < this.views.length && (this.viewYawOffsets[this.selectedCameraIndex] = 0,
  4038. this.viewPitchOffsets[this.selectedCameraIndex] = 0,
  4039. this.scene.view.rotation[1] = this.views[this.selectedCameraIndex].rotation[1],
  4040. this.scene.view.rotation[0] = this.views[this.selectedCameraIndex].rotation[0],
  4041. this.setViewFromSelectedCamera())
  4042. },
  4043. P.prototype.updateUserCamera = function () {
  4044. if (this.clearCacheForCameraChildren(),
  4045. 0 <= this.selectedCameraIndex && this.selectedCameraIndex < this.views.length && this.selectedAnimationIndex < this.animations.length) {
  4046. var e = this.cameraObjectIndices[this.selectedCameraIndex],
  4047. t = this.animations[this.selectedAnimationIndex];
  4048. if (e < t.animatedObjects.length) {
  4049. var i = this.views[this.selectedCameraIndex],
  4050. s = this.scene.view.rotation[1],
  4051. n = this.scene.view.rotation[0],
  4052. r = n - i.rotation[0];
  4053. this.viewYawOffsets[this.selectedCameraIndex] = s - i.rotation[1],
  4054. this.viewPitchOffsets[this.selectedCameraIndex] = r,
  4055. i = t.animatedObjects[e],
  4056. t.getObjectAnimationFramePercent(i, this.totalSeconds);
  4057. r = S.identity();
  4058. var a = S.identity();
  4059. i.useFixedWorldTransform = !1,
  4060. i.useFixedLocalTransform = !1,
  4061. i.animatedLocalTransform.lockTransform = !1,
  4062. i.animatedLocalTransform.clearCachedTransforms(),
  4063. i.cachedFrame0 = -1,
  4064. i.cachedFrame1 = -1,
  4065. i.cachedFrame2 = -1,
  4066. i.cachedFrame3 = -1,
  4067. i.cachedFrameUse0 = 0,
  4068. i.cachedFrameUse1 = 0,
  4069. i.cachedFrameUse2 = 0,
  4070. i.cachedFrameUse3 = 0,
  4071. t.getWorldTransform(e, this.totalSeconds, a, this.sceneScale, !1);
  4072. e = a[0];
  4073. var o = a[1],
  4074. h = a[2],
  4075. l = a[4],
  4076. d = a[5],
  4077. c = a[6],
  4078. u = a[8],
  4079. f = a[9],
  4080. m = a[10];
  4081. e = Math.sqrt(e * e + o * o + h * h),
  4082. l = Math.sqrt(l * l + d * d + c * c),
  4083. d = Math.sqrt(u * u + f * f + m * m);
  4084. (c = -(this.scene.view.pivot[0] - a[12])) * u + (o = -(this.scene.view.pivot[1] - a[13])) * f + (a = -(this.scene.view.pivot[2] - a[14])) * m <= 0 && (s += 180),
  4085. s = S.rotation(S.empty(), s, 1),
  4086. n = S.rotation(S.empty(), n, 0),
  4087. S.mul(r, s, n),
  4088. n = Math.sqrt(c * c + o * o + a * a),
  4089. s = this.scene.view.pivot[1] + r[9] * n,
  4090. a = this.scene.view.pivot[2] + r[10] * n,
  4091. r[12] = this.scene.view.pivot[0] + r[8] * n,
  4092. r[13] = s,
  4093. r[14] = a,
  4094. n = S.identity(),
  4095. t.getWorldTransform(i.parentIndex, this.totalSeconds, n, this.sceneScale, !1),
  4096. t = S.identity(),
  4097. S.invert(t, n),
  4098. n = S.identity(),
  4099. S.mul(n, t, r),
  4100. n[12] /= this.sceneScale,
  4101. n[13] /= this.sceneScale,
  4102. n[14] /= this.sceneScale,
  4103. r[0] *= e,
  4104. r[1] *= e,
  4105. r[2] *= e,
  4106. r[4] *= l,
  4107. r[5] *= l,
  4108. r[6] *= l,
  4109. r[8] *= d,
  4110. r[9] *= d,
  4111. r[10] *= d,
  4112. i.setFixedWorldTransform(r),
  4113. i.setFixedLocalTransform(n)
  4114. }
  4115. }
  4116. },
  4117. P.prototype.setViewFromSelectedCamera = function () {
  4118. if (0 <= this.selectedCameraIndex && this.selectedCameraIndex < this.views.length) {
  4119. var e = this.views[this.selectedCameraIndex],
  4120. t = this.scene.view,
  4121. i = this.viewYawOffsets[this.selectedCameraIndex],
  4122. s = this.viewPitchOffsets[this.selectedCameraIndex];
  4123. t.pivot[0] = e.pivot[0],
  4124. t.pivot[1] = e.pivot[1],
  4125. t.pivot[2] = e.pivot[2],
  4126. t.rotation[0] = e.rotation[0] + s,
  4127. t.rotation[1] = e.rotation[1] + i,
  4128. t.radius = e.radius,
  4129. t.nearPlane = e.nearPlane,
  4130. t.fov = e.fov,
  4131. t.saveResetView(),
  4132. t.updateProjection(),
  4133. t.updateView()
  4134. }
  4135. },
  4136. P.prototype.selectDefaultCamera = function () {
  4137. if (-1 != this.defaultCameraGlobalIndex && 0 < this.animations.length)
  4138. for (var e = this.animations[0], t = e.cameraObjects.length, i = 0; i < t; i++)
  4139. if (e.cameraObjects[i].id == this.defaultCameraGlobalIndex)
  4140. return void(this.selectedCameraIndex = i);
  4141. this.selectedCameraIndex = 0
  4142. },
  4143. P.prototype.updateAnimationPlayback = function () {
  4144. if (!this.stopEverything || !this.runDebugMode) {
  4145. var e = this.animations[this.selectedAnimationIndex];
  4146. if (this.updateUserCamera(),
  4147. this.paused || !this.playAnimations)
  4148. this.startMS = 0 < this.playbackSpeed ? Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed) : Date.now() - 1e3 * this.totalSeconds,
  4149. this.refreshTransformsOnly(),
  4150. this.runDebugMode && this.checkDebug(),
  4151. (e = this.scene.view).saveResetView(),
  4152. e.updateProjection(),
  4153. e.updateView();
  4154. else {
  4155. this.lockPlayback && 0 < this.playbackSpeed && (this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed));
  4156. var t = (Date.now() - this.startMS) / 1e3 * this.playbackSpeed * this.scenePlaybackSpeed;
  4157. this.totalSeconds = (Date.now() - this.startMS) / 1e3 * this.playbackSpeed * this.scenePlaybackSpeed;
  4158. var i = (i = t / e.totalSeconds) - (t = Math.floor(i));
  4159. t != this.loopCount && (this.loopCount++,
  4160. this.loopTurntables && this.rolloverTurntables(),
  4161. this.autoAdvanceNextAnimation && (this.nextAnimation(),
  4162. this.resetPlayback())),
  4163. this.totalSeconds = e.totalSeconds * i,
  4164. this.animationProgress = this.totalSeconds / e.totalSeconds - Math.floor(this.totalSeconds / e.totalSeconds),
  4165. this.updateScene(),
  4166. this.runDebugMode && this.checkDebug()
  4167. }
  4168. }
  4169. },
  4170. P.prototype.updateScene = function () {
  4171. this.lastSceneFramePercent = this.totalSeconds * this.animations[this.selectedAnimationIndex].originalFPS,
  4172. 0 != this.fogObjectIndex && this.updateFog(),
  4173. this.animateTurntables && this.updateTurntables(),
  4174. this.animateMeshes && this.poseMeshes(),
  4175. this.animateLights && this.updateLights(),
  4176. this.animateMaterials && this.updateMaterials(),
  4177. this.animateVisibility && this.updateVisibility()
  4178. },
  4179. P.prototype.findCameraChildren = function () {
  4180. for (var e = this.animations[0], t = e.animatedObjects.length, i = 0; i < t; i++)
  4181. e.hasParentTypeInHierarchy(e.animatedObjects[i], "CameraSO") && this.cameraChildrenIndices.push(i)
  4182. },
  4183. P.prototype.findFixedTransforms = function () {
  4184. for (var e = this.animations.length, t = 0; t < e; t++)
  4185. for (var i = this.animations[t], s = i.animatedObjects.length, n = 0; n < s; n++) {
  4186. var r = i.animatedObjects[n];
  4187. if (!r.useFixedWorldTransform && !i.hasAnimationInHierarchy(r))
  4188. if ("Material" == r.sceneObjectType)
  4189. r.setFixedWorldTransform(S.identity()),
  4190. r.setFixedLocalTransform(S.identity());
  4191. else {
  4192. var a = S.identity(),
  4193. o = S.identity();
  4194. i.hasParentTypeInHierarchy(r, "SceneRootSO") ? (i.getWorldTransform(r.id, 0, a, this.sceneScale, !1),
  4195. r.evaluateLocalTransformAtFramePercent(0, o, !0, !1)) : (i.evaluateModelPartTransformAtFrame(r.id, 0, a, !1),
  4196. r.evaluateLocalTransformAtFramePercent(0, o, !1, !1)),
  4197. r.setFixedWorldTransform(a),
  4198. r.setFixedLocalTransform(o)
  4199. }
  4200. }
  4201. },
  4202. P.prototype.clearCacheForCameraChildren = function () {
  4203. for (var e = this.animations[this.selectedAnimationIndex], t = this.cameraChildrenIndices.length, i = 0; i < t; i++) {
  4204. var s = e.animatedObjects[this.cameraChildrenIndices[i]];
  4205. s.useFixedWorldTransform = !1,
  4206. s.useFixedLocalTransform = !1,
  4207. s.cachedFrame0 = -10,
  4208. s.cachedFrame1 = -10,
  4209. s.cachedFrame2 = -10,
  4210. s.cachedFrame3 = -10,
  4211. s.cachedFrameUse0 = 0,
  4212. s.cachedFrameUse1 = 0,
  4213. s.cachedFrameUse2 = 0,
  4214. s.cachedFrameUse3 = 0,
  4215. s.animatedLocalTransform.clearCachedTransforms(),
  4216. s.animatedLocalTransform.lockTransform = !1
  4217. }
  4218. },
  4219. P.prototype.refreshTransformsOnly = function () {
  4220. for (var e = this.animations[this.selectedAnimationIndex], t = e.meshObjects.length, i = 0; i < t; i++) {
  4221. var s = e.meshObjects[i];
  4222. if (e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0),
  4223. this.enableSkinning && s.skinningRig && this.unitScaleSkinnedMeshes && !s.skinningRig.isRigidSkin) {
  4224. var n = (s = s.mesh.displayMatrix)[0],
  4225. r = s[1],
  4226. a = s[2],
  4227. o = s[4],
  4228. h = s[5],
  4229. l = s[6],
  4230. d = s[8],
  4231. c = s[9],
  4232. u = s[10];
  4233. d = ((n = Math.sqrt(n * n + r * r + a * a)) + (o = Math.sqrt(o * o + h * h + l * l)) + (d = Math.sqrt(d * d + c * c + u * u))) / 2;
  4234. s[0] /= d,
  4235. s[1] /= d,
  4236. s[2] /= d,
  4237. s[4] /= d,
  4238. s[5] /= d,
  4239. s[6] /= d,
  4240. s[8] /= d,
  4241. s[9] /= d,
  4242. s[10] /= d
  4243. }
  4244. }
  4245. if (this.animateLights)
  4246. for (t = e.lightObjects.length,
  4247. i = 0; i < t; i++)
  4248. (s = e.lightObjects[i]).useFixedWorldTransform || (d = this.scene.lights.getLightPos(s.lightIndex),
  4249. c = this.scene.lights.getLightDir(s.lightIndex),
  4250. u = S.identity(),
  4251. e.getWorldTransform(s.id, this.totalSeconds, u, this.sceneScale, !0),
  4252. c[0] = u[8],
  4253. c[1] = u[9],
  4254. c[2] = u[10],
  4255. 0 != d[3] && (d[0] = u[12],
  4256. d[1] = u[13],
  4257. d[2] = u[14],
  4258. this.scene.lights.setLightPos(s.lightIndex, d)),
  4259. this.scene.lights.setLightDir(s.lightIndex, c))
  4260. },
  4261. P.prototype.findMeshIndexByPartIndex = function (e, t) {
  4262. for (var i = 0; i < this.meshIDs.length; ++i)
  4263. if (t == this.meshIDs[i])
  4264. return i;
  4265. return -1
  4266. },
  4267. P.prototype.findLightIndexByPartIndex = function (e) {
  4268. for (var t = 0; t < this.lightIDs.length; t++)
  4269. if (e == this.lightIDs[t])
  4270. return t;
  4271. return -1
  4272. },
  4273. P.prototype.findMaterialIndexByPartIndex = function (e) {
  4274. for (var t = 0; t < this.materialIDs.length; t++)
  4275. if (e == this.materialIDs[t])
  4276. return t;
  4277. return -1
  4278. },
  4279. P.prototype.nextAnimation = function () {
  4280. this.selectedAnimationIndex++,
  4281. this.selectedAnimationIndex >= this.animations.length && (this.selectedAnimationIndex = 0)
  4282. },
  4283. P.prototype.selectAnimation = function (e) {
  4284. 0 <= e && e < this.animations.length && (this.selectedAnimationIndex = e),
  4285. this.paused && this.setAnimationProgress(this.animationProgress, !0)
  4286. },
  4287. P.prototype.selectCamera = function (e) {
  4288. -1 != e && this.selectedCameraIndex != e && (this.selectedCameraIndex = e,
  4289. this.setViewFromSelectedCamera())
  4290. },
  4291. P.prototype.getAnimatedCamera = function () {
  4292. if (0 <= this.selectedCameraIndex && this.selectedAnimationIndex < this.animations.length) {
  4293. var e = this.animations[this.selectedAnimationIndex];
  4294. if (this.selectedCameraIndex < e.cameraObjects.length)
  4295. return e.cameraObjects[this.selectedCameraIndex]
  4296. }
  4297. },
  4298. P.prototype.poseMeshes = function () {
  4299. for (var e = this.animations[this.selectedAnimationIndex], t = e.meshObjects.length, i = 0; i < t; i++) {
  4300. var s = e.meshObjects[i];
  4301. if (this.enableSkinning && s.skinningRig)
  4302. if (s.skinningRig.isRigidSkin)
  4303. e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0);
  4304. else {
  4305. s.setupSkinningRig(e, s.modelPartIndex, this.totalSeconds, s.skinningRig),
  4306. e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0);
  4307. var n = s.modelPartScale * this.sceneScale;
  4308. if (this.unitScaleSkinnedMeshes) {
  4309. var r = s.mesh.displayMatrix,
  4310. a = r[0],
  4311. o = r[1],
  4312. h = r[2],
  4313. l = r[4],
  4314. d = r[5],
  4315. c = r[6],
  4316. u = r[8],
  4317. f = r[9],
  4318. m = r[10];
  4319. u = ((a = Math.sqrt(a * a + o * o + h * h)) + (l = Math.sqrt(l * l + d * d + c * c)) + (u = Math.sqrt(u * u + f * f + m * m))) / 2;
  4320. r[0] /= u,
  4321. r[1] /= u,
  4322. r[2] /= u,
  4323. r[4] /= u,
  4324. r[5] /= u,
  4325. r[6] /= u,
  4326. r[8] /= u,
  4327. r[9] /= u,
  4328. r[10] /= u,
  4329. n *= u
  4330. }
  4331. s.skinningRig.deformMesh(s.mesh, n)
  4332. }
  4333. else
  4334. e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0)
  4335. }
  4336. },
  4337. P.prototype.updateLights = function () {
  4338. for (var e = this.animations[this.selectedAnimationIndex], t = this.totalSeconds * e.originalFPS, i = e.lightObjects.length, s = 0; s < i; s++) {
  4339. var n = e.lightObjects[s],
  4340. r = this.scene.lights.getLightPos(n.lightIndex),
  4341. a = this.scene.lights.getLightDir(n.lightIndex),
  4342. o = this.scene.lights.getLightColor(n.lightIndex),
  4343. h = S.identity(),
  4344. l = 1;
  4345. n.useFixedWorldTransform || e.getWorldTransform(n.id, this.totalSeconds, h, this.sceneScale, !0),
  4346. n.redProperty && (n.redProperty.evaluate(t, o[0], n),
  4347. o[0] = n.redProperty.lastValue),
  4348. n.greenProperty && (n.greenProperty.evaluate(t, o[1], n),
  4349. o[1] = n.greenProperty.lastValue),
  4350. n.blueProperty && (n.blueProperty.evaluate(t, o[2], n),
  4351. o[2] = n.blueProperty.lastValue),
  4352. n.brightnessProperty && (n.brightnessProperty.evaluate(t, l, n),
  4353. l = n.brightnessProperty.lastValue),
  4354. o[0] *= l,
  4355. o[1] *= l,
  4356. o[2] *= l,
  4357. 0 != r[3] && (n.useFixedWorldTransform || (r[0] = h[12],
  4358. r[1] = h[13],
  4359. r[2] = h[14],
  4360. this.scene.lights.setLightPos(n.lightIndex, r)),
  4361. n.spotAngleProperty && 0 < this.scene.lights.spot[3 * n.lightIndex] && (r = 0,
  4362. n.spotAngleProperty.evaluate(t, r, n),
  4363. r = n.spotAngleProperty.lastValue,
  4364. this.scene.lights.setLightSpotAngle(n.lightIndex, r)),
  4365. n.spotSharpnessProperty && (r = 0,
  4366. n.spotSharpnessProperty.evaluate(t, r, n),
  4367. r = n.spotSharpnessProperty.lastValue,
  4368. this.scene.lights.setLightSpotSharpness(n.lightIndex, r)),
  4369. n.distanceProperty && (r = 1,
  4370. n.distanceProperty.evaluate(t, r, n),
  4371. r = n.distanceProperty.lastValue * this.sceneScale,
  4372. this.scene.lights.setLightDistance(n.lightIndex, r))),
  4373. n.useFixedWorldTransform || (a[0] = h[8],
  4374. a[1] = h[9],
  4375. a[2] = h[10],
  4376. this.scene.lights.setLightDir(n.lightIndex, a)),
  4377. this.scene.lights.setLightColor(n.lightIndex, o)
  4378. }
  4379. },
  4380. P.prototype.updateTurntables = function () {
  4381. for (var e = this.animations[this.selectedAnimationIndex], t = this.totalSeconds * e.originalFPS, i = e.turnTableObjects.length, s = 0; s < i; s++) {
  4382. var n = e.turnTableObjects[s];
  4383. n.spinProperty.evaluate(t, 0, n),
  4384. n.turnTableSpin = n.turnTableSpinOffset + n.spinProperty.lastValue * this.totalSeconds
  4385. }
  4386. },
  4387. P.prototype.rolloverTurntables = function () {
  4388. for (var e = this.animations[this.selectedAnimationIndex], t = e.turnTableObjects.length, i = 0; i < t; i++) {
  4389. var s = e.turnTableObjects[i];
  4390. s.turnTableSpinOffset = s.turnTableSpin
  4391. }
  4392. },
  4393. P.prototype.updateMaterials = function () {
  4394. for (var e = this.animations[this.selectedAnimationIndex], t = this.totalSeconds * e.originalFPS, i = e.materialObjects.length, s = 0; s < i; s++) {
  4395. var n = e.materialObjects[s];
  4396. n.offsetUProperty && (n.offsetUProperty.evaluate(t, 0, n),
  4397. this.scene.materialsList[n.materialIndex].uOffset = n.offsetUProperty.lastValue),
  4398. n.offsetVProperty && (n.offsetVProperty.evaluate(t, 0, n),
  4399. this.scene.materialsList[n.materialIndex].vOffset = n.offsetVProperty.lastValue),
  4400. n.emissiveProperty && 1 < n.emissiveProperty.numKeyframes && (n.emissiveProperty.evaluate(t, 0, n),
  4401. this.scene.materialsList[n.materialIndex].emissiveIntensity = n.emissiveProperty.lastValue)
  4402. }
  4403. },
  4404. P.prototype.updateFog = function () {
  4405. var e = this.animations[this.selectedAnimationIndex],
  4406. t = this.totalSeconds * e.originalFPS;
  4407. 0 <= this.fogObjectIndex && this.fogObjectIndex < e.animatedObjects.length && this.scene.fog && ((e = e.animatedObjects[this.fogObjectIndex]).redProperty && (this.scene.fog.desc.color[0] = e.redProperty.evaluate(t, this.scene.fog.desc.color[0], e)),
  4408. e.greenProperty && (this.scene.fog.desc.color[1] = e.greenProperty.evaluate(t, this.scene.fog.desc.color[1], e)),
  4409. e.blueProperty && (this.scene.fog.desc.color[2] = e.blueProperty.evaluate(t, this.scene.fog.desc.color[2], e)),
  4410. e.distanceProperty && (this.scene.fog.desc.distance = e.distanceProperty.evaluate(t, this.scene.fog.desc.distance, e)),
  4411. e.opacityProperty && (this.scene.fog.desc.opacity = e.opacityProperty.evaluate(t, this.scene.fog.desc.opacity, e)),
  4412. e.skyIllumProperty && (this.scene.fog.desc.skyIllum = e.skyIllumProperty.evaluate(t, this.scene.fog.desc.skyIllum, e)),
  4413. e.lightIllumProperty && (this.scene.fog.desc.lightIllum = e.lightIllumProperty.evaluate(t, this.scene.fog.desc.lightIllum, e)),
  4414. e.dispersionProperty && (this.scene.fog.desc.dispersion = e.dispersionProperty.evaluate(t, this.scene.fog.desc.dispersion, e)))
  4415. },
  4416. P.prototype.updateVisibility = function () {
  4417. for (var e = this.animations[this.selectedAnimationIndex], t = this.subMeshObjectIndices.length, i = 0; i < t; i++) {
  4418. if (-1 != (n = this.subMeshLiveIndices[i])) {
  4419. var s = this.subMeshObjectIndices[i],
  4420. n = this.scene.meshRenderables[n],
  4421. r = e.getObjectAnimationFramePercent(e.animatedObjects[s], this.totalSeconds);
  4422. n.visible = e.isVisibleAtFramePercent(s, r)
  4423. }
  4424. }
  4425. },
  4426. F.prototype.build = function (e, t) {
  4427. var i = this.gl;
  4428. this.program = i.createProgram(),
  4429. this.params = {},
  4430. this.samplers = {},
  4431. this.attribs = {};
  4432. var s = function (e) {
  4433. for (var t = "", i = e.indexOf("\n"), s = 0; - 1 != i;)
  4434. t += ++s + ": ",
  4435. t += e.substring(0, i + 1),
  4436. i = (e = e.substring(i + 1, e.length)).indexOf("\n");
  4437. console.log(t)
  4438. },
  4439. n = i.createShader(i.VERTEX_SHADER);
  4440. i.shaderSource(n, e),
  4441. i.compileShader(n),
  4442. i.getShaderParameter(n, i.COMPILE_STATUS) || (console.log(i.getShaderInfoLog(n)),
  4443. I.verboseErrors && s(e)),
  4444. i.attachShader(this.program, n),
  4445. n = i.createShader(i.FRAGMENT_SHADER),
  4446. i.shaderSource(n, t),
  4447. i.compileShader(n),
  4448. i.getShaderParameter(n, i.COMPILE_STATUS) || (console.log(i.getShaderInfoLog(n)),
  4449. I.verboseErrors && s(t)),
  4450. i.attachShader(this.program, n),
  4451. i.linkProgram(this.program),
  4452. i.getProgramParameter(this.program, i.LINK_STATUS) || console.log(i.getProgramInfoLog(this.program));
  4453. n = i.getProgramParameter(this.program, i.ACTIVE_UNIFORMS);
  4454. var r = 0;
  4455. for (s = 0; s < n; ++s) {
  4456. var a = i.getActiveUniform(this.program, s),
  4457. o = a.name,
  4458. h = o.indexOf("[");
  4459. 0 <= h && (o = o.substring(0, h)),
  4460. h = i.getUniformLocation(this.program, a.name),
  4461. a.type == i.SAMPLER_2D || a.type == i.SAMPLER_CUBE ? this.samplers[o] = {
  4462. location: h,
  4463. unit: r++
  4464. } : this.params[o] = h
  4465. }
  4466. for (n = i.getProgramParameter(this.program, i.ACTIVE_ATTRIBUTES),
  4467. s = 0; s < n; ++s)
  4468. r = i.getActiveAttrib(this.program, s),
  4469. this.attribs[r.name] = i.getAttribLocation(this.program, r.name)
  4470. },
  4471. F.prototype.bind = function () {
  4472. return !!this.program && (this.gl.useProgram(this.program),
  4473. !0)
  4474. },
  4475. F.prototype.complete = function () {
  4476. return !!this.program
  4477. },
  4478. O.prototype.fromURLs = function (e, t, i) {
  4479. var s = "";
  4480. if (i)
  4481. for (var n = 0; n < i.length; ++n)
  4482. s = i[n] + "\n" + s;
  4483. if (i = s + ":" + e + "|" + t,
  4484. void 0 !== (n = this.cache[i]))
  4485. return n;
  4486. function r() {
  4487. null != o && null != h && a.build(o, h)
  4488. }
  4489. var a = new F(this.gl),
  4490. o = null,
  4491. h = null;
  4492. return this.fetch(e, function (e) {
  4493. o = s + e,
  4494. r()
  4495. }),
  4496. this.fetch(t, function (e) {
  4497. h = s + e,
  4498. r()
  4499. }),
  4500. this.cache[i] = a
  4501. },
  4502. O.prototype.fetch = function (e, t) {
  4503. void 0 !== G ? void 0 !== G[e] ? this.resolveIncludes(new String(G[e]), t) : t("") : C.fetchText("src/shader/" + e, function (e) {
  4504. this.resolveIncludes(e, t)
  4505. }
  4506. .bind(this),
  4507. function () {
  4508. t("")
  4509. })
  4510. },
  4511. O.prototype.resolveIncludes = function (t, i) {
  4512. for (var r = [], a = !0, e = function (e, t, i, s, n) {
  4513. return a = !0,
  4514. r.push({
  4515. offset: n,
  4516. path: t.slice(1, t.length - 1)
  4517. }),
  4518. ""
  4519. }; a;)
  4520. a = !1,
  4521. t = t.replace(/#include\s((<[^>]+>)|("[^"]+"))/, e);
  4522. if (0 < r.length) {
  4523. var s = r.length;
  4524. for (e = 0; e < r.length; ++e)
  4525. this.fetch(r[e].path, function (e) {
  4526. if (this.src = e,
  4527. --s <= 0) {
  4528. for (e = r.length - 1; 0 <= e; --e)
  4529. t = t.substring(0, r[e].offset) + r[e].src + t.substring(r[e].offset);
  4530. i(t)
  4531. }
  4532. }
  4533. .bind(r[e]))
  4534. } else
  4535. i(t)
  4536. },
  4537. E.prototype.bindDepthTexture = function (e, t) {
  4538. this.shadowCount > t && this.depthTextures[t].bind(e)
  4539. },
  4540. E.prototype.collect = function (e, t) {
  4541. for (var i = this.gl, s = e.lights, n = s.shadowCount, r = s.modelViewBuffer, a = s.projectionBuffer, o = s.matrix, h = 0 != e.sceneAnimator, l = S.empty(), d = !1, c = 0; c < n; ++c)
  4542. if (s.shadowsNeedUpdate[c]) {
  4543. d = !(s.shadowsNeedUpdate[c] = 0),
  4544. S.mul(l, r.subarray(16 * c, 16 * (c + 1)), o),
  4545. S.mul(l, a.subarray(16 * c, 16 * (c + 1)), l),
  4546. this.depthTargets[c].bind(),
  4547. i.clearColor(1, 1, 1, 1),
  4548. i.clear(i.COLOR_BUFFER_BIT | i.DEPTH_BUFFER_BIT);
  4549. var u = this.shaderSolid;
  4550. u.bind(),
  4551. i.uniformMatrix4fv(u.params.uViewProjection, !1, l),
  4552. i.uniformMatrix4fv(u.params.uMeshTransform, !1, S.identity());
  4553. for (var f = 0; f < e.meshRenderables.length; ++f) {
  4554. var m = e.meshRenderables[f],
  4555. p = m.material;
  4556. !m.mesh.desc.castShadows || !p.castShadows || 0 < p.shadowAlphaTest || (h && i.uniformMatrix4fv(u.params.uMeshTransform, !1, m.mesh.displayMatrix),
  4557. m.drawShadow(u.attribs.vPosition))
  4558. }
  4559. for ((u = this.shaderAlphaTest).bind(),
  4560. i.uniformMatrix4fv(u.params.uViewProjection, !1, l),
  4561. i.uniformMatrix4fv(u.params.uMeshTransform, !1, S.identity()),
  4562. f = 0; f < e.meshRenderables.length; ++f)
  4563. p = (m = e.meshRenderables[f]).material,
  4564. m.mesh.desc.castShadows && p.castShadows && 0 < p.shadowAlphaTest && (p.textures.albedo.bind(u.samplers.tAlbedo),
  4565. h && (i.uniform2f(u.params.uUVOffset, p.uOffset, p.vOffset),
  4566. i.uniformMatrix4fv(u.params.uMeshTransform, !1, m.mesh.displayMatrix)),
  4567. m.drawAlphaShadow(u.attribs.vPosition, u.attribs.vTexCoord))
  4568. }
  4569. d && (t.bind(),
  4570. i.enable(i.CULL_FACE),
  4571. i.cullFace(i.BACK))
  4572. },
  4573. E.prototype.complete = function () {
  4574. return this.shaderSolid.complete() && this.shaderAlphaTest.complete()
  4575. },
  4576. B.prototype.draw = function (e) {
  4577. var t = e.view,
  4578. i = e.lights,
  4579. s = e.shadow,
  4580. n = this.gl,
  4581. r = this.shader.params,
  4582. a = this.shader.samplers;
  4583. this.shader.bind(),
  4584. t = S.mul(S.empty(), t.projectionMatrix, t.viewMatrix),
  4585. S.mul(t, t, this.desc.transform),
  4586. n.uniformMatrix4fv(r.uModelViewProjectionMatrix, !1, t),
  4587. t = S.mul(S.empty(), i.matrix, this.desc.transform),
  4588. n.uniformMatrix4fv(r.uModelSkyMatrix, !1, t),
  4589. 0 < i.count && (n.uniform4fv(r.uLightPositions, i.positionBuffer),
  4590. n.uniform3fv(r.uLightDirections, i.directionBuffer),
  4591. n.uniform3fv(r.uLightColors, i.colors),
  4592. n.uniform3fv(r.uLightParams, i.parameters),
  4593. n.uniform3fv(r.uLightSpot, i.spot),
  4594. e = .392699 * e.postRender.currentSample(),
  4595. n.uniform2f(r.uShadowKernelRotation, .5 * Math.cos(e), .5 * Math.sin(e)),
  4596. 0 < i.shadowCount && (e = s.depthTextures[0].desc.width,
  4597. n.uniform2f(r.uShadowMapSize, e, 1 / e),
  4598. n.uniformMatrix4fv(r.uShadowMatrices, !1, i.finalTransformBuffer),
  4599. n.uniformMatrix4fv(r.uInvShadowMatrices, !1, i.inverseTransformBuffer),
  4600. n.uniform4fv(r.uShadowTexelPadProjections, i.shadowTexelPadProjections),
  4601. s.bindDepthTexture(a.tDepth0, 0),
  4602. s.bindDepthTexture(a.tDepth1, 1),
  4603. s.bindDepthTexture(a.tDepth2, 2))),
  4604. n.uniform3f(r.uShadowCatcherParams, this.desc.simple ? 1 : 0, this.desc.alpha, this.desc.edgeFade),
  4605. n.depthMask(!1),
  4606. n.enable(n.BLEND),
  4607. n.blendFunc(n.ZERO, n.SRC_COLOR),
  4608. i = this.shader.attribs.vPosition,
  4609. n.bindBuffer(n.ARRAY_BUFFER, this.quadGeom),
  4610. n.enableVertexAttribArray(i),
  4611. n.vertexAttribPointer(i, 3, n.FLOAT, !1, 0, 0),
  4612. n.drawArrays(n.TRIANGLES, 0, 6),
  4613. n.disableVertexAttribArray(i),
  4614. n.bindBuffer(n.ARRAY_BUFFER, null),
  4615. n.disable(n.BLEND),
  4616. n.depthMask(!0)
  4617. },
  4618. B.prototype.complete = function () {
  4619. return this.shader.complete()
  4620. },
  4621. L.prototype.solveAdditiveClusterTransform = function (e, t, i) {
  4622. t = S.identity();
  4623. var s = S.identity(),
  4624. n = S.identity();
  4625. S.mul(t, e, this.defaultClusterBaseTransform),
  4626. S.mul(s, this.defaultAssociateWorldTransformInvert, t),
  4627. S.mul(n, this.defaultAssociateWorldTransformInvert, s),
  4628. S.mul(i, this.defaultClusterWorldTransformInvert, n)
  4629. },
  4630. L.prototype.solveSimpleClusterTransform = function (e, t, i) {
  4631. var s = S.identity(),
  4632. n = S.identity();
  4633. S.invert(n, t),
  4634. S.mul(s, n, e),
  4635. S.mul(i, s, this.defaultClusterBaseTransform)
  4636. },
  4637. L.prototype.solveClusterTransformAtFrame = function (e, t, i, s) {
  4638. if (1 == this.linkMode) {
  4639. var n = S.identity();
  4640. t = S.identity(),
  4641. e.evaluateModelPartTransformAtFrame(this.linkObjectIndex, i, n, !1),
  4642. e.evaluateModelPartTransformAtFrame(this.associateObjectIndex, i, t, !1),
  4643. this.solveAdditiveClusterTransform(n, t, s)
  4644. } else {
  4645. n = S.identity();
  4646. var r = S.identity();
  4647. e.evaluateModelPartTransformAtFrame(this.linkObjectIndex, i, n, !1),
  4648. e.evaluateModelPartTransformAtFrame(t, i, r, !1),
  4649. this.solveSimpleClusterTransform(n, r, s)
  4650. }
  4651. },
  4652. M.prototype.unpackUnitVectors = function (e, t, i, s) {
  4653. for (var n = 0; n < i; n++) {
  4654. var r = t[s * n],
  4655. a = 32768 <= (o = t[s * n + 1]);
  4656. a && (o -= 32768);
  4657. var o, h = 1 - ((r = r / 32767.4 * 2 - 1) * r + (o = o / 32767.4 * 2 - 1) * o);
  4658. h = Math.sqrt(h),
  4659. h = isNaN(h) ? 0 : h;
  4660. a && (h = -h),
  4661. e[3 * n] = r,
  4662. e[3 * n + 1] = o,
  4663. e[3 * n + 2] = h
  4664. }
  4665. },
  4666. M.prototype.copyOriginalVertices = function (e) {
  4667. if (!this.unTransformedVertices)
  4668. if (this.unTransformedVertices = new Float32Array(3 * e.vertexCount),
  4669. this.unTransformedNormals = new Float32Array(3 * e.vertexCount),
  4670. this.unTransformedTangents = new Float32Array(3 * e.vertexCount),
  4671. this.unTransformedBiTangents = new Float32Array(3 * e.vertexCount),
  4672. this.skinVertexWeights = new Float32Array(e.vertexCount),
  4673. this.skinVertexTransform4x3 = new Float32Array(12),
  4674. e.dynamicVertexData) {
  4675. var t = new Float32Array(e.dynamicVertexData.buffer);
  4676. new Uint8Array(e.dynamicVertexData.buffer);
  4677. var i = s = 0,
  4678. s = s + 12 + 8;
  4679. e.secondaryTexCoord && (s += 8);
  4680. var n = s,
  4681. r = s += 4,
  4682. a = (s = s + 4,
  4683. e.stride / 2);
  4684. s = new Uint8Array(e.dynamicVertexData.subarray(s)),
  4685. s = new Uint16Array(s.buffer),
  4686. n = new Uint8Array(e.dynamicVertexData.subarray(n)),
  4687. n = new Uint16Array(n.buffer),
  4688. r = new Uint8Array(e.dynamicVertexData.subarray(r)),
  4689. r = new Uint16Array(r.buffer);
  4690. for (this.unpackUnitVectors(this.unTransformedNormals, s, e.vertexCount, a),
  4691. this.unpackUnitVectors(this.unTransformedTangents, n, e.vertexCount, a),
  4692. this.unpackUnitVectors(this.unTransformedBiTangents, r, e.vertexCount, a),
  4693. a = 0; a < e.vertexCount; a++)
  4694. r = (e.stride * a + i) / 4,
  4695. this.unTransformedVertices[3 * a] = t[r],
  4696. this.unTransformedVertices[3 * a + 1] = t[r + 1],
  4697. this.unTransformedVertices[3 * a + 2] = t[r + 2]
  4698. } else
  4699. this.debugString += "<br>Can't init skinning rig - mesh buffer is not dynamic - rigid is " + this.isRigidSkin
  4700. },
  4701. M.prototype.useOriginalMeshVertices = function (e) {
  4702. this.isRigidSkin ? this.debugString += "<br>useOriginalMeshVertices for rigid skin?" : this.copyOriginalVertices(e)
  4703. },
  4704. M.prototype.deformMeshVertices = function (e, t) {
  4705. if (0 != this.skinningClusters.length && this.unTransformedVertices) {
  4706. var i, s = e.stride / 4,
  4707. n = new Float32Array(e.dynamicVertexData.buffer),
  4708. r = new Uint16Array(e.dynamicVertexData.buffer);
  4709. new Uint8Array(e.dynamicVertexData.buffer),
  4710. i = 20,
  4711. e.secondaryTexCoord && (i += 8);
  4712. var a = i,
  4713. o = i += 4;
  4714. i += 4;
  4715. for (var h = this.unTransformedVertices.length / 3, l = 0, d = 0; d < h; ++d) {
  4716. var c = d,
  4717. u = (c * e.stride + a) / 2,
  4718. f = (c * e.stride + o) / 2,
  4719. m = (c * e.stride + i) / 2,
  4720. p = this.linkMapCount[c];
  4721. (k = this.skinVertexTransform4x3)[this.skinVertexWeights[c] = 0] = 0,
  4722. k[1] = 0,
  4723. k[2] = 0,
  4724. k[3] = 0,
  4725. k[4] = 0,
  4726. k[5] = 0,
  4727. k[6] = 0,
  4728. k[7] = 0,
  4729. k[8] = 0,
  4730. k[9] = 0,
  4731. k[10] = 0,
  4732. k[11] = 0;
  4733. var g = this.linkMapWeights[l];
  4734. if (1 == p && 1 == g) {
  4735. var v = this.linkMapClusterIndices[l],
  4736. x = (v = this.skinningClusters[v]).matrix;
  4737. k[0] = x[0],
  4738. k[1] = x[1],
  4739. k[2] = x[2],
  4740. k[3] = x[4],
  4741. k[4] = x[5],
  4742. k[5] = x[6],
  4743. k[6] = x[8],
  4744. k[7] = x[9],
  4745. k[8] = x[10],
  4746. k[9] = x[12],
  4747. k[10] = x[13],
  4748. k[11] = x[14],
  4749. this.skinVertexWeights[c] = 1
  4750. } else
  4751. for (var y = this.skinVertexWeights[c] = 0; y < p; y++)
  4752. g = this.linkMapWeights[l + y],
  4753. (v = this.linkMapClusterIndices[l + y]) < this.skinningClusters.length && (x = (v = this.skinningClusters[v]).matrix,
  4754. k[0] += g * x[0],
  4755. k[1] += g * x[1],
  4756. k[2] += g * x[2],
  4757. k[3] += g * x[4],
  4758. k[4] += g * x[5],
  4759. k[5] += g * x[6],
  4760. k[6] += g * x[8],
  4761. k[7] += g * x[9],
  4762. k[8] += g * x[10],
  4763. k[9] += g * x[12],
  4764. k[10] += g * x[13],
  4765. k[11] += g * x[14],
  4766. this.skinVertexWeights[c] += g,
  4767. 1 == v.linkMode && (this.skinVertexWeights[c] = 1));
  4768. if (l += this.linkMapCount[d],
  4769. 0 < this.skinVertexWeights[c]) {
  4770. var b = this.unTransformedVertices[3 * d + 0],
  4771. S = this.unTransformedVertices[3 * d + 1],
  4772. T = this.unTransformedVertices[3 * d + 2],
  4773. w = this.unTransformedNormals[3 * d + 0],
  4774. C = this.unTransformedNormals[3 * d + 1],
  4775. R = this.unTransformedNormals[3 * d + 2],
  4776. A = (v = this.unTransformedTangents[3 * d + 0],
  4777. x = this.unTransformedTangents[3 * d + 1],
  4778. this.unTransformedTangents[3 * d + 2]),
  4779. k = (p = this.unTransformedBiTangents[3 * d + 0],
  4780. this.unTransformedBiTangents[3 * d + 1]),
  4781. I = (g = this.unTransformedBiTangents[3 * d + 2],
  4782. y = this.skinVertexTransform4x3,
  4783. 1);
  4784. 0 < this.skinVertexWeights[c] && (I = 1 / this.skinVertexWeights[c]),
  4785. n[s * d] = I * (b * y[0] + S * y[3] + T * y[6] + y[9]) * t,
  4786. n[s * d + 1] = I * (b * y[1] + S * y[4] + T * y[7] + y[10]) * t,
  4787. n[s * d + 2] = I * (b * y[2] + S * y[5] + T * y[8] + y[11]) * t,
  4788. b = w * y[0] + C * y[3] + R * y[6],
  4789. c = w * y[1] + C * y[4] + R * y[7],
  4790. w = w * y[2] + C * y[5] + R * y[8],
  4791. C = v * y[0] + x * y[3] + A * y[6],
  4792. R = v * y[1] + x * y[4] + A * y[7],
  4793. v = v * y[2] + x * y[5] + A * y[8],
  4794. x = p * y[0] + k * y[3] + g * y[6],
  4795. A = p * y[1] + k * y[4] + g * y[7],
  4796. p = p * y[2] + k * y[5] + g * y[8],
  4797. c /= k = Math.sqrt(b * b + c * c + w * w),
  4798. w /= k,
  4799. k = 32767.4 * ((b /= k) / 2 + .5),
  4800. g = 32767.4 * (c / 2 + .5),
  4801. w < 0 && (g += 32768),
  4802. r[m] = Math.floor(k),
  4803. r[1 + m] = Math.floor(g),
  4804. R /= k = Math.sqrt(C * C + R * R + v * v),
  4805. v /= k,
  4806. k = 32767.4 * ((C /= k) / 2 + .5),
  4807. g = 32767.4 * (R / 2 + .5),
  4808. v < 0 && (g += 32768),
  4809. r[u] = Math.floor(k),
  4810. r[1 + u] = Math.floor(g),
  4811. A /= k = Math.sqrt(x * x + A * A + p * p),
  4812. p /= k,
  4813. k = 32767.4 * ((x /= k) / 2 + .5),
  4814. g = 32767.4 * (A / 2 + .5),
  4815. p < 0 && (g += 32768),
  4816. r[f] = Math.floor(k),
  4817. r[1 + f] = Math.floor(g)
  4818. } else
  4819. b = this.unTransformedVertices[3 * d + 0],
  4820. S = this.unTransformedVertices[3 * d + 1],
  4821. T = this.unTransformedVertices[3 * d + 2],
  4822. n[s * d] = b * t,
  4823. n[s * d + 1] = S * t,
  4824. n[s * d + 2] = T * t
  4825. }
  4826. }
  4827. },
  4828. M.prototype.deformMesh = function (e, t) {
  4829. if (0 != this.skinningClusters.length && !this.isRigidSkin) {
  4830. this.deformMeshVertices(e, t);
  4831. var i = e.gl;
  4832. i.bindBuffer(i.ARRAY_BUFFER, e.vertexBuffer),
  4833. i.bufferData(i.ARRAY_BUFFER, e.dynamicVertexData, i.DYNAMIC_DRAW),
  4834. i.bindBuffer(i.ARRAY_BUFFER, null)
  4835. }
  4836. },
  4837. _.prototype.setClearColor = function () {
  4838. if (I.transparentBackground)
  4839. this.gl.clearColor(0, 0, 0, 0);
  4840. else if (this.backgroundMode < 1) {
  4841. var e = this.backgroundColor;
  4842. this.gl.clearColor(e[0], e[1], e[2], 1)
  4843. } else
  4844. this.gl.clearColor(.0582, .06772, .07805, 1)
  4845. },
  4846. _.prototype.draw = function (e) {
  4847. if (this.backgroundMode < 1 || I.transparentBackground)
  4848. return !1;
  4849. if (this.complete()) {
  4850. var t = this.gl,
  4851. i = this.backgroundShader,
  4852. s = e.view,
  4853. n = e.lights.invMatrix;
  4854. i.bind(),
  4855. t.uniformMatrix4fv(i.params.uInverseSkyMatrix, !1, n),
  4856. t.uniformMatrix4fv(i.params.uViewProjection, !1, s.viewProjectionMatrix),
  4857. 3 == this.backgroundMode ? t.uniform4fv(i.params.uSkyCoefficients, this.backgroundCoefficients) : this.backgroundTexture.bind(i.samplers.tSkyTexture),
  4858. e = .07 + .94 * (1 - e.stripData.activeFade()),
  4859. t.uniform1f(i.params.uAlpha, e),
  4860. t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer),
  4861. t.enableVertexAttribArray(i.attribs.vPosition),
  4862. t.vertexAttribPointer(i.attribs.vPosition, 3, t.FLOAT, !1, 20, 0),
  4863. t.enableVertexAttribArray(i.attribs.vTexCoord),
  4864. t.vertexAttribPointer(i.attribs.vTexCoord, 2, t.FLOAT, !1, 20, 12),
  4865. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer),
  4866. e < 1 && (t.enable(t.BLEND),
  4867. t.blendFunc(t.SRC_ALPHA, t.ONE_MINUS_SRC_ALPHA)),
  4868. t.depthMask(!1),
  4869. t.disable(t.DEPTH_TEST),
  4870. t.drawElements(t.TRIANGLES, this.skyIndexCount, t.UNSIGNED_SHORT, 0),
  4871. t.enable(t.DEPTH_TEST),
  4872. t.depthMask(!0),
  4873. e < 1 && t.disable(t.BLEND),
  4874. t.disableVertexAttribArray(i.attribs.vPosition),
  4875. t.disableVertexAttribArray(i.attribs.vTexCoord)
  4876. }
  4877. },
  4878. _.prototype.complete = function () {
  4879. return !(this.backgroundShader && !this.backgroundShader.complete()) && this.specularTexture.complete()
  4880. },
  4881. D.expDecay = function (e, t) {
  4882. return Math.exp(-.69314718 / e * t)
  4883. },
  4884. D.prototype.update = function (e) {
  4885. var t = .001 * (Date.now() - this.timestamp);
  4886. this.timestamp = Date.now();
  4887. for (var i = !1, s = 0; s < this.stripCount; ++s) {
  4888. var n = this.selectedStrip == this.STRIP_MENU ? .3 * (s + 1) - .9 : this.selectedStrip < 0 || s < this.selectedStrip ? -2 : 2;
  4889. if (e)
  4890. this.strips[s] = n;
  4891. else {
  4892. var r = (r = n - this.strips[s]) * D.expDecay(.05, t);
  4893. this.animationActive && (this.strips[s] = n - r),
  4894. i = i || .001 < Math.abs(r)
  4895. }
  4896. }
  4897. this.animationActive = i
  4898. },
  4899. D.prototype.active = function () {
  4900. return this.selectedStrip >= this.STRIP_MENU
  4901. },
  4902. D.prototype.activeFade = function () {
  4903. var e;
  4904. return (e = 1 < (e = (this.strips[this.stripCount - 1] - -2) / (.3 * this.stripCount - .9 - -2)) ? 1 : e) < 0 ? 0 : e
  4905. },
  4906. D.prototype.activeWireframe = function () {
  4907. return this.active() && .01 < Math.abs(this.strips[4] - this.strips[3])
  4908. },
  4909. D.prototype.toggleMenu = function () {
  4910. this.selectedStrip = this.selectedStrip == this.STRIP_MENU ? this.STRIP_NONE : this.STRIP_MENU
  4911. },
  4912. D.prototype.selectStrip = function (e, t) {
  4913. if (this.selectedStrip == this.STRIP_MENU) {
  4914. var i = e + t * this.stripSlant;
  4915. this.selectedStrip = this.STRIP_NONE;
  4916. for (var s = 0; s < this.stripCount; ++s)
  4917. if (i < this.strips[s]) {
  4918. this.selectedStrip = s;
  4919. break
  4920. }
  4921. } else
  4922. this.selectedStrip = this.STRIP_MENU
  4923. },
  4924. U.prototype.loadImage = function (e, t) {
  4925. var i = this.gl;
  4926. e && e.width && e.height && (this.desc.width = e.width,
  4927. this.desc.height = e.height),
  4928. this.id = i.createTexture(),
  4929. i.bindTexture(this.type, this.id),
  4930. this.format = t || i.RGBA,
  4931. this.componentType = i.UNSIGNED_BYTE,
  4932. i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !0),
  4933. i.texImage2D(this.type, 0, this.format, this.format, this.componentType, e),
  4934. this.setParams(),
  4935. i.bindTexture(this.type, null)
  4936. },
  4937. U.prototype.loadArray = function (e, t, i) {
  4938. var s = this.gl;
  4939. this.id = s.createTexture(),
  4940. s.bindTexture(this.type, this.id),
  4941. this.format = t || s.RGBA,
  4942. this.componentType = i || s.UNSIGNED_BYTE,
  4943. s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, !0),
  4944. s.texImage2D(this.type, 0, this.format, this.desc.width, this.desc.height, 0, this.format, this.componentType, e || null),
  4945. this.setParams(),
  4946. s.bindTexture(this.type, null)
  4947. },
  4948. U.prototype.setParams = function () {
  4949. var e = this.gl,
  4950. t = function (e) {
  4951. return 0 < e && 0 == (e & e - 1)
  4952. };
  4953. t(this.desc.width) && t(this.desc.height) || (this.desc.clamp = !0,
  4954. this.desc.mipmap = !1),
  4955. t = !this.desc.nofilter,
  4956. this.desc.mipmap ? (e.generateMipmap(this.type),
  4957. e.texParameteri(this.type, e.TEXTURE_MIN_FILTER, t ? e.LINEAR_MIPMAP_LINEAR : e.NEAREST_MIPMAP_NEAREST)) : e.texParameteri(this.type, e.TEXTURE_MIN_FILTER, t ? e.LINEAR : e.NEAREST),
  4958. e.texParameteri(this.type, e.TEXTURE_MAG_FILTER, t ? e.LINEAR : e.NEAREST),
  4959. (this.desc.clamp || this.desc.mirror) && (t = this.desc.clamp ? e.CLAMP_TO_EDGE : e.MIRRORED_REPEAT,
  4960. e.texParameteri(this.type, e.TEXTURE_WRAP_S, t),
  4961. e.texParameteri(this.type, e.TEXTURE_WRAP_T, t)),
  4962. this.desc.aniso && e.ext.textureAniso && e.texParameteri(this.type, e.ext.textureAniso.TEXTURE_MAX_ANISOTROPY_EXT, this.desc.aniso)
  4963. },
  4964. U.prototype.rebuildMips = function () {
  4965. this.desc.mipmap && (this.gl.bindTexture(this.type, this.id),
  4966. this.gl.generateMipmap(this.type))
  4967. },
  4968. U.prototype.copyColorBuffer = function () {
  4969. this.gl.bindTexture(this.type, this.id),
  4970. this.gl.copyTexSubImage2D(this.type, 0, 0, 0, 0, 0, this.desc.width, this.desc.height)
  4971. },
  4972. U.prototype.bind = function (e) {
  4973. if (e) {
  4974. var t = this.gl;
  4975. t.uniform1i(e.location, e.unit),
  4976. t.activeTexture(t.TEXTURE0 + e.unit),
  4977. t.bindTexture(this.type, this.id)
  4978. }
  4979. },
  4980. U.prototype.destroy = function () {
  4981. this.gl.deleteTexture(this.id),
  4982. this.id = null
  4983. },
  4984. U.prototype.complete = function () {
  4985. return !!this.id
  4986. },
  4987. N.prototype.fromURL = function (e, t) {
  4988. var i = this.cache[e];
  4989. if (void 0 !== i)
  4990. return i;
  4991. var s = new U(this.gl, t);
  4992. return C.fetchImage(e, function (e) {
  4993. s.loadImage(e)
  4994. }),
  4995. this.cache[e] = s
  4996. },
  4997. N.prototype.fromFile = function (e, t) {
  4998. if (!e)
  4999. return null;
  5000. var i = this.cache[e.name];
  5001. if (void 0 !== i)
  5002. return i;
  5003. var s = new U(this.gl, t);
  5004. return this.cache[e.name] = s,
  5005. N.parseFile(e, function (e) {
  5006. s.loadImage(e),
  5007. N.closeImage(e)
  5008. }),
  5009. s
  5010. },
  5011. N.prototype.fromFilesMergeAlpha = function (e, t, i) {
  5012. if (!t)
  5013. return this.fromFile(e, i);
  5014. var s = e.name + "|" + t.name,
  5015. n = this.cache[s];
  5016. if (void 0 !== n)
  5017. return n;
  5018. var r = this.gl;
  5019. this.blitShader || (this.blitShader = new F(this.gl),
  5020. this.blitShader.build("precision highp float; varying vec2 c; attribute vec2 pos; void main(){ gl_Position.xy = 2.0*pos-vec2(1.0); gl_Position.zw = vec2(0.5,1.0); c=pos; }", "precision highp float; varying vec2 c; uniform sampler2D tTex; void main(){ gl_FragColor=texture2D(tTex,c).rgbr; }"),
  5021. this.mergeVerts = r.createBuffer(),
  5022. r.bindBuffer(r.ARRAY_BUFFER, this.mergeVerts),
  5023. n = new Float32Array([0, 0, 2, 0, 0, 2]),
  5024. r.bufferData(r.ARRAY_BUFFER, n, r.STATIC_DRAW),
  5025. r.bindBuffer(r.ARRAY_BUFFER, null));
  5026. var a = function (e) {
  5027. this.blitShader.bind(),
  5028. e.bind(this.blitShader.samplers.tTex),
  5029. r.bindBuffer(r.ARRAY_BUFFER, this.mergeVerts),
  5030. r.enableVertexAttribArray(this.blitShader.attribs.pos),
  5031. r.vertexAttribPointer(this.blitShader.attribs.pos, 2, r.FLOAT, !1, 0, 0),
  5032. r.drawArrays(r.TRIANGLES, 0, 3),
  5033. r.disableVertexAttribArray(this.blitShader.attribs.pos),
  5034. r.bindBuffer(r.ARRAY_BUFFER, null)
  5035. }
  5036. .bind(this),
  5037. o = new U(this.gl, i);
  5038. this.cache[s] = o;
  5039. var h = 0,
  5040. l = 0,
  5041. d = function () {
  5042. if (h && l) {
  5043. var e, t;
  5044. if (t = l.width * l.height > h.width * h.height ? (e = l.width,
  5045. l.height) : (e = h.width,
  5046. h.height),
  5047. o.desc.width = e,
  5048. o.desc.height = t,
  5049. e <= r.limits.viewportSizes[0] && t <= r.limits.viewportSizes[1]) {
  5050. var i = {
  5051. clamp: !0
  5052. };
  5053. h.width == e && h.height == t ? (o.loadImage(h, r.RGBA),
  5054. e = new m(r, {
  5055. color0: o,
  5056. ignoreStatus: !0
  5057. }),
  5058. N.closeImage(h)) : ((t = new U(r, i)).loadImage(h, r.RGB),
  5059. N.closeImage(h),
  5060. o.loadArray(null),
  5061. (e = new m(r, {
  5062. color0: o,
  5063. ignoreStatus: !0
  5064. })).bind(),
  5065. a(t),
  5066. t.destroy()),
  5067. (t = new U(r, i)).loadImage(l, r.RGB),
  5068. N.closeImage(l),
  5069. e.bind(),
  5070. r.colorMask(!1, !1, !1, !0),
  5071. a(t),
  5072. r.colorMask(!0, !0, !0, !0),
  5073. t.destroy(),
  5074. m.bindNone(r),
  5075. o.rebuildMips()
  5076. } else {
  5077. (i = document.createElement("canvas")).width = e,
  5078. i.height = t;
  5079. var s = i.getContext("2d");
  5080. for (s.drawImage(h, 0, 0),
  5081. N.closeImage(h),
  5082. i = s.getImageData(0, 0, e, t),
  5083. i = new Uint8Array(i.data.buffer, i.data.byteOffset, i.data.length),
  5084. s.drawImage(l, 0, 0),
  5085. N.closeImage(l),
  5086. s = s.getImageData(0, 0, e, t).data,
  5087. e = e * t * 4,
  5088. t = 0; t < e; t += 4)
  5089. i[t + 3] = s[t];
  5090. o.loadArray(i)
  5091. }
  5092. N.closeImage(l)
  5093. }
  5094. };
  5095. return N.parseFile(e, function (e) {
  5096. h = e,
  5097. d()
  5098. }),
  5099. N.parseFile(t, function (e) {
  5100. l = e,
  5101. d()
  5102. }),
  5103. o
  5104. },
  5105. N.parseFile = function (e, t, i) {
  5106. var s = i || new Image();
  5107. if ("undefined" != typeof URL && void 0 !== URL.createObjectURL) {
  5108. e = new Blob([e.data], {
  5109. type: e.type
  5110. });
  5111. var n = URL.createObjectURL(e);
  5112. s.onload = function () {
  5113. URL.revokeObjectURL(n),
  5114. t && t(s)
  5115. },
  5116. s.src = n
  5117. } else {
  5118. e = new Blob([e.data], {
  5119. type: e.type
  5120. });
  5121. var r = new FileReader();
  5122. r.onload = function (e) {
  5123. s.src = r.result
  5124. },
  5125. s.onload = function () {
  5126. t && t(s)
  5127. },
  5128. r.readAsDataURL(e)
  5129. }
  5130. },
  5131. N.closeImage = function (e) {
  5132. e && 256 < e.width * e.height && (e.onload = null,
  5133. e.onerror = null,
  5134. e.src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D")
  5135. },
  5136. z.prototype.setBackground3x1 = function (e, t, i, s) {
  5137. var n = 8 / this.controlRect.getScreenHeight();
  5138. this.backgroundControl = e.addTextButton("", 0, (1 - n) / 2, 1, n, 1),
  5139. this.backgroundControl.defaultAlpha = 1,
  5140. this.backgroundControl.setBackground3x1(e, 0, 0, t, i, s, 4),
  5141. this.backgroundControl.controlRect.xPercent = this.controlRect.xPercent,
  5142. this.backgroundControl.controlRect.widthPercent = this.controlRect.widthPercent,
  5143. this.controlRect.linkedControl.style.zIndex = "3",
  5144. this.setupCallbacks()
  5145. },
  5146. z.prototype.setSize = function (e, t) {
  5147. this.pixelsX = e;
  5148. var i = 24 / (this.pixelsY = t);
  5149. this.knobWidthPercent = 24 / e,
  5150. this.knobControlRect.xPercent = .5 - this.knobWidthPercent / 2,
  5151. this.knobControlRect.yPercent = (1 - i) / 2 + -1 / t,
  5152. this.knobControlRect.widthPercent = this.knobWidthPercent,
  5153. this.knobControlRect.heightPercent = i,
  5154. this.controlRect.updateElement(),
  5155. this.backgroundControl.controlRect.xPercent = this.controlRect.xPercent,
  5156. this.backgroundControl.controlRect.widthPercent = this.controlRect.widthPercent,
  5157. this.backgroundControl.controlRect.updateElement()
  5158. },
  5159. z.prototype.setSliderPercent = function (e) {
  5160. e < 0 && (e = 0),
  5161. 1 < e && (e = 1),
  5162. this.sliderPercent = e,
  5163. this.knobControlRect.xPercent = e - this.knobWidthPercent / 2,
  5164. this.knobControlRect.updateElement()
  5165. },
  5166. z.prototype.setupCallbacks = function () {
  5167. var e = function (e) {
  5168. if (this.draggingSlider) {
  5169. var t = this.backgroundControl.controlRect.linkedControl.getBoundingClientRect();
  5170. this.setSliderPercent((e.clientX - t.left) / t.width),
  5171. this.guiScreen.ui.viewer.scene.sceneAnimator.setAnimationProgress(this.sliderPercent, !0),
  5172. this.guiScreen.ui.viewer.scene.sceneAnimator.paused && (this.guiScreen.ui.viewer.scene.postRender.discardAAHistory(),
  5173. this.guiScreen.ui.viewer.reDrawScene())
  5174. }
  5175. }
  5176. .bind(this),
  5177. t = function (e) {
  5178. this.draggingSlider = !0;
  5179. var t = this.backgroundControl.controlRect.linkedControl.getBoundingClientRect();
  5180. this.setSliderPercent((e.clientX - t.left) / t.width),
  5181. this.guiScreen.ui.viewer.scene.sceneAnimator.setAnimationProgress(this.sliderPercent, !0),
  5182. this.guiScreen.ui.viewer.scene.sceneAnimator.lockPlayback = !0,
  5183. this.guiScreen.ui.viewer.scene.sceneAnimator.paused && (this.guiScreen.ui.viewer.scene.postRender.discardAAHistory(),
  5184. this.guiScreen.ui.viewer.reDrawScene())
  5185. }
  5186. .bind(this),
  5187. i = function (e) {
  5188. this.draggingSlider = !1,
  5189. this.guiScreen.ui.viewer.scene.sceneAnimator.lockPlayback = !1
  5190. }
  5191. .bind(this);
  5192. this.guiScreen.ui.viewer.input.element.addEventListener("mousemove", e),
  5193. this.guiScreen.ui.viewer.input.element.addEventListener("mouseup", i),
  5194. this.backgroundControl.controlRect.linkedControl.addEventListener("mousemove", e),
  5195. this.backgroundControl.controlRect.linkedControl.addEventListener("mousedown", t),
  5196. this.backgroundControl.controlRect.linkedControl.addEventListener("mouseup", i),
  5197. this.controlRect.linkedControl.addEventListener("mouseup", i)
  5198. },
  5199. j.prototype.setSize = function (e, t) {
  5200. this.container.width = 0 | e,
  5201. this.container.height = 0 | t,
  5202. this.container.style.width = e + "px",
  5203. this.container.style.height = t + "px",
  5204. this.guiScreen.setSize(this.container.width, this.container.height)
  5205. },
  5206. j.prototype.clearView = function () {
  5207. for (; this.container.hasChildNodes();)
  5208. this.container.removeChild(this.container.childNodes[0]);
  5209. delete this.progressBar,
  5210. delete this.thumbnail,
  5211. delete this.fadeThumbnail,
  5212. delete this.playButton,
  5213. delete this.helpOverlay
  5214. },
  5215. j.prototype.bindInput = function (i) {
  5216. i.onSingleTap.push(function (e, t) {
  5217. this.stripData.selectedStrip != this.stripData.STRIP_NONE && (e = 2 / i.element.clientWidth * e - 1,
  5218. t = 1 - 2 / i.element.clientHeight * t,
  5219. this.stripData.selectStrip(e, t),
  5220. this.stripData.selectedStrip == this.stripData.STRIP_MENU && this.helpOverlay.active && this.helpOverlay.toggle(),
  5221. this.refreshUI(),
  5222. this.viewer.wake())
  5223. }
  5224. .bind(this))
  5225. },
  5226. j.sanitize = function (e) {
  5227. return e ? e.replace(/<|>|\(|\)|$|%|=/g, "") : e
  5228. },
  5229. j.sanitizeURL = function (e) {
  5230. return e ? 0 == e.indexOf("http://") || 0 == e.indexOf("https://") || 0 == e.indexOf("ftp://") ? encodeURI(e) : "http://" + encodeURI(e) : e
  5231. },
  5232. j.prototype.showFailure = function (e, t) {
  5233. this.container.innerHTML = "";
  5234. var i = document.createElement("canvas"),
  5235. s = this.container.width / this.container.height;
  5236. i.width = 100,
  5237. i.height = i.height * s | 0,
  5238. i.style.position = "absolute",
  5239. i.style["z-index"] = "0",
  5240. i.style.width = i.style.height = "100%";
  5241. var n = i.getContext("2d"),
  5242. r = n.fillStyle = n.createRadialGradient(i.width / 2, i.height / 2, (i.width + i.height) / 2, i.width / 2, i.height / 2, 0);
  5243. r.addColorStop(0, "rgb(0,0,0)"),
  5244. r.addColorStop(1, "rgb(35,60,80)"),
  5245. n.fillStyle = r,
  5246. n.fillRect(0, 0, i.width, i.height),
  5247. this.container.appendChild(i);
  5248. var a = document.createElement("div");
  5249. dom.addClass(a, "error"),
  5250. a.style["background-image"] = "url(images/errorBG.png)";
  5251. var o = '<div class="errorInfo"><p style="font-size:1.5em; font-weight:lighter">转换模型时出错</p><p style="font-size:1.3em;letter-spacing:2px;font-weight:bold;line-height:1.5em;margin-top:30px">错误信息: ' + (e || "文件无效(ERROR)请检查您所上传的文件以确定其稳定性") + '</p><p style="font-size:0.8em;line-height:1.5em; margin-top:50px">您可以联系我们的客服、或点击<a href="http://www.4dage.com/tutorial.html" style="color: #a6ccea;">视频教程</a>获取更详细的上传解说<br>4Dweb将全程为您提供最优质的模型展示</p></div>';
  5252. a.innerHTML = o,
  5253. this.container.appendChild(a)
  5254. },
  5255. j.prototype.showPreview = function (e) {
  5256. this.clearView(),
  5257. this.thumbnail = document.createElement("canvas");
  5258. var t = this.container.width / this.container.height;
  5259. this.thumbnail.height = this.viewer.mobile ? 200 : 300,
  5260. this.thumbnail.width = this.thumbnail.height * t | 0,
  5261. this.thumbnail.style.width = this.thumbnail.style.height = "100%";
  5262. var i = (t = this.thumbnail.getContext("2d")).fillStyle = t.createRadialGradient(this.thumbnail.width / 2, this.thumbnail.height / 2, (this.thumbnail.width + this.thumbnail.height) / 2, this.thumbnail.width / 2, 0, 0);
  5263. i.addColorStop(0, "rgb(0,0,0)"),
  5264. i.addColorStop(1, "rgb(7,62,92)"),
  5265. t.fillStyle = i,
  5266. t.fillRect(0, 0, this.thumbnail.width, this.thumbnail.height),
  5267. this.container.appendChild(this.thumbnail),
  5268. this.playButton = document.createElement("input"),
  5269. this.playButton.type = "image",
  5270. // this.playButton.src = I.dataLocale + "play.png",
  5271. this.playButton.style.position = "absolute",
  5272. this.playButton.style.left = "50%",
  5273. this.playButton.style.top = "50%",
  5274. this.playButton.style["-webkit-transform"] = this.playButton.style.transform = "translate(-50%,-50%) scale(0.4,0.4)",
  5275. this.playButton.style.opacity = .5,
  5276. this.playButton.style.outline = "0px",
  5277. this.playButton.onclick = function () {
  5278. this.viewer.loadScene(this.viewer.sceneURL),
  5279. this.container.removeChild(this.playButton),
  5280. delete this.playButton
  5281. }
  5282. .bind(this),
  5283. this.container.appendChild(this.playButton),
  5284. e || n(this.viewer.sceneURL, function (e) {
  5285. this.loadingImageURL || this.setThumbnail(e)
  5286. }
  5287. .bind(this))
  5288. },
  5289. j.prototype.setThumbnailURL = function (e) {
  5290. (this.loadingImageURL = e) && C.fetchImage(this.loadingImageURL, this.setThumbnail.bind(this))
  5291. },
  5292. j.prototype.setThumbnail = function (e) {
  5293. if (this.thumbnail)
  5294. if (e.height >= this.container.height) {
  5295. var t = this.container.height / e.height;
  5296. e.style.position = "absolute",
  5297. e.style.outline = "0px",
  5298. e.style.left = "50%",
  5299. e.style.top = "50%",
  5300. e.style["-webkit-transform"] = e.style.transform = "translate(-50%,-50%) scale(" + t + "," + t + ")",
  5301. this.container.replaceChild(e, this.thumbnail),
  5302. this.thumbnail = e
  5303. } else {
  5304. var i, s = this.thumbnail.getContext("2d"),
  5305. n = this.thumbnail.width,
  5306. r = this.thumbnail.height;
  5307. t = r / e.height;
  5308. s.drawImage(e, (n - e.width * t) / 2, 0, e.width * t, r);
  5309. try {
  5310. i = s.getImageData(0, 0, n, r)
  5311. } catch (e) {
  5312. return
  5313. }
  5314. e = s.createImageData(n, r);
  5315. for (var a = 0; a < 2; ++a) {
  5316. t = i.data;
  5317. for (var o = e.data, h = 0, l = 0; l < r; ++l)
  5318. for (var d = 0; d < n; ++d) {
  5319. for (var c = 0, u = 0, f = 0, m = -2; m <= 2; ++m)
  5320. for (var p = (p = l + m) < 0 ? 0 : r <= p ? r - 1 : p, g = -2; g <= 2; ++g) {
  5321. var v;
  5322. c = c + t[v = 4 * (p * n + (v = (v = d + g) < 0 ? 0 : n <= v ? n - 1 : v))],
  5323. u = u + t[v + 1],
  5324. f = f + t[v + 2]
  5325. }
  5326. o[h++] = c / 25,
  5327. o[h++] = u / 25,
  5328. o[h++] = f / 25,
  5329. o[h++] = 255
  5330. }
  5331. t = i,
  5332. i = e,
  5333. e = t
  5334. }
  5335. s.putImageData(i, 0, 0)
  5336. }
  5337. },
  5338. j.prototype.showActiveView = function () {
  5339. var e, t, i, s, n, r = this.thumbnail;
  5340. this.clearView(),
  5341. r && (this.fadeThumbnail = r,
  5342. this.fadeThumbnail.style.opacity = 1,
  5343. this.container.appendChild(this.fadeThumbnail)),
  5344. void 0 === I.largeUI && (I.largeUI = this.viewer.mobile),
  5345. this.container.width < 450 && (I.largeUI = !1);
  5346. var a = g.support();
  5347. r = 1;
  5348. window.devicePixelRatio && (2 < window.devicePixelRatio ? r = 4 : 1 < window.devicePixelRatio && (r = 2)),
  5349. I.largeUI && r < 4 && (r *= 2);
  5350. var o = I.largeUI ? .3 : .5;
  5351. this.helpOverlay = document.createElement("div"),
  5352. this.helpOverlay.style.pointerEvents = "none",
  5353. this.container.appendChild(this.helpOverlay),
  5354. this.hideSigOnHelp = e = this.container.width < 450,
  5355. this.hideSigOnStrips = !0,
  5356. t = [8, 8],
  5357. s = e ? (i = 198 + 2 * t[0],
  5358. 258 + 2 * t[1]) : (i = 354 + 2 * t[0],
  5359. 218 + 2 * t[1]),
  5360. (n = document.createElement("div")).style.position = "absolute",
  5361. n.style.width = n.style.height = "100%",
  5362. this.helpOverlay.contents = n,
  5363. (n = document.createElement("div")).style.position = "absolute",
  5364. n.style.right = I.largeUI ? "85px" : "45px",
  5365. n.style.top = I.largeUI ? "20px" : "12px",
  5366. n.style["z-index"] = "20",
  5367. n.style.width = i + "px",
  5368. n.style.height = s + "px",
  5369. this.helpOverlay.contents.appendChild(n),
  5370. (s = document.createElement("div")).style.position = "absolute",
  5371. s.style.width = "100%",
  5372. s.style.height = "100%",
  5373. s.style.backgroundColor = "black",
  5374. s.style.opacity = "0.65",
  5375. s.style.borderRadius = "16px",
  5376. n.appendChild(s),
  5377. s = document.createElement("a"),
  5378. dom.addClass(s, "tipClose"),
  5379. s.style.position = "absolute",
  5380. s.style.color = "#FFFFFF",
  5381. s.style.backgroundColor = "rgba(0,0,0,0.0)",
  5382. s.style.border = "0px",
  5383. s.style.outline = "0px",
  5384. s.style.fontSize = I.largeUI ? "16pt" : "10pt",
  5385. s.style.right = I.largeUI ? "-9px" : "4px",
  5386. s.style.top = I.largeUI ? "3px" : "7px",
  5387. s.style.width = s.style.height = I.largeUI ? "32px" : "16px",
  5388. s.style.pointerEvents = "auto",
  5389. s.style.cursor = "pointer",
  5390. s.onclick = function (e) {
  5391. this.helpOverlay.toggle(),
  5392. this.refreshUI()
  5393. }
  5394. .bind(this, s),
  5395. n.appendChild(s),
  5396. (s = document.createElement("center")).style.position = "absolute",
  5397. s.style.left = t[0] - 4 + "px",
  5398. s.style.right = t[0] + 4 + "px",
  5399. s.style.top = s.style.bottom = t[1] + "px",
  5400. s.style.paddingTop = "8px",
  5401. e || (s.style.paddingRight = "8px"),
  5402. n.appendChild(s),
  5403. n = s,
  5404. t = (this.viewer.mobile ? "M" : "PC") + (2 < r ? 4 : 2) + "x.png",
  5405. (s = document.createElement("img")).style.width = "66px",
  5406. s.style.height = "90px",
  5407. n.appendChild(s),
  5408. (s = document.createElement("img")).style.width = "66px",
  5409. s.style.height = "90px",
  5410. n.appendChild(s),
  5411. (s = document.createElement("img")).style.width = "66px",
  5412. s.style.height = "90px",
  5413. n.appendChild(s),
  5414. (s = document.createElement("img")).style.width = "66px",
  5415. s.style.height = "90px",
  5416. n.appendChild(s),
  5417. (s = document.createElement("img")).style.position = "relative",
  5418. e || (s.style.left = "8px"),
  5419. s.style.width = "66px",
  5420. s.style.height = "90px",
  5421. n.appendChild(s),
  5422. (t = document.createElement("a")).href = "http://www.4dage.com/",
  5423. t.target = "_blank",
  5424. t.style.pointerEvents = "auto",
  5425. t.style.cursor = "pointer",
  5426. n.appendChild(t),
  5427. (s = document.createElement("img")).style.position = "absolute",
  5428. s.style.left = .5 * i - (e ? 65 : 116) + "px",
  5429. s.style.bottom = e ? "8px" : "12px",
  5430. s.style.width = e ? "116px" : "232px",
  5431. t.appendChild(s),
  5432. (i = document.createElement("div")).style.position = "absolute",
  5433. i.style.left = 0,
  5434. i.style.right = e ? "30px" : "128px",
  5435. i.style.bottom = e ? "-4px" : "4px",
  5436. i.style.textAlign = "right",
  5437. i.style.fontFamilly = "Open Sans Arial",
  5438. n.appendChild(i),
  5439. (e = document.createElement("font")).style.fontSize = "9pt",
  5440. e.style.fontFamily = "Open Sans Arial",
  5441. i.appendChild(e),
  5442. e.appendChild(t),
  5443. this.helpOverlay.active = !1,
  5444. this.helpOverlay.toggle = function (e) {
  5445. this.active ? this.removeChild(this.contents) : this.appendChild(this.contents),
  5446. this.active = !this.active
  5447. }
  5448. .bind(this.helpOverlay, this.viewer),
  5449. this.menuCluster = document.createElement("div"),
  5450. this.menuCluster.style.position = "absolute",
  5451. this.menuCluster.style.right = I.largeUI ? "4px" : "0px",
  5452. this.menuCluster.style.top = I.largeUI ? "20px" : "10px",
  5453. I.largeUI ? (this.menuCluster.style.width = "72px",
  5454. this.menuCluster.style.height = "64px") : (this.menuCluster.style.width = "36px",
  5455. this.menuCluster.style.height = "36px"),
  5456. (n = document.createElement("div")).style.left = n.style.top = "0px",
  5457. n.style.width = n.style.height = "100%",
  5458. this.menuCluster.contents = n,
  5459. this.menuCluster.appendChild(n),
  5460. e = 0;
  5461. var h = (i = function (e, t, i, s, n, r) {
  5462. var a = document.createElement("div");
  5463. return dom.addClass(a, "controlBtn"),
  5464. dom.addClass(a, i),
  5465. a.title = t,
  5466. I.largeUI && dom.addClass(a, "largeUI"),
  5467. e.appendChild(a),
  5468. a
  5469. })(this.menuCluster.contents, "4DAGE主页", "home", "", e++, o);
  5470. for (h.onclick = function (e) {
  5471. window.open("http://www.4dage.com", "_blank")
  5472. }
  5473. .bind(this, h),
  5474. a && ((a = i(this.menuCluster.contents, "全屏", "fullscreen", "fullscreen" + r + "x.png", e++, o)).onclick = function (e) {
  5475. g.active() ? g.end() : g.begin(this.viewer.domRoot, this.viewer.fullscreenChange.bind(this.viewer)),
  5476. dom.hasClass(e, "full") ? dom.removeClass(e, "full") : dom.addClass(e, "full"),
  5477. this.refreshUI()
  5478. }
  5479. .bind(this, a)),
  5480. (a = i(this.menuCluster.contents, "操作方式说明", "tips", "help" + r + "x.png", e++, o)).onclick = function (e) {
  5481. this.helpOverlay.toggle(),
  5482. this.refreshUI()
  5483. }
  5484. .bind(this, a),
  5485. this.container.appendChild(this.menuCluster),
  5486. this.menuCluster.active = !0,
  5487. this.menuCluster.toggle = function () {
  5488. this.active ? this.removeChild(this.contents) : this.appendChild(this.contents),
  5489. this.active = !this.active
  5490. }
  5491. .bind(this.menuCluster),
  5492. void 0 !== I.hostImage && (I.hostURL && ((t = document.createElement("a")).href = I.hostURL,
  5493. t.target = "_blank"),
  5494. (s = document.createElement("img")).src = I.hostImage,
  5495. s.style.position = "absolute",
  5496. s.style.top = "4px",
  5497. s.style.left = "4px",
  5498. s.style.opacity = .65,
  5499. s.style["-webkit-transform"] = s.style.transform = "translate(-50%,-50%) scale(0.5,0.5) translate(50%,50%)",
  5500. I.hostURL ? (s.onmouseover = function () {
  5501. this.style.opacity = 1
  5502. }
  5503. .bind(s),
  5504. s.onmouseout = function () {
  5505. this.style.opacity = .5
  5506. }
  5507. .bind(s),
  5508. t.appendChild(s),
  5509. this.hostLogo = t) : this.hostLogo = s,
  5510. (e = new XMLHttpRequest()).open("HEAD", s.src, !0),
  5511. e.onload = function () {
  5512. this.container.appendChild(this.hostLogo)
  5513. }
  5514. .bind(this),
  5515. e.send()),
  5516. this.sceneStats = document.createElement("text"),
  5517. this.sceneStats.style.position = "absolute",
  5518. this.sceneStats.style.left = "9px",
  5519. this.sceneStats.style.bottom = "8px",
  5520. this.sceneStats.style.color = "gray",
  5521. this.sceneStats.style.fontFamily = "Open Sans Arial",
  5522. this.sceneStats.style.fontSize = "75%",
  5523. e = a = r = 0; e < this.viewer.scene.meshes.length; ++e)
  5524. r += (i = this.viewer.scene.meshes[e]).indexCount / 3,
  5525. a += i.vertexCount;
  5526. this.sceneStats.innerHTML = "Triangles: " + (0 | r).toLocaleString() + "<br>Vertices: " + (0 | a).toLocaleString(),
  5527. I.showFrameTime && (this.frameTimer = document.createElement("text"),
  5528. this.frameTimer.style.position = "absolute",
  5529. this.frameTimer.style.left = this.frameTimer.style.top = "5px",
  5530. this.frameTimer.style.color = "gray",
  5531. this.frameTimer.style.fontSize = "75%",
  5532. this.container.appendChild(this.frameTimer),
  5533. this.frameTimer.innerHTML = "--",
  5534. this.frameCount = 1e20)
  5535. },
  5536. j.prototype.refreshUI = function () {
  5537. if (this.sigCluster) {
  5538. var e = !1,
  5539. t = this.stripData.selectedStrip == this.stripData.STRIP_MENU;
  5540. this.hideSigOnStrips && (e = e || t),
  5541. this.hideSigOnHelp && (e = e || this.helpOverlay.active),
  5542. this.sigCluster.active == e && this.sigCluster.toggle()
  5543. }
  5544. },
  5545. j.prototype.signalLoadProgress = function (e, t) {
  5546. if (this.thumbnail) {
  5547. if (!this.progressBar) {
  5548. var i = document.createElement("div");
  5549. i.style.backgroundColor = "rgb(240,240,240)",
  5550. i.style.opacity = .9,
  5551. i.style.position = "absolute",
  5552. i.style.zIndex = 999
  5553. i.style.left = "20%",
  5554. i.style.width = "60%",
  5555. i.style.bottom = "30%",
  5556. i.style.height = "4px",
  5557. i.style["border-radius"] = "2px",
  5558. this.progressBar = document.createElement("div"),
  5559. this.progressBar.style.backgroundColor = "#00ccff",
  5560. this.progressBar.style.position = "absolute",
  5561. this.progressBar.style.left = this.progressBar.style.bottom = "0px",
  5562. this.progressBar.style.height = "100%",
  5563. this.progressBar.style.width = "0px",
  5564. this.progressBar.style["border-radius"] = "2px",
  5565. i.appendChild(this.progressBar),
  5566. this.container.appendChild(i),
  5567. this.playButton && (this.container.removeChild(this.playButton),
  5568. delete this.playButton)
  5569. }
  5570. this.progressBar.style.width = t <= 0 ? (100 * e / (2097152 + e) | 0) + "%" : (100 * e / t | 0) + "%"
  5571. }
  5572. },
  5573. j.prototype.animating = function () {
  5574. return !!this.fadeThumbnail || !!this.frameTimer
  5575. },
  5576. j.prototype.animate = function () {
  5577. if (this.fadeThumbnail && (this.fadeThumbnailTimer = this.fadeThumbnailTimer || Date.now(),
  5578. this.fadeThumbnail.style.opacity = 1 - .0015 * (Date.now() - this.fadeThumbnailTimer),
  5579. this.fadeThumbnail.style.opacity < .01 && (this.container.removeChild(this.fadeThumbnail),
  5580. delete this.fadeThumbnail,
  5581. delete this.fadeThumbnailTimer)),
  5582. this.frameTimer && (this.frameCount++,
  5583. 60 <= this.frameCount)) {
  5584. var e = (new Date()).getTime();
  5585. if (void 0 !== this.frameTime) {
  5586. var t = (e - this.frameTime) / this.frameCount;
  5587. t = Math.floor(100 * t) / 100;
  5588. this.frameTimer.innerHTML = t + " ms",
  5589. this.frameTimer.style.color = t < 32 ? "green" : "red"
  5590. }
  5591. this.frameCount = 0,
  5592. this.frameTime = e
  5593. }
  5594. if (this.guiScreen && this.guiScreen.playbackControls && ((e = this.guiScreen.playbackControls.timelineSlider).draggingSlider ? this.viewer.scene.sceneAnimator.setAnimationProgress(e.sliderPercent, !0) : e.setSliderPercent(this.viewer.scene.sceneAnimator.animationProgress)),
  5595. this.sceneStats) {
  5596. for (var i = t = e = 0; i < this.viewer.scene.meshes.length; ++i) {
  5597. var s = this.viewer.scene.meshes[i];
  5598. e = e + s.indexCount / 3,
  5599. t = t + s.vertexCount
  5600. }
  5601. this.sceneStats.innerHTML = "Triangles: " + (0 | e).toLocaleString() + "<br>Vertices: " + (0 | t).toLocaleString(),
  5602. this.viewer.scene.sceneAnimator && this.viewer.scene.sceneAnimator.showPlayControls && (this.sceneStats.innerHTML += "<br><br><br><br>"),
  5603. e = !!this.sceneStats.parentElement,
  5604. t = this.stripData.active() || !1,
  5605. e && !t ? (this.container.removeChild(this.sceneStats),
  5606. this.hostLogo && this.container.appendChild(this.hostLogo)) : !e && t && (this.container.appendChild(this.sceneStats),
  5607. this.hostLogo && this.container.removeChild(this.hostLogo))
  5608. }
  5609. this.refreshUI(),
  5610. (this.stripData.animationActive || this.stripData.active()) && (this.animateStrips(),
  5611. this.stripData.animationActive && this.viewer.wake())
  5612. },
  5613. j.prototype.animateStrips = function () {
  5614. if (this.stripText)
  5615. for (var e = Math.atan(this.viewer.canvas.height / this.viewer.canvas.width / this.stripData.stripSlant), t = 0; t < this.stripData.labels.length; ++t) {
  5616. var i = .5 + .5 * (i = (i = this.stripData.strips[t]) - this.stripData.stripSlant);
  5617. t == this.stripData.selectedStrip ? (this.stripText[t].style["-ms-transform"] = this.stripText[t].style["-webkit-transform"] = this.stripText[t].style.transform = "none",
  5618. this.stripText[t].style.top = "4px",
  5619. this.stripText[t].style.left = "0px",
  5620. this.stripText[t].style.width = "150px",
  5621. this.stripText[t].txt.style.textAlign = "center",
  5622. this.stripText[t].txt.style.background = "rgba(0, 0, 0, 0.75)",
  5623. this.stripText[t].txt.style.background = "-webkit-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5624. this.stripText[t].txt.style.background = "-o-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5625. this.stripText[t].txt.style.background = "-moz-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5626. this.stripText[t].txt.style.background = "linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5627. this.stripText[t].txt.style.paddingLeft = "32px",
  5628. this.stripText[t].txt.style.paddingTop = "6px",
  5629. this.stripText[t].txt.style.paddingBottom = "4px",
  5630. this.stripText[t].txt.style.textShadow = "1px 1px 2px rgba(0,0,0,0.7)",
  5631. this.stripText[t].line.style.opacity = .5,
  5632. this.stripText[t].line.style.top = "100%",
  5633. this.stripText[t].line.style.width = "100%",
  5634. this.stripText[t].line.style.height = "1px") : (this.stripText[t].style["-ms-transform"] = this.stripText[t].style["-webkit-transform"] = this.stripText[t].style.transform = "translate(-50%, -50%) rotate(" + e + "rad) translate(50%, 50%)",
  5635. this.stripText[t].style.left = 100 * i + "%",
  5636. this.stripText[t].style.top = "0px",
  5637. this.stripText[t].style.width = "85px",
  5638. this.stripText[t].txt.style.textAlign = "left",
  5639. this.stripText[t].txt.style.background = "none",
  5640. this.stripText[t].txt.style.paddingLeft = "8px",
  5641. this.stripText[t].txt.style.paddingTop = "6px",
  5642. this.stripText[t].txt.style.paddingBottom = "4px",
  5643. this.stripText[t].txt.style.textShadow = "2px 0px 3px rgba(0,0,0,0.7)",
  5644. this.stripText[t].line.style.opacity = 1,
  5645. this.stripText[t].line.style.top = "-1px",
  5646. this.stripText[t].line.style.width = "10000px",
  5647. this.stripText[t].line.style.height = "2px")
  5648. }
  5649. };
  5650. var V = {
  5651. type: Float32Array,
  5652. create: function (e, t, i, s) {
  5653. var n = new V.type(4);
  5654. return n[0] = e,
  5655. n[1] = t,
  5656. n[2] = i,
  5657. n[3] = s,
  5658. n
  5659. },
  5660. empty: function () {
  5661. return new V.type(4)
  5662. },
  5663. set: function (e, t, i, s, n) {
  5664. e[0] = t,
  5665. e[1] = i,
  5666. e[2] = s,
  5667. e[3] = n
  5668. },
  5669. copy: function (e, t) {
  5670. e[0] = t[0],
  5671. e[1] = t[1],
  5672. e[2] = t[2],
  5673. e[3] = t[3]
  5674. },
  5675. add: function (e, t, i) {
  5676. return e[0] = t[0] + i[0],
  5677. e[1] = t[1] + i[1],
  5678. e[2] = t[2] + i[2],
  5679. e[3] = t[3] + i[3],
  5680. e
  5681. },
  5682. sub: function (e, t, i) {
  5683. return e[0] = t[0] - i[0],
  5684. e[1] = t[1] - i[1],
  5685. e[2] = t[2] - i[2],
  5686. e[3] = t[3] - i[3],
  5687. e
  5688. },
  5689. scale: function (e, t, i) {
  5690. return e[0] = i[0] * t,
  5691. e[1] = i[1] * t,
  5692. e[2] = i[2] * t,
  5693. e[3] = i[3] * t,
  5694. e
  5695. },
  5696. mul: function (e, t, i) {
  5697. return e[0] = t[0] * i[0],
  5698. e[1] = t[1] * i[1],
  5699. e[2] = t[2] * i[2],
  5700. e[3] = t[3] * i[3],
  5701. e
  5702. },
  5703. mad: function (e, t, i, s) {
  5704. return e[0] = t[0] * i[0] + s[0],
  5705. e[1] = t[1] * i[1] + s[1],
  5706. e[2] = t[2] * i[2] + s[2],
  5707. e[3] = t[3] * i[3] + s[3],
  5708. e
  5709. },
  5710. smad: function (e, t, i, s) {
  5711. return e[0] = t * i[0] + s[0],
  5712. e[1] = t * i[1] + s[1],
  5713. e[2] = t * i[2] + s[2],
  5714. e[3] = t * i[3] + s[3],
  5715. e
  5716. },
  5717. negate: function (e, t) {
  5718. return e[0] = -t[0],
  5719. e[1] = -t[1],
  5720. e[2] = -t[2],
  5721. e
  5722. },
  5723. negate4: function (e, t) {
  5724. return e[0] = -t[0],
  5725. e[1] = -t[1],
  5726. e[2] = -t[2],
  5727. e[3] = -t[3],
  5728. e
  5729. },
  5730. length: function (e) {
  5731. var t = e[0],
  5732. i = e[1];
  5733. return e = e[2],
  5734. Math.sqrt(t * t + i * i + e * e)
  5735. },
  5736. distance: function (e, t) {
  5737. var i = e[0] - t[0],
  5738. s = e[1] - t[1],
  5739. n = e[2] - t[2];
  5740. return Math.sqrt(i * i + s * s + n * n)
  5741. },
  5742. dot: function (e, t) {
  5743. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2]
  5744. },
  5745. dot4: function (e, t) {
  5746. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3] * t[3]
  5747. },
  5748. normalize: function (e, t) {
  5749. var i = t[0],
  5750. s = t[1],
  5751. n = t[2],
  5752. r = Math.sqrt(i * i + s * s + n * n);
  5753. return 0 == r ? V.set(e, 0, 0, 0, 0) : (r = 1 / r,
  5754. e[0] = i * r,
  5755. e[1] = s * r,
  5756. e[2] = n * r,
  5757. e)
  5758. },
  5759. cross: function (e, t, i) {
  5760. return e[0] = t[1] * i[2],
  5761. e[0] += -t[2] * i[1],
  5762. e[1] = t[2] * i[0] - t[0] * i[2],
  5763. e[2] = t[0] * i[1] - t[1] * i[0],
  5764. e
  5765. },
  5766. lerp: function (e, t, i, s) {
  5767. var n = 1 - s;
  5768. return e[0] = t[0] * n + i[0] * s,
  5769. e[1] = t[1] * n + i[1] * s,
  5770. e[2] = t[2] * n + i[2] * s,
  5771. e
  5772. },
  5773. lerp4: function (e, t, i, s) {
  5774. var n = 1 - s;
  5775. return e[0] = t[0] * n + i[0] * s,
  5776. e[1] = t[1] * n + i[1] * s,
  5777. e[2] = t[2] * n + i[2] * s,
  5778. e[3] = t[3] * n + i[3] * s,
  5779. e
  5780. },
  5781. min: function (e, t, i) {
  5782. return e[0] = Math.min(t[0], i[0]),
  5783. e[1] = Math.min(t[1], i[1]),
  5784. e[2] = Math.min(t[2], i[2]),
  5785. e[3] = Math.min(t[3], i[3]),
  5786. e
  5787. },
  5788. max: function (e, t, i) {
  5789. return e[0] = Math.max(t[0], i[0]),
  5790. e[1] = Math.max(t[1], i[1]),
  5791. e[2] = Math.max(t[2], i[2]),
  5792. e[3] = Math.max(t[3], i[3]),
  5793. e
  5794. },
  5795. projectOnPlane: function (e, t, i, s) {
  5796. var n = V.empty();
  5797. return V.sub(n, t, i),
  5798. i = V.dot(n, s),
  5799. smad(e, -i, normal, t),
  5800. e
  5801. }
  5802. };
  5803. function H(e) {
  5804. this.pivot = [0, 0, 0],
  5805. this.rotation = [0, 0],
  5806. this.radius = 1,
  5807. this.nearPlane = .3,
  5808. this.fov = 45,
  5809. this.size = [1, 1],
  5810. this.transform = S.empty(),
  5811. this.viewMatrix = S.empty(),
  5812. this.projectionMatrix = S.empty(),
  5813. this.viewProjectionMatrix = S.empty(),
  5814. e ? this.loadView(e, !0) : (this.saveResetView(),
  5815. this.updateView(),
  5816. this.updateProjection())
  5817. }
  5818. function W(e, t, i, s) {
  5819. var n;
  5820. if (this.mobile = !!/Android|iPhone|iPod|iPad|Windows Phone|IEMobile|BlackBerry|webOS/.test(navigator.userAgent),
  5821. this.mobileFast = !!/iPhone|iPad/.test(navigator.userAgent),
  5822. n = !this.mobile)
  5823. e: {
  5824. if ((n = document.createElement("canvas")).width = n.height = 16,
  5825. n = n.getContext("webgl", {}) || n.getContext("experimental-webgl", {})) {
  5826. var r = n.getExtension("WEBGL_debug_renderer_info");
  5827. if (r) {
  5828. n = n.getParameter(r.UNMASKED_RENDERER_WEBGL),
  5829. n = !!/Intel|INTEL/.test(n);
  5830. break e
  5831. }
  5832. }
  5833. n = !1
  5834. }
  5835. this.desktopSlow = n,
  5836. this.domRoot = document.createElement("div"),
  5837. this.domRoot.style.width = e + "px",
  5838. this.domRoot.style.height = t + "px",
  5839. this.initCanvas(e, t),
  5840. this.scene = this.input = null,
  5841. this.sceneURL = i,
  5842. this.sleepCounter = 8,
  5843. this.onLoad = null,
  5844. this.stripData = new D(),
  5845. this.ui = new j(this),
  5846. this.ui.setSize(e, t),
  5847. this.ui.showPreview(s)
  5848. }
  5849. H.prototype.saveResetView = function () {
  5850. this.resetDesc = {
  5851. angles: [this.rotation[0], this.rotation[1]],
  5852. pivot: [this.pivot[0], this.pivot[1], this.pivot[2]],
  5853. limits: this.limits,
  5854. orbitRadius: this.radius,
  5855. fov: this.fov
  5856. }
  5857. },
  5858. H.prototype.loadView = function (e, t) {
  5859. e && (this.rotation[0] = e.angles[0],
  5860. this.rotation[1] = e.angles[1],
  5861. rotInfo.pivot[0] || (rotInfo.pivot[0] = e.pivot[0]),
  5862. rotInfo.pivot[1] || (rotInfo.pivot[1] = e.pivot[1]),
  5863. rotInfo.pivot[2] || (rotInfo.pivot[2] = e.pivot[2]),
  5864. this.pivot[0] = rotInfo.pivot[0],
  5865. this.pivot[1] = rotInfo.pivot[1],
  5866. this.pivot[2] = rotInfo.pivot[2],
  5867. this.radius = parseFloat(getQueryVariable('currentdis') ? Number(getQueryVariable('currentdis')) : e.orbitRadius),
  5868. this.fov = e.fov,
  5869. // this.limits = {
  5870. // orbitRadius:{
  5871. // max: getQueryVariable('camdismax')?Number(getQueryVariable('camdismax')): e.limits.orbitRadius.max,
  5872. // min: getQueryVariable('camdismmin')?Number(getQueryVariable('camdismmin')): e.limits.orbitRadius.min,
  5873. // }
  5874. // },
  5875. t && this.saveResetView(),
  5876. this.updateView(),
  5877. this.updateProjection())
  5878. // console.log(e.limits,this.limits,'limits');
  5879. },
  5880. H.prototype.reset = function () {
  5881. this.loadView(this.resetDesc)
  5882. },
  5883. H.prototype.updateView = function () {
  5884. if (void 0 !== this.limits) {
  5885. if (this.limits.angles) {
  5886. var e = this.limits.angles.x,
  5887. t = this.limits.angles.y;
  5888. if (void 0 !== e) {
  5889. var i = this.rotation[0] - e.offset;
  5890. e = Math.min(Math.max(i, e.min), e.max);
  5891. this.rotation[0] += e - i
  5892. }
  5893. void 0 !== t && (i = this.rotation[1] - t.offset,
  5894. e = Math.min(Math.max(i, t.min), t.max),
  5895. this.rotation[1] += e - i)
  5896. }
  5897. void 0 !== this.limits.orbitRadius && (t = this.limits.orbitRadius.min,
  5898. i = this.limits.orbitRadius.max,
  5899. void 0 !== t && (this.radius = Math.max(this.radius, t)),
  5900. void 0 !== i && (this.radius = Math.min(this.radius, i))),
  5901. void 0 !== this.limits.pan && (t = this.limits.pan,
  5902. i = this.resetDesc.pivot,
  5903. t.x && (this.pivot[0] = i[0]),
  5904. t.y && (this.pivot[1] = i[1]),
  5905. t.z && (this.pivot[2] = i[2]))
  5906. }
  5907. S.translation(this.transform, 0, 0, this.radius),
  5908. t = S.rotation(S.empty(), this.rotation[0], 0),
  5909. i = S.rotation(S.empty(), this.rotation[1], 1),
  5910. S.mul(t, i, t),
  5911. S.mul(this.transform, t, this.transform),
  5912. this.transform[12] += this.pivot[0],
  5913. this.transform[13] += this.pivot[1],
  5914. this.transform[14] += this.pivot[2],
  5915. S.invert(this.viewMatrix, this.transform),
  5916. S.mul(this.viewProjectionMatrix, this.viewMatrix, this.projectionMatrix)
  5917. },
  5918. H.prototype.updateProjection = function (e) {
  5919. S.perspectiveInfinite(this.projectionMatrix, this.fov, this.size[0] / this.size[1], this.nearPlane, e),
  5920. S.mul(this.viewProjectionMatrix, this.projectionMatrix, this.viewMatrix)
  5921. },
  5922. W.prototype.initCanvas = function (e, t) {
  5923. if (this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas),
  5924. this.canvas = document.createElement("canvas"),
  5925. this.pixelRatio = window.devicePixelRatio || 1,
  5926. this.mobile) {
  5927. var i = this.mobileFast ? 1.5 : 1;
  5928. this.pixelRatio = this.pixelRatio > i ? i : this.pixelRatio
  5929. } else
  5930. this.desktopSlow && (this.pixelRatio = 1);
  5931. this.canvas.width = e * this.pixelRatio,
  5932. this.canvas.height = t * this.pixelRatio,
  5933. this.canvas.style.width = e + "px",
  5934. this.canvas.style.height = t + "px",
  5935. this.canvas.style.position = "absolute",
  5936. this.domRoot.appendChild(this.canvas)
  5937. },
  5938. W.prototype.initGL = function () {
  5939. var e = {
  5940. alpha: !!I.transparentBackground,
  5941. depth: !1,
  5942. stencil: !1,
  5943. antialias: !1,
  5944. premultipliedAlpha: !!I.transparentBackground,
  5945. preserveDrawingBuffer: !1
  5946. };
  5947. e = this.gl = this.canvas.getContext("webgl", e) || this.canvas.getContext("experimental-webgl", e);
  5948. return this.gl ? (this.canvas.addEventListener("webglcontextlost", function (e) {
  5949. e.preventDefault()
  5950. }, !1),
  5951. this.canvas.addEventListener("webglcontextrestored", function (e) {
  5952. this.loadScene(this.sceneURL)
  5953. }
  5954. .bind(this), !1),
  5955. e.ext = {
  5956. textureAniso: e.getExtension("EXT_texture_filter_anisotropic") || e.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || e.getExtension("MOZ_EXT_texture_filter_anisotropic"),
  5957. textureFloat: e.getExtension("OES_texture_float"),
  5958. textureFloatLinear: e.getExtension("OES_texture_float_linear"),
  5959. textureHalf: e.getExtension("OES_texture_half_float"),
  5960. textureHalfLinear: e.getExtension("OES_texture_half_float_linear"),
  5961. textureDepth: e.getExtension("WEBGL_depth_texture"),
  5962. colorBufferFloat: e.getExtension("WEBGL_color_buffer_float"),
  5963. colorBufferHalf: e.getExtension("EXT_color_buffer_half_float"),
  5964. index32bit: e.getExtension("OES_element_index_uint"),
  5965. loseContext: e.getExtension("WEBGL_lose_context"),
  5966. derivatives: e.getExtension("OES_standard_derivatives"),
  5967. renderInfo: e.getExtension("WEBGL_debug_renderer_info")
  5968. },
  5969. e.limits = {
  5970. textureSize: e.getParameter(e.MAX_TEXTURE_SIZE),
  5971. textureCount: e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),
  5972. varyings: e.getParameter(e.MAX_VARYING_VECTORS),
  5973. vertexAttribs: e.getParameter(e.MAX_VERTEX_ATTRIBS),
  5974. vertexUniforms: e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),
  5975. fragmentUniforms: e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),
  5976. viewportSizes: e.getParameter(e.MAX_VIEWPORT_DIMS),
  5977. vendor: e.getParameter(e.VENDOR),
  5978. version: e.getParameter(e.VERSION)
  5979. },
  5980. e.hints = {
  5981. mobile: this.mobile,
  5982. pixelRatio: this.pixelRatio
  5983. },
  5984. e.enable(e.DEPTH_TEST),
  5985. e.shaderCache = new O(e),
  5986. e.textureCache = new N(e),
  5987. this.allocBacking(),
  5988. !0) : (this.ui.showFailure('webgl出错。</br>建议您将浏览器升级至最新版本,以获最好的体验。<br><span style="font-size:0.8em">获知更多webgl浏览器信息请<a href="webglInfo.html" style="color: #a6ccea;">点击此处</a></span>', this),
  5989. !1)
  5990. },
  5991. W.prototype.allocBacking = function () {
  5992. var e = this.gl,
  5993. t = !1,
  5994. i = {
  5995. width: this.canvas.width,
  5996. height: this.canvas.height
  5997. };
  5998. for (this.mainColor = new U(e, i),
  5999. this.mainDepth = null,
  6000. e.ext.textureDepth && (this.mainDepth = new U(e, {
  6001. width: this.canvas.width,
  6002. height: this.canvas.height,
  6003. nofilter: !0
  6004. }),
  6005. this.mainDepth.loadArray(null, e.DEPTH_COMPONENT, e.UNSIGNED_INT)),
  6006. e.ext.textureHalf && e.ext.textureHalfLinear && (this.mainColor.loadArray(null, e.RGBA, e.ext.textureHalf.HALF_FLOAT_OES),
  6007. this.mainBuffer = new m(e, {
  6008. color0: this.mainColor,
  6009. depth: this.mainDepth,
  6010. createDepth: !this.mainDepth
  6011. }),
  6012. t = this.mainBuffer.valid),
  6013. !t && e.ext.textureFloat && e.ext.textureFloatLinear && !e.hints.mobile && (this.mainColor.loadArray(null, e.RGBA, e.FLOAT),
  6014. this.mainBuffer = new m(e, {
  6015. color0: this.mainColor,
  6016. depth: this.mainDepth,
  6017. createDepth: !this.mainDepth
  6018. }),
  6019. t = this.mainBuffer.valid); !t;)
  6020. this.mainColor = new U(e, i),
  6021. this.mainColor.loadArray(null, e.RGBA, e.UNSIGNED_BYTE),
  6022. this.mainBuffer = new m(e, {
  6023. color0: this.mainColor,
  6024. depth: this.mainDepth,
  6025. createDepth: !this.mainDepth
  6026. }),
  6027. t = this.mainBuffer.valid,
  6028. i.width /= 2,
  6029. i.height /= 2,
  6030. this.mainDepth && (this.mainDepth.destroy(),
  6031. this.mainDepth = null);
  6032. this.mainBufferNoDepth = new m(e, {
  6033. color0: this.mainColor
  6034. })
  6035. },
  6036. W.prototype.loadScene = function (e) {
  6037. if (this.sceneURL = e || this.sceneURL,
  6038. this.scene = this.input = null,
  6039. this.initGL() && this.sceneURL) {
  6040. var t = this.ui.signalLoadProgress.bind(this.ui);
  6041. e = function (e) {
  6042. t(1, 1),
  6043. this.scene = new k(this.gl),
  6044. this.scene.stripData = this.stripData,
  6045. this.scene.load(new h(e)) ? this.scene.metaData.tbVersion <= 2070 ? this.ui.showFailure("模型文件版本过低", this) : (this.bindInput(),
  6046. this.requestFrame(this.updateLoad.bind(this)),
  6047. this.onLoad && this.onLoad()) : this.ui.showFailure("模型文件无法读取或无效", this)
  6048. }
  6049. .bind(this);
  6050. var i = function () {
  6051. this.ui.showFailure("模型文件 (" + this.sceneURL + ") 无法获取.", this)
  6052. }
  6053. .bind(this);
  6054. C.fetchBinary(this.sceneURL, e, i, t)
  6055. }
  6056. },
  6057. W.prototype.unload = function () {
  6058. delete this.scene,
  6059. delete this.input,
  6060. delete this.ui,
  6061. delete this.mainColor,
  6062. delete this.mainBuffer,
  6063. delete this.gl;
  6064. var e = this.domRoot.clientWidth,
  6065. t = this.domRoot.clientHeight;
  6066. this.initCanvas(e, t),
  6067. this.ui = new j(this),
  6068. this.ui.setSize(e, t),
  6069. this.ui.showPreview(),
  6070. this.cancelFrame()
  6071. },
  6072. W.prototype.bindInput = function () {
  6073. this.input = new e(this.ui.container),
  6074. this.input.onDrag.push(function (e, t, i, s) {
  6075. e = 1 - 2.2 / (Math.sqrt(i * i + s * s) + 2.2),
  6076. (t = this.scene.view).rotation[1] -= .4 * i * e,
  6077. t.rotation[0] -= .4 * s * e,
  6078. t.rotation[0] = 90 < t.rotation[0] ? 90 : t.rotation[0],
  6079. t.rotation[0] = t.rotation[0] < -90 ? -90 : t.rotation[0],
  6080. t.updateView(),
  6081. this.wake()
  6082. }
  6083. .bind(this)),
  6084. this.input.onPan.push(function (e, t) {
  6085. var i = this.scene.view,
  6086. s = -e * (n = i.fov / 45 * .8 * (i.radius / this.domRoot.clientHeight)),
  6087. n = t * n;
  6088. i.pivot[0] += s * i.transform[0] + n * i.transform[4],
  6089. i.pivot[1] += s * i.transform[1] + n * i.transform[5],
  6090. i.pivot[2] += s * i.transform[2] + n * i.transform[6],
  6091. i.updateView(),
  6092. this.wake()
  6093. }
  6094. .bind(this)),
  6095. this.input.onPan2.push(function (e, t) {
  6096. var i = 1 - 2.2 / (Math.sqrt(e * e + t * t) + 2.2);
  6097. this.scene.lights.rotation -= .4 * e * i,
  6098. this.wake()
  6099. }
  6100. .bind(this)),
  6101. this.input.onZoom.push(function (e) {
  6102. rotInfo.stopWhenZoom && webview.stopRotate();
  6103. var t = this.scene.view;
  6104. t.radius *= 1 - .002 * e,
  6105. t.radius = t.radius < .001 ? .001 : t.radius,
  6106. t.radius = 1e3 < t.radius ? 1e3 : t.radius,
  6107. t.updateView(),
  6108. this.wake()
  6109. }
  6110. .bind(this)),
  6111. this.input.onDoubleTap.push(function (e, t) {
  6112. this.scene.view.reset(),
  6113. this.scene.sceneAnimator && this.scene.sceneAnimator.resetCustomView(),
  6114. this.wake()
  6115. }
  6116. .bind(this)),
  6117. this.ui.bindInput(this.input)
  6118. },
  6119. W.prototype.rotateWhenIdle = function () {
  6120. if (webview.rotate) return
  6121. rotInfo.radiusK && (webview.scene.view.radius = rotInfo.radiusK / (dom.id("fdageUI").clientWidth / dom.id("fdageUI").clientHeight)),
  6122. webview.scene.view.pivot = rotInfo.pivot.slice(),
  6123. webview.rotate = setInterval(function () {
  6124. webview.scene.view.rotation[1] -= rotInfo.speed,
  6125. webview.updateView(!0, !0, 1)
  6126. }, 16)
  6127. },
  6128. W.prototype.stopRotate = function (ifFinish) { //ifFinish是否不再自动旋转
  6129. if (webview.rotate) {
  6130. clearInterval(webview.rotate),
  6131. // console.log("clearInterval(webview.rotate)"),
  6132. webview.rotate = null,
  6133. ifFinish || (webview.countIdelTime = setTimeout(webview.rotateWhenIdle, rotInfo.idleTime))
  6134. } else {
  6135. if (webview.countIdelTime) {
  6136. clearTimeout(webview.countIdelTime),
  6137. // console.log("clearInterval(countIdelTime)"),
  6138. ifFinish || (webview.countIdelTime = setTimeout(webview.rotateWhenIdle, rotInfo.idleTime))
  6139. }
  6140. }
  6141. },
  6142. W.prototype.resetView = function (e) { //add
  6143. if (window.modelLoding) {
  6144. this.scene.view.reset()
  6145. this.wake()
  6146. }
  6147. },
  6148. W.prototype.zoomIn = function () { //add 放大
  6149. if (window.modelLoding) this.input.onZoom[0](130); //放大会比缩小快一些,所以降低数值
  6150. }
  6151. W.prototype.zoomOut = function () { //add 缩小
  6152. if (window.modelLoding) this.input.onZoom[0](-150);
  6153. }
  6154. W.prototype.wake = function (e) {
  6155. e = e || 16,
  6156. this.sleepCounter = this.sleepCounter < e ? e : this.sleepCounter,
  6157. this.scene.postRender.discardAAHistory(),
  6158. this.requestFrame(this.update.bind(this))
  6159. },
  6160. W.prototype.requestFrame = function (e) {
  6161. var t = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
  6162. if (!this.frameRequestPending) {
  6163. var i = function () {
  6164. this.frameRequestPending = 0,
  6165. e()
  6166. }
  6167. .bind(this);
  6168. this.frameRequestPending = t(i, this.canvas)
  6169. }
  6170. },
  6171. W.prototype.cancelFrame = function () {
  6172. this.frameRequestPending && (window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame)(this.frameRequestPending)
  6173. },
  6174. W.prototype.fullscreenChange = function () {
  6175. g.active() ? (this.oldRootWidth = this.domRoot.style.width,
  6176. this.oldRootHeight = this.domRoot.style.height,
  6177. this.domRoot.style.width = "100%",
  6178. this.domRoot.style.height = "100%") : (this.domRoot.style.width = this.oldRootWidth,
  6179. this.domRoot.style.height = this.oldRootHeight),
  6180. this.wake()
  6181. },
  6182. W.prototype.resize = function (e, t) {
  6183. e && t ? (this.domRoot.style.width = e + "px",
  6184. this.domRoot.style.height = t + "px") : (e = this.domRoot.clientWidth,
  6185. t = this.domRoot.clientHeight),
  6186. this.canvas.width = e * this.pixelRatio,
  6187. this.canvas.height = t * this.pixelRatio,
  6188. this.canvas.style.width = e + "px",
  6189. this.canvas.style.height = t + "px",
  6190. this.ui.setSize(e, t),
  6191. this.allocBacking(),
  6192. this.wake()
  6193. },
  6194. W.prototype.updateLoad = function () {
  6195. this.scene.complete() ? this.start() : this.requestFrame(this.updateLoad.bind(this)),
  6196. this.ui.animate()
  6197. },
  6198. W.prototype.start = function () {
  6199. // console.log('模型加载完成');
  6200. window.modelLoding = true
  6201. this.scene.view.updateView(),
  6202. this.ui.showActiveView(),
  6203. this.requestFrame(this.update.bind(this)),
  6204. window.autoRotate && this.rotateWhenIdle(),
  6205. document.documentElement.style.height = "100%",
  6206. document.documentElement.style.width = "100%",
  6207. document.documentElement.style.margin = "0",
  6208. document.documentElement.style.padding = "0",
  6209. document.body.style.height = "100%",
  6210. document.body.style.width = "100%",
  6211. document.body.style.margin = "0",
  6212. document.body.style.padding = "0"
  6213. },
  6214. W.prototype.update = function () {
  6215. var e = this.scene.sceneAnimator && !this.scene.sceneAnimator.paused;
  6216. (0 < this.sleepCounter || this.ui.animating() || e || this.stripData.animationActive) && (this.stripData.update(),
  6217. this.ui.animate(),
  6218. this.scene.update(),
  6219. this.drawScene(),
  6220. this.requestFrame(this.update.bind(this))),
  6221. e ? this.scene.postRender.discardAAHistory() : this.sleepCounter--
  6222. },
  6223. W.prototype.reDrawScene = function () {
  6224. this.stripData.update(),
  6225. this.ui.animate(),
  6226. this.scene.update(),
  6227. this.drawScene(),
  6228. this.requestFrame(this.update.bind(this)),
  6229. this.scene.postRender.discardAAHistory()
  6230. },
  6231. W.prototype.drawScene = function () {
  6232. this.gl.isContextLost() || (this.domRoot.clientWidth == this.canvas.clientWidth && this.domRoot.clientHeight == this.canvas.clientHeight || this.resize(),
  6233. this.scene.view.size = [this.mainBuffer.width, this.mainBuffer.height],
  6234. this.scene.view.updateProjection(),
  6235. this.scene.postRender.adjustProjectionForSupersampling(this.scene.view),
  6236. this.scene.collectShadows(this.mainBuffer),
  6237. this.mainBuffer.bind(),
  6238. this.scene.draw(this.mainBuffer),
  6239. this.mainDepth && (this.mainBufferNoDepth.bind(),
  6240. this.scene.drawSecondary(this.mainDepth)),
  6241. this.scene.postRender.present(this.mainColor, this.canvas.width, this.canvas.height, this.stripData.active()))
  6242. },
  6243. W.prototype.updateView = function (e, t, i) {
  6244. t && webview.scene.view.updateView(),
  6245. webview.wake(i || 4),
  6246. e && webview.scene.postRender.discardAAHistory()
  6247. },
  6248. (I = void 0 === I ? {} : I).WebViewer = W,
  6249. I.dataLocale = "images/";
  6250. var G = {
  6251. "alphaprepassfrag.glsl": "precision mediump float;\n#include <matdither.glsl>\nuniform sampler2D tAlbedo;varying mediump vec2 d;void main(){float e=texture2D(tAlbedo,d).a;if(e<=f(d.x)){discard;}gl_FragColor=vec4(0.0);}",
  6252. "alphaprepassvert.glsl": "precision highp float;uniform mat4 uModelViewProjectionMatrix;uniform vec2 uUVOffset;attribute vec3 vPosition;attribute vec2 vTexCoord;varying mediump vec2 d;vec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}void main(void){gl_Position=h(uModelViewProjectionMatrix,vPosition.xyz);d=vTexCoord+uUVOffset;}",
  6253. "bloom.glsl": "precision mediump float;uniform sampler2D tInput;uniform vec4 uKernel[BLOOM_SAMPLES];varying highp vec2 j;void main(void){vec3 c=vec3(0.0,0.0,0.0);for(int k=0;k<BLOOM_SAMPLES;++k){vec3 l=uKernel[k].xyz;vec3 m=texture2D(tInput,j+l.xy).xyz;m=max(m,vec3(0.0,0.0,0.0));c+=m*l.z;}gl_FragColor.xyz=c;gl_FragColor.w=0.0;}",
  6254. "bloomshrink.glsl": "precision highp float;uniform sampler2D tInput;varying highp vec2 j;void main(void){float o=0.25/256.0;gl_FragColor=0.25*(texture2D(tInput,j+vec2(o,o))+texture2D(tInput,j+vec2(o,-o))+texture2D(tInput,j+vec2(-o,o))+texture2D(tInput,j+vec2(-o,-o)));}",
  6255. "fogfrag.glsl": "precision highp float;uniform sampler2D tDepth;uniform vec3 uDepthToZ;uniform vec4 uUnproject;uniform mat4 uInvViewMatrix;uniform float uFogInvDistance;uniform float uFogOpacity;uniform float uFogDispersion;uniform vec3 uFogType;uniform vec3 uFogColor;uniform float uFogIllum;uniform mat4 uLightMatrix;\n#ifdef FOG_IBL\nuniform vec4 uFogLightSphere[9];\n#else\nuniform vec4 uSpotParams;uniform vec4 uLightPosition;uniform vec3 uLightColor;uniform vec4 uLightAttenuation;\n#ifdef FOG_SHADOWS\nuniform mat4 uShadowProj;uniform sampler2D uShadowMap;uniform float uDitherOffset;uniform vec4 uCylinder;\n#endif\n#endif\nvec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}vec3 u(mat4 i,vec3 v){return i[0].xyz*v.x+i[1].xyz*v.y+i[2].xyz*v.z;}float A(float B){B*=uFogInvDistance;float C=uFogType.x*min(B,1.0)+(uFogType.y-uFogType.y/(1.0+16.0*B*B))+(uFogType.z-uFogType.z*exp(-3.0*B));return C*uFogOpacity;}\n#ifdef FOG_SHADOWS\nfloat D(vec3 E){vec4 p=h(uShadowProj,E);vec3 F=p.xyz/p.w;vec4 G=texture2D(uShadowMap,F.xy);float H=(G.x+G.y*(1.0/255.0))+G.z*(1.0/65025.0);return F.z<H || H>=1.0?1.0:0.0;}float f(vec2 I){return fract(sin(dot(I,vec2(12.9898,78.233)))*43758.5453+uDitherOffset);}void J(vec3 K,vec3 L,out float M,out float N){vec3 v=uSpotParams.xyz,p=uCylinder.xyz;vec3 O=L-dot(L,v)*v;vec3 P=(K-p)-dot(K-p,v)*v;float a=dot(O,O);float b=2.0*dot(O,P);float c=dot(P,P)-uCylinder.w;float Q=b*b-4.0*a*c;if(Q>=0.0){Q=sqrt(Q);M=(-b-Q)/(2.0*a);N=(-b+Q)/(2.0*a);}else {M=N=0.0;}}\n#endif\nvarying vec2 j;void main(void){vec3 R=uInvViewMatrix[3].xyz;float H=texture2D(tDepth,j).x;H=min(H,0.9999);vec3 S;S.z=uDepthToZ.y/(uDepthToZ.z*H+uDepthToZ.x);S.xy=S.z*(j*uUnproject.xy+uUnproject.zw);S=h(uInvViewMatrix,S).xyz;vec3 T;T.xy=(j*uUnproject.xy+uUnproject.zw);T.z=1.0;T=normalize(u(uInvViewMatrix,-T).xyz);vec3 U=uFogColor;\n#if defined(FOG_IBL)\nvec3 G=u(uLightMatrix,T);vec3 V=uFogLightSphere[0].xyz;V+=uFogLightSphere[1].xyz*G.y;V+=uFogLightSphere[2].xyz*G.z;V+=uFogLightSphere[3].xyz*G.x;vec3 swz=G.yyz*G.xzx;V+=uFogLightSphere[4].xyz*swz.x;V+=uFogLightSphere[5].xyz*swz.y;V+=uFogLightSphere[7].xyz*swz.z;vec3 sqr=G*G;V+=uFogLightSphere[6].xyz*(3.0*sqr.z-1.0);V+=uFogLightSphere[8].xyz*(sqr.x-sqr.y);U=mix(U,U*V,uFogIllum);float C=A(length(S-R));gl_FragColor.xyz=U*C;gl_FragColor.w=C;return;\n#else\n#if defined(FOG_SPOT) || defined(FOG_OMNI)\nfloat W=0.0,X=0.0;{float r=1.0/(uLightAttenuation.z);float a=1.0;float b=2.0*dot(T,R-uLightPosition.xyz);float c=dot(uLightPosition.xyz,uLightPosition.xyz)+dot(R,R)+-2.0*dot(uLightPosition.xyz,R)+-r*r;float Q=b*b-4.0*a*c;if(Q>=0.0){Q=sqrt(Q);W=(-b-Q)/(2.0*a);X=(-b+Q)/(2.0*a);}}\n#if defined(FOG_SPOT)\n{float Y=uSpotParams.w,Z=1.0-Y;vec3 v=T;vec3 dc=uSpotParams.xyz;vec3 dd=R-uLightPosition.xyz;vec3 de=v-dot(v,dc)*dc,df=dd-dot(dd,dc)*dc;float a=Y*dot(de,de)-Z*dot(v,dc)*dot(v,dc);float b=2.0*Y*dot(de,df)-2.0*Z*dot(v,dc)*dot(dd,dc);float c=Y*dot(df,df)-Z*dot(dd,dc)*dot(dd,dc);float Q=b*b-4.0*a*c;if(Q>=0.0){float dh=(-b-sqrt(Q))/(2.0*a);float di=(-b+sqrt(Q))/(2.0*a);if(di<dh){float de=dh;dh=di;di=de;}bool dj=dot(-uLightPosition.xyz+R+T*dh,uSpotParams.xyz)<=0.0;bool dk=dot(-uLightPosition.xyz+R+T*di,uSpotParams.xyz)<=0.0;if(!dj ||!dk){if(dj){dh=di;di=X;}else if(dk){di=dh;dh=W;}W=max(W,dh);X=min(X,di);}else {X=W=0.0;}}else {X=W=0.0;}}\n#endif\nfloat tx=dot(T,S-R);W=clamp(W,0.0,tx);X=clamp(X,0.0,tx);float dl=0.0;if(X>W){\n#ifdef FOG_SHADOWS\n#ifdef MOBILE\n#define SAMPLES 16\n#else\n#define SAMPLES 32\n#endif\nfloat dm=f(j)*(X-W)/float(SAMPLES-2);\n#else\n#define SAMPLES 8\nfloat dm=0.0;\n#endif\nfor(int k=0;k<SAMPLES;++k){float t=W+(X-W)*float(k)/float(SAMPLES-1);vec3 p=R+(t+dm)*T;float a=clamp(length(p-uLightPosition.xyz)*uLightAttenuation.z,0.0,1.0);a=1.0+uLightAttenuation.x*a+uLightAttenuation.y*a*a;\n#ifdef FOG_SHADOWS\na*=D(p);\n#endif\ndl+=a-a*A(t);}dl*=1.0/float(SAMPLES);dl*=(X-W)*uLightAttenuation.z;dl*=A(X-W);}U*=dl*uFogIllum;\n#elif defined(FOG_DIR)\nfloat C=A(dot(T,S-R));\n#ifdef FOG_SHADOWS\nfloat W,X;J(R,T,W,X);float tx=dot(T,S-R);W=clamp(W,0.0,tx);X=clamp(X,0.0,tx);if(X>W){\n#ifdef MOBILE\n#define SAMPLES 16\n#else\n#define SAMPLES 32\n#endif\nfloat dl=0.0;float dm=f(j)*(X-W)/float(SAMPLES-2);float dn=(X-W)*(1.0/float(SAMPLES));for(int k=0;k<SAMPLES;++k){float t=W+float(k)*dn+dm;vec3 p=R+t*T;float s=D(p);C-=(1.0-s)*(A(t+dn)-A(t));}}\n#endif\nfloat du=0.5+0.5*dot(T,-uSpotParams.xyz);du=1.0+uFogDispersion*(2.0*du*du-1.0);U*=(0.1*C)*(du*uFogIllum);\n#endif\ngl_FragColor.xyz=U*uLightColor;gl_FragColor.w=0.0;\n#endif\n}",
  6256. "fogvert.glsl": "precision highp float;attribute vec2 vCoord;varying vec2 j;void main(void){j=vCoord;gl_Position.xy=2.0*vCoord-vec2(1.0,1.0);gl_Position.zw=vec2(0.0,1.0);}",
  6257. "matdither.glsl": "float f(highp float I){highp float G=0.5*fract(gl_FragCoord.x*0.5)+0.5*fract(gl_FragCoord.y*0.5);return 0.4+0.6*fract(G+3.141592e6*I);}",
  6258. "matfrag.glsl": "\n#extension GL_OES_standard_derivatives : enable\nprecision mediump float;varying highp vec3 dv;varying mediump vec2 d;varying mediump vec3 dA;varying mediump vec3 dB;varying mediump vec3 dC;\n#ifdef VERTEX_COLOR\nvarying lowp vec4 dD;\n#endif\n#ifdef TEXCOORD_SECONDARY\nvarying mediump vec2 dE;\n#endif\nuniform sampler2D tAlbedo;uniform sampler2D tReflectivity;uniform sampler2D tNormal;uniform sampler2D tExtras;uniform sampler2D tSkySpecular;\n#ifdef REFRACTION\nuniform sampler2D tRefraction;\n#endif\nuniform vec4 uDiffuseCoefficients[9];uniform vec3 uCameraPosition;uniform float uAlphaTest;uniform vec3 uFresnel;uniform float uHorizonOcclude;uniform float uHorizonSmoothing;\n#ifdef EMISSIVE\nuniform float uEmissiveScale;uniform vec4 uTexRangeEmissive;\n#endif\n#ifdef AMBIENT_OCCLUSION\nuniform vec4 uTexRangeAO;\n#endif\n#ifdef REFRACTION\nuniform float uRefractionIOREntry;uniform float uRefractionRayDistance;uniform vec3 uRefractionTint;uniform float uRefractionAlbedoTint;uniform mat4 uRefractionViewProjection;uniform vec4 uTexRangeRefraction;\n#endif\n#ifdef LIGHT_COUNT\nuniform vec4 uLightPositions[LIGHT_COUNT];uniform vec3 uLightDirections[LIGHT_COUNT];uniform vec3 uLightColors[LIGHT_COUNT];uniform vec3 uLightParams[LIGHT_COUNT];uniform vec3 uLightSpot[LIGHT_COUNT];\n#endif\n#ifdef ANISO\nuniform float uAnisoStrength;uniform vec3 uAnisoTangent;uniform float uAnisoIntegral;uniform vec4 uTexRangeAniso;\n#endif\n#define saturate(x) clamp( x, 0.0, 1.0 )\n#include <matsampling.glsl>\n#include <matlighting.glsl>\n#include <matshadows.glsl>\n#include <matskin.glsl>\n#include <matmicrofiber.glsl>\n#include <matstrips.glsl>\n#ifdef TRANSPARENCY_DITHER\n#include <matdither.glsl>\n#endif\nvoid main(void){vec4 m=texture2D(tAlbedo,d);vec3 dF=dG(m.xyz);float e=m.w;\n#ifdef VERTEX_COLOR\n{vec3 dH=dD.xyz;\n#ifdef VERTEX_COLOR_SRGB\ndH=dH*(dH*(dH*0.305306011+vec3(0.682171111))+vec3(0.012522878));\n#endif\ndF*=dH;\n#ifdef VERTEX_COLOR_ALPHA\ne*=dD.w;\n#endif\n}\n#endif\n#ifdef ALPHA_TEST\nif(e<uAlphaTest){discard;}\n#endif\n#ifdef TRANSPARENCY_DITHER\ne=(e>f(d.x))?1.0:e;\n#endif\nvec3 dI=dJ(texture2D(tNormal,d).xyz);\n#ifdef ANISO\n#ifdef ANISO_NO_DIR_TEX\nvec3 dK=dL(uAnisoTangent);\n#else\nm=dM(d,uTexRangeAniso);vec3 dK=2.0*m.xyz-vec3(1.0);dK=dL(dK);\n#endif\ndK=dK-dI*dot(dK,dI);dK=normalize(dK);vec3 dN=dK*uAnisoStrength;\n#endif\nvec3 dO=normalize(uCameraPosition-dv);m=texture2D(tReflectivity,d);vec3 dP=dG(m.xyz);float dQ=m.w;float dR=dQ;\n#ifdef HORIZON_SMOOTHING\nfloat dS=dot(dO,dI);dS=uHorizonSmoothing-dS*uHorizonSmoothing;dQ=mix(dQ,1.0,dS*dS);\n#endif\n#ifdef STRIPVIEW\ndT dU;dV(dU,dQ,dP);\n#endif\nfloat dW=1.0;\n#ifdef AMBIENT_OCCLUSION\n#ifdef AMBIENT_OCCLUSION_SECONDARY_UV\ndW=dM(dE,uTexRangeAO).x;\n#else\ndW=dM(d,uTexRangeAO).x;\n#endif\ndW*=dW;\n#endif\n#if defined(SKIN)\ndX dY;dZ(dY);dY.ec*=dW;\n#elif defined(MICROFIBER)\ned ee;ef(ee,dI);ee.eh*=dW;\n#else\nvec3 ei=ej(dI);ei*=dW;\n#endif\nvec3 ek=reflect(-dO,dI);\n#ifdef ANISO\nvec3 rt=ek-(0.5*dN*dot(ek,dK));vec3 el=em(rt,mix(dQ,0.5*dQ,uAnisoStrength));\n#else\nvec3 el=em(ek,dQ);\n#endif\nel*=en(ek,dC);\n#ifdef LIGHT_COUNT\nhighp float eo=10.0/log2(dQ*0.968+0.03);eo*=eo;float eu=eo*(1.0/(8.0*3.1415926))+(4.0/(8.0*3.1415926));eu=min(eu,1.0e3);\n#ifdef SHADOW_COUNT\nev eA;\n#ifdef SKIN\n#ifdef SKIN_VERSION_1\neB(eA,SHADOW_KERNEL+SHADOW_KERNEL*dY.eC);\n#else\neD eE;float eF=SHADOW_KERNEL+SHADOW_KERNEL*dY.eC;eG(eE,eF);eB(eA,eF);\n#endif\n#else\neB(eA,SHADOW_KERNEL);\n#endif\n#endif\n#ifdef ANISO\neu*=uAnisoIntegral;\n#endif\nfor(int k=0;k<LIGHT_COUNT;++k){vec3 eH=uLightPositions[k].xyz-dv*uLightPositions[k].w;float eI=inversesqrt(dot(eH,eH));eH*=eI;float a=saturate(uLightParams[k].z/eI);a=1.0+a*(uLightParams[k].x+uLightParams[k].y*a);float s=saturate(dot(eH,uLightDirections[k]));s=saturate(uLightSpot[k].y-uLightSpot[k].z*(1.0-s*s));vec3 eJ=(a*s)*uLightColors[k].xyz;\n#if defined(SKIN)\n#ifdef SHADOW_COUNT\n#ifdef SKIN_VERSION_1\neK(dY,eA.eL[k],1.0,eH,dI,eJ);\n#else\neK(dY,eA.eL[k],eE.eE[k],eH,dI,eJ);\n#endif\n#else\neK(dY,1.0,0.0,eH,dI,eJ);\n#endif\n#elif defined(MICROFIBER)\n#ifdef SHADOW_COUNT\neM(ee,eA.eL[k],eH,dI,eJ);\n#else\neM(ee,1.0,eH,dI,eJ);\n#endif\n#else\nfloat eN=saturate((1.0/3.1415926)*dot(eH,dI));\n#ifdef SHADOW_COUNT\neN*=eA.eL[k];\n#endif\nei+=eN*eJ;\n#endif\nvec3 eO=eH+dO;\n#ifdef ANISO\neO=eO-(dN*dot(eO,dK));\n#endif\neO=normalize(eO);float eP=eu*pow(saturate(dot(eO,dI)),eo);\n#ifdef SHADOW_COUNT\neP*=eA.eL[k];\n#endif\nel+=eP*eJ;}\n#endif\n#if defined(SKIN)\nvec3 ei,diff_extra;eQ(ei,diff_extra,dY,dO,dI,dQ);\n#elif defined(MICROFIBER)\nvec3 ei,diff_extra;eR(ei,diff_extra,ee,dO,dI,dQ);\n#endif\nvec3 eS=eT(dO,dI,dP,dQ*dQ);el*=eS;\n#ifdef REFRACTION\nvec4 eU;{vec3 G=refract(-dO,dI,uRefractionIOREntry);G=dv+G*uRefractionRayDistance;vec4 eV=uRefractionViewProjection[0]*G.x+(uRefractionViewProjection[1]*G.y+(uRefractionViewProjection[2]*G.z+uRefractionViewProjection[3]));vec2 c=eV.xy/eV.w;c=0.5*c+vec2(0.5,0.5);vec2 i=mod(floor(c),2.0);c=fract(c);c.x=i.x>0.0?1.0-c.x:c.x;c.y=i.y>0.0?1.0-c.y:c.y;eU.rgb=texture2D(tRefraction,c).xyz;eU.rgb=mix(eU.rgb,eU.rgb*dF,uRefractionAlbedoTint);eU.rgb=eU.rgb-eU.rgb*eS;eU.rgb*=uRefractionTint;\n#ifdef REFRACTION_NO_MASK_TEX\neU.a=1.0;\n#else\neU.a=dM(d,uTexRangeRefraction).x;\n#endif\n}\n#endif\n#ifdef DIFFUSE_UNLIT\ngl_FragColor.xyz=dF;\n#else\ngl_FragColor.xyz=ei*dF;\n#endif\n#ifdef REFRACTION\ngl_FragColor.xyz=mix(gl_FragColor.xyz,eU.rgb,eU.a);\n#endif\ngl_FragColor.xyz+=el;\n#if defined(SKIN) || defined(MICROFIBER)\ngl_FragColor.xyz+=diff_extra;\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVE_SECONDARY_UV\nvec2 eW=dE;\n#else\nvec2 eW=d;\n#endif\ngl_FragColor.xyz+=uEmissiveScale*dG(dM(eW,uTexRangeEmissive).xyz);\n#endif\n#ifdef STRIPVIEW\ngl_FragColor.xyz=eX(dU,dI,dF,dP,dR,ei,el,gl_FragColor.xyz);\n#endif\n#ifdef NOBLEND\ngl_FragColor.w=1.0;\n#else\ngl_FragColor.w=e;\n#endif\n}",
  6259. "matlighting.glsl": "vec3 eY(vec3 eZ,float fc){return exp(-0.5*fc/(eZ*eZ))/(eZ*2.5066283);}vec3 fd(vec3 eZ){return vec3(1.0,1.0,1.0)/(eZ*2.5066283);}vec3 fe(vec3 ff){return vec3(-0.5,-0.5,-0.5)/(ff);}vec3 fh(vec3 fi,float fc){return exp(fi*fc);}\n#define SAMPLE_COUNT 21.0\n#define SAMPLE_HALF 10.0\n#define GAUSS_SPREAD 0.05\nvec3 fj(float fk,float fl,vec3 fm){vec3 fn=vec3(fl,fl,fl);fn=0.8*fn+vec3(0.2);vec3 fo=cos(fn*3.14159);vec3 fu=cos(fn*3.14159*0.5);fu*=fu;fu*=fu;fu*=fu;fn=fn+0.05*fo*fu*fm;fu*=fu;fu*=fu;fu*=fu;fn=fn+0.1*fo*fu*fm;fn=saturate(fn);fn*=fn*1.2;return fn;}vec3 fv(vec3 fm){return vec3(1.0,1.0,1.0)/3.1415926;}float fA(float fk,float fm){return saturate(-fk*fm+fk+fm);}vec3 fB(float fk,vec3 fm){return saturate(-fk*fm+vec3(fk)+fm);}float fC(float fm){return-0.31830988618379*fm+0.31830988618379;}vec3 fD(vec3 fm){return-0.31830988618379*fm+vec3(0.31830988618379);}vec3 eT(vec3 dO,vec3 dI,vec3 dP,float fE){float C=1.0-saturate(dot(dO,dI));float fF=C*C;C*=fF*fF;C*=fE;return(dP-C*dP)+C*uFresnel;}vec2 fG(vec2 fH,vec2 fm){fH=1.0-fH;vec2 fI=fH*fH;fI*=fI;fH=mix(fI,fH*0.4,fm);return fH;}vec3 ej(vec3 fJ){\n#define c(n) uDiffuseCoefficients[n].xyz\nvec3 G=(c(0)+fJ.y*((c(1)+c(4)*fJ.x)+c(5)*fJ.z))+fJ.x*(c(3)+c(7)*fJ.z)+c(2)*fJ.z;\n#undef c\nvec3 sqr=fJ*fJ;G+=uDiffuseCoefficients[6].xyz*(3.0*sqr.z-1.0);G+=uDiffuseCoefficients[8].xyz*(sqr.x-sqr.y);return G;}void fK(inout vec3 fL,inout vec3 fM,inout vec3 fN,vec3 fJ){fL=uDiffuseCoefficients[0].xyz;fM=uDiffuseCoefficients[1].xyz*fJ.y;fM+=uDiffuseCoefficients[2].xyz*fJ.z;fM+=uDiffuseCoefficients[3].xyz*fJ.x;vec3 swz=fJ.yyz*fJ.xzx;fN=uDiffuseCoefficients[4].xyz*swz.x;fN+=uDiffuseCoefficients[5].xyz*swz.y;fN+=uDiffuseCoefficients[7].xyz*swz.z;vec3 sqr=fJ*fJ;fN+=uDiffuseCoefficients[6].xyz*(3.0*sqr.z-1.0);fN+=uDiffuseCoefficients[8].xyz*(sqr.x-sqr.y);}vec3 fO(vec3 fL,vec3 fM,vec3 fN,vec3 fP,float fm){fP=mix(vec3(1.0),fP,fm);return(fL+fM*fP.x)+fN*fP.z;}vec3 fQ(vec3 fL,vec3 fM,vec3 fN,vec3 fP,vec3 fR){vec3 fS=mix(vec3(1.0),fP.yyy,fR);vec3 fT=mix(vec3(1.0),fP.zzz,fR);return(fL+fM*fS)+fN*fT;}vec3 em(vec3 fJ,float dQ){fJ/=dot(vec3(1.0),abs(fJ));vec2 fU=abs(fJ.zx)-vec2(1.0,1.0);vec2 fV=vec2(fJ.x<0.0?fU.x:-fU.x,fJ.z<0.0?fU.y:-fU.y);vec2 fW=(fJ.y<0.0)?fV:fJ.xz;fW=vec2(0.5*(254.0/256.0),0.125*0.5*(254.0/256.0))*fW+vec2(0.5,0.125*0.5);float fX=fract(7.0*dQ);fW.y+=0.125*(7.0*dQ-fX);vec2 fY=fW+vec2(0.0,0.125);vec4 fZ=mix(texture2D(tSkySpecular,fW),texture2D(tSkySpecular,fY),fX);vec3 r=fZ.xyz*(7.0*fZ.w);return r*r;}float en(vec3 fJ,vec3 hc){float hd=dot(fJ,hc);hd=saturate(1.0+uHorizonOcclude*hd);return hd*hd;}",
  6260. "matmicrofiber.glsl": "\n#ifdef MICROFIBER\nuniform vec4 uTexRangeFuzz;uniform vec4 uFresnelColor;uniform float uFresnelIntegral;uniform float uFresnelOcc;uniform float uFresnelGlossMask;struct ed{vec3 eh;vec3 eN;vec3 he;vec3 hf;vec3 hh;};void ef(out ed s,vec3 dI){s.eh=s.eN=ej(dI);s.he=vec3(0.0);s.hf=uFresnelColor.rgb;s.hh=uFresnelColor.aaa*vec3(1.0,0.5,0.25);\n#ifndef MICROFIBER_NO_FUZZ_TEX\nvec4 m=dM(d,uTexRangeFuzz);s.hf*=dG(m.rgb);\n#endif\n}void eM(inout ed s,float hi,vec3 eH,vec3 dI,vec3 eJ){float fk=dot(eH,dI);float eN=saturate((1.0/3.1415926)*fk);float hj=fA(fk,s.hh.z);\n#ifdef SHADOW_COUNT\neN*=hi;float hk=mix(1.0,hi,uFresnelOcc);float he=hj*hk;\n#else \nfloat he=hj;\n#endif\ns.he=he*eJ+s.he;s.eN=eN*eJ+s.eN;}void eR(out vec3 ei,out vec3 diff_extra,inout ed s,vec3 dO,vec3 dI,float dQ){s.he*=uFresnelIntegral;float fH=dot(dO,dI);vec2 hl=fG(vec2(fH,fH),s.hh.xy);s.he=s.eh*hl.x+(s.he*hl.y);s.he*=s.hf;float hm=saturate(1.0+-uFresnelGlossMask*dQ);s.he*=hm*hm;ei=s.eN;diff_extra=s.he;}\n#endif\n",
  6261. "matsampling.glsl": "vec3 dG(vec3 c){return c*c;}vec3 dJ(vec3 n){vec3 hn=dA;vec3 ho=dB;vec3 hu=gl_FrontFacing?dC:-dC;\n#ifdef TSPACE_RENORMALIZE\nhu=normalize(hu);\n#endif\n#ifdef TSPACE_ORTHOGONALIZE\nhn-=dot(hn,hu)*hu;\n#endif\n#ifdef TSPACE_RENORMALIZE\nhn=normalize(hn);\n#endif\n#ifdef TSPACE_ORTHOGONALIZE\nho=(ho-dot(ho,hu)*hu)-dot(ho,hn)*hn;\n#endif\n#ifdef TSPACE_RENORMALIZE\nho=normalize(ho);\n#endif\n#ifdef TSPACE_COMPUTE_BITANGENT\nvec3 hv=cross(hu,hn);ho=dot(hv,ho)<0.0?-hv:hv;\n#endif\nn=2.0*n-vec3(1.0);return normalize(hn*n.x+ho*n.y+hu*n.z);}vec3 dL(vec3 t){vec3 hu=gl_FrontFacing?dC:-dC;return normalize(dA*t.x+dB*t.y+hu*t.z);}vec4 dM(vec2 hA,vec4 hB){\n#if GL_OES_standard_derivatives\nvec2 hC=fract(hA);vec2 hD=fwidth(hC);float hE=(hD.x+hD.y)>0.5?-6.0:0.0;return texture2D(tExtras,hC*hB.xy+hB.zw,hE);\n#else\nreturn texture2D(tExtras,fract(hA)*hB.xy+hB.zw);\n#endif\n}vec3 hF(sampler2D hG,vec2 hH,float hI){vec3 n=texture2D(hG,hH,hI*2.5).xyz;return dJ(n);}",
  6262. "matshadows.glsl": "\n#ifdef SHADOW_COUNT\n#ifdef MOBILE\n#define SHADOW_KERNEL (4.0/1536.0)\n#else\n#define SHADOW_KERNEL (4.0/2048.0)\n#endif\nhighp vec4 h(highp mat4 i,highp vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}uniform sampler2D tDepth0;\n#if SHADOW_COUNT > 1\nuniform sampler2D tDepth1;\n#if SHADOW_COUNT > 2\nuniform sampler2D tDepth2;\n#endif\n#endif\nuniform highp vec2 uShadowKernelRotation;uniform highp vec2 uShadowMapSize;uniform highp mat4 uShadowMatrices[SHADOW_COUNT];uniform highp vec4 uShadowTexelPadProjections[SHADOW_COUNT];\n#ifndef MOBILE\nuniform highp mat4 uInvShadowMatrices[SHADOW_COUNT];\n#endif\nhighp float hJ(highp vec3 G){\n#ifdef SHADOW_NATIVE_DEPTH\nreturn G.x;\n#else\nreturn(G.x+G.y*(1.0/255.0))+G.z*(1.0/65025.0);\n#endif\n}\n#ifndef SHADOW_COMPARE\n#define SHADOW_COMPARE(a,b) ((a) < (b) ? 1.0 : 0.0)\n#endif\n#ifndef SHADOW_CLIP\n#define SHADOW_CLIP(c,v) v\n#endif\nfloat hK(sampler2D hL,highp vec2 hA,highp float H){\n#ifndef MOBILE\nhighp vec2 c=hA*uShadowMapSize.x;highp vec2 a=floor(c)*uShadowMapSize.y,b=ceil(c)*uShadowMapSize.y;highp vec4 eE;eE.x=hJ(texture2D(hL,a).xyz);eE.y=hJ(texture2D(hL,vec2(b.x,a.y)).xyz);eE.z=hJ(texture2D(hL,vec2(a.x,b.y)).xyz);eE.w=hJ(texture2D(hL,b).xyz);highp vec4 hM;hM.x=SHADOW_COMPARE(H,eE.x);hM.y=SHADOW_COMPARE(H,eE.y);hM.z=SHADOW_COMPARE(H,eE.z);hM.w=SHADOW_COMPARE(H,eE.w);highp vec2 w=c-a*uShadowMapSize.x;vec2 s=(w.y*hM.zw+hM.xy)-w.y*hM.xy;return(w.x*s.y+s.x)-w.x*s.x;\n#else\nhighp float G=hJ(texture2D(hL,hA.xy).xyz);return SHADOW_COMPARE(H,G);\n#endif\n}highp float hN(sampler2D hL,highp vec3 hA,float hO){highp vec2 l=uShadowKernelRotation*hO;float s;s=hK(hL,hA.xy+l,hA.z);s+=hK(hL,hA.xy-l,hA.z);s+=hK(hL,hA.xy+vec2(-l.y,l.x),hA.z);s+=hK(hL,hA.xy+vec2(l.y,-l.x),hA.z);s*=0.25;return s*s;}struct ev{float eL[LIGHT_COUNT];};void eB(out ev ss,float hO){highp vec3 hP[SHADOW_COUNT];vec3 hu=gl_FrontFacing?dC:-dC;for(int k=0;k<SHADOW_COUNT;++k){vec4 hQ=uShadowTexelPadProjections[k];float hR=hQ.x*dv.x+(hQ.y*dv.y+(hQ.z*dv.z+hQ.w));\n#ifdef MOBILE\nhR*=.001+hO;\n#else\nhR*=.0005+0.5*hO;\n#endif\nhighp vec4 hS=h(uShadowMatrices[k],dv+hR*hu);hP[k]=hS.xyz/hS.w;}float m;\n#if SHADOW_COUNT > 0\nm=hN(tDepth0,hP[0],hO);ss.eL[0]=SHADOW_CLIP(hP[0].xy,m);\n#endif\n#if SHADOW_COUNT > 1\nm=hN(tDepth1,hP[1],hO);ss.eL[1]=SHADOW_CLIP(hP[1].xy,m);\n#endif\n#if SHADOW_COUNT > 2\nm=hN(tDepth2,hP[2],hO);ss.eL[2]=SHADOW_CLIP(hP[2].xy,m);\n#endif\nfor(int k=SHADOW_COUNT;k<LIGHT_COUNT;++k){ss.eL[k]=1.0;}}struct eD{highp float eE[LIGHT_COUNT];};\n#ifdef MOBILE\nvoid eG(out eD ss,float hO){for(int k=0;k<LIGHT_COUNT;++k){ss.eE[k]=1.0;}}\n#else\nhighp vec4 hT(sampler2D hL,highp vec2 hA,highp mat4 hU){highp vec4 E;E.xy=hA;\n#ifndef MOBILE\nhighp vec2 c=hA*uShadowMapSize.x;highp vec2 a=floor(c)*uShadowMapSize.y,b=ceil(c)*uShadowMapSize.y;highp vec4 hM;hM.x=hJ(texture2D(hL,a).xyz);hM.y=hJ(texture2D(hL,vec2(b.x,a.y)).xyz);hM.z=hJ(texture2D(hL,vec2(a.x,b.y)).xyz);hM.w=hJ(texture2D(hL,b).xyz);highp vec2 w=c-a*uShadowMapSize.x;vec2 s=(w.y*hM.zw+hM.xy)-w.y*hM.xy;E.z=(w.x*s.y+s.x)-w.x*s.x;\n#else \nE.z=hJ(texture2D(hL,hA.xy).xyz);\n#endif\nE=h(hU,E.xyz);E.xyz/=E.w;return E;}void eG(out eD ss,float hO){highp vec3 hV[SHADOW_COUNT];vec3 hu=gl_FrontFacing?dC:-dC;hu*=0.6;for(int k=0;k<SHADOW_COUNT;++k){vec4 hQ=uShadowTexelPadProjections[k];float hR=hQ.x*dv.x+(hQ.y*dv.y+(hQ.z*dv.z+hQ.w));\n#ifdef MOBILE\nhR*=.001+hO;\n#else\nhR*=.0005+0.5*hO;\n#endif\nhighp vec4 hS=h(uShadowMatrices[k],dv-hR*hu);hV[k]=hS.xyz/hS.w;}highp vec4 hW;\n#if SHADOW_COUNT > 0\nhW=hT(tDepth0,hV[0].xy,uInvShadowMatrices[0]);ss.eE[0]=length(dv.xyz-hW.xyz);\n#endif\n#if SHADOW_COUNT > 1\nhW=hT(tDepth1,hV[1].xy,uInvShadowMatrices[1]);ss.eE[1]=length(dv.xyz-hW.xyz);\n#endif\n#if SHADOW_COUNT > 2\nhW=hT(tDepth2,hV[2].xy,uInvShadowMatrices[2]);ss.eE[2]=length(dv.xyz-hW.xyz);\n#endif\nfor(int k=SHADOW_COUNT;k<LIGHT_COUNT;++k){ss.eE[k]=1.0;}}\n#endif\n#endif\n",
  6263. "matskin.glsl": "\n#ifdef SKIN\n#ifndef SKIN_NO_SUBDERMIS_TEX\nuniform vec4 uTexRangeSubdermis;\n#endif\n#ifndef SKIN_NO_TRANSLUCENCY_TEX\nuniform vec4 uTexRangeTranslucency;\n#endif\n#ifndef SKIN_NO_FUZZ_TEX\nuniform vec4 uTexRangeFuzz;\n#endif\nuniform vec4 uTransColor;uniform vec4 uFresnelColor;uniform vec3 uSubdermisColor;uniform float uTransScatter;uniform float uFresnelOcc;uniform float uFresnelGlossMask;uniform float uTransSky;uniform float uFresnelIntegral;uniform float uTransIntegral;uniform float uSkinTransDepth;uniform float uSkinShadowBlur;uniform float uNormalSmooth;struct dX{vec3 hX;vec3 hY,hZ,ic,he;vec3 ec,eh,id;vec3 ie;vec3 ih;vec3 ii;vec3 ij;float ik;float il;float im;float eC;};void dZ(out dX s){vec4 m;\n#ifdef SKIN_NO_SUBDERMIS_TEX\ns.hX=uSubdermisColor;s.im=1.0;\n#else \nm=dM(d,uTexRangeSubdermis);s.hX=dG(m.xyz);s.im=m.w*m.w;\n#endif\ns.ij=uTransColor.rgb;s.ik=uTransScatter;\n#ifdef SKIN_VERSION_1\ns.eC=uSkinShadowBlur*s.im;\n#else \ns.il=max(max(s.ij.r,s.ij.g),s.ij.b)*uTransColor.a;float io=max(s.hX.r,max(s.hX.g,s.hX.b));io=1.0-io;io*=io;io*=io;io*=io;io=1.0-(io*io);s.im*=io;s.eC=uSkinShadowBlur*s.im*dot(s.hX.rgb,vec3(0.333,0.334,0.333));\n#endif\n#ifndef SKIN_NO_TRANSLUCENCY_TEX\nm=dM(d,uTexRangeTranslucency);s.ij*=dG(m.xyz);\n#endif\ns.ie=hF(tNormal,d,uNormalSmooth*s.im);vec3 iu,iv,iA;fK(iu,iv,iA,s.ie);s.eh=s.hY=iu+iv+iA;\n#ifdef SKIN_VERSION_1 \ns.ec=fQ(iu,iv,iA,vec3(1.0,0.6667,0.25),s.hX);\n#else\ns.ec=fQ(iu,iv,iA,vec3(1.0,0.6667,0.25),s.hX*0.2+vec3(0.1));\n#endif\n#ifdef SKIN_VERSION_1\nvec3 iB,iC,iD;fK(iB,iC,iD,-s.ie);s.id=fO(iB,iC,iD,vec3(1.0,0.4444,0.0625),s.ik);s.id*=uTransSky;\n#else \ns.id=vec3(0.0);\n#endif\ns.hZ=s.ic=s.he=vec3(0.0);s.hX*=0.5;s.ik*=0.5;s.ih=uFresnelColor.rgb;s.ii=uFresnelColor.aaa*vec3(1.0,0.5,0.25);\n#ifndef SKIN_NO_FUZZ_TEX\nm=dM(d,uTexRangeFuzz);s.ih*=dG(m.rgb);\n#endif\n}void eK(inout dX s,float iE,float iF,vec3 eH,vec3 dI,vec3 eJ){float fk=dot(eH,dI);float fl=dot(eH,s.ie);float eN=saturate((1.0/3.1415926)*fk);float hi=iE*iE;hi*=hi;hi=saturate(6.0*hi);\n#ifdef SKIN_VERSION_1 \nvec3 iG=fB(fl,s.hX);\n#else \nvec3 iG=fj(fk,fl,s.hX);\n#endif\nfloat iH=fA(-fl,s.ik);vec3 ic=vec3(iH*iH);\n#ifdef SKIN_VERSION_1\n#ifdef SHADOW_COUNT\nvec3 iI=vec3(iE);float iJ=saturate(hi-2.0*(iE*iE));iI+=iJ*s.hX;float iK=iE;\n#endif\n#else\n#ifdef SHADOW_COUNT\nvec3 iI;highp vec3 iL=(0.995*s.hX)+vec3(0.005,0.005,0.005);highp vec3 iM=vec3(1.0)-iL;iL=mix(iL,iM,iE);float iN=sqrt(iE);vec3 iO=2.0*vec3(1.0-iN);iN=1.0-iN;iN=(1.0-iN*iN);iI=saturate(pow(iL*iN,iO));highp float iP=0.35/(uSkinTransDepth+0.001);highp float iQ=saturate(iF*iP);iQ=saturate(1.0-iQ);iQ*=iQ;highp vec3 iR=vec3((-3.0*iQ)+3.15);highp vec3 iS=(0.9975*s.ij)+vec3(0.0025,0.0025,0.0025);highp float io=saturate(10.0*dot(iS,iS));vec3 iK=pow(iS*iQ,iR)*io;\n#else \nic=vec3(0.0);\n#endif\n#endif\nfloat hj=fA(fl,s.ii.z);\n#ifdef SHADOW_COUNT\nvec3 hk=mix(vec3(1.0),iI,uFresnelOcc);vec3 he=hj*hk;\n#else\nvec3 he=vec3(hj);\n#endif\n#ifdef SHADOW_COUNT\niG*=iI;eN*=hi;ic*=iK;\n#endif\ns.he=he*eJ+s.he;s.ic=ic*eJ+s.ic;s.hZ=iG*eJ+s.hZ;s.hY=eN*eJ+s.hY;}void eQ(out vec3 ei,out vec3 diff_extra,inout dX s,vec3 dO,vec3 dI,float dQ){s.he*=uFresnelIntegral;float fH=dot(dO,dI);vec2 hl=fG(vec2(fH,fH),s.ii.xy);s.he=s.eh*hl.x+(s.he*hl.y);s.he*=s.ih;float hm=saturate(1.0+-uFresnelGlossMask*dQ);s.he*=hm*hm;s.ic=s.ic*uTransIntegral;\n#ifdef SKIN_VERSION_1\ns.hZ=(s.hZ*fD(s.hX))+s.ec;\n#else\ns.hZ=(s.hZ*fv(s.hX))+s.ec;\n#endif\nei=mix(s.hY,s.hZ,s.im);\n#ifdef SKIN_VERSION_1\ns.ic=(s.ic+s.id)*s.ij;diff_extra=(s.he+s.ic)*s.im;\n#else\nei+=s.ic*s.il;diff_extra=s.he*s.im;\n#endif\n}\n#endif\n",
  6264. "matstrips.glsl": "\n#ifdef STRIPVIEW\nuniform float uStrips[5];uniform vec2 uStripRes;struct dT{float io[5];float bg;};void dV(out dT iT,inout float dQ,inout vec3 dP){highp vec2 hA=gl_FragCoord.xy*uStripRes-vec2(1.0,1.0);hA.x+=0.25*hA.y;iT.io[0]=step(hA.x,uStrips[0]);iT.io[1]=step(hA.x,uStrips[1]);iT.io[2]=step(hA.x,uStrips[2]);iT.io[3]=step(hA.x,uStrips[3]);iT.io[4]=step(hA.x,uStrips[4]);iT.bg=1.0-iT.io[4];iT.io[4]-=iT.io[3];iT.io[3]-=iT.io[2];iT.io[2]-=iT.io[1];iT.io[1]-=iT.io[0];bool iU=iT.io[4]>0.0;dQ=iU?0.5:dQ;dP=iU?vec3(0.1):dP;}vec3 eX(dT iT,vec3 dI,vec3 dF,vec3 dP,float dQ,vec3 ei,vec3 el,vec3 iV){return iT.io[0]*(dI*0.5+vec3(0.5))+iT.io[1]*dF+iT.io[2]*dP+vec3(iT.io[3]*dQ)+iT.io[4]*(vec3(0.12)+0.3*ei+el)+iT.bg*iV;}\n#endif\n",
  6265. "matvert.glsl": "precision highp float;uniform mat4 uModelViewProjectionMatrix;uniform mat4 uSkyMatrix;uniform vec2 uUVOffset;attribute vec3 vPosition;attribute vec2 vTexCoord;attribute vec2 vTangent;attribute vec2 vBitangent;attribute vec2 vNormal;\n#ifdef VERTEX_COLOR\nattribute vec4 vColor;\n#endif\n#ifdef TEXCOORD_SECONDARY\nattribute vec2 vTexCoord2;\n#endif\nvarying highp vec3 dv;varying mediump vec2 d;varying mediump vec3 dA;varying mediump vec3 dB;varying mediump vec3 dC;\n#ifdef VERTEX_COLOR\nvarying lowp vec4 dD;\n#endif\n#ifdef TEXCOORD_SECONDARY\nvarying mediump vec2 dE;\n#endif\nvec3 iW(vec2 v){bool iX=(v.y>(32767.1/65535.0));v.y=iX?(v.y-(32768.0/65535.0)):v.y;vec3 r;r.xy=(2.0*65535.0/32767.0)*v-vec2(1.0);r.z=sqrt(clamp(1.0-dot(r.xy,r.xy),0.0,1.0));r.z=iX?-r.z:r.z;return r;}vec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}vec3 u(mat4 i,vec3 v){return i[0].xyz*v.x+i[1].xyz*v.y+i[2].xyz*v.z;}void main(void){gl_Position=h(uModelViewProjectionMatrix,vPosition.xyz);d=vTexCoord+uUVOffset;dA=u(uSkyMatrix,iW(vTangent));dB=u(uSkyMatrix,iW(vBitangent));dC=u(uSkyMatrix,iW(vNormal));dv=h(uSkyMatrix,vPosition.xyz).xyz;\n#ifdef VERTEX_COLOR\ndD=vColor;\n#endif\n#ifdef TEXCOORD_SECONDARY\ndE=vTexCoord2;\n#endif\n}",
  6266. "postaa.glsl": "precision mediump float;uniform sampler2D tInput;varying vec2 j;void main(void){gl_FragColor=texture2D(tInput,j);}",
  6267. "postfrag.glsl": "precision mediump float;uniform sampler2D tInput;\n#ifdef BLOOM\nuniform sampler2D tBloom;\n#endif\n#ifdef GRAIN\nuniform sampler2D tGrain;\n#endif\n#ifdef COLOR_LUT\nuniform sampler2D tLUT;\n#endif\nuniform vec3 uScale;uniform vec3 uBias;uniform vec3 uSaturation;uniform vec4 uSharpenKernel;uniform vec3 uSharpness;uniform vec3 uBloomColor;uniform vec4 uVignetteAspect;uniform vec4 uVignette;uniform vec4 uGrainCoord;uniform vec2 uGrainScaleBias;varying vec2 j;vec3 iY(vec3 c){vec3 iZ=sqrt(c);return(iZ-iZ*c)+c*(0.4672*c+vec3(0.5328));}void main(void){vec4 jc=texture2D(tInput,j);vec3 c=jc.xyz;\n#ifdef SHARPEN\nvec3 hM=texture2D(tInput,j+uSharpenKernel.xy).xyz;hM+=texture2D(tInput,j-uSharpenKernel.xy).xyz;hM+=texture2D(tInput,j+uSharpenKernel.zw).xyz;hM+=texture2D(tInput,j-uSharpenKernel.zw).xyz;vec3 jd=uSharpness.x*c-uSharpness.y*hM;c+=clamp(jd,-uSharpness.z,uSharpness.z);\n#endif\n#ifdef BLOOM\nc+=uBloomColor*texture2D(tBloom,j).xyz;\n#endif\n#ifdef VIGNETTE\nvec2 je=j*uVignetteAspect.xy-uVignetteAspect.zw;vec3 v=clamp(vec3(1.0,1.0,1.0)-uVignette.xyz*dot(je,je),0.0,1.0);vec3 jf=v*v;jf*=v;c*=mix(v,jf,uVignette.w);\n#endif\n#ifdef SATURATION\nfloat gray=dot(c,vec3(0.3,0.59,0.11));c=mix(vec3(gray,gray,gray),c,uSaturation);\n#endif\n#ifdef CONTRAST\nc=c*uScale+uBias;\n#endif\n#ifdef GRAIN\nfloat jh=uGrainScaleBias.x*texture2D(tGrain,j*uGrainCoord.xy+uGrainCoord.zw).x+uGrainScaleBias.y;c+=c*jh;\n#endif\n#ifdef REINHARD\n{c*=1.8;float ji=dot(c,vec3(0.3333));c=clamp(c/(1.0+ji),0.0,1.0);}\n#elif defined(HEJL)\n{const highp float jj=0.22,jk=0.3,jl=.1,jm=0.2,jn=.01,jo=0.3;const highp float ju=1.25;highp vec3 eO=max(vec3(0.0),c-vec3(.004));c=(eO*((ju*jj)*eO+ju*vec3(jl*jk,jl*jk,jl*jk))+ju*vec3(jm*jn,jm*jn,jm*jn))/(eO*(jj*eO+vec3(jk,jk,jk))+vec3(jm*jo,jm*jo,jm*jo))-ju*vec3(jn/jo,jn/jo,jn/jo);}\n#endif\n#ifdef COLOR_LUT\nc=clamp(c,0.0,1.0);c=(255.0/256.0)*c+vec3(0.5/256.0);c.x=texture2D(tLUT,c.xx).x;c.y=texture2D(tLUT,c.yy).y;c.z=texture2D(tLUT,c.zz).z;c*=c;\n#endif\ngl_FragColor.xyz=iY(c);gl_FragColor.w=jc.w;}",
  6268. "postvert.glsl": "precision highp float;attribute vec2 vCoord;varying vec2 j;void main(void){j=vCoord;gl_Position.xy=2.0*vCoord-vec2(1.0,1.0);gl_Position.zw=vec2(0.0,1.0);}",
  6269. "shadowfloorfrag.glsl": "precision mediump float;varying highp vec3 dv;varying mediump vec2 jv;varying mediump vec3 dC;uniform vec3 uShadowCatcherParams;\n#ifdef LIGHT_COUNT\nuniform vec4 uLightPositions[LIGHT_COUNT];uniform vec3 uLightDirections[LIGHT_COUNT];uniform vec3 uLightColors[LIGHT_COUNT];uniform vec3 uLightParams[LIGHT_COUNT];uniform vec3 uLightSpot[LIGHT_COUNT];\n#endif\n#define saturate(x) clamp( x, 0.0, 1.0 )\n#define SHADOW_COMPARE(a,b) ((a) < (b) || (b) >= 1.0 ? 1.0 : 0.0)\n#define SHADOW_CLIP(c,v) ((c.x<0.0 || c.x>1.0 || c.y<0.0 || c.y>1.0) ? 1.0 : v)\n#include <matshadows.glsl>\nvoid main(void){ev eA;eB(eA,SHADOW_KERNEL);vec3 jA=vec3(0.0,0.0,0.0);vec3 jB=vec3(0.0,0.0,0.0);for(int k=0;k<SHADOW_COUNT;++k){vec3 eH=uLightPositions[k].xyz-dv*uLightPositions[k].w;float eI=inversesqrt(dot(eH,eH));eH*=eI;float a=saturate(uLightParams[k].z/eI);a=1.0+a*(uLightParams[k].x+uLightParams[k].y*a);float s=saturate(dot(eH,uLightDirections[k]));s=saturate(uLightSpot[k].y-uLightSpot[k].z*(1.0-s*s));vec3 jC=mix(uLightColors[k].xyz,vec3(1.0,1.0,1.0),uShadowCatcherParams.x);vec3 jD=(a*s)*jC;jD*=saturate(dot(eH,dC));jB+=jD;jA+=jD*eA.eL[k];}float jE=1.0e-4;vec3 r=(jA+jE)/(jB+jE);float jF=saturate(dot(jv,jv))*uShadowCatcherParams.z;r=mix(r,vec3(1.0,1.0,1.0),jF);r=mix(vec3(1.0,1.0,1.0),r,uShadowCatcherParams.y);gl_FragColor.xyz=r;gl_FragColor.w=1.0;}",
  6270. "shadowfloorvert.glsl": "precision highp float;uniform mat4 uModelViewProjectionMatrix;uniform mat4 uModelSkyMatrix;uniform float uScale;attribute vec3 vPosition;varying highp vec3 dv;varying mediump vec2 jv;varying mediump vec3 dC;vec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}void main(void){jv=vPosition.xz;dC=normalize(uModelSkyMatrix[1].xyz);dv=h(uModelSkyMatrix,vPosition).xyz;gl_Position=h(uModelViewProjectionMatrix,vPosition);}",
  6271. "shadowfrag.glsl": "precision highp float;varying vec2 jG;\n#ifdef ALPHA_TEST\nvarying mediump vec2 d;uniform sampler2D tAlbedo;\n#endif\nvec3 jH(float v){vec4 jI=vec4(1.0,255.0,65025.0,16581375.0)*v;jI=fract(jI);jI.xyz-=jI.yzw*(1.0/255.0);return jI.xyz;}void main(void){\n#ifdef ALPHA_TEST\nfloat e=texture2D(tAlbedo,d).a;if(e<0.5){discard;}\n#endif\n#ifdef SHADOW_NATIVE_DEPTH\ngl_FragColor.xyz=vec3(0.0,0.0,0.0);\n#else\ngl_FragColor.xyz=jH((jG.x/jG.y)*0.5+0.5);\n#endif\ngl_FragColor.w=0.0;}",
  6272. "shadowvert.glsl": "precision highp float;attribute vec3 vPosition;attribute vec2 vTexCoord;uniform mat4 uMeshTransform;uniform mat4 uViewProjection;varying vec2 jG;\n#ifdef ALPHA_TEST\nvarying mediump vec2 d;uniform vec2 uUVOffset;\n#endif\nvec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}void main(void){vec3 p=h(uMeshTransform,vPosition).xyz;gl_Position=h(uViewProjection,p);jG=gl_Position.zw;\n#ifdef ALPHA_TEST\nd=vTexCoord+uUVOffset;\n#endif\n}",
  6273. "sky.glsl": "precision highp float;uniform sampler2D tSkyTexture;uniform float uAlpha;varying vec2 d;void main(void){vec3 r=texture2D(tSkyTexture,d).xyz;gl_FragColor.xyz=r*r;gl_FragColor.w=uAlpha;}",
  6274. "skySH.glsl": "precision mediump float;uniform vec4 uSkyCoefficients[9];uniform float uAlpha;varying vec3 jJ;void main(void){vec3 G=normalize(jJ);vec3 r=uSkyCoefficients[0].xyz;r+=uSkyCoefficients[1].xyz*G.y;r+=uSkyCoefficients[2].xyz*G.z;r+=uSkyCoefficients[3].xyz*G.x;vec3 swz=G.yyz*G.xzx;r+=uSkyCoefficients[4].xyz*swz.x;r+=uSkyCoefficients[5].xyz*swz.y;r+=uSkyCoefficients[7].xyz*swz.z;vec3 sqr=G*G;r+=uSkyCoefficients[6].xyz*(3.0*sqr.z-1.0);r+=uSkyCoefficients[8].xyz*(sqr.x-sqr.y);gl_FragColor.xyz=r;gl_FragColor.w=uAlpha;}",
  6275. "skyvert.glsl": "precision highp float;uniform mat4 uInverseSkyMatrix;uniform mat4 uViewProjection;attribute vec3 vPosition;attribute vec2 vTexCoord;\n#if SKYMODE == 3\nvarying vec3 jJ;\n#else\nvarying vec2 d;\n#endif\nvec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}vec4 u(mat4 i,vec3 v){return i[0]*v.x+i[1]*v.y+i[2]*v.z;}void main(void){vec3 p=h(uInverseSkyMatrix,vPosition).xyz;gl_Position=u(uViewProjection,p);gl_Position.z-=(1.0/65535.0)*gl_Position.w;\n#if SKYMODE == 3\njJ=vPosition;jJ.xy+=1e-20*vTexCoord;\n#else\nd=vTexCoord;\n#endif\n}",
  6276. "wirefrag.glsl": "precision highp float;uniform vec4 uStripParams;void main(void){vec2 c=gl_FragCoord.xy*uStripParams.xy-vec2(1.0,1.0);c.x+=0.25*c.y;float a=c.x<uStripParams.z?0.0:0.9;a=c.x<uStripParams.w?a:0.0;gl_FragColor=vec4(0.0,0.0,0.0,a);}",
  6277. "wirevert.glsl": "precision highp float;uniform mat4 uModelViewProjectionMatrix;attribute vec3 vPosition;vec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}void main(void){gl_Position=h(uModelViewProjectionMatrix,vPosition);gl_Position.z+=-0.00005*gl_Position.w;}",
  6278. nil: ""
  6279. }
  6280. }(fdage);