4dage.js 377 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330
  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. function (I) {
  72. function r(e, t, i) {
  73. if (this.name = t.partName,
  74. this.animatedProperties = [],
  75. this.sceneObjectType = t.sceneObjectType,
  76. this.skinningRigIndex = t.skinningRigIndex,
  77. this.id = i,
  78. this.mesh = this.skinningRig = 0,
  79. this.materialIndex = this.lightIndex = this.meshIndex = -1,
  80. this.emissiveProperty = this.offsetVProperty = this.offsetUProperty = this.material = 0,
  81. this.debugMe = t.debugMe,
  82. this.debugString = "",
  83. this.hasTransform = !1,
  84. this.modelPartIndex = t.modelPartIndex,
  85. this.modelPartFPS = t.modelPartFPS,
  86. this.modelPartScale = t.modelPartScale,
  87. this.parentIndex = t.parentIndex,
  88. this.totalFrames = t.totalFrames,
  89. this.animationLength = 1 / this.modelPartFPS * this.totalFrames,
  90. 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,
  91. t.animatedProperties) {
  92. i = t.animatedProperties.length;
  93. for (var s = 0; s < i; ++s) {
  94. var n = t.animatedProperties[s],
  95. r = new a();
  96. r.name = n.name,
  97. this.animatedProperties.push(r),
  98. "Red" != r.name || this.redProperty || (this.redProperty = r),
  99. "Green" != r.name || this.greenProperty || (this.greenProperty = r),
  100. "Blue" != r.name || this.blueProperty || (this.blueProperty = r),
  101. "Brightness" != r.name || this.brightnessProperty || (this.brightnessProperty = r),
  102. "Distance" != r.name || this.distanceProperty || (this.distanceProperty = r),
  103. "Spot Angle" != r.name || this.spotAngleProperty || (this.spotAngleProperty = r),
  104. "Spot Sharpness" != r.name || this.spotSharpnessProperty || (this.spotSharpnessProperty = r),
  105. "Opacity" != r.name || this.opacityProperty || (this.opacityProperty = r),
  106. "Sky Illumination" != r.name || this.skyIllumProperty || (this.skyIllumProperty = r),
  107. "Light Illumination" != r.name || this.lightIllumProperty || (this.lightIllumProperty = r),
  108. "Dispersion" != r.name || this.dispersionProperty || (this.dispersionProperty = r),
  109. "Visible" != r.name || this.visibleProperty || (this.visibleProperty = r),
  110. "Spin Rate" == r.name && (this.spinProperty = r),
  111. "OffsetU" == r.name && (this.offsetUProperty = r),
  112. "OffsetV" == r.name && (this.offsetVProperty = r),
  113. "EmissiveIntensity" == r.name && (this.emissiveProperty = r)
  114. }
  115. }
  116. this.keyframesSharedBufferUShorts = this.keyframesSharedBufferFloats = this.keyFramesByteStream = 0,
  117. (e = e.get(t.file)) && (this.keyFramesByteStream = new u(e.data),
  118. this.unPackKeyFrames()),
  119. this.animatedLocalTransform = new o(this),
  120. this.hasTransform = this.animatedLocalTransform.hasTranslation || this.animatedLocalTransform.hasRotation || this.animatedLocalTransform.hasScale,
  121. this.cachedWorldTransform0 = S.identity(),
  122. this.cachedWorldTransform1 = S.identity(),
  123. this.cachedWorldTransform2 = S.identity(),
  124. this.cachedWorldTransform3 = S.identity(),
  125. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -10,
  126. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  127. this.useFixedLocalTransform = this.useFixedWorldTransform = !1
  128. }
  129. function a() {
  130. this.currentValue = 0,
  131. this.keyframeBufferStartIndexFloat = -1,
  132. this.lastValue = this.interpolationOffsetUShort = this.frameIndexOffsetUShort = this.weighOutOffsetFloat = this.weighInOffsetFloat = this.valueOffsetFloat = this.indexUShortSkip = this.indexFloatSkip = this.interpolationType = this.bytesPerKeyFrame = this.keyframePackingType = 0,
  133. this.lastFramePercent = -10,
  134. this.enable = !0,
  135. this.name = "NONE",
  136. this.splineKF0 = new i(0, 0),
  137. this.splineKF1 = new i(0, 0),
  138. this.splineKF2 = new i(0, 0),
  139. this.splineKF3 = new i(0, 0),
  140. this.debugMe = !0,
  141. this.debugString = "",
  142. this.lastSearchIndex = 1,
  143. this.savedSearchIndex = 0,
  144. this.splineKF0.frameIndex = 0,
  145. this.splineKF1.frameIndex = 1,
  146. this.splineKF2.frameIndex = 2,
  147. this.splineKF3.frameIndex = 3,
  148. this.numKeyframes = 0
  149. }
  150. function o(e) {
  151. var t = e.animatedProperties;
  152. for (this.TX = this.TY = this.TZ = this.RX = this.RY = this.RZ = this.SX = this.SY = this.SZ = 0,
  153. this.hostObject = e,
  154. this.matrix = S.identity(),
  155. this.cachedmatrix0 = S.identity(),
  156. this.cachedmatrix1 = S.identity(),
  157. this.cachedmatrix2 = S.identity(),
  158. this.cachedmatrix3 = S.identity(),
  159. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -1,
  160. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  161. this.debugString = "",
  162. e = 0; e < t.length; e++) {
  163. var i = t[e];
  164. "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)
  165. }
  166. this.hasTranslation = this.TX && this.TY && this.TZ,
  167. this.hasRotation = this.RX && this.RY && this.RZ,
  168. this.hasScale = this.SX && this.SY && this.SZ,
  169. this.lockTransform = !1
  170. }
  171. function c(e, t) {
  172. if (this.originalFPS = 1,
  173. this.name = t.name,
  174. this.totalSeconds = t.length,
  175. this.originalFPS = t.originalFPS,
  176. this.totalFrames = t.totalFrames,
  177. this.expectedNumAnimatedObjects = t.numAnimatedObjects,
  178. this.animatedObjects = [],
  179. this.sceneTransform = S.identity(),
  180. this.debugString = "",
  181. t.animatedObjects)
  182. for (var i = t.animatedObjects.length, s = 0; s < i; ++s) {
  183. var n = new r(e, t.animatedObjects[s], s);
  184. this.animatedObjects.push(n),
  185. this.debugString += n.debugString
  186. }
  187. this.meshObjects = [],
  188. this.lightObjects = [],
  189. this.materialObjects = [],
  190. this.turnTableObjects = [],
  191. this.cameraObjects = []
  192. }
  193. function h(e) {
  194. for (this.files = [],
  195. e = new u(e); !e.empty();) {
  196. var t = {};
  197. t.name = e.readCString(),
  198. t.type = e.readCString();
  199. var i = e.readUint32(),
  200. s = e.readUint32(),
  201. n = e.readUint32();
  202. if (t.data = e.readBytes(s),
  203. !(t.data.length < s)) {
  204. if (1 & i && (t.data = this.decompress(t.data, n),
  205. null === t.data))
  206. continue;
  207. this.files[t.name] = t
  208. }
  209. }
  210. }
  211. function l(e) {
  212. this.digits = new Uint16Array(e || 0)
  213. }
  214. function d(e) {
  215. for (var t = 0; t < e.length; ++t) {
  216. var i = e[t].bounds;
  217. if (void 0 === this.min)
  218. this.min = [i.min[0], i.min[1], i.min[2]],
  219. this.max = [i.max[0], i.max[1], i.max[2]];
  220. else
  221. for (var s = 0; s < 3; ++s)
  222. this.min[s] = Math.min(i.min[s], this.min[s]),
  223. this.max[s] = Math.max(i.max[s], this.max[s])
  224. }
  225. this.min = this.min ? this.min : [0, 0, 0],
  226. this.max = this.max ? this.max : [0, 0, 0],
  227. this.center = [.5 * (this.min[0] + this.max[0]), .5 * (this.min[1] + this.max[1]), .5 * (this.min[2] + this.max[2])],
  228. this.radius = [this.max[0] - this.center[0], this.max[1] - this.center[1], this.max[2] - this.center[2]],
  229. this.radiusDiagonal = Math.sqrt(this.radius[0] * this.radius[0] + this.radius[1] * this.radius[1] + this.radius[2] * this.radius[2])
  230. }
  231. function p(e) {
  232. this.name = "none",
  233. this.text = "default text",
  234. this.title = "none",
  235. this.debugString = this.imagePath = "",
  236. this.controlRect = new s(e),
  237. this.defaultAlpha = .5,
  238. this.focusAlpha = 1,
  239. this.updateAlphas = !0,
  240. 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
  241. }
  242. function u(e) {
  243. this.bytes = new Uint8Array(e)
  244. }
  245. function s(e) {
  246. this.name = "none",
  247. this.title = "frame",
  248. this.yPercent = this.xPercent = 0,
  249. this.heightPercent = this.widthPercent = 1,
  250. this.debugString = "",
  251. this.parentControlRect = 0,
  252. this.childControlRects = [],
  253. this.clicked = this.mouseDown = this.mouseOver = !1,
  254. this.localMouseYPercent = this.localMouseXPercent = 0,
  255. this.enabled = this.visible = !0,
  256. this.opacity = 1,
  257. this.guiScreen = e,
  258. this.id = this.callBack = this.linkedControl = 0
  259. }
  260. r.prototype.setFixedWorldTransform = function (e) {
  261. this.useFixedWorldTransform = !0,
  262. S.copy(this.cachedWorldTransform0, e)
  263. },
  264. r.prototype.setFixedLocalTransform = function (e) {
  265. this.useFixedLocalTransform = !0,
  266. this.animatedLocalTransform.lockTransform = !0,
  267. S.copy(this.animatedLocalTransform.cachedmatrix0, e)
  268. },
  269. r.prototype.getCachedWorldTransform = function (e) {
  270. 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
  271. },
  272. r.prototype.getFreeCachedWorldTransform = function (e) {
  273. return this.useFixedWorldTransform ? 0 : (this.cachedFrameUse0--,
  274. this.cachedFrameUse1--,
  275. this.cachedFrameUse2--,
  276. this.cachedFrameUse3--,
  277. this.cachedFrameUse0 <= this.cachedFrameUse1 && this.cachedFrameUse0 <= this.cachedFrameUse2 && this.cachedFrameUse0 <= this.cachedFrameUse3 ? (this.cachedFrame0 = e,
  278. this.cachedFrameUse0 = 0,
  279. this.cachedWorldTransform0) : this.cachedFrameUse1 <= this.cachedFrameUse0 && this.cachedFrameUse1 <= this.cachedFrameUse2 && this.cachedFrameUse1 <= this.cachedFrameUse3 ? (this.cachedFrame1 = e,
  280. this.cachedFrameUse1 = 0,
  281. this.cachedWorldTransform1) : this.cachedFrameUse2 <= this.cachedFrameUse0 && this.cachedFrameUse2 <= this.cachedFrameUse1 && this.cachedFrameUse2 <= this.cachedFrameUse3 ? (this.cachedFrame2 = e,
  282. this.cachedFrameUse2 = 0,
  283. this.cachedWorldTransform2) : (this.cachedFrame3 = e,
  284. this.cachedFrameUse3 = 0,
  285. this.cachedWorldTransform3))
  286. },
  287. r.prototype.unPackKeyFrames = function () {
  288. if (this.keyFramesByteStream) {
  289. var e = new Float32Array(this.keyFramesByteStream.bytes.buffer),
  290. t = new Uint32Array(this.keyFramesByteStream.bytes.buffer),
  291. i = new Uint16Array(this.keyFramesByteStream.bytes.buffer),
  292. s = new Uint8Array(this.keyFramesByteStream.bytes.buffer);
  293. this.keyframesSharedBufferFloats = e;
  294. e = 0,
  295. e = 1 + (t = (this.keyframesSharedBufferUShorts = t)[0]),
  296. t = this.animatedProperties.length;
  297. for (var n = 0; n < t; n++) {
  298. var r = this.animatedProperties[n],
  299. a = 2 + 2 * n,
  300. o = 2 * a;
  301. r.keyframeBufferStartIndexFloat = e,
  302. r.numKeyframes = i[a],
  303. r.keyframePackingType = s[2 + o],
  304. r.interpolationType = s[3 + o],
  305. r.indexFloatSkip = 0,
  306. (r.indexUShortSkip = 0) < r.numKeyframes && (0 == r.keyframePackingType ? (r.bytesPerKeyFrame = 16,
  307. r.indexFloatSkip = 4,
  308. r.indexUShortSkip = 8,
  309. r.valueOffsetFloat = 0,
  310. r.weighInOffsetFloat = 1,
  311. r.weighOutOffsetFloat = 2,
  312. r.frameIndexOffsetUShort = 6,
  313. r.interpolationOffsetUShort = 7) : 1 == r.keyframePackingType ? (r.bytesPerKeyFrame = 8,
  314. r.indexFloatSkip = 2,
  315. r.indexUShortSkip = 4,
  316. r.valueOffsetFloat = 0,
  317. r.weighInOffsetFloat = 0,
  318. r.weighOutOffsetFloat = 0,
  319. r.frameIndexOffsetUShort = 2,
  320. r.interpolationOffsetUShort = 3) : 2 == r.keyframePackingType && (r.bytesPerKeyFrame = 4,
  321. r.indexFloatSkip = 1,
  322. r.indexUShortSkip = 2,
  323. r.valueOffsetFloat = 0,
  324. r.weighInOffsetFloat = 0,
  325. r.weighOutOffsetFloat = 0,
  326. r.frameIndexOffsetUShort = 0,
  327. r.interpolationOffsetUShort = 0)),
  328. e += r.numKeyframes * r.indexFloatSkip
  329. }
  330. }
  331. },
  332. r.prototype.setupSkinningRig = function (e, t, i, s) {
  333. var n = S.identity(),
  334. r = S.identity(),
  335. a = (a = i * (o = e.animatedObjects[t]).modelPartFPS) - Math.floor(a),
  336. o = (i = Math.floor(e.getObjectAnimationFramePercent(o, i))) + 1,
  337. h = 1 - a,
  338. l = s.skinningClusters.length;
  339. if (0 < l)
  340. for (var d = 0; d < l; d++) {
  341. (c = s.skinningClusters[d]).solveClusterTransformAtFrame(e, t, i, n),
  342. c.solveClusterTransformAtFrame(e, t, o, r);
  343. for (var c = c.matrix, u = 0; u < 16; u++)
  344. c[u] = n[u] * h + r[u] * a
  345. }
  346. },
  347. r.prototype.evaluateLocalTransformAtFramePercent = function (e, t, i, s) {
  348. if (this.useFixedLocalTransform)
  349. S.copy(t, this.animatedLocalTransform.cachedmatrix0);
  350. else {
  351. var n = 0;
  352. s && (n = this.animatedLocalTransform.getCachedTransform(e)),
  353. n ? S.copy(t, n) : ((n = this.animatedLocalTransform.getFreeCachedTransform(e)) ? (this.animatedLocalTransform.evaluateMatrix(n, this.totalFrames, e, i),
  354. S.copy(t, n)) : this.animatedLocalTransform.evaluateMatrix(t, this.totalFrames, e, i),
  355. 0 != this.turnTableSpin && (e = S.rotation(S.empty(), this.turnTableSpin, 1),
  356. S.mul(t, t, e)))
  357. }
  358. },
  359. r.prototype.hasAnimatedTransform = function () {
  360. var e = this.animatedLocalTransform;
  361. 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)
  362. },
  363. a.prototype.evaluateCurve = function (e, t) {
  364. var i = this.splineKF1.frameIndex,
  365. s = this.splineKF2.frameIndex,
  366. n = this.splineKF1.value,
  367. r = this.splineKF2.value,
  368. a = i - (this.splineKF2.frameIndex - this.splineKF0.frameIndex),
  369. o = s - (this.splineKF1.frameIndex - this.splineKF3.frameIndex),
  370. h = n - (this.splineKF2.value - this.splineKF0.value) * this.splineKF1.weighOut,
  371. l = r - (this.splineKF1.value - this.splineKF3.value) * this.splineKF2.weighIn;
  372. return 3 == this.splineKF1.interpolation && (a = i - (this.splineKF2.frameIndex - this.splineKF1.frameIndex),
  373. h = n - this.splineKF1.weighOut),
  374. 3 == this.splineKF2.interpolation && (o = s - (this.splineKF1.frameIndex - this.splineKF2.frameIndex),
  375. l = r + this.splineKF2.weighIn),
  376. a = (e - a) / (i - a),
  377. i = (e - i) / (s - i),
  378. s = (e - s) / (o - s),
  379. ((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
  380. },
  381. a.prototype.evaluate = function (e, t, i) {
  382. if (!i)
  383. return t;
  384. if (0 == this.numKeyframes)
  385. return this.lastValue = t;
  386. if (1 == this.numKeyframes)
  387. return this.lastValue = 2 == this.keyframePackingType ? i.keyframesSharedBufferFloats[this.keyframeBufferStartIndexFloat] : i.keyframesSharedBufferFloats[this.keyframeBufferStartIndexFloat + this.valueOffsetFloat];
  388. if (this.lastFramePercent == e)
  389. return this.lastValue;
  390. var s = this.keyframeBufferStartIndexFloat,
  391. n = 2 * this.keyframeBufferStartIndexFloat;
  392. if (this.lastValue = t,
  393. this.lastFramePercent = e,
  394. 2 == this.keyframePackingType) {
  395. var r = e - (t = Math.floor(e));
  396. return e >= this.numKeyframes && (t -= Math.floor(e / this.numKeyframes) * this.numKeyframes),
  397. 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],
  398. ++t >= this.numKeyframes && (t -= this.numKeyframes),
  399. 0 <= t && t < this.numKeyframes ? e = n * (1 - r) + i.keyframesSharedBufferFloats[s + t] * r : i.debugString += "<br>bad lerp frame " + t + " of " + this.numKeyframes,
  400. this.lastValue = e)
  401. }
  402. var a = this.numKeyframes;
  403. r = i.keyframesSharedBufferUShorts[n + this.frameIndexOffsetUShort];
  404. if (e >= i.keyframesSharedBufferUShorts[n + (a - 1) * this.indexUShortSkip + this.frameIndexOffsetUShort])
  405. return this.lastValue = i.keyframesSharedBufferFloats[s + (a - 1) * this.indexFloatSkip + this.valueOffsetFloat];
  406. if (e < r)
  407. return this.lastValue = i.keyframesSharedBufferFloats[s + this.valueOffsetFloat];
  408. this.lastSearchIndex < this.numKeyframes && e > i.keyframesSharedBufferUShorts[n + this.lastSearchIndex * this.indexUShortSkip + this.frameIndexOffsetUShort] && (this.lastSearchIndex = 1);
  409. for (var o = this.lastSearchIndex; o < a; o++) {
  410. r = s + o * this.indexFloatSkip;
  411. var h = s + (o - 1) * this.indexFloatSkip,
  412. l = n + o * this.indexUShortSkip,
  413. d = n + (o - 1) * this.indexUShortSkip;
  414. if (e >= i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort] && e <= i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort]) {
  415. this.lastSearchIndex = o;
  416. var c = i.keyframesSharedBufferUShorts[d + this.interpolationOffsetUShort];
  417. if (2 == c) {
  418. this.lastValue = e = e >= i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort] ? i.keyframesSharedBufferFloats[r + this.valueOffsetFloat] : i.keyframesSharedBufferFloats[h + this.valueOffsetFloat];
  419. break
  420. }
  421. if (0 == c) {
  422. s = i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort],
  423. t = i.keyframesSharedBufferFloats[h + this.valueOffsetFloat],
  424. n = i.keyframesSharedBufferFloats[r + this.valueOffsetFloat],
  425. r = (e - s) / (i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort] - s),
  426. this.lastValue = e = t * (1 - r) + n * r;
  427. break
  428. }
  429. if (1 == c || 3 == c) {
  430. var u = c = !1,
  431. f = 0,
  432. m = i.keyframesSharedBufferFloats[h + this.valueOffsetFloat],
  433. p = i.keyframesSharedBufferFloats[r + this.valueOffsetFloat],
  434. g = 0,
  435. v = 0,
  436. x = (d = i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort],
  437. l = i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort],
  438. 0),
  439. y = 1,
  440. b = 1,
  441. S = 1,
  442. T = 1,
  443. w = 1,
  444. C = 1,
  445. R = 1,
  446. A = 1;
  447. 0 != this.weighInOffsetFloat && (b = i.keyframesSharedBufferFloats[h + this.weighInOffsetFloat],
  448. S = i.keyframesSharedBufferFloats[r + this.weighInOffsetFloat],
  449. C = i.keyframesSharedBufferFloats[h + this.weighOutOffsetFloat],
  450. R = i.keyframesSharedBufferFloats[r + this.weighOutOffsetFloat]),
  451. 1 < o && (c = !0,
  452. f = i.keyframesSharedBufferFloats[s + (o - 2) * this.indexFloatSkip + this.valueOffsetFloat],
  453. v = i.keyframesSharedBufferUShorts[n + (o - 2) * this.indexUShortSkip + this.frameIndexOffsetUShort],
  454. 0 != this.weighInOffsetFloat && (y = i.keyframesSharedBufferFloats[s + (o - 2) * this.indexFloatSkip + this.weighInOffsetFloat],
  455. w = i.keyframesSharedBufferFloats[s + (o - 2) * this.indexFloatSkip + this.weighOutOffsetFloat])),
  456. o < a - 1 && (u = !0,
  457. g = i.keyframesSharedBufferFloats[s + (o + 1) * this.indexFloatSkip + this.valueOffsetFloat],
  458. x = i.keyframesSharedBufferUShorts[n + (o + 1) * this.indexUShortSkip + this.frameIndexOffsetUShort],
  459. 0 != this.weighInOffsetFloat && (T = i.keyframesSharedBufferFloats[s + (o + 1) * this.indexFloatSkip + this.weighInOffsetFloat],
  460. A = i.keyframesSharedBufferFloats[s + (o + 1) * this.indexFloatSkip + this.weighOutOffsetFloat])),
  461. c && u ? (this.splineKF0.value = f,
  462. this.splineKF1.value = m,
  463. this.splineKF2.value = p,
  464. this.splineKF3.value = g,
  465. this.splineKF0.frameIndex = v,
  466. this.splineKF1.frameIndex = d,
  467. this.splineKF2.frameIndex = l,
  468. this.splineKF3.frameIndex = x,
  469. this.splineKF0.weighIn = y,
  470. this.splineKF0.weighOut = w,
  471. this.splineKF1.weighIn = b,
  472. this.splineKF1.weighOut = C,
  473. this.splineKF2.weighIn = S,
  474. this.splineKF2.weighOut = R,
  475. this.splineKF3.weighIn = T,
  476. this.splineKF3.weighOut = A) : (this.splineKF0.value = m,
  477. this.splineKF1.value = m,
  478. this.splineKF2.value = p,
  479. this.splineKF3.value = p,
  480. this.splineKF0.frameIndex = d,
  481. this.splineKF1.frameIndex = d,
  482. this.splineKF2.frameIndex = l,
  483. this.splineKF3.frameIndex = l,
  484. this.splineKF1.weighIn = b,
  485. this.splineKF2.weighIn = S,
  486. this.splineKF1.weighOut = C,
  487. this.splineKF2.weighOut = R,
  488. u ? (this.splineKF3.value = g,
  489. this.splineKF3.frameIndex = x,
  490. this.splineKF3.weighIn = T,
  491. this.splineKF3.weighOut = A) : (this.splineKF3.frameIndex++,
  492. this.splineKF3.value = this.splineKF1.value,
  493. this.splineKF3.weighIn = 1,
  494. this.splineKF3.weighOut = 1),
  495. c ? (this.splineKF0.value = f,
  496. this.splineKF0.frameIndex = v,
  497. this.splineKF0.weighIn = y,
  498. this.splineKF0.weighOut = w) : (this.splineKF0.value = this.splineKF2.value,
  499. this.splineKF0.weighIn = 1,
  500. this.splineKF0.weighOut = 1,
  501. 0 < this.splineKF0.frameIndex ? this.splineKF0.frameIndex-- : (this.splineKF1.frameIndex++,
  502. this.splineKF2.frameIndex++,
  503. this.splineKF3.frameIndex++,
  504. e++))),
  505. this.lastValue = e = this.evaluateCurve(e, t);
  506. break
  507. }
  508. }
  509. }
  510. return this.lastValue
  511. },
  512. o.prototype.getTRSValue = function (e, t, i) {
  513. return t ? (t.evaluate(e, i, this.hostObject),
  514. "" != t.debugString && (this.debugString += t.debugString),
  515. t.lastValue) : i
  516. },
  517. o.prototype.evaluateMatrix = function (e, t, i, s) {
  518. if (this.lockTransform)
  519. S.copy(e, this.cachedmatrix0);
  520. else {
  521. var n = 0,
  522. r = t = 0;
  523. n = r = t = 0,
  524. n = r = t = 1;
  525. this.hasRotation ? (n = this.getTRSValue(i, this.RX, 0),
  526. t = this.getTRSValue(i, this.RY, 0),
  527. r = this.getTRSValue(i, this.RZ, 0),
  528. s ? (this.matrix = S.rotation(S.empty(), r, 2),
  529. s = S.rotation(S.empty(), n, 0),
  530. S.mul(s, s, this.matrix),
  531. this.matrix = S.rotation(S.empty(), t, 1)) : (this.matrix = S.rotation(S.empty(), n, 0),
  532. s = S.rotation(S.empty(), t, 1),
  533. S.mul(s, s, this.matrix),
  534. this.matrix = S.rotation(S.empty(), r, 2)),
  535. S.mul(this.matrix, this.matrix, s)) : S.copy(this.matrix, S.identity()),
  536. this.hasTranslation && (t = this.getTRSValue(i, this.TX, 0),
  537. r = this.getTRSValue(i, this.TY, 0),
  538. n = this.getTRSValue(i, this.TZ, 0),
  539. this.matrix[12] = t,
  540. this.matrix[13] = r,
  541. this.matrix[14] = n),
  542. this.hasScale && (t = this.getTRSValue(i, this.SX, 1),
  543. r = this.getTRSValue(i, this.SY, 1),
  544. n = this.getTRSValue(i, this.SZ, 1),
  545. this.matrix[0] *= t,
  546. this.matrix[4] *= r,
  547. this.matrix[8] *= n,
  548. this.matrix[1] *= t,
  549. this.matrix[5] *= r,
  550. this.matrix[9] *= n,
  551. this.matrix[2] *= t,
  552. this.matrix[6] *= r,
  553. this.matrix[10] *= n,
  554. this.matrix[3] *= t,
  555. this.matrix[7] *= r,
  556. this.matrix[11] *= n),
  557. S.copy(e, this.matrix)
  558. }
  559. },
  560. o.prototype.clearCachedTransforms = function () {
  561. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -1,
  562. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  563. this.TX && (this.TX.lastFramePercent = -10),
  564. this.TY && (this.TY.lastFramePercent = -10),
  565. this.TZ && (this.TZ.lastFramePercent = -10),
  566. this.RX && (this.RX.lastFramePercent = -10),
  567. this.RY && (this.RY.lastFramePercent = -10),
  568. this.RZ && (this.RZ.lastFramePercent = -10),
  569. this.SX && (this.SX.lastFramePercent = -10),
  570. this.SY && (this.SY.lastFramePercent = -10),
  571. this.SZ && (this.SZ.lastFramePercent = -10),
  572. this.lockTransform = !1
  573. },
  574. o.prototype.getCachedTransform = function (e) {
  575. 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
  576. },
  577. o.prototype.getFreeCachedTransform = function (e) {
  578. return this.lockTransform ? 0 : (this.cachedFrameUse0--,
  579. this.cachedFrameUse1--,
  580. this.cachedFrameUse2--,
  581. this.cachedFrameUse3--,
  582. this.cachedFrameUse0 <= this.cachedFrameUse1 && this.cachedFrameUse0 <= this.cachedFrameUse2 && this.cachedFrameUse0 <= this.cachedFrameUse3 || this.cachedFrame0 == e ? (this.cachedFrame0 = e,
  583. this.cachedFrameUse0 = 0,
  584. this.cachedmatrix0) : this.cachedFrameUse1 <= this.cachedFrameUse0 && this.cachedFrameUse1 <= this.cachedFrameUse2 && this.cachedFrameUse1 <= this.cachedFrameUse3 || this.cachedFrame1 == e ? (this.cachedFrame1 = e,
  585. this.cachedFrameUse1 = 0,
  586. this.cachedmatrix1) : this.cachedFrameUse2 <= this.cachedFrameUse0 && this.cachedFrameUse2 <= this.cachedFrameUse1 && this.cachedFrameUse2 <= this.cachedFrameUse3 || this.cachedFrame2 == e ? (this.cachedFrame2 = e,
  587. this.cachedFrameUse2 = 0,
  588. this.cachedmatrix2) : (this.cachedFrame3 = e,
  589. this.cachedFrameUse3 = 0,
  590. this.cachedmatrix3))
  591. },
  592. c.prototype.evaluateModelPartTransformAtFrame = function (e, t, i, s) {
  593. S.copy(i, S.identity());
  594. for (var n = 0; n < 100; n++) {
  595. var r = this.animatedObjects[e];
  596. if (e == r.parentIndex)
  597. break;
  598. if (r.useFixedWorldTransform) {
  599. S.mul(i, r.cachedWorldTransform0, i);
  600. break
  601. }
  602. var a = 0;
  603. if (s && (a = r.getCachedWorldTransform(t)),
  604. a) {
  605. S.mul(i, a, i);
  606. break
  607. }
  608. a = S.identity(),
  609. r.evaluateLocalTransformAtFramePercent(t, a, !1, s),
  610. S.mul(i, a, i),
  611. e == r.parentIndex && (n = 100),
  612. e = r.parentIndex
  613. }
  614. },
  615. c.prototype.lerpModelPartTransform = function (e, t, i, s) {
  616. var n = this.animatedObjects[e];
  617. if (n.useFixedWorldTransform)
  618. S.copy(i, n.cachedWorldTransform0);
  619. else {
  620. var r = (r = t * n.modelPartFPS) - Math.floor(r),
  621. a = Math.floor(this.getObjectAnimationFramePercent(n, t)),
  622. o = a + 1,
  623. h = t = 0;
  624. for (s && (t = n.getCachedWorldTransform(a),
  625. h = n.getCachedWorldTransform(o)),
  626. t || ((t = n.getFreeCachedWorldTransform(a)) || (t = S.identity()),
  627. this.evaluateModelPartTransformAtFrame(e, a, t, s)),
  628. h || ((h = n.getFreeCachedWorldTransform(o)) || (h = S.identity()),
  629. this.evaluateModelPartTransformAtFrame(e, o, h, s)),
  630. e = 1 - r,
  631. s = 0; s < 16; s++)
  632. i[s] = t[s] * e + h[s] * r
  633. }
  634. },
  635. c.prototype.getModelPartTransform = function (e, t, i, s) {
  636. this.lerpModelPartTransform(e, t, i, s)
  637. },
  638. c.prototype.getAnimatedLocalTransform = function (e, t, i, s) {
  639. e = this.animatedObjects[e];
  640. var n = this.animatedObjects[e.parentIndex],
  641. r = n.modelPartIndex != n.id,
  642. a = S.identity();
  643. if (this.getModelPartTransform(e.modelPartIndex, t, a, s),
  644. r) {
  645. r = S.identity();
  646. var o = S.identity();
  647. this.getModelPartTransform(n.modelPartIndex, t, r, s),
  648. S.invert(o, r),
  649. S.mul(i, o, a),
  650. i[12] *= e.modelPartScale,
  651. i[13] *= e.modelPartScale,
  652. i[14] *= e.modelPartScale
  653. } else
  654. S.copy(i, a)
  655. },
  656. c.prototype.isVisibleAtFramePercent = function (e, t) {
  657. for (var i = e, s = 0, n = 0; n < 100; n++) {
  658. if ((s = this.animatedObjects[i]).visibleProperty) {
  659. if (s.visibleProperty.evaluate(t, 1, s),
  660. "" != s.debugString || "" != s.visibleProperty.debugString)
  661. return this.debugString += s.debugString,
  662. this.debugString += s.visibleProperty.debugString,
  663. !1;
  664. if (0 == s.visibleProperty.lastValue)
  665. return !1
  666. }
  667. i == s.parentIndex && (n = 100),
  668. i = s.parentIndex
  669. }
  670. return !0
  671. },
  672. c.prototype.getWorldTransform = function (e, t, i, s, n) {
  673. if ((e = this.animatedObjects[e]).useFixedWorldTransform)
  674. S.copy(i, e.cachedWorldTransform0);
  675. else {
  676. var r = this.getObjectAnimationFramePercent(e, t),
  677. a = S.identity();
  678. if (e.evaluateLocalTransformAtFramePercent(r, a, !0, n),
  679. r = e.modelPartIndex != e.id) {
  680. r = S.identity();
  681. var o = S.identity();
  682. S.copy(o, a),
  683. this.getAnimatedLocalTransform(e.id, t, r),
  684. S.mul(a, r, o)
  685. }
  686. if (S.copy(i, a),
  687. e.parentIndex != e.id)
  688. for (var h = e.parentIndex, l = 0; l < 100; l++)
  689. e = this.animatedObjects[h],
  690. r = this.getObjectAnimationFramePercent(e, t),
  691. a = S.identity(),
  692. e.evaluateLocalTransformAtFramePercent(r, a, !0, n),
  693. (r = e.modelPartIndex != e.id) ? (r = S.identity(),
  694. this.getAnimatedLocalTransform(e.id, t, r),
  695. o = S.identity(),
  696. S.mul(o, a, i),
  697. S.mul(i, r, o)) : (o = S.identity(),
  698. S.copy(o, i),
  699. S.mul(i, a, o)),
  700. h == e.parentIndex && (l = 100),
  701. h = e.parentIndex;
  702. i[12] *= s,
  703. i[13] *= s,
  704. i[14] *= s
  705. }
  706. },
  707. c.prototype.hasParentInHierarchy = function (e, t) {
  708. for (var i = e.parentIndex, s = 0; s < 100; s++) {
  709. if ((e = this.animatedObjects[i]).id == t)
  710. return !0;
  711. i == e.parentIndex && (s = 100),
  712. i = e.parentIndex
  713. }
  714. return !1
  715. },
  716. c.prototype.hasParentTypeInHierarchy = function (e, t) {
  717. for (var i = e.parentIndex, s = 0; s < 100; s++) {
  718. if ((e = this.animatedObjects[i]).sceneObjectType == t)
  719. return !0;
  720. i == e.parentIndex && (s = 100),
  721. i = e.parentIndex
  722. }
  723. return !1
  724. },
  725. c.prototype.searchAnimationUpHierarchy = function (e) {
  726. for (var t = e.id, i = 0; i < 100; i++) {
  727. if ((e = this.animatedObjects[t]).animatedLocalTransform && (e.hasAnimatedTransform() || e.id != e.modelPartIndex && this.searchAnimationUpHierarchy(this.animatedObjects[e.modelPartIndex])))
  728. return !0;
  729. t == e.parentIndex && (i = 100),
  730. t = e.parentIndex
  731. }
  732. return !1
  733. },
  734. c.prototype.hasAnimationInHierarchy = function (e) {
  735. 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)
  736. },
  737. c.prototype.getObjectAnimationFramePercent = function (e, t) {
  738. if (0 == this.totalFrames || 0 == e.animationLength)
  739. return 0;
  740. var i = t / e.animationLength;
  741. i = Math.floor(i);
  742. return (i = (t -= e.animationLength * i) * e.modelPartFPS) >= e.totalFrames + 1 && (i = e.totalFrames),
  743. i
  744. },
  745. h.prototype.get = function (e) {
  746. return this.files[e]
  747. },
  748. h.prototype.extract = function (e) {
  749. var t = this.files[e];
  750. return delete this.files[e],
  751. t
  752. },
  753. h.prototype.checkSignature = function (e) {
  754. if (!e)
  755. return !1;
  756. var t = this.get(e.name + ".sig");
  757. if (!t)
  758. return !1;
  759. if (!(t = JSON.parse(String.fromCharCode.apply(null, t.data))))
  760. return !1;
  761. for (var i = 5381, s = 0; s < e.data.length; ++s)
  762. i = 33 * i + e.data[s] & 4294967295;
  763. 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),
  764. (s = new l()).setBytes(t[0]),
  765. s.powmod(65537, e).toInt32() == i
  766. },
  767. h.prototype.decompress = function (e, t) {
  768. var i = new Uint8Array(t),
  769. s = 0,
  770. n = new Uint32Array(4096),
  771. r = new Uint32Array(4096),
  772. a = 256,
  773. o = e.length,
  774. h = 0,
  775. l = 1,
  776. d = 0,
  777. c = 1;
  778. i[s++] = e[0];
  779. for (var u = 1; !(o <= (c = u + (u >> 1)) + 1); u++) {
  780. d = e[c + 1],
  781. c = e[c];
  782. if ((f = 1 & u ? d << 4 | c >> 4 : (15 & d) << 8 | c) < a)
  783. if (f < 256)
  784. d = s,
  785. c = 1,
  786. i[s++] = f;
  787. else {
  788. d = s,
  789. c = r[f];
  790. for (var f, m = (f = n[f]) + c; f < m;)
  791. i[s++] = i[f++]
  792. }
  793. else {
  794. if (f != a)
  795. break;
  796. for (d = s,
  797. c = l + 1,
  798. m = (f = h) + l; f < m;)
  799. i[s++] = i[f++];
  800. i[s++] = i[h]
  801. }
  802. n[a] = h,
  803. r[a++] = l + 1,
  804. h = d,
  805. l = c,
  806. a = 4096 <= a ? 256 : a
  807. }
  808. return s == t ? i : null
  809. },
  810. l.prototype.setBytes = function (e, t) {
  811. var i = (e.length + 1) / 2 | 0;
  812. if (this.digits = new Uint16Array(i),
  813. t) {
  814. var s = 0;
  815. for (i = e.length - 1; 0 <= i; i -= 2)
  816. this.digits[s++] = e[i] + (0 < i ? 256 * e[i - 1] : 0)
  817. } else
  818. for (s = 0; s < i; ++s)
  819. this.digits[s] = e[2 * s] + 256 * e[2 * s + 1];
  820. this.trim()
  821. },
  822. l.prototype.toInt32 = function () {
  823. var e = 0;
  824. return 0 < this.digits.length && (e = this.digits[0],
  825. 1 < this.digits.length && (e |= this.digits[1] << 16)),
  826. e
  827. },
  828. l.prototype.lessThan = function (e) {
  829. if (this.digits.length == e.digits.length)
  830. for (var t = this.digits.length - 1; 0 <= t; --t) {
  831. var i = this.digits[t],
  832. s = e.digits[t];
  833. if (i != s)
  834. return i < s
  835. }
  836. return this.digits.length < e.digits.length
  837. },
  838. l.prototype.shiftRight = function () {
  839. for (var e = 0, t = this.digits, i = t.length - 1; 0 <= i; --i) {
  840. var s = t[i];
  841. t[i] = s >> 1 | e << 15,
  842. e = s
  843. }
  844. this.trim()
  845. },
  846. l.prototype.shiftLeft = function (e) {
  847. if (0 < e) {
  848. 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)
  849. 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);
  850. return n.trim(),
  851. n
  852. }
  853. return new l(this)
  854. },
  855. l.prototype.bitCount = function () {
  856. var e = 0;
  857. if (0 < this.digits.length) {
  858. e = 16 * (this.digits.length - 1);
  859. for (var t = this.digits[this.digits.length - 1]; t;)
  860. t >>>= 1,
  861. ++e
  862. }
  863. return e
  864. },
  865. l.prototype.sub = function (e) {
  866. var t = this.digits,
  867. i = e.digits,
  868. s = this.digits.length;
  869. e = e.digits.length;
  870. for (var n = 0, r = 0; r < s; ++r) {
  871. var a, o = (o = t[r]) + ((n = o < (a = (a = r < e ? i[r] : 0) + n) ? 1 : 0) << 16);
  872. t[r] = o - a & 65535
  873. }
  874. this.trim()
  875. },
  876. l.prototype.mul = function (e) {
  877. for (var t = new l(this.digits.length + e.digits.length), i = t.digits, s = 0; s < this.digits.length; ++s)
  878. for (var n = this.digits[s], r = 0; r < e.digits.length; ++r)
  879. for (var a = n * e.digits[r], o = s + r; a;) {
  880. var h = (65535 & a) + i[o];
  881. i[o] = 65535 & h,
  882. a >>>= 16,
  883. a += h >>> 16,
  884. ++o
  885. }
  886. return t.trim(),
  887. t
  888. },
  889. l.prototype.mod = function (e) {
  890. if (this.digits.length <= 0 || e.digits.length <= 0)
  891. return new l(0);
  892. var t = new l(this.digits);
  893. if (!this.lessThan(e)) {
  894. for (var i = (i = new l(e.digits)).shiftLeft(t.bitCount() - i.bitCount()); !t.lessThan(e);)
  895. i.lessThan(t) && t.sub(i),
  896. i.shiftRight();
  897. t.trim()
  898. }
  899. return t
  900. },
  901. l.prototype.powmod = function (e, t) {
  902. for (var i = new l([1]), s = this.mod(t); e;)
  903. 1 & e && (i = i.mul(s).mod(t)),
  904. e >>>= 1,
  905. s = s.mul(s).mod(t);
  906. return i
  907. },
  908. l.prototype.trim = function () {
  909. for (var e = this.digits.length; 0 < e && 0 == this.digits[e - 1];)
  910. --e;
  911. e != this.digits.length && (this.digits = this.digits.subarray(0, e))
  912. },
  913. p.prototype.setBackground3x1 = function (e, t, i, s, n, r, a) {
  914. this.backgroundOffsetX = t,
  915. this.backgroundOffsetY = i,
  916. this.edgePixelsX = a,
  917. this.backgroundLeft = e.addImage(s),
  918. this.backgroundMiddle = e.addImage(n),
  919. this.backgroundRight = e.addImage(r),
  920. this.backgroundLeft.linkedControl.style.zIndex = "0",
  921. this.backgroundMiddle.linkedControl.style.zIndex = "0",
  922. this.backgroundRight.linkedControl.style.zIndex = "0",
  923. this.setOpacity(this.defaultAlpha)
  924. },
  925. p.prototype.setBackground3x3 = function (e, t, i, s, n, r, a, o, h, l, d, c, u, f) {
  926. this.backgroundOffsetX = t,
  927. this.backgroundOffsetY = i,
  928. this.edgePixelsX = u,
  929. this.edgePixelsY = f,
  930. this.backgroundTopLeft = e.addImage(s),
  931. this.backgroundMiddleLeft = e.addImage(a),
  932. this.backgroundBottomLeft = e.addImage(l),
  933. this.backgroundTopMiddle = e.addImage(n),
  934. this.backgroundMiddleMiddle = e.addImage(o),
  935. this.backgroundBottomMiddle = e.addImage(d),
  936. this.backgroundTopRight = e.addImage(r),
  937. this.backgroundMiddleRight = e.addImage(h),
  938. this.backgroundBottomRight = e.addImage(c),
  939. this.backgroundTopLeft.linkedControl.style.zIndex = "0",
  940. this.backgroundTopRight.linkedControl.style.zIndex = "0",
  941. this.backgroundTopMiddle.linkedControl.style.zIndex = "0",
  942. this.backgroundMiddleLeft.linkedControl.style.zIndex = "0",
  943. this.backgroundMiddleRight.linkedControl.style.zIndex = "0",
  944. this.backgroundMiddleMiddle.linkedControl.style.zIndex = "0",
  945. this.backgroundBottomLeft.linkedControl.style.zIndex = "0",
  946. this.backgroundBottomRight.linkedControl.style.zIndex = "0",
  947. this.backgroundBottomMiddle.linkedControl.style.zIndex = "0",
  948. this.setOpacity(this.defaultAlpha)
  949. },
  950. p.prototype.alignBackground = function () {
  951. var e = (n = (s = this.controlRect).guiScreen).left * (1 - s.getScreenXPercent()),
  952. t = n.bottom * (1 - s.getScreenYPercent()),
  953. i = n.width * s.getScreenWidthPercent(),
  954. s = n.height * s.getScreenHeightPercent();
  955. t += this.backgroundOffsetY,
  956. e += this.backgroundOffsetX;
  957. if (this.backgroundTopLeft && this.backgroundTopRight && this.backgroundTopMiddle && this.backgroundMiddleLeft && this.backgroundMiddleRight && this.backgroundMiddleMiddle && this.backgroundBottomLeft && this.backgroundBottomRight && this.backgroundBottomMiddle) {
  958. var n = i - 2 * this.edgePixelsX,
  959. r = s - 2 * this.edgePixelsY;
  960. this.backgroundTopLeft.linkedControl.style.height = this.edgePixelsY + "px",
  961. this.backgroundTopMiddle.linkedControl.style.height = this.edgePixelsY + "px",
  962. this.backgroundTopRight.linkedControl.style.height = this.edgePixelsY + "px",
  963. this.backgroundBottomLeft.linkedControl.style.height = this.edgePixelsY + "px",
  964. this.backgroundBottomMiddle.linkedControl.style.height = this.edgePixelsY + "px",
  965. this.backgroundBottomRight.linkedControl.style.height = this.edgePixelsY + "px",
  966. this.backgroundMiddleLeft.linkedControl.style.height = r + "px",
  967. this.backgroundMiddleMiddle.linkedControl.style.height = r + "px",
  968. this.backgroundMiddleRight.linkedControl.style.height = r + "px",
  969. this.backgroundTopLeft.linkedControl.style.width = this.edgePixelsX + "px",
  970. this.backgroundBottomLeft.linkedControl.style.width = this.edgePixelsX + "px",
  971. this.backgroundMiddleLeft.linkedControl.style.width = this.edgePixelsX + "px",
  972. this.backgroundTopRight.linkedControl.style.width = this.edgePixelsX + "px",
  973. this.backgroundBottomRight.linkedControl.style.width = this.edgePixelsX + "px",
  974. this.backgroundMiddleRight.linkedControl.style.width = this.edgePixelsX + "px",
  975. this.backgroundTopMiddle.linkedControl.style.width = n + "px",
  976. this.backgroundBottomMiddle.linkedControl.style.width = n + "px",
  977. this.backgroundMiddleMiddle.linkedControl.style.width = n + "px",
  978. this.backgroundTopLeft.linkedControl.style.left = e + "px",
  979. this.backgroundBottomLeft.linkedControl.style.left = e + "px",
  980. this.backgroundMiddleLeft.linkedControl.style.left = e + "px",
  981. e += this.edgePixelsX,
  982. this.backgroundTopMiddle.linkedControl.style.left = e + "px",
  983. this.backgroundBottomMiddle.linkedControl.style.left = e + "px",
  984. this.backgroundMiddleMiddle.linkedControl.style.left = e + "px",
  985. e += n,
  986. this.backgroundTopRight.linkedControl.style.left = e + "px",
  987. this.backgroundBottomRight.linkedControl.style.left = e + "px",
  988. this.backgroundMiddleRight.linkedControl.style.left = e + "px",
  989. this.backgroundBottomLeft.linkedControl.style.bottom = t + "px",
  990. this.backgroundBottomMiddle.linkedControl.style.bottom = t + "px",
  991. this.backgroundBottomRight.linkedControl.style.bottom = t + "px",
  992. t += this.edgePixelsY,
  993. this.backgroundMiddleLeft.linkedControl.style.bottom = t + "px",
  994. this.backgroundMiddleRight.linkedControl.style.bottom = t + "px",
  995. this.backgroundMiddleMiddle.linkedControl.style.bottom = t + "px",
  996. t += r,
  997. this.backgroundTopLeft.linkedControl.style.bottom = t + "px",
  998. this.backgroundTopMiddle.linkedControl.style.bottom = t + "px",
  999. this.backgroundTopRight.linkedControl.style.bottom = t + "px"
  1000. }
  1001. this.backgroundLeft && this.backgroundRight && this.backgroundMiddle && (i -= 2 * this.edgePixelsX,
  1002. this.backgroundLeft.linkedControl.style.bottom = t + "px",
  1003. this.backgroundMiddle.linkedControl.style.bottom = t + "px",
  1004. this.backgroundRight.linkedControl.style.bottom = t + "px",
  1005. this.backgroundLeft.linkedControl.style.height = s + "px",
  1006. this.backgroundMiddle.linkedControl.style.height = s + "px",
  1007. this.backgroundRight.linkedControl.style.height = s + "px",
  1008. this.backgroundLeft.linkedControl.style.width = this.edgePixelsX + "px",
  1009. this.backgroundMiddle.linkedControl.style.width = i + "px",
  1010. this.backgroundRight.linkedControl.style.width = this.edgePixelsX + "px",
  1011. this.backgroundLeft.linkedControl.style.left = e + "px",
  1012. e += this.edgePixelsX,
  1013. this.backgroundMiddle.linkedControl.style.left = e + "px",
  1014. this.backgroundRight.linkedControl.style.left = e + i + "px")
  1015. },
  1016. p.prototype.setOpacity = function (e) {
  1017. this.controlRect.linkedControl.style.opacity = e,
  1018. this.backgroundLeft && (this.backgroundLeft.linkedControl.style.opacity = e),
  1019. this.backgroundRight && (this.backgroundRight.linkedControl.style.opacity = e),
  1020. this.backgroundMiddle && (this.backgroundMiddle.linkedControl.style.opacity = e),
  1021. this.backgroundTopLeft && (this.backgroundTopLeft.linkedControl.style.opacity = e),
  1022. this.backgroundTopRight && (this.backgroundTopRight.linkedControl.style.opacity = e),
  1023. this.backgroundTopMiddle && (this.backgroundTopMiddle.linkedControl.style.opacity = e),
  1024. this.backgroundMiddleLeft && (this.backgroundMiddleLeft.linkedControl.style.opacity = e),
  1025. this.backgroundMiddleRight && (this.backgroundMiddleRight.linkedControl.style.opacity = e),
  1026. this.backgroundMiddleMiddle && (this.backgroundMiddleMiddle.linkedControl.style.opacity = e),
  1027. this.backgroundBottomLeft && (this.backgroundBottomLeft.linkedControl.style.opacity = e),
  1028. this.backgroundBottomRight && (this.backgroundBottomRight.linkedControl.style.opacity = e),
  1029. this.backgroundBottomMiddle && (this.backgroundBottomMiddle.linkedControl.style.opacity = e)
  1030. },
  1031. p.prototype.setBackgroundVisible = function (e) {
  1032. this.backgroundLeft && this.backgroundLeft.showControl(e),
  1033. this.backgroundRight && this.backgroundRight.showControl(e),
  1034. this.backgroundMiddle && this.backgroundMiddle.showControl(e),
  1035. this.backgroundTopLeft && this.backgroundTopLeft.showControl(e),
  1036. this.backgroundTopRight && this.backgroundTopRight.showControl(e),
  1037. this.backgroundTopMiddle && this.backgroundTopMiddle.showControl(e),
  1038. this.backgroundMiddleLeft && this.backgroundMiddleLeft.showControl(e),
  1039. this.backgroundMiddleRight && this.backgroundMiddleRight.showControl(e),
  1040. this.backgroundMiddleMiddle && this.backgroundMiddleMiddle.showControl(e),
  1041. this.backgroundBottomLeft && this.backgroundBottomLeft.showControl(e),
  1042. this.backgroundBottomRight && this.backgroundBottomRight.showControl(e),
  1043. this.backgroundBottomMiddle && this.backgroundBottomMiddle.showControl(e)
  1044. },
  1045. p.prototype.setVisible = function (e) {
  1046. this.controlRect.showControl(e),
  1047. this.setBackgroundVisible(e)
  1048. },
  1049. p.prototype.linkControl = function (e) {
  1050. (this.controlRect.linkedControl = e).onmouseover = function () {
  1051. this.updateAlphas && (this.setOpacity(this.focusAlpha),
  1052. this.controlRect.mouseOver = !0,
  1053. this.linkedBackground && this.linkedBackground.setOpacity(this.focusAlpha))
  1054. }
  1055. .bind(this),
  1056. e.onmouseout = function () {
  1057. this.updateAlphas && (this.setOpacity(this.defaultAlpha),
  1058. this.controlRect.mouseOver = !1,
  1059. this.linkedBackground && this.linkedBackground.setOpacity(this.defaultAlpha))
  1060. }
  1061. .bind(this)
  1062. },
  1063. u.prototype.empty = function () {
  1064. return this.bytes.length <= 0
  1065. },
  1066. u.prototype.readCString = function () {
  1067. for (var e = this.bytes, t = e.length, i = 0; i < t; ++i)
  1068. if (0 == e[i])
  1069. return e = String.fromCharCode.apply(null, this.bytes.subarray(0, i)),
  1070. this.bytes = this.bytes.subarray(i + 1),
  1071. e;
  1072. return null
  1073. },
  1074. u.prototype.asString = function () {
  1075. for (var e = "", t = 0; t < this.bytes.length; ++t)
  1076. e += String.fromCharCode(this.bytes[t]);
  1077. return e
  1078. },
  1079. u.prototype.readBytes = function (e) {
  1080. var t = this.bytes.subarray(0, e);
  1081. return this.bytes = this.bytes.subarray(e),
  1082. t
  1083. },
  1084. u.prototype.readUint32 = function () {
  1085. var e = this.bytes,
  1086. t = e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24;
  1087. return this.bytes = e.subarray(4),
  1088. t
  1089. },
  1090. u.prototype.readUint8 = function () {
  1091. var e = this.bytes,
  1092. t = e[0];
  1093. return this.bytes = e.subarray(1),
  1094. t
  1095. },
  1096. u.prototype.readUint16 = function () {
  1097. var e = this.bytes,
  1098. t = e[0] | e[1] << 8;
  1099. return this.bytes = e.subarray(2),
  1100. t
  1101. },
  1102. u.prototype.readFloat32 = function () {
  1103. var e = new Uint8Array(this.bytes);
  1104. e = new Float32Array(e.buffer);
  1105. return this.bytes = this.bytes.subarray(4),
  1106. e[0]
  1107. },
  1108. u.prototype.seekUint32 = function (e) {
  1109. return (e = this.bytes.subarray(4 * e))[0] | e[1] << 8 | e[2] << 16 | e[3] << 24
  1110. },
  1111. u.prototype.seekFloat32 = function (e) {
  1112. return e = new Uint8Array(this.bytes.subarray(4 * e)),
  1113. new Float32Array(e.buffer)[0]
  1114. },
  1115. u.prototype.getMatrix = function (e) {
  1116. return new Float32Array(this.bytes.buffer, 64 * e, 16)
  1117. },
  1118. s.prototype.getScreenWidth = function () {
  1119. if (this.linkedControl)
  1120. return this.guiScreen.width * this.getScreenWidthPercent()
  1121. },
  1122. s.prototype.getScreenHeight = function () {
  1123. if (this.linkedControl)
  1124. return this.guiScreen.height * this.getScreenHeightPercent()
  1125. },
  1126. s.prototype.updateElement = function () {
  1127. var e = this.linkedControl;
  1128. if (e) {
  1129. var t = this.guiScreen.left * (1 - this.getScreenXPercent()),
  1130. i = this.guiScreen.bottom * (1 - this.getScreenYPercent()),
  1131. s = this.guiScreen.width * this.getScreenWidthPercent(),
  1132. n = this.guiScreen.height * this.getScreenHeightPercent();
  1133. e.style.left = t + "px",
  1134. e.style.bottom = i + "px",
  1135. e.style.width = s + "px",
  1136. e.style.height = n + "px"
  1137. }
  1138. },
  1139. s.prototype.updateElement = function () {
  1140. var e = this.linkedControl;
  1141. if (e) {
  1142. var t = this.guiScreen.left * (1 - this.getScreenXPercent()),
  1143. i = this.guiScreen.bottom * (1 - this.getScreenYPercent()),
  1144. s = this.guiScreen.width * this.getScreenWidthPercent(),
  1145. n = this.guiScreen.height * this.getScreenHeightPercent();
  1146. e.style.left = t + "px",
  1147. e.style.bottom = i + "px",
  1148. e.style.width = s + "px",
  1149. e.style.height = n + "px"
  1150. }
  1151. },
  1152. s.prototype.updateChildElements = function () {
  1153. this.updateElement();
  1154. for (var e = 0; e < this.childControlRects.length; e++)
  1155. this.childControlRects[e].updateChildElements()
  1156. },
  1157. s.prototype.set = function (e, t, i, s) {
  1158. this.xPercent = e,
  1159. this.yPercent = t,
  1160. this.widthPercent = i,
  1161. this.heightPercent = s
  1162. },
  1163. s.prototype.linkControl = function (e) {
  1164. (this.linkedControl = e).onmouseover = function () {
  1165. this.mouseOver = !0
  1166. }
  1167. .bind(this),
  1168. e.onmouseout = function () {
  1169. this.mouseOver = !1
  1170. }
  1171. .bind(this),
  1172. e.onmousedown = function () {
  1173. this.mouseDown = !0
  1174. }
  1175. .bind(this),
  1176. e.onmouseup = function () {
  1177. this.mouseDown = !1
  1178. }
  1179. .bind(this),
  1180. e.onclick = function () {
  1181. this.callBack && this.callBack(this),
  1182. this.clicked = !0
  1183. }
  1184. .bind(this)
  1185. },
  1186. s.prototype.showControl = function (e) {
  1187. this.visible = e,
  1188. this.linkedControl && (this.linkedControl.style.display = e ? "block" : "none")
  1189. },
  1190. s.prototype.setOpacity = function (e) {
  1191. this.opacity = e,
  1192. this.linkedControl && (this.linkedControl.style.opacity = e)
  1193. },
  1194. s.prototype.hasChildControlRect = function (e) {
  1195. for (var t = 0; t < this.childControlRects.length; t++)
  1196. if (this.childControlRects[t] == e)
  1197. return !0;
  1198. return !1
  1199. },
  1200. s.prototype.registerChildControlRect = function (e) {
  1201. this.hasChildControlRect(e) || (this.childControlRects.push(e),
  1202. e.parentControlRect = this)
  1203. },
  1204. s.prototype.getScreenWidthPercent = function () {
  1205. var e = this.widthPercent;
  1206. return this.parentControlRect && (e *= this.parentControlRect.getScreenWidthPercent()),
  1207. e
  1208. },
  1209. s.prototype.getScreenHeightPercent = function () {
  1210. var e = this.heightPercent;
  1211. return this.parentControlRect && (e *= this.parentControlRect.getScreenHeightPercent()),
  1212. e
  1213. },
  1214. s.prototype.getScreenXPercent = function () {
  1215. var e = this.xPercent;
  1216. return this.parentControlRect && (e *= this.parentControlRect.getScreenWidthPercent(),
  1217. e += this.parentControlRect.getScreenXPercent()),
  1218. e
  1219. },
  1220. s.prototype.getScreenYPercent = function () {
  1221. var e = this.yPercent;
  1222. return this.parentControlRect && (e *= this.parentControlRect.getScreenHeightPercent(),
  1223. e += this.parentControlRect.getScreenYPercent()),
  1224. e
  1225. };
  1226. function n(e, t, i, s) {
  1227. var n = !1,
  1228. r = e + (-1 == e.indexOf("?") ? "?" : "&") + "thumb=1",
  1229. a = function (e) {
  1230. return (e = new h(e).extract("thumbnail.jpg")) ? N.parseFile(e, t, s) : n ? i && i() : (n = !0,
  1231. C.fetchBinaryIncremental(r, a, i, 394240)),
  1232. 0
  1233. };
  1234. C.fetchBinaryIncremental(r, a, i, 65536)
  1235. }
  1236. function f(e, t) {
  1237. this.desc = t,
  1238. this.gl = e,
  1239. this.iblShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", ["#define FOG_IBL"]);
  1240. var i = ["#define FOG_DIR"];
  1241. this.dirShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1242. i.push("#define FOG_SHADOWS"),
  1243. this.dirShaderShadow = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1244. i = ["#define FOG_SPOT"],
  1245. this.spotShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1246. i.push("#define FOG_SHADOWS"),
  1247. this.spotShaderShadow = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1248. i = ["#define FOG_OMNI"],
  1249. this.omniShaderShadow = this.omniShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1250. this.fullscreenTriangle = e.createBuffer(),
  1251. e.bindBuffer(e.ARRAY_BUFFER, this.fullscreenTriangle),
  1252. i = new Float32Array([0, 0, 2, 0, 0, 2]),
  1253. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  1254. e.bindBuffer(e.ARRAY_BUFFER, null)
  1255. }
  1256. function m(e, t) {
  1257. this.gl = e,
  1258. this.fbo = e.createFramebuffer(),
  1259. e.bindFramebuffer(e.FRAMEBUFFER, this.fbo),
  1260. t && (this.width = t.width,
  1261. this.height = t.height,
  1262. t.color0 && (this.color0 = t.color0,
  1263. e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, this.color0.id, 0),
  1264. this.width = t.color0.desc.width,
  1265. this.height = t.color0.desc.height),
  1266. t.depth ? (this.depth = t.depth,
  1267. e.framebufferTexture2D(e.FRAMEBUFFER, e.DEPTH_ATTACHMENT, e.TEXTURE_2D, this.depth.id, 0)) : (this.depthBuffer = t.depthBuffer,
  1268. t.createDepth && !this.depthBuffer && (this.depthBuffer = m.createDepthBuffer(e, this.width, this.height)),
  1269. this.depthBuffer && (e.bindRenderbuffer(e.RENDERBUFFER, this.depthBuffer),
  1270. e.framebufferRenderbuffer(e.FRAMEBUFFER, e.DEPTH_ATTACHMENT, e.RENDERBUFFER, this.depthBuffer),
  1271. e.bindRenderbuffer(e.RENDERBUFFER, null)))),
  1272. this.valid = t && t.ignoreStatus || e.checkFramebufferStatus(e.FRAMEBUFFER) == e.FRAMEBUFFER_COMPLETE,
  1273. e.bindFramebuffer(e.FRAMEBUFFER, null)
  1274. }
  1275. (I = void 0 === I ? {} : I).embed = function (e, t) {
  1276. var i, s = (t = function (e) {
  1277. if (e = e || {},
  1278. document.location.search)
  1279. for (var t = document.location.search.substring(1).split("&"), i = 0; i < t.length; ++i) {
  1280. var s = t[i].split("=");
  1281. e[s[0]] = s[1]
  1282. }
  1283. return t = function (e) {
  1284. if (0 | e)
  1285. return !0;
  1286. for (var t = "true True TRUE yes Yes YES".split(" "), i = 0; i < t.length; ++i)
  1287. if (e === t[i])
  1288. return !0;
  1289. return !1
  1290. },
  1291. e.width = e.width || 800,
  1292. e.height = e.height || 600,
  1293. e.autoStart = t(e.autoStart),
  1294. e.pagePreset = t(e.pagePreset),
  1295. e.fullFrame = t(e.fullFrame) || t(e.bare),
  1296. e.fullFrame = !e.pagePreset && e.fullFrame,
  1297. e
  1298. }(t)).thumbnailURL;
  1299. if (t.pagePreset) {
  1300. i = new W(t.width, t.height, e, !!s),
  1301. document.body.style.backgroundColor = "#d7e4da";
  1302. var n = document.createElement("div");
  1303. n.style.position = "relative",
  1304. n.style.backgroundColor = "#e4e7e4",
  1305. n.style.width = t.width + 12 + "px",
  1306. n.style.height = t.height + 6 + 16 + "px",
  1307. n.style.margin = "auto",
  1308. n.style.boxShadow = "3px 5px 12px 0px grey",
  1309. document.body.appendChild(n);
  1310. var r = document.createElement("div");
  1311. if (r.style.position = "relative",
  1312. r.style.left = "6px",
  1313. r.style.top = "6px",
  1314. n.appendChild(r),
  1315. r.appendChild(i.domRoot),
  1316. !i.mobile) {
  1317. n.style.resize = "both",
  1318. n.style.overflow = "hidden";
  1319. var a = [n.style.width, n.style.height],
  1320. o = function () {
  1321. g.active() ? n.style.resize = "none" : (n.style.resize = "both",
  1322. a[0] == n.style.width && a[1] == n.style.height || (a[0] = n.style.width,
  1323. a[1] = n.style.height,
  1324. i.resize(n.clientWidth - 12, n.clientHeight - 6 - 16))),
  1325. window.setTimeout(o, 100)
  1326. };
  1327. o()
  1328. }
  1329. } else
  1330. i = new W(t.fullFrame ? window.innerWidth : t.width, t.fullFrame ? window.innerHeight : t.height, e, !!s),
  1331. document.body.appendChild(i.domRoot),
  1332. t.fullFrame && (i.domRoot.style.position = "absolute",
  1333. i.domRoot.style.left = i.domRoot.style.top = 0,
  1334. window.addEventListener("resize", function () {
  1335. g.active() || i.resize(this.document.body.clientWidth, this.document.body.clientHeight)
  1336. }));
  1337. return (webview = i).ui.setThumbnailURL(s),
  1338. t.autoStart && i.loadScene(),
  1339. i
  1340. },
  1341. I.fetchThumbnail = n,
  1342. f.prototype.draw = function (e, t) {
  1343. var i = this.gl,
  1344. s = e.view,
  1345. n = s.projectionMatrix,
  1346. r = S.empty();
  1347. S.mul(r, s.viewMatrix, s.projectionMatrix),
  1348. S.invert(r, s.viewProjectionMatrix),
  1349. r = [n[10] + n[11], -n[14], -2 * n[11]],
  1350. n = [-2 / n[0], -2 / n[5], (1 - n[8]) / n[0], (1 - n[9]) / n[5]],
  1351. i.enable(i.BLEND),
  1352. i.blendFunc(i.ONE, i.ONE_MINUS_SRC_ALPHA);
  1353. for (var a = 0; a < e.lights.count + 1; ++a) {
  1354. var o, h = a - 1,
  1355. l = h < e.lights.shadowCount;
  1356. (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();
  1357. var d = o.params;
  1358. if (i.uniform3fv(d.uDepthToZ, r),
  1359. i.uniform4fv(d.uUnproject, n),
  1360. i.uniformMatrix4fv(d.uInvViewMatrix, !1, s.transform),
  1361. i.uniform1f(d.uFogInvDistance, 1 / this.desc.distance),
  1362. i.uniform1f(d.uFogOpacity, this.desc.opacity * (1 - e.stripData.activeFade())),
  1363. i.uniform1f(d.uFogDispersion, 1 - this.desc.dispersion),
  1364. (u = [0, 0, 0])[this.desc.type] = 1,
  1365. i.uniform3fv(d.uFogType, u),
  1366. i.uniform3fv(d.uFogColor, this.desc.color),
  1367. i.uniform1f(d.uFogIllum, 0 == a ? this.desc.skyIllum : this.desc.lightIllum),
  1368. i.uniformMatrix4fv(d.uLightMatrix, !1, e.lights.invMatrix),
  1369. 0 == a) {
  1370. for (h = new Float32Array(e.sky.diffuseCoefficients),
  1371. l = 4; l < 16; ++l)
  1372. h[l] *= 1 - this.desc.dispersion;
  1373. for (l = 16; l < 36; ++l)
  1374. h[l] *= 1 - this.desc.dispersion * this.desc.dispersion;
  1375. i.uniform4fv(d.uFogLightSphere, h)
  1376. } else {
  1377. var c = e.lights.getLightPos(h),
  1378. u = (c = S.mul4(V.empty(), e.lights.invMatrix, c[0], c[1], c[2], c[3]),
  1379. e.lights.getLightDir(h));
  1380. u = S.mulVec(V.empty(), e.lights.invMatrix, u[0], u[1], u[2]);
  1381. i.uniform4fv(d.uLightPosition, c),
  1382. i.uniform3fv(d.uLightColor, e.lights.getColor(h));
  1383. c = .01745329251 * e.lights.spot[3 * h];
  1384. var f = Math.cos(.5 * c);
  1385. i.uniform4fv(d.uSpotParams, [-u[0], -u[1], -u[2], 0 < c ? f * f : 0]),
  1386. i.uniform4fv(d.uLightAttenuation, [e.lights.parameters[3 * h + 0], e.lights.parameters[3 * h + 1], e.lights.parameters[3 * h + 2], f]),
  1387. l && (l = S.mul(S.empty(), e.lights.finalTransformBuffer.subarray(16 * h), e.lights.matrix),
  1388. i.uniformMatrix4fv(d.uShadowProj, !1, l),
  1389. e.shadow.depthTextures[h].bind(o.samplers.uShadowMap),
  1390. h = 0,
  1391. 1 < e.postRender.sampleCount && (h = e.postRender.currentSample() / e.postRender.sampleCount),
  1392. i.uniform1f(d.uDitherOffset, h),
  1393. i.uniform3fv(d.uAABBMin, e.bounds.min),
  1394. i.uniform3fv(d.uAABBMax, e.bounds.max),
  1395. h = V.lerp(V.empty(), e.bounds.min, e.bounds.max, .5),
  1396. l = V.distance(h, e.bounds.min),
  1397. i.uniform4f(d.uCylinder, h[0], h[1], h[2], l * l))
  1398. }
  1399. t.bind(o.samplers.tDepth),
  1400. o = o.attribs.vCoord,
  1401. i.bindBuffer(i.ARRAY_BUFFER, this.fullscreenTriangle),
  1402. i.enableVertexAttribArray(o),
  1403. i.vertexAttribPointer(o, 2, i.FLOAT, !1, 0, 0),
  1404. i.drawArrays(i.TRIANGLES, 0, 3),
  1405. i.disableVertexAttribArray(o),
  1406. i.bindBuffer(i.ARRAY_BUFFER, null)
  1407. }
  1408. i.disable(i.BLEND)
  1409. },
  1410. f.prototype.complete = function () {
  1411. return this.iblShader.complete() && this.dirShader.complete() && this.dirShaderShadow.complete() && this.spotShader.complete() && this.spotShaderShadow.complete() && this.omniShader.complete() && this.omniShaderShadow.complete()
  1412. },
  1413. m.createDepthBuffer = function (e, t, i) {
  1414. var s = e.createRenderbuffer();
  1415. return e.bindRenderbuffer(e.RENDERBUFFER, s),
  1416. e.renderbufferStorage(e.RENDERBUFFER, e.DEPTH_COMPONENT16, t, i),
  1417. e.bindRenderbuffer(e.RENDERBUFFER, null),
  1418. s
  1419. },
  1420. m.prototype.bind = function () {
  1421. this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.fbo),
  1422. this.gl.viewport(0, 0, this.width, this.height)
  1423. },
  1424. m.bindNone = function (e) {
  1425. e.bindFramebuffer(e.FRAMEBUFFER, null)
  1426. };
  1427. var g = {
  1428. support: function () {
  1429. return !!(document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled)
  1430. },
  1431. begin: function (e, t) {
  1432. var i = e.requestFullscreen || e.webkitRequestFullScreen || e.mozRequestFullScreen || e.msRequestFullscreen;
  1433. if (i) {
  1434. var s = function () {
  1435. g.active() || (document.removeEventListener("fullscreenchange", s),
  1436. document.removeEventListener("webkitfullscreenchange", s),
  1437. document.removeEventListener("mozfullscreenchange", s),
  1438. document.removeEventListener("MSFullscreenChange", s)),
  1439. t && t()
  1440. };
  1441. document.addEventListener("fullscreenchange", s),
  1442. document.addEventListener("webkitfullscreenchange", s),
  1443. document.addEventListener("mozfullscreenchange", s),
  1444. document.addEventListener("MSFullscreenChange", s),
  1445. i.bind(e)()
  1446. }
  1447. },
  1448. end: function () {
  1449. var e = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen;
  1450. e && e.bind(document)()
  1451. },
  1452. active: function () {
  1453. return !!(document.fullscreenElement || document.webkitIsFullScreen || document.mozFullScreenElement || document.msFullscreenElement)
  1454. }
  1455. };
  1456. function v(e) {
  1457. this.debugString = "GUIRegion",
  1458. this.name = "Default",
  1459. this.controlRect = new s(e),
  1460. this.yPercent = this.xPercent = 0,
  1461. this.heightPercent = this.widthPercent = 1,
  1462. this.guiScreen = e
  1463. }
  1464. function t(e) {
  1465. this.init = !1,
  1466. this.ui = e,
  1467. this.bottom = this.left = this.height = this.width = 0,
  1468. this.clicked = this.mouseDown = !1,
  1469. this.playbackControls = 0,
  1470. e = 1,
  1471. window.devicePixelRatio && (2 < window.devicePixelRatio ? e = 4 : 1 < window.devicePixelRatio && (e = 2)),
  1472. this.imageSetNumber = e
  1473. }
  1474. function e(e) {
  1475. this.onTap = [],
  1476. this.onSingleTap = [],
  1477. this.onDoubleTap = [],
  1478. this.onDrag = [],
  1479. this.onZoom = [],
  1480. this.onPan = [],
  1481. this.onPan2 = [],
  1482. this.onAnything = [],
  1483. this.mouseDownCount = 0,
  1484. this.macHax = 0 <= navigator.platform.toUpperCase().indexOf("MAC"),
  1485. e && this.attach(e)
  1486. }
  1487. function i(e, t) {
  1488. e && t ? (this.frameIndex = t.frameIndex,
  1489. this.value = t.value,
  1490. this.interpolation = t.interpolation,
  1491. this.weighIn = t.weighIn,
  1492. this.weighOut = t.weighOut) : (this.interpolation = this.value = this.frameIndex = 0,
  1493. this.weighOut = this.weighIn = 1)
  1494. }
  1495. function x(e, t) {
  1496. for (var i in this.rotation = this.shadowCount = this.count = 0,
  1497. this.positions = [],
  1498. this.directions = [],
  1499. this.matrixWeights = [],
  1500. this.matrix = S.identity(),
  1501. this.invMatrix = S.identity(),
  1502. this.defaultmatrix = S.identity(),
  1503. this.defaultviewmatrix = S.identity(),
  1504. e)
  1505. this[i] = e[i];
  1506. this.count = this.positions.length / 4,
  1507. this.count = Math.min(6, this.count),
  1508. this.shadowCount = Math.min(3, this.shadowCount),
  1509. this.positions = new Float32Array(this.positions),
  1510. this.positionBuffer = new Float32Array(this.positions),
  1511. this.directions = new Float32Array(this.directions),
  1512. this.directionBuffer = new Float32Array(this.directions),
  1513. this.colors = new Float32Array(this.colors),
  1514. this.colorsBuffer = new Float32Array(this.colors),
  1515. this.modelViewBuffer = new Float32Array(16 * this.shadowCount),
  1516. this.projectionBuffer = new Float32Array(16 * this.shadowCount),
  1517. this.finalTransformBuffer = new Float32Array(16 * this.shadowCount),
  1518. this.inverseTransformBuffer = new Float32Array(16 * this.shadowCount),
  1519. this.shadowTexelPadProjections = new Float32Array(4 * this.shadowCount),
  1520. this.shadowsNeedUpdate = new Uint8Array(this.shadowCount);
  1521. for (var s = 0; s < this.shadowsNeedUpdate.length; ++s)
  1522. this.shadowsNeedUpdate[s] = 1;
  1523. for (S.rotation(this.matrix, this.rotation, 1),
  1524. S.transpose(this.invMatrix, this.matrix),
  1525. S.copy(this.defaultmatrix, this.matrix),
  1526. S.copy(this.defaultviewmatrix, t.viewMatrix),
  1527. s = 0; s < this.count; ++s) {
  1528. i = this.positions.subarray(4 * s, 4 * s + 4);
  1529. var n = this.directions.subarray(3 * s, 3 * s + 3);
  1530. 1 == this.matrixWeights[s] ? (S.mul4(i, this.matrix, i[0], i[1], i[2], i[3]),
  1531. 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]),
  1532. S.mulVec(n, t.viewMatrix, n[0], n[1], n[2]))
  1533. }
  1534. }
  1535. function y(e) {
  1536. this.name = "none",
  1537. this.text = "default text",
  1538. this.title = "none",
  1539. this.debugString = this.imagePath = "",
  1540. this.controlRect = new s(e),
  1541. this.textEntries = [],
  1542. this.textOffsetsX = [],
  1543. this.textOffsetsY = [],
  1544. this.buttons = [],
  1545. this.listBoxEntryHeight = 20,
  1546. this.selectedItemText = "",
  1547. this.selectedIndex = -1,
  1548. this.localPixelsY = 0,
  1549. this.localPixelsX = 100,
  1550. this.labelPixelDrop = 0,
  1551. this.labelPixelInset = 10,
  1552. this.labelTextHeight = 16,
  1553. this.closed = !1,
  1554. this.defaultButtonText = this.spacerMiddle = this.spacerRight = this.spacerLeft = this.spacerControl = 0,
  1555. this.listBoxButtons = [],
  1556. this.listBoxRegion = new v(e),
  1557. this.guiScreen = e,
  1558. this.lastMouseOverIndex = -1,
  1559. this.selectionChangedCallback = 0,
  1560. this.debugString = ""
  1561. }
  1562. function b(e, t, i) {
  1563. this.gl = e,
  1564. this.name = i.name;
  1565. var s = {
  1566. mipmap: !0,
  1567. aniso: e.hints.mobile ? 0 : 4,
  1568. clamp: !!i.textureWrapClamp,
  1569. mirror: !!i.textureWrapMirror
  1570. },
  1571. n = {
  1572. mipmap: s.mipmap,
  1573. clamp: s.clamp,
  1574. mirror: s.mirror,
  1575. nofilter: i.textureFilterNearest || !1
  1576. };
  1577. if (n.nofilter || (n.aniso = e.hints.mobile ? 2 : 4),
  1578. this.textures = {
  1579. albedo: e.textureCache.fromFilesMergeAlpha(t.get(i.albedoTex), t.get(i.alphaTex), n),
  1580. reflectivity: e.textureCache.fromFilesMergeAlpha(t.get(i.reflectivityTex), t.get(i.glossTex), s),
  1581. normal: e.textureCache.fromFile(t.get(i.normalTex), s),
  1582. extras: e.textureCache.fromFilesMergeAlpha(t.get(i.extrasTex), t.get(i.extrasTexA), s)
  1583. },
  1584. this.extrasTexCoordRanges = {},
  1585. i.extrasTexCoordRanges)
  1586. for (var r in i.extrasTexCoordRanges)
  1587. this.extrasTexCoordRanges[r] = new Float32Array(i.extrasTexCoordRanges[r].scaleBias);
  1588. this.textures.extras || ((t = new U(e, {
  1589. width: 1,
  1590. height: 1
  1591. })).loadArray(new Uint8Array([255, 255, 255, 255])),
  1592. this.textures.extras = t);
  1593. var a = i.blendTint || [1, 1, 1];
  1594. t = {
  1595. none: function () {
  1596. e.disable(e.BLEND)
  1597. },
  1598. alpha: function () {
  1599. e.enable(e.BLEND),
  1600. e.blendFuncSeparate(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA, e.ONE_MINUS_DST_ALPHA, e.ONE)
  1601. },
  1602. add: function () {
  1603. e.enable(e.BLEND),
  1604. e.blendColor(a[0], a[1], a[2], 1),
  1605. e.blendFunc(e.ONE, e.CONSTANT_COLOR)
  1606. }
  1607. },
  1608. this.blend = t[i.blend] || t.none,
  1609. this.alphaTest = i.alphaTest || 0,
  1610. this.usesBlending = this.blend !== t.none,
  1611. this.usesRefraction = !!i.refraction,
  1612. this.shadowAlphaTest = this.alphaTest,
  1613. this.shadowAlphaTest <= 0 && this.blend === t.alpha && (this.shadowAlphaTest = .5),
  1614. this.castShadows = this.blend !== t.add,
  1615. this.horizonOcclude = i.horizonOcclude || 0,
  1616. this.fresnel = new Float32Array(i.fresnel ? i.fresnel : [1, 1, 1]),
  1617. this.emissiveIntensity = i.emissiveIntensity || 1,
  1618. n = !(s = []),
  1619. 0 < i.lightCount && s.push("#define LIGHT_COUNT " + i.lightCount),
  1620. 0 < i.shadowCount && (r = Math.min(i.lightCount, i.shadowCount),
  1621. this.usesRefraction && e.limits.textureCount <= 8 && (r = 2 < r ? 2 : r),
  1622. s.push("#define SHADOW_COUNT " + r)),
  1623. 0 < i.alphaTest && s.push("#define ALPHA_TEST"),
  1624. this.blend === t.alpha ? s.push("#define TRANSPARENCY_DITHER") : this.blend === t.none && s.push("#define NOBLEND"),
  1625. e.hints.mobile && s.push("#define MOBILE"),
  1626. e.ext.textureDepth && s.push("#define SHADOW_NATIVE_DEPTH"),
  1627. r = function (e) {
  1628. return 1 / (2 / 3 * 3.1415962 * (e * e + e + 1))
  1629. },
  1630. i.useSkin && (s.push("#define SKIN"),
  1631. this.skinParams = i.skinParams || {
  1632. subdermisColor: [1, 1, 1],
  1633. transColor: [1, 0, 0, 1],
  1634. fresnelColor: [.2, .2, .2, .5],
  1635. fresnelOcc: 1,
  1636. fresnelGlossMask: 1,
  1637. transSky: .5,
  1638. shadowBlur: .5,
  1639. normalSmooth: .5,
  1640. transScatter: 0,
  1641. transDepth: 0,
  1642. millimeterScale: 1
  1643. },
  1644. this.extrasTexCoordRanges.subdermisTex || s.push("#define SKIN_NO_SUBDERMIS_TEX"),
  1645. this.extrasTexCoordRanges.translucencyTex || s.push("#define SKIN_NO_TRANSLUCENCY_TEX"),
  1646. this.extrasTexCoordRanges.fuzzTex || s.push("#define SKIN_NO_FUZZ_TEX"),
  1647. void 0 === this.skinParams.version && (this.skinParams.version = 1),
  1648. 2 == this.skinParams.version ? (s.push("#define SKIN_VERSION_2"),
  1649. this.skinParams.shadowBlur *= 4,
  1650. this.skinParams.shadowBlur = Math.min(this.skinParams.shadowBlur, 40),
  1651. this.skinParams.transIntegral = r(.5 * this.skinParams.transScatter),
  1652. this.skinParams.fresnelIntegral = 1 / 3.14159 * (1 - .5 * this.skinParams.fresnelColor[3]),
  1653. this.skinParams.transSky = 0) : (s.push("#define SKIN_VERSION_1"),
  1654. this.skinParams.shadowBlur = 8 * Math.min(this.skinParams.shadowBlur, 1),
  1655. this.skinParams.transDepth = 0,
  1656. this.skinParams.transScatter = this.skinParams.transColor[3],
  1657. this.skinParams.transIntegral = 1 / 3.14159 * (1 - .5 * this.skinParams.transScatter),
  1658. this.skinParams.fresnelIntegral = 1 / 3.14159 * (1 - .5 * this.skinParams.fresnelColor[3]),
  1659. this.skinParams.transSky *= 1.25,
  1660. this.skinParams.transIntegral *= 1.25)),
  1661. i.aniso && (s.push("#define ANISO"),
  1662. this.anisoParams = i.anisoParams || {
  1663. strength: 1,
  1664. tangent: [1, 0, 0],
  1665. integral: .5
  1666. },
  1667. this.extrasTexCoordRanges.anisoTex || s.push("#define ANISO_NO_DIR_TEX")),
  1668. i.microfiber && (s.push("#define MICROFIBER"),
  1669. this.microfiberParams = i.microfiberParams || {
  1670. fresnelColor: [.2, .2, .2, .5],
  1671. fresnelOcc: 1,
  1672. fresnelGlossMask: 1
  1673. },
  1674. this.microfiberParams.fresnelIntegral = 1 / 3.14159 * (1 - .5 * this.microfiberParams.fresnelColor[3]),
  1675. this.extrasTexCoordRanges.fuzzTex || s.push("#define MICROFIBER_NO_FUZZ_TEX")),
  1676. i.refraction && (s.push("#define REFRACTION"),
  1677. this.refractionParams = i.refractionParams || {
  1678. distantBackground: !1,
  1679. tint: [1, 1, 1],
  1680. useAlbedoTint: !1,
  1681. IOR: 1.5
  1682. },
  1683. this.extrasTexCoordRanges.refractionMaskTex || s.push("#define REFRACTION_NO_MASK_TEX")),
  1684. i.vertexColor && (s.push("#define VERTEX_COLOR"),
  1685. i.vertexColorsRGB && s.push("#define VERTEX_COLOR_SRGB"),
  1686. i.vertexColorAlpha && s.push("#define VERTEX_COLOR_ALPHA")),
  1687. this.horizonSmoothing = i.horizonSmoothing || 0,
  1688. 0 < this.horizonSmoothing && s.push("#define HORIZON_SMOOTHING"),
  1689. i.unlitDiffuse && s.push("#define DIFFUSE_UNLIT"),
  1690. this.extrasTexCoordRanges.emissiveTex && (s.push("#define EMISSIVE"),
  1691. i.emissiveSecondaryUV && (s.push("#define EMISSIVE_SECONDARY_UV"),
  1692. n = !0)),
  1693. this.extrasTexCoordRanges.aoTex && (s.push("#define AMBIENT_OCCLUSION"),
  1694. i.aoSecondaryUV && (s.push("#define AMBIENT_OCCLUSION_SECONDARY_UV"),
  1695. n = !0)),
  1696. i.tangentOrthogonalize && s.push("#define TSPACE_ORTHOGONALIZE"),
  1697. i.tangentNormalize && s.push("#define TSPACE_RENORMALIZE"),
  1698. i.tangentGenerateBitangent && s.push("#define TSPACE_COMPUTE_BITANGENT"),
  1699. n && s.push("#define TEXCOORD_SECONDARY"),
  1700. this.vOffset = this.uOffset = 0,
  1701. s.push("#define UV_OFFSET "),
  1702. this.shader = e.shaderCache.fromURLs("matvert.glsl", "matfrag.glsl", s),
  1703. s.push("#define STRIPVIEW"),
  1704. this.stripShader = e.shaderCache.fromURLs("matvert.glsl", "matfrag.glsl", s),
  1705. this.wireShader = e.shaderCache.fromURLs("wirevert.glsl", "wirefrag.glsl"),
  1706. this.blend === t.alpha && (this.prepassShader = e.shaderCache.fromURLs("alphaprepassvert.glsl", "alphaprepassfrag.glsl"))
  1707. }
  1708. v.prototype.addImageElement = function (e, t) {
  1709. var i = this.guiScreen.ui.menuCluster.contents,
  1710. s = document.createElement("input");
  1711. e.linkControl(s),
  1712. this.guiScreen.updateElement(e),
  1713. s.type = "image",
  1714. s.src = I.dataLocale + t,
  1715. s.style.position = "absolute",
  1716. s.style.border = "none",
  1717. s.style.outline = "0px",
  1718. s.style.zIndex = "1",
  1719. s.title = t,
  1720. s.style.opacity = e.opacity;
  1721. var n = new XMLHttpRequest();
  1722. return n.open("HEAD", s.src, !0),
  1723. n.onload = function (e) {
  1724. e.appendChild(this)
  1725. }
  1726. .bind(s, i),
  1727. n.send(),
  1728. s
  1729. },
  1730. v.prototype.addImage = function (e) {
  1731. var t = new s(this.guiScreen);
  1732. return this.addImageElement(t, e),
  1733. t
  1734. },
  1735. v.prototype.addTextButton = function (e, t, i, s, n, r) {
  1736. var a = new p(this.guiScreen);
  1737. return a.name = "none",
  1738. a.text = e,
  1739. a.controlRect.set(t, i, s, n),
  1740. a.controlRect.opacity = r,
  1741. this.controlRect.registerChildControlRect(a.controlRect),
  1742. t = this.guiScreen.ui.menuCluster.contents,
  1743. (i = document.createElement("text")).style.color = "white",
  1744. i.style.fontFamily = "Arial",
  1745. i.style.fontSize = I.largeUI ? "14px" : "12px",
  1746. i.style.textShadow = "2px 2px 3px #000000",
  1747. t.appendChild(i),
  1748. a.controlRect.linkControl(i),
  1749. this.guiScreen.updateElement(a.controlRect),
  1750. i.type = "text",
  1751. i.name = "text",
  1752. i.style.position = "absolute",
  1753. i.style.border = "none",
  1754. i.style.outline = "0px",
  1755. i.style.zIndex = "2",
  1756. i.innerHTML = e,
  1757. i.style.opacity = a.controlRect.opacity,
  1758. a.linkControl(i),
  1759. a
  1760. },
  1761. t.prototype.setSize = function (e, t) {
  1762. this.width = e,
  1763. this.height = t,
  1764. this.left = -e,
  1765. this.bottom = -t,
  1766. this.playbackControls && this.playbackControls.resize(this)
  1767. },
  1768. t.prototype.setupActiveView = function (e) {
  1769. this.init || (this.init = !0,
  1770. (this.ui = e).viewer.scene.sceneAnimator && (this.playbackControls = new R(this),
  1771. this.playbackControls.resize(this)))
  1772. },
  1773. t.prototype.updateElement = function (e) {
  1774. var t = e.linkedControl;
  1775. if (t) {
  1776. var i = this.left * (1 - e.getScreenXPercent()),
  1777. s = this.bottom * (1 - e.getScreenYPercent()),
  1778. n = this.width * e.getScreenWidthPercent();
  1779. e = this.height * e.getScreenHeightPercent(),
  1780. t.style.left = i + "px",
  1781. t.style.bottom = s + "px",
  1782. t.style.width = n + "px",
  1783. t.style.height = e + "px"
  1784. }
  1785. },
  1786. e.prototype.attach = function (e) {
  1787. this.element = e;
  1788. var m = function (e) {
  1789. for (var t = 0; t < this.onAnything.length; ++t)
  1790. this.onAnything[t]();
  1791. e.preventDefault()
  1792. }
  1793. .bind(this);
  1794. this.mouseStates = [{
  1795. pressed: !1,
  1796. position: [0, 0],
  1797. downPosition: [0, 0]
  1798. }, {
  1799. pressed: !1,
  1800. position: [0, 0],
  1801. downPosition: [0, 0]
  1802. }, {
  1803. pressed: !1,
  1804. position: [0, 0],
  1805. downPosition: [0, 0]
  1806. }],
  1807. this.lastTapPos = [0, 0],
  1808. e = function (e) {
  1809. if (e.target === this.element) {
  1810. this.mouseDownCount++;
  1811. var t = this.mouseStates[e.button];
  1812. if (t) {
  1813. t.pressed = !0;
  1814. var i = this.element.getBoundingClientRect();
  1815. t.position[0] = t.downPosition[0] = e.clientX - i.left,
  1816. t.position[1] = t.downPosition[1] = e.clientY - i.top,
  1817. m(e)
  1818. }
  1819. }
  1820. }
  1821. .bind(this),
  1822. this.element.addEventListener("mousedown", e),
  1823. e = function (e) {
  1824. var t = this.mouseStates[e.button];
  1825. if (t) {
  1826. var i = this.element.getBoundingClientRect(),
  1827. s = e.clientX - i.left;
  1828. i = e.clientY - i.top;
  1829. if (t.pressed = !1,
  1830. t.position[0] = s,
  1831. t.position[1] = i,
  1832. 0 == e.button && e.target == this.element && Math.abs(t.position[0] - t.downPosition[0]) + Math.abs(t.position[1] - t.downPosition[1]) < 10) {
  1833. for (var n = 0; n < this.onTap.length; ++n)
  1834. this.onTap[n](s, i);
  1835. if (this.needSingleClick = !0,
  1836. window.setTimeout(function (e, t) {
  1837. if (this.needSingleClick) {
  1838. for (var i = 0; i < this.onSingleTap.length; ++i)
  1839. this.onSingleTap[i](e, t);
  1840. this.needSingleClick = !1
  1841. }
  1842. }
  1843. .bind(this, s, i), 301),
  1844. t = !1,
  1845. void 0 !== this.doubleClickTimer && (n = Math.abs(s - this.lastTapPos[0]) + Math.abs(i - this.lastTapPos[1]) < 8,
  1846. Date.now() - this.doubleClickTimer < 300 && n))
  1847. for (t = !0,
  1848. this.needSingleClick = !1,
  1849. n = 0; n < this.onDoubleTap.length; ++n)
  1850. this.onDoubleTap[n](s, i);
  1851. this.doubleClickTimer = Date.now(),
  1852. t && (this.doubleClickTimer = -1e9),
  1853. this.lastTapPos[0] = s,
  1854. this.lastTapPos[1] = i
  1855. }
  1856. }
  1857. m(e)
  1858. }
  1859. .bind(this),
  1860. this.element.addEventListener("mouseup", e),
  1861. e = function (e) {
  1862. for (var t = !1, i = this.element.getBoundingClientRect(), s = 0; s < 3; ++s) {
  1863. var n = this.mouseStates[s];
  1864. if (n.pressed) {
  1865. webview.stopRotate();
  1866. t = e.clientX - i.left;
  1867. var r = e.clientY - i.top,
  1868. a = t - n.position[0],
  1869. o = r - n.position[1];
  1870. if (n.position[0] = t,
  1871. n.position[1] = r,
  1872. 2 == s && e.altKey)
  1873. for (n = 0; n < this.onZoom.length; ++n)
  1874. this.onZoom[n](2 * o);
  1875. else if (1 <= s || e.ctrlKey)
  1876. for (n = 0; n < this.onPan.length; ++n)
  1877. this.onPan[n](a, o);
  1878. else if (0 == s)
  1879. if (e.shiftKey)
  1880. for (n = 0; n < this.onPan2.length; ++n)
  1881. this.onPan2[n](a, o);
  1882. else
  1883. for (n = 0; n < this.onDrag.length; ++n)
  1884. this.onDrag[n](t, r, a, o);
  1885. t = !0
  1886. }
  1887. }
  1888. t && m(e)
  1889. }
  1890. .bind(this),
  1891. this.element.addEventListener("mousemove", e),
  1892. e = function (e) {
  1893. var t = 0;
  1894. e.deltaY ? (t = -.4 * e.deltaY,
  1895. 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);
  1896. for (var i = 0; i < this.onZoom.length; ++i)
  1897. this.onZoom[i](t);
  1898. m(e)
  1899. }
  1900. .bind(this),
  1901. this.element.addEventListener("mousewheel", e),
  1902. this.element.addEventListener("DOMMouseScroll", e),
  1903. this.element.addEventListener("wheel", e),
  1904. e = function (e) {
  1905. for (var t = 0; t < this.mouseStates.length; ++t)
  1906. this.mouseStates[t].pressed = !1;
  1907. e.preventDefault()
  1908. }
  1909. .bind(this),
  1910. this.element.addEventListener("mouseleave", e),
  1911. this.element.addEventListener("contextmenu", function (e) {
  1912. e.preventDefault()
  1913. }),
  1914. this.touches = {},
  1915. this.tapPossible = !1,
  1916. this.touchCountFloor = 0,
  1917. e = function (e) {
  1918. for (var t = this.element.getBoundingClientRect(), i = !1, s = 0; s < e.changedTouches.length; ++s)
  1919. if (e.target === this.element) {
  1920. var n = e.changedTouches[s];
  1921. (i = {
  1922. x: n.clientX - t.left,
  1923. y: n.clientY - t.top
  1924. }).startX = i.x,
  1925. i.startY = i.y,
  1926. this.touches[n.identifier] = i,
  1927. i = !0
  1928. }
  1929. for (this.tapPossible = 1 == e.touches.length,
  1930. n = t = 0; n < this.touches.length; ++n)
  1931. t++;
  1932. t > this.touchCountFloor && (this.touchCountFloor = t),
  1933. i && m(e)
  1934. }
  1935. .bind(this),
  1936. this.element.addEventListener("touchstart", e),
  1937. e = function (e) {
  1938. for (var t = !1, i = 0; i < e.changedTouches.length; ++i) {
  1939. var s = e.changedTouches[i],
  1940. n = this.touches[s.identifier];
  1941. if (n) {
  1942. if (this.tapPossible) {
  1943. var r = this.element.getBoundingClientRect();
  1944. t = s.clientX - r.left,
  1945. r = s.clientY - r.top;
  1946. if (Math.max(Math.abs(t - n.startX), Math.abs(r - n.startY)) < 24) {
  1947. for (i = 0; i < this.onTap.length; ++i)
  1948. this.onTap[i](t, r);
  1949. if (this.needSingleTap = !0,
  1950. window.setTimeout(function (e, t) {
  1951. if (this.needSingleTap) {
  1952. for (var i = 0; i < this.onSingleTap.length; ++i)
  1953. this.onSingleTap[i](e, t);
  1954. this.needSingleTap = !1
  1955. }
  1956. }
  1957. .bind(this, t, r), 501),
  1958. n = !1,
  1959. void 0 !== this.doubleTapTimer) {
  1960. var a = Math.max(Math.abs(t - this.lastTapPos[0]), Math.abs(r - this.lastTapPos[1])) < 24,
  1961. o = Date.now() - this.doubleTapTimer < 500;
  1962. if (a && o)
  1963. for (n = !0,
  1964. i = 0; i < this.onDoubleTap.length; ++i)
  1965. this.onDoubleTap[i](t, r)
  1966. }
  1967. this.doubleTapTimer = Date.now(),
  1968. n && (this.doubleTapTimer = -1e9),
  1969. this.lastTapPos[0] = t,
  1970. this.lastTapPos[1] = r
  1971. }
  1972. this.tapPossible = !1
  1973. }
  1974. delete this.touches[s.identifier],
  1975. t = !0
  1976. }
  1977. }
  1978. for (s = i = 0; s < this.touches.length; ++s)
  1979. i++;
  1980. i <= 0 && (this.touchCountFloor = 0),
  1981. t && m(e)
  1982. }
  1983. .bind(this),
  1984. this.element.addEventListener("touchend", e),
  1985. this.element.addEventListener("touchcancel", e),
  1986. this.element.addEventListener("touchleave", e),
  1987. e = function (e) {
  1988. webview.stopRotate();
  1989. for (var t = [], i = 0; i < e.touches.length; ++i)
  1990. e.touches[i].target === this.element && t.push(e.touches[i]);
  1991. var s = this.element.getBoundingClientRect();
  1992. if (1 == t.length && this.touchCountFloor <= 1) {
  1993. var n = t[0],
  1994. r = this.touches[n.identifier];
  1995. if (r) {
  1996. var a = n.clientX - s.left,
  1997. o = (n = n.clientY - s.top,
  1998. s = a - r.x,
  1999. n - r.y);
  2000. for (r.x = a,
  2001. r.y = n,
  2002. i = 0; i < this.onDrag.length; ++i)
  2003. this.onDrag[i](a, n, s, o, e.shiftKey)
  2004. }
  2005. } else if (2 == t.length && this.touchCountFloor <= 2) {
  2006. if (o = t[0],
  2007. i = this.touches[o.identifier],
  2008. n = t[1],
  2009. r = this.touches[n.identifier],
  2010. i && r) {
  2011. a = o.clientX - s.left,
  2012. o = o.clientY - s.top;
  2013. var h = n.clientX - s.left,
  2014. l = n.clientY - s.top,
  2015. d = Math.sqrt((a - h) * (a - h) + (o - l) * (o - l)),
  2016. c = Math.sqrt((i.x - r.x) * (i.x - r.x) + (i.y - r.y) * (i.y - r.y)),
  2017. u = Math.abs(d - c),
  2018. f = (s = (a - i.x + h - r.x) / 2,
  2019. n = (o - i.y + l - r.y) / 2,
  2020. Math.sqrt(s * s + n * n));
  2021. if (i.x = a,
  2022. i.y = o,
  2023. r.x = h,
  2024. r.y = l,
  2025. 0 < u)
  2026. for (r = u / (u + f),
  2027. i = 0; i < this.onZoom.length; ++i)
  2028. this.onZoom[i](2 * (d - c) * r);
  2029. if (0 < f)
  2030. for (r = f / (u + f),
  2031. i = 0; i < this.onDrag.length; ++i)
  2032. this.onPan[i](s * r, n * r)
  2033. }
  2034. } else if (3 <= t.length) {
  2035. for (i = c = d = h = o = 0; i < t.length; ++i)
  2036. n = t[i],
  2037. r = this.touches[n.identifier],
  2038. d += a = n.clientX - s.left,
  2039. c += n = n.clientY - s.top,
  2040. r && (o += r.x,
  2041. h += r.y,
  2042. r.x = a,
  2043. r.y = n);
  2044. for (o /= t.length,
  2045. h /= t.length,
  2046. d /= t.length,
  2047. c /= t.length,
  2048. i = 0; i < this.onPan2.length; ++i)
  2049. this.onPan2[i](d - o, c - h)
  2050. }
  2051. 0 < t.length && m(e)
  2052. }
  2053. .bind(this),
  2054. this.element.addEventListener("touchmove", e)
  2055. },
  2056. x.prototype.getLightPos = function (e) {
  2057. return this.positionBuffer.subarray(4 * e, 4 * e + 4)
  2058. },
  2059. x.prototype.setLightDistance = function (e, t) {
  2060. t <= 0 && (t = 1e-5),
  2061. this.parameters[3 * e + 2] = 1 / t
  2062. },
  2063. x.prototype.setLightSpotAngle = function (e, t) {
  2064. t <= 0 && (t = 1e-6),
  2065. this.spot[3 * e] = t;
  2066. var i = Math.sin(3.1415926 / 180 * t / 2);
  2067. this.spot[3 * e + 2] = 1 / (i * i) * this.spot[3 * e + 1]
  2068. },
  2069. x.prototype.setLightSpotSharpness = function (e, t) {
  2070. this.spot[3 * e + 1] = t,
  2071. this.setLightSpotAngle(this.spot[3 * e])
  2072. },
  2073. x.prototype.setLightPos = function (e, t) {
  2074. this.positions[4 * e + 0] = t[0],
  2075. this.positions[4 * e + 1] = t[1],
  2076. this.positions[4 * e + 2] = t[2];
  2077. var i = this.positions.subarray(4 * e, 4 * e + 4);
  2078. 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])
  2079. },
  2080. x.prototype.setLightDir = function (e, t) {
  2081. this.directions[3 * e + 0] = t[0],
  2082. this.directions[3 * e + 1] = t[1],
  2083. this.directions[3 * e + 2] = t[2];
  2084. var i = this.directions.subarray(3 * e, 3 * e + 3);
  2085. 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])
  2086. },
  2087. x.prototype.getLightColor = function (e) {
  2088. return this.colors.subarray(3 * e, 3 * e + 3)
  2089. },
  2090. x.prototype.setLightColor = function (e, t) {
  2091. this.colors[3 * e + 0] = t[0],
  2092. this.colors[3 * e + 1] = t[1],
  2093. this.colors[3 * e + 2] = t[2]
  2094. },
  2095. x.prototype.getLightDir = function (e) {
  2096. return this.directionBuffer.subarray(3 * e, 3 * e + 3)
  2097. },
  2098. x.prototype.getColor = function (e) {
  2099. return e *= 3,
  2100. [this.colors[e], this.colors[e + 1], this.colors[e + 2]]
  2101. },
  2102. x.prototype.update = function (e, t) {
  2103. var i = new S.type(this.matrix);
  2104. S.rotation(this.matrix, this.rotation, 1),
  2105. S.transpose(this.invMatrix, this.matrix);
  2106. for (var s = 0; s < this.count; ++s) {
  2107. var n = this.positions.subarray(4 * s, 4 * s + 4),
  2108. r = this.directions.subarray(3 * s, 3 * s + 3),
  2109. a = this.getLightPos(s),
  2110. o = this.getLightDir(s);
  2111. 1 == this.matrixWeights[s] ? (a[0] = n[0],
  2112. a[1] = n[1],
  2113. a[2] = n[2],
  2114. a[3] = n[3],
  2115. o[0] = r[0],
  2116. o[1] = r[1],
  2117. o[2] = r[2]) : 2 == this.matrixWeights[s] ? (S.mul4(a, e.transform, n[0], n[1], n[2], n[3]),
  2118. S.mulVec(o, e.transform, r[0], r[1], r[2]),
  2119. S.mul4(a, this.matrix, a[0], a[1], a[2], a[3]),
  2120. S.mulVec(o, this.matrix, o[0], o[1], o[2])) : (S.mul4(a, this.matrix, n[0], n[1], n[2], n[3]),
  2121. S.mulVec(o, this.matrix, r[0], r[1], r[2])),
  2122. V.normalize(o, o)
  2123. }
  2124. r = new Float32Array(this.finalTransformBuffer),
  2125. a = S.empty(),
  2126. o = S.empty();
  2127. var h = S.empty(),
  2128. l = V.empty(),
  2129. d = V.empty(),
  2130. c = V.empty(),
  2131. u = V.empty(),
  2132. f = (n = V.empty(),
  2133. []),
  2134. m = [],
  2135. p = S.create(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1);
  2136. for (s = 0; s < this.count; ++s) {
  2137. for (l = this.getLightPos(s),
  2138. d = this.getLightDir(s),
  2139. .99 < Math.abs(d[1]) ? V.set(c, 1, 0, 0) : V.set(c, 0, 1, 0),
  2140. V.cross(u, c, d),
  2141. V.normalize(u, u),
  2142. V.cross(c, d, u),
  2143. V.normalize(c, c),
  2144. 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),
  2145. l = 0; l < 8; ++l)
  2146. n[0] = 1 & l ? t.max[0] : t.min[0],
  2147. n[1] = 2 & l ? t.max[1] : t.min[1],
  2148. n[2] = 4 & l ? t.max[2] : t.min[2],
  2149. S.mulPoint(n, this.matrix, 1.005 * n[0], 1.005 * n[1], 1.005 * n[2]),
  2150. S.mulPoint(n, a, n[0], n[1], n[2]),
  2151. 0 == l ? (f[0] = m[0] = n[0],
  2152. f[1] = m[1] = n[1],
  2153. f[2] = m[2] = n[2]) : (f[0] = Math.min(f[0], n[0]),
  2154. f[1] = Math.min(f[1], n[1]),
  2155. f[2] = Math.min(f[2], n[2]),
  2156. m[0] = Math.max(m[0], n[0]),
  2157. m[1] = Math.max(m[1], n[1]),
  2158. m[2] = Math.max(m[2], n[2]));
  2159. l = -f[2],
  2160. d = -m[2];
  2161. var g = this.spot[3 * s];
  2162. 0 < g ? (l = Math.min(l, 1 / this.parameters[3 * s + 2]),
  2163. d = Math.max(.04 * l, d),
  2164. S.perspective(o, g, 1, d, l),
  2165. s < this.shadowCount && (l = 2 * -Math.tan(.00872664625 * g),
  2166. this.shadowTexelPadProjections[4 * s + 0] = this.modelViewBuffer[16 * s + 2] * l,
  2167. this.shadowTexelPadProjections[4 * s + 1] = this.modelViewBuffer[16 * s + 6] * l,
  2168. this.shadowTexelPadProjections[4 * s + 2] = this.modelViewBuffer[16 * s + 10] * l,
  2169. this.shadowTexelPadProjections[4 * s + 3] = this.modelViewBuffer[16 * s + 14] * l)) : (S.ortho(o, f[0], m[0], f[1], m[1], d, l),
  2170. s < this.shadowCount && (this.shadowTexelPadProjections[4 * s + 0] = this.shadowTexelPadProjections[4 * s + 1] = this.shadowTexelPadProjections[4 * s + 2] = 0,
  2171. this.shadowTexelPadProjections[4 * s + 3] = Math.max(m[0] - f[0], m[1] - f[1]))),
  2172. S.mul(h, o, a),
  2173. S.mul(h, p, h),
  2174. S.copyToBuffer(this.modelViewBuffer, 16 * s, a),
  2175. S.copyToBuffer(this.projectionBuffer, 16 * s, o),
  2176. S.copyToBuffer(this.finalTransformBuffer, 16 * s, h),
  2177. S.invert(h, h),
  2178. S.copyToBuffer(this.inverseTransformBuffer, 16 * s, h)
  2179. }
  2180. for (n = !1,
  2181. s = 0; s < i.length; ++s)
  2182. if (i[s] != this.matrix[s]) {
  2183. n = !0;
  2184. break
  2185. }
  2186. for (s = 0; s < this.shadowCount; s++)
  2187. if (n && 1 == this.matrixWeights[s])
  2188. this.shadowsNeedUpdate[s] = 1;
  2189. else
  2190. for (i = 16 * s; i < 16 * s + 16; ++i)
  2191. if (r[i] != this.finalTransformBuffer[i]) {
  2192. this.shadowsNeedUpdate[s] = 1;
  2193. break
  2194. }
  2195. },
  2196. x.prototype.flagUpdateAnimatedLighting = function () {
  2197. for (var e = 0; e < this.shadowCount; e++)
  2198. this.shadowsNeedUpdate[e] = 1
  2199. },
  2200. y.prototype.linkControl = function (e) {
  2201. this.controlRect.linkControl(e)
  2202. },
  2203. y.prototype.spawnControl = function (e, t, i, s, n, r) {
  2204. var a = "backgroundTopLE" + (w = this.guiScreen.imageSetNumber) + "x.png",
  2205. o = "backgroundTopM" + w + "x.png",
  2206. h = "backgroundTopRE" + w + "x.png",
  2207. l = "backgroundMiddleLE" + w + "x.png",
  2208. d = "backgroundMiddleM" + w + "x.png",
  2209. c = "backgroundMiddleRE" + w + "x.png",
  2210. u = "backgroundBottomLE" + w + "x.png",
  2211. f = "backgroundBottomM" + w + "x.png",
  2212. m = "backgroundBottomRE" + w + "x.png",
  2213. p = 3 * w,
  2214. g = "backgroundLE" + w + "x.png",
  2215. v = "backgroundM" + w + "x.png",
  2216. x = "backgroundRE" + w + "x.png",
  2217. y = 2 * w,
  2218. b = "spacerLE" + w + "x.png",
  2219. S = "spacerM" + w + "x.png",
  2220. T = "spacerRE" + w + "x.png",
  2221. w = 2 * w,
  2222. C = this.controlRect.guiScreen.width,
  2223. R = this.controlRect.guiScreen.height;
  2224. if (n) {
  2225. n = this.textEntries.length;
  2226. var A = i;
  2227. for (i = 0; i < n; i++) {
  2228. var k = 8 * (this.textEntries[i] ? this.textEntries[i].length : 0);
  2229. A < k && (A = k)
  2230. }
  2231. i = A + r
  2232. }
  2233. for (r = 1 / (n = this.textEntries.length + 1),
  2234. this.localPixelsX = i,
  2235. this.listBoxEntryHeight = s,
  2236. this.localPixelsY = (this.textEntries.length + 1) * this.listBoxEntryHeight,
  2237. i = 8 / this.localPixelsY,
  2238. s = 6 / this.localPixelsX,
  2239. A = 4 / this.localPixelsX,
  2240. k = r - i / 4,
  2241. this.labelTextHeight = I.largeUI ? 20 : 16,
  2242. this.labelPixelDrop = (this.listBoxEntryHeight - this.labelTextHeight) / 2,
  2243. this.listBoxRegion.controlRect.widthPercent = this.localPixelsX / C,
  2244. this.listBoxRegion.controlRect.heightPercent = this.localPixelsY / R,
  2245. this.listBoxRegion.controlRect.xPercent = e / C,
  2246. this.listBoxRegion.controlRect.yPercent = t / R,
  2247. this.openBackground = this.listBoxRegion.addTextButton("", 0, 0, 1, 1 + i, 1),
  2248. this.openBackground.setBackground3x3(this.listBoxRegion, 0, 0, a, o, h, l, d, c, u, f, m, p, p),
  2249. this.closedBackground = this.listBoxRegion.addTextButton("", 0, 0, 1, r, 1),
  2250. this.closedBackground.setBackground3x1(this.listBoxRegion, 0, 0, g, v, x, y),
  2251. e = this.labelPixelInset + this.textOffsetsX[0],
  2252. t = this.labelPixelDrop + this.textOffsetsY[0],
  2253. t /= this.localPixelsY,
  2254. e /= this.localPixelsX,
  2255. this.defaultButton = this.listBoxRegion.addTextButton("Selected", e, -t, 1, r, .5),
  2256. this.selectedIndex = 0,
  2257. this.defaultButton.controlRect.linkedControl.innerHTML = this.textEntries[this.selectedIndex],
  2258. this.defaultButton.linkedBackground = this.closedBackground,
  2259. this.spacerControl = this.listBoxRegion.addTextButton("", s, k, 1 - (s + A), i, 1),
  2260. this.spacerControl.defaultAlpha = 1,
  2261. this.spacerControl.setBackground3x1(this.listBoxRegion, 0, 0, b, S, T, w),
  2262. this.spacerControl.setVisible(!1),
  2263. this.spacerControl.linkedBackground = this.openBackground,
  2264. i = 1; i < n; i++)
  2265. e = this.labelPixelInset + this.textOffsetsX[i - 1],
  2266. t = this.labelPixelDrop + this.textOffsetsY[i - 1] - 4,
  2267. e /= this.localPixelsX,
  2268. t /= this.localPixelsY,
  2269. b = this.listBoxRegion.addTextButton(this.textEntries[i - 1], e, r * i - t, 1 - e, r, .5),
  2270. this.listBoxButtons.push(b),
  2271. b.linkedBackground = this.openBackground;
  2272. this.showList(!1),
  2273. this.setupCallbacks()
  2274. },
  2275. y.prototype.setControl = function (e, t, i, s, n, r) {
  2276. var a = this.controlRect.guiScreen.width,
  2277. o = this.controlRect.guiScreen.height;
  2278. if (n) {
  2279. n = this.textEntries.length;
  2280. for (var h = 0; h < n; h++) {
  2281. var l = 8 * (this.textEntries[h] ? this.textEntries[h].length : 0);
  2282. i < l && (i = l)
  2283. }
  2284. i += r
  2285. }
  2286. this.localPixelsX = i,
  2287. this.listBoxEntryHeight = s,
  2288. this.localPixelsY = (this.textEntries.length + 1) * this.listBoxEntryHeight,
  2289. this.listBoxRegion.controlRect.widthPercent = this.localPixelsX / a,
  2290. this.listBoxRegion.controlRect.heightPercent = this.localPixelsY / o,
  2291. this.listBoxRegion.controlRect.xPercent = e / a,
  2292. this.listBoxRegion.controlRect.yPercent = t / o,
  2293. this.listBoxRegion.controlRect.updateChildElements(),
  2294. this.spacerControl.alignBackground(),
  2295. this.openBackground.alignBackground(),
  2296. this.closedBackground.alignBackground()
  2297. },
  2298. y.prototype.addItem = function (e, t, i) {
  2299. this.textEntries.push(e),
  2300. this.textOffsetsX.push(t),
  2301. this.textOffsetsY.push(i)
  2302. },
  2303. y.prototype.showList = function (e) {
  2304. for (var t = this.listBoxButtons.length, i = 0; i < t; i++)
  2305. this.listBoxButtons[i].setVisible(e);
  2306. this.closed = !e,
  2307. this.spacerControl && this.spacerControl.setVisible(e),
  2308. this.openBackground && this.openBackground.setVisible(e),
  2309. this.closedBackground && this.closedBackground.setVisible(!e),
  2310. e ? (this.defaultButton.linkedBackground = this.openBackground,
  2311. this.openBackground.setOpacity(1),
  2312. this.closedBackground.setOpacity(.5)) : this.defaultButton.linkedBackground = this.closedBackground
  2313. },
  2314. y.prototype.selectItem = function (e) {
  2315. this.selectedItemText = this.textEntries[e],
  2316. this.selectedIndex = e,
  2317. this.defaultButton.controlRect.linkedControl.innerHTML = this.textEntries[this.selectedIndex],
  2318. e = (this.labelTextHeight - this.listBoxEntryHeight + 3) / this.localPixelsY,
  2319. this.defaultButton.controlRect.xPercent = (this.labelPixelInset + this.textOffsetsX[this.selectedIndex]) / this.localPixelsX,
  2320. this.defaultButton.controlRect.yPercent = e,
  2321. this.defaultButton.controlRect.updateElement()
  2322. },
  2323. y.prototype.setupCallbacks = function () {
  2324. var e = function (e) {
  2325. if (this.closed) {
  2326. var t = (t = this.closedBackground.controlRect.linkedControl).getBoundingClientRect(),
  2327. i = e.clientX - t.left;
  2328. e = e.clientY - t.top,
  2329. i /= t.width,
  2330. t = e / t.height,
  2331. 0 <= i && i <= 1 && 0 <= t && t <= 1 ? this.closedBackground.setOpacity(1) : this.closedBackground.setOpacity(.5)
  2332. } else
  2333. t = (t = this.openBackground.controlRect.linkedControl).getBoundingClientRect(),
  2334. i = e.clientX - t.left,
  2335. e = e.clientY - t.top,
  2336. i /= t.width,
  2337. t = e / t.height,
  2338. 0 <= i && i <= 1 && 0 <= t && t <= 1 ? this.openBackground.setOpacity(1) : this.openBackground.setOpacity(.5)
  2339. }
  2340. .bind(this);
  2341. this.defaultButton.controlRect.linkedControl.onclick = function () {
  2342. this.closed ? this.showList(!0) : (this.showList(this.closed),
  2343. this.closedBackground.setOpacity(1),
  2344. this.defaultButton.setOpacity(1))
  2345. }
  2346. .bind(this);
  2347. for (var t = function (e) {
  2348. this.selectItem(e.id),
  2349. this.showList(!1),
  2350. this.defaultButton.setOpacity(.5),
  2351. this.selectionChangedCallback && this.selectionChangedCallback(this)
  2352. }
  2353. .bind(this), i = function (e) {
  2354. e = this.listBoxButtons.length;
  2355. for (var t = 0; t < e; t++)
  2356. this.listBoxButtons[t].controlRect.mouseOver && (this.selectItem(t),
  2357. t = e,
  2358. this.selectionChangedCallback && this.selectionChangedCallback(this));
  2359. this.showList(!1)
  2360. }
  2361. .bind(this), s = this.listBoxButtons.length, n = 0; n < s; n++)
  2362. this.listBoxButtons[n].controlRect.callBack = t,
  2363. this.listBoxButtons[n].controlRect.id = n,
  2364. this.listBoxButtons[n].controlRect.linkedControl.addEventListener("mousemove", e);
  2365. this.guiScreen.ui.viewer.input.element.addEventListener("mousemove", e),
  2366. this.openBackground.controlRect.linkedControl.addEventListener("mousemove", e),
  2367. this.closedBackground.controlRect.linkedControl.addEventListener("mousemove", e),
  2368. this.guiScreen.ui.viewer.input.element.addEventListener("mousedown", i)
  2369. },
  2370. b.prototype.bind = function (e, t) {
  2371. if (!this.complete())
  2372. return !1;
  2373. var i, s = e.view,
  2374. n = e.lights,
  2375. r = e.sky,
  2376. a = e.shadow,
  2377. o = e.stripData.active() ? this.stripShader : this.shader,
  2378. h = this.skinParams,
  2379. l = this.anisoParams,
  2380. d = this.microfiberParams,
  2381. c = this.gl,
  2382. u = o.params,
  2383. f = this.textures,
  2384. m = o.samplers;
  2385. o.bind(),
  2386. this.blend();
  2387. var p = t.mesh.displayMatrix,
  2388. g = S.mul(S.empty(), s.viewMatrix, p),
  2389. v = S.mul(S.empty(), s.projectionMatrix, s.viewMatrix);
  2390. g = S.mul(S.empty(), s.projectionMatrix, g),
  2391. p = S.mul(S.empty(), n.matrix, p);
  2392. return c.uniformMatrix4fv(u.uModelViewProjectionMatrix, !1, g),
  2393. c.uniformMatrix4fv(u.uSkyMatrix, !1, p),
  2394. p = S.mulPoint(V.empty(), n.matrix, s.transform[12], s.transform[13], s.transform[14]),
  2395. c.uniform3f(u.uCameraPosition, p[0], p[1], p[2]),
  2396. c.uniform3fv(u.uFresnel, this.fresnel),
  2397. c.uniform1f(u.uAlphaTest, this.alphaTest),
  2398. c.uniform1f(u.uHorizonOcclude, this.horizonOcclude),
  2399. c.uniform1f(u.uHorizonSmoothing, this.horizonSmoothing),
  2400. c.uniform4fv(u.uDiffuseCoefficients, r.diffuseCoefficients),
  2401. 0 < n.count && (c.uniform4fv(u.uLightPositions, n.positionBuffer),
  2402. c.uniform3fv(u.uLightDirections, n.directionBuffer),
  2403. c.uniform3fv(u.uLightColors, n.colors),
  2404. c.uniform3fv(u.uLightParams, n.parameters),
  2405. c.uniform3fv(u.uLightSpot, n.spot),
  2406. p = .392699 * e.postRender.currentSample(),
  2407. c.uniform2f(u.uShadowKernelRotation, .5 * Math.cos(p), .5 * Math.sin(p)),
  2408. 0 < n.shadowCount && (p = a.depthTextures[0].desc.width,
  2409. c.uniform2f(u.uShadowMapSize, p, 1 / p),
  2410. c.uniformMatrix4fv(u.uShadowMatrices, !1, n.finalTransformBuffer),
  2411. c.uniformMatrix4fv(u.uInvShadowMatrices, !1, n.inverseTransformBuffer),
  2412. c.uniform4fv(u.uShadowTexelPadProjections, n.shadowTexelPadProjections),
  2413. a.bindDepthTexture(m.tDepth0, 0),
  2414. a.bindDepthTexture(m.tDepth1, 1),
  2415. a.bindDepthTexture(m.tDepth2, 2))),
  2416. h && (c.uniform3fv(u.uSubdermisColor, h.subdermisColor),
  2417. c.uniform4fv(u.uTransColor, h.transColor),
  2418. c.uniform1f(u.uTransScatter, h.transScatter),
  2419. c.uniform4fv(u.uFresnelColor, h.fresnelColor),
  2420. c.uniform1f(u.uFresnelOcc, h.fresnelOcc),
  2421. c.uniform1f(u.uFresnelGlossMask, h.fresnelGlossMask),
  2422. c.uniform1f(u.uFresnelIntegral, h.fresnelIntegral),
  2423. c.uniform1f(u.uTransIntegral, h.transIntegral),
  2424. c.uniform1f(u.uSkinTransDepth, h.transDepth),
  2425. c.uniform1f(u.uTransSky, h.transSky),
  2426. c.uniform1f(u.uSkinShadowBlur, h.shadowBlur),
  2427. c.uniform1f(u.uNormalSmooth, h.normalSmooth),
  2428. (i = this.extrasTexCoordRanges.subdermisTex) && c.uniform4fv(u.uTexRangeSubdermis, i),
  2429. (i = this.extrasTexCoordRanges.translucencyTex) && c.uniform4fv(u.uTexRangeTranslucency, i),
  2430. (i = this.extrasTexCoordRanges.fuzzTex) && c.uniform4fv(u.uTexRangeFuzz, i)),
  2431. d && (c.uniform4fv(u.uFresnelColor, d.fresnelColor),
  2432. c.uniform1f(u.uFresnelOcc, d.fresnelOcc),
  2433. c.uniform1f(u.uFresnelGlossMask, d.fresnelGlossMask),
  2434. c.uniform1f(u.uFresnelIntegral, d.fresnelIntegral),
  2435. (i = this.extrasTexCoordRanges.fuzzTex) && c.uniform4fv(u.uTexRangeFuzz, i)),
  2436. l && (c.uniform3fv(u.uAnisoTangent, l.tangent),
  2437. c.uniform1f(u.uAnisoStrength, l.strength),
  2438. c.uniform1f(u.uAnisoIntegral, l.integral),
  2439. (i = this.extrasTexCoordRanges.anisoTex) && c.uniform4fv(u.uTexRangeAniso, i)),
  2440. this.usesRefraction && (e.refractionSurface && e.refractionSurface.bind(m.tRefraction),
  2441. n = S.mul(S.empty(), v, n.invMatrix),
  2442. c.uniformMatrix4fv(u.uRefractionViewProjection, !1, n),
  2443. c.uniform1f(u.uRefractionRayDistance, this.refractionParams.distantBackground ? 1e10 : 4 * t.mesh.bounds.maxExtent),
  2444. c.uniform3fv(u.uRefractionTint, this.refractionParams.tint),
  2445. c.uniform1f(u.uRefractionAlbedoTint, this.refractionParams.useAlbedoTint ? 1 : 0),
  2446. c.uniform1f(u.uRefractionIOREntry, 1 / this.refractionParams.IOR),
  2447. (i = this.extrasTexCoordRanges.refractionMaskTex) && c.uniform4fv(u.uTexRangeRefraction, i)),
  2448. (i = this.extrasTexCoordRanges.emissiveTex) && (c.uniform4fv(u.uTexRangeEmissive, i),
  2449. c.uniform1f(u.uEmissiveScale, this.emissiveIntensity)),
  2450. (i = this.extrasTexCoordRanges.aoTex) && c.uniform4fv(u.uTexRangeAO, i),
  2451. f.albedo.bind(m.tAlbedo),
  2452. f.reflectivity.bind(m.tReflectivity),
  2453. f.normal.bind(m.tNormal),
  2454. f.extras.bind(m.tExtras),
  2455. r.specularTexture.bind(m.tSkySpecular),
  2456. o === this.stripShader && (c.uniform1fv(u.uStrips, e.stripData.strips),
  2457. c.uniform2f(u.uStripRes, 2 / s.size[0], 2 / s.size[1])),
  2458. c.uniform2f(u.uUVOffset, this.uOffset, this.vOffset),
  2459. !0
  2460. },
  2461. b.prototype.bindAlphaPrepass = function (e, t) {
  2462. if (!this.complete() || !this.prepassShader)
  2463. return !1;
  2464. var i = this.gl,
  2465. s = this.prepassShader.params,
  2466. n = this.prepassShader.samplers;
  2467. this.prepassShader.bind();
  2468. var r = S.mul(S.empty(), e.view.viewMatrix, t.mesh.displayMatrix);
  2469. r = S.mul(S.empty(), e.view.projectionMatrix, r);
  2470. return i.uniformMatrix4fv(s.uModelViewProjectionMatrix, !1, r),
  2471. i.uniform2f(s.uUVOffset, this.uOffset, this.vOffset),
  2472. this.textures.albedo.bind(n.tAlbedo),
  2473. !0
  2474. },
  2475. b.prototype.bindWire = function (e, t) {
  2476. if (!this.complete())
  2477. return !1;
  2478. var i = this.gl,
  2479. s = this.wireShader.params,
  2480. n = e.view;
  2481. i.enable(i.BLEND),
  2482. i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA),
  2483. i.depthMask(!1),
  2484. this.wireShader.bind();
  2485. var r = S.mul(S.empty(), e.view.viewMatrix, t.mesh.displayMatrix);
  2486. r = S.mul(S.empty(), e.view.projectionMatrix, r);
  2487. return i.uniformMatrix4fv(s.uModelViewProjectionMatrix, !1, r),
  2488. i.uniform4f(s.uStripParams, 2 / n.size[0], 2 / n.size[1], e.stripData.strips[3], e.stripData.strips[4]),
  2489. !0
  2490. },
  2491. b.prototype.complete = function () {
  2492. 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()
  2493. };
  2494. var S = {
  2495. type: Float32Array,
  2496. create: function (e, t, i, s, n, r, a, o, h, l, d, c, u, f, m, p) {
  2497. var g = new S.type(16);
  2498. return g[0] = e,
  2499. g[4] = t,
  2500. g[8] = i,
  2501. g[12] = s,
  2502. g[1] = n,
  2503. g[5] = r,
  2504. g[9] = a,
  2505. g[13] = o,
  2506. g[2] = h,
  2507. g[6] = l,
  2508. g[10] = d,
  2509. g[14] = c,
  2510. g[3] = u,
  2511. g[7] = f,
  2512. g[11] = m,
  2513. g[15] = p,
  2514. g
  2515. },
  2516. empty: function () {
  2517. return new S.type(16)
  2518. },
  2519. identity: function () {
  2520. var e = new S.type(16);
  2521. return e[0] = 1,
  2522. e[4] = 0,
  2523. e[8] = 0,
  2524. e[12] = 0,
  2525. e[1] = 0,
  2526. e[5] = 1,
  2527. e[9] = 0,
  2528. e[13] = 0,
  2529. e[2] = 0,
  2530. e[6] = 0,
  2531. e[10] = 1,
  2532. e[14] = 0,
  2533. e[3] = 0,
  2534. e[7] = 0,
  2535. e[11] = 0,
  2536. e[15] = 1,
  2537. e
  2538. },
  2539. set: function (e, t, i, s, n, r, a, o, h, l, d, c, u, f, m, p, g) {
  2540. e[0] = t,
  2541. e[4] = i,
  2542. e[8] = s,
  2543. e[12] = n,
  2544. e[1] = r,
  2545. e[5] = a,
  2546. e[9] = o,
  2547. e[13] = h,
  2548. e[2] = l,
  2549. e[6] = d,
  2550. e[10] = c,
  2551. e[14] = u,
  2552. e[3] = f,
  2553. e[7] = m,
  2554. e[11] = p,
  2555. e[15] = g
  2556. },
  2557. translation: function (e, t, i, s) {
  2558. return S.set(e, 1, 0, 0, t, 0, 1, 0, i, 0, 0, 1, s, 0, 0, 0, 1),
  2559. e
  2560. },
  2561. rotation: function (e, t, i) {
  2562. e[0] = 1,
  2563. e[4] = 0,
  2564. e[8] = 0,
  2565. e[12] = 0,
  2566. e[1] = 0,
  2567. e[5] = 1,
  2568. e[9] = 0,
  2569. e[13] = 0,
  2570. e[2] = 0,
  2571. e[6] = 0,
  2572. e[10] = 1,
  2573. e[14] = 0,
  2574. e[3] = 0,
  2575. e[7] = 0,
  2576. e[11] = 0,
  2577. e[15] = 1;
  2578. var s = .0174532925 * t;
  2579. switch (t = Math.sin(s),
  2580. s = Math.cos(s),
  2581. i) {
  2582. case 0:
  2583. e[5] = s,
  2584. e[9] = -t,
  2585. e[6] = t,
  2586. e[10] = s;
  2587. break;
  2588. case 1:
  2589. e[0] = s,
  2590. e[8] = t,
  2591. e[2] = -t,
  2592. e[10] = s;
  2593. break;
  2594. case 2:
  2595. e[0] = s,
  2596. e[4] = -t,
  2597. e[1] = t,
  2598. e[5] = s
  2599. }
  2600. return e
  2601. },
  2602. mul: function (e, t, i) {
  2603. var s = t[0],
  2604. n = t[1],
  2605. r = t[2],
  2606. a = t[3],
  2607. o = t[4],
  2608. h = t[5],
  2609. l = t[6],
  2610. d = t[7],
  2611. c = t[8],
  2612. u = t[9],
  2613. f = t[10],
  2614. m = t[11],
  2615. p = t[12],
  2616. g = t[13],
  2617. v = t[14];
  2618. t = t[15];
  2619. var x = i[0],
  2620. y = i[1],
  2621. b = i[2],
  2622. S = i[3];
  2623. return e[0] = x * s + y * o + b * c + S * p,
  2624. e[1] = x * n + y * h + b * u + S * g,
  2625. e[2] = x * r + y * l + b * f + S * v,
  2626. e[3] = x * a + y * d + b * m + S * t,
  2627. x = i[4],
  2628. y = i[5],
  2629. b = i[6],
  2630. S = i[7],
  2631. e[4] = x * s + y * o + b * c + S * p,
  2632. e[5] = x * n + y * h + b * u + S * g,
  2633. e[6] = x * r + y * l + b * f + S * v,
  2634. e[7] = x * a + y * d + b * m + S * t,
  2635. x = i[8],
  2636. y = i[9],
  2637. b = i[10],
  2638. S = i[11],
  2639. e[8] = x * s + y * o + b * c + S * p,
  2640. e[9] = x * n + y * h + b * u + S * g,
  2641. e[10] = x * r + y * l + b * f + S * v,
  2642. e[11] = x * a + y * d + b * m + S * t,
  2643. x = i[12],
  2644. y = i[13],
  2645. b = i[14],
  2646. S = i[15],
  2647. e[12] = x * s + y * o + b * c + S * p,
  2648. e[13] = x * n + y * h + b * u + S * g,
  2649. e[14] = x * r + y * l + b * f + S * v,
  2650. e[15] = x * a + y * d + b * m + S * t,
  2651. e
  2652. },
  2653. invert: function (e, t) {
  2654. var i = t[0],
  2655. s = t[1],
  2656. n = t[2],
  2657. r = t[3],
  2658. a = t[4],
  2659. o = t[5],
  2660. h = t[6],
  2661. l = t[7],
  2662. d = t[8],
  2663. c = t[9],
  2664. u = t[10],
  2665. f = t[11],
  2666. m = t[12],
  2667. p = t[13],
  2668. g = t[14],
  2669. v = t[15],
  2670. x = i * o - s * a,
  2671. y = i * h - n * a,
  2672. b = i * l - r * a,
  2673. S = s * h - n * o,
  2674. T = s * l - r * o,
  2675. w = n * l - r * h,
  2676. C = d * p - c * m,
  2677. R = d * g - u * m,
  2678. A = d * v - f * m,
  2679. k = c * g - u * p,
  2680. I = c * v - f * p,
  2681. P = u * v - f * g,
  2682. F = x * P - y * I + b * k + S * A - T * R + w * C;
  2683. return F ? (F = 1 / F,
  2684. e[0] = (o * P - h * I + l * k) * F,
  2685. e[1] = (n * I - s * P - r * k) * F,
  2686. e[2] = (p * w - g * T + v * S) * F,
  2687. e[3] = (u * T - c * w - f * S) * F,
  2688. e[4] = (h * A - a * P - l * R) * F,
  2689. e[5] = (i * P - n * A + r * R) * F,
  2690. e[6] = (g * b - m * w - v * y) * F,
  2691. e[7] = (d * w - u * b + f * y) * F,
  2692. e[8] = (a * I - o * A + l * C) * F,
  2693. e[9] = (s * A - i * I - r * C) * F,
  2694. e[10] = (m * T - p * b + v * x) * F,
  2695. e[11] = (c * b - d * T - f * x) * F,
  2696. e[12] = (o * R - a * k - h * C) * F,
  2697. e[13] = (i * k - s * R + n * C) * F,
  2698. e[14] = (p * y - m * S - g * x) * F,
  2699. e[15] = (d * S - c * y + u * x) * F,
  2700. e) : null
  2701. },
  2702. transpose: function (e, t) {
  2703. return e[0] = t[0],
  2704. e[4] = t[1],
  2705. e[8] = t[2],
  2706. e[12] = t[3],
  2707. e[1] = t[4],
  2708. e[5] = t[5],
  2709. e[9] = t[6],
  2710. e[13] = t[7],
  2711. e[2] = t[8],
  2712. e[6] = t[9],
  2713. e[10] = t[10],
  2714. e[14] = t[11],
  2715. e[3] = t[12],
  2716. e[7] = t[13],
  2717. e[11] = t[14],
  2718. e[15] = t[15],
  2719. e
  2720. },
  2721. mul4: function (e, t, i, s, n, r) {
  2722. return e[0] = t[0] * i + t[4] * s + t[8] * n + t[12] * r,
  2723. e[1] = t[1] * i + t[5] * s + t[9] * n + t[13] * r,
  2724. e[2] = t[2] * i + t[6] * s + t[10] * n + t[14] * r,
  2725. e[3] = t[3] * i + t[7] * s + t[11] * n + t[15] * r,
  2726. e
  2727. },
  2728. mulPoint: function (e, t, i, s, n) {
  2729. return e[0] = t[0] * i + t[4] * s + t[8] * n + t[12],
  2730. e[1] = t[1] * i + t[5] * s + t[9] * n + t[13],
  2731. e[2] = t[2] * i + t[6] * s + t[10] * n + t[14],
  2732. e
  2733. },
  2734. mulVec: function (e, t, i, s, n) {
  2735. return e[0] = t[0] * i + t[4] * s + t[8] * n,
  2736. e[1] = t[1] * i + t[5] * s + t[9] * n,
  2737. e[2] = t[2] * i + t[6] * s + t[10] * n,
  2738. e
  2739. },
  2740. perspective: function (e, t, i, s, n, r) {
  2741. return r = r || 0,
  2742. t = 1 / Math.tan(.00872664625 * t),
  2743. e[0] = t / i,
  2744. e[1] = e[2] = e[3] = 0,
  2745. e[5] = t,
  2746. e[4] = e[6] = e[7] = 0,
  2747. e[8] = e[9] = 0,
  2748. e[10] = (n + s) / (s - n) - 30518044e-12 * r,
  2749. e[11] = -1,
  2750. e[14] = 2 * n * s / (s - n),
  2751. e[12] = e[13] = e[15] = 0,
  2752. e
  2753. },
  2754. perspectiveInfinite: function (e, t, i, s, n) {
  2755. return n = n || 0,
  2756. t = 1 / Math.tan(.00872664625 * t),
  2757. e[0] = t / i,
  2758. e[1] = e[2] = e[3] = 0,
  2759. e[5] = t,
  2760. e[4] = e[6] = e[7] = 0,
  2761. e[8] = e[9] = 0,
  2762. e[10] = e[11] = -1 - 30518044e-12 * n,
  2763. e[14] = -2 * s,
  2764. e[12] = e[13] = e[15] = 0,
  2765. e
  2766. },
  2767. ortho: function (e, t, i, s, n, r, a, o) {
  2768. var h = 1 / (i - t),
  2769. l = 1 / (n - s),
  2770. d = 1 / (a - r);
  2771. return e[0] = h + h,
  2772. e[1] = e[2] = e[3] = 0,
  2773. e[5] = l + l,
  2774. e[4] = e[6] = e[7] = 0,
  2775. e[12] = -(i + t) * h,
  2776. e[13] = -(n + s) * l,
  2777. e[10] = -(d + d) - 30518044e-12 * (o || 0),
  2778. e[14] = -(a + r) * d,
  2779. e[8] = e[9] = e[11] = 0,
  2780. e[15] = 1,
  2781. e
  2782. },
  2783. lookAt: function (e, t, i, s) {
  2784. var n = e.subarray(0, 3),
  2785. r = e.subarray(4, 7),
  2786. a = e.subarray(8, 11);
  2787. V.sub(a, t, i),
  2788. V.cross(n, s, a),
  2789. V.normalize(a, a),
  2790. V.normalize(n, n),
  2791. V.cross(r, a, n),
  2792. 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)
  2793. },
  2794. copy: function (e, t) {
  2795. for (var i = 0; i < 16; ++i)
  2796. e[i] = t[i]
  2797. },
  2798. copyToBuffer: function (e, t, i) {
  2799. for (var s = 0; s < 16; ++s)
  2800. e[t + s] = i[s]
  2801. }
  2802. };
  2803. function T(e, t, i) {
  2804. this.gl = e;
  2805. var s = (this.desc = t).isDynamicMesh;
  2806. this.numSubMeshes = this.dynamicVertexData = 0,
  2807. this.displayMatrix = S.identity(),
  2808. this.name = t.name,
  2809. this.modelMatrix = S.identity(),
  2810. this.origin = t.transform ? V.create(t.transform[12], t.transform[13], t.transform[14], 1) : V.create(0, 5, 0, 1),
  2811. this.stride = 32,
  2812. (this.vertexColor = t.vertexColor) && (this.stride += 4),
  2813. (this.secondaryTexCoord = t.secondaryTexCoord) && (this.stride += 8),
  2814. i = new u(i.data),
  2815. this.indexCount = t.indexCount,
  2816. this.indexTypeSize = t.indexTypeSize,
  2817. this.indexType = 4 == this.indexTypeSize ? e.UNSIGNED_INT : e.UNSIGNED_SHORT,
  2818. this.indexBuffer = e.createBuffer(),
  2819. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
  2820. var n = i.readBytes(this.indexCount * this.indexTypeSize);
  2821. e.bufferData(e.ELEMENT_ARRAY_BUFFER, n, e.STATIC_DRAW),
  2822. this.wireCount = t.wireCount,
  2823. this.wireBuffer = e.createBuffer(),
  2824. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.wireBuffer),
  2825. n = i.readBytes(this.wireCount * this.indexTypeSize),
  2826. e.bufferData(e.ELEMENT_ARRAY_BUFFER, n, e.STATIC_DRAW),
  2827. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null),
  2828. this.vertexCount = t.vertexCount,
  2829. this.vertexBuffer = e.createBuffer(),
  2830. e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer),
  2831. i = i.readBytes(this.vertexCount * this.stride),
  2832. s ? (this.dynamicVertexData = new Uint8Array(i),
  2833. e.bufferData(e.ARRAY_BUFFER, i, e.DYNAMIC_DRAW)) : e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  2834. e.bindBuffer(e.ARRAY_BUFFER, null),
  2835. this.bounds = void 0 === t.minBound || void 0 === t.maxBound ? {
  2836. min: V.create(-10, -10, -10, 1),
  2837. max: V.create(10, 10, -0, 1)
  2838. } : {
  2839. min: V.create(t.minBound[0], t.minBound[1], t.minBound[2], 1),
  2840. max: V.create(t.maxBound[0], t.maxBound[1], t.maxBound[2], 1)
  2841. },
  2842. 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]),
  2843. this.bounds.averageExtent = (t.maxBound[0] - t.minBound[0] + (t.maxBound[1] - t.minBound[1]) + (t.maxBound[2] - t.minBound[2])) / 3
  2844. }
  2845. function w(e, t, i) {
  2846. this.mesh = e,
  2847. this.gl = this.mesh.gl,
  2848. this.indexOffset = t.firstIndex * e.indexTypeSize,
  2849. this.indexCount = t.indexCount,
  2850. this.wireIndexOffset = t.firstWireIndex * e.indexTypeSize,
  2851. this.wireIndexCount = t.wireIndexCount,
  2852. this.material = i,
  2853. this.visible = !0
  2854. }
  2855. w.prototype.draw = function (e) {
  2856. var t = this.gl;
  2857. if (this.material.bind(e, this)) {
  2858. e = this.material.shader.attribs;
  2859. var i = this.mesh.stride;
  2860. this.mesh.desc.cullBackFaces ? (t.enable(t.CULL_FACE),
  2861. t.cullFace(t.BACK)) : t.disable(t.CULL_FACE),
  2862. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  2863. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2864. t.enableVertexAttribArray(e.vPosition),
  2865. t.enableVertexAttribArray(e.vTexCoord),
  2866. t.enableVertexAttribArray(e.vTangent),
  2867. t.enableVertexAttribArray(e.vBitangent),
  2868. t.enableVertexAttribArray(e.vNormal);
  2869. var s = this.mesh.vertexColor && void 0 !== e.vColor;
  2870. s && t.enableVertexAttribArray(e.vColor);
  2871. var n = this.mesh.secondaryTexCoord && void 0 !== e.vTexCoord2;
  2872. n && t.enableVertexAttribArray(e.vTexCoord2);
  2873. var r = 0;
  2874. t.vertexAttribPointer(e.vPosition, 3, t.FLOAT, !1, i, r),
  2875. r += 12,
  2876. t.vertexAttribPointer(e.vTexCoord, 2, t.FLOAT, !1, i, r),
  2877. r += 8,
  2878. this.mesh.secondaryTexCoord && (n && t.vertexAttribPointer(e.vTexCoord2, 2, t.FLOAT, !1, i, r),
  2879. r += 8),
  2880. t.vertexAttribPointer(e.vTangent, 2, t.UNSIGNED_SHORT, !0, i, r),
  2881. r += 4,
  2882. t.vertexAttribPointer(e.vBitangent, 2, t.UNSIGNED_SHORT, !0, i, r),
  2883. r += 4,
  2884. t.vertexAttribPointer(e.vNormal, 2, t.UNSIGNED_SHORT, !0, i, r),
  2885. s && t.vertexAttribPointer(e.vColor, 4, t.UNSIGNED_BYTE, !0, i, r + 4),
  2886. t.drawElements(t.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  2887. t.disableVertexAttribArray(e.vPosition),
  2888. t.disableVertexAttribArray(e.vTexCoord),
  2889. t.disableVertexAttribArray(e.vTangent),
  2890. t.disableVertexAttribArray(e.vBitangent),
  2891. t.disableVertexAttribArray(e.vNormal),
  2892. s && t.disableVertexAttribArray(e.vColor),
  2893. n && t.disableVertexAttribArray(e.vTexCoord2)
  2894. }
  2895. },
  2896. w.prototype.drawShadow = function (e) {
  2897. var t = this.gl;
  2898. this.mesh.desc.cullBackFaces ? (t.enable(t.CULL_FACE),
  2899. t.cullFace(t.BACK)) : t.disable(t.CULL_FACE),
  2900. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  2901. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2902. t.enableVertexAttribArray(e),
  2903. t.vertexAttribPointer(e, 3, t.FLOAT, !1, this.mesh.stride, 0),
  2904. t.drawElements(t.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  2905. t.disableVertexAttribArray(e)
  2906. },
  2907. w.prototype.drawAlphaShadow = function (e, t) {
  2908. var i = this.gl;
  2909. this.mesh.desc.cullBackFaces ? (i.enable(i.CULL_FACE),
  2910. i.cullFace(i.BACK)) : i.disable(i.CULL_FACE),
  2911. i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  2912. i.bindBuffer(i.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2913. i.enableVertexAttribArray(e),
  2914. i.enableVertexAttribArray(t),
  2915. i.vertexAttribPointer(e, 3, i.FLOAT, !1, this.mesh.stride, 0),
  2916. i.vertexAttribPointer(t, 2, i.FLOAT, !1, this.mesh.stride, 12),
  2917. i.drawElements(i.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  2918. i.disableVertexAttribArray(e),
  2919. i.disableVertexAttribArray(t)
  2920. },
  2921. w.prototype.drawAlphaPrepass = function (e) {
  2922. var t = this.gl;
  2923. if (this.material.bindAlphaPrepass(e, this)) {
  2924. e = this.material.prepassShader.attribs;
  2925. var i = this.mesh.stride;
  2926. this.mesh.desc.cullBackFaces ? (t.enable(t.CULL_FACE),
  2927. t.cullFace(t.BACK)) : t.disable(t.CULL_FACE),
  2928. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  2929. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2930. t.enableVertexAttribArray(e.vPosition),
  2931. t.enableVertexAttribArray(e.vTexCoord),
  2932. t.vertexAttribPointer(e.vPosition, 3, t.FLOAT, !1, i, 0),
  2933. t.vertexAttribPointer(e.vTexCoord, 2, t.FLOAT, !1, i, 12),
  2934. t.drawElements(t.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  2935. t.disableVertexAttribArray(e.vPosition),
  2936. t.disableVertexAttribArray(e.vTexCoord)
  2937. }
  2938. },
  2939. w.prototype.drawWire = function (e) {
  2940. var t = this.material.wireShader.attribs,
  2941. i = this.gl;
  2942. this.material.bindWire(e, this) && (i.enableVertexAttribArray(t.vPosition),
  2943. i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.mesh.wireBuffer),
  2944. i.bindBuffer(i.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2945. i.vertexAttribPointer(t.vPosition, 3, i.FLOAT, !1, this.mesh.stride, 0),
  2946. i.drawElements(i.LINES, this.wireIndexCount, this.mesh.indexType, this.wireIndexOffset),
  2947. i.disableVertexAttribArray(t.vPosition))
  2948. },
  2949. w.prototype.complete = function () {
  2950. return this.material.complete()
  2951. };
  2952. var C = {
  2953. fetchImage: function (e, t, i) {
  2954. var s = new Image();
  2955. s.crossOrigin = "Anonymous",
  2956. s.onload = function () {
  2957. 0 < s.width && 0 < s.height ? t(s) : i && i()
  2958. },
  2959. i && (req.onerror = function () {
  2960. i()
  2961. }),
  2962. s.src = e
  2963. },
  2964. fetchText: function (e, t, i, s) {
  2965. var n = new XMLHttpRequest();
  2966. n.open("GET", e, !0),
  2967. n.onload = function () {
  2968. 200 == n.status ? t(n.responseText) : i && i()
  2969. },
  2970. i && (n.onerror = function () {
  2971. i()
  2972. }),
  2973. s && (n.onprogress = function (e) {
  2974. s(e.loaded, e.total)
  2975. }),
  2976. n.send()
  2977. },
  2978. fetchBinary: function (e, t, i, s) {
  2979. var n = new XMLHttpRequest();
  2980. n.open("GET", e, !0),
  2981. n.responseType = "arraybuffer",
  2982. n.onload = function () {
  2983. 200 == n.status ? t(n.response) : i && i()
  2984. },
  2985. i && (n.onerror = function () {
  2986. i()
  2987. }),
  2988. s && (n.onprogress = function (e) {
  2989. s(e.loaded, e.total)
  2990. }),
  2991. n.send()
  2992. },
  2993. fetchBinaryIncremental: function (r, a, t, o) {
  2994. var i = new XMLHttpRequest();
  2995. i.open("HEAD", r, !0),
  2996. i.onload = function () {
  2997. if (200 == i.status) {
  2998. var e = i.getResponseHeader("Accept-Ranges");
  2999. if (e && "none" != e) {
  3000. var s = 0 | i.getResponseHeader("Content-Length"),
  3001. n = function (e, t) {
  3002. var i = new XMLHttpRequest();
  3003. i.open("GET", r, !0),
  3004. i.setRequestHeader("Range", "bytes=" + e + "-" + t),
  3005. i.responseType = "arraybuffer",
  3006. i.onload = function () {
  3007. (206 == i.status || 200 == i.status) && a(i.response) && t < s && n(e += o, t = (t += o) < s - 1 ? t : s - 1)
  3008. },
  3009. i.send()
  3010. };
  3011. n(0, o - 1)
  3012. } else
  3013. t && t()
  3014. } else
  3015. t && t()
  3016. },
  3017. t && (i.onerror = function () {
  3018. t()
  3019. }),
  3020. i.send()
  3021. }
  3022. };
  3023. function R(e) {
  3024. this.debugString = "",
  3025. this.init = !1,
  3026. this.speedList = this.cameraList = this.animationList = this.playButton = this.timelineSlider = this.playbackRegion = this.previousFrameButton = this.nextFrameButton = this.pauseButton = this.playButton = 0,
  3027. this.visible = !1,
  3028. this.backgroundRegion = this.screenButton = 0,
  3029. this.guiScreen = e,
  3030. this.playbackRegion = new v(e),
  3031. this.idealSliderWidth = 650,
  3032. this.totalListBoxPixelsX = 0,
  3033. this.minWidth = 500,
  3034. this.compactMode = !1,
  3035. this.ui = e.ui;
  3036. var t = "animationpause" + e.imageSetNumber + "x.png",
  3037. i = "animationplay" + e.imageSetNumber + "x.png",
  3038. s = "timelineLE" + e.imageSetNumber + "x.png",
  3039. n = "timelineM" + e.imageSetNumber + "x.png",
  3040. r = "timelineRE" + e.imageSetNumber + "x.png",
  3041. a = e.ui.viewer.scene.sceneAnimator.animations.length;
  3042. if (0 != a) {
  3043. var o = this.idealSliderWidth;
  3044. this.bottomOffset = 85,
  3045. this.centerOffset = 60;
  3046. var h, l = (h = e.width / 2 + this.centerOffset) - o / 2,
  3047. d = l - 14 - 32,
  3048. c = (h = h + o / 2) - d,
  3049. u = 32 / e.height,
  3050. f = this.bottomOffset / e.height,
  3051. m = this.playbackRegion;
  3052. if (m.controlRect.widthPercent = c / e.width,
  3053. m.controlRect.heightPercent = u,
  3054. m.controlRect.xPercent = d / e.width,
  3055. m.controlRect.yPercent = f,
  3056. u = 32 / c,
  3057. this.pauseButton = new p(this.guiScreen),
  3058. this.pauseButton.controlRect.set(0, .125, u, .75),
  3059. this.pauseButton.controlRect.opacity = .5,
  3060. m.controlRect.registerChildControlRect(this.pauseButton.controlRect),
  3061. this.pauseButton.linkControl(m.addImageElement(this.pauseButton.controlRect, t)),
  3062. this.playButton = new p(this.guiScreen),
  3063. this.playButton.controlRect.set(0, .125, u, .75),
  3064. this.playButton.controlRect.opacity = .5,
  3065. m.controlRect.registerChildControlRect(this.playButton.controlRect),
  3066. this.playButton.linkControl(m.addImageElement(this.playButton.controlRect, i)),
  3067. t = o / c,
  3068. c = (l - d) / c,
  3069. this.timelineSlider = new z(this.guiScreen, m),
  3070. this.timelineSlider.controlRect.set(c, .03125, t, 1),
  3071. m.controlRect.registerChildControlRect(this.timelineSlider.controlRect),
  3072. this.timelineSlider.setBackground3x1(m, s, n, r),
  3073. this.pauseButton.controlRect.showControl(!e.ui.viewer.scene.sceneAnimator.paused),
  3074. this.playButton.controlRect.showControl(e.ui.viewer.scene.sceneAnimator.paused),
  3075. s = h + 14,
  3076. n = this.bottomOffset + 4,
  3077. r = e.ui.viewer.scene.sceneAnimator.animations[0].cameraObjects.length,
  3078. e.ui.viewer.scene.sceneAnimator.selectDefaultCamera(),
  3079. e.ui.viewer.scene.sceneAnimator.setViewFromSelectedCamera(),
  3080. this.maxListPixelsX = 0,
  3081. 1 < r) {
  3082. for (this.cameraList = new y(e),
  3083. c = 0; c < r; c++)
  3084. this.cameraList.addItem(e.ui.viewer.scene.sceneAnimator.animations[0].cameraObjects[c].name, 0, 0);
  3085. this.cameraList.spawnControl(s, n, 10, 24, !0, 8),
  3086. this.cameraList.selectItem(e.ui.viewer.scene.sceneAnimator.selectedCameraIndex),
  3087. this.maxListPixelsX = this.cameraList.localPixelsX,
  3088. this.totalListBoxPixelsX += this.cameraList.localPixelsX + 14
  3089. }
  3090. if (1 < a) {
  3091. for (this.animationList = new y(e),
  3092. c = 0; c < a; c++)
  3093. this.animationList.addItem(e.ui.viewer.scene.sceneAnimator.animations[c].name, 0, 0);
  3094. this.animationList.spawnControl(s, n, 10, 24, !0, 8),
  3095. this.maxListPixelsX < this.animationList.localPixelsX && (this.maxListPixelsX = this.animationList.localPixelsX),
  3096. this.totalListBoxPixelsX += this.animationList.localPixelsX + 14,
  3097. this.animationList.selectItem(e.ui.viewer.scene.sceneAnimator.selectedAnimationIndex)
  3098. }
  3099. c = h - (s = d - 44 - 14) + this.totalListBoxPixelsX,
  3100. this.speedList = new y(e),
  3101. this.speedList.addItem("4.0x", 4, 0),
  3102. this.speedList.addItem("2.0x", 4, 0),
  3103. this.speedList.addItem("1.0x", 4, 0),
  3104. this.speedList.addItem("0.5x", 4, 0),
  3105. this.speedList.addItem("0.25x", -2, 0),
  3106. this.speedList.spawnControl(s, n, 44, 24, !1, 0),
  3107. this.speedList.selectItem(2),
  3108. c > e.width && (this.idealSliderWidth = e.width - (118 + (this.totalListBoxPixelsX + 14)) - this.centerOffset,
  3109. e = 0,
  3110. this.cameraList && e++,
  3111. this.animationList && e++,
  3112. 1 == e && (this.idealSliderWidth += 56,
  3113. this.centerOffset -= 14),
  3114. 2 == e && (this.idealSliderWidth += 63,
  3115. this.centerOffset -= 63)),
  3116. this.setupCallbacks()
  3117. }
  3118. }
  3119. function A(e, t, i) {
  3120. if (this.gl = e,
  3121. this.desc = t,
  3122. t = [],
  3123. 0 != this.desc.sharpen && t.push("#define SHARPEN"),
  3124. (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"),
  3125. 0 != this.desc.vignette[3] && t.push("#define VIGNETTE"),
  3126. 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"),
  3127. 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"),
  3128. 0 != this.desc.grain && t.push("#define GRAIN"),
  3129. 1 == this.desc.toneMap ? t.push("#define REINHARD") : 2 == this.desc.toneMap && t.push("#define HEJL"),
  3130. this.desc.colorLUT && t.push("#define COLOR_LUT"),
  3131. this.sampleIndex = 0,
  3132. this.sampleCount = 1,
  3133. i && (this.sampleCount = 4,
  3134. this.sampleOffsets = [
  3135. [-.5, -.5],
  3136. [.5, -.5],
  3137. [-.5, .5],
  3138. [.5, .5]
  3139. ]),
  3140. this.aaShader = e.shaderCache.fromURLs("postvert.glsl", "postaa.glsl"),
  3141. this.shader = e.shaderCache.fromURLs("postvert.glsl", "postfrag.glsl", t),
  3142. this.plainShader = e.shaderCache.fromURLs("postvert.glsl", "postfrag.glsl", []),
  3143. this.fullscreenTriangle = e.createBuffer(),
  3144. e.bindBuffer(e.ARRAY_BUFFER, this.fullscreenTriangle),
  3145. i = new Float32Array([0, 0, 2, 0, 0, 2]),
  3146. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3147. e.bindBuffer(e.ARRAY_BUFFER, null),
  3148. this.useBloom) {
  3149. for (this.bloomTextures = [],
  3150. this.bloomTargets = [],
  3151. i = 0; i < 2; ++i)
  3152. t = {
  3153. width: 256,
  3154. height: 256,
  3155. clamp: !0
  3156. },
  3157. this.bloomTextures[i] = new U(e, t),
  3158. this.bloomTextures[i].loadArray(null, e.RGBA, e.ext.textureHalf && e.ext.textureHalfLinear ? e.ext.textureHalf.HALF_FLOAT_OES : e.UNSIGNED_BYTE),
  3159. this.bloomTargets[i] = new m(e, {
  3160. width: t.width,
  3161. height: t.height,
  3162. color0: this.bloomTextures[i]
  3163. });
  3164. for (this.bloomSamples = 64; this.bloomSamples + 16 >= e.limits.fragmentUniforms;)
  3165. this.bloomSamples /= 2;
  3166. this.bloomShader = e.shaderCache.fromURLs("postvert.glsl", "bloom.glsl", ["#define BLOOM_SAMPLES " + this.bloomSamples]),
  3167. this.shrinkShader = e.shaderCache.fromURLs("postvert.glsl", "bloomshrink.glsl")
  3168. }
  3169. for (e = new Uint8Array(16384),
  3170. i = 0; i < 16384; i++) {
  3171. t = 255 * Math.random();
  3172. var s = 255 * Math.random();
  3173. e[i] = .5 * (t + s)
  3174. }
  3175. this.noiseTexture = new U(this.gl, {
  3176. width: 128,
  3177. height: 128
  3178. }),
  3179. this.noiseTexture.loadArray(e, this.gl.LUMINANCE),
  3180. this.desc.colorLUT && (e = this.desc.colorLUT,
  3181. this.colorLUT = new U(this.gl, {
  3182. width: e.length / 3 | 0,
  3183. height: 1,
  3184. clamp: !0
  3185. }),
  3186. this.colorLUT.loadArray(new Uint8Array(e), this.gl.RGB)),
  3187. this.blackTexture = new U(this.gl, {
  3188. width: 1,
  3189. height: 1
  3190. }),
  3191. this.blackTexture.loadArray(new Uint8Array([0, 0, 0, 0])),
  3192. this.bloomResult = this.blackTexture
  3193. }
  3194. function k(e) {
  3195. this.gl = e,
  3196. this.name = "untitled",
  3197. this.meshes = [],
  3198. this.meshRenderables = [],
  3199. this.materials = {},
  3200. this.sky = this.view = null,
  3201. this.selectedPartIndex = 0,
  3202. this.soloPart = !1,
  3203. this.miscnotes = "",
  3204. this.nextView = null,
  3205. this.viewFade = 0,
  3206. this.refractionSurface = this.shadow = this.stripData = this.lights = null,
  3207. this.sceneAnimator = this.frameCounter = 0,
  3208. this.sceneLoaded = !1,
  3209. this.debugString = ""
  3210. }
  3211. function P(e, t, i) {
  3212. if (this.scene = e,
  3213. this.animations = [],
  3214. this.skinningRigs = [],
  3215. this.meshIDs = [],
  3216. this.lightIDs = [],
  3217. this.materialIDs = [],
  3218. this.views = [],
  3219. this.viewYawOffsets = [],
  3220. this.viewPitchOffsets = [],
  3221. this.cameraObjectIndices = [],
  3222. this.cameraChildrenIndices = [],
  3223. this.subMeshObjectIndices = [],
  3224. this.subMeshLiveIndices = [],
  3225. this.scene = e,
  3226. this.selectedCameraIndex = -1,
  3227. this.selectedAnimationIndex = 0,
  3228. this.debugString = "",
  3229. this.scenePlaybackSpeed = this.playbackSpeed = 1,
  3230. this.animationProgress = this.totalSeconds = 0,
  3231. this.paused = this.autoAdvanceNextAnimation = !1,
  3232. this.animateVisibility = this.drawAnimated = this.linkSceneObjects = this.loadSkinningRigs = this.animateMaterials = this.animateTurntables = this.enableSkinning = this.animateMeshes = this.animateLights = this.playAnimations = this.loadAnimations = !0,
  3233. this.showDebugInfo = !1,
  3234. this.loopCount = 0,
  3235. this.loopTurntables = this.lockPlayback = !1,
  3236. this.fogObjectIndex = -1,
  3237. this.unitScaleSkinnedMeshes = !0,
  3238. this.sceneScale = i.sceneScale,
  3239. this.defaultCameraGlobalIndex = i.selectedCamera,
  3240. this.selectedAnimationIndex = i.selectedAnimation,
  3241. this.autoPlayAnims = i.autoPlayAnims,
  3242. this.showPlayControls = i.showPlayControls,
  3243. i.scenePlaybackSpeed && (this.scenePlaybackSpeed = i.scenePlaybackSpeed,
  3244. 0 == this.scenePlaybackSpeed && (this.scenePlaybackSpeed = 1)),
  3245. this.autoPlayAnims || (this.paused = !0),
  3246. this.loadAnimations) {
  3247. if (i.meshIDs)
  3248. for (var s = i.meshIDs.length, n = 0; n < s; ++n) {
  3249. var r = i.meshIDs[n].partIndex;
  3250. this.meshIDs.push(r)
  3251. }
  3252. if (i.lightIDs)
  3253. for (s = i.lightIDs.length,
  3254. n = 0; n < s; ++n)
  3255. r = (r = i.lightIDs[n]).partIndex,
  3256. this.lightIDs.push(r);
  3257. if (i.materialIDs)
  3258. for (s = i.materialIDs.length,
  3259. n = 0; n < s; ++n)
  3260. r = (r = i.materialIDs[n]).partIndex,
  3261. this.materialIDs.push(r);
  3262. if (this.numMatricesInTable = i.numMatrices,
  3263. r = new u((n = t.get("MatTable.bin")).data),
  3264. n || (this.numMatricesInTable = 0,
  3265. this.debugString += "<br>No mattable?"),
  3266. i.skinningRigs && this.loadSkinningRigs)
  3267. for (s = i.skinningRigs.length,
  3268. n = 0; n < s; ++n) {
  3269. "" == (a = new M(t, i.skinningRigs[n], r)).debugString ? this.skinningRigs.push(a) : (this.debugString += "<br>Error loading skinning rig " + n + " :" + a.debugString,
  3270. this.debugString += "<br>Skipping the rest",
  3271. n = s)
  3272. }
  3273. if (i.animations)
  3274. for (r = i.animations.length,
  3275. n = 0; n < r; ++n)
  3276. s = new c(t, i.animations[n]),
  3277. this.animations.push(s);
  3278. if (this.startMS = Date.now(),
  3279. r = this.animations.length,
  3280. this.linkSceneObjects && 0 != r) {
  3281. for (n = 0; n < r; n++)
  3282. for (s = (t = this.animations[n]).animatedObjects.length,
  3283. i = 0; i < s; i++)
  3284. "LightSO" == (a = t.animatedObjects[i]).sceneObjectType && (a.lightIndex = this.findLightIndexByPartIndex(i),
  3285. -1 != a.lightIndex ? t.lightObjects.push(a) : this.debugString += "<br> got light not in scene " + a.name),
  3286. "FogSO" == a.sceneObjectType && (this.fogObjectIndex = i),
  3287. "SubMeshSO" == a.sceneObjectType && 0 == n && (this.subMeshObjectIndices.push(i),
  3288. this.subMeshLiveIndices.push(-1)),
  3289. "Material" == a.sceneObjectType && (a.materialIndex = this.findMaterialIndexByPartIndex(i),
  3290. -1 == a.materialIndex ? this.debugString += "<br> can't find material index for object " + i : t.materialObjects.push(a)),
  3291. "TurnTableSO" == a.sceneObjectType && t.turnTableObjects.push(a),
  3292. "MeshSO" == a.sceneObjectType && (a.meshIndex = this.findMeshIndexByPartIndex(this.scene.meshes, i),
  3293. -1 == a.meshIndex ? (this.debugString += "<br> can't find mesh index for object " + i,
  3294. this.logObjectInfo(i, 0)) : (t.meshObjects.push(a),
  3295. a.mesh = this.scene.meshes[a.meshIndex],
  3296. -1 != a.skinningRigIndex && a.mesh && a.skinningRigIndex < this.skinningRigs.length && (a.skinningRig = this.skinningRigs[a.skinningRigIndex],
  3297. a.skinningRig.isRigidSkin || (a.mesh.dynamicVertexData ? a.skinningRig.useOriginalMeshVertices(a.mesh) : (this.debugString += "Skinning object - but mesh is not dynamic",
  3298. this.debugString += "<br>Rig index " + a.skinningRigIndex,
  3299. this.debugString += " not tagged as rigid"))))),
  3300. "CameraSO" == a.sceneObjectType && (a.modelPartIndex = a.id,
  3301. t.cameraObjects.push(a));
  3302. for (i = (t = this.animations[0]).cameraObjects.length,
  3303. n = 0; n < i; n++)
  3304. r = t.cameraObjects[n],
  3305. (s = this.scene.cameras[r.name]) ? (s = s.view) && (s = new H(s),
  3306. this.cameraObjectIndices.push(r.id),
  3307. this.views.push(s),
  3308. this.viewYawOffsets.push(0),
  3309. this.viewPitchOffsets.push(0)) : (this.debugString += "<br>no camDesc for " + r.name,
  3310. this.views.push(e.view));
  3311. for (e = this.scene.meshes.length,
  3312. r = this.subMeshObjectIndices.length,
  3313. n = s = 0; n < e; n++) {
  3314. var a = this.scene.meshes[n],
  3315. o = !1;
  3316. for (i = 0; i < r; i++) {
  3317. var h = this.subMeshObjectIndices[i],
  3318. l = t.animatedObjects[h],
  3319. d = t.animatedObjects[l.parentIndex];
  3320. if (d.mesh || (this.debugString += "<br>submesh parent object has no mesh?",
  3321. this.debugString += "<br>obj.name " + l.name,
  3322. this.debugString += "<br>parent.name " + d.name,
  3323. this.debugString += "<br>submesh index " + i,
  3324. this.debugString += "<br>obj.index " + h),
  3325. d.mesh == a) {
  3326. for (o = 0; o < a.numSubMeshes; o++)
  3327. this.subMeshLiveIndices[i + (a.numSubMeshes - 1 - o)] = s,
  3328. s++;
  3329. i = r,
  3330. o = !0
  3331. }
  3332. }
  3333. o || (this.debugString += "<br>Missing submesh? - no matches for mesh " + n + " of " + e)
  3334. }
  3335. for (n = 0; n < r; n++)
  3336. -
  3337. 1 == this.subMeshLiveIndices[n] && (this.debugString += "<br>Missing mesh? Unused submesh " + n + " of " + r);
  3338. this.showDebugInfo = this.stopEverything = this.runDebugMode = !1,
  3339. this.selectDefaultCamera(),
  3340. this.findCameraChildren(),
  3341. this.findFixedTransforms(),
  3342. this.runDebugMode && (this.setAnimationProgress(0, !0),
  3343. "" != this.debugString ? this.stopEverything = !0 : this.checkDebug())
  3344. }
  3345. } else
  3346. this.debugString += "<br>Skip loading animation data"
  3347. }
  3348. function F(e) {
  3349. this.gl = e,
  3350. this.program = null,
  3351. this.params = {},
  3352. this.samplers = {},
  3353. this.attribs = {}
  3354. }
  3355. function O(e) {
  3356. this.gl = e,
  3357. this.cache = []
  3358. }
  3359. function E(e, t) {
  3360. if (this.gl = e,
  3361. this.shadowCount = t,
  3362. this.nativeDepth = !!e.ext.textureDepth,
  3363. this.desc = i,
  3364. i = this.nativeDepth ? ["#define SHADOW_NATIVE_DEPTH"] : [],
  3365. this.shaderSolid = e.shaderCache.fromURLs("shadowvert.glsl", "shadowfrag.glsl", i),
  3366. i.push("#define ALPHA_TEST 1"),
  3367. this.shaderAlphaTest = e.shaderCache.fromURLs("shadowvert.glsl", "shadowfrag.glsl", i),
  3368. this.depthTextures = [],
  3369. this.depthTargets = [],
  3370. 0 < this.shadowCount) {
  3371. var i = {
  3372. width: 2048,
  3373. height: 2048,
  3374. clamp: !0,
  3375. mipmap: !1,
  3376. nofilter: !0
  3377. };
  3378. e.hints.mobile && (i.width = i.height = 1536);
  3379. var s, n, r = {
  3380. width: i.width,
  3381. height: i.height
  3382. };
  3383. n = this.nativeDepth ? (s = e.DEPTH_COMPONENT,
  3384. e.UNSIGNED_SHORT) : (r.depthBuffer = m.createDepthBuffer(e, i.width, i.height),
  3385. s = e.RGB,
  3386. e.UNSIGNED_BYTE);
  3387. for (var a = 0; a < this.shadowCount; ++a)
  3388. this.depthTextures[a] = new U(e, i),
  3389. this.depthTextures[a].loadArray(null, s, n),
  3390. this.nativeDepth ? r.depth = this.depthTextures[a] : r.color0 = this.depthTextures[a],
  3391. this.depthTargets[a] = new m(e, r)
  3392. }
  3393. }
  3394. function B(e, t, i, s) {
  3395. this.gl = e,
  3396. this.desc = t,
  3397. this.lightCount = s.count,
  3398. this.shadowCount = i.shadowCount,
  3399. (t = this.nativeDepth ? ["#define SHADOW_NATIVE_DEPTH"] : []).push("#define LIGHT_COUNT " + this.lightCount),
  3400. t.push("#define SHADOW_COUNT " + this.shadowCount),
  3401. e.hints.mobile && t.push("#define MOBILE"),
  3402. this.shader = e.shaderCache.fromURLs("shadowfloorvert.glsl", "shadowfloorfrag.glsl", t),
  3403. t = new Float32Array([-1, 0, -1, -1, 0, 1, 1, 0, 1, -1, 0, -1, 1, 0, 1, 1, 0, -1]),
  3404. this.quadGeom = e.createBuffer(),
  3405. e.bindBuffer(e.ARRAY_BUFFER, this.quadGeom),
  3406. e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW),
  3407. e.bindBuffer(e.ARRAY_BUFFER, null)
  3408. }
  3409. function L() {
  3410. this.associateObjectIndex = this.linkObjectIndex = this.linkMode = 0,
  3411. this.vertexIndices = [],
  3412. this.vertexWeights = [],
  3413. this.matrix = S.identity(),
  3414. this.defaultAssociateWorldTransform = this.defaultClusterWorldTransform = this.defaultClusterBaseTransform = 0,
  3415. this.defaultClusterWorldTransformInvert = S.identity(),
  3416. this.defaultAssociateWorldTransformInvert = S.identity(),
  3417. this.debugString = ""
  3418. }
  3419. function M(e, t, i) {
  3420. if (this.debugString = "",
  3421. this.skinningClusters = [],
  3422. this.srcVFile = t.file,
  3423. e = e.get(this.srcVFile))
  3424. if (e.data) {
  3425. this.rigByteStream = new u(e.data),
  3426. e = new Uint32Array(this.rigByteStream.bytes.buffer, 0, this.rigByteStream.bytes.length / 4),
  3427. this.expectedNumClusters = e[0],
  3428. this.expectedNumVertices = e[1],
  3429. this.numClusterLinks = e[2],
  3430. this.originalObjectIndex = e[3],
  3431. this.isRigidSkin = e[4],
  3432. this.tangentMethod = e[5],
  3433. t = 6 + 7 * this.expectedNumClusters;
  3434. for (var s = 0; s < this.expectedNumClusters; s++) {
  3435. var n = new L();
  3436. this.skinningClusters.push(n);
  3437. var r = 6 + 7 * s;
  3438. n.linkMode = e[1 + r],
  3439. n.linkObjectIndex = e[2 + r],
  3440. n.associateObjectIndex = e[3 + r];
  3441. var a = e[5 + r];
  3442. n.defaultClusterWorldTransform = i.getMatrix(e[4 + r]),
  3443. n.defaultClusterBaseTransform = i.getMatrix(a),
  3444. S.invert(n.defaultClusterWorldTransformInvert, n.defaultClusterWorldTransform),
  3445. 1 == n.linkMode && (n.defaultAssociateWorldTransform = i.getMatrix(e[6 + r]),
  3446. S.invert(n.defaultAssociateWorldTransformInvert, n.defaultAssociateWorldTransform))
  3447. }
  3448. e = (t = (i = 4 * t) + this.expectedNumVertices) + 2 * this.numClusterLinks,
  3449. t = new Uint8Array(this.rigByteStream.bytes.subarray(t)),
  3450. e = new Uint8Array(this.rigByteStream.bytes.subarray(e)),
  3451. this.linkMapCount = new Uint8Array(this.rigByteStream.bytes.buffer, i, this.expectedNumVertices),
  3452. this.linkMapClusterIndices = new Uint16Array(t.buffer),
  3453. this.linkMapWeights = new Float32Array(e.buffer)
  3454. } else
  3455. this.debugString += "<br>No data in " + this.srcVFile;
  3456. else
  3457. this.debugString += "<br>Error loading buffer for skinning rig " + this.srcVFile
  3458. }
  3459. function _(e, t, i) {
  3460. if (this.gl = e,
  3461. void 0 !== (s = t.extract("sky.dat") || t.extract("sky.png"))) {
  3462. this.specularTexture = new U(e, {
  3463. width: 256,
  3464. height: 2048,
  3465. clamp: !0
  3466. }),
  3467. t = s.data;
  3468. for (var s, n = (s = s.data.length) / 4, r = new Uint8Array(s), a = 0, o = 0; a < s; ++o)
  3469. r[a++] = t[o + 2 * n],
  3470. r[a++] = t[o + n],
  3471. r[a++] = t[o],
  3472. r[a++] = t[o + 3 * n];
  3473. this.specularTexture.loadArray(r)
  3474. }
  3475. if (this.diffuseCoefficients = new Float32Array(i.diffuseCoefficients),
  3476. this.backgroundMode = i.backgroundMode || 0,
  3477. this.backgroundBrightness = i.backgroundBrightness || 1,
  3478. this.backgroundColor = new Float32Array(i.backgroundColor),
  3479. 1 <= this.backgroundMode)
  3480. if (this.backgroundShader = e.shaderCache.fromURLs("skyvert.glsl", 3 == this.backgroundMode ? "skySH.glsl" : "sky.glsl", ["#define SKYMODE " + this.backgroundMode]),
  3481. this.vertexBuffer = e.createBuffer(),
  3482. e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer),
  3483. i = 1 / 256,
  3484. s = 2.8 * (t = .5 / 256),
  3485. n = .5 * t,
  3486. 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]),
  3487. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3488. e.bindBuffer(e.ARRAY_BUFFER, null),
  3489. this.indexBuffer = e.createBuffer(),
  3490. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer),
  3491. 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]),
  3492. this.skyIndexCount = i.length,
  3493. e.bufferData(e.ELEMENT_ARRAY_BUFFER, i, e.STATIC_DRAW),
  3494. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null),
  3495. 3 == this.backgroundMode)
  3496. for (this.backgroundCoefficients = new Float32Array(this.diffuseCoefficients),
  3497. a = 0; a < this.backgroundCoefficients.length; ++a)
  3498. this.backgroundCoefficients[a] *= this.backgroundBrightness;
  3499. else {
  3500. var h;
  3501. this.backgroundTexture = new U(e, {
  3502. width: 256,
  3503. height: 256,
  3504. clamp: !0
  3505. }),
  3506. i = !1,
  3507. e.ext.textureHalf && e.ext.textureHalfLinear && (this.backgroundTexture.loadArray(null, e.RGB, e.ext.textureHalf.HALF_FLOAT_OES),
  3508. i = (h = new m(e, {
  3509. color0: this.backgroundTexture
  3510. })).valid),
  3511. !i && e.ext.textureFloat && e.ext.textureFloatLinear && !e.hints.mobile && (this.backgroundTexture.loadArray(null, e.RGB, e.FLOAT),
  3512. i = (h = new m(e, {
  3513. color0: this.backgroundTexture
  3514. })).valid),
  3515. i || (this.backgroundTexture.loadArray(),
  3516. h = new m(e, {
  3517. color0: this.backgroundTexture
  3518. })),
  3519. h.bind(),
  3520. (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);}"),
  3521. h.bind(),
  3522. e.uniform1f(h.params.b, 7 * Math.sqrt(this.backgroundBrightness)),
  3523. this.specularTexture.bind(h.samplers.tex),
  3524. i = e.createBuffer(),
  3525. e.bindBuffer(e.ARRAY_BUFFER, i),
  3526. i = new Float32Array([-1, -1, .5, 1, 3, -1, .5, 1, -1, 3, .5, 1]),
  3527. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3528. e.enableVertexAttribArray(h.attribs.p),
  3529. e.vertexAttribPointer(h.attribs.p, 4, e.FLOAT, !1, 0, 0),
  3530. e.drawArrays(e.TRIANGLES, 0, 3),
  3531. e.disableVertexAttribArray(h.attribs.p)
  3532. }
  3533. }
  3534. function D() {
  3535. this.STRIP_NONE = -2,
  3536. this.STRIP_MENU = -1,
  3537. this.stripCount = 5,
  3538. this.strips = [0, 0, 0, 0, 0],
  3539. this.labels = ["Normals", "Albedo", "Reflectivity", "Gloss", "Topology"],
  3540. this.stripSlant = .25,
  3541. this.selectedStrip = this.STRIP_NONE,
  3542. this.animationActive = !1,
  3543. this.timestamp = Date.now(),
  3544. this.update(!0)
  3545. }
  3546. function U(e, t) {
  3547. this.gl = e,
  3548. this.id = null,
  3549. this.type = e.TEXTURE_2D,
  3550. this.format = e.RGBA,
  3551. this.componentType = e.UNSIGNED_BYTE,
  3552. t = t || {},
  3553. this.desc = {
  3554. width: t.width || 1,
  3555. height: t.height || 1,
  3556. mipmap: t.mipmap,
  3557. clamp: t.clamp,
  3558. mirror: t.mirror,
  3559. aniso: t.aniso,
  3560. nofilter: t.nofilter
  3561. }
  3562. }
  3563. function N(e) {
  3564. this.gl = e,
  3565. this.cache = []
  3566. }
  3567. function z(e, t) {
  3568. this.name = "none",
  3569. this.debugString = "",
  3570. this.knobControlRect = new s(e),
  3571. this.controlRect = new s(e);
  3572. var i = document.createElement("div");
  3573. i.id = "sliderUI",
  3574. i.style.position = "absolute",
  3575. i.style.overflow = "hidden",
  3576. i.style["-moz-user-select"] = "none",
  3577. i.style["-khtml-user-select"] = "none",
  3578. i.style["-webkit-user-select"] = "none",
  3579. i.style["-ms-user-select"] = "none",
  3580. this.controlRect.linkedControl = i,
  3581. this.backgroundControl = 0,
  3582. this.controlRect.registerChildControlRect(this.knobControlRect),
  3583. this.knobControlRect.setOpacity(.65),
  3584. this.sliderPercent = this.pixelsY = this.pixelsX = 0,
  3585. this.draggingSlider = !1,
  3586. this.guiScreen = e,
  3587. t.addImageElement(this.knobControlRect, "animationknob" + e.imageSetNumber + "x.png")
  3588. }
  3589. function j(e) {
  3590. this.viewer = e,
  3591. this.stripData = e.stripData,
  3592. (e = this.container = document.createElement("div")).id = "fdageUI",
  3593. e.style.position = "absolute",
  3594. e.style.overflow = "hidden",
  3595. e.style["-moz-user-select"] = "none",
  3596. e.style["-khtml-user-select"] = "none",
  3597. e.style["-webkit-user-select"] = "none",
  3598. e.style["-ms-user-select"] = "none",
  3599. this.viewer.domRoot.appendChild(e),
  3600. this.guiScreen = new t(this)
  3601. }
  3602. R.prototype.resize = function (e) {
  3603. e.ui.viewer.scene.sceneAnimator.showPlayControls || (e.width = 1,
  3604. e.height = 1),
  3605. this.compactMode = e.width < this.minWidth;
  3606. var t = this.bottomOffset,
  3607. i = this.bottomOffset + 4,
  3608. s = 0;
  3609. 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);
  3610. var n = e.width - s - 72;
  3611. 0 == s && (n -= 14);
  3612. var r = 116,
  3613. a = r + n + 14;
  3614. this.compactMode && (r = 58,
  3615. n += 44 + s,
  3616. 0 < s && (t += 32),
  3617. s || (i += 32));
  3618. var o = (s = 32 / n) + 14 / n,
  3619. h = 1 - o,
  3620. l = this.playbackRegion;
  3621. l.controlRect.widthPercent = n / e.width,
  3622. l.controlRect.heightPercent = 32 / e.height,
  3623. l.controlRect.xPercent = r / e.width,
  3624. l.controlRect.yPercent = t / e.height,
  3625. this.pauseButton.controlRect.set(0, .125, s, .75),
  3626. this.playButton.controlRect.set(0, .125, s, .75),
  3627. this.timelineSlider.controlRect.set(o, .03125, h, 1),
  3628. this.timelineSlider.setSize(n - 46, 32),
  3629. l.controlRect.updateElement(),
  3630. l.controlRect.updateChildElements(),
  3631. this.speedList.setControl(58, i, 44, 24, !1),
  3632. this.cameraList && (this.cameraList.setControl(a, i, 10, 24, !0, 8),
  3633. a += this.cameraList.localPixelsX + 14),
  3634. this.animationList && this.animationList.setControl(a, i, 10, 24, !0, 8),
  3635. this.timelineSlider.backgroundControl.alignBackground()
  3636. },
  3637. R.prototype.setupCallbacks = function () {
  3638. var e = function (e) {
  3639. "0.01x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.01),
  3640. "0.05x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.05),
  3641. "0.25x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.25),
  3642. "0.5x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.5),
  3643. "1.0x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(1),
  3644. "2.0x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(2),
  3645. "4.0x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(4)
  3646. }
  3647. .bind(this),
  3648. t = function (e) {
  3649. this.ui.viewer.scene.sceneAnimator.selectCamera(this.cameraList.selectedIndex),
  3650. this.ui.viewer.wake()
  3651. }
  3652. .bind(this),
  3653. i = function (e) {
  3654. this.ui.viewer.scene.sceneAnimator.selectAnimation(this.animationList.selectedIndex),
  3655. this.ui.viewer.wake()
  3656. }
  3657. .bind(this);
  3658. this.speedList && (this.speedList.selectionChangedCallback = e),
  3659. this.cameraList && (this.cameraList.selectionChangedCallback = t),
  3660. this.animationList && (this.animationList.selectionChangedCallback = i),
  3661. this.playButton.controlRect.linkedControl.onclick = function () {
  3662. this.ui.viewer.scene.sceneAnimator.pause(!1),
  3663. this.playButton.controlRect.showControl(!1),
  3664. this.pauseButton.controlRect.showControl(!0),
  3665. this.ui.viewer.wake()
  3666. }
  3667. .bind(this),
  3668. this.pauseButton.controlRect.linkedControl.onclick = function () {
  3669. this.ui.viewer.scene.sceneAnimator.pause(!0),
  3670. this.playButton.controlRect.showControl(!0),
  3671. this.pauseButton.controlRect.showControl(!1)
  3672. }
  3673. .bind(this)
  3674. },
  3675. A.prototype.prepareBloom = function (e) {
  3676. if (this.useBloom && this.bloomShader.complete() && this.shrinkShader.complete()) {
  3677. this.shrinkShader.bind(),
  3678. this.bloomTargets[1].bind(),
  3679. e.bind(this.shrinkShader.samplers.tInput),
  3680. this.fillScreen(this.shrinkShader.attribs.vCoord),
  3681. this.bloomShader.bind();
  3682. var t = [];
  3683. this.bloomTargets[0].bind(),
  3684. this.bloomTextures[1].bind(this.bloomShader.samplers.tInput);
  3685. for (var i = 0, s = 0; s < this.bloomSamples; ++s) {
  3686. var n, r = 2 * s / (this.bloomSamples - 1) - 1;
  3687. n = 4 * r,
  3688. i += n = Math.exp(-.5 * n * n / 1) / 2.50662827463,
  3689. t[4 * s + 0] = r * this.desc.bloomSize,
  3690. t[4 * s + 1] = 0,
  3691. t[4 * s + 2] = n,
  3692. t[4 * s + 3] = 0
  3693. }
  3694. for (s = 0; s < this.bloomSamples; ++s)
  3695. t[4 * s + 2] /= i;
  3696. for (this.gl.uniform4fv(this.bloomShader.params.uKernel, t),
  3697. this.fillScreen(this.bloomShader.attribs.vCoord),
  3698. this.bloomTargets[1].bind(),
  3699. this.bloomTextures[0].bind(this.bloomShader.samplers.tInput),
  3700. s = 0; s < this.bloomSamples; ++s)
  3701. i = t[4 * s + 0],
  3702. i *= e.desc.width / e.desc.height,
  3703. t[4 * s + 0] = 0,
  3704. t[4 * s + 1] = i;
  3705. this.gl.uniform4fv(this.bloomShader.params.uKernel, t),
  3706. this.fillScreen(this.bloomShader.attribs.vCoord),
  3707. this.bloomResult = this.bloomTextures[1]
  3708. } else
  3709. this.bloomResult = this.blackTexture
  3710. },
  3711. A.prototype.computeParams = function (e, t) {
  3712. var i = this.desc,
  3713. s = {};
  3714. s.scale = [i.contrast[0] * i.contrast[3], i.contrast[1] * i.contrast[3], i.contrast[2] * i.contrast[3]],
  3715. s.bias = [i.bias[0] * i.bias[3], i.bias[1] * i.bias[3], i.bias[2] * i.bias[3]],
  3716. 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]];
  3717. var n = [i.brightness[0] * i.brightness[3], i.brightness[1] * i.brightness[3], i.brightness[2] * i.brightness[3]];
  3718. s.scale = [s.scale[0] * n[0], s.scale[1] * n[1], s.scale[2] * n[2]],
  3719. s.bias = [s.bias[0] * n[0], s.bias[1] * n[1], s.bias[2] * n[2]],
  3720. s.saturation = [i.saturation[0] * i.saturation[3], i.saturation[1] * i.saturation[3], i.saturation[2] * i.saturation[3]],
  3721. s.bloomColor = [i.bloomColor[0] * i.bloomColor[3], i.bloomColor[1] * i.bloomColor[3], i.bloomColor[2] * i.bloomColor[3]],
  3722. s.sharpen = [i.sharpen, .25 * i.sharpen, i.sharpenLimit],
  3723. s.sharpenKernel = [1 / e, 0, 0, 1 / t],
  3724. n = t < e ? e : t,
  3725. s.vignetteAspect = [e / n, t / n, .5 * e / n, .5 * t / n],
  3726. 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];
  3727. n = 1 / this.noiseTexture.desc.width;
  3728. var r = 1 / this.noiseTexture.desc.height,
  3729. a = 1 - i.grainSharpness;
  3730. return s.grainCoord = [n * e, r * t, .5 * a * n, .5 * a * r],
  3731. s.grainScaleBias = [2 * i.grain, -i.grain],
  3732. s
  3733. },
  3734. A.prototype.present = function (e, t, i, s) {
  3735. if (s || this.prepareBloom(e),
  3736. 1 < this.sampleCount && this.allocAABuffer(t, i),
  3737. (s = s ? this.plainShader : this.shader).bind()) {
  3738. var n = this.gl,
  3739. r = s.samplers,
  3740. a = s.params,
  3741. o = this.computeParams(t, i);
  3742. if (e.bind(r.tInput),
  3743. this.bloomResult.bind(r.tBloom),
  3744. this.noiseTexture.bind(r.tGrain),
  3745. this.colorLUT && this.colorLUT.bind(r.tLUT),
  3746. n.uniform3fv(a.uScale, o.scale),
  3747. n.uniform3fv(a.uBias, o.bias),
  3748. n.uniform3fv(a.uSaturation, o.saturation),
  3749. n.uniform4fv(a.uSharpenKernel, o.sharpenKernel),
  3750. n.uniform3fv(a.uSharpness, o.sharpen),
  3751. n.uniform3fv(a.uBloomColor, o.bloomColor),
  3752. n.uniform4fv(a.uVignetteAspect, o.vignetteAspect),
  3753. n.uniform4fv(a.uVignette, o.vignette),
  3754. n.uniform4fv(a.uGrainCoord, o.grainCoord),
  3755. n.uniform2fv(a.uGrainScaleBias, o.grainScaleBias),
  3756. e = 1 < this.sampleCount && 0 <= this.sampleIndex) {
  3757. var h = 1 / (1 + this.sampleIndex);
  3758. this.sampleIndex += 1,
  3759. h < 1 && (n.enable(n.BLEND),
  3760. n.blendColor(h, h, h, h),
  3761. n.blendFunc(n.CONSTANT_ALPHA, n.ONE_MINUS_CONSTANT_ALPHA)),
  3762. this.aaTarget.bind()
  3763. } else
  3764. m.bindNone(n),
  3765. 1 < this.sampleCount && (this.sampleIndex += 1);
  3766. n.viewport(0, 0, t, i),
  3767. this.fillScreen(s.attribs.vCoord),
  3768. e && (h < 1 && n.disable(n.BLEND),
  3769. m.bindNone(n),
  3770. this.aaShader.bind(),
  3771. this.aaBuffer.bind(this.aaShader.samplers.tInput),
  3772. this.fillScreen(this.aaShader.attribs.vCoord))
  3773. }
  3774. },
  3775. A.prototype.allocAABuffer = function (e, t) {
  3776. this.aaBuffer && this.aaBuffer.desc.width == e && this.aaBuffer.desc.height == t || (this.aaBuffer && this.aaBuffer.destroy(),
  3777. this.aaBuffer = new U(this.gl, {
  3778. width: e,
  3779. height: t,
  3780. clamp: !0
  3781. }),
  3782. this.aaBuffer.loadArray(),
  3783. this.aaTarget = new m(this.gl, {
  3784. color0: this.aaBuffer,
  3785. ignoreStatus: !0
  3786. }))
  3787. },
  3788. A.prototype.adjustProjectionForSupersampling = function (e) {
  3789. if (1 < this.sampleCount) {
  3790. var t = this.currentSample(),
  3791. i = this.sampleOffsets[t][0] / e.size[0];
  3792. t = this.sampleOffsets[t][1] / e.size[1],
  3793. i = S.translation(S.empty(), i, t, 0);
  3794. S.mul(e.projectionMatrix, i, e.projectionMatrix)
  3795. }
  3796. },
  3797. A.prototype.discardAAHistory = function () {
  3798. this.sampleIndex = -1
  3799. },
  3800. A.prototype.currentSample = function () {
  3801. return (this.sampleIndex < 0 ? 0 : this.sampleIndex) % this.sampleCount
  3802. },
  3803. A.prototype.fillScreen = function (e) {
  3804. var t = this.gl;
  3805. t.bindBuffer(t.ARRAY_BUFFER, this.fullscreenTriangle),
  3806. t.enableVertexAttribArray(e),
  3807. t.vertexAttribPointer(e, 2, t.FLOAT, !1, 0, 0),
  3808. t.drawArrays(t.TRIANGLES, 0, 3),
  3809. t.disableVertexAttribArray(e),
  3810. t.bindBuffer(t.ARRAY_BUFFER, null)
  3811. },
  3812. A.prototype.blitTexture = function (e) {
  3813. this.aaShader.bind(),
  3814. e.bind(this.aaShader.samplers.tInput),
  3815. this.fillScreen(this.aaShader.attribs.vCoord)
  3816. },
  3817. k.prototype.load = function (e) {
  3818. var t, i = this.gl,
  3819. s = e.extract("scene.json");
  3820. if (void 0 === s)
  3821. return !1;
  3822. if (!e.checkSignature(s))
  3823. return !1;
  3824. if (null == (s = new u(s.data).asString()) || s.length <= 0)
  3825. return !1;
  3826. try {
  3827. t = JSON.parse(s)
  3828. } catch (e) {
  3829. return console.error(e),
  3830. !1
  3831. }
  3832. for (var n in this.metaData = t.metaData,
  3833. this.view = new H(t.mainCamera.view),
  3834. this.sky = new _(this.gl, e, t.sky),
  3835. this.lights = new x(t.lights, this.view),
  3836. this.materialsList = [],
  3837. this.materials = {},
  3838. t.materials) {
  3839. var r = t.materials[n];
  3840. r.lightCount = this.lights.count,
  3841. r.shadowCount = this.lights.shadowCount,
  3842. s = new b(this.gl, e, r),
  3843. this.materials[r.name] = s,
  3844. this.materialsList.push(s)
  3845. }
  3846. if (t.meshes)
  3847. for (r = 0; r < t.meshes.length; ++r) {
  3848. n = t.meshes[r],
  3849. n = new T(this.gl, n, e.extract(n.file)),
  3850. this.meshes.push(n);
  3851. for (var a = 0; a < n.desc.subMeshes.length; ++a) {
  3852. var o = n.desc.subMeshes[a];
  3853. (s = this.materials[o.material]) && (n.numSubMeshes++,
  3854. this.meshRenderables.push(new w(n, o, s)))
  3855. }
  3856. }
  3857. return this.bounds = new d(this.meshes),
  3858. this.postRender = new A(this.gl, t.mainCamera.post, !0),
  3859. this.shadow = new E(i, this.lights.shadowCount),
  3860. this.cameras = t.Cameras,
  3861. t.AnimData && (this.sceneAnimator = new P(this, e, t.AnimData)),
  3862. t.fog && (this.fog = new f(i, t.fog)),
  3863. t.shadowFloor && (this.shadowFloor = new B(i, t.shadowFloor, this.shadow, this.lights)),
  3864. this.sceneLoaded = !0
  3865. },
  3866. k.prototype.update = function () {
  3867. this.sceneAnimator && (this.frameCounter++,
  3868. this.lights.flagUpdateAnimatedLighting(),
  3869. this.sceneAnimator.drawAnimated && (1 == this.frameCounter ? this.sceneAnimator.resetPlayback() : this.sceneAnimator.updateAnimationPlayback())),
  3870. this.lights.update(this.view, this.bounds)
  3871. },
  3872. k.prototype.collectShadows = function (e) {
  3873. this.shadow.collect(this, e)
  3874. },
  3875. k.prototype.draw = function (e) {
  3876. var t = this.gl;
  3877. if (this.sceneLoaded) {
  3878. this.sky.setClearColor(),
  3879. t.clear(t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT | t.STENCIL_BUFFER_BIT),
  3880. t.enable(t.DEPTH_TEST),
  3881. this.sky.draw(this),
  3882. this.shadowFloor && this.shadowFloor.draw(this);
  3883. for (var i = 0; i < this.meshRenderables.length; ++i)
  3884. this.meshRenderables[i].material.usesBlending || this.meshRenderables[i].material.usesRefraction || !this.meshRenderables[i].visible || this.meshRenderables[i].draw(this);
  3885. for (t.enable(t.POLYGON_OFFSET_FILL),
  3886. t.polygonOffset(1, 1),
  3887. t.colorMask(!1, !1, !1, !1),
  3888. i = 0; i < this.meshRenderables.length; ++i)
  3889. this.meshRenderables[i].drawAlphaPrepass(this);
  3890. for (t.colorMask(!0, !0, !0, !0),
  3891. t.disable(t.POLYGON_OFFSET_FILL),
  3892. t.depthFunc(t.LEQUAL),
  3893. t.depthMask(!1),
  3894. i = 0; i < this.meshRenderables.length; ++i)
  3895. this.meshRenderables[i].material.usesBlending && this.meshRenderables[i].visible && this.meshRenderables[i].draw(this);
  3896. t.disable(t.BLEND),
  3897. t.depthMask(!0),
  3898. t.depthFunc(t.LESS);
  3899. var s = !1;
  3900. for (i = 0; i < this.meshRenderables.length; ++i)
  3901. if (this.meshRenderables[i].material.usesRefraction) {
  3902. s = !0;
  3903. break
  3904. }
  3905. if (s)
  3906. 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),
  3907. this.refractionSurface.loadArray(null, e.color0.format, e.color0.componentType),
  3908. this.refractionBuffer = new m(this.gl, {
  3909. color0: this.refractionSurface
  3910. })),
  3911. this.refractionBuffer.bind(),
  3912. this.postRender.blitTexture(e.color0),
  3913. e.bind(),
  3914. i = 0; i < this.meshRenderables.length; ++i)
  3915. this.meshRenderables[i].material.usesRefraction && this.meshRenderables[i].visible && this.meshRenderables[i].draw(this);
  3916. if (this.stripData.activeWireframe() && 0 < this.meshRenderables.length) {
  3917. for (i = 0; i < this.meshRenderables.length; ++i)
  3918. this.meshRenderables[i].visible && this.meshRenderables[i].drawWire(this);
  3919. t.depthMask(!0)
  3920. }
  3921. t.disable(t.BLEND)
  3922. }
  3923. },
  3924. k.prototype.drawSecondary = function (e) {
  3925. this.fog && this.fog.draw(this, e)
  3926. },
  3927. k.prototype.complete = function () {
  3928. if (!this.sky.complete() || !this.shadow.complete() || this.fog && !this.fog.complete() || this.shadowFloor && !this.shadowFloor.complete())
  3929. return !1;
  3930. for (var e = 0; e < this.meshRenderables.length; ++e)
  3931. if (!this.meshRenderables[e].complete())
  3932. return !1;
  3933. return !0
  3934. },
  3935. P.prototype.flagAllForDebugging = function () {
  3936. for (var e = this.animations.length, t = 0; t < e; t++)
  3937. for (var i = this.animations[t], s = i.animatedObjects.length, n = 0; n < s; n++)
  3938. i.animatedObjects[n].debugMe = !0
  3939. },
  3940. P.prototype.checkDebug = function () {
  3941. this.debugString = "<br>--------------------------------------Debug Info:",
  3942. this.debugString += "<br>this.selectedAnimationIndex :" + this.selectedAnimationIndex;
  3943. var e = this.animations[this.selectedAnimationIndex],
  3944. t = e.animatedObjects.length;
  3945. this.debugString += "<br>numAnimatedObjects :" + t,
  3946. "" != e.debugString && (this.debugString += "<br>--------------------------------------------------Got animation bug info:",
  3947. this.debugString += e.debugString,
  3948. this.showDebugInfo = this.stopEverything = !0,
  3949. e.debugString = "");
  3950. for (var i = 0; i < t; i++) {
  3951. var s = e.animatedObjects[i];
  3952. "" == s.debugString && "" == s.animatedLocalTransform.debugString || (this.debugString += "<br>--------------------------------------------------Got object bug info:",
  3953. this.debugString += s.debugString,
  3954. this.debugString += s.animatedLocalTransform.debugString,
  3955. this.showDebugInfo = this.stopEverything = !0,
  3956. s.debugString = "",
  3957. s.animatedLocalTransform.debugString = ""),
  3958. s.skinningRig && "" != s.skinningRig.debugString && (this.debugString += "<br>--------------------------------------------------Got skin rig info:",
  3959. this.debugString += s.skinningRig.debugString,
  3960. s.skinningRig.debugString = "",
  3961. this.showDebugInfo = this.stopEverything = !0)
  3962. }
  3963. this.debugString += "<br>--------------------------------------Done Debug Info:"
  3964. },
  3965. P.prototype.logObjectInfo = function (e, t) {
  3966. var i = t * (o = this.animations[this.selectedAnimationIndex]).originalFPS;
  3967. if (e >= o.animatedObjects.length)
  3968. this.debugString += "object index " + e + " exceeds " + o.animatedObjects.length;
  3969. else {
  3970. var s = o.animatedObjects[e],
  3971. n = o.animatedObjects[s.modelPartIndex],
  3972. r = o.getObjectAnimationFramePercent(s, t),
  3973. a = o.getObjectAnimationFramePercent(n, t);
  3974. this.debugString = "",
  3975. this.debugString += "<br>Object Name: " + s.name,
  3976. this.debugString += "<br>Object Type: " + s.sceneObjectType,
  3977. this.debugString += "<br>Object Index: " + s.id,
  3978. this.debugString += "<br>Part Index: " + s.modelPartIndex,
  3979. this.debugString += "<br>Part Scale: " + s.modelPartScale,
  3980. this.debugString += "<br>Mesh Index: " + s.meshIndex,
  3981. this.debugString += "<br>Light Index: " + s.lightIndex,
  3982. this.debugString += "<br>Deformer Index: " + s.skinningRigIndex,
  3983. this.debugString += "<br>Parent Index: " + s.parentIndex,
  3984. this.debugString += "<br>Scene time " + t,
  3985. this.debugString += "<br>Scene framepercent " + i,
  3986. this.debugString += "<br>Object looped framepercent " + r,
  3987. this.debugString += "<br>Model looped framepercent " + a,
  3988. this.debugString += "<br>Object Anim length " + s.animationLength,
  3989. this.debugString += "<br>Object Total frames " + s.totalFrames,
  3990. this.debugString += "<br>Object FPS " + s.modelPartFPS,
  3991. this.debugString += "<br>Model Part Anim length " + n.animationLength,
  3992. this.debugString += "<br>Model total frames " + n.totalFrames,
  3993. this.debugString += "<br>Model Part FPS " + n.modelPartFPS,
  3994. i = S.identity(),
  3995. o.getWorldTransform(s.id, t, i, this.sceneScale, !0),
  3996. this.debugString += s.debugString;
  3997. var o = i[0],
  3998. h = (s = i[1],
  3999. n = i[2],
  4000. r = i[4],
  4001. a = i[5],
  4002. i[6]),
  4003. l = i[8],
  4004. d = i[9];
  4005. i = i[10];
  4006. Math.sqrt(o * o + s * s + n * n),
  4007. Math.sqrt(r * r + a * a + h * h),
  4008. Math.sqrt(l * l + d * d + i * i)
  4009. }
  4010. },
  4011. P.prototype.resetPlayback = function () {
  4012. this.startMS = Date.now(),
  4013. this.animationProgress = this.totalSeconds = 0,
  4014. this.setAnimationProgress(0, !0)
  4015. },
  4016. P.prototype.pause = function (e) {
  4017. this.paused = e,
  4018. this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed)
  4019. },
  4020. P.prototype.setAnimationProgress = function (e, t) {
  4021. var i = this.animations[this.selectedAnimationIndex];
  4022. this.animationProgress = e,
  4023. this.totalSeconds = i.totalSeconds * this.animationProgress,
  4024. this.totalSeconds -= 1 / i.originalFPS,
  4025. this.totalSeconds < 0 && (this.totalSeconds = 0),
  4026. this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed),
  4027. t && this.updateScene()
  4028. },
  4029. P.prototype.setPlaybackSpeed = function (e) {
  4030. this.playbackSpeed = e,
  4031. this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed)
  4032. },
  4033. P.prototype.resetCustomView = function () {
  4034. 0 <= this.selectedCameraIndex && this.selectedCameraIndex < this.views.length && (this.viewYawOffsets[this.selectedCameraIndex] = 0,
  4035. this.viewPitchOffsets[this.selectedCameraIndex] = 0,
  4036. this.scene.view.rotation[1] = this.views[this.selectedCameraIndex].rotation[1],
  4037. this.scene.view.rotation[0] = this.views[this.selectedCameraIndex].rotation[0],
  4038. this.setViewFromSelectedCamera())
  4039. },
  4040. P.prototype.updateUserCamera = function () {
  4041. if (this.clearCacheForCameraChildren(),
  4042. 0 <= this.selectedCameraIndex && this.selectedCameraIndex < this.views.length && this.selectedAnimationIndex < this.animations.length) {
  4043. var e = this.cameraObjectIndices[this.selectedCameraIndex],
  4044. t = this.animations[this.selectedAnimationIndex];
  4045. if (e < t.animatedObjects.length) {
  4046. var i = this.views[this.selectedCameraIndex],
  4047. s = this.scene.view.rotation[1],
  4048. n = this.scene.view.rotation[0],
  4049. r = n - i.rotation[0];
  4050. this.viewYawOffsets[this.selectedCameraIndex] = s - i.rotation[1],
  4051. this.viewPitchOffsets[this.selectedCameraIndex] = r,
  4052. i = t.animatedObjects[e],
  4053. t.getObjectAnimationFramePercent(i, this.totalSeconds);
  4054. r = S.identity();
  4055. var a = S.identity();
  4056. i.useFixedWorldTransform = !1,
  4057. i.useFixedLocalTransform = !1,
  4058. i.animatedLocalTransform.lockTransform = !1,
  4059. i.animatedLocalTransform.clearCachedTransforms(),
  4060. i.cachedFrame0 = -1,
  4061. i.cachedFrame1 = -1,
  4062. i.cachedFrame2 = -1,
  4063. i.cachedFrame3 = -1,
  4064. i.cachedFrameUse0 = 0,
  4065. i.cachedFrameUse1 = 0,
  4066. i.cachedFrameUse2 = 0,
  4067. i.cachedFrameUse3 = 0,
  4068. t.getWorldTransform(e, this.totalSeconds, a, this.sceneScale, !1);
  4069. e = a[0];
  4070. var o = a[1],
  4071. h = a[2],
  4072. l = a[4],
  4073. d = a[5],
  4074. c = a[6],
  4075. u = a[8],
  4076. f = a[9],
  4077. m = a[10];
  4078. e = Math.sqrt(e * e + o * o + h * h),
  4079. l = Math.sqrt(l * l + d * d + c * c),
  4080. d = Math.sqrt(u * u + f * f + m * m);
  4081. (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),
  4082. s = S.rotation(S.empty(), s, 1),
  4083. n = S.rotation(S.empty(), n, 0),
  4084. S.mul(r, s, n),
  4085. n = Math.sqrt(c * c + o * o + a * a),
  4086. s = this.scene.view.pivot[1] + r[9] * n,
  4087. a = this.scene.view.pivot[2] + r[10] * n,
  4088. r[12] = this.scene.view.pivot[0] + r[8] * n,
  4089. r[13] = s,
  4090. r[14] = a,
  4091. n = S.identity(),
  4092. t.getWorldTransform(i.parentIndex, this.totalSeconds, n, this.sceneScale, !1),
  4093. t = S.identity(),
  4094. S.invert(t, n),
  4095. n = S.identity(),
  4096. S.mul(n, t, r),
  4097. n[12] /= this.sceneScale,
  4098. n[13] /= this.sceneScale,
  4099. n[14] /= this.sceneScale,
  4100. r[0] *= e,
  4101. r[1] *= e,
  4102. r[2] *= e,
  4103. r[4] *= l,
  4104. r[5] *= l,
  4105. r[6] *= l,
  4106. r[8] *= d,
  4107. r[9] *= d,
  4108. r[10] *= d,
  4109. i.setFixedWorldTransform(r),
  4110. i.setFixedLocalTransform(n)
  4111. }
  4112. }
  4113. },
  4114. P.prototype.setViewFromSelectedCamera = function () {
  4115. if (0 <= this.selectedCameraIndex && this.selectedCameraIndex < this.views.length) {
  4116. var e = this.views[this.selectedCameraIndex],
  4117. t = this.scene.view,
  4118. i = this.viewYawOffsets[this.selectedCameraIndex],
  4119. s = this.viewPitchOffsets[this.selectedCameraIndex];
  4120. t.pivot[0] = e.pivot[0],
  4121. t.pivot[1] = e.pivot[1],
  4122. t.pivot[2] = e.pivot[2],
  4123. t.rotation[0] = e.rotation[0] + s,
  4124. t.rotation[1] = e.rotation[1] + i,
  4125. t.radius = e.radius,
  4126. t.nearPlane = e.nearPlane,
  4127. t.fov = e.fov,
  4128. t.saveResetView(),
  4129. t.updateProjection(),
  4130. t.updateView()
  4131. }
  4132. },
  4133. P.prototype.selectDefaultCamera = function () {
  4134. if (-1 != this.defaultCameraGlobalIndex && 0 < this.animations.length)
  4135. for (var e = this.animations[0], t = e.cameraObjects.length, i = 0; i < t; i++)
  4136. if (e.cameraObjects[i].id == this.defaultCameraGlobalIndex)
  4137. return void(this.selectedCameraIndex = i);
  4138. this.selectedCameraIndex = 0
  4139. },
  4140. P.prototype.updateAnimationPlayback = function () {
  4141. if (!this.stopEverything || !this.runDebugMode) {
  4142. var e = this.animations[this.selectedAnimationIndex];
  4143. if (this.updateUserCamera(),
  4144. this.paused || !this.playAnimations)
  4145. this.startMS = 0 < this.playbackSpeed ? Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed) : Date.now() - 1e3 * this.totalSeconds,
  4146. this.refreshTransformsOnly(),
  4147. this.runDebugMode && this.checkDebug(),
  4148. (e = this.scene.view).saveResetView(),
  4149. e.updateProjection(),
  4150. e.updateView();
  4151. else {
  4152. this.lockPlayback && 0 < this.playbackSpeed && (this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed));
  4153. var t = (Date.now() - this.startMS) / 1e3 * this.playbackSpeed * this.scenePlaybackSpeed;
  4154. this.totalSeconds = (Date.now() - this.startMS) / 1e3 * this.playbackSpeed * this.scenePlaybackSpeed;
  4155. var i = (i = t / e.totalSeconds) - (t = Math.floor(i));
  4156. t != this.loopCount && (this.loopCount++,
  4157. this.loopTurntables && this.rolloverTurntables(),
  4158. this.autoAdvanceNextAnimation && (this.nextAnimation(),
  4159. this.resetPlayback())),
  4160. this.totalSeconds = e.totalSeconds * i,
  4161. this.animationProgress = this.totalSeconds / e.totalSeconds - Math.floor(this.totalSeconds / e.totalSeconds),
  4162. this.updateScene(),
  4163. this.runDebugMode && this.checkDebug()
  4164. }
  4165. }
  4166. },
  4167. P.prototype.updateScene = function () {
  4168. this.lastSceneFramePercent = this.totalSeconds * this.animations[this.selectedAnimationIndex].originalFPS,
  4169. 0 != this.fogObjectIndex && this.updateFog(),
  4170. this.animateTurntables && this.updateTurntables(),
  4171. this.animateMeshes && this.poseMeshes(),
  4172. this.animateLights && this.updateLights(),
  4173. this.animateMaterials && this.updateMaterials(),
  4174. this.animateVisibility && this.updateVisibility()
  4175. },
  4176. P.prototype.findCameraChildren = function () {
  4177. for (var e = this.animations[0], t = e.animatedObjects.length, i = 0; i < t; i++)
  4178. e.hasParentTypeInHierarchy(e.animatedObjects[i], "CameraSO") && this.cameraChildrenIndices.push(i)
  4179. },
  4180. P.prototype.findFixedTransforms = function () {
  4181. for (var e = this.animations.length, t = 0; t < e; t++)
  4182. for (var i = this.animations[t], s = i.animatedObjects.length, n = 0; n < s; n++) {
  4183. var r = i.animatedObjects[n];
  4184. if (!r.useFixedWorldTransform && !i.hasAnimationInHierarchy(r))
  4185. if ("Material" == r.sceneObjectType)
  4186. r.setFixedWorldTransform(S.identity()),
  4187. r.setFixedLocalTransform(S.identity());
  4188. else {
  4189. var a = S.identity(),
  4190. o = S.identity();
  4191. i.hasParentTypeInHierarchy(r, "SceneRootSO") ? (i.getWorldTransform(r.id, 0, a, this.sceneScale, !1),
  4192. r.evaluateLocalTransformAtFramePercent(0, o, !0, !1)) : (i.evaluateModelPartTransformAtFrame(r.id, 0, a, !1),
  4193. r.evaluateLocalTransformAtFramePercent(0, o, !1, !1)),
  4194. r.setFixedWorldTransform(a),
  4195. r.setFixedLocalTransform(o)
  4196. }
  4197. }
  4198. },
  4199. P.prototype.clearCacheForCameraChildren = function () {
  4200. for (var e = this.animations[this.selectedAnimationIndex], t = this.cameraChildrenIndices.length, i = 0; i < t; i++) {
  4201. var s = e.animatedObjects[this.cameraChildrenIndices[i]];
  4202. s.useFixedWorldTransform = !1,
  4203. s.useFixedLocalTransform = !1,
  4204. s.cachedFrame0 = -10,
  4205. s.cachedFrame1 = -10,
  4206. s.cachedFrame2 = -10,
  4207. s.cachedFrame3 = -10,
  4208. s.cachedFrameUse0 = 0,
  4209. s.cachedFrameUse1 = 0,
  4210. s.cachedFrameUse2 = 0,
  4211. s.cachedFrameUse3 = 0,
  4212. s.animatedLocalTransform.clearCachedTransforms(),
  4213. s.animatedLocalTransform.lockTransform = !1
  4214. }
  4215. },
  4216. P.prototype.refreshTransformsOnly = function () {
  4217. for (var e = this.animations[this.selectedAnimationIndex], t = e.meshObjects.length, i = 0; i < t; i++) {
  4218. var s = e.meshObjects[i];
  4219. if (e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0),
  4220. this.enableSkinning && s.skinningRig && this.unitScaleSkinnedMeshes && !s.skinningRig.isRigidSkin) {
  4221. var n = (s = s.mesh.displayMatrix)[0],
  4222. r = s[1],
  4223. a = s[2],
  4224. o = s[4],
  4225. h = s[5],
  4226. l = s[6],
  4227. d = s[8],
  4228. c = s[9],
  4229. u = s[10];
  4230. 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;
  4231. s[0] /= d,
  4232. s[1] /= d,
  4233. s[2] /= d,
  4234. s[4] /= d,
  4235. s[5] /= d,
  4236. s[6] /= d,
  4237. s[8] /= d,
  4238. s[9] /= d,
  4239. s[10] /= d
  4240. }
  4241. }
  4242. if (this.animateLights)
  4243. for (t = e.lightObjects.length,
  4244. i = 0; i < t; i++)
  4245. (s = e.lightObjects[i]).useFixedWorldTransform || (d = this.scene.lights.getLightPos(s.lightIndex),
  4246. c = this.scene.lights.getLightDir(s.lightIndex),
  4247. u = S.identity(),
  4248. e.getWorldTransform(s.id, this.totalSeconds, u, this.sceneScale, !0),
  4249. c[0] = u[8],
  4250. c[1] = u[9],
  4251. c[2] = u[10],
  4252. 0 != d[3] && (d[0] = u[12],
  4253. d[1] = u[13],
  4254. d[2] = u[14],
  4255. this.scene.lights.setLightPos(s.lightIndex, d)),
  4256. this.scene.lights.setLightDir(s.lightIndex, c))
  4257. },
  4258. P.prototype.findMeshIndexByPartIndex = function (e, t) {
  4259. for (var i = 0; i < this.meshIDs.length; ++i)
  4260. if (t == this.meshIDs[i])
  4261. return i;
  4262. return -1
  4263. },
  4264. P.prototype.findLightIndexByPartIndex = function (e) {
  4265. for (var t = 0; t < this.lightIDs.length; t++)
  4266. if (e == this.lightIDs[t])
  4267. return t;
  4268. return -1
  4269. },
  4270. P.prototype.findMaterialIndexByPartIndex = function (e) {
  4271. for (var t = 0; t < this.materialIDs.length; t++)
  4272. if (e == this.materialIDs[t])
  4273. return t;
  4274. return -1
  4275. },
  4276. P.prototype.nextAnimation = function () {
  4277. this.selectedAnimationIndex++,
  4278. this.selectedAnimationIndex >= this.animations.length && (this.selectedAnimationIndex = 0)
  4279. },
  4280. P.prototype.selectAnimation = function (e) {
  4281. 0 <= e && e < this.animations.length && (this.selectedAnimationIndex = e),
  4282. this.paused && this.setAnimationProgress(this.animationProgress, !0)
  4283. },
  4284. P.prototype.selectCamera = function (e) {
  4285. -1 != e && this.selectedCameraIndex != e && (this.selectedCameraIndex = e,
  4286. this.setViewFromSelectedCamera())
  4287. },
  4288. P.prototype.getAnimatedCamera = function () {
  4289. if (0 <= this.selectedCameraIndex && this.selectedAnimationIndex < this.animations.length) {
  4290. var e = this.animations[this.selectedAnimationIndex];
  4291. if (this.selectedCameraIndex < e.cameraObjects.length)
  4292. return e.cameraObjects[this.selectedCameraIndex]
  4293. }
  4294. },
  4295. P.prototype.poseMeshes = function () {
  4296. for (var e = this.animations[this.selectedAnimationIndex], t = e.meshObjects.length, i = 0; i < t; i++) {
  4297. var s = e.meshObjects[i];
  4298. if (this.enableSkinning && s.skinningRig)
  4299. if (s.skinningRig.isRigidSkin)
  4300. e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0);
  4301. else {
  4302. s.setupSkinningRig(e, s.modelPartIndex, this.totalSeconds, s.skinningRig),
  4303. e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0);
  4304. var n = s.modelPartScale * this.sceneScale;
  4305. if (this.unitScaleSkinnedMeshes) {
  4306. var r = s.mesh.displayMatrix,
  4307. a = r[0],
  4308. o = r[1],
  4309. h = r[2],
  4310. l = r[4],
  4311. d = r[5],
  4312. c = r[6],
  4313. u = r[8],
  4314. f = r[9],
  4315. m = r[10];
  4316. 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;
  4317. r[0] /= u,
  4318. r[1] /= u,
  4319. r[2] /= u,
  4320. r[4] /= u,
  4321. r[5] /= u,
  4322. r[6] /= u,
  4323. r[8] /= u,
  4324. r[9] /= u,
  4325. r[10] /= u,
  4326. n *= u
  4327. }
  4328. s.skinningRig.deformMesh(s.mesh, n)
  4329. }
  4330. else
  4331. e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0)
  4332. }
  4333. },
  4334. P.prototype.updateLights = function () {
  4335. for (var e = this.animations[this.selectedAnimationIndex], t = this.totalSeconds * e.originalFPS, i = e.lightObjects.length, s = 0; s < i; s++) {
  4336. var n = e.lightObjects[s],
  4337. r = this.scene.lights.getLightPos(n.lightIndex),
  4338. a = this.scene.lights.getLightDir(n.lightIndex),
  4339. o = this.scene.lights.getLightColor(n.lightIndex),
  4340. h = S.identity(),
  4341. l = 1;
  4342. n.useFixedWorldTransform || e.getWorldTransform(n.id, this.totalSeconds, h, this.sceneScale, !0),
  4343. n.redProperty && (n.redProperty.evaluate(t, o[0], n),
  4344. o[0] = n.redProperty.lastValue),
  4345. n.greenProperty && (n.greenProperty.evaluate(t, o[1], n),
  4346. o[1] = n.greenProperty.lastValue),
  4347. n.blueProperty && (n.blueProperty.evaluate(t, o[2], n),
  4348. o[2] = n.blueProperty.lastValue),
  4349. n.brightnessProperty && (n.brightnessProperty.evaluate(t, l, n),
  4350. l = n.brightnessProperty.lastValue),
  4351. o[0] *= l,
  4352. o[1] *= l,
  4353. o[2] *= l,
  4354. 0 != r[3] && (n.useFixedWorldTransform || (r[0] = h[12],
  4355. r[1] = h[13],
  4356. r[2] = h[14],
  4357. this.scene.lights.setLightPos(n.lightIndex, r)),
  4358. n.spotAngleProperty && 0 < this.scene.lights.spot[3 * n.lightIndex] && (r = 0,
  4359. n.spotAngleProperty.evaluate(t, r, n),
  4360. r = n.spotAngleProperty.lastValue,
  4361. this.scene.lights.setLightSpotAngle(n.lightIndex, r)),
  4362. n.spotSharpnessProperty && (r = 0,
  4363. n.spotSharpnessProperty.evaluate(t, r, n),
  4364. r = n.spotSharpnessProperty.lastValue,
  4365. this.scene.lights.setLightSpotSharpness(n.lightIndex, r)),
  4366. n.distanceProperty && (r = 1,
  4367. n.distanceProperty.evaluate(t, r, n),
  4368. r = n.distanceProperty.lastValue * this.sceneScale,
  4369. this.scene.lights.setLightDistance(n.lightIndex, r))),
  4370. n.useFixedWorldTransform || (a[0] = h[8],
  4371. a[1] = h[9],
  4372. a[2] = h[10],
  4373. this.scene.lights.setLightDir(n.lightIndex, a)),
  4374. this.scene.lights.setLightColor(n.lightIndex, o)
  4375. }
  4376. },
  4377. P.prototype.updateTurntables = function () {
  4378. for (var e = this.animations[this.selectedAnimationIndex], t = this.totalSeconds * e.originalFPS, i = e.turnTableObjects.length, s = 0; s < i; s++) {
  4379. var n = e.turnTableObjects[s];
  4380. n.spinProperty.evaluate(t, 0, n),
  4381. n.turnTableSpin = n.turnTableSpinOffset + n.spinProperty.lastValue * this.totalSeconds
  4382. }
  4383. },
  4384. P.prototype.rolloverTurntables = function () {
  4385. for (var e = this.animations[this.selectedAnimationIndex], t = e.turnTableObjects.length, i = 0; i < t; i++) {
  4386. var s = e.turnTableObjects[i];
  4387. s.turnTableSpinOffset = s.turnTableSpin
  4388. }
  4389. },
  4390. P.prototype.updateMaterials = function () {
  4391. for (var e = this.animations[this.selectedAnimationIndex], t = this.totalSeconds * e.originalFPS, i = e.materialObjects.length, s = 0; s < i; s++) {
  4392. var n = e.materialObjects[s];
  4393. n.offsetUProperty && (n.offsetUProperty.evaluate(t, 0, n),
  4394. this.scene.materialsList[n.materialIndex].uOffset = n.offsetUProperty.lastValue),
  4395. n.offsetVProperty && (n.offsetVProperty.evaluate(t, 0, n),
  4396. this.scene.materialsList[n.materialIndex].vOffset = n.offsetVProperty.lastValue),
  4397. n.emissiveProperty && 1 < n.emissiveProperty.numKeyframes && (n.emissiveProperty.evaluate(t, 0, n),
  4398. this.scene.materialsList[n.materialIndex].emissiveIntensity = n.emissiveProperty.lastValue)
  4399. }
  4400. },
  4401. P.prototype.updateFog = function () {
  4402. var e = this.animations[this.selectedAnimationIndex],
  4403. t = this.totalSeconds * e.originalFPS;
  4404. 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)),
  4405. e.greenProperty && (this.scene.fog.desc.color[1] = e.greenProperty.evaluate(t, this.scene.fog.desc.color[1], e)),
  4406. e.blueProperty && (this.scene.fog.desc.color[2] = e.blueProperty.evaluate(t, this.scene.fog.desc.color[2], e)),
  4407. e.distanceProperty && (this.scene.fog.desc.distance = e.distanceProperty.evaluate(t, this.scene.fog.desc.distance, e)),
  4408. e.opacityProperty && (this.scene.fog.desc.opacity = e.opacityProperty.evaluate(t, this.scene.fog.desc.opacity, e)),
  4409. e.skyIllumProperty && (this.scene.fog.desc.skyIllum = e.skyIllumProperty.evaluate(t, this.scene.fog.desc.skyIllum, e)),
  4410. e.lightIllumProperty && (this.scene.fog.desc.lightIllum = e.lightIllumProperty.evaluate(t, this.scene.fog.desc.lightIllum, e)),
  4411. e.dispersionProperty && (this.scene.fog.desc.dispersion = e.dispersionProperty.evaluate(t, this.scene.fog.desc.dispersion, e)))
  4412. },
  4413. P.prototype.updateVisibility = function () {
  4414. for (var e = this.animations[this.selectedAnimationIndex], t = this.subMeshObjectIndices.length, i = 0; i < t; i++) {
  4415. if (-1 != (n = this.subMeshLiveIndices[i])) {
  4416. var s = this.subMeshObjectIndices[i],
  4417. n = this.scene.meshRenderables[n],
  4418. r = e.getObjectAnimationFramePercent(e.animatedObjects[s], this.totalSeconds);
  4419. n.visible = e.isVisibleAtFramePercent(s, r)
  4420. }
  4421. }
  4422. },
  4423. F.prototype.build = function (e, t) {
  4424. var i = this.gl;
  4425. this.program = i.createProgram(),
  4426. this.params = {},
  4427. this.samplers = {},
  4428. this.attribs = {};
  4429. var s = function (e) {
  4430. for (var t = "", i = e.indexOf("\n"), s = 0; - 1 != i;)
  4431. t += ++s + ": ",
  4432. t += e.substring(0, i + 1),
  4433. i = (e = e.substring(i + 1, e.length)).indexOf("\n");
  4434. console.log(t)
  4435. },
  4436. n = i.createShader(i.VERTEX_SHADER);
  4437. i.shaderSource(n, e),
  4438. i.compileShader(n),
  4439. i.getShaderParameter(n, i.COMPILE_STATUS) || (console.log(i.getShaderInfoLog(n)),
  4440. I.verboseErrors && s(e)),
  4441. i.attachShader(this.program, n),
  4442. n = i.createShader(i.FRAGMENT_SHADER),
  4443. i.shaderSource(n, t),
  4444. i.compileShader(n),
  4445. i.getShaderParameter(n, i.COMPILE_STATUS) || (console.log(i.getShaderInfoLog(n)),
  4446. I.verboseErrors && s(t)),
  4447. i.attachShader(this.program, n),
  4448. i.linkProgram(this.program),
  4449. i.getProgramParameter(this.program, i.LINK_STATUS) || console.log(i.getProgramInfoLog(this.program));
  4450. n = i.getProgramParameter(this.program, i.ACTIVE_UNIFORMS);
  4451. var r = 0;
  4452. for (s = 0; s < n; ++s) {
  4453. var a = i.getActiveUniform(this.program, s),
  4454. o = a.name,
  4455. h = o.indexOf("[");
  4456. 0 <= h && (o = o.substring(0, h)),
  4457. h = i.getUniformLocation(this.program, a.name),
  4458. a.type == i.SAMPLER_2D || a.type == i.SAMPLER_CUBE ? this.samplers[o] = {
  4459. location: h,
  4460. unit: r++
  4461. } : this.params[o] = h
  4462. }
  4463. for (n = i.getProgramParameter(this.program, i.ACTIVE_ATTRIBUTES),
  4464. s = 0; s < n; ++s)
  4465. r = i.getActiveAttrib(this.program, s),
  4466. this.attribs[r.name] = i.getAttribLocation(this.program, r.name)
  4467. },
  4468. F.prototype.bind = function () {
  4469. return !!this.program && (this.gl.useProgram(this.program),
  4470. !0)
  4471. },
  4472. F.prototype.complete = function () {
  4473. return !!this.program
  4474. },
  4475. O.prototype.fromURLs = function (e, t, i) {
  4476. var s = "";
  4477. if (i)
  4478. for (var n = 0; n < i.length; ++n)
  4479. s = i[n] + "\n" + s;
  4480. if (i = s + ":" + e + "|" + t,
  4481. void 0 !== (n = this.cache[i]))
  4482. return n;
  4483. function r() {
  4484. null != o && null != h && a.build(o, h)
  4485. }
  4486. var a = new F(this.gl),
  4487. o = null,
  4488. h = null;
  4489. return this.fetch(e, function (e) {
  4490. o = s + e,
  4491. r()
  4492. }),
  4493. this.fetch(t, function (e) {
  4494. h = s + e,
  4495. r()
  4496. }),
  4497. this.cache[i] = a
  4498. },
  4499. O.prototype.fetch = function (e, t) {
  4500. void 0 !== G ? void 0 !== G[e] ? this.resolveIncludes(new String(G[e]), t) : t("") : C.fetchText("src/shader/" + e, function (e) {
  4501. this.resolveIncludes(e, t)
  4502. }
  4503. .bind(this),
  4504. function () {
  4505. t("")
  4506. })
  4507. },
  4508. O.prototype.resolveIncludes = function (t, i) {
  4509. for (var r = [], a = !0, e = function (e, t, i, s, n) {
  4510. return a = !0,
  4511. r.push({
  4512. offset: n,
  4513. path: t.slice(1, t.length - 1)
  4514. }),
  4515. ""
  4516. }; a;)
  4517. a = !1,
  4518. t = t.replace(/#include\s((<[^>]+>)|("[^"]+"))/, e);
  4519. if (0 < r.length) {
  4520. var s = r.length;
  4521. for (e = 0; e < r.length; ++e)
  4522. this.fetch(r[e].path, function (e) {
  4523. if (this.src = e,
  4524. --s <= 0) {
  4525. for (e = r.length - 1; 0 <= e; --e)
  4526. t = t.substring(0, r[e].offset) + r[e].src + t.substring(r[e].offset);
  4527. i(t)
  4528. }
  4529. }
  4530. .bind(r[e]))
  4531. } else
  4532. i(t)
  4533. },
  4534. E.prototype.bindDepthTexture = function (e, t) {
  4535. this.shadowCount > t && this.depthTextures[t].bind(e)
  4536. },
  4537. E.prototype.collect = function (e, t) {
  4538. 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)
  4539. if (s.shadowsNeedUpdate[c]) {
  4540. d = !(s.shadowsNeedUpdate[c] = 0),
  4541. S.mul(l, r.subarray(16 * c, 16 * (c + 1)), o),
  4542. S.mul(l, a.subarray(16 * c, 16 * (c + 1)), l),
  4543. this.depthTargets[c].bind(),
  4544. i.clearColor(1, 1, 1, 1),
  4545. i.clear(i.COLOR_BUFFER_BIT | i.DEPTH_BUFFER_BIT);
  4546. var u = this.shaderSolid;
  4547. u.bind(),
  4548. i.uniformMatrix4fv(u.params.uViewProjection, !1, l),
  4549. i.uniformMatrix4fv(u.params.uMeshTransform, !1, S.identity());
  4550. for (var f = 0; f < e.meshRenderables.length; ++f) {
  4551. var m = e.meshRenderables[f],
  4552. p = m.material;
  4553. !m.mesh.desc.castShadows || !p.castShadows || 0 < p.shadowAlphaTest || (h && i.uniformMatrix4fv(u.params.uMeshTransform, !1, m.mesh.displayMatrix),
  4554. m.drawShadow(u.attribs.vPosition))
  4555. }
  4556. for ((u = this.shaderAlphaTest).bind(),
  4557. i.uniformMatrix4fv(u.params.uViewProjection, !1, l),
  4558. i.uniformMatrix4fv(u.params.uMeshTransform, !1, S.identity()),
  4559. f = 0; f < e.meshRenderables.length; ++f)
  4560. p = (m = e.meshRenderables[f]).material,
  4561. m.mesh.desc.castShadows && p.castShadows && 0 < p.shadowAlphaTest && (p.textures.albedo.bind(u.samplers.tAlbedo),
  4562. h && (i.uniform2f(u.params.uUVOffset, p.uOffset, p.vOffset),
  4563. i.uniformMatrix4fv(u.params.uMeshTransform, !1, m.mesh.displayMatrix)),
  4564. m.drawAlphaShadow(u.attribs.vPosition, u.attribs.vTexCoord))
  4565. }
  4566. d && (t.bind(),
  4567. i.enable(i.CULL_FACE),
  4568. i.cullFace(i.BACK))
  4569. },
  4570. E.prototype.complete = function () {
  4571. return this.shaderSolid.complete() && this.shaderAlphaTest.complete()
  4572. },
  4573. B.prototype.draw = function (e) {
  4574. var t = e.view,
  4575. i = e.lights,
  4576. s = e.shadow,
  4577. n = this.gl,
  4578. r = this.shader.params,
  4579. a = this.shader.samplers;
  4580. this.shader.bind(),
  4581. t = S.mul(S.empty(), t.projectionMatrix, t.viewMatrix),
  4582. S.mul(t, t, this.desc.transform),
  4583. n.uniformMatrix4fv(r.uModelViewProjectionMatrix, !1, t),
  4584. t = S.mul(S.empty(), i.matrix, this.desc.transform),
  4585. n.uniformMatrix4fv(r.uModelSkyMatrix, !1, t),
  4586. 0 < i.count && (n.uniform4fv(r.uLightPositions, i.positionBuffer),
  4587. n.uniform3fv(r.uLightDirections, i.directionBuffer),
  4588. n.uniform3fv(r.uLightColors, i.colors),
  4589. n.uniform3fv(r.uLightParams, i.parameters),
  4590. n.uniform3fv(r.uLightSpot, i.spot),
  4591. e = .392699 * e.postRender.currentSample(),
  4592. n.uniform2f(r.uShadowKernelRotation, .5 * Math.cos(e), .5 * Math.sin(e)),
  4593. 0 < i.shadowCount && (e = s.depthTextures[0].desc.width,
  4594. n.uniform2f(r.uShadowMapSize, e, 1 / e),
  4595. n.uniformMatrix4fv(r.uShadowMatrices, !1, i.finalTransformBuffer),
  4596. n.uniformMatrix4fv(r.uInvShadowMatrices, !1, i.inverseTransformBuffer),
  4597. n.uniform4fv(r.uShadowTexelPadProjections, i.shadowTexelPadProjections),
  4598. s.bindDepthTexture(a.tDepth0, 0),
  4599. s.bindDepthTexture(a.tDepth1, 1),
  4600. s.bindDepthTexture(a.tDepth2, 2))),
  4601. n.uniform3f(r.uShadowCatcherParams, this.desc.simple ? 1 : 0, this.desc.alpha, this.desc.edgeFade),
  4602. n.depthMask(!1),
  4603. n.enable(n.BLEND),
  4604. n.blendFunc(n.ZERO, n.SRC_COLOR),
  4605. i = this.shader.attribs.vPosition,
  4606. n.bindBuffer(n.ARRAY_BUFFER, this.quadGeom),
  4607. n.enableVertexAttribArray(i),
  4608. n.vertexAttribPointer(i, 3, n.FLOAT, !1, 0, 0),
  4609. n.drawArrays(n.TRIANGLES, 0, 6),
  4610. n.disableVertexAttribArray(i),
  4611. n.bindBuffer(n.ARRAY_BUFFER, null),
  4612. n.disable(n.BLEND),
  4613. n.depthMask(!0)
  4614. },
  4615. B.prototype.complete = function () {
  4616. return this.shader.complete()
  4617. },
  4618. L.prototype.solveAdditiveClusterTransform = function (e, t, i) {
  4619. t = S.identity();
  4620. var s = S.identity(),
  4621. n = S.identity();
  4622. S.mul(t, e, this.defaultClusterBaseTransform),
  4623. S.mul(s, this.defaultAssociateWorldTransformInvert, t),
  4624. S.mul(n, this.defaultAssociateWorldTransformInvert, s),
  4625. S.mul(i, this.defaultClusterWorldTransformInvert, n)
  4626. },
  4627. L.prototype.solveSimpleClusterTransform = function (e, t, i) {
  4628. var s = S.identity(),
  4629. n = S.identity();
  4630. S.invert(n, t),
  4631. S.mul(s, n, e),
  4632. S.mul(i, s, this.defaultClusterBaseTransform)
  4633. },
  4634. L.prototype.solveClusterTransformAtFrame = function (e, t, i, s) {
  4635. if (1 == this.linkMode) {
  4636. var n = S.identity();
  4637. t = S.identity(),
  4638. e.evaluateModelPartTransformAtFrame(this.linkObjectIndex, i, n, !1),
  4639. e.evaluateModelPartTransformAtFrame(this.associateObjectIndex, i, t, !1),
  4640. this.solveAdditiveClusterTransform(n, t, s)
  4641. } else {
  4642. n = S.identity();
  4643. var r = S.identity();
  4644. e.evaluateModelPartTransformAtFrame(this.linkObjectIndex, i, n, !1),
  4645. e.evaluateModelPartTransformAtFrame(t, i, r, !1),
  4646. this.solveSimpleClusterTransform(n, r, s)
  4647. }
  4648. },
  4649. M.prototype.unpackUnitVectors = function (e, t, i, s) {
  4650. for (var n = 0; n < i; n++) {
  4651. var r = t[s * n],
  4652. a = 32768 <= (o = t[s * n + 1]);
  4653. a && (o -= 32768);
  4654. var o, h = 1 - ((r = r / 32767.4 * 2 - 1) * r + (o = o / 32767.4 * 2 - 1) * o);
  4655. h = Math.sqrt(h),
  4656. h = isNaN(h) ? 0 : h;
  4657. a && (h = -h),
  4658. e[3 * n] = r,
  4659. e[3 * n + 1] = o,
  4660. e[3 * n + 2] = h
  4661. }
  4662. },
  4663. M.prototype.copyOriginalVertices = function (e) {
  4664. if (!this.unTransformedVertices)
  4665. if (this.unTransformedVertices = new Float32Array(3 * e.vertexCount),
  4666. this.unTransformedNormals = new Float32Array(3 * e.vertexCount),
  4667. this.unTransformedTangents = new Float32Array(3 * e.vertexCount),
  4668. this.unTransformedBiTangents = new Float32Array(3 * e.vertexCount),
  4669. this.skinVertexWeights = new Float32Array(e.vertexCount),
  4670. this.skinVertexTransform4x3 = new Float32Array(12),
  4671. e.dynamicVertexData) {
  4672. var t = new Float32Array(e.dynamicVertexData.buffer);
  4673. new Uint8Array(e.dynamicVertexData.buffer);
  4674. var i = s = 0,
  4675. s = s + 12 + 8;
  4676. e.secondaryTexCoord && (s += 8);
  4677. var n = s,
  4678. r = s += 4,
  4679. a = (s = s + 4,
  4680. e.stride / 2);
  4681. s = new Uint8Array(e.dynamicVertexData.subarray(s)),
  4682. s = new Uint16Array(s.buffer),
  4683. n = new Uint8Array(e.dynamicVertexData.subarray(n)),
  4684. n = new Uint16Array(n.buffer),
  4685. r = new Uint8Array(e.dynamicVertexData.subarray(r)),
  4686. r = new Uint16Array(r.buffer);
  4687. for (this.unpackUnitVectors(this.unTransformedNormals, s, e.vertexCount, a),
  4688. this.unpackUnitVectors(this.unTransformedTangents, n, e.vertexCount, a),
  4689. this.unpackUnitVectors(this.unTransformedBiTangents, r, e.vertexCount, a),
  4690. a = 0; a < e.vertexCount; a++)
  4691. r = (e.stride * a + i) / 4,
  4692. this.unTransformedVertices[3 * a] = t[r],
  4693. this.unTransformedVertices[3 * a + 1] = t[r + 1],
  4694. this.unTransformedVertices[3 * a + 2] = t[r + 2]
  4695. } else
  4696. this.debugString += "<br>Can't init skinning rig - mesh buffer is not dynamic - rigid is " + this.isRigidSkin
  4697. },
  4698. M.prototype.useOriginalMeshVertices = function (e) {
  4699. this.isRigidSkin ? this.debugString += "<br>useOriginalMeshVertices for rigid skin?" : this.copyOriginalVertices(e)
  4700. },
  4701. M.prototype.deformMeshVertices = function (e, t) {
  4702. if (0 != this.skinningClusters.length && this.unTransformedVertices) {
  4703. var i, s = e.stride / 4,
  4704. n = new Float32Array(e.dynamicVertexData.buffer),
  4705. r = new Uint16Array(e.dynamicVertexData.buffer);
  4706. new Uint8Array(e.dynamicVertexData.buffer),
  4707. i = 20,
  4708. e.secondaryTexCoord && (i += 8);
  4709. var a = i,
  4710. o = i += 4;
  4711. i += 4;
  4712. for (var h = this.unTransformedVertices.length / 3, l = 0, d = 0; d < h; ++d) {
  4713. var c = d,
  4714. u = (c * e.stride + a) / 2,
  4715. f = (c * e.stride + o) / 2,
  4716. m = (c * e.stride + i) / 2,
  4717. p = this.linkMapCount[c];
  4718. (k = this.skinVertexTransform4x3)[this.skinVertexWeights[c] = 0] = 0,
  4719. k[1] = 0,
  4720. k[2] = 0,
  4721. k[3] = 0,
  4722. k[4] = 0,
  4723. k[5] = 0,
  4724. k[6] = 0,
  4725. k[7] = 0,
  4726. k[8] = 0,
  4727. k[9] = 0,
  4728. k[10] = 0,
  4729. k[11] = 0;
  4730. var g = this.linkMapWeights[l];
  4731. if (1 == p && 1 == g) {
  4732. var v = this.linkMapClusterIndices[l],
  4733. x = (v = this.skinningClusters[v]).matrix;
  4734. k[0] = x[0],
  4735. k[1] = x[1],
  4736. k[2] = x[2],
  4737. k[3] = x[4],
  4738. k[4] = x[5],
  4739. k[5] = x[6],
  4740. k[6] = x[8],
  4741. k[7] = x[9],
  4742. k[8] = x[10],
  4743. k[9] = x[12],
  4744. k[10] = x[13],
  4745. k[11] = x[14],
  4746. this.skinVertexWeights[c] = 1
  4747. } else
  4748. for (var y = this.skinVertexWeights[c] = 0; y < p; y++)
  4749. g = this.linkMapWeights[l + y],
  4750. (v = this.linkMapClusterIndices[l + y]) < this.skinningClusters.length && (x = (v = this.skinningClusters[v]).matrix,
  4751. k[0] += g * x[0],
  4752. k[1] += g * x[1],
  4753. k[2] += g * x[2],
  4754. k[3] += g * x[4],
  4755. k[4] += g * x[5],
  4756. k[5] += g * x[6],
  4757. k[6] += g * x[8],
  4758. k[7] += g * x[9],
  4759. k[8] += g * x[10],
  4760. k[9] += g * x[12],
  4761. k[10] += g * x[13],
  4762. k[11] += g * x[14],
  4763. this.skinVertexWeights[c] += g,
  4764. 1 == v.linkMode && (this.skinVertexWeights[c] = 1));
  4765. if (l += this.linkMapCount[d],
  4766. 0 < this.skinVertexWeights[c]) {
  4767. var b = this.unTransformedVertices[3 * d + 0],
  4768. S = this.unTransformedVertices[3 * d + 1],
  4769. T = this.unTransformedVertices[3 * d + 2],
  4770. w = this.unTransformedNormals[3 * d + 0],
  4771. C = this.unTransformedNormals[3 * d + 1],
  4772. R = this.unTransformedNormals[3 * d + 2],
  4773. A = (v = this.unTransformedTangents[3 * d + 0],
  4774. x = this.unTransformedTangents[3 * d + 1],
  4775. this.unTransformedTangents[3 * d + 2]),
  4776. k = (p = this.unTransformedBiTangents[3 * d + 0],
  4777. this.unTransformedBiTangents[3 * d + 1]),
  4778. I = (g = this.unTransformedBiTangents[3 * d + 2],
  4779. y = this.skinVertexTransform4x3,
  4780. 1);
  4781. 0 < this.skinVertexWeights[c] && (I = 1 / this.skinVertexWeights[c]),
  4782. n[s * d] = I * (b * y[0] + S * y[3] + T * y[6] + y[9]) * t,
  4783. n[s * d + 1] = I * (b * y[1] + S * y[4] + T * y[7] + y[10]) * t,
  4784. n[s * d + 2] = I * (b * y[2] + S * y[5] + T * y[8] + y[11]) * t,
  4785. b = w * y[0] + C * y[3] + R * y[6],
  4786. c = w * y[1] + C * y[4] + R * y[7],
  4787. w = w * y[2] + C * y[5] + R * y[8],
  4788. C = v * y[0] + x * y[3] + A * y[6],
  4789. R = v * y[1] + x * y[4] + A * y[7],
  4790. v = v * y[2] + x * y[5] + A * y[8],
  4791. x = p * y[0] + k * y[3] + g * y[6],
  4792. A = p * y[1] + k * y[4] + g * y[7],
  4793. p = p * y[2] + k * y[5] + g * y[8],
  4794. c /= k = Math.sqrt(b * b + c * c + w * w),
  4795. w /= k,
  4796. k = 32767.4 * ((b /= k) / 2 + .5),
  4797. g = 32767.4 * (c / 2 + .5),
  4798. w < 0 && (g += 32768),
  4799. r[m] = Math.floor(k),
  4800. r[1 + m] = Math.floor(g),
  4801. R /= k = Math.sqrt(C * C + R * R + v * v),
  4802. v /= k,
  4803. k = 32767.4 * ((C /= k) / 2 + .5),
  4804. g = 32767.4 * (R / 2 + .5),
  4805. v < 0 && (g += 32768),
  4806. r[u] = Math.floor(k),
  4807. r[1 + u] = Math.floor(g),
  4808. A /= k = Math.sqrt(x * x + A * A + p * p),
  4809. p /= k,
  4810. k = 32767.4 * ((x /= k) / 2 + .5),
  4811. g = 32767.4 * (A / 2 + .5),
  4812. p < 0 && (g += 32768),
  4813. r[f] = Math.floor(k),
  4814. r[1 + f] = Math.floor(g)
  4815. } else
  4816. b = this.unTransformedVertices[3 * d + 0],
  4817. S = this.unTransformedVertices[3 * d + 1],
  4818. T = this.unTransformedVertices[3 * d + 2],
  4819. n[s * d] = b * t,
  4820. n[s * d + 1] = S * t,
  4821. n[s * d + 2] = T * t
  4822. }
  4823. }
  4824. },
  4825. M.prototype.deformMesh = function (e, t) {
  4826. if (0 != this.skinningClusters.length && !this.isRigidSkin) {
  4827. this.deformMeshVertices(e, t);
  4828. var i = e.gl;
  4829. i.bindBuffer(i.ARRAY_BUFFER, e.vertexBuffer),
  4830. i.bufferData(i.ARRAY_BUFFER, e.dynamicVertexData, i.DYNAMIC_DRAW),
  4831. i.bindBuffer(i.ARRAY_BUFFER, null)
  4832. }
  4833. },
  4834. _.prototype.setClearColor = function () {
  4835. if (I.transparentBackground)
  4836. this.gl.clearColor(0, 0, 0, 0);
  4837. else if (this.backgroundMode < 1) {
  4838. var e = this.backgroundColor;
  4839. this.gl.clearColor(e[0], e[1], e[2], 1)
  4840. } else
  4841. this.gl.clearColor(.0582, .06772, .07805, 1)
  4842. },
  4843. _.prototype.draw = function (e) {
  4844. if (this.backgroundMode < 1 || I.transparentBackground)
  4845. return !1;
  4846. if (this.complete()) {
  4847. var t = this.gl,
  4848. i = this.backgroundShader,
  4849. s = e.view,
  4850. n = e.lights.invMatrix;
  4851. i.bind(),
  4852. t.uniformMatrix4fv(i.params.uInverseSkyMatrix, !1, n),
  4853. t.uniformMatrix4fv(i.params.uViewProjection, !1, s.viewProjectionMatrix),
  4854. 3 == this.backgroundMode ? t.uniform4fv(i.params.uSkyCoefficients, this.backgroundCoefficients) : this.backgroundTexture.bind(i.samplers.tSkyTexture),
  4855. e = .07 + .94 * (1 - e.stripData.activeFade()),
  4856. t.uniform1f(i.params.uAlpha, e),
  4857. t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer),
  4858. t.enableVertexAttribArray(i.attribs.vPosition),
  4859. t.vertexAttribPointer(i.attribs.vPosition, 3, t.FLOAT, !1, 20, 0),
  4860. t.enableVertexAttribArray(i.attribs.vTexCoord),
  4861. t.vertexAttribPointer(i.attribs.vTexCoord, 2, t.FLOAT, !1, 20, 12),
  4862. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer),
  4863. e < 1 && (t.enable(t.BLEND),
  4864. t.blendFunc(t.SRC_ALPHA, t.ONE_MINUS_SRC_ALPHA)),
  4865. t.depthMask(!1),
  4866. t.disable(t.DEPTH_TEST),
  4867. t.drawElements(t.TRIANGLES, this.skyIndexCount, t.UNSIGNED_SHORT, 0),
  4868. t.enable(t.DEPTH_TEST),
  4869. t.depthMask(!0),
  4870. e < 1 && t.disable(t.BLEND),
  4871. t.disableVertexAttribArray(i.attribs.vPosition),
  4872. t.disableVertexAttribArray(i.attribs.vTexCoord)
  4873. }
  4874. },
  4875. _.prototype.complete = function () {
  4876. return !(this.backgroundShader && !this.backgroundShader.complete()) && this.specularTexture.complete()
  4877. },
  4878. D.expDecay = function (e, t) {
  4879. return Math.exp(-.69314718 / e * t)
  4880. },
  4881. D.prototype.update = function (e) {
  4882. var t = .001 * (Date.now() - this.timestamp);
  4883. this.timestamp = Date.now();
  4884. for (var i = !1, s = 0; s < this.stripCount; ++s) {
  4885. var n = this.selectedStrip == this.STRIP_MENU ? .3 * (s + 1) - .9 : this.selectedStrip < 0 || s < this.selectedStrip ? -2 : 2;
  4886. if (e)
  4887. this.strips[s] = n;
  4888. else {
  4889. var r = (r = n - this.strips[s]) * D.expDecay(.05, t);
  4890. this.animationActive && (this.strips[s] = n - r),
  4891. i = i || .001 < Math.abs(r)
  4892. }
  4893. }
  4894. this.animationActive = i
  4895. },
  4896. D.prototype.active = function () {
  4897. return this.selectedStrip >= this.STRIP_MENU
  4898. },
  4899. D.prototype.activeFade = function () {
  4900. var e;
  4901. return (e = 1 < (e = (this.strips[this.stripCount - 1] - -2) / (.3 * this.stripCount - .9 - -2)) ? 1 : e) < 0 ? 0 : e
  4902. },
  4903. D.prototype.activeWireframe = function () {
  4904. return this.active() && .01 < Math.abs(this.strips[4] - this.strips[3])
  4905. },
  4906. D.prototype.toggleMenu = function () {
  4907. this.selectedStrip = this.selectedStrip == this.STRIP_MENU ? this.STRIP_NONE : this.STRIP_MENU
  4908. },
  4909. D.prototype.selectStrip = function (e, t) {
  4910. if (this.selectedStrip == this.STRIP_MENU) {
  4911. var i = e + t * this.stripSlant;
  4912. this.selectedStrip = this.STRIP_NONE;
  4913. for (var s = 0; s < this.stripCount; ++s)
  4914. if (i < this.strips[s]) {
  4915. this.selectedStrip = s;
  4916. break
  4917. }
  4918. } else
  4919. this.selectedStrip = this.STRIP_MENU
  4920. },
  4921. U.prototype.loadImage = function (e, t) {
  4922. var i = this.gl;
  4923. e && e.width && e.height && (this.desc.width = e.width,
  4924. this.desc.height = e.height),
  4925. this.id = i.createTexture(),
  4926. i.bindTexture(this.type, this.id),
  4927. this.format = t || i.RGBA,
  4928. this.componentType = i.UNSIGNED_BYTE,
  4929. i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !0),
  4930. i.texImage2D(this.type, 0, this.format, this.format, this.componentType, e),
  4931. this.setParams(),
  4932. i.bindTexture(this.type, null)
  4933. },
  4934. U.prototype.loadArray = function (e, t, i) {
  4935. var s = this.gl;
  4936. this.id = s.createTexture(),
  4937. s.bindTexture(this.type, this.id),
  4938. this.format = t || s.RGBA,
  4939. this.componentType = i || s.UNSIGNED_BYTE,
  4940. s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, !0),
  4941. s.texImage2D(this.type, 0, this.format, this.desc.width, this.desc.height, 0, this.format, this.componentType, e || null),
  4942. this.setParams(),
  4943. s.bindTexture(this.type, null)
  4944. },
  4945. U.prototype.setParams = function () {
  4946. var e = this.gl,
  4947. t = function (e) {
  4948. return 0 < e && 0 == (e & e - 1)
  4949. };
  4950. t(this.desc.width) && t(this.desc.height) || (this.desc.clamp = !0,
  4951. this.desc.mipmap = !1),
  4952. t = !this.desc.nofilter,
  4953. this.desc.mipmap ? (e.generateMipmap(this.type),
  4954. 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),
  4955. e.texParameteri(this.type, e.TEXTURE_MAG_FILTER, t ? e.LINEAR : e.NEAREST),
  4956. (this.desc.clamp || this.desc.mirror) && (t = this.desc.clamp ? e.CLAMP_TO_EDGE : e.MIRRORED_REPEAT,
  4957. e.texParameteri(this.type, e.TEXTURE_WRAP_S, t),
  4958. e.texParameteri(this.type, e.TEXTURE_WRAP_T, t)),
  4959. this.desc.aniso && e.ext.textureAniso && e.texParameteri(this.type, e.ext.textureAniso.TEXTURE_MAX_ANISOTROPY_EXT, this.desc.aniso)
  4960. },
  4961. U.prototype.rebuildMips = function () {
  4962. this.desc.mipmap && (this.gl.bindTexture(this.type, this.id),
  4963. this.gl.generateMipmap(this.type))
  4964. },
  4965. U.prototype.copyColorBuffer = function () {
  4966. this.gl.bindTexture(this.type, this.id),
  4967. this.gl.copyTexSubImage2D(this.type, 0, 0, 0, 0, 0, this.desc.width, this.desc.height)
  4968. },
  4969. U.prototype.bind = function (e) {
  4970. if (e) {
  4971. var t = this.gl;
  4972. t.uniform1i(e.location, e.unit),
  4973. t.activeTexture(t.TEXTURE0 + e.unit),
  4974. t.bindTexture(this.type, this.id)
  4975. }
  4976. },
  4977. U.prototype.destroy = function () {
  4978. this.gl.deleteTexture(this.id),
  4979. this.id = null
  4980. },
  4981. U.prototype.complete = function () {
  4982. return !!this.id
  4983. },
  4984. N.prototype.fromURL = function (e, t) {
  4985. var i = this.cache[e];
  4986. if (void 0 !== i)
  4987. return i;
  4988. var s = new U(this.gl, t);
  4989. return C.fetchImage(e, function (e) {
  4990. s.loadImage(e)
  4991. }),
  4992. this.cache[e] = s
  4993. },
  4994. N.prototype.fromFile = function (e, t) {
  4995. if (!e)
  4996. return null;
  4997. var i = this.cache[e.name];
  4998. if (void 0 !== i)
  4999. return i;
  5000. var s = new U(this.gl, t);
  5001. return this.cache[e.name] = s,
  5002. N.parseFile(e, function (e) {
  5003. s.loadImage(e),
  5004. N.closeImage(e)
  5005. }),
  5006. s
  5007. },
  5008. N.prototype.fromFilesMergeAlpha = function (e, t, i) {
  5009. if (!t)
  5010. return this.fromFile(e, i);
  5011. var s = e.name + "|" + t.name,
  5012. n = this.cache[s];
  5013. if (void 0 !== n)
  5014. return n;
  5015. var r = this.gl;
  5016. this.blitShader || (this.blitShader = new F(this.gl),
  5017. 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; }"),
  5018. this.mergeVerts = r.createBuffer(),
  5019. r.bindBuffer(r.ARRAY_BUFFER, this.mergeVerts),
  5020. n = new Float32Array([0, 0, 2, 0, 0, 2]),
  5021. r.bufferData(r.ARRAY_BUFFER, n, r.STATIC_DRAW),
  5022. r.bindBuffer(r.ARRAY_BUFFER, null));
  5023. var a = function (e) {
  5024. this.blitShader.bind(),
  5025. e.bind(this.blitShader.samplers.tTex),
  5026. r.bindBuffer(r.ARRAY_BUFFER, this.mergeVerts),
  5027. r.enableVertexAttribArray(this.blitShader.attribs.pos),
  5028. r.vertexAttribPointer(this.blitShader.attribs.pos, 2, r.FLOAT, !1, 0, 0),
  5029. r.drawArrays(r.TRIANGLES, 0, 3),
  5030. r.disableVertexAttribArray(this.blitShader.attribs.pos),
  5031. r.bindBuffer(r.ARRAY_BUFFER, null)
  5032. }
  5033. .bind(this),
  5034. o = new U(this.gl, i);
  5035. this.cache[s] = o;
  5036. var h = 0,
  5037. l = 0,
  5038. d = function () {
  5039. if (h && l) {
  5040. var e, t;
  5041. if (t = l.width * l.height > h.width * h.height ? (e = l.width,
  5042. l.height) : (e = h.width,
  5043. h.height),
  5044. o.desc.width = e,
  5045. o.desc.height = t,
  5046. e <= r.limits.viewportSizes[0] && t <= r.limits.viewportSizes[1]) {
  5047. var i = {
  5048. clamp: !0
  5049. };
  5050. h.width == e && h.height == t ? (o.loadImage(h, r.RGBA),
  5051. e = new m(r, {
  5052. color0: o,
  5053. ignoreStatus: !0
  5054. }),
  5055. N.closeImage(h)) : ((t = new U(r, i)).loadImage(h, r.RGB),
  5056. N.closeImage(h),
  5057. o.loadArray(null),
  5058. (e = new m(r, {
  5059. color0: o,
  5060. ignoreStatus: !0
  5061. })).bind(),
  5062. a(t),
  5063. t.destroy()),
  5064. (t = new U(r, i)).loadImage(l, r.RGB),
  5065. N.closeImage(l),
  5066. e.bind(),
  5067. r.colorMask(!1, !1, !1, !0),
  5068. a(t),
  5069. r.colorMask(!0, !0, !0, !0),
  5070. t.destroy(),
  5071. m.bindNone(r),
  5072. o.rebuildMips()
  5073. } else {
  5074. (i = document.createElement("canvas")).width = e,
  5075. i.height = t;
  5076. var s = i.getContext("2d");
  5077. for (s.drawImage(h, 0, 0),
  5078. N.closeImage(h),
  5079. i = s.getImageData(0, 0, e, t),
  5080. i = new Uint8Array(i.data.buffer, i.data.byteOffset, i.data.length),
  5081. s.drawImage(l, 0, 0),
  5082. N.closeImage(l),
  5083. s = s.getImageData(0, 0, e, t).data,
  5084. e = e * t * 4,
  5085. t = 0; t < e; t += 4)
  5086. i[t + 3] = s[t];
  5087. o.loadArray(i)
  5088. }
  5089. N.closeImage(l)
  5090. }
  5091. };
  5092. return N.parseFile(e, function (e) {
  5093. h = e,
  5094. d()
  5095. }),
  5096. N.parseFile(t, function (e) {
  5097. l = e,
  5098. d()
  5099. }),
  5100. o
  5101. },
  5102. N.parseFile = function (e, t, i) {
  5103. var s = i || new Image();
  5104. if ("undefined" != typeof URL && void 0 !== URL.createObjectURL) {
  5105. e = new Blob([e.data], {
  5106. type: e.type
  5107. });
  5108. var n = URL.createObjectURL(e);
  5109. s.onload = function () {
  5110. URL.revokeObjectURL(n),
  5111. t && t(s)
  5112. },
  5113. s.src = n
  5114. } else {
  5115. e = new Blob([e.data], {
  5116. type: e.type
  5117. });
  5118. var r = new FileReader();
  5119. r.onload = function (e) {
  5120. s.src = r.result
  5121. },
  5122. s.onload = function () {
  5123. t && t(s)
  5124. },
  5125. r.readAsDataURL(e)
  5126. }
  5127. },
  5128. N.closeImage = function (e) {
  5129. e && 256 < e.width * e.height && (e.onload = null,
  5130. e.onerror = null,
  5131. e.src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D")
  5132. },
  5133. z.prototype.setBackground3x1 = function (e, t, i, s) {
  5134. var n = 8 / this.controlRect.getScreenHeight();
  5135. this.backgroundControl = e.addTextButton("", 0, (1 - n) / 2, 1, n, 1),
  5136. this.backgroundControl.defaultAlpha = 1,
  5137. this.backgroundControl.setBackground3x1(e, 0, 0, t, i, s, 4),
  5138. this.backgroundControl.controlRect.xPercent = this.controlRect.xPercent,
  5139. this.backgroundControl.controlRect.widthPercent = this.controlRect.widthPercent,
  5140. this.controlRect.linkedControl.style.zIndex = "3",
  5141. this.setupCallbacks()
  5142. },
  5143. z.prototype.setSize = function (e, t) {
  5144. this.pixelsX = e;
  5145. var i = 24 / (this.pixelsY = t);
  5146. this.knobWidthPercent = 24 / e,
  5147. this.knobControlRect.xPercent = .5 - this.knobWidthPercent / 2,
  5148. this.knobControlRect.yPercent = (1 - i) / 2 + -1 / t,
  5149. this.knobControlRect.widthPercent = this.knobWidthPercent,
  5150. this.knobControlRect.heightPercent = i,
  5151. this.controlRect.updateElement(),
  5152. this.backgroundControl.controlRect.xPercent = this.controlRect.xPercent,
  5153. this.backgroundControl.controlRect.widthPercent = this.controlRect.widthPercent,
  5154. this.backgroundControl.controlRect.updateElement()
  5155. },
  5156. z.prototype.setSliderPercent = function (e) {
  5157. e < 0 && (e = 0),
  5158. 1 < e && (e = 1),
  5159. this.sliderPercent = e,
  5160. this.knobControlRect.xPercent = e - this.knobWidthPercent / 2,
  5161. this.knobControlRect.updateElement()
  5162. },
  5163. z.prototype.setupCallbacks = function () {
  5164. var e = function (e) {
  5165. if (this.draggingSlider) {
  5166. var t = this.backgroundControl.controlRect.linkedControl.getBoundingClientRect();
  5167. this.setSliderPercent((e.clientX - t.left) / t.width),
  5168. this.guiScreen.ui.viewer.scene.sceneAnimator.setAnimationProgress(this.sliderPercent, !0),
  5169. this.guiScreen.ui.viewer.scene.sceneAnimator.paused && (this.guiScreen.ui.viewer.scene.postRender.discardAAHistory(),
  5170. this.guiScreen.ui.viewer.reDrawScene())
  5171. }
  5172. }
  5173. .bind(this),
  5174. t = function (e) {
  5175. this.draggingSlider = !0;
  5176. var t = this.backgroundControl.controlRect.linkedControl.getBoundingClientRect();
  5177. this.setSliderPercent((e.clientX - t.left) / t.width),
  5178. this.guiScreen.ui.viewer.scene.sceneAnimator.setAnimationProgress(this.sliderPercent, !0),
  5179. this.guiScreen.ui.viewer.scene.sceneAnimator.lockPlayback = !0,
  5180. this.guiScreen.ui.viewer.scene.sceneAnimator.paused && (this.guiScreen.ui.viewer.scene.postRender.discardAAHistory(),
  5181. this.guiScreen.ui.viewer.reDrawScene())
  5182. }
  5183. .bind(this),
  5184. i = function (e) {
  5185. this.draggingSlider = !1,
  5186. this.guiScreen.ui.viewer.scene.sceneAnimator.lockPlayback = !1
  5187. }
  5188. .bind(this);
  5189. this.guiScreen.ui.viewer.input.element.addEventListener("mousemove", e),
  5190. this.guiScreen.ui.viewer.input.element.addEventListener("mouseup", i),
  5191. this.backgroundControl.controlRect.linkedControl.addEventListener("mousemove", e),
  5192. this.backgroundControl.controlRect.linkedControl.addEventListener("mousedown", t),
  5193. this.backgroundControl.controlRect.linkedControl.addEventListener("mouseup", i),
  5194. this.controlRect.linkedControl.addEventListener("mouseup", i)
  5195. },
  5196. j.prototype.setSize = function (e, t) {
  5197. this.container.width = 0 | e,
  5198. this.container.height = 0 | t,
  5199. this.container.style.width = e + "px",
  5200. this.container.style.height = t + "px",
  5201. this.guiScreen.setSize(this.container.width, this.container.height)
  5202. },
  5203. j.prototype.clearView = function () {
  5204. for (; this.container.hasChildNodes();)
  5205. this.container.removeChild(this.container.childNodes[0]);
  5206. delete this.progressBar,
  5207. delete this.thumbnail,
  5208. delete this.fadeThumbnail,
  5209. delete this.playButton,
  5210. delete this.helpOverlay
  5211. },
  5212. j.prototype.bindInput = function (i) {
  5213. i.onSingleTap.push(function (e, t) {
  5214. this.stripData.selectedStrip != this.stripData.STRIP_NONE && (e = 2 / i.element.clientWidth * e - 1,
  5215. t = 1 - 2 / i.element.clientHeight * t,
  5216. this.stripData.selectStrip(e, t),
  5217. this.stripData.selectedStrip == this.stripData.STRIP_MENU && this.helpOverlay.active && this.helpOverlay.toggle(),
  5218. this.refreshUI(),
  5219. this.viewer.wake())
  5220. }
  5221. .bind(this))
  5222. },
  5223. j.sanitize = function (e) {
  5224. return e ? e.replace(/<|>|\(|\)|$|%|=/g, "") : e
  5225. },
  5226. j.sanitizeURL = function (e) {
  5227. return e ? 0 == e.indexOf("http://") || 0 == e.indexOf("https://") || 0 == e.indexOf("ftp://") ? encodeURI(e) : "http://" + encodeURI(e) : e
  5228. },
  5229. j.prototype.showFailure = function (e, t) {
  5230. this.container.innerHTML = "";
  5231. var i = document.createElement("canvas"),
  5232. s = this.container.width / this.container.height;
  5233. i.width = 100,
  5234. i.height = i.height * s | 0,
  5235. i.style.position = "absolute",
  5236. i.style["z-index"] = "0",
  5237. i.style.width = i.style.height = "100%";
  5238. var n = i.getContext("2d"),
  5239. r = n.fillStyle = n.createRadialGradient(i.width / 2, i.height / 2, (i.width + i.height) / 2, i.width / 2, i.height / 2, 0);
  5240. r.addColorStop(0, "rgb(0,0,0)"),
  5241. r.addColorStop(1, "rgb(35,60,80)"),
  5242. n.fillStyle = r,
  5243. n.fillRect(0, 0, i.width, i.height),
  5244. this.container.appendChild(i);
  5245. var a = document.createElement("div");
  5246. dom.addClass(a, "error"),
  5247. a.style["background-image"] = "url(images/errorBG.png)";
  5248. 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>';
  5249. a.innerHTML = o,
  5250. this.container.appendChild(a)
  5251. },
  5252. j.prototype.showPreview = function (e) {
  5253. this.clearView(),
  5254. this.thumbnail = document.createElement("canvas");
  5255. var t = this.container.width / this.container.height;
  5256. this.thumbnail.height = this.viewer.mobile ? 200 : 300,
  5257. this.thumbnail.width = this.thumbnail.height * t | 0,
  5258. this.thumbnail.style.width = this.thumbnail.style.height = "100%";
  5259. 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);
  5260. i.addColorStop(0, "rgb(0,0,0)"),
  5261. i.addColorStop(1, "rgb(7,62,92)"),
  5262. t.fillStyle = i,
  5263. t.fillRect(0, 0, this.thumbnail.width, this.thumbnail.height),
  5264. this.container.appendChild(this.thumbnail),
  5265. this.playButton = document.createElement("input"),
  5266. this.playButton.type = "image",
  5267. // this.playButton.src = I.dataLocale + "play.png",
  5268. this.playButton.style.position = "absolute",
  5269. this.playButton.style.left = "50%",
  5270. this.playButton.style.top = "50%",
  5271. this.playButton.style["-webkit-transform"] = this.playButton.style.transform = "translate(-50%,-50%) scale(0.4,0.4)",
  5272. this.playButton.style.opacity = .5,
  5273. this.playButton.style.outline = "0px",
  5274. this.playButton.onclick = function () {
  5275. this.viewer.loadScene(this.viewer.sceneURL),
  5276. this.container.removeChild(this.playButton),
  5277. delete this.playButton
  5278. }
  5279. .bind(this),
  5280. this.container.appendChild(this.playButton),
  5281. e || n(this.viewer.sceneURL, function (e) {
  5282. this.loadingImageURL || this.setThumbnail(e)
  5283. }
  5284. .bind(this))
  5285. },
  5286. j.prototype.setThumbnailURL = function (e) {
  5287. (this.loadingImageURL = e) && C.fetchImage(this.loadingImageURL, this.setThumbnail.bind(this))
  5288. },
  5289. j.prototype.setThumbnail = function (e) {
  5290. if (this.thumbnail)
  5291. if (e.height >= this.container.height) {
  5292. var t = this.container.height / e.height;
  5293. e.style.position = "absolute",
  5294. e.style.outline = "0px",
  5295. e.style.left = "50%",
  5296. e.style.top = "50%",
  5297. e.style["-webkit-transform"] = e.style.transform = "translate(-50%,-50%) scale(" + t + "," + t + ")",
  5298. this.container.replaceChild(e, this.thumbnail),
  5299. this.thumbnail = e
  5300. } else {
  5301. var i, s = this.thumbnail.getContext("2d"),
  5302. n = this.thumbnail.width,
  5303. r = this.thumbnail.height;
  5304. t = r / e.height;
  5305. s.drawImage(e, (n - e.width * t) / 2, 0, e.width * t, r);
  5306. try {
  5307. i = s.getImageData(0, 0, n, r)
  5308. } catch (e) {
  5309. return
  5310. }
  5311. e = s.createImageData(n, r);
  5312. for (var a = 0; a < 2; ++a) {
  5313. t = i.data;
  5314. for (var o = e.data, h = 0, l = 0; l < r; ++l)
  5315. for (var d = 0; d < n; ++d) {
  5316. for (var c = 0, u = 0, f = 0, m = -2; m <= 2; ++m)
  5317. for (var p = (p = l + m) < 0 ? 0 : r <= p ? r - 1 : p, g = -2; g <= 2; ++g) {
  5318. var v;
  5319. c = c + t[v = 4 * (p * n + (v = (v = d + g) < 0 ? 0 : n <= v ? n - 1 : v))],
  5320. u = u + t[v + 1],
  5321. f = f + t[v + 2]
  5322. }
  5323. o[h++] = c / 25,
  5324. o[h++] = u / 25,
  5325. o[h++] = f / 25,
  5326. o[h++] = 255
  5327. }
  5328. t = i,
  5329. i = e,
  5330. e = t
  5331. }
  5332. s.putImageData(i, 0, 0)
  5333. }
  5334. },
  5335. j.prototype.showActiveView = function () {
  5336. var e, t, i, s, n, r = this.thumbnail;
  5337. this.clearView(),
  5338. r && (this.fadeThumbnail = r,
  5339. this.fadeThumbnail.style.opacity = 1,
  5340. this.container.appendChild(this.fadeThumbnail)),
  5341. void 0 === I.largeUI && (I.largeUI = this.viewer.mobile),
  5342. this.container.width < 450 && (I.largeUI = !1);
  5343. var a = g.support();
  5344. r = 1;
  5345. window.devicePixelRatio && (2 < window.devicePixelRatio ? r = 4 : 1 < window.devicePixelRatio && (r = 2)),
  5346. I.largeUI && r < 4 && (r *= 2);
  5347. var o = I.largeUI ? .3 : .5;
  5348. this.helpOverlay = document.createElement("div"),
  5349. this.helpOverlay.style.pointerEvents = "none",
  5350. this.container.appendChild(this.helpOverlay),
  5351. this.hideSigOnHelp = e = this.container.width < 450,
  5352. this.hideSigOnStrips = !0,
  5353. t = [8, 8],
  5354. s = e ? (i = 198 + 2 * t[0],
  5355. 258 + 2 * t[1]) : (i = 354 + 2 * t[0],
  5356. 218 + 2 * t[1]),
  5357. (n = document.createElement("div")).style.position = "absolute",
  5358. n.style.width = n.style.height = "100%",
  5359. this.helpOverlay.contents = n,
  5360. (n = document.createElement("div")).style.position = "absolute",
  5361. n.style.right = I.largeUI ? "85px" : "45px",
  5362. n.style.top = I.largeUI ? "20px" : "12px",
  5363. n.style["z-index"] = "20",
  5364. n.style.width = i + "px",
  5365. n.style.height = s + "px",
  5366. this.helpOverlay.contents.appendChild(n),
  5367. (s = document.createElement("div")).style.position = "absolute",
  5368. s.style.width = "100%",
  5369. s.style.height = "100%",
  5370. s.style.backgroundColor = "black",
  5371. s.style.opacity = "0.65",
  5372. s.style.borderRadius = "16px",
  5373. n.appendChild(s),
  5374. s = document.createElement("a"),
  5375. dom.addClass(s, "tipClose"),
  5376. s.style.position = "absolute",
  5377. s.style.color = "#FFFFFF",
  5378. s.style.backgroundColor = "rgba(0,0,0,0.0)",
  5379. s.style.border = "0px",
  5380. s.style.outline = "0px",
  5381. s.style.fontSize = I.largeUI ? "16pt" : "10pt",
  5382. s.style.right = I.largeUI ? "-9px" : "4px",
  5383. s.style.top = I.largeUI ? "3px" : "7px",
  5384. s.style.width = s.style.height = I.largeUI ? "32px" : "16px",
  5385. s.style.pointerEvents = "auto",
  5386. s.style.cursor = "pointer",
  5387. s.onclick = function (e) {
  5388. this.helpOverlay.toggle(),
  5389. this.refreshUI()
  5390. }
  5391. .bind(this, s),
  5392. n.appendChild(s),
  5393. (s = document.createElement("center")).style.position = "absolute",
  5394. s.style.left = t[0] - 4 + "px",
  5395. s.style.right = t[0] + 4 + "px",
  5396. s.style.top = s.style.bottom = t[1] + "px",
  5397. s.style.paddingTop = "8px",
  5398. e || (s.style.paddingRight = "8px"),
  5399. n.appendChild(s),
  5400. n = s,
  5401. t = (this.viewer.mobile ? "M" : "PC") + (2 < r ? 4 : 2) + "x.png",
  5402. (s = document.createElement("img")).style.width = "66px",
  5403. s.style.height = "90px",
  5404. n.appendChild(s),
  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.position = "relative",
  5415. e || (s.style.left = "8px"),
  5416. s.style.width = "66px",
  5417. s.style.height = "90px",
  5418. n.appendChild(s),
  5419. (t = document.createElement("a")).href = "http://www.4dage.com/",
  5420. t.target = "_blank",
  5421. t.style.pointerEvents = "auto",
  5422. t.style.cursor = "pointer",
  5423. n.appendChild(t),
  5424. (s = document.createElement("img")).style.position = "absolute",
  5425. s.style.left = .5 * i - (e ? 65 : 116) + "px",
  5426. s.style.bottom = e ? "8px" : "12px",
  5427. s.style.width = e ? "116px" : "232px",
  5428. t.appendChild(s),
  5429. (i = document.createElement("div")).style.position = "absolute",
  5430. i.style.left = 0,
  5431. i.style.right = e ? "30px" : "128px",
  5432. i.style.bottom = e ? "-4px" : "4px",
  5433. i.style.textAlign = "right",
  5434. i.style.fontFamilly = "Open Sans Arial",
  5435. n.appendChild(i),
  5436. (e = document.createElement("font")).style.fontSize = "9pt",
  5437. e.style.fontFamily = "Open Sans Arial",
  5438. i.appendChild(e),
  5439. e.appendChild(t),
  5440. this.helpOverlay.active = !1,
  5441. this.helpOverlay.toggle = function (e) {
  5442. this.active ? this.removeChild(this.contents) : this.appendChild(this.contents),
  5443. this.active = !this.active
  5444. }
  5445. .bind(this.helpOverlay, this.viewer),
  5446. this.menuCluster = document.createElement("div"),
  5447. this.menuCluster.style.position = "absolute",
  5448. this.menuCluster.style.right = I.largeUI ? "4px" : "0px",
  5449. this.menuCluster.style.top = I.largeUI ? "20px" : "10px",
  5450. I.largeUI ? (this.menuCluster.style.width = "72px",
  5451. this.menuCluster.style.height = "64px") : (this.menuCluster.style.width = "36px",
  5452. this.menuCluster.style.height = "36px"),
  5453. (n = document.createElement("div")).style.left = n.style.top = "0px",
  5454. n.style.width = n.style.height = "100%",
  5455. this.menuCluster.contents = n,
  5456. this.menuCluster.appendChild(n),
  5457. e = 0;
  5458. var h = (i = function (e, t, i, s, n, r) {
  5459. var a = document.createElement("div");
  5460. return dom.addClass(a, "controlBtn"),
  5461. dom.addClass(a, i),
  5462. a.title = t,
  5463. I.largeUI && dom.addClass(a, "largeUI"),
  5464. e.appendChild(a),
  5465. a
  5466. })(this.menuCluster.contents, "4DAGE主页", "home", "", e++, o);
  5467. for (h.onclick = function (e) {
  5468. window.open("http://www.4dage.com", "_blank")
  5469. }
  5470. .bind(this, h),
  5471. a && ((a = i(this.menuCluster.contents, "全屏", "fullscreen", "fullscreen" + r + "x.png", e++, o)).onclick = function (e) {
  5472. g.active() ? g.end() : g.begin(this.viewer.domRoot, this.viewer.fullscreenChange.bind(this.viewer)),
  5473. dom.hasClass(e, "full") ? dom.removeClass(e, "full") : dom.addClass(e, "full"),
  5474. this.refreshUI()
  5475. }
  5476. .bind(this, a)),
  5477. (a = i(this.menuCluster.contents, "操作方式说明", "tips", "help" + r + "x.png", e++, o)).onclick = function (e) {
  5478. this.helpOverlay.toggle(),
  5479. this.refreshUI()
  5480. }
  5481. .bind(this, a),
  5482. this.container.appendChild(this.menuCluster),
  5483. this.menuCluster.active = !0,
  5484. this.menuCluster.toggle = function () {
  5485. this.active ? this.removeChild(this.contents) : this.appendChild(this.contents),
  5486. this.active = !this.active
  5487. }
  5488. .bind(this.menuCluster),
  5489. void 0 !== I.hostImage && (I.hostURL && ((t = document.createElement("a")).href = I.hostURL,
  5490. t.target = "_blank"),
  5491. (s = document.createElement("img")).src = I.hostImage,
  5492. s.style.position = "absolute",
  5493. s.style.top = "4px",
  5494. s.style.left = "4px",
  5495. s.style.opacity = .65,
  5496. s.style["-webkit-transform"] = s.style.transform = "translate(-50%,-50%) scale(0.5,0.5) translate(50%,50%)",
  5497. I.hostURL ? (s.onmouseover = function () {
  5498. this.style.opacity = 1
  5499. }
  5500. .bind(s),
  5501. s.onmouseout = function () {
  5502. this.style.opacity = .5
  5503. }
  5504. .bind(s),
  5505. t.appendChild(s),
  5506. this.hostLogo = t) : this.hostLogo = s,
  5507. (e = new XMLHttpRequest()).open("HEAD", s.src, !0),
  5508. e.onload = function () {
  5509. this.container.appendChild(this.hostLogo)
  5510. }
  5511. .bind(this),
  5512. e.send()),
  5513. this.sceneStats = document.createElement("text"),
  5514. this.sceneStats.style.position = "absolute",
  5515. this.sceneStats.style.left = "9px",
  5516. this.sceneStats.style.bottom = "8px",
  5517. this.sceneStats.style.color = "gray",
  5518. this.sceneStats.style.fontFamily = "Open Sans Arial",
  5519. this.sceneStats.style.fontSize = "75%",
  5520. e = a = r = 0; e < this.viewer.scene.meshes.length; ++e)
  5521. r += (i = this.viewer.scene.meshes[e]).indexCount / 3,
  5522. a += i.vertexCount;
  5523. this.sceneStats.innerHTML = "Triangles: " + (0 | r).toLocaleString() + "<br>Vertices: " + (0 | a).toLocaleString(),
  5524. I.showFrameTime && (this.frameTimer = document.createElement("text"),
  5525. this.frameTimer.style.position = "absolute",
  5526. this.frameTimer.style.left = this.frameTimer.style.top = "5px",
  5527. this.frameTimer.style.color = "gray",
  5528. this.frameTimer.style.fontSize = "75%",
  5529. this.container.appendChild(this.frameTimer),
  5530. this.frameTimer.innerHTML = "--",
  5531. this.frameCount = 1e20)
  5532. },
  5533. j.prototype.refreshUI = function () {
  5534. if (this.sigCluster) {
  5535. var e = !1,
  5536. t = this.stripData.selectedStrip == this.stripData.STRIP_MENU;
  5537. this.hideSigOnStrips && (e = e || t),
  5538. this.hideSigOnHelp && (e = e || this.helpOverlay.active),
  5539. this.sigCluster.active == e && this.sigCluster.toggle()
  5540. }
  5541. },
  5542. j.prototype.signalLoadProgress = function (e, t) {
  5543. if (this.thumbnail) {
  5544. if (!this.progressBar) {
  5545. var i = document.createElement("div");
  5546. i.style.backgroundColor = "rgb(240,240,240)",
  5547. i.style.opacity = .9,
  5548. i.style.position = "absolute",
  5549. i.style.zIndex = 999
  5550. i.style.left = "20%",
  5551. i.style.width = "60%",
  5552. i.style.bottom = "30%",
  5553. i.style.height = "4px",
  5554. i.style["border-radius"] = "2px",
  5555. this.progressBar = document.createElement("div"),
  5556. this.progressBar.style.backgroundColor = "#00ccff",
  5557. this.progressBar.style.position = "absolute",
  5558. this.progressBar.style.left = this.progressBar.style.bottom = "0px",
  5559. this.progressBar.style.height = "100%",
  5560. this.progressBar.style.width = "0px",
  5561. this.progressBar.style["border-radius"] = "2px",
  5562. i.appendChild(this.progressBar),
  5563. this.container.appendChild(i),
  5564. this.playButton && (this.container.removeChild(this.playButton),
  5565. delete this.playButton)
  5566. }
  5567. this.progressBar.style.width = t <= 0 ? (100 * e / (2097152 + e) | 0) + "%" : (100 * e / t | 0) + "%"
  5568. }
  5569. },
  5570. j.prototype.animating = function () {
  5571. return !!this.fadeThumbnail || !!this.frameTimer
  5572. },
  5573. j.prototype.animate = function () {
  5574. if (this.fadeThumbnail && (this.fadeThumbnailTimer = this.fadeThumbnailTimer || Date.now(),
  5575. this.fadeThumbnail.style.opacity = 1 - .0015 * (Date.now() - this.fadeThumbnailTimer),
  5576. this.fadeThumbnail.style.opacity < .01 && (this.container.removeChild(this.fadeThumbnail),
  5577. delete this.fadeThumbnail,
  5578. delete this.fadeThumbnailTimer)),
  5579. this.frameTimer && (this.frameCount++,
  5580. 60 <= this.frameCount)) {
  5581. var e = (new Date()).getTime();
  5582. if (void 0 !== this.frameTime) {
  5583. var t = (e - this.frameTime) / this.frameCount;
  5584. t = Math.floor(100 * t) / 100;
  5585. this.frameTimer.innerHTML = t + " ms",
  5586. this.frameTimer.style.color = t < 32 ? "green" : "red"
  5587. }
  5588. this.frameCount = 0,
  5589. this.frameTime = e
  5590. }
  5591. 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)),
  5592. this.sceneStats) {
  5593. for (var i = t = e = 0; i < this.viewer.scene.meshes.length; ++i) {
  5594. var s = this.viewer.scene.meshes[i];
  5595. e = e + s.indexCount / 3,
  5596. t = t + s.vertexCount
  5597. }
  5598. this.sceneStats.innerHTML = "Triangles: " + (0 | e).toLocaleString() + "<br>Vertices: " + (0 | t).toLocaleString(),
  5599. this.viewer.scene.sceneAnimator && this.viewer.scene.sceneAnimator.showPlayControls && (this.sceneStats.innerHTML += "<br><br><br><br>"),
  5600. e = !!this.sceneStats.parentElement,
  5601. t = this.stripData.active() || !1,
  5602. e && !t ? (this.container.removeChild(this.sceneStats),
  5603. this.hostLogo && this.container.appendChild(this.hostLogo)) : !e && t && (this.container.appendChild(this.sceneStats),
  5604. this.hostLogo && this.container.removeChild(this.hostLogo))
  5605. }
  5606. this.refreshUI(),
  5607. (this.stripData.animationActive || this.stripData.active()) && (this.animateStrips(),
  5608. this.stripData.animationActive && this.viewer.wake())
  5609. },
  5610. j.prototype.animateStrips = function () {
  5611. if (this.stripText)
  5612. for (var e = Math.atan(this.viewer.canvas.height / this.viewer.canvas.width / this.stripData.stripSlant), t = 0; t < this.stripData.labels.length; ++t) {
  5613. var i = .5 + .5 * (i = (i = this.stripData.strips[t]) - this.stripData.stripSlant);
  5614. t == this.stripData.selectedStrip ? (this.stripText[t].style["-ms-transform"] = this.stripText[t].style["-webkit-transform"] = this.stripText[t].style.transform = "none",
  5615. this.stripText[t].style.top = "4px",
  5616. this.stripText[t].style.left = "0px",
  5617. this.stripText[t].style.width = "150px",
  5618. this.stripText[t].txt.style.textAlign = "center",
  5619. this.stripText[t].txt.style.background = "rgba(0, 0, 0, 0.75)",
  5620. this.stripText[t].txt.style.background = "-webkit-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5621. this.stripText[t].txt.style.background = "-o-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5622. this.stripText[t].txt.style.background = "-moz-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5623. this.stripText[t].txt.style.background = "linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5624. this.stripText[t].txt.style.paddingLeft = "32px",
  5625. this.stripText[t].txt.style.paddingTop = "6px",
  5626. this.stripText[t].txt.style.paddingBottom = "4px",
  5627. this.stripText[t].txt.style.textShadow = "1px 1px 2px rgba(0,0,0,0.7)",
  5628. this.stripText[t].line.style.opacity = .5,
  5629. this.stripText[t].line.style.top = "100%",
  5630. this.stripText[t].line.style.width = "100%",
  5631. 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%)",
  5632. this.stripText[t].style.left = 100 * i + "%",
  5633. this.stripText[t].style.top = "0px",
  5634. this.stripText[t].style.width = "85px",
  5635. this.stripText[t].txt.style.textAlign = "left",
  5636. this.stripText[t].txt.style.background = "none",
  5637. this.stripText[t].txt.style.paddingLeft = "8px",
  5638. this.stripText[t].txt.style.paddingTop = "6px",
  5639. this.stripText[t].txt.style.paddingBottom = "4px",
  5640. this.stripText[t].txt.style.textShadow = "2px 0px 3px rgba(0,0,0,0.7)",
  5641. this.stripText[t].line.style.opacity = 1,
  5642. this.stripText[t].line.style.top = "-1px",
  5643. this.stripText[t].line.style.width = "10000px",
  5644. this.stripText[t].line.style.height = "2px")
  5645. }
  5646. };
  5647. var V = {
  5648. type: Float32Array,
  5649. create: function (e, t, i, s) {
  5650. var n = new V.type(4);
  5651. return n[0] = e,
  5652. n[1] = t,
  5653. n[2] = i,
  5654. n[3] = s,
  5655. n
  5656. },
  5657. empty: function () {
  5658. return new V.type(4)
  5659. },
  5660. set: function (e, t, i, s, n) {
  5661. e[0] = t,
  5662. e[1] = i,
  5663. e[2] = s,
  5664. e[3] = n
  5665. },
  5666. copy: function (e, t) {
  5667. e[0] = t[0],
  5668. e[1] = t[1],
  5669. e[2] = t[2],
  5670. e[3] = t[3]
  5671. },
  5672. add: function (e, t, i) {
  5673. return e[0] = t[0] + i[0],
  5674. e[1] = t[1] + i[1],
  5675. e[2] = t[2] + i[2],
  5676. e[3] = t[3] + i[3],
  5677. e
  5678. },
  5679. sub: function (e, t, i) {
  5680. return e[0] = t[0] - i[0],
  5681. e[1] = t[1] - i[1],
  5682. e[2] = t[2] - i[2],
  5683. e[3] = t[3] - i[3],
  5684. e
  5685. },
  5686. scale: function (e, t, i) {
  5687. return e[0] = i[0] * t,
  5688. e[1] = i[1] * t,
  5689. e[2] = i[2] * t,
  5690. e[3] = i[3] * t,
  5691. e
  5692. },
  5693. mul: function (e, t, i) {
  5694. return e[0] = t[0] * i[0],
  5695. e[1] = t[1] * i[1],
  5696. e[2] = t[2] * i[2],
  5697. e[3] = t[3] * i[3],
  5698. e
  5699. },
  5700. mad: function (e, t, i, s) {
  5701. return e[0] = t[0] * i[0] + s[0],
  5702. e[1] = t[1] * i[1] + s[1],
  5703. e[2] = t[2] * i[2] + s[2],
  5704. e[3] = t[3] * i[3] + s[3],
  5705. e
  5706. },
  5707. smad: function (e, t, i, s) {
  5708. return e[0] = t * i[0] + s[0],
  5709. e[1] = t * i[1] + s[1],
  5710. e[2] = t * i[2] + s[2],
  5711. e[3] = t * i[3] + s[3],
  5712. e
  5713. },
  5714. negate: function (e, t) {
  5715. return e[0] = -t[0],
  5716. e[1] = -t[1],
  5717. e[2] = -t[2],
  5718. e
  5719. },
  5720. negate4: function (e, t) {
  5721. return e[0] = -t[0],
  5722. e[1] = -t[1],
  5723. e[2] = -t[2],
  5724. e[3] = -t[3],
  5725. e
  5726. },
  5727. length: function (e) {
  5728. var t = e[0],
  5729. i = e[1];
  5730. return e = e[2],
  5731. Math.sqrt(t * t + i * i + e * e)
  5732. },
  5733. distance: function (e, t) {
  5734. var i = e[0] - t[0],
  5735. s = e[1] - t[1],
  5736. n = e[2] - t[2];
  5737. return Math.sqrt(i * i + s * s + n * n)
  5738. },
  5739. dot: function (e, t) {
  5740. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2]
  5741. },
  5742. dot4: function (e, t) {
  5743. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3] * t[3]
  5744. },
  5745. normalize: function (e, t) {
  5746. var i = t[0],
  5747. s = t[1],
  5748. n = t[2],
  5749. r = Math.sqrt(i * i + s * s + n * n);
  5750. return 0 == r ? V.set(e, 0, 0, 0, 0) : (r = 1 / r,
  5751. e[0] = i * r,
  5752. e[1] = s * r,
  5753. e[2] = n * r,
  5754. e)
  5755. },
  5756. cross: function (e, t, i) {
  5757. return e[0] = t[1] * i[2],
  5758. e[0] += -t[2] * i[1],
  5759. e[1] = t[2] * i[0] - t[0] * i[2],
  5760. e[2] = t[0] * i[1] - t[1] * i[0],
  5761. e
  5762. },
  5763. lerp: function (e, t, i, s) {
  5764. var n = 1 - s;
  5765. return e[0] = t[0] * n + i[0] * s,
  5766. e[1] = t[1] * n + i[1] * s,
  5767. e[2] = t[2] * n + i[2] * s,
  5768. e
  5769. },
  5770. lerp4: function (e, t, i, s) {
  5771. var n = 1 - s;
  5772. return e[0] = t[0] * n + i[0] * s,
  5773. e[1] = t[1] * n + i[1] * s,
  5774. e[2] = t[2] * n + i[2] * s,
  5775. e[3] = t[3] * n + i[3] * s,
  5776. e
  5777. },
  5778. min: function (e, t, i) {
  5779. return e[0] = Math.min(t[0], i[0]),
  5780. e[1] = Math.min(t[1], i[1]),
  5781. e[2] = Math.min(t[2], i[2]),
  5782. e[3] = Math.min(t[3], i[3]),
  5783. e
  5784. },
  5785. max: function (e, t, i) {
  5786. return e[0] = Math.max(t[0], i[0]),
  5787. e[1] = Math.max(t[1], i[1]),
  5788. e[2] = Math.max(t[2], i[2]),
  5789. e[3] = Math.max(t[3], i[3]),
  5790. e
  5791. },
  5792. projectOnPlane: function (e, t, i, s) {
  5793. var n = V.empty();
  5794. return V.sub(n, t, i),
  5795. i = V.dot(n, s),
  5796. smad(e, -i, normal, t),
  5797. e
  5798. }
  5799. };
  5800. function H(e) {
  5801. this.pivot = [0, 0, 0],
  5802. this.rotation = [0, 0],
  5803. this.radius = 1,
  5804. this.nearPlane = .3,
  5805. this.fov = 45,
  5806. this.size = [1, 1],
  5807. this.transform = S.empty(),
  5808. this.viewMatrix = S.empty(),
  5809. this.projectionMatrix = S.empty(),
  5810. this.viewProjectionMatrix = S.empty(),
  5811. e ? this.loadView(e, !0) : (this.saveResetView(),
  5812. this.updateView(),
  5813. this.updateProjection())
  5814. }
  5815. function W(e, t, i, s) {
  5816. var n;
  5817. if (this.mobile = !!/Android|iPhone|iPod|iPad|Windows Phone|IEMobile|BlackBerry|webOS/.test(navigator.userAgent),
  5818. this.mobileFast = !!/iPhone|iPad/.test(navigator.userAgent),
  5819. n = !this.mobile)
  5820. e: {
  5821. if ((n = document.createElement("canvas")).width = n.height = 16,
  5822. n = n.getContext("webgl", {}) || n.getContext("experimental-webgl", {})) {
  5823. var r = n.getExtension("WEBGL_debug_renderer_info");
  5824. if (r) {
  5825. n = n.getParameter(r.UNMASKED_RENDERER_WEBGL),
  5826. n = !!/Intel|INTEL/.test(n);
  5827. break e
  5828. }
  5829. }
  5830. n = !1
  5831. }
  5832. this.desktopSlow = n,
  5833. this.domRoot = document.createElement("div"),
  5834. this.domRoot.style.width = e + "px",
  5835. this.domRoot.style.height = t + "px",
  5836. this.initCanvas(e, t),
  5837. this.scene = this.input = null,
  5838. this.sceneURL = i,
  5839. this.sleepCounter = 8,
  5840. this.onLoad = null,
  5841. this.stripData = new D(),
  5842. this.ui = new j(this),
  5843. this.ui.setSize(e, t),
  5844. this.ui.showPreview(s)
  5845. }
  5846. H.prototype.saveResetView = function () {
  5847. this.resetDesc = {
  5848. angles: [this.rotation[0], this.rotation[1]],
  5849. pivot: [this.pivot[0], this.pivot[1], this.pivot[2]],
  5850. limits: this.limits,
  5851. orbitRadius: this.radius,
  5852. fov: this.fov
  5853. }
  5854. },
  5855. H.prototype.loadView = function (e, t) {
  5856. e && (this.rotation[0] = e.angles[0],
  5857. this.rotation[1] = e.angles[1],
  5858. rotInfo.pivot[0] || (rotInfo.pivot[0] = e.pivot[0]),
  5859. rotInfo.pivot[1] || (rotInfo.pivot[1] = e.pivot[1]),
  5860. rotInfo.pivot[2] || (rotInfo.pivot[2] = e.pivot[2]),
  5861. this.pivot[0] = rotInfo.pivot[0],
  5862. this.pivot[1] = rotInfo.pivot[1],
  5863. this.pivot[2] = rotInfo.pivot[2],
  5864. this.radius = parseFloat(getQueryVariable('currentdis') ? Number(getQueryVariable('currentdis')) : e.orbitRadius),
  5865. this.fov = e.fov,
  5866. // this.limits = {
  5867. // orbitRadius:{
  5868. // max: getQueryVariable('camdismax')?Number(getQueryVariable('camdismax')): e.limits.orbitRadius.max,
  5869. // min: getQueryVariable('camdismmin')?Number(getQueryVariable('camdismmin')): e.limits.orbitRadius.min,
  5870. // }
  5871. // },
  5872. t && this.saveResetView(),
  5873. this.updateView(),
  5874. this.updateProjection())
  5875. // console.log(e.limits,this.limits,'limits');
  5876. },
  5877. H.prototype.reset = function () {
  5878. this.loadView(this.resetDesc)
  5879. },
  5880. H.prototype.updateView = function () {
  5881. if (void 0 !== this.limits) {
  5882. if (this.limits.angles) {
  5883. var e = this.limits.angles.x,
  5884. t = this.limits.angles.y;
  5885. if (void 0 !== e) {
  5886. var i = this.rotation[0] - e.offset;
  5887. e = Math.min(Math.max(i, e.min), e.max);
  5888. this.rotation[0] += e - i
  5889. }
  5890. void 0 !== t && (i = this.rotation[1] - t.offset,
  5891. e = Math.min(Math.max(i, t.min), t.max),
  5892. this.rotation[1] += e - i)
  5893. }
  5894. void 0 !== this.limits.orbitRadius && (t = this.limits.orbitRadius.min,
  5895. i = this.limits.orbitRadius.max,
  5896. void 0 !== t && (this.radius = Math.max(this.radius, t)),
  5897. void 0 !== i && (this.radius = Math.min(this.radius, i))),
  5898. void 0 !== this.limits.pan && (t = this.limits.pan,
  5899. i = this.resetDesc.pivot,
  5900. t.x && (this.pivot[0] = i[0]),
  5901. t.y && (this.pivot[1] = i[1]),
  5902. t.z && (this.pivot[2] = i[2]))
  5903. }
  5904. S.translation(this.transform, 0, 0, this.radius),
  5905. t = S.rotation(S.empty(), this.rotation[0], 0),
  5906. i = S.rotation(S.empty(), this.rotation[1], 1),
  5907. S.mul(t, i, t),
  5908. S.mul(this.transform, t, this.transform),
  5909. this.transform[12] += this.pivot[0],
  5910. this.transform[13] += this.pivot[1],
  5911. this.transform[14] += this.pivot[2],
  5912. S.invert(this.viewMatrix, this.transform),
  5913. S.mul(this.viewProjectionMatrix, this.viewMatrix, this.projectionMatrix)
  5914. },
  5915. H.prototype.updateProjection = function (e) {
  5916. S.perspectiveInfinite(this.projectionMatrix, this.fov, this.size[0] / this.size[1], this.nearPlane, e),
  5917. S.mul(this.viewProjectionMatrix, this.projectionMatrix, this.viewMatrix)
  5918. },
  5919. W.prototype.initCanvas = function (e, t) {
  5920. if (this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas),
  5921. this.canvas = document.createElement("canvas"),
  5922. this.pixelRatio = window.devicePixelRatio || 1,
  5923. this.mobile) {
  5924. var i = this.mobileFast ? 1.5 : 1;
  5925. this.pixelRatio = this.pixelRatio > i ? i : this.pixelRatio
  5926. } else
  5927. this.desktopSlow && (this.pixelRatio = 1);
  5928. this.canvas.width = e * this.pixelRatio,
  5929. this.canvas.height = t * this.pixelRatio,
  5930. this.canvas.style.width = e + "px",
  5931. this.canvas.style.height = t + "px",
  5932. this.canvas.style.position = "absolute",
  5933. this.domRoot.appendChild(this.canvas)
  5934. },
  5935. W.prototype.initGL = function () {
  5936. var e = {
  5937. alpha: !!I.transparentBackground,
  5938. depth: !1,
  5939. stencil: !1,
  5940. antialias: !1,
  5941. premultipliedAlpha: !!I.transparentBackground,
  5942. preserveDrawingBuffer: !1
  5943. };
  5944. e = this.gl = this.canvas.getContext("webgl", e) || this.canvas.getContext("experimental-webgl", e);
  5945. return this.gl ? (this.canvas.addEventListener("webglcontextlost", function (e) {
  5946. e.preventDefault()
  5947. }, !1),
  5948. this.canvas.addEventListener("webglcontextrestored", function (e) {
  5949. this.loadScene(this.sceneURL)
  5950. }
  5951. .bind(this), !1),
  5952. e.ext = {
  5953. textureAniso: e.getExtension("EXT_texture_filter_anisotropic") || e.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || e.getExtension("MOZ_EXT_texture_filter_anisotropic"),
  5954. textureFloat: e.getExtension("OES_texture_float"),
  5955. textureFloatLinear: e.getExtension("OES_texture_float_linear"),
  5956. textureHalf: e.getExtension("OES_texture_half_float"),
  5957. textureHalfLinear: e.getExtension("OES_texture_half_float_linear"),
  5958. textureDepth: e.getExtension("WEBGL_depth_texture"),
  5959. colorBufferFloat: e.getExtension("WEBGL_color_buffer_float"),
  5960. colorBufferHalf: e.getExtension("EXT_color_buffer_half_float"),
  5961. index32bit: e.getExtension("OES_element_index_uint"),
  5962. loseContext: e.getExtension("WEBGL_lose_context"),
  5963. derivatives: e.getExtension("OES_standard_derivatives"),
  5964. renderInfo: e.getExtension("WEBGL_debug_renderer_info")
  5965. },
  5966. e.limits = {
  5967. textureSize: e.getParameter(e.MAX_TEXTURE_SIZE),
  5968. textureCount: e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),
  5969. varyings: e.getParameter(e.MAX_VARYING_VECTORS),
  5970. vertexAttribs: e.getParameter(e.MAX_VERTEX_ATTRIBS),
  5971. vertexUniforms: e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),
  5972. fragmentUniforms: e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),
  5973. viewportSizes: e.getParameter(e.MAX_VIEWPORT_DIMS),
  5974. vendor: e.getParameter(e.VENDOR),
  5975. version: e.getParameter(e.VERSION)
  5976. },
  5977. e.hints = {
  5978. mobile: this.mobile,
  5979. pixelRatio: this.pixelRatio
  5980. },
  5981. e.enable(e.DEPTH_TEST),
  5982. e.shaderCache = new O(e),
  5983. e.textureCache = new N(e),
  5984. this.allocBacking(),
  5985. !0) : (this.ui.showFailure('webgl出错。</br>建议您将浏览器升级至最新版本,以获最好的体验。<br><span style="font-size:0.8em">获知更多webgl浏览器信息请<a href="webglInfo.html" style="color: #a6ccea;">点击此处</a></span>', this),
  5986. !1)
  5987. },
  5988. W.prototype.allocBacking = function () {
  5989. var e = this.gl,
  5990. t = !1,
  5991. i = {
  5992. width: this.canvas.width,
  5993. height: this.canvas.height
  5994. };
  5995. for (this.mainColor = new U(e, i),
  5996. this.mainDepth = null,
  5997. e.ext.textureDepth && (this.mainDepth = new U(e, {
  5998. width: this.canvas.width,
  5999. height: this.canvas.height,
  6000. nofilter: !0
  6001. }),
  6002. this.mainDepth.loadArray(null, e.DEPTH_COMPONENT, e.UNSIGNED_INT)),
  6003. e.ext.textureHalf && e.ext.textureHalfLinear && (this.mainColor.loadArray(null, e.RGBA, e.ext.textureHalf.HALF_FLOAT_OES),
  6004. this.mainBuffer = new m(e, {
  6005. color0: this.mainColor,
  6006. depth: this.mainDepth,
  6007. createDepth: !this.mainDepth
  6008. }),
  6009. t = this.mainBuffer.valid),
  6010. !t && e.ext.textureFloat && e.ext.textureFloatLinear && !e.hints.mobile && (this.mainColor.loadArray(null, e.RGBA, e.FLOAT),
  6011. this.mainBuffer = new m(e, {
  6012. color0: this.mainColor,
  6013. depth: this.mainDepth,
  6014. createDepth: !this.mainDepth
  6015. }),
  6016. t = this.mainBuffer.valid); !t;)
  6017. this.mainColor = new U(e, i),
  6018. this.mainColor.loadArray(null, e.RGBA, e.UNSIGNED_BYTE),
  6019. this.mainBuffer = new m(e, {
  6020. color0: this.mainColor,
  6021. depth: this.mainDepth,
  6022. createDepth: !this.mainDepth
  6023. }),
  6024. t = this.mainBuffer.valid,
  6025. i.width /= 2,
  6026. i.height /= 2,
  6027. this.mainDepth && (this.mainDepth.destroy(),
  6028. this.mainDepth = null);
  6029. this.mainBufferNoDepth = new m(e, {
  6030. color0: this.mainColor
  6031. })
  6032. },
  6033. W.prototype.loadScene = function (e) {
  6034. if (this.sceneURL = e || this.sceneURL,
  6035. this.scene = this.input = null,
  6036. this.initGL() && this.sceneURL) {
  6037. var t = this.ui.signalLoadProgress.bind(this.ui);
  6038. e = function (e) {
  6039. t(1, 1),
  6040. this.scene = new k(this.gl),
  6041. this.scene.stripData = this.stripData,
  6042. this.scene.load(new h(e)) ? this.scene.metaData.tbVersion <= 2070 ? this.ui.showFailure("模型文件版本过低", this) : (this.bindInput(),
  6043. this.requestFrame(this.updateLoad.bind(this)),
  6044. this.onLoad && this.onLoad()) : this.ui.showFailure("模型文件无法读取或无效", this)
  6045. }
  6046. .bind(this);
  6047. var i = function () {
  6048. this.ui.showFailure("模型文件 (" + this.sceneURL + ") 无法获取.", this)
  6049. }
  6050. .bind(this);
  6051. C.fetchBinary(this.sceneURL, e, i, t)
  6052. }
  6053. },
  6054. W.prototype.unload = function () {
  6055. delete this.scene,
  6056. delete this.input,
  6057. delete this.ui,
  6058. delete this.mainColor,
  6059. delete this.mainBuffer,
  6060. delete this.gl;
  6061. var e = this.domRoot.clientWidth,
  6062. t = this.domRoot.clientHeight;
  6063. this.initCanvas(e, t),
  6064. this.ui = new j(this),
  6065. this.ui.setSize(e, t),
  6066. this.ui.showPreview(),
  6067. this.cancelFrame()
  6068. },
  6069. W.prototype.bindInput = function () {
  6070. this.input = new e(this.ui.container),
  6071. this.input.onDrag.push(function (e, t, i, s) {
  6072. e = 1 - 2.2 / (Math.sqrt(i * i + s * s) + 2.2),
  6073. (t = this.scene.view).rotation[1] -= .4 * i * e,
  6074. t.rotation[0] -= .4 * s * e,
  6075. t.rotation[0] = 90 < t.rotation[0] ? 90 : t.rotation[0],
  6076. t.rotation[0] = t.rotation[0] < -90 ? -90 : t.rotation[0],
  6077. t.updateView(),
  6078. this.wake()
  6079. }
  6080. .bind(this)),
  6081. this.input.onPan.push(function (e, t) {
  6082. var i = this.scene.view,
  6083. s = -e * (n = i.fov / 45 * .8 * (i.radius / this.domRoot.clientHeight)),
  6084. n = t * n;
  6085. i.pivot[0] += s * i.transform[0] + n * i.transform[4],
  6086. i.pivot[1] += s * i.transform[1] + n * i.transform[5],
  6087. i.pivot[2] += s * i.transform[2] + n * i.transform[6],
  6088. i.updateView(),
  6089. this.wake()
  6090. }
  6091. .bind(this)),
  6092. this.input.onPan2.push(function (e, t) {
  6093. var i = 1 - 2.2 / (Math.sqrt(e * e + t * t) + 2.2);
  6094. this.scene.lights.rotation -= .4 * e * i,
  6095. this.wake()
  6096. }
  6097. .bind(this)),
  6098. this.input.onZoom.push(function (e) {
  6099. rotInfo.stopWhenZoom && webview.stopRotate();
  6100. var t = this.scene.view;
  6101. t.radius *= 1 - .002 * e,
  6102. t.radius = t.radius < .001 ? .001 : t.radius,
  6103. t.radius = 1e3 < t.radius ? 1e3 : t.radius,
  6104. t.updateView(),
  6105. this.wake()
  6106. }
  6107. .bind(this)),
  6108. this.input.onDoubleTap.push(function (e, t) {
  6109. this.scene.view.reset(),
  6110. this.scene.sceneAnimator && this.scene.sceneAnimator.resetCustomView(),
  6111. this.wake()
  6112. }
  6113. .bind(this)),
  6114. this.ui.bindInput(this.input)
  6115. },
  6116. W.prototype.rotateWhenIdle = function () {
  6117. if (webview.rotate) return
  6118. rotInfo.radiusK && (webview.scene.view.radius = rotInfo.radiusK / (dom.id("fdageUI").clientWidth / dom.id("fdageUI").clientHeight)),
  6119. webview.scene.view.pivot = rotInfo.pivot.slice(),
  6120. webview.rotate = setInterval(function () {
  6121. webview.scene.view.rotation[1] -= rotInfo.speed,
  6122. webview.updateView(!0, !0, 1)
  6123. }, 16)
  6124. },
  6125. W.prototype.stopRotate = function (ifFinish) { //ifFinish是否不再自动旋转
  6126. if (webview.rotate) {
  6127. clearInterval(webview.rotate),
  6128. // console.log("clearInterval(webview.rotate)"),
  6129. webview.rotate = null,
  6130. ifFinish || (webview.countIdelTime = setTimeout(webview.rotateWhenIdle, rotInfo.idleTime))
  6131. } else {
  6132. if (webview.countIdelTime) {
  6133. clearTimeout(webview.countIdelTime),
  6134. // console.log("clearInterval(countIdelTime)"),
  6135. ifFinish || (webview.countIdelTime = setTimeout(webview.rotateWhenIdle, rotInfo.idleTime))
  6136. }
  6137. }
  6138. },
  6139. W.prototype.resetView = function (e) { //add
  6140. if (window.modelLoding) {
  6141. this.scene.view.reset()
  6142. this.wake()
  6143. }
  6144. },
  6145. W.prototype.zoomIn = function () { //add 放大
  6146. if (window.modelLoding) this.input.onZoom[0](130); //放大会比缩小快一些,所以降低数值
  6147. }
  6148. W.prototype.zoomOut = function () { //add 缩小
  6149. if (window.modelLoding) this.input.onZoom[0](-150);
  6150. }
  6151. W.prototype.wake = function (e) {
  6152. e = e || 16,
  6153. this.sleepCounter = this.sleepCounter < e ? e : this.sleepCounter,
  6154. this.scene.postRender.discardAAHistory(),
  6155. this.requestFrame(this.update.bind(this))
  6156. },
  6157. W.prototype.requestFrame = function (e) {
  6158. var t = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
  6159. if (!this.frameRequestPending) {
  6160. var i = function () {
  6161. this.frameRequestPending = 0,
  6162. e()
  6163. }
  6164. .bind(this);
  6165. this.frameRequestPending = t(i, this.canvas)
  6166. }
  6167. },
  6168. W.prototype.cancelFrame = function () {
  6169. this.frameRequestPending && (window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame)(this.frameRequestPending)
  6170. },
  6171. W.prototype.fullscreenChange = function () {
  6172. g.active() ? (this.oldRootWidth = this.domRoot.style.width,
  6173. this.oldRootHeight = this.domRoot.style.height,
  6174. this.domRoot.style.width = "100%",
  6175. this.domRoot.style.height = "100%") : (this.domRoot.style.width = this.oldRootWidth,
  6176. this.domRoot.style.height = this.oldRootHeight),
  6177. this.wake()
  6178. },
  6179. W.prototype.resize = function (e, t) {
  6180. e && t ? (this.domRoot.style.width = e + "px",
  6181. this.domRoot.style.height = t + "px") : (e = this.domRoot.clientWidth,
  6182. t = this.domRoot.clientHeight),
  6183. this.canvas.width = e * this.pixelRatio,
  6184. this.canvas.height = t * this.pixelRatio,
  6185. this.canvas.style.width = e + "px",
  6186. this.canvas.style.height = t + "px",
  6187. this.ui.setSize(e, t),
  6188. this.allocBacking(),
  6189. this.wake()
  6190. },
  6191. W.prototype.updateLoad = function () {
  6192. this.scene.complete() ? this.start() : this.requestFrame(this.updateLoad.bind(this)),
  6193. this.ui.animate()
  6194. },
  6195. W.prototype.start = function () {
  6196. // console.log('模型加载完成');
  6197. window.modelLoding = true
  6198. this.scene.view.updateView(),
  6199. this.ui.showActiveView(),
  6200. this.requestFrame(this.update.bind(this)),
  6201. window.autoRotate && this.rotateWhenIdle(),
  6202. document.documentElement.style.height = "100%",
  6203. document.documentElement.style.width = "100%",
  6204. document.documentElement.style.margin = "0",
  6205. document.documentElement.style.padding = "0",
  6206. document.body.style.height = "100%",
  6207. document.body.style.width = "100%",
  6208. document.body.style.margin = "0",
  6209. document.body.style.padding = "0"
  6210. },
  6211. W.prototype.update = function () {
  6212. var e = this.scene.sceneAnimator && !this.scene.sceneAnimator.paused;
  6213. (0 < this.sleepCounter || this.ui.animating() || e || this.stripData.animationActive) && (this.stripData.update(),
  6214. this.ui.animate(),
  6215. this.scene.update(),
  6216. this.drawScene(),
  6217. this.requestFrame(this.update.bind(this))),
  6218. e ? this.scene.postRender.discardAAHistory() : this.sleepCounter--
  6219. },
  6220. W.prototype.reDrawScene = function () {
  6221. this.stripData.update(),
  6222. this.ui.animate(),
  6223. this.scene.update(),
  6224. this.drawScene(),
  6225. this.requestFrame(this.update.bind(this)),
  6226. this.scene.postRender.discardAAHistory()
  6227. },
  6228. W.prototype.drawScene = function () {
  6229. this.gl.isContextLost() || (this.domRoot.clientWidth == this.canvas.clientWidth && this.domRoot.clientHeight == this.canvas.clientHeight || this.resize(),
  6230. this.scene.view.size = [this.mainBuffer.width, this.mainBuffer.height],
  6231. this.scene.view.updateProjection(),
  6232. this.scene.postRender.adjustProjectionForSupersampling(this.scene.view),
  6233. this.scene.collectShadows(this.mainBuffer),
  6234. this.mainBuffer.bind(),
  6235. this.scene.draw(this.mainBuffer),
  6236. this.mainDepth && (this.mainBufferNoDepth.bind(),
  6237. this.scene.drawSecondary(this.mainDepth)),
  6238. this.scene.postRender.present(this.mainColor, this.canvas.width, this.canvas.height, this.stripData.active()))
  6239. },
  6240. W.prototype.updateView = function (e, t, i) {
  6241. t && webview.scene.view.updateView(),
  6242. webview.wake(i || 4),
  6243. e && webview.scene.postRender.discardAAHistory()
  6244. },
  6245. (I = void 0 === I ? {} : I).WebViewer = W,
  6246. I.dataLocale = "images/";
  6247. var G = {
  6248. "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);}",
  6249. "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;}",
  6250. "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;}",
  6251. "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)));}",
  6252. "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}",
  6253. "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);}",
  6254. "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);}",
  6255. "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}",
  6256. "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;}",
  6257. "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",
  6258. "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);}",
  6259. "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",
  6260. "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",
  6261. "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",
  6262. "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}",
  6263. "postaa.glsl": "precision mediump float;uniform sampler2D tInput;varying vec2 j;void main(void){gl_FragColor=texture2D(tInput,j);}",
  6264. "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;}",
  6265. "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);}",
  6266. "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;}",
  6267. "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);}",
  6268. "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;}",
  6269. "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}",
  6270. "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;}",
  6271. "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;}",
  6272. "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}",
  6273. "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);}",
  6274. "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;}",
  6275. nil: ""
  6276. }
  6277. }(fdage);