4dage.js 350 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630
  1. var webview,
  2. dom = {},
  3. rotInfo = { idleTime: 3e3, speed: 0.15, pivot: [], stopWhenZoom: !1 };
  4. function getQueryVariable(e) {
  5. for (
  6. var t = window.location.search.substring(1).split("&"), i = 0;
  7. i < t.length;
  8. i++
  9. ) {
  10. var s = t[i].split("=");
  11. if (s[0] == e) return s[1];
  12. }
  13. return !1;
  14. }
  15. (dom.addClass = function(e, t) {
  16. if (void 0 === e.className) e.className = t;
  17. else if (e.className !== t) {
  18. var i = e.className.split(/ +/);
  19. -1 == i.indexOf(t) &&
  20. (i.push(t),
  21. (e.className = i
  22. .join(" ")
  23. .replace(/^\s+/, "")
  24. .replace(/\s+$/, "")));
  25. }
  26. }),
  27. (dom.removeClass = function(e, t) {
  28. if (t)
  29. if (void 0 === e.className);
  30. else if (e.className === t) e.removeAttribute("class");
  31. else {
  32. var i = e.className.split(/ +/),
  33. s = i.indexOf(t);
  34. -1 != s && (i.splice(s, 1), (e.className = i.join(" ")));
  35. }
  36. else e.className = void 0;
  37. }),
  38. (dom.hasClass = function(e, t) {
  39. return new RegExp("(?:^|\\s+)" + t + "(?:\\s+|$)").test(e.className) || !1;
  40. }),
  41. (dom.id = function(e, t) {
  42. return (
  43. ((t = t || document).getElementById && t.getElementById(e)) ||
  44. document.getElementById(e)
  45. );
  46. }),
  47. (dom.Tag = function(e, t) {
  48. return (t = t || document).getElementsByTagName(e);
  49. }),
  50. (dom.cla = function(e, t) {
  51. return (t = t || document).getElementsByClassName(e);
  52. }),
  53. (dom.ifVoid = function(e, t) {
  54. return null == e ? t : e;
  55. }),
  56. (dom.objToArray = function(e) {
  57. if (e instanceof Array) return e;
  58. var t = [];
  59. for (var i in e) t.push(e[i]);
  60. return t;
  61. });
  62. var Clamp = function(e, t, i) {
  63. return (
  64. void 0 === t && (t = 0),
  65. void 0 === i && (i = 1),
  66. Math.min(i, Math.max(t, e))
  67. );
  68. },
  69. codeToCh = function(e) {
  70. return unescape(e);
  71. };
  72. (fdage = {}),
  73. (function(I) {
  74. "use strict";
  75. function r(e, t, i) {
  76. if (
  77. ((this.name = t.partName),
  78. (this.animatedProperties = []),
  79. (this.sceneObjectType = t.sceneObjectType),
  80. (this.skinningRigIndex = t.skinningRigIndex),
  81. (this.id = i),
  82. (this.mesh = this.skinningRig = 0),
  83. (this.materialIndex = this.lightIndex = this.meshIndex = -1),
  84. (this.emissiveProperty = this.offsetVProperty = this.offsetUProperty = this.material = 0),
  85. (this.debugMe = t.debugMe),
  86. (this.debugString = ""),
  87. (this.hasTransform = !1),
  88. (this.modelPartIndex = t.modelPartIndex),
  89. (this.modelPartFPS = t.modelPartFPS),
  90. (this.modelPartScale = t.modelPartScale),
  91. (this.parentIndex = t.parentIndex),
  92. (this.totalFrames = t.totalFrames),
  93. (this.animationLength = (1 / this.modelPartFPS) * this.totalFrames),
  94. (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),
  95. t.animatedProperties)
  96. ) {
  97. i = t.animatedProperties.length;
  98. for (var s = 0; s < i; ++s) {
  99. var n = t.animatedProperties[s],
  100. r = new a();
  101. (r.name = n.name),
  102. this.animatedProperties.push(r),
  103. "Red" != r.name || this.redProperty || (this.redProperty = r),
  104. "Green" != r.name || this.greenProperty || (this.greenProperty = r),
  105. "Blue" != r.name || this.blueProperty || (this.blueProperty = r),
  106. "Brightness" != r.name ||
  107. this.brightnessProperty ||
  108. (this.brightnessProperty = r),
  109. "Distance" != r.name ||
  110. this.distanceProperty ||
  111. (this.distanceProperty = r),
  112. "Spot Angle" != r.name ||
  113. this.spotAngleProperty ||
  114. (this.spotAngleProperty = r),
  115. "Spot Sharpness" != r.name ||
  116. this.spotSharpnessProperty ||
  117. (this.spotSharpnessProperty = r),
  118. "Opacity" != r.name ||
  119. this.opacityProperty ||
  120. (this.opacityProperty = r),
  121. "Sky Illumination" != r.name ||
  122. this.skyIllumProperty ||
  123. (this.skyIllumProperty = r),
  124. "Light Illumination" != r.name ||
  125. this.lightIllumProperty ||
  126. (this.lightIllumProperty = r),
  127. "Dispersion" != r.name ||
  128. this.dispersionProperty ||
  129. (this.dispersionProperty = r),
  130. "Visible" != r.name ||
  131. this.visibleProperty ||
  132. (this.visibleProperty = r),
  133. "Spin Rate" == r.name && (this.spinProperty = r),
  134. "OffsetU" == r.name && (this.offsetUProperty = r),
  135. "OffsetV" == r.name && (this.offsetVProperty = r),
  136. "EmissiveIntensity" == r.name && (this.emissiveProperty = r);
  137. }
  138. }
  139. (this.keyframesSharedBufferUShorts = this.keyframesSharedBufferFloats = this.keyFramesByteStream = 0),
  140. (e = e.get(t.file)) &&
  141. ((this.keyFramesByteStream = new u(e.data)), this.unPackKeyFrames()),
  142. (this.animatedLocalTransform = new o(this)),
  143. (this.hasTransform =
  144. this.animatedLocalTransform.hasTranslation ||
  145. this.animatedLocalTransform.hasRotation ||
  146. this.animatedLocalTransform.hasScale),
  147. (this.cachedWorldTransform0 = S.identity()),
  148. (this.cachedWorldTransform1 = S.identity()),
  149. (this.cachedWorldTransform2 = S.identity()),
  150. (this.cachedWorldTransform3 = S.identity()),
  151. (this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -10),
  152. (this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0),
  153. (this.useFixedLocalTransform = this.useFixedWorldTransform = !1);
  154. }
  155. function a() {
  156. (this.currentValue = 0),
  157. (this.keyframeBufferStartIndexFloat = -1),
  158. (this.lastValue = this.interpolationOffsetUShort = this.frameIndexOffsetUShort = this.weighOutOffsetFloat = this.weighInOffsetFloat = this.valueOffsetFloat = this.indexUShortSkip = this.indexFloatSkip = this.interpolationType = this.bytesPerKeyFrame = this.keyframePackingType = 0),
  159. (this.lastFramePercent = -10),
  160. (this.enable = !0),
  161. (this.name = "NONE"),
  162. (this.splineKF0 = new i(0, 0)),
  163. (this.splineKF1 = new i(0, 0)),
  164. (this.splineKF2 = new i(0, 0)),
  165. (this.splineKF3 = new i(0, 0)),
  166. (this.debugMe = !0),
  167. (this.debugString = ""),
  168. (this.lastSearchIndex = 1),
  169. (this.savedSearchIndex = 0),
  170. (this.splineKF0.frameIndex = 0),
  171. (this.splineKF1.frameIndex = 1),
  172. (this.splineKF2.frameIndex = 2),
  173. (this.splineKF3.frameIndex = 3),
  174. (this.numKeyframes = 0);
  175. }
  176. function o(e) {
  177. var t = e.animatedProperties;
  178. for (
  179. this.TX = this.TY = this.TZ = this.RX = this.RY = this.RZ = this.SX = this.SY = this.SZ = 0,
  180. this.hostObject = e,
  181. this.matrix = S.identity(),
  182. this.cachedmatrix0 = S.identity(),
  183. this.cachedmatrix1 = S.identity(),
  184. this.cachedmatrix2 = S.identity(),
  185. this.cachedmatrix3 = S.identity(),
  186. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -1,
  187. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  188. this.debugString = "",
  189. e = 0;
  190. e < t.length;
  191. e++
  192. ) {
  193. var i = t[e];
  194. "Translation X" == i.name
  195. ? (this.TX = i)
  196. : "Translation Y" == i.name
  197. ? (this.TY = i)
  198. : "Translation Z" == i.name
  199. ? (this.TZ = i)
  200. : "Rotation X" == i.name
  201. ? (this.RX = i)
  202. : "Rotation Y" == i.name
  203. ? (this.RY = i)
  204. : "Rotation Z" == i.name
  205. ? (this.RZ = i)
  206. : "Scale X" == i.name
  207. ? (this.SX = i)
  208. : "Scale Y" == i.name
  209. ? (this.SY = i)
  210. : "Scale Z" == i.name && (this.SZ = i);
  211. }
  212. (this.hasTranslation = this.TX && this.TY && this.TZ),
  213. (this.hasRotation = this.RX && this.RY && this.RZ),
  214. (this.hasScale = this.SX && this.SY && this.SZ),
  215. (this.lockTransform = !1);
  216. }
  217. function c(e, t) {
  218. if (
  219. ((this.originalFPS = 1),
  220. (this.name = t.name),
  221. (this.totalSeconds = t.length),
  222. (this.originalFPS = t.originalFPS),
  223. (this.totalFrames = t.totalFrames),
  224. (this.expectedNumAnimatedObjects = t.numAnimatedObjects),
  225. (this.animatedObjects = []),
  226. (this.sceneTransform = S.identity()),
  227. (this.debugString = ""),
  228. t.animatedObjects)
  229. )
  230. for (var i = t.animatedObjects.length, s = 0; s < i; ++s) {
  231. var n = new r(e, t.animatedObjects[s], s);
  232. this.animatedObjects.push(n), (this.debugString += n.debugString);
  233. }
  234. (this.meshObjects = []),
  235. (this.lightObjects = []),
  236. (this.materialObjects = []),
  237. (this.turnTableObjects = []),
  238. (this.cameraObjects = []);
  239. }
  240. function h(e) {
  241. for (this.files = [], e = new u(e); !e.empty(); ) {
  242. var t = {};
  243. (t.name = e.readCString()), (t.type = e.readCString());
  244. var i = e.readUint32(),
  245. s = e.readUint32(),
  246. n = e.readUint32();
  247. if (((t.data = e.readBytes(s)), !(t.data.length < s))) {
  248. if (1 & i && ((t.data = this.decompress(t.data, n)), null === t.data))
  249. continue;
  250. this.files[t.name] = t;
  251. }
  252. }
  253. }
  254. function l(e) {
  255. this.digits = new Uint16Array(e || 0);
  256. }
  257. function d(e) {
  258. for (var t = 0; t < e.length; ++t) {
  259. var i = e[t].bounds;
  260. if (void 0 === this.min)
  261. (this.min = [i.min[0], i.min[1], i.min[2]]),
  262. (this.max = [i.max[0], i.max[1], i.max[2]]);
  263. else
  264. for (var s = 0; s < 3; ++s)
  265. (this.min[s] = Math.min(i.min[s], this.min[s])),
  266. (this.max[s] = Math.max(i.max[s], this.max[s]));
  267. }
  268. (this.min = this.min ? this.min : [0, 0, 0]),
  269. (this.max = this.max ? this.max : [0, 0, 0]),
  270. (this.center = [
  271. 0.5 * (this.min[0] + this.max[0]),
  272. 0.5 * (this.min[1] + this.max[1]),
  273. 0.5 * (this.min[2] + this.max[2]),
  274. ]),
  275. (this.radius = [
  276. this.max[0] - this.center[0],
  277. this.max[1] - this.center[1],
  278. this.max[2] - this.center[2],
  279. ]),
  280. (this.radiusDiagonal = Math.sqrt(
  281. this.radius[0] * this.radius[0] +
  282. this.radius[1] * this.radius[1] +
  283. this.radius[2] * this.radius[2]
  284. ));
  285. }
  286. function p(e) {
  287. (this.name = "none"),
  288. (this.text = "default text"),
  289. (this.title = "none"),
  290. (this.debugString = this.imagePath = ""),
  291. (this.controlRect = new s(e)),
  292. (this.defaultAlpha = 0.5),
  293. (this.focusAlpha = 1),
  294. (this.updateAlphas = !0),
  295. (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);
  296. }
  297. function u(e) {
  298. this.bytes = new Uint8Array(e);
  299. }
  300. function s(e) {
  301. (this.name = "none"),
  302. (this.title = "frame"),
  303. (this.yPercent = this.xPercent = 0),
  304. (this.heightPercent = this.widthPercent = 1),
  305. (this.debugString = ""),
  306. (this.parentControlRect = 0),
  307. (this.childControlRects = []),
  308. (this.clicked = this.mouseDown = this.mouseOver = !1),
  309. (this.localMouseYPercent = this.localMouseXPercent = 0),
  310. (this.enabled = this.visible = !0),
  311. (this.opacity = 1),
  312. (this.guiScreen = e),
  313. (this.id = this.callBack = this.linkedControl = 0);
  314. }
  315. (r.prototype.setFixedWorldTransform = function(e) {
  316. (this.useFixedWorldTransform = !0), S.copy(this.cachedWorldTransform0, e);
  317. }),
  318. (r.prototype.setFixedLocalTransform = function(e) {
  319. (this.useFixedLocalTransform = !0),
  320. (this.animatedLocalTransform.lockTransform = !0),
  321. S.copy(this.animatedLocalTransform.cachedmatrix0, e);
  322. }),
  323. (r.prototype.getCachedWorldTransform = function(e) {
  324. return this.useFixedWorldTransform
  325. ? 0
  326. : e == this.cachedFrame0
  327. ? this.cachedmatrix0
  328. : e == this.cachedFrame1
  329. ? this.cachedmatrix1
  330. : e == this.cachedFrame2
  331. ? this.cachedmatrix2
  332. : e == this.cachedFrame3
  333. ? this.cachedmatrix3
  334. : 0;
  335. }),
  336. (r.prototype.getFreeCachedWorldTransform = function(e) {
  337. return this.useFixedWorldTransform
  338. ? 0
  339. : (this.cachedFrameUse0--,
  340. this.cachedFrameUse1--,
  341. this.cachedFrameUse2--,
  342. this.cachedFrameUse3--,
  343. this.cachedFrameUse0 <= this.cachedFrameUse1 &&
  344. this.cachedFrameUse0 <= this.cachedFrameUse2 &&
  345. this.cachedFrameUse0 <= this.cachedFrameUse3
  346. ? ((this.cachedFrame0 = e),
  347. (this.cachedFrameUse0 = 0),
  348. this.cachedWorldTransform0)
  349. : this.cachedFrameUse1 <= this.cachedFrameUse0 &&
  350. this.cachedFrameUse1 <= this.cachedFrameUse2 &&
  351. this.cachedFrameUse1 <= this.cachedFrameUse3
  352. ? ((this.cachedFrame1 = e),
  353. (this.cachedFrameUse1 = 0),
  354. this.cachedWorldTransform1)
  355. : this.cachedFrameUse2 <= this.cachedFrameUse0 &&
  356. this.cachedFrameUse2 <= this.cachedFrameUse1 &&
  357. this.cachedFrameUse2 <= this.cachedFrameUse3
  358. ? ((this.cachedFrame2 = e),
  359. (this.cachedFrameUse2 = 0),
  360. this.cachedWorldTransform2)
  361. : ((this.cachedFrame3 = e),
  362. (this.cachedFrameUse3 = 0),
  363. this.cachedWorldTransform3));
  364. }),
  365. (r.prototype.unPackKeyFrames = function() {
  366. if (this.keyFramesByteStream) {
  367. var e = new Float32Array(this.keyFramesByteStream.bytes.buffer),
  368. t = new Uint32Array(this.keyFramesByteStream.bytes.buffer),
  369. i = new Uint16Array(this.keyFramesByteStream.bytes.buffer),
  370. s = new Uint8Array(this.keyFramesByteStream.bytes.buffer);
  371. this.keyframesSharedBufferFloats = e;
  372. (e = 0),
  373. (e = 1 + (t = (this.keyframesSharedBufferUShorts = t)[0])),
  374. (t = this.animatedProperties.length);
  375. for (var n = 0; n < t; n++) {
  376. var r = this.animatedProperties[n],
  377. a = 2 + 2 * n,
  378. o = 2 * a;
  379. (r.keyframeBufferStartIndexFloat = e),
  380. (r.numKeyframes = i[a]),
  381. (r.keyframePackingType = s[2 + o]),
  382. (r.interpolationType = s[3 + o]),
  383. (r.indexFloatSkip = 0),
  384. (r.indexUShortSkip = 0) < r.numKeyframes &&
  385. (0 == r.keyframePackingType
  386. ? ((r.bytesPerKeyFrame = 16),
  387. (r.indexFloatSkip = 4),
  388. (r.indexUShortSkip = 8),
  389. (r.valueOffsetFloat = 0),
  390. (r.weighInOffsetFloat = 1),
  391. (r.weighOutOffsetFloat = 2),
  392. (r.frameIndexOffsetUShort = 6),
  393. (r.interpolationOffsetUShort = 7))
  394. : 1 == r.keyframePackingType
  395. ? ((r.bytesPerKeyFrame = 8),
  396. (r.indexFloatSkip = 2),
  397. (r.indexUShortSkip = 4),
  398. (r.valueOffsetFloat = 0),
  399. (r.weighInOffsetFloat = 0),
  400. (r.weighOutOffsetFloat = 0),
  401. (r.frameIndexOffsetUShort = 2),
  402. (r.interpolationOffsetUShort = 3))
  403. : 2 == r.keyframePackingType &&
  404. ((r.bytesPerKeyFrame = 4),
  405. (r.indexFloatSkip = 1),
  406. (r.indexUShortSkip = 2),
  407. (r.valueOffsetFloat = 0),
  408. (r.weighInOffsetFloat = 0),
  409. (r.weighOutOffsetFloat = 0),
  410. (r.frameIndexOffsetUShort = 0),
  411. (r.interpolationOffsetUShort = 0))),
  412. (e += r.numKeyframes * r.indexFloatSkip);
  413. }
  414. }
  415. }),
  416. (r.prototype.setupSkinningRig = function(e, t, i, s) {
  417. var n = S.identity(),
  418. r = S.identity(),
  419. a = (a = i * (o = e.animatedObjects[t]).modelPartFPS) - Math.floor(a),
  420. o = (i = Math.floor(e.getObjectAnimationFramePercent(o, i))) + 1,
  421. h = 1 - a,
  422. l = s.skinningClusters.length;
  423. if (0 < l)
  424. for (var d = 0; d < l; d++) {
  425. (c = s.skinningClusters[d]).solveClusterTransformAtFrame(
  426. e,
  427. t,
  428. i,
  429. n
  430. ),
  431. c.solveClusterTransformAtFrame(e, t, o, r);
  432. for (var c = c.matrix, u = 0; u < 16; u++)
  433. c[u] = n[u] * h + r[u] * a;
  434. }
  435. }),
  436. (r.prototype.evaluateLocalTransformAtFramePercent = function(e, t, i, s) {
  437. if (this.useFixedLocalTransform)
  438. S.copy(t, this.animatedLocalTransform.cachedmatrix0);
  439. else {
  440. var n = 0;
  441. s && (n = this.animatedLocalTransform.getCachedTransform(e)),
  442. n
  443. ? S.copy(t, n)
  444. : ((n = this.animatedLocalTransform.getFreeCachedTransform(e))
  445. ? (this.animatedLocalTransform.evaluateMatrix(
  446. n,
  447. this.totalFrames,
  448. e,
  449. i
  450. ),
  451. S.copy(t, n))
  452. : this.animatedLocalTransform.evaluateMatrix(
  453. t,
  454. this.totalFrames,
  455. e,
  456. i
  457. ),
  458. 0 != this.turnTableSpin &&
  459. ((e = S.rotation(S.empty(), this.turnTableSpin, 1)),
  460. S.mul(t, t, e)));
  461. }
  462. }),
  463. (r.prototype.hasAnimatedTransform = function() {
  464. var e = this.animatedLocalTransform;
  465. return !!(
  466. (e.TX && 1 < e.TX.numKeyframes) ||
  467. (e.TY && 1 < e.TY.numKeyframes) ||
  468. (e.TZ && 1 < e.TZ.numKeyframes) ||
  469. (e.RX && 1 < e.RX.numKeyframes) ||
  470. (e.RY && 1 < e.RY.numKeyframes) ||
  471. (e.RZ && 1 < e.RZ.numKeyframes) ||
  472. (e.SX && 1 < e.SX.numKeyframes) ||
  473. (e.SY && 1 < e.SY.numKeyframes) ||
  474. (e.SZ && 1 < e.SZ.numKeyframes)
  475. );
  476. }),
  477. (a.prototype.evaluateCurve = function(e, t) {
  478. var i = this.splineKF1.frameIndex,
  479. s = this.splineKF2.frameIndex,
  480. n = this.splineKF1.value,
  481. r = this.splineKF2.value,
  482. a = i - (this.splineKF2.frameIndex - this.splineKF0.frameIndex),
  483. o = s - (this.splineKF1.frameIndex - this.splineKF3.frameIndex),
  484. h =
  485. n -
  486. (this.splineKF2.value - this.splineKF0.value) *
  487. this.splineKF1.weighOut,
  488. l =
  489. r -
  490. (this.splineKF1.value - this.splineKF3.value) *
  491. this.splineKF2.weighIn;
  492. return (
  493. 3 == this.splineKF1.interpolation &&
  494. ((a = i - (this.splineKF2.frameIndex - this.splineKF1.frameIndex)),
  495. (h = n - this.splineKF1.weighOut)),
  496. 3 == this.splineKF2.interpolation &&
  497. ((o = s - (this.splineKF1.frameIndex - this.splineKF2.frameIndex)),
  498. (l = r + this.splineKF2.weighIn)),
  499. (a = (e - a) / (i - a)),
  500. (i = (e - i) / (s - i)),
  501. (s = (e - s) / (o - s)),
  502. ((h * (1 - a) + n * a) * (1 - i) + (o = n * (1 - i) + r * i) * i) *
  503. (1 - i) +
  504. ((r * (1 - s) + l * s) * i + o * (1 - i)) * i
  505. );
  506. }),
  507. (a.prototype.evaluate = function(e, t, i) {
  508. if (!i) return t;
  509. if (0 == this.numKeyframes) return (this.lastValue = t);
  510. if (1 == this.numKeyframes)
  511. return (this.lastValue =
  512. 2 == this.keyframePackingType
  513. ? i.keyframesSharedBufferFloats[
  514. this.keyframeBufferStartIndexFloat
  515. ]
  516. : i.keyframesSharedBufferFloats[
  517. this.keyframeBufferStartIndexFloat + this.valueOffsetFloat
  518. ]);
  519. if (this.lastFramePercent == e) return this.lastValue;
  520. var s = this.keyframeBufferStartIndexFloat,
  521. n = 2 * this.keyframeBufferStartIndexFloat;
  522. if (
  523. ((this.lastValue = t),
  524. (this.lastFramePercent = e),
  525. 2 == this.keyframePackingType)
  526. ) {
  527. var r = e - (t = Math.floor(e));
  528. return (
  529. e >= this.numKeyframes &&
  530. (t -= Math.floor(e / this.numKeyframes) * this.numKeyframes),
  531. t >= this.numKeyframes
  532. ? (this.lastValue =
  533. i.keyframesSharedBufferFloats[s + (this.numKeyframes - 1)])
  534. : t < 0
  535. ? (this.lastValue = i.keyframesSharedBufferFloats[s])
  536. : 0 == r
  537. ? (this.lastValue = i.keyframesSharedBufferFloats[s + t])
  538. : ((e = n = i.keyframesSharedBufferFloats[s + t]),
  539. ++t >= this.numKeyframes && (t -= this.numKeyframes),
  540. 0 <= t && t < this.numKeyframes
  541. ? (e = n * (1 - r) + i.keyframesSharedBufferFloats[s + t] * r)
  542. : (i.debugString +=
  543. "<br>bad lerp frame " + t + " of " + this.numKeyframes),
  544. (this.lastValue = e))
  545. );
  546. }
  547. var a = this.numKeyframes;
  548. r = i.keyframesSharedBufferUShorts[n + this.frameIndexOffsetUShort];
  549. if (
  550. e >=
  551. i.keyframesSharedBufferUShorts[
  552. n + (a - 1) * this.indexUShortSkip + this.frameIndexOffsetUShort
  553. ]
  554. )
  555. return (this.lastValue =
  556. i.keyframesSharedBufferFloats[
  557. s + (a - 1) * this.indexFloatSkip + this.valueOffsetFloat
  558. ]);
  559. if (e < r)
  560. return (this.lastValue =
  561. i.keyframesSharedBufferFloats[s + this.valueOffsetFloat]);
  562. this.lastSearchIndex < this.numKeyframes &&
  563. e >
  564. i.keyframesSharedBufferUShorts[
  565. n +
  566. this.lastSearchIndex * this.indexUShortSkip +
  567. this.frameIndexOffsetUShort
  568. ] &&
  569. (this.lastSearchIndex = 1);
  570. for (var o = this.lastSearchIndex; o < a; o++) {
  571. r = s + o * this.indexFloatSkip;
  572. var h = s + (o - 1) * this.indexFloatSkip,
  573. l = n + o * this.indexUShortSkip,
  574. d = n + (o - 1) * this.indexUShortSkip;
  575. if (
  576. e >=
  577. i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort] &&
  578. e <= i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort]
  579. ) {
  580. this.lastSearchIndex = o;
  581. var c =
  582. i.keyframesSharedBufferUShorts[
  583. d + this.interpolationOffsetUShort
  584. ];
  585. if (2 == c) {
  586. this.lastValue = e =
  587. e >=
  588. i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort]
  589. ? i.keyframesSharedBufferFloats[r + this.valueOffsetFloat]
  590. : i.keyframesSharedBufferFloats[h + this.valueOffsetFloat];
  591. break;
  592. }
  593. if (0 == c) {
  594. (s =
  595. i.keyframesSharedBufferUShorts[
  596. d + this.frameIndexOffsetUShort
  597. ]),
  598. (t = i.keyframesSharedBufferFloats[h + this.valueOffsetFloat]),
  599. (n = i.keyframesSharedBufferFloats[r + this.valueOffsetFloat]),
  600. (r =
  601. (e - s) /
  602. (i.keyframesSharedBufferUShorts[
  603. l + this.frameIndexOffsetUShort
  604. ] -
  605. s)),
  606. (this.lastValue = e = t * (1 - r) + n * r);
  607. break;
  608. }
  609. if (1 == c || 3 == c) {
  610. var u = (c = !1),
  611. f = 0,
  612. m = i.keyframesSharedBufferFloats[h + this.valueOffsetFloat],
  613. p = i.keyframesSharedBufferFloats[r + this.valueOffsetFloat],
  614. g = 0,
  615. v = 0,
  616. x =
  617. ((d =
  618. i.keyframesSharedBufferUShorts[
  619. d + this.frameIndexOffsetUShort
  620. ]),
  621. (l =
  622. i.keyframesSharedBufferUShorts[
  623. l + this.frameIndexOffsetUShort
  624. ]),
  625. 0),
  626. y = 1,
  627. b = 1,
  628. S = 1,
  629. T = 1,
  630. w = 1,
  631. C = 1,
  632. R = 1,
  633. A = 1;
  634. 0 != this.weighInOffsetFloat &&
  635. ((b =
  636. i.keyframesSharedBufferFloats[h + this.weighInOffsetFloat]),
  637. (S =
  638. i.keyframesSharedBufferFloats[r + this.weighInOffsetFloat]),
  639. (C =
  640. i.keyframesSharedBufferFloats[h + this.weighOutOffsetFloat]),
  641. (R =
  642. i.keyframesSharedBufferFloats[r + this.weighOutOffsetFloat])),
  643. 1 < o &&
  644. ((c = !0),
  645. (f =
  646. i.keyframesSharedBufferFloats[
  647. s + (o - 2) * this.indexFloatSkip + this.valueOffsetFloat
  648. ]),
  649. (v =
  650. i.keyframesSharedBufferUShorts[
  651. n +
  652. (o - 2) * this.indexUShortSkip +
  653. this.frameIndexOffsetUShort
  654. ]),
  655. 0 != this.weighInOffsetFloat &&
  656. ((y =
  657. i.keyframesSharedBufferFloats[
  658. s +
  659. (o - 2) * this.indexFloatSkip +
  660. this.weighInOffsetFloat
  661. ]),
  662. (w =
  663. i.keyframesSharedBufferFloats[
  664. s +
  665. (o - 2) * this.indexFloatSkip +
  666. this.weighOutOffsetFloat
  667. ]))),
  668. o < a - 1 &&
  669. ((u = !0),
  670. (g =
  671. i.keyframesSharedBufferFloats[
  672. s + (o + 1) * this.indexFloatSkip + this.valueOffsetFloat
  673. ]),
  674. (x =
  675. i.keyframesSharedBufferUShorts[
  676. n +
  677. (o + 1) * this.indexUShortSkip +
  678. this.frameIndexOffsetUShort
  679. ]),
  680. 0 != this.weighInOffsetFloat &&
  681. ((T =
  682. i.keyframesSharedBufferFloats[
  683. s +
  684. (o + 1) * this.indexFloatSkip +
  685. this.weighInOffsetFloat
  686. ]),
  687. (A =
  688. i.keyframesSharedBufferFloats[
  689. s +
  690. (o + 1) * this.indexFloatSkip +
  691. this.weighOutOffsetFloat
  692. ]))),
  693. c && u
  694. ? ((this.splineKF0.value = f),
  695. (this.splineKF1.value = m),
  696. (this.splineKF2.value = p),
  697. (this.splineKF3.value = g),
  698. (this.splineKF0.frameIndex = v),
  699. (this.splineKF1.frameIndex = d),
  700. (this.splineKF2.frameIndex = l),
  701. (this.splineKF3.frameIndex = x),
  702. (this.splineKF0.weighIn = y),
  703. (this.splineKF0.weighOut = w),
  704. (this.splineKF1.weighIn = b),
  705. (this.splineKF1.weighOut = C),
  706. (this.splineKF2.weighIn = S),
  707. (this.splineKF2.weighOut = R),
  708. (this.splineKF3.weighIn = T),
  709. (this.splineKF3.weighOut = A))
  710. : ((this.splineKF0.value = m),
  711. (this.splineKF1.value = m),
  712. (this.splineKF2.value = p),
  713. (this.splineKF3.value = p),
  714. (this.splineKF0.frameIndex = d),
  715. (this.splineKF1.frameIndex = d),
  716. (this.splineKF2.frameIndex = l),
  717. (this.splineKF3.frameIndex = l),
  718. (this.splineKF1.weighIn = b),
  719. (this.splineKF2.weighIn = S),
  720. (this.splineKF1.weighOut = C),
  721. (this.splineKF2.weighOut = R),
  722. u
  723. ? ((this.splineKF3.value = g),
  724. (this.splineKF3.frameIndex = x),
  725. (this.splineKF3.weighIn = T),
  726. (this.splineKF3.weighOut = A))
  727. : (this.splineKF3.frameIndex++,
  728. (this.splineKF3.value = this.splineKF1.value),
  729. (this.splineKF3.weighIn = 1),
  730. (this.splineKF3.weighOut = 1)),
  731. c
  732. ? ((this.splineKF0.value = f),
  733. (this.splineKF0.frameIndex = v),
  734. (this.splineKF0.weighIn = y),
  735. (this.splineKF0.weighOut = w))
  736. : ((this.splineKF0.value = this.splineKF2.value),
  737. (this.splineKF0.weighIn = 1),
  738. (this.splineKF0.weighOut = 1),
  739. 0 < this.splineKF0.frameIndex
  740. ? this.splineKF0.frameIndex--
  741. : (this.splineKF1.frameIndex++,
  742. this.splineKF2.frameIndex++,
  743. this.splineKF3.frameIndex++,
  744. e++))),
  745. (this.lastValue = e = this.evaluateCurve(e, t));
  746. break;
  747. }
  748. }
  749. }
  750. return this.lastValue;
  751. }),
  752. (o.prototype.getTRSValue = function(e, t, i) {
  753. return t
  754. ? (t.evaluate(e, i, this.hostObject),
  755. "" != t.debugString && (this.debugString += t.debugString),
  756. t.lastValue)
  757. : i;
  758. }),
  759. (o.prototype.evaluateMatrix = function(e, t, i, s) {
  760. if (this.lockTransform) S.copy(e, this.cachedmatrix0);
  761. else {
  762. var n = 0,
  763. r = (t = 0);
  764. (n = r = t = 0), (n = r = t = 1);
  765. this.hasRotation
  766. ? ((n = this.getTRSValue(i, this.RX, 0)),
  767. (t = this.getTRSValue(i, this.RY, 0)),
  768. (r = this.getTRSValue(i, this.RZ, 0)),
  769. s
  770. ? ((this.matrix = S.rotation(S.empty(), r, 2)),
  771. (s = S.rotation(S.empty(), n, 0)),
  772. S.mul(s, s, this.matrix),
  773. (this.matrix = S.rotation(S.empty(), t, 1)))
  774. : ((this.matrix = S.rotation(S.empty(), n, 0)),
  775. (s = S.rotation(S.empty(), t, 1)),
  776. S.mul(s, s, this.matrix),
  777. (this.matrix = S.rotation(S.empty(), r, 2))),
  778. S.mul(this.matrix, this.matrix, s))
  779. : S.copy(this.matrix, S.identity()),
  780. this.hasTranslation &&
  781. ((t = this.getTRSValue(i, this.TX, 0)),
  782. (r = this.getTRSValue(i, this.TY, 0)),
  783. (n = this.getTRSValue(i, this.TZ, 0)),
  784. (this.matrix[12] = t),
  785. (this.matrix[13] = r),
  786. (this.matrix[14] = n)),
  787. this.hasScale &&
  788. ((t = this.getTRSValue(i, this.SX, 1)),
  789. (r = this.getTRSValue(i, this.SY, 1)),
  790. (n = this.getTRSValue(i, this.SZ, 1)),
  791. (this.matrix[0] *= t),
  792. (this.matrix[4] *= r),
  793. (this.matrix[8] *= n),
  794. (this.matrix[1] *= t),
  795. (this.matrix[5] *= r),
  796. (this.matrix[9] *= n),
  797. (this.matrix[2] *= t),
  798. (this.matrix[6] *= r),
  799. (this.matrix[10] *= n),
  800. (this.matrix[3] *= t),
  801. (this.matrix[7] *= r),
  802. (this.matrix[11] *= n)),
  803. S.copy(e, this.matrix);
  804. }
  805. }),
  806. (o.prototype.clearCachedTransforms = function() {
  807. (this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -1),
  808. (this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0),
  809. this.TX && (this.TX.lastFramePercent = -10),
  810. this.TY && (this.TY.lastFramePercent = -10),
  811. this.TZ && (this.TZ.lastFramePercent = -10),
  812. this.RX && (this.RX.lastFramePercent = -10),
  813. this.RY && (this.RY.lastFramePercent = -10),
  814. this.RZ && (this.RZ.lastFramePercent = -10),
  815. this.SX && (this.SX.lastFramePercent = -10),
  816. this.SY && (this.SY.lastFramePercent = -10),
  817. this.SZ && (this.SZ.lastFramePercent = -10),
  818. (this.lockTransform = !1);
  819. }),
  820. (o.prototype.getCachedTransform = function(e) {
  821. return this.lockTransform
  822. ? 0
  823. : this.cachedFrame0 == e
  824. ? this.cachedmatrix0
  825. : this.cachedFrame1 == e
  826. ? this.cachedmatrix1
  827. : this.cachedFrame2 == e
  828. ? this.cachedmatrix2
  829. : this.cachedFrame3 == e
  830. ? this.cachedmatrix3
  831. : 0;
  832. }),
  833. (o.prototype.getFreeCachedTransform = function(e) {
  834. return this.lockTransform
  835. ? 0
  836. : (this.cachedFrameUse0--,
  837. this.cachedFrameUse1--,
  838. this.cachedFrameUse2--,
  839. this.cachedFrameUse3--,
  840. (this.cachedFrameUse0 <= this.cachedFrameUse1 &&
  841. this.cachedFrameUse0 <= this.cachedFrameUse2 &&
  842. this.cachedFrameUse0 <= this.cachedFrameUse3) ||
  843. this.cachedFrame0 == e
  844. ? ((this.cachedFrame0 = e),
  845. (this.cachedFrameUse0 = 0),
  846. this.cachedmatrix0)
  847. : (this.cachedFrameUse1 <= this.cachedFrameUse0 &&
  848. this.cachedFrameUse1 <= this.cachedFrameUse2 &&
  849. this.cachedFrameUse1 <= this.cachedFrameUse3) ||
  850. this.cachedFrame1 == e
  851. ? ((this.cachedFrame1 = e),
  852. (this.cachedFrameUse1 = 0),
  853. this.cachedmatrix1)
  854. : (this.cachedFrameUse2 <= this.cachedFrameUse0 &&
  855. this.cachedFrameUse2 <= this.cachedFrameUse1 &&
  856. this.cachedFrameUse2 <= this.cachedFrameUse3) ||
  857. this.cachedFrame2 == e
  858. ? ((this.cachedFrame2 = e),
  859. (this.cachedFrameUse2 = 0),
  860. this.cachedmatrix2)
  861. : ((this.cachedFrame3 = e),
  862. (this.cachedFrameUse3 = 0),
  863. this.cachedmatrix3));
  864. }),
  865. (c.prototype.evaluateModelPartTransformAtFrame = function(e, t, i, s) {
  866. S.copy(i, S.identity());
  867. for (var n = 0; n < 100; n++) {
  868. var r = this.animatedObjects[e];
  869. if (e == r.parentIndex) break;
  870. if (r.useFixedWorldTransform) {
  871. S.mul(i, r.cachedWorldTransform0, i);
  872. break;
  873. }
  874. var a = 0;
  875. if ((s && (a = r.getCachedWorldTransform(t)), a)) {
  876. S.mul(i, a, i);
  877. break;
  878. }
  879. (a = S.identity()),
  880. r.evaluateLocalTransformAtFramePercent(t, a, !1, s),
  881. S.mul(i, a, i),
  882. e == r.parentIndex && (n = 100),
  883. (e = r.parentIndex);
  884. }
  885. }),
  886. (c.prototype.lerpModelPartTransform = function(e, t, i, s) {
  887. var n = this.animatedObjects[e];
  888. if (n.useFixedWorldTransform) S.copy(i, n.cachedWorldTransform0);
  889. else {
  890. var r = (r = t * n.modelPartFPS) - Math.floor(r),
  891. a = Math.floor(this.getObjectAnimationFramePercent(n, t)),
  892. o = a + 1,
  893. h = (t = 0);
  894. for (
  895. s &&
  896. ((t = n.getCachedWorldTransform(a)),
  897. (h = n.getCachedWorldTransform(o))),
  898. t ||
  899. ((t = n.getFreeCachedWorldTransform(a)) || (t = S.identity()),
  900. this.evaluateModelPartTransformAtFrame(e, a, t, s)),
  901. h ||
  902. ((h = n.getFreeCachedWorldTransform(o)) || (h = S.identity()),
  903. this.evaluateModelPartTransformAtFrame(e, o, h, s)),
  904. e = 1 - r,
  905. s = 0;
  906. s < 16;
  907. s++
  908. )
  909. i[s] = t[s] * e + h[s] * r;
  910. }
  911. }),
  912. (c.prototype.getModelPartTransform = function(e, t, i, s) {
  913. this.lerpModelPartTransform(e, t, i, s);
  914. }),
  915. (c.prototype.getAnimatedLocalTransform = function(e, t, i, s) {
  916. e = this.animatedObjects[e];
  917. var n = this.animatedObjects[e.parentIndex],
  918. r = n.modelPartIndex != n.id,
  919. a = S.identity();
  920. if ((this.getModelPartTransform(e.modelPartIndex, t, a, s), r)) {
  921. r = S.identity();
  922. var o = S.identity();
  923. this.getModelPartTransform(n.modelPartIndex, t, r, s),
  924. S.invert(o, r),
  925. S.mul(i, o, a),
  926. (i[12] *= e.modelPartScale),
  927. (i[13] *= e.modelPartScale),
  928. (i[14] *= e.modelPartScale);
  929. } else S.copy(i, a);
  930. }),
  931. (c.prototype.isVisibleAtFramePercent = function(e, t) {
  932. for (var i = e, s = 0, n = 0; n < 100; n++) {
  933. if ((s = this.animatedObjects[i]).visibleProperty) {
  934. if (
  935. (s.visibleProperty.evaluate(t, 1, s),
  936. "" != s.debugString || "" != s.visibleProperty.debugString)
  937. )
  938. return (
  939. (this.debugString += s.debugString),
  940. (this.debugString += s.visibleProperty.debugString),
  941. !1
  942. );
  943. if (0 == s.visibleProperty.lastValue) return !1;
  944. }
  945. i == s.parentIndex && (n = 100), (i = s.parentIndex);
  946. }
  947. return !0;
  948. }),
  949. (c.prototype.getWorldTransform = function(e, t, i, s, n) {
  950. if ((e = this.animatedObjects[e]).useFixedWorldTransform)
  951. S.copy(i, e.cachedWorldTransform0);
  952. else {
  953. var r = this.getObjectAnimationFramePercent(e, t),
  954. a = S.identity();
  955. if (
  956. (e.evaluateLocalTransformAtFramePercent(r, a, !0, n),
  957. (r = e.modelPartIndex != e.id))
  958. ) {
  959. r = S.identity();
  960. var o = S.identity();
  961. S.copy(o, a),
  962. this.getAnimatedLocalTransform(e.id, t, r),
  963. S.mul(a, r, o);
  964. }
  965. if ((S.copy(i, a), e.parentIndex != e.id))
  966. for (var h = e.parentIndex, l = 0; l < 100; l++)
  967. (e = this.animatedObjects[h]),
  968. (r = this.getObjectAnimationFramePercent(e, t)),
  969. (a = S.identity()),
  970. e.evaluateLocalTransformAtFramePercent(r, a, !0, n),
  971. (r = e.modelPartIndex != e.id)
  972. ? ((r = S.identity()),
  973. this.getAnimatedLocalTransform(e.id, t, r),
  974. (o = S.identity()),
  975. S.mul(o, a, i),
  976. S.mul(i, r, o))
  977. : ((o = S.identity()), S.copy(o, i), S.mul(i, a, o)),
  978. h == e.parentIndex && (l = 100),
  979. (h = e.parentIndex);
  980. (i[12] *= s), (i[13] *= s), (i[14] *= s);
  981. }
  982. }),
  983. (c.prototype.hasParentInHierarchy = function(e, t) {
  984. for (var i = e.parentIndex, s = 0; s < 100; s++) {
  985. if ((e = this.animatedObjects[i]).id == t) return !0;
  986. i == e.parentIndex && (s = 100), (i = e.parentIndex);
  987. }
  988. return !1;
  989. }),
  990. (c.prototype.hasParentTypeInHierarchy = function(e, t) {
  991. for (var i = e.parentIndex, s = 0; s < 100; s++) {
  992. if ((e = this.animatedObjects[i]).sceneObjectType == t) return !0;
  993. i == e.parentIndex && (s = 100), (i = e.parentIndex);
  994. }
  995. return !1;
  996. }),
  997. (c.prototype.searchAnimationUpHierarchy = function(e) {
  998. for (var t = e.id, i = 0; i < 100; i++) {
  999. if (
  1000. (e = this.animatedObjects[t]).animatedLocalTransform &&
  1001. (e.hasAnimatedTransform() ||
  1002. (e.id != e.modelPartIndex &&
  1003. this.searchAnimationUpHierarchy(
  1004. this.animatedObjects[e.modelPartIndex]
  1005. )))
  1006. )
  1007. return !0;
  1008. t == e.parentIndex && (i = 100), (t = e.parentIndex);
  1009. }
  1010. return !1;
  1011. }),
  1012. (c.prototype.hasAnimationInHierarchy = function(e) {
  1013. return !!(
  1014. this.searchAnimationUpHierarchy(e) ||
  1015. (e.id != e.modelPartIndex &&
  1016. this.searchAnimationUpHierarchy(
  1017. this.animatedObjects[e.modelPartIndex]
  1018. )) ||
  1019. this.hasParentTypeInHierarchy(e, "TurnTableSO") ||
  1020. this.hasParentTypeInHierarchy(e, "CameraSO") ||
  1021. "CameraSO" == e.sceneObjectType
  1022. );
  1023. }),
  1024. (c.prototype.getObjectAnimationFramePercent = function(e, t) {
  1025. if (0 == this.totalFrames || 0 == e.animationLength) return 0;
  1026. var i = t / e.animationLength;
  1027. i = Math.floor(i);
  1028. return (
  1029. (i = (t -= e.animationLength * i) * e.modelPartFPS) >=
  1030. e.totalFrames + 1 && (i = e.totalFrames),
  1031. i
  1032. );
  1033. }),
  1034. (h.prototype.get = function(e) {
  1035. return this.files[e];
  1036. }),
  1037. (h.prototype.extract = function(e) {
  1038. var t = this.files[e];
  1039. return delete this.files[e], t;
  1040. }),
  1041. (h.prototype.checkSignature = function(e) {
  1042. if (!e) return !1;
  1043. var t = this.get(e.name + ".sig");
  1044. if (!t) return !1;
  1045. if (!(t = JSON.parse(String.fromCharCode.apply(null, t.data))))
  1046. return !1;
  1047. for (var i = 5381, s = 0; s < e.data.length; ++s)
  1048. i = (33 * i + e.data[s]) & 4294967295;
  1049. return (
  1050. (e = new l()).setBytes(
  1051. [
  1052. 0,
  1053. 233,
  1054. 33,
  1055. 170,
  1056. 116,
  1057. 86,
  1058. 29,
  1059. 195,
  1060. 228,
  1061. 46,
  1062. 189,
  1063. 3,
  1064. 185,
  1065. 31,
  1066. 245,
  1067. 19,
  1068. 159,
  1069. 105,
  1070. 73,
  1071. 190,
  1072. 158,
  1073. 80,
  1074. 175,
  1075. 38,
  1076. 210,
  1077. 116,
  1078. 221,
  1079. 229,
  1080. 171,
  1081. 134,
  1082. 104,
  1083. 144,
  1084. 140,
  1085. 5,
  1086. 99,
  1087. 255,
  1088. 208,
  1089. 78,
  1090. 248,
  1091. 215,
  1092. 172,
  1093. 44,
  1094. 79,
  1095. 83,
  1096. 5,
  1097. 244,
  1098. 152,
  1099. 19,
  1100. 92,
  1101. 137,
  1102. 112,
  1103. 10,
  1104. 101,
  1105. 142,
  1106. 209,
  1107. 100,
  1108. 244,
  1109. 92,
  1110. 190,
  1111. 125,
  1112. 28,
  1113. 0,
  1114. 185,
  1115. 54,
  1116. 143,
  1117. 247,
  1118. 49,
  1119. 37,
  1120. 15,
  1121. 254,
  1122. 142,
  1123. 180,
  1124. 185,
  1125. 232,
  1126. 50,
  1127. 219,
  1128. 11,
  1129. 186,
  1130. 106,
  1131. 116,
  1132. 78,
  1133. 212,
  1134. 10,
  1135. 105,
  1136. 53,
  1137. 26,
  1138. 14,
  1139. 181,
  1140. 80,
  1141. 47,
  1142. 87,
  1143. 213,
  1144. 182,
  1145. 19,
  1146. 126,
  1147. 151,
  1148. 86,
  1149. 109,
  1150. 182,
  1151. 224,
  1152. 37,
  1153. 135,
  1154. 80,
  1155. 59,
  1156. 22,
  1157. 93,
  1158. 125,
  1159. 68,
  1160. 214,
  1161. 106,
  1162. 209,
  1163. 152,
  1164. 235,
  1165. 157,
  1166. 249,
  1167. 245,
  1168. 48,
  1169. 76,
  1170. 203,
  1171. 0,
  1172. 0,
  1173. 95,
  1174. 200,
  1175. 246,
  1176. 243,
  1177. 229,
  1178. 85,
  1179. 79,
  1180. 169,
  1181. ],
  1182. !0
  1183. ),
  1184. (s = new l()).setBytes(t[0]),
  1185. s.powmod(65537, e).toInt32() == i
  1186. );
  1187. }),
  1188. (h.prototype.decompress = function(e, t) {
  1189. var i = new Uint8Array(t),
  1190. s = 0,
  1191. n = new Uint32Array(4096),
  1192. r = new Uint32Array(4096),
  1193. a = 256,
  1194. o = e.length,
  1195. h = 0,
  1196. l = 1,
  1197. d = 0,
  1198. c = 1;
  1199. i[s++] = e[0];
  1200. for (var u = 1; !(o <= (c = u + (u >> 1)) + 1); u++) {
  1201. (d = e[c + 1]), (c = e[c]);
  1202. if ((f = 1 & u ? (d << 4) | (c >> 4) : ((15 & d) << 8) | c) < a)
  1203. if (f < 256) (d = s), (c = 1), (i[s++] = f);
  1204. else {
  1205. (d = s), (c = r[f]);
  1206. for (var f, m = (f = n[f]) + c; f < m; ) i[s++] = i[f++];
  1207. }
  1208. else {
  1209. if (f != a) break;
  1210. for (d = s, c = l + 1, m = (f = h) + l; f < m; ) i[s++] = i[f++];
  1211. i[s++] = i[h];
  1212. }
  1213. (n[a] = h),
  1214. (r[a++] = l + 1),
  1215. (h = d),
  1216. (l = c),
  1217. (a = 4096 <= a ? 256 : a);
  1218. }
  1219. return s == t ? i : null;
  1220. }),
  1221. (l.prototype.setBytes = function(e, t) {
  1222. var i = ((e.length + 1) / 2) | 0;
  1223. if (((this.digits = new Uint16Array(i)), t)) {
  1224. var s = 0;
  1225. for (i = e.length - 1; 0 <= i; i -= 2)
  1226. this.digits[s++] = e[i] + (0 < i ? 256 * e[i - 1] : 0);
  1227. } else
  1228. for (s = 0; s < i; ++s)
  1229. this.digits[s] = e[2 * s] + 256 * e[2 * s + 1];
  1230. this.trim();
  1231. }),
  1232. (l.prototype.toInt32 = function() {
  1233. var e = 0;
  1234. return (
  1235. 0 < this.digits.length &&
  1236. ((e = this.digits[0]),
  1237. 1 < this.digits.length && (e |= this.digits[1] << 16)),
  1238. e
  1239. );
  1240. }),
  1241. (l.prototype.lessThan = function(e) {
  1242. if (this.digits.length == e.digits.length)
  1243. for (var t = this.digits.length - 1; 0 <= t; --t) {
  1244. var i = this.digits[t],
  1245. s = e.digits[t];
  1246. if (i != s) return i < s;
  1247. }
  1248. return this.digits.length < e.digits.length;
  1249. }),
  1250. (l.prototype.shiftRight = function() {
  1251. for (var e = 0, t = this.digits, i = t.length - 1; 0 <= i; --i) {
  1252. var s = t[i];
  1253. (t[i] = (s >> 1) | (e << 15)), (e = s);
  1254. }
  1255. this.trim();
  1256. }),
  1257. (l.prototype.shiftLeft = function(e) {
  1258. if (0 < e) {
  1259. for (
  1260. var t = (e / 16) | 0,
  1261. i = 16 - (e %= 16),
  1262. s = this.digits.length + t + 1,
  1263. n = new l(s),
  1264. r = 0;
  1265. r < s;
  1266. ++r
  1267. )
  1268. n.digits[r] =
  1269. 65535 &
  1270. (((r < t || r >= this.digits.length + t
  1271. ? 0
  1272. : this.digits[r - t]) <<
  1273. e) |
  1274. ((r < 1 + t ? 0 : this.digits[r - t - 1]) >>> i));
  1275. return n.trim(), n;
  1276. }
  1277. return new l(this);
  1278. }),
  1279. (l.prototype.bitCount = function() {
  1280. var e = 0;
  1281. if (0 < this.digits.length) {
  1282. e = 16 * (this.digits.length - 1);
  1283. for (var t = this.digits[this.digits.length - 1]; t; )
  1284. (t >>>= 1), ++e;
  1285. }
  1286. return e;
  1287. }),
  1288. (l.prototype.sub = function(e) {
  1289. var t = this.digits,
  1290. i = e.digits,
  1291. s = this.digits.length;
  1292. e = e.digits.length;
  1293. for (var n = 0, r = 0; r < s; ++r) {
  1294. var a,
  1295. o =
  1296. (o = t[r]) +
  1297. ((n = o < (a = (a = r < e ? i[r] : 0) + n) ? 1 : 0) << 16);
  1298. t[r] = (o - a) & 65535;
  1299. }
  1300. this.trim();
  1301. }),
  1302. (l.prototype.mul = function(e) {
  1303. for (
  1304. var t = new l(this.digits.length + e.digits.length),
  1305. i = t.digits,
  1306. s = 0;
  1307. s < this.digits.length;
  1308. ++s
  1309. )
  1310. for (var n = this.digits[s], r = 0; r < e.digits.length; ++r)
  1311. for (var a = n * e.digits[r], o = s + r; a; ) {
  1312. var h = (65535 & a) + i[o];
  1313. (i[o] = 65535 & h), (a >>>= 16), (a += h >>> 16), ++o;
  1314. }
  1315. return t.trim(), t;
  1316. }),
  1317. (l.prototype.mod = function(e) {
  1318. if (this.digits.length <= 0 || e.digits.length <= 0) return new l(0);
  1319. var t = new l(this.digits);
  1320. if (!this.lessThan(e)) {
  1321. for (
  1322. var i = (i = new l(e.digits)).shiftLeft(
  1323. t.bitCount() - i.bitCount()
  1324. );
  1325. !t.lessThan(e);
  1326. )
  1327. i.lessThan(t) && t.sub(i), i.shiftRight();
  1328. t.trim();
  1329. }
  1330. return t;
  1331. }),
  1332. (l.prototype.powmod = function(e, t) {
  1333. for (var i = new l([1]), s = this.mod(t); e; )
  1334. 1 & e && (i = i.mul(s).mod(t)), (e >>>= 1), (s = s.mul(s).mod(t));
  1335. return i;
  1336. }),
  1337. (l.prototype.trim = function() {
  1338. for (var e = this.digits.length; 0 < e && 0 == this.digits[e - 1]; )
  1339. --e;
  1340. e != this.digits.length && (this.digits = this.digits.subarray(0, e));
  1341. }),
  1342. (p.prototype.setBackground3x1 = function(e, t, i, s, n, r, a) {
  1343. (this.backgroundOffsetX = t),
  1344. (this.backgroundOffsetY = i),
  1345. (this.edgePixelsX = a),
  1346. (this.backgroundLeft = e.addImage(s)),
  1347. (this.backgroundMiddle = e.addImage(n)),
  1348. (this.backgroundRight = e.addImage(r)),
  1349. (this.backgroundLeft.linkedControl.style.zIndex = "0"),
  1350. (this.backgroundMiddle.linkedControl.style.zIndex = "0"),
  1351. (this.backgroundRight.linkedControl.style.zIndex = "0"),
  1352. this.setOpacity(this.defaultAlpha);
  1353. }),
  1354. (p.prototype.setBackground3x3 = function(
  1355. e,
  1356. t,
  1357. i,
  1358. s,
  1359. n,
  1360. r,
  1361. a,
  1362. o,
  1363. h,
  1364. l,
  1365. d,
  1366. c,
  1367. u,
  1368. f
  1369. ) {
  1370. (this.backgroundOffsetX = t),
  1371. (this.backgroundOffsetY = i),
  1372. (this.edgePixelsX = u),
  1373. (this.edgePixelsY = f),
  1374. (this.backgroundTopLeft = e.addImage(s)),
  1375. (this.backgroundMiddleLeft = e.addImage(a)),
  1376. (this.backgroundBottomLeft = e.addImage(l)),
  1377. (this.backgroundTopMiddle = e.addImage(n)),
  1378. (this.backgroundMiddleMiddle = e.addImage(o)),
  1379. (this.backgroundBottomMiddle = e.addImage(d)),
  1380. (this.backgroundTopRight = e.addImage(r)),
  1381. (this.backgroundMiddleRight = e.addImage(h)),
  1382. (this.backgroundBottomRight = e.addImage(c)),
  1383. (this.backgroundTopLeft.linkedControl.style.zIndex = "0"),
  1384. (this.backgroundTopRight.linkedControl.style.zIndex = "0"),
  1385. (this.backgroundTopMiddle.linkedControl.style.zIndex = "0"),
  1386. (this.backgroundMiddleLeft.linkedControl.style.zIndex = "0"),
  1387. (this.backgroundMiddleRight.linkedControl.style.zIndex = "0"),
  1388. (this.backgroundMiddleMiddle.linkedControl.style.zIndex = "0"),
  1389. (this.backgroundBottomLeft.linkedControl.style.zIndex = "0"),
  1390. (this.backgroundBottomRight.linkedControl.style.zIndex = "0"),
  1391. (this.backgroundBottomMiddle.linkedControl.style.zIndex = "0"),
  1392. this.setOpacity(this.defaultAlpha);
  1393. }),
  1394. (p.prototype.alignBackground = function() {
  1395. var e =
  1396. (n = (s = this.controlRect).guiScreen).left *
  1397. (1 - s.getScreenXPercent()),
  1398. t = n.bottom * (1 - s.getScreenYPercent()),
  1399. i = n.width * s.getScreenWidthPercent(),
  1400. s = n.height * s.getScreenHeightPercent();
  1401. (t += this.backgroundOffsetY), (e += this.backgroundOffsetX);
  1402. if (
  1403. this.backgroundTopLeft &&
  1404. this.backgroundTopRight &&
  1405. this.backgroundTopMiddle &&
  1406. this.backgroundMiddleLeft &&
  1407. this.backgroundMiddleRight &&
  1408. this.backgroundMiddleMiddle &&
  1409. this.backgroundBottomLeft &&
  1410. this.backgroundBottomRight &&
  1411. this.backgroundBottomMiddle
  1412. ) {
  1413. var n = i - 2 * this.edgePixelsX,
  1414. r = s - 2 * this.edgePixelsY;
  1415. (this.backgroundTopLeft.linkedControl.style.height =
  1416. this.edgePixelsY + "px"),
  1417. (this.backgroundTopMiddle.linkedControl.style.height =
  1418. this.edgePixelsY + "px"),
  1419. (this.backgroundTopRight.linkedControl.style.height =
  1420. this.edgePixelsY + "px"),
  1421. (this.backgroundBottomLeft.linkedControl.style.height =
  1422. this.edgePixelsY + "px"),
  1423. (this.backgroundBottomMiddle.linkedControl.style.height =
  1424. this.edgePixelsY + "px"),
  1425. (this.backgroundBottomRight.linkedControl.style.height =
  1426. this.edgePixelsY + "px"),
  1427. (this.backgroundMiddleLeft.linkedControl.style.height = r + "px"),
  1428. (this.backgroundMiddleMiddle.linkedControl.style.height = r + "px"),
  1429. (this.backgroundMiddleRight.linkedControl.style.height = r + "px"),
  1430. (this.backgroundTopLeft.linkedControl.style.width =
  1431. this.edgePixelsX + "px"),
  1432. (this.backgroundBottomLeft.linkedControl.style.width =
  1433. this.edgePixelsX + "px"),
  1434. (this.backgroundMiddleLeft.linkedControl.style.width =
  1435. this.edgePixelsX + "px"),
  1436. (this.backgroundTopRight.linkedControl.style.width =
  1437. this.edgePixelsX + "px"),
  1438. (this.backgroundBottomRight.linkedControl.style.width =
  1439. this.edgePixelsX + "px"),
  1440. (this.backgroundMiddleRight.linkedControl.style.width =
  1441. this.edgePixelsX + "px"),
  1442. (this.backgroundTopMiddle.linkedControl.style.width = n + "px"),
  1443. (this.backgroundBottomMiddle.linkedControl.style.width = n + "px"),
  1444. (this.backgroundMiddleMiddle.linkedControl.style.width = n + "px"),
  1445. (this.backgroundTopLeft.linkedControl.style.left = e + "px"),
  1446. (this.backgroundBottomLeft.linkedControl.style.left = e + "px"),
  1447. (this.backgroundMiddleLeft.linkedControl.style.left = e + "px"),
  1448. (e += this.edgePixelsX),
  1449. (this.backgroundTopMiddle.linkedControl.style.left = e + "px"),
  1450. (this.backgroundBottomMiddle.linkedControl.style.left = e + "px"),
  1451. (this.backgroundMiddleMiddle.linkedControl.style.left = e + "px"),
  1452. (e += n),
  1453. (this.backgroundTopRight.linkedControl.style.left = e + "px"),
  1454. (this.backgroundBottomRight.linkedControl.style.left = e + "px"),
  1455. (this.backgroundMiddleRight.linkedControl.style.left = e + "px"),
  1456. (this.backgroundBottomLeft.linkedControl.style.bottom = t + "px"),
  1457. (this.backgroundBottomMiddle.linkedControl.style.bottom = t + "px"),
  1458. (this.backgroundBottomRight.linkedControl.style.bottom = t + "px"),
  1459. (t += this.edgePixelsY),
  1460. (this.backgroundMiddleLeft.linkedControl.style.bottom = t + "px"),
  1461. (this.backgroundMiddleRight.linkedControl.style.bottom = t + "px"),
  1462. (this.backgroundMiddleMiddle.linkedControl.style.bottom = t + "px"),
  1463. (t += r),
  1464. (this.backgroundTopLeft.linkedControl.style.bottom = t + "px"),
  1465. (this.backgroundTopMiddle.linkedControl.style.bottom = t + "px"),
  1466. (this.backgroundTopRight.linkedControl.style.bottom = t + "px");
  1467. }
  1468. this.backgroundLeft &&
  1469. this.backgroundRight &&
  1470. this.backgroundMiddle &&
  1471. ((i -= 2 * this.edgePixelsX),
  1472. (this.backgroundLeft.linkedControl.style.bottom = t + "px"),
  1473. (this.backgroundMiddle.linkedControl.style.bottom = t + "px"),
  1474. (this.backgroundRight.linkedControl.style.bottom = t + "px"),
  1475. (this.backgroundLeft.linkedControl.style.height = s + "px"),
  1476. (this.backgroundMiddle.linkedControl.style.height = s + "px"),
  1477. (this.backgroundRight.linkedControl.style.height = s + "px"),
  1478. (this.backgroundLeft.linkedControl.style.width =
  1479. this.edgePixelsX + "px"),
  1480. (this.backgroundMiddle.linkedControl.style.width = i + "px"),
  1481. (this.backgroundRight.linkedControl.style.width =
  1482. this.edgePixelsX + "px"),
  1483. (this.backgroundLeft.linkedControl.style.left = e + "px"),
  1484. (e += this.edgePixelsX),
  1485. (this.backgroundMiddle.linkedControl.style.left = e + "px"),
  1486. (this.backgroundRight.linkedControl.style.left = e + i + "px"));
  1487. }),
  1488. (p.prototype.setOpacity = function(e) {
  1489. (this.controlRect.linkedControl.style.opacity = e),
  1490. this.backgroundLeft &&
  1491. (this.backgroundLeft.linkedControl.style.opacity = e),
  1492. this.backgroundRight &&
  1493. (this.backgroundRight.linkedControl.style.opacity = e),
  1494. this.backgroundMiddle &&
  1495. (this.backgroundMiddle.linkedControl.style.opacity = e),
  1496. this.backgroundTopLeft &&
  1497. (this.backgroundTopLeft.linkedControl.style.opacity = e),
  1498. this.backgroundTopRight &&
  1499. (this.backgroundTopRight.linkedControl.style.opacity = e),
  1500. this.backgroundTopMiddle &&
  1501. (this.backgroundTopMiddle.linkedControl.style.opacity = e),
  1502. this.backgroundMiddleLeft &&
  1503. (this.backgroundMiddleLeft.linkedControl.style.opacity = e),
  1504. this.backgroundMiddleRight &&
  1505. (this.backgroundMiddleRight.linkedControl.style.opacity = e),
  1506. this.backgroundMiddleMiddle &&
  1507. (this.backgroundMiddleMiddle.linkedControl.style.opacity = e),
  1508. this.backgroundBottomLeft &&
  1509. (this.backgroundBottomLeft.linkedControl.style.opacity = e),
  1510. this.backgroundBottomRight &&
  1511. (this.backgroundBottomRight.linkedControl.style.opacity = e),
  1512. this.backgroundBottomMiddle &&
  1513. (this.backgroundBottomMiddle.linkedControl.style.opacity = e);
  1514. }),
  1515. (p.prototype.setBackgroundVisible = function(e) {
  1516. this.backgroundLeft && this.backgroundLeft.showControl(e),
  1517. this.backgroundRight && this.backgroundRight.showControl(e),
  1518. this.backgroundMiddle && this.backgroundMiddle.showControl(e),
  1519. this.backgroundTopLeft && this.backgroundTopLeft.showControl(e),
  1520. this.backgroundTopRight && this.backgroundTopRight.showControl(e),
  1521. this.backgroundTopMiddle && this.backgroundTopMiddle.showControl(e),
  1522. this.backgroundMiddleLeft && this.backgroundMiddleLeft.showControl(e),
  1523. this.backgroundMiddleRight &&
  1524. this.backgroundMiddleRight.showControl(e),
  1525. this.backgroundMiddleMiddle &&
  1526. this.backgroundMiddleMiddle.showControl(e),
  1527. this.backgroundBottomLeft && this.backgroundBottomLeft.showControl(e),
  1528. this.backgroundBottomRight &&
  1529. this.backgroundBottomRight.showControl(e),
  1530. this.backgroundBottomMiddle &&
  1531. this.backgroundBottomMiddle.showControl(e);
  1532. }),
  1533. (p.prototype.setVisible = function(e) {
  1534. this.controlRect.showControl(e), this.setBackgroundVisible(e);
  1535. }),
  1536. (p.prototype.linkControl = function(e) {
  1537. ((this.controlRect.linkedControl = e).onmouseover = function() {
  1538. this.updateAlphas &&
  1539. (this.setOpacity(this.focusAlpha),
  1540. (this.controlRect.mouseOver = !0),
  1541. this.linkedBackground &&
  1542. this.linkedBackground.setOpacity(this.focusAlpha));
  1543. }.bind(this)),
  1544. (e.onmouseout = function() {
  1545. this.updateAlphas &&
  1546. (this.setOpacity(this.defaultAlpha),
  1547. (this.controlRect.mouseOver = !1),
  1548. this.linkedBackground &&
  1549. this.linkedBackground.setOpacity(this.defaultAlpha));
  1550. }.bind(this));
  1551. }),
  1552. (u.prototype.empty = function() {
  1553. return this.bytes.length <= 0;
  1554. }),
  1555. (u.prototype.readCString = function() {
  1556. for (var e = this.bytes, t = e.length, i = 0; i < t; ++i)
  1557. if (0 == e[i])
  1558. return (
  1559. (e = String.fromCharCode.apply(null, this.bytes.subarray(0, i))),
  1560. (this.bytes = this.bytes.subarray(i + 1)),
  1561. e
  1562. );
  1563. return null;
  1564. }),
  1565. (u.prototype.asString = function() {
  1566. for (var e = "", t = 0; t < this.bytes.length; ++t)
  1567. e += String.fromCharCode(this.bytes[t]);
  1568. return e;
  1569. }),
  1570. (u.prototype.readBytes = function(e) {
  1571. var t = this.bytes.subarray(0, e);
  1572. return (this.bytes = this.bytes.subarray(e)), t;
  1573. }),
  1574. (u.prototype.readUint32 = function() {
  1575. var e = this.bytes,
  1576. t = e[0] | (e[1] << 8) | (e[2] << 16) | (e[3] << 24);
  1577. return (this.bytes = e.subarray(4)), t;
  1578. }),
  1579. (u.prototype.readUint8 = function() {
  1580. var e = this.bytes,
  1581. t = e[0];
  1582. return (this.bytes = e.subarray(1)), t;
  1583. }),
  1584. (u.prototype.readUint16 = function() {
  1585. var e = this.bytes,
  1586. t = e[0] | (e[1] << 8);
  1587. return (this.bytes = e.subarray(2)), t;
  1588. }),
  1589. (u.prototype.readFloat32 = function() {
  1590. var e = new Uint8Array(this.bytes);
  1591. e = new Float32Array(e.buffer);
  1592. return (this.bytes = this.bytes.subarray(4)), e[0];
  1593. }),
  1594. (u.prototype.seekUint32 = function(e) {
  1595. return (
  1596. (e = this.bytes.subarray(4 * e))[0] |
  1597. (e[1] << 8) |
  1598. (e[2] << 16) |
  1599. (e[3] << 24)
  1600. );
  1601. }),
  1602. (u.prototype.seekFloat32 = function(e) {
  1603. return (
  1604. (e = new Uint8Array(this.bytes.subarray(4 * e))),
  1605. new Float32Array(e.buffer)[0]
  1606. );
  1607. }),
  1608. (u.prototype.getMatrix = function(e) {
  1609. return new Float32Array(this.bytes.buffer, 64 * e, 16);
  1610. }),
  1611. (s.prototype.getScreenWidth = function() {
  1612. if (this.linkedControl)
  1613. return this.guiScreen.width * this.getScreenWidthPercent();
  1614. }),
  1615. (s.prototype.getScreenHeight = function() {
  1616. if (this.linkedControl)
  1617. return this.guiScreen.height * this.getScreenHeightPercent();
  1618. }),
  1619. (s.prototype.updateElement = function() {
  1620. var e = this.linkedControl;
  1621. if (e) {
  1622. var t = this.guiScreen.left * (1 - this.getScreenXPercent()),
  1623. i = this.guiScreen.bottom * (1 - this.getScreenYPercent()),
  1624. s = this.guiScreen.width * this.getScreenWidthPercent(),
  1625. n = this.guiScreen.height * this.getScreenHeightPercent();
  1626. (e.style.left = t + "px"),
  1627. (e.style.bottom = i + "px"),
  1628. (e.style.width = s + "px"),
  1629. (e.style.height = n + "px");
  1630. }
  1631. }),
  1632. (s.prototype.updateElement = function() {
  1633. var e = this.linkedControl;
  1634. if (e) {
  1635. var t = this.guiScreen.left * (1 - this.getScreenXPercent()),
  1636. i = this.guiScreen.bottom * (1 - this.getScreenYPercent()),
  1637. s = this.guiScreen.width * this.getScreenWidthPercent(),
  1638. n = this.guiScreen.height * this.getScreenHeightPercent();
  1639. (e.style.left = t + "px"),
  1640. (e.style.bottom = i + "px"),
  1641. (e.style.width = s + "px"),
  1642. (e.style.height = n + "px");
  1643. }
  1644. }),
  1645. (s.prototype.updateChildElements = function() {
  1646. this.updateElement();
  1647. for (var e = 0; e < this.childControlRects.length; e++)
  1648. this.childControlRects[e].updateChildElements();
  1649. }),
  1650. (s.prototype.set = function(e, t, i, s) {
  1651. (this.xPercent = e),
  1652. (this.yPercent = t),
  1653. (this.widthPercent = i),
  1654. (this.heightPercent = s);
  1655. }),
  1656. (s.prototype.linkControl = function(e) {
  1657. ((this.linkedControl = e).onmouseover = function() {
  1658. this.mouseOver = !0;
  1659. }.bind(this)),
  1660. (e.onmouseout = function() {
  1661. this.mouseOver = !1;
  1662. }.bind(this)),
  1663. (e.onmousedown = function() {
  1664. this.mouseDown = !0;
  1665. }.bind(this)),
  1666. (e.onmouseup = function() {
  1667. this.mouseDown = !1;
  1668. }.bind(this)),
  1669. (e.onclick = function() {
  1670. this.callBack && this.callBack(this), (this.clicked = !0);
  1671. }.bind(this));
  1672. }),
  1673. (s.prototype.showControl = function(e) {
  1674. (this.visible = e),
  1675. this.linkedControl &&
  1676. (this.linkedControl.style.display = e ? "block" : "none");
  1677. }),
  1678. (s.prototype.setOpacity = function(e) {
  1679. (this.opacity = e),
  1680. this.linkedControl && (this.linkedControl.style.opacity = e);
  1681. }),
  1682. (s.prototype.hasChildControlRect = function(e) {
  1683. for (var t = 0; t < this.childControlRects.length; t++)
  1684. if (this.childControlRects[t] == e) return !0;
  1685. return !1;
  1686. }),
  1687. (s.prototype.registerChildControlRect = function(e) {
  1688. this.hasChildControlRect(e) ||
  1689. (this.childControlRects.push(e), (e.parentControlRect = this));
  1690. }),
  1691. (s.prototype.getScreenWidthPercent = function() {
  1692. var e = this.widthPercent;
  1693. return (
  1694. this.parentControlRect &&
  1695. (e *= this.parentControlRect.getScreenWidthPercent()),
  1696. e
  1697. );
  1698. }),
  1699. (s.prototype.getScreenHeightPercent = function() {
  1700. var e = this.heightPercent;
  1701. return (
  1702. this.parentControlRect &&
  1703. (e *= this.parentControlRect.getScreenHeightPercent()),
  1704. e
  1705. );
  1706. }),
  1707. (s.prototype.getScreenXPercent = function() {
  1708. var e = this.xPercent;
  1709. return (
  1710. this.parentControlRect &&
  1711. ((e *= this.parentControlRect.getScreenWidthPercent()),
  1712. (e += this.parentControlRect.getScreenXPercent())),
  1713. e
  1714. );
  1715. }),
  1716. (s.prototype.getScreenYPercent = function() {
  1717. var e = this.yPercent;
  1718. return (
  1719. this.parentControlRect &&
  1720. ((e *= this.parentControlRect.getScreenHeightPercent()),
  1721. (e += this.parentControlRect.getScreenYPercent())),
  1722. e
  1723. );
  1724. });
  1725. function n(e, t, i, s) {
  1726. var n = !1,
  1727. r = e + (-1 == e.indexOf("?") ? "?" : "&") + "thumb=1",
  1728. a = function(e) {
  1729. return (
  1730. (e = new h(e).extract("thumbnail.jpg"))
  1731. ? N.parseFile(e, t, s)
  1732. : n
  1733. ? i && i()
  1734. : ((n = !0), C.fetchBinaryIncremental(r, a, i, 394240)),
  1735. 0
  1736. );
  1737. };
  1738. C.fetchBinaryIncremental(r, a, i, 65536);
  1739. }
  1740. function f(e, t) {
  1741. (this.desc = t),
  1742. (this.gl = e),
  1743. (this.iblShader = e.shaderCache.fromURLs(
  1744. "fogvert.glsl",
  1745. "fogfrag.glsl",
  1746. ["#define FOG_IBL"]
  1747. ));
  1748. var i = ["#define FOG_DIR"];
  1749. (this.dirShader = e.shaderCache.fromURLs(
  1750. "fogvert.glsl",
  1751. "fogfrag.glsl",
  1752. i
  1753. )),
  1754. i.push("#define FOG_SHADOWS"),
  1755. (this.dirShaderShadow = e.shaderCache.fromURLs(
  1756. "fogvert.glsl",
  1757. "fogfrag.glsl",
  1758. i
  1759. )),
  1760. (i = ["#define FOG_SPOT"]),
  1761. (this.spotShader = e.shaderCache.fromURLs(
  1762. "fogvert.glsl",
  1763. "fogfrag.glsl",
  1764. i
  1765. )),
  1766. i.push("#define FOG_SHADOWS"),
  1767. (this.spotShaderShadow = e.shaderCache.fromURLs(
  1768. "fogvert.glsl",
  1769. "fogfrag.glsl",
  1770. i
  1771. )),
  1772. (i = ["#define FOG_OMNI"]),
  1773. (this.omniShaderShadow = this.omniShader = e.shaderCache.fromURLs(
  1774. "fogvert.glsl",
  1775. "fogfrag.glsl",
  1776. i
  1777. )),
  1778. (this.fullscreenTriangle = e.createBuffer()),
  1779. e.bindBuffer(e.ARRAY_BUFFER, this.fullscreenTriangle),
  1780. (i = new Float32Array([0, 0, 2, 0, 0, 2])),
  1781. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  1782. e.bindBuffer(e.ARRAY_BUFFER, null);
  1783. }
  1784. function m(e, t) {
  1785. (this.gl = e),
  1786. (this.fbo = e.createFramebuffer()),
  1787. e.bindFramebuffer(e.FRAMEBUFFER, this.fbo),
  1788. t &&
  1789. ((this.width = t.width),
  1790. (this.height = t.height),
  1791. t.color0 &&
  1792. ((this.color0 = t.color0),
  1793. e.framebufferTexture2D(
  1794. e.FRAMEBUFFER,
  1795. e.COLOR_ATTACHMENT0,
  1796. e.TEXTURE_2D,
  1797. this.color0.id,
  1798. 0
  1799. ),
  1800. (this.width = t.color0.desc.width),
  1801. (this.height = t.color0.desc.height)),
  1802. t.depth
  1803. ? ((this.depth = t.depth),
  1804. e.framebufferTexture2D(
  1805. e.FRAMEBUFFER,
  1806. e.DEPTH_ATTACHMENT,
  1807. e.TEXTURE_2D,
  1808. this.depth.id,
  1809. 0
  1810. ))
  1811. : ((this.depthBuffer = t.depthBuffer),
  1812. t.createDepth &&
  1813. !this.depthBuffer &&
  1814. (this.depthBuffer = m.createDepthBuffer(
  1815. e,
  1816. this.width,
  1817. this.height
  1818. )),
  1819. this.depthBuffer &&
  1820. (e.bindRenderbuffer(e.RENDERBUFFER, this.depthBuffer),
  1821. e.framebufferRenderbuffer(
  1822. e.FRAMEBUFFER,
  1823. e.DEPTH_ATTACHMENT,
  1824. e.RENDERBUFFER,
  1825. this.depthBuffer
  1826. ),
  1827. e.bindRenderbuffer(e.RENDERBUFFER, null)))),
  1828. (this.valid =
  1829. (t && t.ignoreStatus) ||
  1830. e.checkFramebufferStatus(e.FRAMEBUFFER) == e.FRAMEBUFFER_COMPLETE),
  1831. e.bindFramebuffer(e.FRAMEBUFFER, null);
  1832. }
  1833. ((I = void 0 === I ? {} : I).embed = function(e, t) {
  1834. var i,
  1835. s = (t = (function(e) {
  1836. if (((e = e || {}), document.location.search))
  1837. for (
  1838. var t = document.location.search.substring(1).split("&"), i = 0;
  1839. i < t.length;
  1840. ++i
  1841. ) {
  1842. var s = t[i].split("=");
  1843. e[s[0]] = s[1];
  1844. }
  1845. return (
  1846. (t = function(e) {
  1847. if (0 | e) return !0;
  1848. for (
  1849. var t = "true True TRUE yes Yes YES".split(" "), i = 0;
  1850. i < t.length;
  1851. ++i
  1852. )
  1853. if (e === t[i]) return !0;
  1854. return !1;
  1855. }),
  1856. (e.width = e.width || 800),
  1857. (e.height = e.height || 600),
  1858. (e.autoStart = t(e.autoStart)),
  1859. (e.pagePreset = t(e.pagePreset)),
  1860. (e.fullFrame = t(e.fullFrame) || t(e.bare)),
  1861. (e.fullFrame = !e.pagePreset && e.fullFrame),
  1862. e
  1863. );
  1864. })(t)).thumbnailURL;
  1865. if (t.pagePreset) {
  1866. (i = new W(t.width, t.height, e, !!s)),
  1867. (document.body.style.backgroundColor = "#d7e4da");
  1868. var n = document.createElement("div");
  1869. (n.style.position = "relative"),
  1870. (n.style.backgroundColor = "#e4e7e4"),
  1871. (n.style.width = t.width + 12 + "px"),
  1872. (n.style.height = t.height + 6 + 16 + "px"),
  1873. (n.style.margin = "auto"),
  1874. (n.style.boxShadow = "3px 5px 12px 0px grey"),
  1875. document.body.appendChild(n);
  1876. var r = document.createElement("div");
  1877. if (
  1878. ((r.style.position = "relative"),
  1879. (r.style.left = "6px"),
  1880. (r.style.top = "6px"),
  1881. n.appendChild(r),
  1882. r.appendChild(i.domRoot),
  1883. !i.mobile)
  1884. ) {
  1885. (n.style.resize = "both"), (n.style.overflow = "hidden");
  1886. var a = [n.style.width, n.style.height],
  1887. o = function() {
  1888. g.active()
  1889. ? (n.style.resize = "none")
  1890. : ((n.style.resize = "both"),
  1891. (a[0] == n.style.width && a[1] == n.style.height) ||
  1892. ((a[0] = n.style.width),
  1893. (a[1] = n.style.height),
  1894. i.resize(n.clientWidth - 12, n.clientHeight - 6 - 16))),
  1895. window.setTimeout(o, 100);
  1896. };
  1897. o();
  1898. }
  1899. } else
  1900. (i = new W(
  1901. t.fullFrame ? window.innerWidth : t.width,
  1902. t.fullFrame ? window.innerHeight : t.height,
  1903. e,
  1904. !!s
  1905. )),
  1906. document.body.appendChild(i.domRoot),
  1907. t.fullFrame &&
  1908. ((i.domRoot.style.position = "absolute"),
  1909. (i.domRoot.style.left = i.domRoot.style.top = 0),
  1910. window.addEventListener("resize", function() {
  1911. g.active() ||
  1912. i.resize(
  1913. this.document.body.clientWidth,
  1914. this.document.body.clientHeight
  1915. );
  1916. }));
  1917. return (
  1918. (webview = i).ui.setThumbnailURL(s), t.autoStart && i.loadScene(), i
  1919. );
  1920. }),
  1921. (I.fetchThumbnail = n),
  1922. (f.prototype.draw = function(e, t) {
  1923. var i = this.gl,
  1924. s = e.view,
  1925. n = s.projectionMatrix,
  1926. r = S.empty();
  1927. S.mul(r, s.viewMatrix, s.projectionMatrix),
  1928. S.invert(r, s.viewProjectionMatrix),
  1929. (r = [n[10] + n[11], -n[14], -2 * n[11]]),
  1930. (n = [-2 / n[0], -2 / n[5], (1 - n[8]) / n[0], (1 - n[9]) / n[5]]),
  1931. i.enable(i.BLEND),
  1932. i.blendFunc(i.ONE, i.ONE_MINUS_SRC_ALPHA);
  1933. for (var a = 0; a < e.lights.count + 1; ++a) {
  1934. var o,
  1935. h = a - 1,
  1936. l = h < e.lights.shadowCount;
  1937. (o =
  1938. 0 == a
  1939. ? this.iblShader
  1940. : 0 < e.lights.spot[3 * h]
  1941. ? l
  1942. ? this.spotShaderShadow
  1943. : this.spotShader
  1944. : 0 < e.lights.getLightPos(h)[3]
  1945. ? this.omniShader
  1946. : l
  1947. ? this.dirShaderShadow
  1948. : this.dirShader).bind();
  1949. var d = o.params;
  1950. if (
  1951. (i.uniform3fv(d.uDepthToZ, r),
  1952. i.uniform4fv(d.uUnproject, n),
  1953. i.uniformMatrix4fv(d.uInvViewMatrix, !1, s.transform),
  1954. i.uniform1f(d.uFogInvDistance, 1 / this.desc.distance),
  1955. i.uniform1f(
  1956. d.uFogOpacity,
  1957. this.desc.opacity * (1 - e.stripData.activeFade())
  1958. ),
  1959. i.uniform1f(d.uFogDispersion, 1 - this.desc.dispersion),
  1960. ((u = [0, 0, 0])[this.desc.type] = 1),
  1961. i.uniform3fv(d.uFogType, u),
  1962. i.uniform3fv(d.uFogColor, this.desc.color),
  1963. i.uniform1f(
  1964. d.uFogIllum,
  1965. 0 == a ? this.desc.skyIllum : this.desc.lightIllum
  1966. ),
  1967. i.uniformMatrix4fv(d.uLightMatrix, !1, e.lights.invMatrix),
  1968. 0 == a)
  1969. ) {
  1970. for (
  1971. h = new Float32Array(e.sky.diffuseCoefficients), l = 4;
  1972. l < 16;
  1973. ++l
  1974. )
  1975. h[l] *= 1 - this.desc.dispersion;
  1976. for (l = 16; l < 36; ++l)
  1977. h[l] *= 1 - this.desc.dispersion * this.desc.dispersion;
  1978. i.uniform4fv(d.uFogLightSphere, h);
  1979. } else {
  1980. var c = e.lights.getLightPos(h),
  1981. u =
  1982. ((c = S.mul4(
  1983. V.empty(),
  1984. e.lights.invMatrix,
  1985. c[0],
  1986. c[1],
  1987. c[2],
  1988. c[3]
  1989. )),
  1990. e.lights.getLightDir(h));
  1991. u = S.mulVec(V.empty(), e.lights.invMatrix, u[0], u[1], u[2]);
  1992. i.uniform4fv(d.uLightPosition, c),
  1993. i.uniform3fv(d.uLightColor, e.lights.getColor(h));
  1994. c = 0.01745329251 * e.lights.spot[3 * h];
  1995. var f = Math.cos(0.5 * c);
  1996. i.uniform4fv(d.uSpotParams, [
  1997. -u[0],
  1998. -u[1],
  1999. -u[2],
  2000. 0 < c ? f * f : 0,
  2001. ]),
  2002. i.uniform4fv(d.uLightAttenuation, [
  2003. e.lights.parameters[3 * h + 0],
  2004. e.lights.parameters[3 * h + 1],
  2005. e.lights.parameters[3 * h + 2],
  2006. f,
  2007. ]),
  2008. l &&
  2009. ((l = S.mul(
  2010. S.empty(),
  2011. e.lights.finalTransformBuffer.subarray(16 * h),
  2012. e.lights.matrix
  2013. )),
  2014. i.uniformMatrix4fv(d.uShadowProj, !1, l),
  2015. e.shadow.depthTextures[h].bind(o.samplers.uShadowMap),
  2016. (h = 0),
  2017. 1 < e.postRender.sampleCount &&
  2018. (h = e.postRender.currentSample() / e.postRender.sampleCount),
  2019. i.uniform1f(d.uDitherOffset, h),
  2020. i.uniform3fv(d.uAABBMin, e.bounds.min),
  2021. i.uniform3fv(d.uAABBMax, e.bounds.max),
  2022. (h = V.lerp(V.empty(), e.bounds.min, e.bounds.max, 0.5)),
  2023. (l = V.distance(h, e.bounds.min)),
  2024. i.uniform4f(d.uCylinder, h[0], h[1], h[2], l * l));
  2025. }
  2026. t.bind(o.samplers.tDepth),
  2027. (o = o.attribs.vCoord),
  2028. i.bindBuffer(i.ARRAY_BUFFER, this.fullscreenTriangle),
  2029. i.enableVertexAttribArray(o),
  2030. i.vertexAttribPointer(o, 2, i.FLOAT, !1, 0, 0),
  2031. i.drawArrays(i.TRIANGLES, 0, 3),
  2032. i.disableVertexAttribArray(o),
  2033. i.bindBuffer(i.ARRAY_BUFFER, null);
  2034. }
  2035. i.disable(i.BLEND);
  2036. }),
  2037. (f.prototype.complete = function() {
  2038. return (
  2039. this.iblShader.complete() &&
  2040. this.dirShader.complete() &&
  2041. this.dirShaderShadow.complete() &&
  2042. this.spotShader.complete() &&
  2043. this.spotShaderShadow.complete() &&
  2044. this.omniShader.complete() &&
  2045. this.omniShaderShadow.complete()
  2046. );
  2047. }),
  2048. (m.createDepthBuffer = function(e, t, i) {
  2049. var s = e.createRenderbuffer();
  2050. return (
  2051. e.bindRenderbuffer(e.RENDERBUFFER, s),
  2052. e.renderbufferStorage(e.RENDERBUFFER, e.DEPTH_COMPONENT16, t, i),
  2053. e.bindRenderbuffer(e.RENDERBUFFER, null),
  2054. s
  2055. );
  2056. }),
  2057. (m.prototype.bind = function() {
  2058. this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.fbo),
  2059. this.gl.viewport(0, 0, this.width, this.height);
  2060. }),
  2061. (m.bindNone = function(e) {
  2062. e.bindFramebuffer(e.FRAMEBUFFER, null);
  2063. });
  2064. var g = {
  2065. support: function() {
  2066. return !!(
  2067. document.fullscreenEnabled ||
  2068. document.webkitFullscreenEnabled ||
  2069. document.mozFullScreenEnabled ||
  2070. document.msFullscreenEnabled
  2071. );
  2072. },
  2073. begin: function(e, t) {
  2074. var i =
  2075. e.requestFullscreen ||
  2076. e.webkitRequestFullScreen ||
  2077. e.mozRequestFullScreen ||
  2078. e.msRequestFullscreen;
  2079. if (i) {
  2080. var s = function() {
  2081. g.active() ||
  2082. (document.removeEventListener("fullscreenchange", s),
  2083. document.removeEventListener("webkitfullscreenchange", s),
  2084. document.removeEventListener("mozfullscreenchange", s),
  2085. document.removeEventListener("MSFullscreenChange", s)),
  2086. t && t();
  2087. };
  2088. document.addEventListener("fullscreenchange", s),
  2089. document.addEventListener("webkitfullscreenchange", s),
  2090. document.addEventListener("mozfullscreenchange", s),
  2091. document.addEventListener("MSFullscreenChange", s),
  2092. i.bind(e)();
  2093. }
  2094. },
  2095. end: function() {
  2096. var e =
  2097. document.exitFullscreen ||
  2098. document.webkitExitFullscreen ||
  2099. document.mozCancelFullScreen ||
  2100. document.msExitFullscreen;
  2101. e && e.bind(document)();
  2102. },
  2103. active: function() {
  2104. return !!(
  2105. document.fullscreenElement ||
  2106. document.webkitIsFullScreen ||
  2107. document.mozFullScreenElement ||
  2108. document.msFullscreenElement
  2109. );
  2110. },
  2111. };
  2112. function v(e) {
  2113. (this.debugString = "GUIRegion"),
  2114. (this.name = "Default"),
  2115. (this.controlRect = new s(e)),
  2116. (this.yPercent = this.xPercent = 0),
  2117. (this.heightPercent = this.widthPercent = 1),
  2118. (this.guiScreen = e);
  2119. }
  2120. function t(e) {
  2121. (this.init = !1),
  2122. (this.ui = e),
  2123. (this.bottom = this.left = this.height = this.width = 0),
  2124. (this.clicked = this.mouseDown = !1),
  2125. (this.playbackControls = 0),
  2126. (e = 1),
  2127. window.devicePixelRatio &&
  2128. (2 < window.devicePixelRatio
  2129. ? (e = 4)
  2130. : 1 < window.devicePixelRatio && (e = 2)),
  2131. (this.imageSetNumber = e);
  2132. }
  2133. function e(e) {
  2134. (this.onTap = []),
  2135. (this.onSingleTap = []),
  2136. (this.onDoubleTap = []),
  2137. (this.onDrag = []),
  2138. (this.onZoom = []),
  2139. (this.onPan = []),
  2140. (this.onPan2 = []),
  2141. (this.onAnything = []),
  2142. (this.mouseDownCount = 0),
  2143. (this.macHax = 0 <= navigator.platform.toUpperCase().indexOf("MAC")),
  2144. e && this.attach(e);
  2145. }
  2146. function i(e, t) {
  2147. e && t
  2148. ? ((this.frameIndex = t.frameIndex),
  2149. (this.value = t.value),
  2150. (this.interpolation = t.interpolation),
  2151. (this.weighIn = t.weighIn),
  2152. (this.weighOut = t.weighOut))
  2153. : ((this.interpolation = this.value = this.frameIndex = 0),
  2154. (this.weighOut = this.weighIn = 1));
  2155. }
  2156. function x(e, t) {
  2157. for (var i in ((this.rotation = this.shadowCount = this.count = 0),
  2158. (this.positions = []),
  2159. (this.directions = []),
  2160. (this.matrixWeights = []),
  2161. (this.matrix = S.identity()),
  2162. (this.invMatrix = S.identity()),
  2163. (this.defaultmatrix = S.identity()),
  2164. (this.defaultviewmatrix = S.identity()),
  2165. e))
  2166. this[i] = e[i];
  2167. (this.count = this.positions.length / 4),
  2168. (this.count = Math.min(6, this.count)),
  2169. (this.shadowCount = Math.min(3, this.shadowCount)),
  2170. (this.positions = new Float32Array(this.positions)),
  2171. (this.positionBuffer = new Float32Array(this.positions)),
  2172. (this.directions = new Float32Array(this.directions)),
  2173. (this.directionBuffer = new Float32Array(this.directions)),
  2174. (this.colors = new Float32Array(this.colors)),
  2175. (this.colorsBuffer = new Float32Array(this.colors)),
  2176. (this.modelViewBuffer = new Float32Array(16 * this.shadowCount)),
  2177. (this.projectionBuffer = new Float32Array(16 * this.shadowCount)),
  2178. (this.finalTransformBuffer = new Float32Array(16 * this.shadowCount)),
  2179. (this.inverseTransformBuffer = new Float32Array(16 * this.shadowCount)),
  2180. (this.shadowTexelPadProjections = new Float32Array(
  2181. 4 * this.shadowCount
  2182. )),
  2183. (this.shadowsNeedUpdate = new Uint8Array(this.shadowCount));
  2184. for (var s = 0; s < this.shadowsNeedUpdate.length; ++s)
  2185. this.shadowsNeedUpdate[s] = 1;
  2186. for (
  2187. S.rotation(this.matrix, this.rotation, 1),
  2188. S.transpose(this.invMatrix, this.matrix),
  2189. S.copy(this.defaultmatrix, this.matrix),
  2190. S.copy(this.defaultviewmatrix, t.viewMatrix),
  2191. s = 0;
  2192. s < this.count;
  2193. ++s
  2194. ) {
  2195. i = this.positions.subarray(4 * s, 4 * s + 4);
  2196. var n = this.directions.subarray(3 * s, 3 * s + 3);
  2197. 1 == this.matrixWeights[s]
  2198. ? (S.mul4(i, this.matrix, i[0], i[1], i[2], i[3]),
  2199. S.mulVec(n, this.matrix, n[0], n[1], n[2]))
  2200. : 2 == this.matrixWeights[s] &&
  2201. (S.mul4(i, t.viewMatrix, i[0], i[1], i[2], i[3]),
  2202. S.mulVec(n, t.viewMatrix, n[0], n[1], n[2]));
  2203. }
  2204. }
  2205. function y(e) {
  2206. (this.name = "none"),
  2207. (this.text = "default text"),
  2208. (this.title = "none"),
  2209. (this.debugString = this.imagePath = ""),
  2210. (this.controlRect = new s(e)),
  2211. (this.textEntries = []),
  2212. (this.textOffsetsX = []),
  2213. (this.textOffsetsY = []),
  2214. (this.buttons = []),
  2215. (this.listBoxEntryHeight = 20),
  2216. (this.selectedItemText = ""),
  2217. (this.selectedIndex = -1),
  2218. (this.localPixelsY = 0),
  2219. (this.localPixelsX = 100),
  2220. (this.labelPixelDrop = 0),
  2221. (this.labelPixelInset = 10),
  2222. (this.labelTextHeight = 16),
  2223. (this.closed = !1),
  2224. (this.defaultButtonText = this.spacerMiddle = this.spacerRight = this.spacerLeft = this.spacerControl = 0),
  2225. (this.listBoxButtons = []),
  2226. (this.listBoxRegion = new v(e)),
  2227. (this.guiScreen = e),
  2228. (this.lastMouseOverIndex = -1),
  2229. (this.selectionChangedCallback = 0),
  2230. (this.debugString = "");
  2231. }
  2232. function b(e, t, i) {
  2233. (this.gl = e), (this.name = i.name);
  2234. var s = {
  2235. mipmap: !0,
  2236. aniso: e.hints.mobile ? 0 : 4,
  2237. clamp: !!i.textureWrapClamp,
  2238. mirror: !!i.textureWrapMirror,
  2239. },
  2240. n = {
  2241. mipmap: s.mipmap,
  2242. clamp: s.clamp,
  2243. mirror: s.mirror,
  2244. nofilter: i.textureFilterNearest || !1,
  2245. };
  2246. if (
  2247. (n.nofilter || (n.aniso = e.hints.mobile ? 2 : 4),
  2248. (this.textures = {
  2249. albedo: e.textureCache.fromFilesMergeAlpha(
  2250. t.get(i.albedoTex),
  2251. t.get(i.alphaTex),
  2252. n
  2253. ),
  2254. reflectivity: e.textureCache.fromFilesMergeAlpha(
  2255. t.get(i.reflectivityTex),
  2256. t.get(i.glossTex),
  2257. s
  2258. ),
  2259. normal: e.textureCache.fromFile(t.get(i.normalTex), s),
  2260. extras: e.textureCache.fromFilesMergeAlpha(
  2261. t.get(i.extrasTex),
  2262. t.get(i.extrasTexA),
  2263. s
  2264. ),
  2265. }),
  2266. (this.extrasTexCoordRanges = {}),
  2267. i.extrasTexCoordRanges)
  2268. )
  2269. for (var r in i.extrasTexCoordRanges)
  2270. this.extrasTexCoordRanges[r] = new Float32Array(
  2271. i.extrasTexCoordRanges[r].scaleBias
  2272. );
  2273. this.textures.extras ||
  2274. ((t = new U(e, { width: 1, height: 1 })).loadArray(
  2275. new Uint8Array([255, 255, 255, 255])
  2276. ),
  2277. (this.textures.extras = t));
  2278. var a = i.blendTint || [1, 1, 1];
  2279. (t = {
  2280. none: function() {
  2281. e.disable(e.BLEND);
  2282. },
  2283. alpha: function() {
  2284. e.enable(e.BLEND),
  2285. e.blendFuncSeparate(
  2286. e.SRC_ALPHA,
  2287. e.ONE_MINUS_SRC_ALPHA,
  2288. e.ONE_MINUS_DST_ALPHA,
  2289. e.ONE
  2290. );
  2291. },
  2292. add: function() {
  2293. e.enable(e.BLEND),
  2294. e.blendColor(a[0], a[1], a[2], 1),
  2295. e.blendFunc(e.ONE, e.CONSTANT_COLOR);
  2296. },
  2297. }),
  2298. (this.blend = t[i.blend] || t.none),
  2299. (this.alphaTest = i.alphaTest || 0),
  2300. (this.usesBlending = this.blend !== t.none),
  2301. (this.usesRefraction = !!i.refraction),
  2302. (this.shadowAlphaTest = this.alphaTest),
  2303. this.shadowAlphaTest <= 0 &&
  2304. this.blend === t.alpha &&
  2305. (this.shadowAlphaTest = 0.5),
  2306. (this.castShadows = this.blend !== t.add),
  2307. (this.horizonOcclude = i.horizonOcclude || 0),
  2308. (this.fresnel = new Float32Array(i.fresnel ? i.fresnel : [1, 1, 1])),
  2309. (this.emissiveIntensity = i.emissiveIntensity || 1),
  2310. (n = !(s = [])),
  2311. 0 < i.lightCount && s.push("#define LIGHT_COUNT " + i.lightCount),
  2312. 0 < i.shadowCount &&
  2313. ((r = Math.min(i.lightCount, i.shadowCount)),
  2314. this.usesRefraction &&
  2315. e.limits.textureCount <= 8 &&
  2316. (r = 2 < r ? 2 : r),
  2317. s.push("#define SHADOW_COUNT " + r)),
  2318. 0 < i.alphaTest && s.push("#define ALPHA_TEST"),
  2319. this.blend === t.alpha
  2320. ? s.push("#define TRANSPARENCY_DITHER")
  2321. : this.blend === t.none && s.push("#define NOBLEND"),
  2322. e.hints.mobile && s.push("#define MOBILE"),
  2323. e.ext.textureDepth && s.push("#define SHADOW_NATIVE_DEPTH"),
  2324. (r = function(e) {
  2325. return 1 / ((2 / 3) * 3.1415962 * (e * e + e + 1));
  2326. }),
  2327. i.useSkin &&
  2328. (s.push("#define SKIN"),
  2329. (this.skinParams = i.skinParams || {
  2330. subdermisColor: [1, 1, 1],
  2331. transColor: [1, 0, 0, 1],
  2332. fresnelColor: [0.2, 0.2, 0.2, 0.5],
  2333. fresnelOcc: 1,
  2334. fresnelGlossMask: 1,
  2335. transSky: 0.5,
  2336. shadowBlur: 0.5,
  2337. normalSmooth: 0.5,
  2338. transScatter: 0,
  2339. transDepth: 0,
  2340. millimeterScale: 1,
  2341. }),
  2342. this.extrasTexCoordRanges.subdermisTex ||
  2343. s.push("#define SKIN_NO_SUBDERMIS_TEX"),
  2344. this.extrasTexCoordRanges.translucencyTex ||
  2345. s.push("#define SKIN_NO_TRANSLUCENCY_TEX"),
  2346. this.extrasTexCoordRanges.fuzzTex ||
  2347. s.push("#define SKIN_NO_FUZZ_TEX"),
  2348. void 0 === this.skinParams.version && (this.skinParams.version = 1),
  2349. 2 == this.skinParams.version
  2350. ? (s.push("#define SKIN_VERSION_2"),
  2351. (this.skinParams.shadowBlur *= 4),
  2352. (this.skinParams.shadowBlur = Math.min(
  2353. this.skinParams.shadowBlur,
  2354. 40
  2355. )),
  2356. (this.skinParams.transIntegral = r(
  2357. 0.5 * this.skinParams.transScatter
  2358. )),
  2359. (this.skinParams.fresnelIntegral =
  2360. (1 / 3.14159) * (1 - 0.5 * this.skinParams.fresnelColor[3])),
  2361. (this.skinParams.transSky = 0))
  2362. : (s.push("#define SKIN_VERSION_1"),
  2363. (this.skinParams.shadowBlur =
  2364. 8 * Math.min(this.skinParams.shadowBlur, 1)),
  2365. (this.skinParams.transDepth = 0),
  2366. (this.skinParams.transScatter = this.skinParams.transColor[3]),
  2367. (this.skinParams.transIntegral =
  2368. (1 / 3.14159) * (1 - 0.5 * this.skinParams.transScatter)),
  2369. (this.skinParams.fresnelIntegral =
  2370. (1 / 3.14159) * (1 - 0.5 * this.skinParams.fresnelColor[3])),
  2371. (this.skinParams.transSky *= 1.25),
  2372. (this.skinParams.transIntegral *= 1.25))),
  2373. i.aniso &&
  2374. (s.push("#define ANISO"),
  2375. (this.anisoParams = i.anisoParams || {
  2376. strength: 1,
  2377. tangent: [1, 0, 0],
  2378. integral: 0.5,
  2379. }),
  2380. this.extrasTexCoordRanges.anisoTex ||
  2381. s.push("#define ANISO_NO_DIR_TEX")),
  2382. i.microfiber &&
  2383. (s.push("#define MICROFIBER"),
  2384. (this.microfiberParams = i.microfiberParams || {
  2385. fresnelColor: [0.2, 0.2, 0.2, 0.5],
  2386. fresnelOcc: 1,
  2387. fresnelGlossMask: 1,
  2388. }),
  2389. (this.microfiberParams.fresnelIntegral =
  2390. (1 / 3.14159) * (1 - 0.5 * this.microfiberParams.fresnelColor[3])),
  2391. this.extrasTexCoordRanges.fuzzTex ||
  2392. s.push("#define MICROFIBER_NO_FUZZ_TEX")),
  2393. i.refraction &&
  2394. (s.push("#define REFRACTION"),
  2395. (this.refractionParams = i.refractionParams || {
  2396. distantBackground: !1,
  2397. tint: [1, 1, 1],
  2398. useAlbedoTint: !1,
  2399. IOR: 1.5,
  2400. }),
  2401. this.extrasTexCoordRanges.refractionMaskTex ||
  2402. s.push("#define REFRACTION_NO_MASK_TEX")),
  2403. i.vertexColor &&
  2404. (s.push("#define VERTEX_COLOR"),
  2405. i.vertexColorsRGB && s.push("#define VERTEX_COLOR_SRGB"),
  2406. i.vertexColorAlpha && s.push("#define VERTEX_COLOR_ALPHA")),
  2407. (this.horizonSmoothing = i.horizonSmoothing || 0),
  2408. 0 < this.horizonSmoothing && s.push("#define HORIZON_SMOOTHING"),
  2409. i.unlitDiffuse && s.push("#define DIFFUSE_UNLIT"),
  2410. this.extrasTexCoordRanges.emissiveTex &&
  2411. (s.push("#define EMISSIVE"),
  2412. i.emissiveSecondaryUV &&
  2413. (s.push("#define EMISSIVE_SECONDARY_UV"), (n = !0))),
  2414. this.extrasTexCoordRanges.aoTex &&
  2415. (s.push("#define AMBIENT_OCCLUSION"),
  2416. i.aoSecondaryUV &&
  2417. (s.push("#define AMBIENT_OCCLUSION_SECONDARY_UV"), (n = !0))),
  2418. i.tangentOrthogonalize && s.push("#define TSPACE_ORTHOGONALIZE"),
  2419. i.tangentNormalize && s.push("#define TSPACE_RENORMALIZE"),
  2420. i.tangentGenerateBitangent &&
  2421. s.push("#define TSPACE_COMPUTE_BITANGENT"),
  2422. n && s.push("#define TEXCOORD_SECONDARY"),
  2423. (this.vOffset = this.uOffset = 0),
  2424. s.push("#define UV_OFFSET "),
  2425. (this.shader = e.shaderCache.fromURLs(
  2426. "matvert.glsl",
  2427. "matfrag.glsl",
  2428. s
  2429. )),
  2430. s.push("#define STRIPVIEW"),
  2431. (this.stripShader = e.shaderCache.fromURLs(
  2432. "matvert.glsl",
  2433. "matfrag.glsl",
  2434. s
  2435. )),
  2436. (this.wireShader = e.shaderCache.fromURLs(
  2437. "wirevert.glsl",
  2438. "wirefrag.glsl"
  2439. )),
  2440. this.blend === t.alpha &&
  2441. (this.prepassShader = e.shaderCache.fromURLs(
  2442. "alphaprepassvert.glsl",
  2443. "alphaprepassfrag.glsl"
  2444. ));
  2445. }
  2446. (v.prototype.addImageElement = function(e, t) {
  2447. var i = this.guiScreen.ui.menuCluster.contents,
  2448. s = document.createElement("input");
  2449. e.linkControl(s),
  2450. this.guiScreen.updateElement(e),
  2451. (s.type = "image"),
  2452. (s.src = I.dataLocale + t),
  2453. (s.style.position = "absolute"),
  2454. (s.style.border = "none"),
  2455. (s.style.outline = "0px"),
  2456. (s.style.zIndex = "1"),
  2457. (s.title = t),
  2458. (s.style.opacity = e.opacity);
  2459. var n = new XMLHttpRequest();
  2460. return (
  2461. n.open("HEAD", s.src, !0),
  2462. (n.onload = function(e) {
  2463. e.appendChild(this);
  2464. }.bind(s, i)),
  2465. n.send(),
  2466. s
  2467. );
  2468. }),
  2469. (v.prototype.addImage = function(e) {
  2470. var t = new s(this.guiScreen);
  2471. return this.addImageElement(t, e), t;
  2472. }),
  2473. (v.prototype.addTextButton = function(e, t, i, s, n, r) {
  2474. var a = new p(this.guiScreen);
  2475. return (
  2476. (a.name = "none"),
  2477. (a.text = e),
  2478. a.controlRect.set(t, i, s, n),
  2479. (a.controlRect.opacity = r),
  2480. this.controlRect.registerChildControlRect(a.controlRect),
  2481. (t = this.guiScreen.ui.menuCluster.contents),
  2482. ((i = document.createElement("text")).style.color = "white"),
  2483. (i.style.fontFamily = "Arial"),
  2484. (i.style.fontSize = I.largeUI ? "14px" : "12px"),
  2485. (i.style.textShadow = "2px 2px 3px #000000"),
  2486. t.appendChild(i),
  2487. a.controlRect.linkControl(i),
  2488. this.guiScreen.updateElement(a.controlRect),
  2489. (i.type = "text"),
  2490. (i.name = "text"),
  2491. (i.style.position = "absolute"),
  2492. (i.style.border = "none"),
  2493. (i.style.outline = "0px"),
  2494. (i.style.zIndex = "2"),
  2495. (i.innerHTML = e),
  2496. (i.style.opacity = a.controlRect.opacity),
  2497. a.linkControl(i),
  2498. a
  2499. );
  2500. }),
  2501. (t.prototype.setSize = function(e, t) {
  2502. (this.width = e),
  2503. (this.height = t),
  2504. (this.left = -e),
  2505. (this.bottom = -t),
  2506. this.playbackControls && this.playbackControls.resize(this);
  2507. }),
  2508. (t.prototype.setupActiveView = function(e) {
  2509. this.init ||
  2510. ((this.init = !0),
  2511. (this.ui = e).viewer.scene.sceneAnimator &&
  2512. ((this.playbackControls = new R(this)),
  2513. this.playbackControls.resize(this)));
  2514. }),
  2515. (t.prototype.updateElement = function(e) {
  2516. var t = e.linkedControl;
  2517. if (t) {
  2518. var i = this.left * (1 - e.getScreenXPercent()),
  2519. s = this.bottom * (1 - e.getScreenYPercent()),
  2520. n = this.width * e.getScreenWidthPercent();
  2521. (e = this.height * e.getScreenHeightPercent()),
  2522. (t.style.left = i + "px"),
  2523. (t.style.bottom = s + "px"),
  2524. (t.style.width = n + "px"),
  2525. (t.style.height = e + "px");
  2526. }
  2527. }),
  2528. (e.prototype.attach = function(e) {
  2529. this.element = e;
  2530. var m = function(e) {
  2531. for (var t = 0; t < this.onAnything.length; ++t) this.onAnything[t]();
  2532. e.preventDefault();
  2533. }.bind(this);
  2534. (this.mouseStates = [
  2535. { pressed: !1, position: [0, 0], downPosition: [0, 0] },
  2536. { pressed: !1, position: [0, 0], downPosition: [0, 0] },
  2537. { pressed: !1, position: [0, 0], downPosition: [0, 0] },
  2538. ]),
  2539. (this.lastTapPos = [0, 0]),
  2540. (e = function(e) {
  2541. if (e.target === this.element) {
  2542. this.mouseDownCount++;
  2543. var t = this.mouseStates[e.button];
  2544. if (t) {
  2545. t.pressed = !0;
  2546. var i = this.element.getBoundingClientRect();
  2547. (t.position[0] = t.downPosition[0] = e.clientX - i.left),
  2548. (t.position[1] = t.downPosition[1] = e.clientY - i.top),
  2549. m(e);
  2550. }
  2551. }
  2552. }.bind(this)),
  2553. this.element.addEventListener("mousedown", e),
  2554. (e = function(e) {
  2555. var t = this.mouseStates[e.button];
  2556. if (t) {
  2557. var i = this.element.getBoundingClientRect(),
  2558. s = e.clientX - i.left;
  2559. i = e.clientY - i.top;
  2560. if (
  2561. ((t.pressed = !1),
  2562. (t.position[0] = s),
  2563. (t.position[1] = i),
  2564. 0 == e.button &&
  2565. e.target == this.element &&
  2566. Math.abs(t.position[0] - t.downPosition[0]) +
  2567. Math.abs(t.position[1] - t.downPosition[1]) <
  2568. 10)
  2569. ) {
  2570. for (var n = 0; n < this.onTap.length; ++n) this.onTap[n](s, i);
  2571. if (
  2572. ((this.needSingleClick = !0),
  2573. window.setTimeout(
  2574. function(e, t) {
  2575. if (this.needSingleClick) {
  2576. for (var i = 0; i < this.onSingleTap.length; ++i)
  2577. this.onSingleTap[i](e, t);
  2578. this.needSingleClick = !1;
  2579. }
  2580. }.bind(this, s, i),
  2581. 301
  2582. ),
  2583. (t = !1),
  2584. void 0 !== this.doubleClickTimer &&
  2585. ((n =
  2586. Math.abs(s - this.lastTapPos[0]) +
  2587. Math.abs(i - this.lastTapPos[1]) <
  2588. 8),
  2589. Date.now() - this.doubleClickTimer < 300 && n))
  2590. )
  2591. for (
  2592. t = !0, this.needSingleClick = !1, n = 0;
  2593. n < this.onDoubleTap.length;
  2594. ++n
  2595. )
  2596. this.onDoubleTap[n](s, i);
  2597. (this.doubleClickTimer = Date.now()),
  2598. t && (this.doubleClickTimer = -1e9),
  2599. (this.lastTapPos[0] = s),
  2600. (this.lastTapPos[1] = i);
  2601. }
  2602. }
  2603. m(e);
  2604. }.bind(this)),
  2605. this.element.addEventListener("mouseup", e),
  2606. (e = function(e) {
  2607. for (
  2608. var t = !1, i = this.element.getBoundingClientRect(), s = 0;
  2609. s < 3;
  2610. ++s
  2611. ) {
  2612. var n = this.mouseStates[s];
  2613. if (n.pressed) {
  2614. webview.stopRotate();
  2615. t = e.clientX - i.left;
  2616. var r = e.clientY - i.top,
  2617. a = t - n.position[0],
  2618. o = r - n.position[1];
  2619. if (
  2620. ((n.position[0] = t), (n.position[1] = r), 2 == s && e.altKey)
  2621. )
  2622. for (n = 0; n < this.onZoom.length; ++n)
  2623. this.onZoom[n](2 * o);
  2624. else if (1 <= s || e.ctrlKey)
  2625. for (n = 0; n < this.onPan.length; ++n) this.onPan[n](a, o);
  2626. else if (0 == s)
  2627. if (e.shiftKey)
  2628. for (n = 0; n < this.onPan2.length; ++n)
  2629. this.onPan2[n](a, o);
  2630. else
  2631. for (n = 0; n < this.onDrag.length; ++n)
  2632. this.onDrag[n](t, r, a, o);
  2633. t = !0;
  2634. }
  2635. }
  2636. t && m(e);
  2637. }.bind(this)),
  2638. this.element.addEventListener("mousemove", e),
  2639. (e = function(e) {
  2640. var t = 0;
  2641. e.deltaY
  2642. ? ((t = -0.4 * e.deltaY),
  2643. 1 == e.deltaMode
  2644. ? (t *= 16)
  2645. : 2 == e.deltaMode && (t *= this.element.clientHeight))
  2646. : e.wheelDelta
  2647. ? (t =
  2648. this.macHax && 120 == Math.abs(e.wheelDelta)
  2649. ? 0.08 * e.wheelDelta
  2650. : 0.4 * e.wheelDelta)
  2651. : e.detail && (t = -10 * e.detail);
  2652. for (var i = 0; i < this.onZoom.length; ++i) this.onZoom[i](t);
  2653. m(e);
  2654. }.bind(this)),
  2655. this.element.addEventListener("mousewheel", e),
  2656. this.element.addEventListener("DOMMouseScroll", e),
  2657. this.element.addEventListener("wheel", e),
  2658. (e = function(e) {
  2659. for (var t = 0; t < this.mouseStates.length; ++t)
  2660. this.mouseStates[t].pressed = !1;
  2661. e.preventDefault();
  2662. }.bind(this)),
  2663. this.element.addEventListener("mouseleave", e),
  2664. this.element.addEventListener("contextmenu", function(e) {
  2665. e.preventDefault();
  2666. }),
  2667. (this.touches = {}),
  2668. (this.tapPossible = !1),
  2669. (this.touchCountFloor = 0),
  2670. (e = function(e) {
  2671. for (
  2672. var t = this.element.getBoundingClientRect(), i = !1, s = 0;
  2673. s < e.changedTouches.length;
  2674. ++s
  2675. )
  2676. if (e.target === this.element) {
  2677. var n = e.changedTouches[s];
  2678. ((i = { x: n.clientX - t.left, y: n.clientY - t.top }).startX =
  2679. i.x),
  2680. (i.startY = i.y),
  2681. (this.touches[n.identifier] = i),
  2682. (i = !0);
  2683. }
  2684. for (
  2685. this.tapPossible = 1 == e.touches.length, n = t = 0;
  2686. n < this.touches.length;
  2687. ++n
  2688. )
  2689. t++;
  2690. t > this.touchCountFloor && (this.touchCountFloor = t), i && m(e);
  2691. }.bind(this)),
  2692. this.element.addEventListener("touchstart", e),
  2693. (e = function(e) {
  2694. for (var t = !1, i = 0; i < e.changedTouches.length; ++i) {
  2695. var s = e.changedTouches[i],
  2696. n = this.touches[s.identifier];
  2697. if (n) {
  2698. if (this.tapPossible) {
  2699. var r = this.element.getBoundingClientRect();
  2700. (t = s.clientX - r.left), (r = s.clientY - r.top);
  2701. if (
  2702. Math.max(Math.abs(t - n.startX), Math.abs(r - n.startY)) <
  2703. 24
  2704. ) {
  2705. for (i = 0; i < this.onTap.length; ++i) this.onTap[i](t, r);
  2706. if (
  2707. ((this.needSingleTap = !0),
  2708. window.setTimeout(
  2709. function(e, t) {
  2710. if (this.needSingleTap) {
  2711. for (var i = 0; i < this.onSingleTap.length; ++i)
  2712. this.onSingleTap[i](e, t);
  2713. this.needSingleTap = !1;
  2714. }
  2715. }.bind(this, t, r),
  2716. 501
  2717. ),
  2718. (n = !1),
  2719. void 0 !== this.doubleTapTimer)
  2720. ) {
  2721. var a =
  2722. Math.max(
  2723. Math.abs(t - this.lastTapPos[0]),
  2724. Math.abs(r - this.lastTapPos[1])
  2725. ) < 24,
  2726. o = Date.now() - this.doubleTapTimer < 500;
  2727. if (a && o)
  2728. for (n = !0, i = 0; i < this.onDoubleTap.length; ++i)
  2729. this.onDoubleTap[i](t, r);
  2730. }
  2731. (this.doubleTapTimer = Date.now()),
  2732. n && (this.doubleTapTimer = -1e9),
  2733. (this.lastTapPos[0] = t),
  2734. (this.lastTapPos[1] = r);
  2735. }
  2736. this.tapPossible = !1;
  2737. }
  2738. delete this.touches[s.identifier], (t = !0);
  2739. }
  2740. }
  2741. for (s = i = 0; s < this.touches.length; ++s) i++;
  2742. i <= 0 && (this.touchCountFloor = 0), t && m(e);
  2743. }.bind(this)),
  2744. this.element.addEventListener("touchend", e),
  2745. this.element.addEventListener("touchcancel", e),
  2746. this.element.addEventListener("touchleave", e),
  2747. (e = function(e) {
  2748. webview.stopRotate();
  2749. for (var t = [], i = 0; i < e.touches.length; ++i)
  2750. e.touches[i].target === this.element && t.push(e.touches[i]);
  2751. var s = this.element.getBoundingClientRect();
  2752. if (1 == t.length && this.touchCountFloor <= 1) {
  2753. var n = t[0],
  2754. r = this.touches[n.identifier];
  2755. if (r) {
  2756. var a = n.clientX - s.left,
  2757. o = ((n = n.clientY - s.top), (s = a - r.x), n - r.y);
  2758. for (r.x = a, r.y = n, i = 0; i < this.onDrag.length; ++i)
  2759. this.onDrag[i](a, n, s, o, e.shiftKey);
  2760. }
  2761. } else if (2 == t.length && this.touchCountFloor <= 2) {
  2762. if (
  2763. ((o = t[0]),
  2764. (i = this.touches[o.identifier]),
  2765. (n = t[1]),
  2766. (r = this.touches[n.identifier]),
  2767. i && r)
  2768. ) {
  2769. (a = o.clientX - s.left), (o = o.clientY - s.top);
  2770. var h = n.clientX - s.left,
  2771. l = n.clientY - s.top,
  2772. d = Math.sqrt((a - h) * (a - h) + (o - l) * (o - l)),
  2773. c = Math.sqrt(
  2774. (i.x - r.x) * (i.x - r.x) + (i.y - r.y) * (i.y - r.y)
  2775. ),
  2776. u = Math.abs(d - c),
  2777. f =
  2778. ((s = (a - i.x + h - r.x) / 2),
  2779. (n = (o - i.y + l - r.y) / 2),
  2780. Math.sqrt(s * s + n * n));
  2781. if (((i.x = a), (i.y = o), (r.x = h), (r.y = l), 0 < u))
  2782. for (r = u / (u + f), i = 0; i < this.onZoom.length; ++i)
  2783. this.onZoom[i](2 * (d - c) * r);
  2784. if (0 < f)
  2785. for (r = f / (u + f), i = 0; i < this.onDrag.length; ++i)
  2786. this.onPan[i](s * r, n * r);
  2787. }
  2788. } else if (3 <= t.length) {
  2789. for (i = c = d = h = o = 0; i < t.length; ++i)
  2790. (n = t[i]),
  2791. (r = this.touches[n.identifier]),
  2792. (d += a = n.clientX - s.left),
  2793. (c += n = n.clientY - s.top),
  2794. r && ((o += r.x), (h += r.y), (r.x = a), (r.y = n));
  2795. for (
  2796. o /= t.length,
  2797. h /= t.length,
  2798. d /= t.length,
  2799. c /= t.length,
  2800. i = 0;
  2801. i < this.onPan2.length;
  2802. ++i
  2803. )
  2804. this.onPan2[i](d - o, c - h);
  2805. }
  2806. 0 < t.length && m(e);
  2807. }.bind(this)),
  2808. this.element.addEventListener("touchmove", e);
  2809. }),
  2810. (x.prototype.getLightPos = function(e) {
  2811. return this.positionBuffer.subarray(4 * e, 4 * e + 4);
  2812. }),
  2813. (x.prototype.setLightDistance = function(e, t) {
  2814. t <= 0 && (t = 1e-5), (this.parameters[3 * e + 2] = 1 / t);
  2815. }),
  2816. (x.prototype.setLightSpotAngle = function(e, t) {
  2817. t <= 0 && (t = 1e-6), (this.spot[3 * e] = t);
  2818. var i = Math.sin(((3.1415926 / 180) * t) / 2);
  2819. this.spot[3 * e + 2] = (1 / (i * i)) * this.spot[3 * e + 1];
  2820. }),
  2821. (x.prototype.setLightSpotSharpness = function(e, t) {
  2822. (this.spot[3 * e + 1] = t), this.setLightSpotAngle(this.spot[3 * e]);
  2823. }),
  2824. (x.prototype.setLightPos = function(e, t) {
  2825. (this.positions[4 * e + 0] = t[0]),
  2826. (this.positions[4 * e + 1] = t[1]),
  2827. (this.positions[4 * e + 2] = t[2]);
  2828. var i = this.positions.subarray(4 * e, 4 * e + 4);
  2829. 1 == this.matrixWeights[e]
  2830. ? S.mul4(i, this.defaultmatrix, t[0], t[1], t[2], i[3])
  2831. : 2 == this.matrixWeights[e] &&
  2832. S.mul4(i, this.defaultviewmatrix, t[0], t[1], t[2], i[3]);
  2833. }),
  2834. (x.prototype.setLightDir = function(e, t) {
  2835. (this.directions[3 * e + 0] = t[0]),
  2836. (this.directions[3 * e + 1] = t[1]),
  2837. (this.directions[3 * e + 2] = t[2]);
  2838. var i = this.directions.subarray(3 * e, 3 * e + 3);
  2839. 1 == this.matrixWeights[e]
  2840. ? S.mulVec(i, this.defaultmatrix, t[0], t[1], t[2])
  2841. : 2 == this.matrixWeights[e] &&
  2842. S.mulVec(i, this.defaultviewmatrix, t[0], t[1], t[2]);
  2843. }),
  2844. (x.prototype.getLightColor = function(e) {
  2845. return this.colors.subarray(3 * e, 3 * e + 3);
  2846. }),
  2847. (x.prototype.setLightColor = function(e, t) {
  2848. (this.colors[3 * e + 0] = t[0]),
  2849. (this.colors[3 * e + 1] = t[1]),
  2850. (this.colors[3 * e + 2] = t[2]);
  2851. }),
  2852. (x.prototype.getLightDir = function(e) {
  2853. return this.directionBuffer.subarray(3 * e, 3 * e + 3);
  2854. }),
  2855. (x.prototype.getColor = function(e) {
  2856. return (
  2857. (e *= 3), [this.colors[e], this.colors[e + 1], this.colors[e + 2]]
  2858. );
  2859. }),
  2860. (x.prototype.update = function(e, t) {
  2861. var i = new S.type(this.matrix);
  2862. S.rotation(this.matrix, this.rotation, 1),
  2863. S.transpose(this.invMatrix, this.matrix);
  2864. for (var s = 0; s < this.count; ++s) {
  2865. var n = this.positions.subarray(4 * s, 4 * s + 4),
  2866. r = this.directions.subarray(3 * s, 3 * s + 3),
  2867. a = this.getLightPos(s),
  2868. o = this.getLightDir(s);
  2869. 1 == this.matrixWeights[s]
  2870. ? ((a[0] = n[0]),
  2871. (a[1] = n[1]),
  2872. (a[2] = n[2]),
  2873. (a[3] = n[3]),
  2874. (o[0] = r[0]),
  2875. (o[1] = r[1]),
  2876. (o[2] = r[2]))
  2877. : 2 == this.matrixWeights[s]
  2878. ? (S.mul4(a, e.transform, n[0], n[1], n[2], n[3]),
  2879. S.mulVec(o, e.transform, r[0], r[1], r[2]),
  2880. S.mul4(a, this.matrix, a[0], a[1], a[2], a[3]),
  2881. S.mulVec(o, this.matrix, o[0], o[1], o[2]))
  2882. : (S.mul4(a, this.matrix, n[0], n[1], n[2], n[3]),
  2883. S.mulVec(o, this.matrix, r[0], r[1], r[2])),
  2884. V.normalize(o, o);
  2885. }
  2886. (r = new Float32Array(this.finalTransformBuffer)),
  2887. (a = S.empty()),
  2888. (o = S.empty());
  2889. var h = S.empty(),
  2890. l = V.empty(),
  2891. d = V.empty(),
  2892. c = V.empty(),
  2893. u = V.empty(),
  2894. f = ((n = V.empty()), []),
  2895. m = [],
  2896. p = S.create(
  2897. 0.5,
  2898. 0,
  2899. 0,
  2900. 0.5,
  2901. 0,
  2902. 0.5,
  2903. 0,
  2904. 0.5,
  2905. 0,
  2906. 0,
  2907. 0.5,
  2908. 0.5,
  2909. 0,
  2910. 0,
  2911. 0,
  2912. 1
  2913. );
  2914. for (s = 0; s < this.count; ++s) {
  2915. for (
  2916. l = this.getLightPos(s),
  2917. d = this.getLightDir(s),
  2918. 0.99 < Math.abs(d[1]) ? V.set(c, 1, 0, 0) : V.set(c, 0, 1, 0),
  2919. V.cross(u, c, d),
  2920. V.normalize(u, u),
  2921. V.cross(c, d, u),
  2922. V.normalize(c, c),
  2923. S.set(
  2924. a,
  2925. u[0],
  2926. u[1],
  2927. u[2],
  2928. -V.dot(u, l),
  2929. c[0],
  2930. c[1],
  2931. c[2],
  2932. -V.dot(c, l),
  2933. d[0],
  2934. d[1],
  2935. d[2],
  2936. -V.dot(d, l),
  2937. 0,
  2938. 0,
  2939. 0,
  2940. 1
  2941. ),
  2942. l = 0;
  2943. l < 8;
  2944. ++l
  2945. )
  2946. (n[0] = 1 & l ? t.max[0] : t.min[0]),
  2947. (n[1] = 2 & l ? t.max[1] : t.min[1]),
  2948. (n[2] = 4 & l ? t.max[2] : t.min[2]),
  2949. S.mulPoint(
  2950. n,
  2951. this.matrix,
  2952. 1.005 * n[0],
  2953. 1.005 * n[1],
  2954. 1.005 * n[2]
  2955. ),
  2956. S.mulPoint(n, a, n[0], n[1], n[2]),
  2957. 0 == l
  2958. ? ((f[0] = m[0] = n[0]),
  2959. (f[1] = m[1] = n[1]),
  2960. (f[2] = m[2] = n[2]))
  2961. : ((f[0] = Math.min(f[0], n[0])),
  2962. (f[1] = Math.min(f[1], n[1])),
  2963. (f[2] = Math.min(f[2], n[2])),
  2964. (m[0] = Math.max(m[0], n[0])),
  2965. (m[1] = Math.max(m[1], n[1])),
  2966. (m[2] = Math.max(m[2], n[2])));
  2967. (l = -f[2]), (d = -m[2]);
  2968. var g = this.spot[3 * s];
  2969. 0 < g
  2970. ? ((l = Math.min(l, 1 / this.parameters[3 * s + 2])),
  2971. (d = Math.max(0.04 * l, d)),
  2972. S.perspective(o, g, 1, d, l),
  2973. s < this.shadowCount &&
  2974. ((l = 2 * -Math.tan(0.00872664625 * g)),
  2975. (this.shadowTexelPadProjections[4 * s + 0] =
  2976. this.modelViewBuffer[16 * s + 2] * l),
  2977. (this.shadowTexelPadProjections[4 * s + 1] =
  2978. this.modelViewBuffer[16 * s + 6] * l),
  2979. (this.shadowTexelPadProjections[4 * s + 2] =
  2980. this.modelViewBuffer[16 * s + 10] * l),
  2981. (this.shadowTexelPadProjections[4 * s + 3] =
  2982. this.modelViewBuffer[16 * s + 14] * l)))
  2983. : (S.ortho(o, f[0], m[0], f[1], m[1], d, l),
  2984. s < this.shadowCount &&
  2985. ((this.shadowTexelPadProjections[
  2986. 4 * s + 0
  2987. ] = this.shadowTexelPadProjections[
  2988. 4 * s + 1
  2989. ] = this.shadowTexelPadProjections[4 * s + 2] = 0),
  2990. (this.shadowTexelPadProjections[4 * s + 3] = Math.max(
  2991. m[0] - f[0],
  2992. m[1] - f[1]
  2993. )))),
  2994. S.mul(h, o, a),
  2995. S.mul(h, p, h),
  2996. S.copyToBuffer(this.modelViewBuffer, 16 * s, a),
  2997. S.copyToBuffer(this.projectionBuffer, 16 * s, o),
  2998. S.copyToBuffer(this.finalTransformBuffer, 16 * s, h),
  2999. S.invert(h, h),
  3000. S.copyToBuffer(this.inverseTransformBuffer, 16 * s, h);
  3001. }
  3002. for (n = !1, s = 0; s < i.length; ++s)
  3003. if (i[s] != this.matrix[s]) {
  3004. n = !0;
  3005. break;
  3006. }
  3007. for (s = 0; s < this.shadowCount; s++)
  3008. if (n && 1 == this.matrixWeights[s]) this.shadowsNeedUpdate[s] = 1;
  3009. else
  3010. for (i = 16 * s; i < 16 * s + 16; ++i)
  3011. if (r[i] != this.finalTransformBuffer[i]) {
  3012. this.shadowsNeedUpdate[s] = 1;
  3013. break;
  3014. }
  3015. }),
  3016. (x.prototype.flagUpdateAnimatedLighting = function() {
  3017. for (var e = 0; e < this.shadowCount; e++)
  3018. this.shadowsNeedUpdate[e] = 1;
  3019. }),
  3020. (y.prototype.linkControl = function(e) {
  3021. this.controlRect.linkControl(e);
  3022. }),
  3023. (y.prototype.spawnControl = function(e, t, i, s, n, r) {
  3024. var a =
  3025. "backgroundTopLE" + (w = this.guiScreen.imageSetNumber) + "x.png",
  3026. o = "backgroundTopM" + w + "x.png",
  3027. h = "backgroundTopRE" + w + "x.png",
  3028. l = "backgroundMiddleLE" + w + "x.png",
  3029. d = "backgroundMiddleM" + w + "x.png",
  3030. c = "backgroundMiddleRE" + w + "x.png",
  3031. u = "backgroundBottomLE" + w + "x.png",
  3032. f = "backgroundBottomM" + w + "x.png",
  3033. m = "backgroundBottomRE" + w + "x.png",
  3034. p = 3 * w,
  3035. g = "backgroundLE" + w + "x.png",
  3036. v = "backgroundM" + w + "x.png",
  3037. x = "backgroundRE" + w + "x.png",
  3038. y = 2 * w,
  3039. b = "spacerLE" + w + "x.png",
  3040. S = "spacerM" + w + "x.png",
  3041. T = "spacerRE" + w + "x.png",
  3042. w = 2 * w,
  3043. C = this.controlRect.guiScreen.width,
  3044. R = this.controlRect.guiScreen.height;
  3045. if (n) {
  3046. n = this.textEntries.length;
  3047. var A = i;
  3048. for (i = 0; i < n; i++) {
  3049. var k = 8 * (this.textEntries[i] ? this.textEntries[i].length : 0);
  3050. A < k && (A = k);
  3051. }
  3052. i = A + r;
  3053. }
  3054. for (
  3055. r = 1 / (n = this.textEntries.length + 1),
  3056. this.localPixelsX = i,
  3057. this.listBoxEntryHeight = s,
  3058. this.localPixelsY =
  3059. (this.textEntries.length + 1) * this.listBoxEntryHeight,
  3060. i = 8 / this.localPixelsY,
  3061. s = 6 / this.localPixelsX,
  3062. A = 4 / this.localPixelsX,
  3063. k = r - i / 4,
  3064. this.labelTextHeight = I.largeUI ? 20 : 16,
  3065. this.labelPixelDrop =
  3066. (this.listBoxEntryHeight - this.labelTextHeight) / 2,
  3067. this.listBoxRegion.controlRect.widthPercent = this.localPixelsX / C,
  3068. this.listBoxRegion.controlRect.heightPercent =
  3069. this.localPixelsY / R,
  3070. this.listBoxRegion.controlRect.xPercent = e / C,
  3071. this.listBoxRegion.controlRect.yPercent = t / R,
  3072. this.openBackground = this.listBoxRegion.addTextButton(
  3073. "",
  3074. 0,
  3075. 0,
  3076. 1,
  3077. 1 + i,
  3078. 1
  3079. ),
  3080. this.openBackground.setBackground3x3(
  3081. this.listBoxRegion,
  3082. 0,
  3083. 0,
  3084. a,
  3085. o,
  3086. h,
  3087. l,
  3088. d,
  3089. c,
  3090. u,
  3091. f,
  3092. m,
  3093. p,
  3094. p
  3095. ),
  3096. this.closedBackground = this.listBoxRegion.addTextButton(
  3097. "",
  3098. 0,
  3099. 0,
  3100. 1,
  3101. r,
  3102. 1
  3103. ),
  3104. this.closedBackground.setBackground3x1(
  3105. this.listBoxRegion,
  3106. 0,
  3107. 0,
  3108. g,
  3109. v,
  3110. x,
  3111. y
  3112. ),
  3113. e = this.labelPixelInset + this.textOffsetsX[0],
  3114. t = this.labelPixelDrop + this.textOffsetsY[0],
  3115. t /= this.localPixelsY,
  3116. e /= this.localPixelsX,
  3117. this.defaultButton = this.listBoxRegion.addTextButton(
  3118. "Selected",
  3119. e,
  3120. -t,
  3121. 1,
  3122. r,
  3123. 0.5
  3124. ),
  3125. this.selectedIndex = 0,
  3126. this.defaultButton.controlRect.linkedControl.innerHTML = this.textEntries[
  3127. this.selectedIndex
  3128. ],
  3129. this.defaultButton.linkedBackground = this.closedBackground,
  3130. this.spacerControl = this.listBoxRegion.addTextButton(
  3131. "",
  3132. s,
  3133. k,
  3134. 1 - (s + A),
  3135. i,
  3136. 1
  3137. ),
  3138. this.spacerControl.defaultAlpha = 1,
  3139. this.spacerControl.setBackground3x1(
  3140. this.listBoxRegion,
  3141. 0,
  3142. 0,
  3143. b,
  3144. S,
  3145. T,
  3146. w
  3147. ),
  3148. this.spacerControl.setVisible(!1),
  3149. this.spacerControl.linkedBackground = this.openBackground,
  3150. i = 1;
  3151. i < n;
  3152. i++
  3153. )
  3154. (e = this.labelPixelInset + this.textOffsetsX[i - 1]),
  3155. (t = this.labelPixelDrop + this.textOffsetsY[i - 1] - 4),
  3156. (e /= this.localPixelsX),
  3157. (t /= this.localPixelsY),
  3158. (b = this.listBoxRegion.addTextButton(
  3159. this.textEntries[i - 1],
  3160. e,
  3161. r * i - t,
  3162. 1 - e,
  3163. r,
  3164. 0.5
  3165. )),
  3166. this.listBoxButtons.push(b),
  3167. (b.linkedBackground = this.openBackground);
  3168. this.showList(!1), this.setupCallbacks();
  3169. }),
  3170. (y.prototype.setControl = function(e, t, i, s, n, r) {
  3171. var a = this.controlRect.guiScreen.width,
  3172. o = this.controlRect.guiScreen.height;
  3173. if (n) {
  3174. n = this.textEntries.length;
  3175. for (var h = 0; h < n; h++) {
  3176. var l = 8 * (this.textEntries[h] ? this.textEntries[h].length : 0);
  3177. i < l && (i = l);
  3178. }
  3179. i += r;
  3180. }
  3181. (this.localPixelsX = i),
  3182. (this.listBoxEntryHeight = s),
  3183. (this.localPixelsY =
  3184. (this.textEntries.length + 1) * this.listBoxEntryHeight),
  3185. (this.listBoxRegion.controlRect.widthPercent = this.localPixelsX / a),
  3186. (this.listBoxRegion.controlRect.heightPercent =
  3187. this.localPixelsY / o),
  3188. (this.listBoxRegion.controlRect.xPercent = e / a),
  3189. (this.listBoxRegion.controlRect.yPercent = t / o),
  3190. this.listBoxRegion.controlRect.updateChildElements(),
  3191. this.spacerControl.alignBackground(),
  3192. this.openBackground.alignBackground(),
  3193. this.closedBackground.alignBackground();
  3194. }),
  3195. (y.prototype.addItem = function(e, t, i) {
  3196. this.textEntries.push(e),
  3197. this.textOffsetsX.push(t),
  3198. this.textOffsetsY.push(i);
  3199. }),
  3200. (y.prototype.showList = function(e) {
  3201. for (var t = this.listBoxButtons.length, i = 0; i < t; i++)
  3202. this.listBoxButtons[i].setVisible(e);
  3203. (this.closed = !e),
  3204. this.spacerControl && this.spacerControl.setVisible(e),
  3205. this.openBackground && this.openBackground.setVisible(e),
  3206. this.closedBackground && this.closedBackground.setVisible(!e),
  3207. e
  3208. ? ((this.defaultButton.linkedBackground = this.openBackground),
  3209. this.openBackground.setOpacity(1),
  3210. this.closedBackground.setOpacity(0.5))
  3211. : (this.defaultButton.linkedBackground = this.closedBackground);
  3212. }),
  3213. (y.prototype.selectItem = function(e) {
  3214. (this.selectedItemText = this.textEntries[e]),
  3215. (this.selectedIndex = e),
  3216. (this.defaultButton.controlRect.linkedControl.innerHTML = this.textEntries[
  3217. this.selectedIndex
  3218. ]),
  3219. (e =
  3220. (this.labelTextHeight - this.listBoxEntryHeight + 3) /
  3221. this.localPixelsY),
  3222. (this.defaultButton.controlRect.xPercent =
  3223. (this.labelPixelInset + this.textOffsetsX[this.selectedIndex]) /
  3224. this.localPixelsX),
  3225. (this.defaultButton.controlRect.yPercent = e),
  3226. this.defaultButton.controlRect.updateElement();
  3227. }),
  3228. (y.prototype.setupCallbacks = function() {
  3229. var e = function(e) {
  3230. if (this.closed) {
  3231. var t = (t = this.closedBackground.controlRect
  3232. .linkedControl).getBoundingClientRect(),
  3233. i = e.clientX - t.left;
  3234. (e = e.clientY - t.top),
  3235. (i /= t.width),
  3236. (t = e / t.height),
  3237. 0 <= i && i <= 1 && 0 <= t && t <= 1
  3238. ? this.closedBackground.setOpacity(1)
  3239. : this.closedBackground.setOpacity(0.5);
  3240. } else
  3241. (t = (t = this.openBackground.controlRect
  3242. .linkedControl).getBoundingClientRect()),
  3243. (i = e.clientX - t.left),
  3244. (e = e.clientY - t.top),
  3245. (i /= t.width),
  3246. (t = e / t.height),
  3247. 0 <= i && i <= 1 && 0 <= t && t <= 1
  3248. ? this.openBackground.setOpacity(1)
  3249. : this.openBackground.setOpacity(0.5);
  3250. }.bind(this);
  3251. this.defaultButton.controlRect.linkedControl.onclick = function() {
  3252. this.closed
  3253. ? this.showList(!0)
  3254. : (this.showList(this.closed),
  3255. this.closedBackground.setOpacity(1),
  3256. this.defaultButton.setOpacity(1));
  3257. }.bind(this);
  3258. for (
  3259. var t = function(e) {
  3260. this.selectItem(e.id),
  3261. this.showList(!1),
  3262. this.defaultButton.setOpacity(0.5),
  3263. this.selectionChangedCallback &&
  3264. this.selectionChangedCallback(this);
  3265. }.bind(this),
  3266. i = function(e) {
  3267. e = this.listBoxButtons.length;
  3268. for (var t = 0; t < e; t++)
  3269. this.listBoxButtons[t].controlRect.mouseOver &&
  3270. (this.selectItem(t),
  3271. (t = e),
  3272. this.selectionChangedCallback &&
  3273. this.selectionChangedCallback(this));
  3274. this.showList(!1);
  3275. }.bind(this),
  3276. s = this.listBoxButtons.length,
  3277. n = 0;
  3278. n < s;
  3279. n++
  3280. )
  3281. (this.listBoxButtons[n].controlRect.callBack = t),
  3282. (this.listBoxButtons[n].controlRect.id = n),
  3283. this.listBoxButtons[n].controlRect.linkedControl.addEventListener(
  3284. "mousemove",
  3285. e
  3286. );
  3287. this.guiScreen.ui.viewer.input.element.addEventListener("mousemove", e),
  3288. this.openBackground.controlRect.linkedControl.addEventListener(
  3289. "mousemove",
  3290. e
  3291. ),
  3292. this.closedBackground.controlRect.linkedControl.addEventListener(
  3293. "mousemove",
  3294. e
  3295. ),
  3296. this.guiScreen.ui.viewer.input.element.addEventListener(
  3297. "mousedown",
  3298. i
  3299. );
  3300. }),
  3301. (b.prototype.bind = function(e, t) {
  3302. if (!this.complete()) return !1;
  3303. var i,
  3304. s = e.view,
  3305. n = e.lights,
  3306. r = e.sky,
  3307. a = e.shadow,
  3308. o = e.stripData.active() ? this.stripShader : this.shader,
  3309. h = this.skinParams,
  3310. l = this.anisoParams,
  3311. d = this.microfiberParams,
  3312. c = this.gl,
  3313. u = o.params,
  3314. f = this.textures,
  3315. m = o.samplers;
  3316. o.bind(), this.blend();
  3317. var p = t.mesh.displayMatrix,
  3318. g = S.mul(S.empty(), s.viewMatrix, p),
  3319. v = S.mul(S.empty(), s.projectionMatrix, s.viewMatrix);
  3320. (g = S.mul(S.empty(), s.projectionMatrix, g)),
  3321. (p = S.mul(S.empty(), n.matrix, p));
  3322. return (
  3323. c.uniformMatrix4fv(u.uModelViewProjectionMatrix, !1, g),
  3324. c.uniformMatrix4fv(u.uSkyMatrix, !1, p),
  3325. (p = S.mulPoint(
  3326. V.empty(),
  3327. n.matrix,
  3328. s.transform[12],
  3329. s.transform[13],
  3330. s.transform[14]
  3331. )),
  3332. c.uniform3f(u.uCameraPosition, p[0], p[1], p[2]),
  3333. c.uniform3fv(u.uFresnel, this.fresnel),
  3334. c.uniform1f(u.uAlphaTest, this.alphaTest),
  3335. c.uniform1f(u.uHorizonOcclude, this.horizonOcclude),
  3336. c.uniform1f(u.uHorizonSmoothing, this.horizonSmoothing),
  3337. c.uniform4fv(u.uDiffuseCoefficients, r.diffuseCoefficients),
  3338. 0 < n.count &&
  3339. (c.uniform4fv(u.uLightPositions, n.positionBuffer),
  3340. c.uniform3fv(u.uLightDirections, n.directionBuffer),
  3341. c.uniform3fv(u.uLightColors, n.colors),
  3342. c.uniform3fv(u.uLightParams, n.parameters),
  3343. c.uniform3fv(u.uLightSpot, n.spot),
  3344. (p = 0.392699 * e.postRender.currentSample()),
  3345. c.uniform2f(
  3346. u.uShadowKernelRotation,
  3347. 0.5 * Math.cos(p),
  3348. 0.5 * Math.sin(p)
  3349. ),
  3350. 0 < n.shadowCount &&
  3351. ((p = a.depthTextures[0].desc.width),
  3352. c.uniform2f(u.uShadowMapSize, p, 1 / p),
  3353. c.uniformMatrix4fv(u.uShadowMatrices, !1, n.finalTransformBuffer),
  3354. c.uniformMatrix4fv(
  3355. u.uInvShadowMatrices,
  3356. !1,
  3357. n.inverseTransformBuffer
  3358. ),
  3359. c.uniform4fv(
  3360. u.uShadowTexelPadProjections,
  3361. n.shadowTexelPadProjections
  3362. ),
  3363. a.bindDepthTexture(m.tDepth0, 0),
  3364. a.bindDepthTexture(m.tDepth1, 1),
  3365. a.bindDepthTexture(m.tDepth2, 2))),
  3366. h &&
  3367. (c.uniform3fv(u.uSubdermisColor, h.subdermisColor),
  3368. c.uniform4fv(u.uTransColor, h.transColor),
  3369. c.uniform1f(u.uTransScatter, h.transScatter),
  3370. c.uniform4fv(u.uFresnelColor, h.fresnelColor),
  3371. c.uniform1f(u.uFresnelOcc, h.fresnelOcc),
  3372. c.uniform1f(u.uFresnelGlossMask, h.fresnelGlossMask),
  3373. c.uniform1f(u.uFresnelIntegral, h.fresnelIntegral),
  3374. c.uniform1f(u.uTransIntegral, h.transIntegral),
  3375. c.uniform1f(u.uSkinTransDepth, h.transDepth),
  3376. c.uniform1f(u.uTransSky, h.transSky),
  3377. c.uniform1f(u.uSkinShadowBlur, h.shadowBlur),
  3378. c.uniform1f(u.uNormalSmooth, h.normalSmooth),
  3379. (i = this.extrasTexCoordRanges.subdermisTex) &&
  3380. c.uniform4fv(u.uTexRangeSubdermis, i),
  3381. (i = this.extrasTexCoordRanges.translucencyTex) &&
  3382. c.uniform4fv(u.uTexRangeTranslucency, i),
  3383. (i = this.extrasTexCoordRanges.fuzzTex) &&
  3384. c.uniform4fv(u.uTexRangeFuzz, i)),
  3385. d &&
  3386. (c.uniform4fv(u.uFresnelColor, d.fresnelColor),
  3387. c.uniform1f(u.uFresnelOcc, d.fresnelOcc),
  3388. c.uniform1f(u.uFresnelGlossMask, d.fresnelGlossMask),
  3389. c.uniform1f(u.uFresnelIntegral, d.fresnelIntegral),
  3390. (i = this.extrasTexCoordRanges.fuzzTex) &&
  3391. c.uniform4fv(u.uTexRangeFuzz, i)),
  3392. l &&
  3393. (c.uniform3fv(u.uAnisoTangent, l.tangent),
  3394. c.uniform1f(u.uAnisoStrength, l.strength),
  3395. c.uniform1f(u.uAnisoIntegral, l.integral),
  3396. (i = this.extrasTexCoordRanges.anisoTex) &&
  3397. c.uniform4fv(u.uTexRangeAniso, i)),
  3398. this.usesRefraction &&
  3399. (e.refractionSurface && e.refractionSurface.bind(m.tRefraction),
  3400. (n = S.mul(S.empty(), v, n.invMatrix)),
  3401. c.uniformMatrix4fv(u.uRefractionViewProjection, !1, n),
  3402. c.uniform1f(
  3403. u.uRefractionRayDistance,
  3404. this.refractionParams.distantBackground
  3405. ? 1e10
  3406. : 4 * t.mesh.bounds.maxExtent
  3407. ),
  3408. c.uniform3fv(u.uRefractionTint, this.refractionParams.tint),
  3409. c.uniform1f(
  3410. u.uRefractionAlbedoTint,
  3411. this.refractionParams.useAlbedoTint ? 1 : 0
  3412. ),
  3413. c.uniform1f(u.uRefractionIOREntry, 1 / this.refractionParams.IOR),
  3414. (i = this.extrasTexCoordRanges.refractionMaskTex) &&
  3415. c.uniform4fv(u.uTexRangeRefraction, i)),
  3416. (i = this.extrasTexCoordRanges.emissiveTex) &&
  3417. (c.uniform4fv(u.uTexRangeEmissive, i),
  3418. c.uniform1f(u.uEmissiveScale, this.emissiveIntensity)),
  3419. (i = this.extrasTexCoordRanges.aoTex) &&
  3420. c.uniform4fv(u.uTexRangeAO, i),
  3421. f.albedo.bind(m.tAlbedo),
  3422. f.reflectivity.bind(m.tReflectivity),
  3423. f.normal.bind(m.tNormal),
  3424. f.extras.bind(m.tExtras),
  3425. r.specularTexture.bind(m.tSkySpecular),
  3426. o === this.stripShader &&
  3427. (c.uniform1fv(u.uStrips, e.stripData.strips),
  3428. c.uniform2f(u.uStripRes, 2 / s.size[0], 2 / s.size[1])),
  3429. c.uniform2f(u.uUVOffset, this.uOffset, this.vOffset),
  3430. !0
  3431. );
  3432. }),
  3433. (b.prototype.bindAlphaPrepass = function(e, t) {
  3434. if (!this.complete() || !this.prepassShader) return !1;
  3435. var i = this.gl,
  3436. s = this.prepassShader.params,
  3437. n = this.prepassShader.samplers;
  3438. this.prepassShader.bind();
  3439. var r = S.mul(S.empty(), e.view.viewMatrix, t.mesh.displayMatrix);
  3440. r = S.mul(S.empty(), e.view.projectionMatrix, r);
  3441. return (
  3442. i.uniformMatrix4fv(s.uModelViewProjectionMatrix, !1, r),
  3443. i.uniform2f(s.uUVOffset, this.uOffset, this.vOffset),
  3444. this.textures.albedo.bind(n.tAlbedo),
  3445. !0
  3446. );
  3447. }),
  3448. (b.prototype.bindWire = function(e, t) {
  3449. if (!this.complete()) return !1;
  3450. var i = this.gl,
  3451. s = this.wireShader.params,
  3452. n = e.view;
  3453. i.enable(i.BLEND),
  3454. i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA),
  3455. i.depthMask(!1),
  3456. this.wireShader.bind();
  3457. var r = S.mul(S.empty(), e.view.viewMatrix, t.mesh.displayMatrix);
  3458. r = S.mul(S.empty(), e.view.projectionMatrix, r);
  3459. return (
  3460. i.uniformMatrix4fv(s.uModelViewProjectionMatrix, !1, r),
  3461. i.uniform4f(
  3462. s.uStripParams,
  3463. 2 / n.size[0],
  3464. 2 / n.size[1],
  3465. e.stripData.strips[3],
  3466. e.stripData.strips[4]
  3467. ),
  3468. !0
  3469. );
  3470. }),
  3471. (b.prototype.complete = function() {
  3472. return (
  3473. this.wireShader.complete() &&
  3474. this.shader.complete() &&
  3475. this.stripShader.complete() &&
  3476. (!this.prepassShader || this.prepassShader.complete()) &&
  3477. (!this.refractionShader || this.refractionShader.complete()) &&
  3478. this.textures.albedo.complete() &&
  3479. this.textures.reflectivity.complete() &&
  3480. this.textures.normal.complete()
  3481. );
  3482. });
  3483. var S = {
  3484. type: Float32Array,
  3485. create: function(e, t, i, s, n, r, a, o, h, l, d, c, u, f, m, p) {
  3486. var g = new S.type(16);
  3487. return (
  3488. (g[0] = e),
  3489. (g[4] = t),
  3490. (g[8] = i),
  3491. (g[12] = s),
  3492. (g[1] = n),
  3493. (g[5] = r),
  3494. (g[9] = a),
  3495. (g[13] = o),
  3496. (g[2] = h),
  3497. (g[6] = l),
  3498. (g[10] = d),
  3499. (g[14] = c),
  3500. (g[3] = u),
  3501. (g[7] = f),
  3502. (g[11] = m),
  3503. (g[15] = p),
  3504. g
  3505. );
  3506. },
  3507. empty: function() {
  3508. return new S.type(16);
  3509. },
  3510. identity: function() {
  3511. var e = new S.type(16);
  3512. return (
  3513. (e[0] = 1),
  3514. (e[4] = 0),
  3515. (e[8] = 0),
  3516. (e[12] = 0),
  3517. (e[1] = 0),
  3518. (e[5] = 1),
  3519. (e[9] = 0),
  3520. (e[13] = 0),
  3521. (e[2] = 0),
  3522. (e[6] = 0),
  3523. (e[10] = 1),
  3524. (e[14] = 0),
  3525. (e[3] = 0),
  3526. (e[7] = 0),
  3527. (e[11] = 0),
  3528. (e[15] = 1),
  3529. e
  3530. );
  3531. },
  3532. set: function(e, t, i, s, n, r, a, o, h, l, d, c, u, f, m, p, g) {
  3533. (e[0] = t),
  3534. (e[4] = i),
  3535. (e[8] = s),
  3536. (e[12] = n),
  3537. (e[1] = r),
  3538. (e[5] = a),
  3539. (e[9] = o),
  3540. (e[13] = h),
  3541. (e[2] = l),
  3542. (e[6] = d),
  3543. (e[10] = c),
  3544. (e[14] = u),
  3545. (e[3] = f),
  3546. (e[7] = m),
  3547. (e[11] = p),
  3548. (e[15] = g);
  3549. },
  3550. translation: function(e, t, i, s) {
  3551. return S.set(e, 1, 0, 0, t, 0, 1, 0, i, 0, 0, 1, s, 0, 0, 0, 1), e;
  3552. },
  3553. rotation: function(e, t, i) {
  3554. (e[0] = 1),
  3555. (e[4] = 0),
  3556. (e[8] = 0),
  3557. (e[12] = 0),
  3558. (e[1] = 0),
  3559. (e[5] = 1),
  3560. (e[9] = 0),
  3561. (e[13] = 0),
  3562. (e[2] = 0),
  3563. (e[6] = 0),
  3564. (e[10] = 1),
  3565. (e[14] = 0),
  3566. (e[3] = 0),
  3567. (e[7] = 0),
  3568. (e[11] = 0),
  3569. (e[15] = 1);
  3570. var s = 0.0174532925 * t;
  3571. switch (((t = Math.sin(s)), (s = Math.cos(s)), i)) {
  3572. case 0:
  3573. (e[5] = s), (e[9] = -t), (e[6] = t), (e[10] = s);
  3574. break;
  3575. case 1:
  3576. (e[0] = s), (e[8] = t), (e[2] = -t), (e[10] = s);
  3577. break;
  3578. case 2:
  3579. (e[0] = s), (e[4] = -t), (e[1] = t), (e[5] = s);
  3580. }
  3581. return e;
  3582. },
  3583. mul: function(e, t, i) {
  3584. var s = t[0],
  3585. n = t[1],
  3586. r = t[2],
  3587. a = t[3],
  3588. o = t[4],
  3589. h = t[5],
  3590. l = t[6],
  3591. d = t[7],
  3592. c = t[8],
  3593. u = t[9],
  3594. f = t[10],
  3595. m = t[11],
  3596. p = t[12],
  3597. g = t[13],
  3598. v = t[14];
  3599. t = t[15];
  3600. var x = i[0],
  3601. y = i[1],
  3602. b = i[2],
  3603. S = i[3];
  3604. return (
  3605. (e[0] = x * s + y * o + b * c + S * p),
  3606. (e[1] = x * n + y * h + b * u + S * g),
  3607. (e[2] = x * r + y * l + b * f + S * v),
  3608. (e[3] = x * a + y * d + b * m + S * t),
  3609. (x = i[4]),
  3610. (y = i[5]),
  3611. (b = i[6]),
  3612. (S = i[7]),
  3613. (e[4] = x * s + y * o + b * c + S * p),
  3614. (e[5] = x * n + y * h + b * u + S * g),
  3615. (e[6] = x * r + y * l + b * f + S * v),
  3616. (e[7] = x * a + y * d + b * m + S * t),
  3617. (x = i[8]),
  3618. (y = i[9]),
  3619. (b = i[10]),
  3620. (S = i[11]),
  3621. (e[8] = x * s + y * o + b * c + S * p),
  3622. (e[9] = x * n + y * h + b * u + S * g),
  3623. (e[10] = x * r + y * l + b * f + S * v),
  3624. (e[11] = x * a + y * d + b * m + S * t),
  3625. (x = i[12]),
  3626. (y = i[13]),
  3627. (b = i[14]),
  3628. (S = i[15]),
  3629. (e[12] = x * s + y * o + b * c + S * p),
  3630. (e[13] = x * n + y * h + b * u + S * g),
  3631. (e[14] = x * r + y * l + b * f + S * v),
  3632. (e[15] = x * a + y * d + b * m + S * t),
  3633. e
  3634. );
  3635. },
  3636. invert: function(e, t) {
  3637. var i = t[0],
  3638. s = t[1],
  3639. n = t[2],
  3640. r = t[3],
  3641. a = t[4],
  3642. o = t[5],
  3643. h = t[6],
  3644. l = t[7],
  3645. d = t[8],
  3646. c = t[9],
  3647. u = t[10],
  3648. f = t[11],
  3649. m = t[12],
  3650. p = t[13],
  3651. g = t[14],
  3652. v = t[15],
  3653. x = i * o - s * a,
  3654. y = i * h - n * a,
  3655. b = i * l - r * a,
  3656. S = s * h - n * o,
  3657. T = s * l - r * o,
  3658. w = n * l - r * h,
  3659. C = d * p - c * m,
  3660. R = d * g - u * m,
  3661. A = d * v - f * m,
  3662. k = c * g - u * p,
  3663. I = c * v - f * p,
  3664. P = u * v - f * g,
  3665. F = x * P - y * I + b * k + S * A - T * R + w * C;
  3666. return F
  3667. ? ((F = 1 / F),
  3668. (e[0] = (o * P - h * I + l * k) * F),
  3669. (e[1] = (n * I - s * P - r * k) * F),
  3670. (e[2] = (p * w - g * T + v * S) * F),
  3671. (e[3] = (u * T - c * w - f * S) * F),
  3672. (e[4] = (h * A - a * P - l * R) * F),
  3673. (e[5] = (i * P - n * A + r * R) * F),
  3674. (e[6] = (g * b - m * w - v * y) * F),
  3675. (e[7] = (d * w - u * b + f * y) * F),
  3676. (e[8] = (a * I - o * A + l * C) * F),
  3677. (e[9] = (s * A - i * I - r * C) * F),
  3678. (e[10] = (m * T - p * b + v * x) * F),
  3679. (e[11] = (c * b - d * T - f * x) * F),
  3680. (e[12] = (o * R - a * k - h * C) * F),
  3681. (e[13] = (i * k - s * R + n * C) * F),
  3682. (e[14] = (p * y - m * S - g * x) * F),
  3683. (e[15] = (d * S - c * y + u * x) * F),
  3684. e)
  3685. : null;
  3686. },
  3687. transpose: function(e, t) {
  3688. return (
  3689. (e[0] = t[0]),
  3690. (e[4] = t[1]),
  3691. (e[8] = t[2]),
  3692. (e[12] = t[3]),
  3693. (e[1] = t[4]),
  3694. (e[5] = t[5]),
  3695. (e[9] = t[6]),
  3696. (e[13] = t[7]),
  3697. (e[2] = t[8]),
  3698. (e[6] = t[9]),
  3699. (e[10] = t[10]),
  3700. (e[14] = t[11]),
  3701. (e[3] = t[12]),
  3702. (e[7] = t[13]),
  3703. (e[11] = t[14]),
  3704. (e[15] = t[15]),
  3705. e
  3706. );
  3707. },
  3708. mul4: function(e, t, i, s, n, r) {
  3709. return (
  3710. (e[0] = t[0] * i + t[4] * s + t[8] * n + t[12] * r),
  3711. (e[1] = t[1] * i + t[5] * s + t[9] * n + t[13] * r),
  3712. (e[2] = t[2] * i + t[6] * s + t[10] * n + t[14] * r),
  3713. (e[3] = t[3] * i + t[7] * s + t[11] * n + t[15] * r),
  3714. e
  3715. );
  3716. },
  3717. mulPoint: function(e, t, i, s, n) {
  3718. return (
  3719. (e[0] = t[0] * i + t[4] * s + t[8] * n + t[12]),
  3720. (e[1] = t[1] * i + t[5] * s + t[9] * n + t[13]),
  3721. (e[2] = t[2] * i + t[6] * s + t[10] * n + t[14]),
  3722. e
  3723. );
  3724. },
  3725. mulVec: function(e, t, i, s, n) {
  3726. return (
  3727. (e[0] = t[0] * i + t[4] * s + t[8] * n),
  3728. (e[1] = t[1] * i + t[5] * s + t[9] * n),
  3729. (e[2] = t[2] * i + t[6] * s + t[10] * n),
  3730. e
  3731. );
  3732. },
  3733. perspective: function(e, t, i, s, n, r) {
  3734. return (
  3735. (r = r || 0),
  3736. (t = 1 / Math.tan(0.00872664625 * t)),
  3737. (e[0] = t / i),
  3738. (e[1] = e[2] = e[3] = 0),
  3739. (e[5] = t),
  3740. (e[4] = e[6] = e[7] = 0),
  3741. (e[8] = e[9] = 0),
  3742. (e[10] = (n + s) / (s - n) - 30518044e-12 * r),
  3743. (e[11] = -1),
  3744. (e[14] = (2 * n * s) / (s - n)),
  3745. (e[12] = e[13] = e[15] = 0),
  3746. e
  3747. );
  3748. },
  3749. perspectiveInfinite: function(e, t, i, s, n) {
  3750. return (
  3751. (n = n || 0),
  3752. (t = 1 / Math.tan(0.00872664625 * t)),
  3753. (e[0] = t / i),
  3754. (e[1] = e[2] = e[3] = 0),
  3755. (e[5] = t),
  3756. (e[4] = e[6] = e[7] = 0),
  3757. (e[8] = e[9] = 0),
  3758. (e[10] = e[11] = -1 - 30518044e-12 * n),
  3759. (e[14] = -2 * s),
  3760. (e[12] = e[13] = e[15] = 0),
  3761. e
  3762. );
  3763. },
  3764. ortho: function(e, t, i, s, n, r, a, o) {
  3765. var h = 1 / (i - t),
  3766. l = 1 / (n - s),
  3767. d = 1 / (a - r);
  3768. return (
  3769. (e[0] = h + h),
  3770. (e[1] = e[2] = e[3] = 0),
  3771. (e[5] = l + l),
  3772. (e[4] = e[6] = e[7] = 0),
  3773. (e[12] = -(i + t) * h),
  3774. (e[13] = -(n + s) * l),
  3775. (e[10] = -(d + d) - 30518044e-12 * (o || 0)),
  3776. (e[14] = -(a + r) * d),
  3777. (e[8] = e[9] = e[11] = 0),
  3778. (e[15] = 1),
  3779. e
  3780. );
  3781. },
  3782. lookAt: function(e, t, i, s) {
  3783. var n = e.subarray(0, 3),
  3784. r = e.subarray(4, 7),
  3785. a = e.subarray(8, 11);
  3786. V.sub(a, t, i),
  3787. V.cross(n, s, a),
  3788. V.normalize(a, a),
  3789. V.normalize(n, n),
  3790. V.cross(r, a, n),
  3791. S.set(
  3792. e,
  3793. n[0],
  3794. n[1],
  3795. n[2],
  3796. -V.dot(n, t),
  3797. r[0],
  3798. r[1],
  3799. r[2],
  3800. -V.dot(r, t),
  3801. a[0],
  3802. a[1],
  3803. a[2],
  3804. -V.dot(a, t),
  3805. 0,
  3806. 0,
  3807. 0,
  3808. 1
  3809. );
  3810. },
  3811. copy: function(e, t) {
  3812. for (var i = 0; i < 16; ++i) e[i] = t[i];
  3813. },
  3814. copyToBuffer: function(e, t, i) {
  3815. for (var s = 0; s < 16; ++s) e[t + s] = i[s];
  3816. },
  3817. };
  3818. function T(e, t, i) {
  3819. this.gl = e;
  3820. var s = (this.desc = t).isDynamicMesh;
  3821. (this.numSubMeshes = this.dynamicVertexData = 0),
  3822. (this.displayMatrix = S.identity()),
  3823. (this.name = t.name),
  3824. (this.modelMatrix = S.identity()),
  3825. (this.origin = t.transform
  3826. ? V.create(t.transform[12], t.transform[13], t.transform[14], 1)
  3827. : V.create(0, 5, 0, 1)),
  3828. (this.stride = 32),
  3829. (this.vertexColor = t.vertexColor) && (this.stride += 4),
  3830. (this.secondaryTexCoord = t.secondaryTexCoord) && (this.stride += 8),
  3831. (i = new u(i.data)),
  3832. (this.indexCount = t.indexCount),
  3833. (this.indexTypeSize = t.indexTypeSize),
  3834. (this.indexType =
  3835. 4 == this.indexTypeSize ? e.UNSIGNED_INT : e.UNSIGNED_SHORT),
  3836. (this.indexBuffer = e.createBuffer()),
  3837. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
  3838. var n = i.readBytes(this.indexCount * this.indexTypeSize);
  3839. e.bufferData(e.ELEMENT_ARRAY_BUFFER, n, e.STATIC_DRAW),
  3840. (this.wireCount = t.wireCount),
  3841. (this.wireBuffer = e.createBuffer()),
  3842. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.wireBuffer),
  3843. (n = i.readBytes(this.wireCount * this.indexTypeSize)),
  3844. e.bufferData(e.ELEMENT_ARRAY_BUFFER, n, e.STATIC_DRAW),
  3845. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null),
  3846. (this.vertexCount = t.vertexCount),
  3847. (this.vertexBuffer = e.createBuffer()),
  3848. e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer),
  3849. (i = i.readBytes(this.vertexCount * this.stride)),
  3850. s
  3851. ? ((this.dynamicVertexData = new Uint8Array(i)),
  3852. e.bufferData(e.ARRAY_BUFFER, i, e.DYNAMIC_DRAW))
  3853. : e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3854. e.bindBuffer(e.ARRAY_BUFFER, null),
  3855. (this.bounds =
  3856. void 0 === t.minBound || void 0 === t.maxBound
  3857. ? { min: V.create(-10, -10, -10, 1), max: V.create(10, 10, -0, 1) }
  3858. : {
  3859. min: V.create(t.minBound[0], t.minBound[1], t.minBound[2], 1),
  3860. max: V.create(t.maxBound[0], t.maxBound[1], t.maxBound[2], 1),
  3861. }),
  3862. (this.bounds.maxExtent = Math.max(
  3863. Math.max(
  3864. t.maxBound[0] - t.minBound[0],
  3865. t.maxBound[1] - t.minBound[1]
  3866. ),
  3867. t.maxBound[2] - t.minBound[2]
  3868. )),
  3869. (this.bounds.averageExtent =
  3870. (t.maxBound[0] -
  3871. t.minBound[0] +
  3872. (t.maxBound[1] - t.minBound[1]) +
  3873. (t.maxBound[2] - t.minBound[2])) /
  3874. 3);
  3875. }
  3876. function w(e, t, i) {
  3877. (this.mesh = e),
  3878. (this.gl = this.mesh.gl),
  3879. (this.indexOffset = t.firstIndex * e.indexTypeSize),
  3880. (this.indexCount = t.indexCount),
  3881. (this.wireIndexOffset = t.firstWireIndex * e.indexTypeSize),
  3882. (this.wireIndexCount = t.wireIndexCount),
  3883. (this.material = i),
  3884. (this.visible = !0);
  3885. }
  3886. (w.prototype.draw = function(e) {
  3887. var t = this.gl;
  3888. if (this.material.bind(e, this)) {
  3889. e = this.material.shader.attribs;
  3890. var i = this.mesh.stride;
  3891. this.mesh.desc.cullBackFaces
  3892. ? (t.enable(t.CULL_FACE), t.cullFace(t.BACK))
  3893. : t.disable(t.CULL_FACE),
  3894. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  3895. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  3896. t.enableVertexAttribArray(e.vPosition),
  3897. t.enableVertexAttribArray(e.vTexCoord),
  3898. t.enableVertexAttribArray(e.vTangent),
  3899. t.enableVertexAttribArray(e.vBitangent),
  3900. t.enableVertexAttribArray(e.vNormal);
  3901. var s = this.mesh.vertexColor && void 0 !== e.vColor;
  3902. s && t.enableVertexAttribArray(e.vColor);
  3903. var n = this.mesh.secondaryTexCoord && void 0 !== e.vTexCoord2;
  3904. n && t.enableVertexAttribArray(e.vTexCoord2);
  3905. var r = 0;
  3906. t.vertexAttribPointer(e.vPosition, 3, t.FLOAT, !1, i, r),
  3907. (r += 12),
  3908. t.vertexAttribPointer(e.vTexCoord, 2, t.FLOAT, !1, i, r),
  3909. (r += 8),
  3910. this.mesh.secondaryTexCoord &&
  3911. (n && t.vertexAttribPointer(e.vTexCoord2, 2, t.FLOAT, !1, i, r),
  3912. (r += 8)),
  3913. t.vertexAttribPointer(e.vTangent, 2, t.UNSIGNED_SHORT, !0, i, r),
  3914. (r += 4),
  3915. t.vertexAttribPointer(e.vBitangent, 2, t.UNSIGNED_SHORT, !0, i, r),
  3916. (r += 4),
  3917. t.vertexAttribPointer(e.vNormal, 2, t.UNSIGNED_SHORT, !0, i, r),
  3918. s &&
  3919. t.vertexAttribPointer(e.vColor, 4, t.UNSIGNED_BYTE, !0, i, r + 4),
  3920. t.drawElements(
  3921. t.TRIANGLES,
  3922. this.indexCount,
  3923. this.mesh.indexType,
  3924. this.indexOffset
  3925. ),
  3926. t.disableVertexAttribArray(e.vPosition),
  3927. t.disableVertexAttribArray(e.vTexCoord),
  3928. t.disableVertexAttribArray(e.vTangent),
  3929. t.disableVertexAttribArray(e.vBitangent),
  3930. t.disableVertexAttribArray(e.vNormal),
  3931. s && t.disableVertexAttribArray(e.vColor),
  3932. n && t.disableVertexAttribArray(e.vTexCoord2);
  3933. }
  3934. }),
  3935. (w.prototype.drawShadow = function(e) {
  3936. var t = this.gl;
  3937. this.mesh.desc.cullBackFaces
  3938. ? (t.enable(t.CULL_FACE), t.cullFace(t.BACK))
  3939. : t.disable(t.CULL_FACE),
  3940. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  3941. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  3942. t.enableVertexAttribArray(e),
  3943. t.vertexAttribPointer(e, 3, t.FLOAT, !1, this.mesh.stride, 0),
  3944. t.drawElements(
  3945. t.TRIANGLES,
  3946. this.indexCount,
  3947. this.mesh.indexType,
  3948. this.indexOffset
  3949. ),
  3950. t.disableVertexAttribArray(e);
  3951. }),
  3952. (w.prototype.drawAlphaShadow = function(e, t) {
  3953. var i = this.gl;
  3954. this.mesh.desc.cullBackFaces
  3955. ? (i.enable(i.CULL_FACE), i.cullFace(i.BACK))
  3956. : i.disable(i.CULL_FACE),
  3957. i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  3958. i.bindBuffer(i.ARRAY_BUFFER, this.mesh.vertexBuffer),
  3959. i.enableVertexAttribArray(e),
  3960. i.enableVertexAttribArray(t),
  3961. i.vertexAttribPointer(e, 3, i.FLOAT, !1, this.mesh.stride, 0),
  3962. i.vertexAttribPointer(t, 2, i.FLOAT, !1, this.mesh.stride, 12),
  3963. i.drawElements(
  3964. i.TRIANGLES,
  3965. this.indexCount,
  3966. this.mesh.indexType,
  3967. this.indexOffset
  3968. ),
  3969. i.disableVertexAttribArray(e),
  3970. i.disableVertexAttribArray(t);
  3971. }),
  3972. (w.prototype.drawAlphaPrepass = function(e) {
  3973. var t = this.gl;
  3974. if (this.material.bindAlphaPrepass(e, this)) {
  3975. e = this.material.prepassShader.attribs;
  3976. var i = this.mesh.stride;
  3977. this.mesh.desc.cullBackFaces
  3978. ? (t.enable(t.CULL_FACE), t.cullFace(t.BACK))
  3979. : t.disable(t.CULL_FACE),
  3980. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  3981. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  3982. t.enableVertexAttribArray(e.vPosition),
  3983. t.enableVertexAttribArray(e.vTexCoord),
  3984. t.vertexAttribPointer(e.vPosition, 3, t.FLOAT, !1, i, 0),
  3985. t.vertexAttribPointer(e.vTexCoord, 2, t.FLOAT, !1, i, 12),
  3986. t.drawElements(
  3987. t.TRIANGLES,
  3988. this.indexCount,
  3989. this.mesh.indexType,
  3990. this.indexOffset
  3991. ),
  3992. t.disableVertexAttribArray(e.vPosition),
  3993. t.disableVertexAttribArray(e.vTexCoord);
  3994. }
  3995. }),
  3996. (w.prototype.drawWire = function(e) {
  3997. var t = this.material.wireShader.attribs,
  3998. i = this.gl;
  3999. this.material.bindWire(e, this) &&
  4000. (i.enableVertexAttribArray(t.vPosition),
  4001. i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.mesh.wireBuffer),
  4002. i.bindBuffer(i.ARRAY_BUFFER, this.mesh.vertexBuffer),
  4003. i.vertexAttribPointer(
  4004. t.vPosition,
  4005. 3,
  4006. i.FLOAT,
  4007. !1,
  4008. this.mesh.stride,
  4009. 0
  4010. ),
  4011. i.drawElements(
  4012. i.LINES,
  4013. this.wireIndexCount,
  4014. this.mesh.indexType,
  4015. this.wireIndexOffset
  4016. ),
  4017. i.disableVertexAttribArray(t.vPosition));
  4018. }),
  4019. (w.prototype.complete = function() {
  4020. return this.material.complete();
  4021. });
  4022. var C = {
  4023. fetchImage: function(e, t, i) {
  4024. var s = new Image();
  4025. (s.crossOrigin = "Anonymous"),
  4026. (s.onload = function() {
  4027. 0 < s.width && 0 < s.height ? t(s) : i && i();
  4028. }),
  4029. i &&
  4030. (req.onerror = function() {
  4031. i();
  4032. }),
  4033. (s.src = e);
  4034. },
  4035. fetchText: function(e, t, i, s) {
  4036. var n = new XMLHttpRequest();
  4037. n.open("GET", e, !0),
  4038. (n.onload = function() {
  4039. 200 == n.status ? t(n.responseText) : i && i();
  4040. }),
  4041. i &&
  4042. (n.onerror = function() {
  4043. i();
  4044. }),
  4045. s &&
  4046. (n.onprogress = function(e) {
  4047. s(e.loaded, e.total);
  4048. }),
  4049. n.send();
  4050. },
  4051. fetchBinary: function(e, t, i, s) {
  4052. var n = new XMLHttpRequest();
  4053. n.open("GET", e, !0),
  4054. (n.responseType = "arraybuffer"),
  4055. (n.onload = function() {
  4056. 200 == n.status ? t(n.response) : i && i();
  4057. }),
  4058. i &&
  4059. (n.onerror = function() {
  4060. i();
  4061. }),
  4062. s &&
  4063. (n.onprogress = function(e) {
  4064. s(e.loaded, e.total);
  4065. }),
  4066. n.send();
  4067. },
  4068. fetchBinaryIncremental: function(r, a, t, o) {
  4069. var i = new XMLHttpRequest();
  4070. i.open("HEAD", r, !0),
  4071. (i.onload = function() {
  4072. if (200 == i.status) {
  4073. var e = i.getResponseHeader("Accept-Ranges");
  4074. if (e && "none" != e) {
  4075. var s = 0 | i.getResponseHeader("Content-Length"),
  4076. n = function(e, t) {
  4077. var i = new XMLHttpRequest();
  4078. i.open("GET", r, !0),
  4079. i.setRequestHeader("Range", "bytes=" + e + "-" + t),
  4080. (i.responseType = "arraybuffer"),
  4081. (i.onload = function() {
  4082. (206 == i.status || 200 == i.status) &&
  4083. a(i.response) &&
  4084. t < s &&
  4085. n((e += o), (t = (t += o) < s - 1 ? t : s - 1));
  4086. }),
  4087. i.send();
  4088. };
  4089. n(0, o - 1);
  4090. } else t && t();
  4091. } else t && t();
  4092. }),
  4093. t &&
  4094. (i.onerror = function() {
  4095. t();
  4096. }),
  4097. i.send();
  4098. },
  4099. };
  4100. function R(e) {
  4101. (this.debugString = ""),
  4102. (this.init = !1),
  4103. (this.speedList = this.cameraList = this.animationList = this.playButton = this.timelineSlider = this.playbackRegion = this.previousFrameButton = this.nextFrameButton = this.pauseButton = this.playButton = 0),
  4104. (this.visible = !1),
  4105. (this.backgroundRegion = this.screenButton = 0),
  4106. (this.guiScreen = e),
  4107. (this.playbackRegion = new v(e)),
  4108. (this.idealSliderWidth = 650),
  4109. (this.totalListBoxPixelsX = 0),
  4110. (this.minWidth = 500),
  4111. (this.compactMode = !1),
  4112. (this.ui = e.ui);
  4113. var t = "animationpause" + e.imageSetNumber + "x.png",
  4114. i = "animationplay" + e.imageSetNumber + "x.png",
  4115. s = "timelineLE" + e.imageSetNumber + "x.png",
  4116. n = "timelineM" + e.imageSetNumber + "x.png",
  4117. r = "timelineRE" + e.imageSetNumber + "x.png",
  4118. a = e.ui.viewer.scene.sceneAnimator.animations.length;
  4119. if (0 != a) {
  4120. var o = this.idealSliderWidth;
  4121. (this.bottomOffset = 85), (this.centerOffset = 60);
  4122. var h,
  4123. l = (h = e.width / 2 + this.centerOffset) - o / 2,
  4124. d = l - 14 - 32,
  4125. c = (h = h + o / 2) - d,
  4126. u = 32 / e.height,
  4127. f = this.bottomOffset / e.height,
  4128. m = this.playbackRegion;
  4129. if (
  4130. ((m.controlRect.widthPercent = c / e.width),
  4131. (m.controlRect.heightPercent = u),
  4132. (m.controlRect.xPercent = d / e.width),
  4133. (m.controlRect.yPercent = f),
  4134. (u = 32 / c),
  4135. (this.pauseButton = new p(this.guiScreen)),
  4136. this.pauseButton.controlRect.set(0, 0.125, u, 0.75),
  4137. (this.pauseButton.controlRect.opacity = 0.5),
  4138. m.controlRect.registerChildControlRect(this.pauseButton.controlRect),
  4139. this.pauseButton.linkControl(
  4140. m.addImageElement(this.pauseButton.controlRect, t)
  4141. ),
  4142. (this.playButton = new p(this.guiScreen)),
  4143. this.playButton.controlRect.set(0, 0.125, u, 0.75),
  4144. (this.playButton.controlRect.opacity = 0.5),
  4145. m.controlRect.registerChildControlRect(this.playButton.controlRect),
  4146. this.playButton.linkControl(
  4147. m.addImageElement(this.playButton.controlRect, i)
  4148. ),
  4149. (t = o / c),
  4150. (c = (l - d) / c),
  4151. (this.timelineSlider = new z(this.guiScreen, m)),
  4152. this.timelineSlider.controlRect.set(c, 0.03125, t, 1),
  4153. m.controlRect.registerChildControlRect(
  4154. this.timelineSlider.controlRect
  4155. ),
  4156. this.timelineSlider.setBackground3x1(m, s, n, r),
  4157. this.pauseButton.controlRect.showControl(
  4158. !e.ui.viewer.scene.sceneAnimator.paused
  4159. ),
  4160. this.playButton.controlRect.showControl(
  4161. e.ui.viewer.scene.sceneAnimator.paused
  4162. ),
  4163. (s = h + 14),
  4164. (n = this.bottomOffset + 4),
  4165. (r =
  4166. e.ui.viewer.scene.sceneAnimator.animations[0].cameraObjects.length),
  4167. e.ui.viewer.scene.sceneAnimator.selectDefaultCamera(),
  4168. e.ui.viewer.scene.sceneAnimator.setViewFromSelectedCamera(),
  4169. (this.maxListPixelsX = 0),
  4170. 1 < r)
  4171. ) {
  4172. for (this.cameraList = new y(e), c = 0; c < r; c++)
  4173. this.cameraList.addItem(
  4174. e.ui.viewer.scene.sceneAnimator.animations[0].cameraObjects[c]
  4175. .name,
  4176. 0,
  4177. 0
  4178. );
  4179. this.cameraList.spawnControl(s, n, 10, 24, !0, 8),
  4180. this.cameraList.selectItem(
  4181. e.ui.viewer.scene.sceneAnimator.selectedCameraIndex
  4182. ),
  4183. (this.maxListPixelsX = this.cameraList.localPixelsX),
  4184. (this.totalListBoxPixelsX += this.cameraList.localPixelsX + 14);
  4185. }
  4186. if (1 < a) {
  4187. for (this.animationList = new y(e), c = 0; c < a; c++)
  4188. this.animationList.addItem(
  4189. e.ui.viewer.scene.sceneAnimator.animations[c].name,
  4190. 0,
  4191. 0
  4192. );
  4193. this.animationList.spawnControl(s, n, 10, 24, !0, 8),
  4194. this.maxListPixelsX < this.animationList.localPixelsX &&
  4195. (this.maxListPixelsX = this.animationList.localPixelsX),
  4196. (this.totalListBoxPixelsX += this.animationList.localPixelsX + 14),
  4197. this.animationList.selectItem(
  4198. e.ui.viewer.scene.sceneAnimator.selectedAnimationIndex
  4199. );
  4200. }
  4201. (c = h - (s = d - 44 - 14) + this.totalListBoxPixelsX),
  4202. (this.speedList = new y(e)),
  4203. this.speedList.addItem("4.0x", 4, 0),
  4204. this.speedList.addItem("2.0x", 4, 0),
  4205. this.speedList.addItem("1.0x", 4, 0),
  4206. this.speedList.addItem("0.5x", 4, 0),
  4207. this.speedList.addItem("0.25x", -2, 0),
  4208. this.speedList.spawnControl(s, n, 44, 24, !1, 0),
  4209. this.speedList.selectItem(2),
  4210. c > e.width &&
  4211. ((this.idealSliderWidth =
  4212. e.width -
  4213. (118 + (this.totalListBoxPixelsX + 14)) -
  4214. this.centerOffset),
  4215. (e = 0),
  4216. this.cameraList && e++,
  4217. this.animationList && e++,
  4218. 1 == e &&
  4219. ((this.idealSliderWidth += 56), (this.centerOffset -= 14)),
  4220. 2 == e &&
  4221. ((this.idealSliderWidth += 63), (this.centerOffset -= 63))),
  4222. this.setupCallbacks();
  4223. }
  4224. }
  4225. function A(e, t, i) {
  4226. if (
  4227. ((this.gl = e),
  4228. (this.desc = t),
  4229. (t = []),
  4230. 0 != this.desc.sharpen && t.push("#define SHARPEN"),
  4231. (this.useBloom =
  4232. 0 < this.desc.bloomColor[0] * this.desc.bloomColor[3] ||
  4233. 0 < this.desc.bloomColor[1] * this.desc.bloomColor[3] ||
  4234. 0 < this.desc.bloomColor[2] * this.desc.bloomColor[3]) &&
  4235. t.push("#define BLOOM"),
  4236. 0 != this.desc.vignette[3] && t.push("#define VIGNETTE"),
  4237. (1 == this.desc.saturation[0] * this.desc.saturation[3] &&
  4238. 1 == this.desc.saturation[1] * this.desc.saturation[3] &&
  4239. 1 == this.desc.saturation[2] * this.desc.saturation[3]) ||
  4240. t.push("#define SATURATION"),
  4241. (1 == this.desc.contrast[0] * this.desc.contrast[3] &&
  4242. 1 == this.desc.contrast[1] * this.desc.contrast[3] &&
  4243. 1 == this.desc.contrast[2] * this.desc.contrast[3] &&
  4244. 1 == this.desc.brightness[0] * this.desc.brightness[3] &&
  4245. 1 == this.desc.brightness[1] * this.desc.brightness[3] &&
  4246. 1 == this.desc.brightness[2] * this.desc.brightness[3]) ||
  4247. t.push("#define CONTRAST"),
  4248. 0 != this.desc.grain && t.push("#define GRAIN"),
  4249. 1 == this.desc.toneMap
  4250. ? t.push("#define REINHARD")
  4251. : 2 == this.desc.toneMap && t.push("#define HEJL"),
  4252. this.desc.colorLUT && t.push("#define COLOR_LUT"),
  4253. (this.sampleIndex = 0),
  4254. (this.sampleCount = 1),
  4255. i &&
  4256. ((this.sampleCount = 4),
  4257. (this.sampleOffsets = [
  4258. [-0.5, -0.5],
  4259. [0.5, -0.5],
  4260. [-0.5, 0.5],
  4261. [0.5, 0.5],
  4262. ])),
  4263. (this.aaShader = e.shaderCache.fromURLs(
  4264. "postvert.glsl",
  4265. "postaa.glsl"
  4266. )),
  4267. (this.shader = e.shaderCache.fromURLs(
  4268. "postvert.glsl",
  4269. "postfrag.glsl",
  4270. t
  4271. )),
  4272. (this.plainShader = e.shaderCache.fromURLs(
  4273. "postvert.glsl",
  4274. "postfrag.glsl",
  4275. []
  4276. )),
  4277. (this.fullscreenTriangle = e.createBuffer()),
  4278. e.bindBuffer(e.ARRAY_BUFFER, this.fullscreenTriangle),
  4279. (i = new Float32Array([0, 0, 2, 0, 0, 2])),
  4280. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  4281. e.bindBuffer(e.ARRAY_BUFFER, null),
  4282. this.useBloom)
  4283. ) {
  4284. for (this.bloomTextures = [], this.bloomTargets = [], i = 0; i < 2; ++i)
  4285. (t = { width: 256, height: 256, clamp: !0 }),
  4286. (this.bloomTextures[i] = new U(e, t)),
  4287. this.bloomTextures[i].loadArray(
  4288. null,
  4289. e.RGBA,
  4290. e.ext.textureHalf && e.ext.textureHalfLinear
  4291. ? e.ext.textureHalf.HALF_FLOAT_OES
  4292. : e.UNSIGNED_BYTE
  4293. ),
  4294. (this.bloomTargets[i] = new m(e, {
  4295. width: t.width,
  4296. height: t.height,
  4297. color0: this.bloomTextures[i],
  4298. }));
  4299. for (
  4300. this.bloomSamples = 64;
  4301. this.bloomSamples + 16 >= e.limits.fragmentUniforms;
  4302. )
  4303. this.bloomSamples /= 2;
  4304. (this.bloomShader = e.shaderCache.fromURLs(
  4305. "postvert.glsl",
  4306. "bloom.glsl",
  4307. ["#define BLOOM_SAMPLES " + this.bloomSamples]
  4308. )),
  4309. (this.shrinkShader = e.shaderCache.fromURLs(
  4310. "postvert.glsl",
  4311. "bloomshrink.glsl"
  4312. ));
  4313. }
  4314. for (e = new Uint8Array(16384), i = 0; i < 16384; i++) {
  4315. t = 255 * Math.random();
  4316. var s = 255 * Math.random();
  4317. e[i] = 0.5 * (t + s);
  4318. }
  4319. (this.noiseTexture = new U(this.gl, { width: 128, height: 128 })),
  4320. this.noiseTexture.loadArray(e, this.gl.LUMINANCE),
  4321. this.desc.colorLUT &&
  4322. ((e = this.desc.colorLUT),
  4323. (this.colorLUT = new U(this.gl, {
  4324. width: (e.length / 3) | 0,
  4325. height: 1,
  4326. clamp: !0,
  4327. })),
  4328. this.colorLUT.loadArray(new Uint8Array(e), this.gl.RGB)),
  4329. (this.blackTexture = new U(this.gl, { width: 1, height: 1 })),
  4330. this.blackTexture.loadArray(new Uint8Array([0, 0, 0, 0])),
  4331. (this.bloomResult = this.blackTexture);
  4332. }
  4333. function k(e) {
  4334. (this.gl = e),
  4335. (this.name = "untitled"),
  4336. (this.meshes = []),
  4337. (this.meshRenderables = []),
  4338. (this.materials = {}),
  4339. (this.sky = this.view = null),
  4340. (this.selectedPartIndex = 0),
  4341. (this.soloPart = !1),
  4342. (this.miscnotes = ""),
  4343. (this.nextView = null),
  4344. (this.viewFade = 0),
  4345. (this.refractionSurface = this.shadow = this.stripData = this.lights = null),
  4346. (this.sceneAnimator = this.frameCounter = 0),
  4347. (this.sceneLoaded = !1),
  4348. (this.debugString = "");
  4349. }
  4350. function P(e, t, i) {
  4351. if (
  4352. ((this.scene = e),
  4353. (this.animations = []),
  4354. (this.skinningRigs = []),
  4355. (this.meshIDs = []),
  4356. (this.lightIDs = []),
  4357. (this.materialIDs = []),
  4358. (this.views = []),
  4359. (this.viewYawOffsets = []),
  4360. (this.viewPitchOffsets = []),
  4361. (this.cameraObjectIndices = []),
  4362. (this.cameraChildrenIndices = []),
  4363. (this.subMeshObjectIndices = []),
  4364. (this.subMeshLiveIndices = []),
  4365. (this.scene = e),
  4366. (this.selectedCameraIndex = -1),
  4367. (this.selectedAnimationIndex = 0),
  4368. (this.debugString = ""),
  4369. (this.scenePlaybackSpeed = this.playbackSpeed = 1),
  4370. (this.animationProgress = this.totalSeconds = 0),
  4371. (this.paused = this.autoAdvanceNextAnimation = !1),
  4372. (this.animateVisibility = this.drawAnimated = this.linkSceneObjects = this.loadSkinningRigs = this.animateMaterials = this.animateTurntables = this.enableSkinning = this.animateMeshes = this.animateLights = this.playAnimations = this.loadAnimations = !0),
  4373. (this.showDebugInfo = !1),
  4374. (this.loopCount = 0),
  4375. (this.loopTurntables = this.lockPlayback = !1),
  4376. (this.fogObjectIndex = -1),
  4377. (this.unitScaleSkinnedMeshes = !0),
  4378. (this.sceneScale = i.sceneScale),
  4379. (this.defaultCameraGlobalIndex = i.selectedCamera),
  4380. (this.selectedAnimationIndex = i.selectedAnimation),
  4381. (this.autoPlayAnims = i.autoPlayAnims),
  4382. (this.showPlayControls = i.showPlayControls),
  4383. i.scenePlaybackSpeed &&
  4384. ((this.scenePlaybackSpeed = i.scenePlaybackSpeed),
  4385. 0 == this.scenePlaybackSpeed && (this.scenePlaybackSpeed = 1)),
  4386. this.autoPlayAnims || (this.paused = !0),
  4387. this.loadAnimations)
  4388. ) {
  4389. if (i.meshIDs)
  4390. for (var s = i.meshIDs.length, n = 0; n < s; ++n) {
  4391. var r = i.meshIDs[n].partIndex;
  4392. this.meshIDs.push(r);
  4393. }
  4394. if (i.lightIDs)
  4395. for (s = i.lightIDs.length, n = 0; n < s; ++n)
  4396. (r = (r = i.lightIDs[n]).partIndex), this.lightIDs.push(r);
  4397. if (i.materialIDs)
  4398. for (s = i.materialIDs.length, n = 0; n < s; ++n)
  4399. (r = (r = i.materialIDs[n]).partIndex), this.materialIDs.push(r);
  4400. if (
  4401. ((this.numMatricesInTable = i.numMatrices),
  4402. (r = new u((n = t.get("MatTable.bin")).data)),
  4403. n ||
  4404. ((this.numMatricesInTable = 0),
  4405. (this.debugString += "<br>No mattable?")),
  4406. i.skinningRigs && this.loadSkinningRigs)
  4407. )
  4408. for (s = i.skinningRigs.length, n = 0; n < s; ++n) {
  4409. "" == (a = new M(t, i.skinningRigs[n], r)).debugString
  4410. ? this.skinningRigs.push(a)
  4411. : ((this.debugString +=
  4412. "<br>Error loading skinning rig " + n + " :" + a.debugString),
  4413. (this.debugString += "<br>Skipping the rest"),
  4414. (n = s));
  4415. }
  4416. if (i.animations)
  4417. for (r = i.animations.length, n = 0; n < r; ++n)
  4418. (s = new c(t, i.animations[n])), this.animations.push(s);
  4419. if (
  4420. ((this.startMS = Date.now()),
  4421. (r = this.animations.length),
  4422. this.linkSceneObjects && 0 != r)
  4423. ) {
  4424. for (n = 0; n < r; n++)
  4425. for (
  4426. s = (t = this.animations[n]).animatedObjects.length, i = 0;
  4427. i < s;
  4428. i++
  4429. )
  4430. "LightSO" == (a = t.animatedObjects[i]).sceneObjectType &&
  4431. ((a.lightIndex = this.findLightIndexByPartIndex(i)),
  4432. -1 != a.lightIndex
  4433. ? t.lightObjects.push(a)
  4434. : (this.debugString +=
  4435. "<br> got light not in scene " + a.name)),
  4436. "FogSO" == a.sceneObjectType && (this.fogObjectIndex = i),
  4437. "SubMeshSO" == a.sceneObjectType &&
  4438. 0 == n &&
  4439. (this.subMeshObjectIndices.push(i),
  4440. this.subMeshLiveIndices.push(-1)),
  4441. "Material" == a.sceneObjectType &&
  4442. ((a.materialIndex = this.findMaterialIndexByPartIndex(i)),
  4443. -1 == a.materialIndex
  4444. ? (this.debugString +=
  4445. "<br> can't find material index for object " + i)
  4446. : t.materialObjects.push(a)),
  4447. "TurnTableSO" == a.sceneObjectType &&
  4448. t.turnTableObjects.push(a),
  4449. "MeshSO" == a.sceneObjectType &&
  4450. ((a.meshIndex = this.findMeshIndexByPartIndex(
  4451. this.scene.meshes,
  4452. i
  4453. )),
  4454. -1 == a.meshIndex
  4455. ? ((this.debugString +=
  4456. "<br> can't find mesh index for object " + i),
  4457. this.logObjectInfo(i, 0))
  4458. : (t.meshObjects.push(a),
  4459. (a.mesh = this.scene.meshes[a.meshIndex]),
  4460. -1 != a.skinningRigIndex &&
  4461. a.mesh &&
  4462. a.skinningRigIndex < this.skinningRigs.length &&
  4463. ((a.skinningRig = this.skinningRigs[
  4464. a.skinningRigIndex
  4465. ]),
  4466. a.skinningRig.isRigidSkin ||
  4467. (a.mesh.dynamicVertexData
  4468. ? a.skinningRig.useOriginalMeshVertices(a.mesh)
  4469. : ((this.debugString +=
  4470. "Skinning object - but mesh is not dynamic"),
  4471. (this.debugString +=
  4472. "<br>Rig index " + a.skinningRigIndex),
  4473. (this.debugString += " not tagged as rigid")))))),
  4474. "CameraSO" == a.sceneObjectType &&
  4475. ((a.modelPartIndex = a.id), t.cameraObjects.push(a));
  4476. for (
  4477. i = (t = this.animations[0]).cameraObjects.length, n = 0;
  4478. n < i;
  4479. n++
  4480. )
  4481. (r = t.cameraObjects[n]),
  4482. (s = this.scene.cameras[r.name])
  4483. ? (s = s.view) &&
  4484. ((s = new H(s)),
  4485. this.cameraObjectIndices.push(r.id),
  4486. this.views.push(s),
  4487. this.viewYawOffsets.push(0),
  4488. this.viewPitchOffsets.push(0))
  4489. : ((this.debugString += "<br>no camDesc for " + r.name),
  4490. this.views.push(e.view));
  4491. for (
  4492. e = this.scene.meshes.length,
  4493. r = this.subMeshObjectIndices.length,
  4494. n = s = 0;
  4495. n < e;
  4496. n++
  4497. ) {
  4498. var a = this.scene.meshes[n],
  4499. o = !1;
  4500. for (i = 0; i < r; i++) {
  4501. var h = this.subMeshObjectIndices[i],
  4502. l = t.animatedObjects[h],
  4503. d = t.animatedObjects[l.parentIndex];
  4504. if (
  4505. (d.mesh ||
  4506. ((this.debugString +=
  4507. "<br>submesh parent object has no mesh?"),
  4508. (this.debugString += "<br>obj.name " + l.name),
  4509. (this.debugString += "<br>parent.name " + d.name),
  4510. (this.debugString += "<br>submesh index " + i),
  4511. (this.debugString += "<br>obj.index " + h)),
  4512. d.mesh == a)
  4513. ) {
  4514. for (o = 0; o < a.numSubMeshes; o++)
  4515. (this.subMeshLiveIndices[i + (a.numSubMeshes - 1 - o)] = s),
  4516. s++;
  4517. (i = r), (o = !0);
  4518. }
  4519. }
  4520. o ||
  4521. (this.debugString +=
  4522. "<br>Missing submesh? - no matches for mesh " + n + " of " + e);
  4523. }
  4524. for (n = 0; n < r; n++)
  4525. -1 == this.subMeshLiveIndices[n] &&
  4526. (this.debugString +=
  4527. "<br>Missing mesh? Unused submesh " + n + " of " + r);
  4528. (this.showDebugInfo = this.stopEverything = this.runDebugMode = !1),
  4529. this.selectDefaultCamera(),
  4530. this.findCameraChildren(),
  4531. this.findFixedTransforms(),
  4532. this.runDebugMode &&
  4533. (this.setAnimationProgress(0, !0),
  4534. "" != this.debugString
  4535. ? (this.stopEverything = !0)
  4536. : this.checkDebug());
  4537. }
  4538. } else this.debugString += "<br>Skip loading animation data";
  4539. }
  4540. function F(e) {
  4541. (this.gl = e),
  4542. (this.program = null),
  4543. (this.params = {}),
  4544. (this.samplers = {}),
  4545. (this.attribs = {});
  4546. }
  4547. function O(e) {
  4548. (this.gl = e), (this.cache = []);
  4549. }
  4550. function E(e, t) {
  4551. if (
  4552. ((this.gl = e),
  4553. (this.shadowCount = t),
  4554. (this.nativeDepth = !!e.ext.textureDepth),
  4555. (this.desc = i),
  4556. (i = this.nativeDepth ? ["#define SHADOW_NATIVE_DEPTH"] : []),
  4557. (this.shaderSolid = e.shaderCache.fromURLs(
  4558. "shadowvert.glsl",
  4559. "shadowfrag.glsl",
  4560. i
  4561. )),
  4562. i.push("#define ALPHA_TEST 1"),
  4563. (this.shaderAlphaTest = e.shaderCache.fromURLs(
  4564. "shadowvert.glsl",
  4565. "shadowfrag.glsl",
  4566. i
  4567. )),
  4568. (this.depthTextures = []),
  4569. (this.depthTargets = []),
  4570. 0 < this.shadowCount)
  4571. ) {
  4572. var i = {
  4573. width: 2048,
  4574. height: 2048,
  4575. clamp: !0,
  4576. mipmap: !1,
  4577. nofilter: !0,
  4578. };
  4579. e.hints.mobile && (i.width = i.height = 1536);
  4580. var s,
  4581. n,
  4582. r = { width: i.width, height: i.height };
  4583. n = this.nativeDepth
  4584. ? ((s = e.DEPTH_COMPONENT), e.UNSIGNED_SHORT)
  4585. : ((r.depthBuffer = m.createDepthBuffer(e, i.width, i.height)),
  4586. (s = e.RGB),
  4587. e.UNSIGNED_BYTE);
  4588. for (var a = 0; a < this.shadowCount; ++a)
  4589. (this.depthTextures[a] = new U(e, i)),
  4590. this.depthTextures[a].loadArray(null, s, n),
  4591. this.nativeDepth
  4592. ? (r.depth = this.depthTextures[a])
  4593. : (r.color0 = this.depthTextures[a]),
  4594. (this.depthTargets[a] = new m(e, r));
  4595. }
  4596. }
  4597. function B(e, t, i, s) {
  4598. (this.gl = e),
  4599. (this.desc = t),
  4600. (this.lightCount = s.count),
  4601. (this.shadowCount = i.shadowCount),
  4602. (t = this.nativeDepth ? ["#define SHADOW_NATIVE_DEPTH"] : []).push(
  4603. "#define LIGHT_COUNT " + this.lightCount
  4604. ),
  4605. t.push("#define SHADOW_COUNT " + this.shadowCount),
  4606. e.hints.mobile && t.push("#define MOBILE"),
  4607. (this.shader = e.shaderCache.fromURLs(
  4608. "shadowfloorvert.glsl",
  4609. "shadowfloorfrag.glsl",
  4610. t
  4611. )),
  4612. (t = new Float32Array([
  4613. -1,
  4614. 0,
  4615. -1,
  4616. -1,
  4617. 0,
  4618. 1,
  4619. 1,
  4620. 0,
  4621. 1,
  4622. -1,
  4623. 0,
  4624. -1,
  4625. 1,
  4626. 0,
  4627. 1,
  4628. 1,
  4629. 0,
  4630. -1,
  4631. ])),
  4632. (this.quadGeom = e.createBuffer()),
  4633. e.bindBuffer(e.ARRAY_BUFFER, this.quadGeom),
  4634. e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW),
  4635. e.bindBuffer(e.ARRAY_BUFFER, null);
  4636. }
  4637. function L() {
  4638. (this.associateObjectIndex = this.linkObjectIndex = this.linkMode = 0),
  4639. (this.vertexIndices = []),
  4640. (this.vertexWeights = []),
  4641. (this.matrix = S.identity()),
  4642. (this.defaultAssociateWorldTransform = this.defaultClusterWorldTransform = this.defaultClusterBaseTransform = 0),
  4643. (this.defaultClusterWorldTransformInvert = S.identity()),
  4644. (this.defaultAssociateWorldTransformInvert = S.identity()),
  4645. (this.debugString = "");
  4646. }
  4647. function M(e, t, i) {
  4648. if (
  4649. ((this.debugString = ""),
  4650. (this.skinningClusters = []),
  4651. (this.srcVFile = t.file),
  4652. (e = e.get(this.srcVFile)))
  4653. )
  4654. if (e.data) {
  4655. (this.rigByteStream = new u(e.data)),
  4656. (e = new Uint32Array(
  4657. this.rigByteStream.bytes.buffer,
  4658. 0,
  4659. this.rigByteStream.bytes.length / 4
  4660. )),
  4661. (this.expectedNumClusters = e[0]),
  4662. (this.expectedNumVertices = e[1]),
  4663. (this.numClusterLinks = e[2]),
  4664. (this.originalObjectIndex = e[3]),
  4665. (this.isRigidSkin = e[4]),
  4666. (this.tangentMethod = e[5]),
  4667. (t = 6 + 7 * this.expectedNumClusters);
  4668. for (var s = 0; s < this.expectedNumClusters; s++) {
  4669. var n = new L();
  4670. this.skinningClusters.push(n);
  4671. var r = 6 + 7 * s;
  4672. (n.linkMode = e[1 + r]),
  4673. (n.linkObjectIndex = e[2 + r]),
  4674. (n.associateObjectIndex = e[3 + r]);
  4675. var a = e[5 + r];
  4676. (n.defaultClusterWorldTransform = i.getMatrix(e[4 + r])),
  4677. (n.defaultClusterBaseTransform = i.getMatrix(a)),
  4678. S.invert(
  4679. n.defaultClusterWorldTransformInvert,
  4680. n.defaultClusterWorldTransform
  4681. ),
  4682. 1 == n.linkMode &&
  4683. ((n.defaultAssociateWorldTransform = i.getMatrix(e[6 + r])),
  4684. S.invert(
  4685. n.defaultAssociateWorldTransformInvert,
  4686. n.defaultAssociateWorldTransform
  4687. ));
  4688. }
  4689. (e =
  4690. (t = (i = 4 * t) + this.expectedNumVertices) +
  4691. 2 * this.numClusterLinks),
  4692. (t = new Uint8Array(this.rigByteStream.bytes.subarray(t))),
  4693. (e = new Uint8Array(this.rigByteStream.bytes.subarray(e))),
  4694. (this.linkMapCount = new Uint8Array(
  4695. this.rigByteStream.bytes.buffer,
  4696. i,
  4697. this.expectedNumVertices
  4698. )),
  4699. (this.linkMapClusterIndices = new Uint16Array(t.buffer)),
  4700. (this.linkMapWeights = new Float32Array(e.buffer));
  4701. } else this.debugString += "<br>No data in " + this.srcVFile;
  4702. else
  4703. this.debugString +=
  4704. "<br>Error loading buffer for skinning rig " + this.srcVFile;
  4705. }
  4706. function _(e, t, i) {
  4707. if (
  4708. ((this.gl = e),
  4709. void 0 !== (s = t.extract("sky.dat") || t.extract("sky.png")))
  4710. ) {
  4711. (this.specularTexture = new U(e, {
  4712. width: 256,
  4713. height: 2048,
  4714. clamp: !0,
  4715. })),
  4716. (t = s.data);
  4717. for (
  4718. var s,
  4719. n = (s = s.data.length) / 4,
  4720. r = new Uint8Array(s),
  4721. a = 0,
  4722. o = 0;
  4723. a < s;
  4724. ++o
  4725. )
  4726. (r[a++] = t[o + 2 * n]),
  4727. (r[a++] = t[o + n]),
  4728. (r[a++] = t[o]),
  4729. (r[a++] = t[o + 3 * n]);
  4730. this.specularTexture.loadArray(r);
  4731. }
  4732. if (
  4733. ((this.diffuseCoefficients = new Float32Array(i.diffuseCoefficients)),
  4734. (this.backgroundMode = i.backgroundMode || 0),
  4735. (this.backgroundBrightness = i.backgroundBrightness || 1),
  4736. (this.backgroundColor = new Float32Array(i.backgroundColor)),
  4737. 1 <= this.backgroundMode)
  4738. )
  4739. if (
  4740. ((this.backgroundShader = e.shaderCache.fromURLs(
  4741. "skyvert.glsl",
  4742. 3 == this.backgroundMode ? "skySH.glsl" : "sky.glsl",
  4743. ["#define SKYMODE " + this.backgroundMode]
  4744. )),
  4745. (this.vertexBuffer = e.createBuffer()),
  4746. e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer),
  4747. (i = 1 / 256),
  4748. (s = 2.8 * (t = 0.5 / 256)),
  4749. (n = 0.5 * t),
  4750. (i = new Float32Array([
  4751. 0,
  4752. 1,
  4753. 0,
  4754. 0.49609375 + i,
  4755. 0.49609375 + i,
  4756. 1,
  4757. 0,
  4758. 0,
  4759. 0.9921875 + i,
  4760. 0.49609375 + i,
  4761. 0,
  4762. 0,
  4763. 1,
  4764. 0.49609375 + i,
  4765. 0.9921875 + i,
  4766. -1,
  4767. 0,
  4768. 0,
  4769. 0 + i,
  4770. 0.49609375 + i,
  4771. 0,
  4772. 0,
  4773. -1,
  4774. 0.49609375 + i,
  4775. 0 + i,
  4776. 0,
  4777. -1,
  4778. 0,
  4779. 0.9921875 + i,
  4780. 0 + i,
  4781. 0,
  4782. -1,
  4783. 0,
  4784. 0.9921875 + i,
  4785. 0.9921875 + i,
  4786. 0,
  4787. -1,
  4788. 0,
  4789. 0 + i,
  4790. 0.9921875 + i,
  4791. 0,
  4792. -1,
  4793. 0,
  4794. 0 + i,
  4795. 0 + i,
  4796. s,
  4797. 1 - s,
  4798. -s,
  4799. 0.5 + t,
  4800. 0.5 - t,
  4801. s,
  4802. 1 - s,
  4803. s,
  4804. 0.5 + t,
  4805. 0.5 + t,
  4806. -s,
  4807. 1 - s,
  4808. s,
  4809. 0.5 - t,
  4810. 0.5 + t,
  4811. -s,
  4812. 1 - s,
  4813. -s,
  4814. 0.5 - t,
  4815. 0.5 - t,
  4816. -s,
  4817. 0,
  4818. -1 + s,
  4819. 0.5 - t,
  4820. 0 + i + t,
  4821. s,
  4822. 0,
  4823. -1 + s,
  4824. 0.5 + t,
  4825. 0 + i + t,
  4826. 1 - s,
  4827. 0,
  4828. -s,
  4829. 0.9921875 + i - t,
  4830. 0.5 - t,
  4831. 1 - s,
  4832. 0,
  4833. s,
  4834. 0.9921875 + i - t,
  4835. 0.5 + t,
  4836. s,
  4837. 0,
  4838. 1 - s,
  4839. 0.5 + t,
  4840. 0.9921875 + i - t,
  4841. -s,
  4842. 0,
  4843. 1 - s,
  4844. 0.5 - t,
  4845. 0.9921875 + i - t,
  4846. -1 + s,
  4847. 0,
  4848. s,
  4849. 0 + i + t,
  4850. 0.5 + t,
  4851. -1 + s,
  4852. 0,
  4853. -s,
  4854. 0 + i + t,
  4855. 0.5 - t,
  4856. 1,
  4857. 0,
  4858. 0,
  4859. 0.9921875 + i - n,
  4860. 0.49609375 + i,
  4861. 0,
  4862. 0,
  4863. 1,
  4864. 0.49609375 + i,
  4865. 0.9921875 + i - n,
  4866. -1,
  4867. 0,
  4868. 0,
  4869. 0 + i + n,
  4870. 0.49609375 + i,
  4871. 0,
  4872. 0,
  4873. -1,
  4874. 0.49609375 + i,
  4875. 0 + i + n,
  4876. 0,
  4877. 1,
  4878. 0,
  4879. 0.49609375 + i - n,
  4880. 0.49609375 + i,
  4881. 0,
  4882. 1,
  4883. 0,
  4884. 0.49609375 + i,
  4885. 0.49609375 + i - n,
  4886. 0,
  4887. 1,
  4888. 0,
  4889. 0.49609375 + i + n,
  4890. 0.49609375 + i,
  4891. 0,
  4892. 1,
  4893. 0,
  4894. 0.49609375 + i,
  4895. 0.49609375 + i + n,
  4896. ])),
  4897. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  4898. e.bindBuffer(e.ARRAY_BUFFER, null),
  4899. (this.indexBuffer = e.createBuffer()),
  4900. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer),
  4901. (i = new Uint16Array([
  4902. 2,
  4903. 1,
  4904. 6,
  4905. 3,
  4906. 2,
  4907. 7,
  4908. 8,
  4909. 4,
  4910. 3,
  4911. 4,
  4912. 5,
  4913. 1,
  4914. 9,
  4915. 14,
  4916. 15,
  4917. 17,
  4918. 10,
  4919. 16,
  4920. 18,
  4921. 19,
  4922. 11,
  4923. 20,
  4924. 13,
  4925. 12,
  4926. 28,
  4927. 12,
  4928. 13,
  4929. 13,
  4930. 24,
  4931. 28,
  4932. 28,
  4933. 24,
  4934. 9,
  4935. 9,
  4936. 24,
  4937. 14,
  4938. 25,
  4939. 9,
  4940. 15,
  4941. 25,
  4942. 15,
  4943. 21,
  4944. 10,
  4945. 25,
  4946. 21,
  4947. 10,
  4948. 21,
  4949. 16,
  4950. 22,
  4951. 26,
  4952. 10,
  4953. 22,
  4954. 10,
  4955. 17,
  4956. 18,
  4957. 11,
  4958. 26,
  4959. 22,
  4960. 18,
  4961. 26,
  4962. 19,
  4963. 23,
  4964. 27,
  4965. 19,
  4966. 27,
  4967. 11,
  4968. 23,
  4969. 20,
  4970. 27,
  4971. 27,
  4972. 20,
  4973. 12,
  4974. ])),
  4975. (this.skyIndexCount = i.length),
  4976. e.bufferData(e.ELEMENT_ARRAY_BUFFER, i, e.STATIC_DRAW),
  4977. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null),
  4978. 3 == this.backgroundMode)
  4979. )
  4980. for (
  4981. this.backgroundCoefficients = new Float32Array(
  4982. this.diffuseCoefficients
  4983. ),
  4984. a = 0;
  4985. a < this.backgroundCoefficients.length;
  4986. ++a
  4987. )
  4988. this.backgroundCoefficients[a] *= this.backgroundBrightness;
  4989. else {
  4990. var h;
  4991. (this.backgroundTexture = new U(e, {
  4992. width: 256,
  4993. height: 256,
  4994. clamp: !0,
  4995. })),
  4996. (i = !1),
  4997. e.ext.textureHalf &&
  4998. e.ext.textureHalfLinear &&
  4999. (this.backgroundTexture.loadArray(
  5000. null,
  5001. e.RGB,
  5002. e.ext.textureHalf.HALF_FLOAT_OES
  5003. ),
  5004. (i = (h = new m(e, { color0: this.backgroundTexture })).valid)),
  5005. !i &&
  5006. e.ext.textureFloat &&
  5007. e.ext.textureFloatLinear &&
  5008. !e.hints.mobile &&
  5009. (this.backgroundTexture.loadArray(null, e.RGB, e.FLOAT),
  5010. (i = (h = new m(e, { color0: this.backgroundTexture })).valid)),
  5011. i ||
  5012. (this.backgroundTexture.loadArray(),
  5013. (h = new m(e, { color0: this.backgroundTexture }))),
  5014. h.bind(),
  5015. (h = new F(e)).build(
  5016. "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); }",
  5017. "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);}"
  5018. ),
  5019. h.bind(),
  5020. e.uniform1f(h.params.b, 7 * Math.sqrt(this.backgroundBrightness)),
  5021. this.specularTexture.bind(h.samplers.tex),
  5022. (i = e.createBuffer()),
  5023. e.bindBuffer(e.ARRAY_BUFFER, i),
  5024. (i = new Float32Array([
  5025. -1,
  5026. -1,
  5027. 0.5,
  5028. 1,
  5029. 3,
  5030. -1,
  5031. 0.5,
  5032. 1,
  5033. -1,
  5034. 3,
  5035. 0.5,
  5036. 1,
  5037. ])),
  5038. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  5039. e.enableVertexAttribArray(h.attribs.p),
  5040. e.vertexAttribPointer(h.attribs.p, 4, e.FLOAT, !1, 0, 0),
  5041. e.drawArrays(e.TRIANGLES, 0, 3),
  5042. e.disableVertexAttribArray(h.attribs.p);
  5043. }
  5044. }
  5045. function D() {
  5046. (this.STRIP_NONE = -2),
  5047. (this.STRIP_MENU = -1),
  5048. (this.stripCount = 5),
  5049. (this.strips = [0, 0, 0, 0, 0]),
  5050. (this.labels = [
  5051. "Normals",
  5052. "Albedo",
  5053. "Reflectivity",
  5054. "Gloss",
  5055. "Topology",
  5056. ]),
  5057. (this.stripSlant = 0.25),
  5058. (this.selectedStrip = this.STRIP_NONE),
  5059. (this.animationActive = !1),
  5060. (this.timestamp = Date.now()),
  5061. this.update(!0);
  5062. }
  5063. function U(e, t) {
  5064. (this.gl = e),
  5065. (this.id = null),
  5066. (this.type = e.TEXTURE_2D),
  5067. (this.format = e.RGBA),
  5068. (this.componentType = e.UNSIGNED_BYTE),
  5069. (t = t || {}),
  5070. (this.desc = {
  5071. width: t.width || 1,
  5072. height: t.height || 1,
  5073. mipmap: t.mipmap,
  5074. clamp: t.clamp,
  5075. mirror: t.mirror,
  5076. aniso: t.aniso,
  5077. nofilter: t.nofilter,
  5078. });
  5079. }
  5080. function N(e) {
  5081. (this.gl = e), (this.cache = []);
  5082. }
  5083. function z(e, t) {
  5084. (this.name = "none"),
  5085. (this.debugString = ""),
  5086. (this.knobControlRect = new s(e)),
  5087. (this.controlRect = new s(e));
  5088. var i = document.createElement("div");
  5089. (i.id = "sliderUI"),
  5090. (i.style.position = "absolute"),
  5091. (i.style.overflow = "hidden"),
  5092. (i.style["-moz-user-select"] = "none"),
  5093. (i.style["-khtml-user-select"] = "none"),
  5094. (i.style["-webkit-user-select"] = "none"),
  5095. (i.style["-ms-user-select"] = "none"),
  5096. (this.controlRect.linkedControl = i),
  5097. (this.backgroundControl = 0),
  5098. this.controlRect.registerChildControlRect(this.knobControlRect),
  5099. this.knobControlRect.setOpacity(0.65),
  5100. (this.sliderPercent = this.pixelsY = this.pixelsX = 0),
  5101. (this.draggingSlider = !1),
  5102. (this.guiScreen = e),
  5103. t.addImageElement(
  5104. this.knobControlRect,
  5105. "animationknob" + e.imageSetNumber + "x.png"
  5106. );
  5107. }
  5108. function j(e) {
  5109. (this.viewer = e),
  5110. (this.stripData = e.stripData),
  5111. ((e = this.container = document.createElement("div")).id = "fdageUI"),
  5112. (e.style.position = "absolute"),
  5113. (e.style.overflow = "hidden"),
  5114. (e.style["-moz-user-select"] = "none"),
  5115. (e.style["-khtml-user-select"] = "none"),
  5116. (e.style["-webkit-user-select"] = "none"),
  5117. (e.style["-ms-user-select"] = "none"),
  5118. this.viewer.domRoot.appendChild(e),
  5119. (this.guiScreen = new t(this));
  5120. }
  5121. (R.prototype.resize = function(e) {
  5122. e.ui.viewer.scene.sceneAnimator.showPlayControls ||
  5123. ((e.width = 1), (e.height = 1)),
  5124. (this.compactMode = e.width < this.minWidth);
  5125. var t = this.bottomOffset,
  5126. i = this.bottomOffset + 4,
  5127. s = 0;
  5128. this.cameraList && this.animationList
  5129. ? (s +=
  5130. 42 + this.cameraList.localPixelsX + this.animationList.localPixelsX)
  5131. : this.cameraList
  5132. ? (s += 28 + this.cameraList.localPixelsX)
  5133. : this.animationList && (s += 28 + this.animationList.localPixelsX);
  5134. var n = e.width - s - 72;
  5135. 0 == s && (n -= 14);
  5136. var r = 116,
  5137. a = r + n + 14;
  5138. this.compactMode &&
  5139. ((r = 58), (n += 44 + s), 0 < s && (t += 32), s || (i += 32));
  5140. var o = (s = 32 / n) + 14 / n,
  5141. h = 1 - o,
  5142. l = this.playbackRegion;
  5143. (l.controlRect.widthPercent = n / e.width),
  5144. (l.controlRect.heightPercent = 32 / e.height),
  5145. (l.controlRect.xPercent = r / e.width),
  5146. (l.controlRect.yPercent = t / e.height),
  5147. this.pauseButton.controlRect.set(0, 0.125, s, 0.75),
  5148. this.playButton.controlRect.set(0, 0.125, s, 0.75),
  5149. this.timelineSlider.controlRect.set(o, 0.03125, h, 1),
  5150. this.timelineSlider.setSize(n - 46, 32),
  5151. l.controlRect.updateElement(),
  5152. l.controlRect.updateChildElements(),
  5153. this.speedList.setControl(58, i, 44, 24, !1),
  5154. this.cameraList &&
  5155. (this.cameraList.setControl(a, i, 10, 24, !0, 8),
  5156. (a += this.cameraList.localPixelsX + 14)),
  5157. this.animationList &&
  5158. this.animationList.setControl(a, i, 10, 24, !0, 8),
  5159. this.timelineSlider.backgroundControl.alignBackground();
  5160. }),
  5161. (R.prototype.setupCallbacks = function() {
  5162. var e = function(e) {
  5163. "0.01x" == this.speedList.selectedItemText &&
  5164. this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(0.01),
  5165. "0.05x" == this.speedList.selectedItemText &&
  5166. this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(0.05),
  5167. "0.25x" == this.speedList.selectedItemText &&
  5168. this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(0.25),
  5169. "0.5x" == this.speedList.selectedItemText &&
  5170. this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(0.5),
  5171. "1.0x" == this.speedList.selectedItemText &&
  5172. this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(1),
  5173. "2.0x" == this.speedList.selectedItemText &&
  5174. this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(2),
  5175. "4.0x" == this.speedList.selectedItemText &&
  5176. this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(4);
  5177. }.bind(this),
  5178. t = function(e) {
  5179. this.ui.viewer.scene.sceneAnimator.selectCamera(
  5180. this.cameraList.selectedIndex
  5181. ),
  5182. this.ui.viewer.wake();
  5183. }.bind(this),
  5184. i = function(e) {
  5185. this.ui.viewer.scene.sceneAnimator.selectAnimation(
  5186. this.animationList.selectedIndex
  5187. ),
  5188. this.ui.viewer.wake();
  5189. }.bind(this);
  5190. this.speedList && (this.speedList.selectionChangedCallback = e),
  5191. this.cameraList && (this.cameraList.selectionChangedCallback = t),
  5192. this.animationList &&
  5193. (this.animationList.selectionChangedCallback = i),
  5194. (this.playButton.controlRect.linkedControl.onclick = function() {
  5195. this.ui.viewer.scene.sceneAnimator.pause(!1),
  5196. this.playButton.controlRect.showControl(!1),
  5197. this.pauseButton.controlRect.showControl(!0),
  5198. this.ui.viewer.wake();
  5199. }.bind(this)),
  5200. (this.pauseButton.controlRect.linkedControl.onclick = function() {
  5201. this.ui.viewer.scene.sceneAnimator.pause(!0),
  5202. this.playButton.controlRect.showControl(!0),
  5203. this.pauseButton.controlRect.showControl(!1);
  5204. }.bind(this));
  5205. }),
  5206. (A.prototype.prepareBloom = function(e) {
  5207. if (
  5208. this.useBloom &&
  5209. this.bloomShader.complete() &&
  5210. this.shrinkShader.complete()
  5211. ) {
  5212. this.shrinkShader.bind(),
  5213. this.bloomTargets[1].bind(),
  5214. e.bind(this.shrinkShader.samplers.tInput),
  5215. this.fillScreen(this.shrinkShader.attribs.vCoord),
  5216. this.bloomShader.bind();
  5217. var t = [];
  5218. this.bloomTargets[0].bind(),
  5219. this.bloomTextures[1].bind(this.bloomShader.samplers.tInput);
  5220. for (var i = 0, s = 0; s < this.bloomSamples; ++s) {
  5221. var n,
  5222. r = (2 * s) / (this.bloomSamples - 1) - 1;
  5223. (n = 4 * r),
  5224. (i += n = Math.exp((-0.5 * n * n) / 1) / 2.50662827463),
  5225. (t[4 * s + 0] = r * this.desc.bloomSize),
  5226. (t[4 * s + 1] = 0),
  5227. (t[4 * s + 2] = n),
  5228. (t[4 * s + 3] = 0);
  5229. }
  5230. for (s = 0; s < this.bloomSamples; ++s) t[4 * s + 2] /= i;
  5231. for (
  5232. this.gl.uniform4fv(this.bloomShader.params.uKernel, t),
  5233. this.fillScreen(this.bloomShader.attribs.vCoord),
  5234. this.bloomTargets[1].bind(),
  5235. this.bloomTextures[0].bind(this.bloomShader.samplers.tInput),
  5236. s = 0;
  5237. s < this.bloomSamples;
  5238. ++s
  5239. )
  5240. (i = t[4 * s + 0]),
  5241. (i *= e.desc.width / e.desc.height),
  5242. (t[4 * s + 0] = 0),
  5243. (t[4 * s + 1] = i);
  5244. this.gl.uniform4fv(this.bloomShader.params.uKernel, t),
  5245. this.fillScreen(this.bloomShader.attribs.vCoord),
  5246. (this.bloomResult = this.bloomTextures[1]);
  5247. } else this.bloomResult = this.blackTexture;
  5248. }),
  5249. (A.prototype.computeParams = function(e, t) {
  5250. var i = this.desc,
  5251. s = {};
  5252. (s.scale = [
  5253. i.contrast[0] * i.contrast[3],
  5254. i.contrast[1] * i.contrast[3],
  5255. i.contrast[2] * i.contrast[3],
  5256. ]),
  5257. (s.bias = [
  5258. i.bias[0] * i.bias[3],
  5259. i.bias[1] * i.bias[3],
  5260. i.bias[2] * i.bias[3],
  5261. ]),
  5262. (s.bias = [
  5263. -s.bias[0] * s.scale[0] + s.bias[0],
  5264. -s.bias[1] * s.scale[1] + s.bias[1],
  5265. -s.bias[2] * s.scale[2] + s.bias[2],
  5266. ]);
  5267. var n = [
  5268. i.brightness[0] * i.brightness[3],
  5269. i.brightness[1] * i.brightness[3],
  5270. i.brightness[2] * i.brightness[3],
  5271. ];
  5272. (s.scale = [s.scale[0] * n[0], s.scale[1] * n[1], s.scale[2] * n[2]]),
  5273. (s.bias = [s.bias[0] * n[0], s.bias[1] * n[1], s.bias[2] * n[2]]),
  5274. (s.saturation = [
  5275. i.saturation[0] * i.saturation[3],
  5276. i.saturation[1] * i.saturation[3],
  5277. i.saturation[2] * i.saturation[3],
  5278. ]),
  5279. (s.bloomColor = [
  5280. i.bloomColor[0] * i.bloomColor[3],
  5281. i.bloomColor[1] * i.bloomColor[3],
  5282. i.bloomColor[2] * i.bloomColor[3],
  5283. ]),
  5284. (s.sharpen = [i.sharpen, 0.25 * i.sharpen, i.sharpenLimit]),
  5285. (s.sharpenKernel = [1 / e, 0, 0, 1 / t]),
  5286. (n = t < e ? e : t),
  5287. (s.vignetteAspect = [e / n, t / n, (0.5 * e) / n, (0.5 * t) / n]),
  5288. (s.vignette = [
  5289. 2 * (1 - i.vignette[0]) * i.vignette[3],
  5290. 2 * (1 - i.vignette[1]) * i.vignette[3],
  5291. 2 * (1 - i.vignette[2]) * i.vignette[3],
  5292. i.vignetteCurve,
  5293. ]);
  5294. n = 1 / this.noiseTexture.desc.width;
  5295. var r = 1 / this.noiseTexture.desc.height,
  5296. a = 1 - i.grainSharpness;
  5297. return (
  5298. (s.grainCoord = [n * e, r * t, 0.5 * a * n, 0.5 * a * r]),
  5299. (s.grainScaleBias = [2 * i.grain, -i.grain]),
  5300. s
  5301. );
  5302. }),
  5303. (A.prototype.present = function(e, t, i, s) {
  5304. if (
  5305. (s || this.prepareBloom(e),
  5306. 1 < this.sampleCount && this.allocAABuffer(t, i),
  5307. (s = s ? this.plainShader : this.shader).bind())
  5308. ) {
  5309. var n = this.gl,
  5310. r = s.samplers,
  5311. a = s.params,
  5312. o = this.computeParams(t, i);
  5313. if (
  5314. (e.bind(r.tInput),
  5315. this.bloomResult.bind(r.tBloom),
  5316. this.noiseTexture.bind(r.tGrain),
  5317. this.colorLUT && this.colorLUT.bind(r.tLUT),
  5318. n.uniform3fv(a.uScale, o.scale),
  5319. n.uniform3fv(a.uBias, o.bias),
  5320. n.uniform3fv(a.uSaturation, o.saturation),
  5321. n.uniform4fv(a.uSharpenKernel, o.sharpenKernel),
  5322. n.uniform3fv(a.uSharpness, o.sharpen),
  5323. n.uniform3fv(a.uBloomColor, o.bloomColor),
  5324. n.uniform4fv(a.uVignetteAspect, o.vignetteAspect),
  5325. n.uniform4fv(a.uVignette, o.vignette),
  5326. n.uniform4fv(a.uGrainCoord, o.grainCoord),
  5327. n.uniform2fv(a.uGrainScaleBias, o.grainScaleBias),
  5328. (e = 1 < this.sampleCount && 0 <= this.sampleIndex))
  5329. ) {
  5330. var h = 1 / (1 + this.sampleIndex);
  5331. (this.sampleIndex += 1),
  5332. h < 1 &&
  5333. (n.enable(n.BLEND),
  5334. n.blendColor(h, h, h, h),
  5335. n.blendFunc(n.CONSTANT_ALPHA, n.ONE_MINUS_CONSTANT_ALPHA)),
  5336. this.aaTarget.bind();
  5337. } else m.bindNone(n), 1 < this.sampleCount && (this.sampleIndex += 1);
  5338. n.viewport(0, 0, t, i),
  5339. this.fillScreen(s.attribs.vCoord),
  5340. e &&
  5341. (h < 1 && n.disable(n.BLEND),
  5342. m.bindNone(n),
  5343. this.aaShader.bind(),
  5344. this.aaBuffer.bind(this.aaShader.samplers.tInput),
  5345. this.fillScreen(this.aaShader.attribs.vCoord));
  5346. }
  5347. }),
  5348. (A.prototype.allocAABuffer = function(e, t) {
  5349. (this.aaBuffer &&
  5350. this.aaBuffer.desc.width == e &&
  5351. this.aaBuffer.desc.height == t) ||
  5352. (this.aaBuffer && this.aaBuffer.destroy(),
  5353. (this.aaBuffer = new U(this.gl, { width: e, height: t, clamp: !0 })),
  5354. this.aaBuffer.loadArray(),
  5355. (this.aaTarget = new m(this.gl, {
  5356. color0: this.aaBuffer,
  5357. ignoreStatus: !0,
  5358. })));
  5359. }),
  5360. (A.prototype.adjustProjectionForSupersampling = function(e) {
  5361. if (1 < this.sampleCount) {
  5362. var t = this.currentSample(),
  5363. i = this.sampleOffsets[t][0] / e.size[0];
  5364. (t = this.sampleOffsets[t][1] / e.size[1]),
  5365. (i = S.translation(S.empty(), i, t, 0));
  5366. S.mul(e.projectionMatrix, i, e.projectionMatrix);
  5367. }
  5368. }),
  5369. (A.prototype.discardAAHistory = function() {
  5370. this.sampleIndex = -1;
  5371. }),
  5372. (A.prototype.currentSample = function() {
  5373. return (this.sampleIndex < 0 ? 0 : this.sampleIndex) % this.sampleCount;
  5374. }),
  5375. (A.prototype.fillScreen = function(e) {
  5376. var t = this.gl;
  5377. t.bindBuffer(t.ARRAY_BUFFER, this.fullscreenTriangle),
  5378. t.enableVertexAttribArray(e),
  5379. t.vertexAttribPointer(e, 2, t.FLOAT, !1, 0, 0),
  5380. t.drawArrays(t.TRIANGLES, 0, 3),
  5381. t.disableVertexAttribArray(e),
  5382. t.bindBuffer(t.ARRAY_BUFFER, null);
  5383. }),
  5384. (A.prototype.blitTexture = function(e) {
  5385. this.aaShader.bind(),
  5386. e.bind(this.aaShader.samplers.tInput),
  5387. this.fillScreen(this.aaShader.attribs.vCoord);
  5388. }),
  5389. (k.prototype.load = function(e) {
  5390. var t,
  5391. i = this.gl,
  5392. s = e.extract("scene.json");
  5393. if (void 0 === s) return !1;
  5394. if (!e.checkSignature(s)) return !1;
  5395. if (null == (s = new u(s.data).asString()) || s.length <= 0) return !1;
  5396. try {
  5397. t = JSON.parse(s);
  5398. } catch (e) {
  5399. return console.error(e), !1;
  5400. }
  5401. for (var n in ((this.metaData = t.metaData),
  5402. (this.view = new H(t.mainCamera.view)),
  5403. (this.sky = new _(this.gl, e, t.sky)),
  5404. (this.lights = new x(t.lights, this.view)),
  5405. (this.materialsList = []),
  5406. (this.materials = {}),
  5407. t.materials)) {
  5408. var r = t.materials[n];
  5409. (r.lightCount = this.lights.count),
  5410. (r.shadowCount = this.lights.shadowCount),
  5411. (s = new b(this.gl, e, r)),
  5412. (this.materials[r.name] = s),
  5413. this.materialsList.push(s);
  5414. }
  5415. if (t.meshes)
  5416. for (r = 0; r < t.meshes.length; ++r) {
  5417. (n = t.meshes[r]),
  5418. (n = new T(this.gl, n, e.extract(n.file))),
  5419. this.meshes.push(n);
  5420. for (var a = 0; a < n.desc.subMeshes.length; ++a) {
  5421. var o = n.desc.subMeshes[a];
  5422. (s = this.materials[o.material]) &&
  5423. (n.numSubMeshes++, this.meshRenderables.push(new w(n, o, s)));
  5424. }
  5425. }
  5426. return (
  5427. (this.bounds = new d(this.meshes)),
  5428. (this.postRender = new A(this.gl, t.mainCamera.post, !0)),
  5429. (this.shadow = new E(i, this.lights.shadowCount)),
  5430. (this.cameras = t.Cameras),
  5431. t.AnimData && (this.sceneAnimator = new P(this, e, t.AnimData)),
  5432. t.fog && (this.fog = new f(i, t.fog)),
  5433. t.shadowFloor &&
  5434. (this.shadowFloor = new B(
  5435. i,
  5436. t.shadowFloor,
  5437. this.shadow,
  5438. this.lights
  5439. )),
  5440. (this.sceneLoaded = !0)
  5441. );
  5442. }),
  5443. (k.prototype.update = function() {
  5444. this.sceneAnimator &&
  5445. (this.frameCounter++,
  5446. this.lights.flagUpdateAnimatedLighting(),
  5447. this.sceneAnimator.drawAnimated &&
  5448. (1 == this.frameCounter
  5449. ? this.sceneAnimator.resetPlayback()
  5450. : this.sceneAnimator.updateAnimationPlayback())),
  5451. this.lights.update(this.view, this.bounds);
  5452. }),
  5453. (k.prototype.collectShadows = function(e) {
  5454. this.shadow.collect(this, e);
  5455. }),
  5456. (k.prototype.draw = function(e) {
  5457. var t = this.gl;
  5458. if (this.sceneLoaded) {
  5459. this.sky.setClearColor(),
  5460. t.clear(
  5461. t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT | t.STENCIL_BUFFER_BIT
  5462. ),
  5463. t.enable(t.DEPTH_TEST),
  5464. this.sky.draw(this),
  5465. this.shadowFloor && this.shadowFloor.draw(this);
  5466. for (var i = 0; i < this.meshRenderables.length; ++i)
  5467. this.meshRenderables[i].material.usesBlending ||
  5468. this.meshRenderables[i].material.usesRefraction ||
  5469. !this.meshRenderables[i].visible ||
  5470. this.meshRenderables[i].draw(this);
  5471. for (
  5472. t.enable(t.POLYGON_OFFSET_FILL),
  5473. t.polygonOffset(1, 1),
  5474. t.colorMask(!1, !1, !1, !1),
  5475. i = 0;
  5476. i < this.meshRenderables.length;
  5477. ++i
  5478. )
  5479. this.meshRenderables[i].drawAlphaPrepass(this);
  5480. for (
  5481. t.colorMask(!0, !0, !0, !0),
  5482. t.disable(t.POLYGON_OFFSET_FILL),
  5483. t.depthFunc(t.LEQUAL),
  5484. t.depthMask(!1),
  5485. i = 0;
  5486. i < this.meshRenderables.length;
  5487. ++i
  5488. )
  5489. this.meshRenderables[i].material.usesBlending &&
  5490. this.meshRenderables[i].visible &&
  5491. this.meshRenderables[i].draw(this);
  5492. t.disable(t.BLEND), t.depthMask(!0), t.depthFunc(t.LESS);
  5493. var s = !1;
  5494. for (i = 0; i < this.meshRenderables.length; ++i)
  5495. if (this.meshRenderables[i].material.usesRefraction) {
  5496. s = !0;
  5497. break;
  5498. }
  5499. if (s)
  5500. for (
  5501. (this.refractionSurface &&
  5502. this.refractionSurface.desc.width == e.color0.desc.width &&
  5503. this.refractionSurface.desc.height == e.color0.desc.height) ||
  5504. ((this.refractionSurface = new U(t, e.color0.desc)),
  5505. this.refractionSurface.loadArray(
  5506. null,
  5507. e.color0.format,
  5508. e.color0.componentType
  5509. ),
  5510. (this.refractionBuffer = new m(this.gl, {
  5511. color0: this.refractionSurface,
  5512. }))),
  5513. this.refractionBuffer.bind(),
  5514. this.postRender.blitTexture(e.color0),
  5515. e.bind(),
  5516. i = 0;
  5517. i < this.meshRenderables.length;
  5518. ++i
  5519. )
  5520. this.meshRenderables[i].material.usesRefraction &&
  5521. this.meshRenderables[i].visible &&
  5522. this.meshRenderables[i].draw(this);
  5523. if (
  5524. this.stripData.activeWireframe() &&
  5525. 0 < this.meshRenderables.length
  5526. ) {
  5527. for (i = 0; i < this.meshRenderables.length; ++i)
  5528. this.meshRenderables[i].visible &&
  5529. this.meshRenderables[i].drawWire(this);
  5530. t.depthMask(!0);
  5531. }
  5532. t.disable(t.BLEND);
  5533. }
  5534. }),
  5535. (k.prototype.drawSecondary = function(e) {
  5536. this.fog && this.fog.draw(this, e);
  5537. }),
  5538. (k.prototype.complete = function() {
  5539. if (
  5540. !this.sky.complete() ||
  5541. !this.shadow.complete() ||
  5542. (this.fog && !this.fog.complete()) ||
  5543. (this.shadowFloor && !this.shadowFloor.complete())
  5544. )
  5545. return !1;
  5546. for (var e = 0; e < this.meshRenderables.length; ++e)
  5547. if (!this.meshRenderables[e].complete()) return !1;
  5548. return !0;
  5549. }),
  5550. (P.prototype.flagAllForDebugging = function() {
  5551. for (var e = this.animations.length, t = 0; t < e; t++)
  5552. for (
  5553. var i = this.animations[t], s = i.animatedObjects.length, n = 0;
  5554. n < s;
  5555. n++
  5556. )
  5557. i.animatedObjects[n].debugMe = !0;
  5558. }),
  5559. (P.prototype.checkDebug = function() {
  5560. (this.debugString =
  5561. "<br>--------------------------------------Debug Info:"),
  5562. (this.debugString +=
  5563. "<br>this.selectedAnimationIndex :" + this.selectedAnimationIndex);
  5564. var e = this.animations[this.selectedAnimationIndex],
  5565. t = e.animatedObjects.length;
  5566. (this.debugString += "<br>numAnimatedObjects :" + t),
  5567. "" != e.debugString &&
  5568. ((this.debugString +=
  5569. "<br>--------------------------------------------------Got animation bug info:"),
  5570. (this.debugString += e.debugString),
  5571. (this.showDebugInfo = this.stopEverything = !0),
  5572. (e.debugString = ""));
  5573. for (var i = 0; i < t; i++) {
  5574. var s = e.animatedObjects[i];
  5575. ("" == s.debugString && "" == s.animatedLocalTransform.debugString) ||
  5576. ((this.debugString +=
  5577. "<br>--------------------------------------------------Got object bug info:"),
  5578. (this.debugString += s.debugString),
  5579. (this.debugString += s.animatedLocalTransform.debugString),
  5580. (this.showDebugInfo = this.stopEverything = !0),
  5581. (s.debugString = ""),
  5582. (s.animatedLocalTransform.debugString = "")),
  5583. s.skinningRig &&
  5584. "" != s.skinningRig.debugString &&
  5585. ((this.debugString +=
  5586. "<br>--------------------------------------------------Got skin rig info:"),
  5587. (this.debugString += s.skinningRig.debugString),
  5588. (s.skinningRig.debugString = ""),
  5589. (this.showDebugInfo = this.stopEverything = !0));
  5590. }
  5591. this.debugString +=
  5592. "<br>--------------------------------------Done Debug Info:";
  5593. }),
  5594. (P.prototype.logObjectInfo = function(e, t) {
  5595. var i =
  5596. t * (o = this.animations[this.selectedAnimationIndex]).originalFPS;
  5597. if (e >= o.animatedObjects.length)
  5598. this.debugString +=
  5599. "object index " + e + " exceeds " + o.animatedObjects.length;
  5600. else {
  5601. var s = o.animatedObjects[e],
  5602. n = o.animatedObjects[s.modelPartIndex],
  5603. r = o.getObjectAnimationFramePercent(s, t),
  5604. a = o.getObjectAnimationFramePercent(n, t);
  5605. (this.debugString = ""),
  5606. (this.debugString += "<br>Object Name: " + s.name),
  5607. (this.debugString += "<br>Object Type: " + s.sceneObjectType),
  5608. (this.debugString += "<br>Object Index: " + s.id),
  5609. (this.debugString += "<br>Part Index: " + s.modelPartIndex),
  5610. (this.debugString += "<br>Part Scale: " + s.modelPartScale),
  5611. (this.debugString += "<br>Mesh Index: " + s.meshIndex),
  5612. (this.debugString += "<br>Light Index: " + s.lightIndex),
  5613. (this.debugString += "<br>Deformer Index: " + s.skinningRigIndex),
  5614. (this.debugString += "<br>Parent Index: " + s.parentIndex),
  5615. (this.debugString += "<br>Scene time " + t),
  5616. (this.debugString += "<br>Scene framepercent " + i),
  5617. (this.debugString += "<br>Object looped framepercent " + r),
  5618. (this.debugString += "<br>Model looped framepercent " + a),
  5619. (this.debugString += "<br>Object Anim length " + s.animationLength),
  5620. (this.debugString += "<br>Object Total frames " + s.totalFrames),
  5621. (this.debugString += "<br>Object FPS " + s.modelPartFPS),
  5622. (this.debugString +=
  5623. "<br>Model Part Anim length " + n.animationLength),
  5624. (this.debugString += "<br>Model total frames " + n.totalFrames),
  5625. (this.debugString += "<br>Model Part FPS " + n.modelPartFPS),
  5626. (i = S.identity()),
  5627. o.getWorldTransform(s.id, t, i, this.sceneScale, !0),
  5628. (this.debugString += s.debugString);
  5629. var o = i[0],
  5630. h = ((s = i[1]), (n = i[2]), (r = i[4]), (a = i[5]), i[6]),
  5631. l = i[8],
  5632. d = i[9];
  5633. i = i[10];
  5634. Math.sqrt(o * o + s * s + n * n),
  5635. Math.sqrt(r * r + a * a + h * h),
  5636. Math.sqrt(l * l + d * d + i * i);
  5637. }
  5638. }),
  5639. (P.prototype.resetPlayback = function() {
  5640. (this.startMS = Date.now()),
  5641. (this.animationProgress = this.totalSeconds = 0),
  5642. this.setAnimationProgress(0, !0);
  5643. }),
  5644. (P.prototype.pause = function(e) {
  5645. (this.paused = e),
  5646. (this.startMS =
  5647. Date.now() -
  5648. (1e3 * this.totalSeconds) /
  5649. (this.playbackSpeed * this.scenePlaybackSpeed));
  5650. }),
  5651. (P.prototype.setAnimationProgress = function(e, t) {
  5652. var i = this.animations[this.selectedAnimationIndex];
  5653. (this.animationProgress = e),
  5654. (this.totalSeconds = i.totalSeconds * this.animationProgress),
  5655. (this.totalSeconds -= 1 / i.originalFPS),
  5656. this.totalSeconds < 0 && (this.totalSeconds = 0),
  5657. (this.startMS =
  5658. Date.now() -
  5659. (1e3 * this.totalSeconds) /
  5660. (this.playbackSpeed * this.scenePlaybackSpeed)),
  5661. t && this.updateScene();
  5662. }),
  5663. (P.prototype.setPlaybackSpeed = function(e) {
  5664. (this.playbackSpeed = e),
  5665. (this.startMS =
  5666. Date.now() -
  5667. (1e3 * this.totalSeconds) /
  5668. (this.playbackSpeed * this.scenePlaybackSpeed));
  5669. }),
  5670. (P.prototype.resetCustomView = function() {
  5671. 0 <= this.selectedCameraIndex &&
  5672. this.selectedCameraIndex < this.views.length &&
  5673. ((this.viewYawOffsets[this.selectedCameraIndex] = 0),
  5674. (this.viewPitchOffsets[this.selectedCameraIndex] = 0),
  5675. (this.scene.view.rotation[1] = this.views[
  5676. this.selectedCameraIndex
  5677. ].rotation[1]),
  5678. (this.scene.view.rotation[0] = this.views[
  5679. this.selectedCameraIndex
  5680. ].rotation[0]),
  5681. this.setViewFromSelectedCamera());
  5682. }),
  5683. (P.prototype.updateUserCamera = function() {
  5684. if (
  5685. (this.clearCacheForCameraChildren(),
  5686. 0 <= this.selectedCameraIndex &&
  5687. this.selectedCameraIndex < this.views.length &&
  5688. this.selectedAnimationIndex < this.animations.length)
  5689. ) {
  5690. var e = this.cameraObjectIndices[this.selectedCameraIndex],
  5691. t = this.animations[this.selectedAnimationIndex];
  5692. if (e < t.animatedObjects.length) {
  5693. var i = this.views[this.selectedCameraIndex],
  5694. s = this.scene.view.rotation[1],
  5695. n = this.scene.view.rotation[0],
  5696. r = n - i.rotation[0];
  5697. (this.viewYawOffsets[this.selectedCameraIndex] = s - i.rotation[1]),
  5698. (this.viewPitchOffsets[this.selectedCameraIndex] = r),
  5699. (i = t.animatedObjects[e]),
  5700. t.getObjectAnimationFramePercent(i, this.totalSeconds);
  5701. r = S.identity();
  5702. var a = S.identity();
  5703. (i.useFixedWorldTransform = !1),
  5704. (i.useFixedLocalTransform = !1),
  5705. (i.animatedLocalTransform.lockTransform = !1),
  5706. i.animatedLocalTransform.clearCachedTransforms(),
  5707. (i.cachedFrame0 = -1),
  5708. (i.cachedFrame1 = -1),
  5709. (i.cachedFrame2 = -1),
  5710. (i.cachedFrame3 = -1),
  5711. (i.cachedFrameUse0 = 0),
  5712. (i.cachedFrameUse1 = 0),
  5713. (i.cachedFrameUse2 = 0),
  5714. (i.cachedFrameUse3 = 0),
  5715. t.getWorldTransform(e, this.totalSeconds, a, this.sceneScale, !1);
  5716. e = a[0];
  5717. var o = a[1],
  5718. h = a[2],
  5719. l = a[4],
  5720. d = a[5],
  5721. c = a[6],
  5722. u = a[8],
  5723. f = a[9],
  5724. m = a[10];
  5725. (e = Math.sqrt(e * e + o * o + h * h)),
  5726. (l = Math.sqrt(l * l + d * d + c * c)),
  5727. (d = Math.sqrt(u * u + f * f + m * m));
  5728. (c = -(this.scene.view.pivot[0] - a[12])) * u +
  5729. (o = -(this.scene.view.pivot[1] - a[13])) * f +
  5730. (a = -(this.scene.view.pivot[2] - a[14])) * m <=
  5731. 0 && (s += 180),
  5732. (s = S.rotation(S.empty(), s, 1)),
  5733. (n = S.rotation(S.empty(), n, 0)),
  5734. S.mul(r, s, n),
  5735. (n = Math.sqrt(c * c + o * o + a * a)),
  5736. (s = this.scene.view.pivot[1] + r[9] * n),
  5737. (a = this.scene.view.pivot[2] + r[10] * n),
  5738. (r[12] = this.scene.view.pivot[0] + r[8] * n),
  5739. (r[13] = s),
  5740. (r[14] = a),
  5741. (n = S.identity()),
  5742. t.getWorldTransform(
  5743. i.parentIndex,
  5744. this.totalSeconds,
  5745. n,
  5746. this.sceneScale,
  5747. !1
  5748. ),
  5749. (t = S.identity()),
  5750. S.invert(t, n),
  5751. (n = S.identity()),
  5752. S.mul(n, t, r),
  5753. (n[12] /= this.sceneScale),
  5754. (n[13] /= this.sceneScale),
  5755. (n[14] /= this.sceneScale),
  5756. (r[0] *= e),
  5757. (r[1] *= e),
  5758. (r[2] *= e),
  5759. (r[4] *= l),
  5760. (r[5] *= l),
  5761. (r[6] *= l),
  5762. (r[8] *= d),
  5763. (r[9] *= d),
  5764. (r[10] *= d),
  5765. i.setFixedWorldTransform(r),
  5766. i.setFixedLocalTransform(n);
  5767. }
  5768. }
  5769. }),
  5770. (P.prototype.setViewFromSelectedCamera = function() {
  5771. if (
  5772. 0 <= this.selectedCameraIndex &&
  5773. this.selectedCameraIndex < this.views.length
  5774. ) {
  5775. var e = this.views[this.selectedCameraIndex],
  5776. t = this.scene.view,
  5777. i = this.viewYawOffsets[this.selectedCameraIndex],
  5778. s = this.viewPitchOffsets[this.selectedCameraIndex];
  5779. (t.pivot[0] = e.pivot[0]),
  5780. (t.pivot[1] = e.pivot[1]),
  5781. (t.pivot[2] = e.pivot[2]),
  5782. (t.rotation[0] = e.rotation[0] + s),
  5783. (t.rotation[1] = e.rotation[1] + i),
  5784. (t.radius = e.radius),
  5785. (t.nearPlane = e.nearPlane),
  5786. (t.fov = e.fov),
  5787. t.saveResetView(),
  5788. t.updateProjection(),
  5789. t.updateView();
  5790. }
  5791. }),
  5792. (P.prototype.selectDefaultCamera = function() {
  5793. if (-1 != this.defaultCameraGlobalIndex && 0 < this.animations.length)
  5794. for (
  5795. var e = this.animations[0], t = e.cameraObjects.length, i = 0;
  5796. i < t;
  5797. i++
  5798. )
  5799. if (e.cameraObjects[i].id == this.defaultCameraGlobalIndex)
  5800. return void (this.selectedCameraIndex = i);
  5801. this.selectedCameraIndex = 0;
  5802. }),
  5803. (P.prototype.updateAnimationPlayback = function() {
  5804. if (!this.stopEverything || !this.runDebugMode) {
  5805. var e = this.animations[this.selectedAnimationIndex];
  5806. if ((this.updateUserCamera(), this.paused || !this.playAnimations))
  5807. (this.startMS =
  5808. 0 < this.playbackSpeed
  5809. ? Date.now() -
  5810. (1e3 * this.totalSeconds) /
  5811. (this.playbackSpeed * this.scenePlaybackSpeed)
  5812. : Date.now() - 1e3 * this.totalSeconds),
  5813. this.refreshTransformsOnly(),
  5814. this.runDebugMode && this.checkDebug(),
  5815. (e = this.scene.view).saveResetView(),
  5816. e.updateProjection(),
  5817. e.updateView();
  5818. else {
  5819. this.lockPlayback &&
  5820. 0 < this.playbackSpeed &&
  5821. (this.startMS =
  5822. Date.now() -
  5823. (1e3 * this.totalSeconds) /
  5824. (this.playbackSpeed * this.scenePlaybackSpeed));
  5825. var t =
  5826. ((Date.now() - this.startMS) / 1e3) *
  5827. this.playbackSpeed *
  5828. this.scenePlaybackSpeed;
  5829. this.totalSeconds =
  5830. ((Date.now() - this.startMS) / 1e3) *
  5831. this.playbackSpeed *
  5832. this.scenePlaybackSpeed;
  5833. var i = (i = t / e.totalSeconds) - (t = Math.floor(i));
  5834. t != this.loopCount &&
  5835. (this.loopCount++,
  5836. this.loopTurntables && this.rolloverTurntables(),
  5837. this.autoAdvanceNextAnimation &&
  5838. (this.nextAnimation(), this.resetPlayback())),
  5839. (this.totalSeconds = e.totalSeconds * i),
  5840. (this.animationProgress =
  5841. this.totalSeconds / e.totalSeconds -
  5842. Math.floor(this.totalSeconds / e.totalSeconds)),
  5843. this.updateScene(),
  5844. this.runDebugMode && this.checkDebug();
  5845. }
  5846. }
  5847. }),
  5848. (P.prototype.updateScene = function() {
  5849. (this.lastSceneFramePercent =
  5850. this.totalSeconds *
  5851. this.animations[this.selectedAnimationIndex].originalFPS),
  5852. 0 != this.fogObjectIndex && this.updateFog(),
  5853. this.animateTurntables && this.updateTurntables(),
  5854. this.animateMeshes && this.poseMeshes(),
  5855. this.animateLights && this.updateLights(),
  5856. this.animateMaterials && this.updateMaterials(),
  5857. this.animateVisibility && this.updateVisibility();
  5858. }),
  5859. (P.prototype.findCameraChildren = function() {
  5860. for (
  5861. var e = this.animations[0], t = e.animatedObjects.length, i = 0;
  5862. i < t;
  5863. i++
  5864. )
  5865. e.hasParentTypeInHierarchy(e.animatedObjects[i], "CameraSO") &&
  5866. this.cameraChildrenIndices.push(i);
  5867. }),
  5868. (P.prototype.findFixedTransforms = function() {
  5869. for (var e = this.animations.length, t = 0; t < e; t++)
  5870. for (
  5871. var i = this.animations[t], s = i.animatedObjects.length, n = 0;
  5872. n < s;
  5873. n++
  5874. ) {
  5875. var r = i.animatedObjects[n];
  5876. if (!r.useFixedWorldTransform && !i.hasAnimationInHierarchy(r))
  5877. if ("Material" == r.sceneObjectType)
  5878. r.setFixedWorldTransform(S.identity()),
  5879. r.setFixedLocalTransform(S.identity());
  5880. else {
  5881. var a = S.identity(),
  5882. o = S.identity();
  5883. i.hasParentTypeInHierarchy(r, "SceneRootSO")
  5884. ? (i.getWorldTransform(r.id, 0, a, this.sceneScale, !1),
  5885. r.evaluateLocalTransformAtFramePercent(0, o, !0, !1))
  5886. : (i.evaluateModelPartTransformAtFrame(r.id, 0, a, !1),
  5887. r.evaluateLocalTransformAtFramePercent(0, o, !1, !1)),
  5888. r.setFixedWorldTransform(a),
  5889. r.setFixedLocalTransform(o);
  5890. }
  5891. }
  5892. }),
  5893. (P.prototype.clearCacheForCameraChildren = function() {
  5894. for (
  5895. var e = this.animations[this.selectedAnimationIndex],
  5896. t = this.cameraChildrenIndices.length,
  5897. i = 0;
  5898. i < t;
  5899. i++
  5900. ) {
  5901. var s = e.animatedObjects[this.cameraChildrenIndices[i]];
  5902. (s.useFixedWorldTransform = !1),
  5903. (s.useFixedLocalTransform = !1),
  5904. (s.cachedFrame0 = -10),
  5905. (s.cachedFrame1 = -10),
  5906. (s.cachedFrame2 = -10),
  5907. (s.cachedFrame3 = -10),
  5908. (s.cachedFrameUse0 = 0),
  5909. (s.cachedFrameUse1 = 0),
  5910. (s.cachedFrameUse2 = 0),
  5911. (s.cachedFrameUse3 = 0),
  5912. s.animatedLocalTransform.clearCachedTransforms(),
  5913. (s.animatedLocalTransform.lockTransform = !1);
  5914. }
  5915. }),
  5916. (P.prototype.refreshTransformsOnly = function() {
  5917. for (
  5918. var e = this.animations[this.selectedAnimationIndex],
  5919. t = e.meshObjects.length,
  5920. i = 0;
  5921. i < t;
  5922. i++
  5923. ) {
  5924. var s = e.meshObjects[i];
  5925. if (
  5926. (e.getWorldTransform(
  5927. s.id,
  5928. this.totalSeconds,
  5929. s.mesh.displayMatrix,
  5930. this.sceneScale,
  5931. !0
  5932. ),
  5933. this.enableSkinning &&
  5934. s.skinningRig &&
  5935. this.unitScaleSkinnedMeshes &&
  5936. !s.skinningRig.isRigidSkin)
  5937. ) {
  5938. var n = (s = s.mesh.displayMatrix)[0],
  5939. r = s[1],
  5940. a = s[2],
  5941. o = s[4],
  5942. h = s[5],
  5943. l = s[6],
  5944. d = s[8],
  5945. c = s[9],
  5946. u = s[10];
  5947. d =
  5948. ((n = Math.sqrt(n * n + r * r + a * a)) +
  5949. (o = Math.sqrt(o * o + h * h + l * l)) +
  5950. (d = Math.sqrt(d * d + c * c + u * u))) /
  5951. 2;
  5952. (s[0] /= d),
  5953. (s[1] /= d),
  5954. (s[2] /= d),
  5955. (s[4] /= d),
  5956. (s[5] /= d),
  5957. (s[6] /= d),
  5958. (s[8] /= d),
  5959. (s[9] /= d),
  5960. (s[10] /= d);
  5961. }
  5962. }
  5963. if (this.animateLights)
  5964. for (t = e.lightObjects.length, i = 0; i < t; i++)
  5965. (s = e.lightObjects[i]).useFixedWorldTransform ||
  5966. ((d = this.scene.lights.getLightPos(s.lightIndex)),
  5967. (c = this.scene.lights.getLightDir(s.lightIndex)),
  5968. (u = S.identity()),
  5969. e.getWorldTransform(
  5970. s.id,
  5971. this.totalSeconds,
  5972. u,
  5973. this.sceneScale,
  5974. !0
  5975. ),
  5976. (c[0] = u[8]),
  5977. (c[1] = u[9]),
  5978. (c[2] = u[10]),
  5979. 0 != d[3] &&
  5980. ((d[0] = u[12]),
  5981. (d[1] = u[13]),
  5982. (d[2] = u[14]),
  5983. this.scene.lights.setLightPos(s.lightIndex, d)),
  5984. this.scene.lights.setLightDir(s.lightIndex, c));
  5985. }),
  5986. (P.prototype.findMeshIndexByPartIndex = function(e, t) {
  5987. for (var i = 0; i < this.meshIDs.length; ++i)
  5988. if (t == this.meshIDs[i]) return i;
  5989. return -1;
  5990. }),
  5991. (P.prototype.findLightIndexByPartIndex = function(e) {
  5992. for (var t = 0; t < this.lightIDs.length; t++)
  5993. if (e == this.lightIDs[t]) return t;
  5994. return -1;
  5995. }),
  5996. (P.prototype.findMaterialIndexByPartIndex = function(e) {
  5997. for (var t = 0; t < this.materialIDs.length; t++)
  5998. if (e == this.materialIDs[t]) return t;
  5999. return -1;
  6000. }),
  6001. (P.prototype.nextAnimation = function() {
  6002. this.selectedAnimationIndex++,
  6003. this.selectedAnimationIndex >= this.animations.length &&
  6004. (this.selectedAnimationIndex = 0);
  6005. }),
  6006. (P.prototype.selectAnimation = function(e) {
  6007. 0 <= e &&
  6008. e < this.animations.length &&
  6009. (this.selectedAnimationIndex = e),
  6010. this.paused && this.setAnimationProgress(this.animationProgress, !0);
  6011. }),
  6012. (P.prototype.selectCamera = function(e) {
  6013. -1 != e &&
  6014. this.selectedCameraIndex != e &&
  6015. ((this.selectedCameraIndex = e), this.setViewFromSelectedCamera());
  6016. }),
  6017. (P.prototype.getAnimatedCamera = function() {
  6018. if (
  6019. 0 <= this.selectedCameraIndex &&
  6020. this.selectedAnimationIndex < this.animations.length
  6021. ) {
  6022. var e = this.animations[this.selectedAnimationIndex];
  6023. if (this.selectedCameraIndex < e.cameraObjects.length)
  6024. return e.cameraObjects[this.selectedCameraIndex];
  6025. }
  6026. }),
  6027. (P.prototype.poseMeshes = function() {
  6028. for (
  6029. var e = this.animations[this.selectedAnimationIndex],
  6030. t = e.meshObjects.length,
  6031. i = 0;
  6032. i < t;
  6033. i++
  6034. ) {
  6035. var s = e.meshObjects[i];
  6036. if (this.enableSkinning && s.skinningRig)
  6037. if (s.skinningRig.isRigidSkin)
  6038. e.getWorldTransform(
  6039. s.id,
  6040. this.totalSeconds,
  6041. s.mesh.displayMatrix,
  6042. this.sceneScale,
  6043. !0
  6044. );
  6045. else {
  6046. s.setupSkinningRig(
  6047. e,
  6048. s.modelPartIndex,
  6049. this.totalSeconds,
  6050. s.skinningRig
  6051. ),
  6052. e.getWorldTransform(
  6053. s.id,
  6054. this.totalSeconds,
  6055. s.mesh.displayMatrix,
  6056. this.sceneScale,
  6057. !0
  6058. );
  6059. var n = s.modelPartScale * this.sceneScale;
  6060. if (this.unitScaleSkinnedMeshes) {
  6061. var r = s.mesh.displayMatrix,
  6062. a = r[0],
  6063. o = r[1],
  6064. h = r[2],
  6065. l = r[4],
  6066. d = r[5],
  6067. c = r[6],
  6068. u = r[8],
  6069. f = r[9],
  6070. m = r[10];
  6071. u =
  6072. ((a = Math.sqrt(a * a + o * o + h * h)) +
  6073. (l = Math.sqrt(l * l + d * d + c * c)) +
  6074. (u = Math.sqrt(u * u + f * f + m * m))) /
  6075. 2;
  6076. (r[0] /= u),
  6077. (r[1] /= u),
  6078. (r[2] /= u),
  6079. (r[4] /= u),
  6080. (r[5] /= u),
  6081. (r[6] /= u),
  6082. (r[8] /= u),
  6083. (r[9] /= u),
  6084. (r[10] /= u),
  6085. (n *= u);
  6086. }
  6087. s.skinningRig.deformMesh(s.mesh, n);
  6088. }
  6089. else
  6090. e.getWorldTransform(
  6091. s.id,
  6092. this.totalSeconds,
  6093. s.mesh.displayMatrix,
  6094. this.sceneScale,
  6095. !0
  6096. );
  6097. }
  6098. }),
  6099. (P.prototype.updateLights = function() {
  6100. for (
  6101. var e = this.animations[this.selectedAnimationIndex],
  6102. t = this.totalSeconds * e.originalFPS,
  6103. i = e.lightObjects.length,
  6104. s = 0;
  6105. s < i;
  6106. s++
  6107. ) {
  6108. var n = e.lightObjects[s],
  6109. r = this.scene.lights.getLightPos(n.lightIndex),
  6110. a = this.scene.lights.getLightDir(n.lightIndex),
  6111. o = this.scene.lights.getLightColor(n.lightIndex),
  6112. h = S.identity(),
  6113. l = 1;
  6114. n.useFixedWorldTransform ||
  6115. e.getWorldTransform(
  6116. n.id,
  6117. this.totalSeconds,
  6118. h,
  6119. this.sceneScale,
  6120. !0
  6121. ),
  6122. n.redProperty &&
  6123. (n.redProperty.evaluate(t, o[0], n),
  6124. (o[0] = n.redProperty.lastValue)),
  6125. n.greenProperty &&
  6126. (n.greenProperty.evaluate(t, o[1], n),
  6127. (o[1] = n.greenProperty.lastValue)),
  6128. n.blueProperty &&
  6129. (n.blueProperty.evaluate(t, o[2], n),
  6130. (o[2] = n.blueProperty.lastValue)),
  6131. n.brightnessProperty &&
  6132. (n.brightnessProperty.evaluate(t, l, n),
  6133. (l = n.brightnessProperty.lastValue)),
  6134. (o[0] *= l),
  6135. (o[1] *= l),
  6136. (o[2] *= l),
  6137. 0 != r[3] &&
  6138. (n.useFixedWorldTransform ||
  6139. ((r[0] = h[12]),
  6140. (r[1] = h[13]),
  6141. (r[2] = h[14]),
  6142. this.scene.lights.setLightPos(n.lightIndex, r)),
  6143. n.spotAngleProperty &&
  6144. 0 < this.scene.lights.spot[3 * n.lightIndex] &&
  6145. ((r = 0),
  6146. n.spotAngleProperty.evaluate(t, r, n),
  6147. (r = n.spotAngleProperty.lastValue),
  6148. this.scene.lights.setLightSpotAngle(n.lightIndex, r)),
  6149. n.spotSharpnessProperty &&
  6150. ((r = 0),
  6151. n.spotSharpnessProperty.evaluate(t, r, n),
  6152. (r = n.spotSharpnessProperty.lastValue),
  6153. this.scene.lights.setLightSpotSharpness(n.lightIndex, r)),
  6154. n.distanceProperty &&
  6155. ((r = 1),
  6156. n.distanceProperty.evaluate(t, r, n),
  6157. (r = n.distanceProperty.lastValue * this.sceneScale),
  6158. this.scene.lights.setLightDistance(n.lightIndex, r))),
  6159. n.useFixedWorldTransform ||
  6160. ((a[0] = h[8]),
  6161. (a[1] = h[9]),
  6162. (a[2] = h[10]),
  6163. this.scene.lights.setLightDir(n.lightIndex, a)),
  6164. this.scene.lights.setLightColor(n.lightIndex, o);
  6165. }
  6166. }),
  6167. (P.prototype.updateTurntables = function() {
  6168. for (
  6169. var e = this.animations[this.selectedAnimationIndex],
  6170. t = this.totalSeconds * e.originalFPS,
  6171. i = e.turnTableObjects.length,
  6172. s = 0;
  6173. s < i;
  6174. s++
  6175. ) {
  6176. var n = e.turnTableObjects[s];
  6177. n.spinProperty.evaluate(t, 0, n),
  6178. (n.turnTableSpin =
  6179. n.turnTableSpinOffset +
  6180. n.spinProperty.lastValue * this.totalSeconds);
  6181. }
  6182. }),
  6183. (P.prototype.rolloverTurntables = function() {
  6184. for (
  6185. var e = this.animations[this.selectedAnimationIndex],
  6186. t = e.turnTableObjects.length,
  6187. i = 0;
  6188. i < t;
  6189. i++
  6190. ) {
  6191. var s = e.turnTableObjects[i];
  6192. s.turnTableSpinOffset = s.turnTableSpin;
  6193. }
  6194. }),
  6195. (P.prototype.updateMaterials = function() {
  6196. for (
  6197. var e = this.animations[this.selectedAnimationIndex],
  6198. t = this.totalSeconds * e.originalFPS,
  6199. i = e.materialObjects.length,
  6200. s = 0;
  6201. s < i;
  6202. s++
  6203. ) {
  6204. var n = e.materialObjects[s];
  6205. n.offsetUProperty &&
  6206. (n.offsetUProperty.evaluate(t, 0, n),
  6207. (this.scene.materialsList[n.materialIndex].uOffset =
  6208. n.offsetUProperty.lastValue)),
  6209. n.offsetVProperty &&
  6210. (n.offsetVProperty.evaluate(t, 0, n),
  6211. (this.scene.materialsList[n.materialIndex].vOffset =
  6212. n.offsetVProperty.lastValue)),
  6213. n.emissiveProperty &&
  6214. 1 < n.emissiveProperty.numKeyframes &&
  6215. (n.emissiveProperty.evaluate(t, 0, n),
  6216. (this.scene.materialsList[n.materialIndex].emissiveIntensity =
  6217. n.emissiveProperty.lastValue));
  6218. }
  6219. }),
  6220. (P.prototype.updateFog = function() {
  6221. var e = this.animations[this.selectedAnimationIndex],
  6222. t = this.totalSeconds * e.originalFPS;
  6223. 0 <= this.fogObjectIndex &&
  6224. this.fogObjectIndex < e.animatedObjects.length &&
  6225. this.scene.fog &&
  6226. ((e = e.animatedObjects[this.fogObjectIndex]).redProperty &&
  6227. (this.scene.fog.desc.color[0] = e.redProperty.evaluate(
  6228. t,
  6229. this.scene.fog.desc.color[0],
  6230. e
  6231. )),
  6232. e.greenProperty &&
  6233. (this.scene.fog.desc.color[1] = e.greenProperty.evaluate(
  6234. t,
  6235. this.scene.fog.desc.color[1],
  6236. e
  6237. )),
  6238. e.blueProperty &&
  6239. (this.scene.fog.desc.color[2] = e.blueProperty.evaluate(
  6240. t,
  6241. this.scene.fog.desc.color[2],
  6242. e
  6243. )),
  6244. e.distanceProperty &&
  6245. (this.scene.fog.desc.distance = e.distanceProperty.evaluate(
  6246. t,
  6247. this.scene.fog.desc.distance,
  6248. e
  6249. )),
  6250. e.opacityProperty &&
  6251. (this.scene.fog.desc.opacity = e.opacityProperty.evaluate(
  6252. t,
  6253. this.scene.fog.desc.opacity,
  6254. e
  6255. )),
  6256. e.skyIllumProperty &&
  6257. (this.scene.fog.desc.skyIllum = e.skyIllumProperty.evaluate(
  6258. t,
  6259. this.scene.fog.desc.skyIllum,
  6260. e
  6261. )),
  6262. e.lightIllumProperty &&
  6263. (this.scene.fog.desc.lightIllum = e.lightIllumProperty.evaluate(
  6264. t,
  6265. this.scene.fog.desc.lightIllum,
  6266. e
  6267. )),
  6268. e.dispersionProperty &&
  6269. (this.scene.fog.desc.dispersion = e.dispersionProperty.evaluate(
  6270. t,
  6271. this.scene.fog.desc.dispersion,
  6272. e
  6273. )));
  6274. }),
  6275. (P.prototype.updateVisibility = function() {
  6276. for (
  6277. var e = this.animations[this.selectedAnimationIndex],
  6278. t = this.subMeshObjectIndices.length,
  6279. i = 0;
  6280. i < t;
  6281. i++
  6282. ) {
  6283. if (-1 != (n = this.subMeshLiveIndices[i])) {
  6284. var s = this.subMeshObjectIndices[i],
  6285. n = this.scene.meshRenderables[n],
  6286. r = e.getObjectAnimationFramePercent(
  6287. e.animatedObjects[s],
  6288. this.totalSeconds
  6289. );
  6290. n.visible = e.isVisibleAtFramePercent(s, r);
  6291. }
  6292. }
  6293. }),
  6294. (F.prototype.build = function(e, t) {
  6295. var i = this.gl;
  6296. (this.program = i.createProgram()),
  6297. (this.params = {}),
  6298. (this.samplers = {}),
  6299. (this.attribs = {});
  6300. var s = function(e) {
  6301. for (var t = "", i = e.indexOf("\n"), s = 0; -1 != i; )
  6302. (t += ++s + ": "),
  6303. (t += e.substring(0, i + 1)),
  6304. (i = (e = e.substring(i + 1, e.length)).indexOf("\n"));
  6305. console.log(t);
  6306. },
  6307. n = i.createShader(i.VERTEX_SHADER);
  6308. i.shaderSource(n, e),
  6309. i.compileShader(n),
  6310. i.getShaderParameter(n, i.COMPILE_STATUS) ||
  6311. (console.log(i.getShaderInfoLog(n)), I.verboseErrors && s(e)),
  6312. i.attachShader(this.program, n),
  6313. (n = i.createShader(i.FRAGMENT_SHADER)),
  6314. i.shaderSource(n, t),
  6315. i.compileShader(n),
  6316. i.getShaderParameter(n, i.COMPILE_STATUS) ||
  6317. (console.log(i.getShaderInfoLog(n)), I.verboseErrors && s(t)),
  6318. i.attachShader(this.program, n),
  6319. i.linkProgram(this.program),
  6320. i.getProgramParameter(this.program, i.LINK_STATUS) ||
  6321. console.log(i.getProgramInfoLog(this.program));
  6322. n = i.getProgramParameter(this.program, i.ACTIVE_UNIFORMS);
  6323. var r = 0;
  6324. for (s = 0; s < n; ++s) {
  6325. var a = i.getActiveUniform(this.program, s),
  6326. o = a.name,
  6327. h = o.indexOf("[");
  6328. 0 <= h && (o = o.substring(0, h)),
  6329. (h = i.getUniformLocation(this.program, a.name)),
  6330. a.type == i.SAMPLER_2D || a.type == i.SAMPLER_CUBE
  6331. ? (this.samplers[o] = { location: h, unit: r++ })
  6332. : (this.params[o] = h);
  6333. }
  6334. for (
  6335. n = i.getProgramParameter(this.program, i.ACTIVE_ATTRIBUTES), s = 0;
  6336. s < n;
  6337. ++s
  6338. )
  6339. (r = i.getActiveAttrib(this.program, s)),
  6340. (this.attribs[r.name] = i.getAttribLocation(this.program, r.name));
  6341. }),
  6342. (F.prototype.bind = function() {
  6343. return !!this.program && (this.gl.useProgram(this.program), !0);
  6344. }),
  6345. (F.prototype.complete = function() {
  6346. return !!this.program;
  6347. }),
  6348. (O.prototype.fromURLs = function(e, t, i) {
  6349. var s = "";
  6350. if (i) for (var n = 0; n < i.length; ++n) s = i[n] + "\n" + s;
  6351. if (((i = s + ":" + e + "|" + t), void 0 !== (n = this.cache[i])))
  6352. return n;
  6353. function r() {
  6354. null != o && null != h && a.build(o, h);
  6355. }
  6356. var a = new F(this.gl),
  6357. o = null,
  6358. h = null;
  6359. return (
  6360. this.fetch(e, function(e) {
  6361. (o = s + e), r();
  6362. }),
  6363. this.fetch(t, function(e) {
  6364. (h = s + e), r();
  6365. }),
  6366. (this.cache[i] = a)
  6367. );
  6368. }),
  6369. (O.prototype.fetch = function(e, t) {
  6370. void 0 !== G
  6371. ? void 0 !== G[e]
  6372. ? this.resolveIncludes(new String(G[e]), t)
  6373. : t("")
  6374. : C.fetchText(
  6375. "src/shader/" + e,
  6376. function(e) {
  6377. this.resolveIncludes(e, t);
  6378. }.bind(this),
  6379. function() {
  6380. t("");
  6381. }
  6382. );
  6383. }),
  6384. (O.prototype.resolveIncludes = function(t, i) {
  6385. for (
  6386. var r = [],
  6387. a = !0,
  6388. e = function(e, t, i, s, n) {
  6389. return (
  6390. (a = !0),
  6391. r.push({ offset: n, path: t.slice(1, t.length - 1) }),
  6392. ""
  6393. );
  6394. };
  6395. a;
  6396. )
  6397. (a = !1), (t = t.replace(/#include\s((<[^>]+>)|("[^"]+"))/, e));
  6398. if (0 < r.length) {
  6399. var s = r.length;
  6400. for (e = 0; e < r.length; ++e)
  6401. this.fetch(
  6402. r[e].path,
  6403. function(e) {
  6404. if (((this.src = e), --s <= 0)) {
  6405. for (e = r.length - 1; 0 <= e; --e)
  6406. t =
  6407. t.substring(0, r[e].offset) +
  6408. r[e].src +
  6409. t.substring(r[e].offset);
  6410. i(t);
  6411. }
  6412. }.bind(r[e])
  6413. );
  6414. } else i(t);
  6415. }),
  6416. (E.prototype.bindDepthTexture = function(e, t) {
  6417. this.shadowCount > t && this.depthTextures[t].bind(e);
  6418. }),
  6419. (E.prototype.collect = function(e, t) {
  6420. for (
  6421. var i = this.gl,
  6422. s = e.lights,
  6423. n = s.shadowCount,
  6424. r = s.modelViewBuffer,
  6425. a = s.projectionBuffer,
  6426. o = s.matrix,
  6427. h = 0 != e.sceneAnimator,
  6428. l = S.empty(),
  6429. d = !1,
  6430. c = 0;
  6431. c < n;
  6432. ++c
  6433. )
  6434. if (s.shadowsNeedUpdate[c]) {
  6435. (d = !(s.shadowsNeedUpdate[c] = 0)),
  6436. S.mul(l, r.subarray(16 * c, 16 * (c + 1)), o),
  6437. S.mul(l, a.subarray(16 * c, 16 * (c + 1)), l),
  6438. this.depthTargets[c].bind(),
  6439. i.clearColor(1, 1, 1, 1),
  6440. i.clear(i.COLOR_BUFFER_BIT | i.DEPTH_BUFFER_BIT);
  6441. var u = this.shaderSolid;
  6442. u.bind(),
  6443. i.uniformMatrix4fv(u.params.uViewProjection, !1, l),
  6444. i.uniformMatrix4fv(u.params.uMeshTransform, !1, S.identity());
  6445. for (var f = 0; f < e.meshRenderables.length; ++f) {
  6446. var m = e.meshRenderables[f],
  6447. p = m.material;
  6448. !m.mesh.desc.castShadows ||
  6449. !p.castShadows ||
  6450. 0 < p.shadowAlphaTest ||
  6451. (h &&
  6452. i.uniformMatrix4fv(
  6453. u.params.uMeshTransform,
  6454. !1,
  6455. m.mesh.displayMatrix
  6456. ),
  6457. m.drawShadow(u.attribs.vPosition));
  6458. }
  6459. for (
  6460. (u = this.shaderAlphaTest).bind(),
  6461. i.uniformMatrix4fv(u.params.uViewProjection, !1, l),
  6462. i.uniformMatrix4fv(u.params.uMeshTransform, !1, S.identity()),
  6463. f = 0;
  6464. f < e.meshRenderables.length;
  6465. ++f
  6466. )
  6467. (p = (m = e.meshRenderables[f]).material),
  6468. m.mesh.desc.castShadows &&
  6469. p.castShadows &&
  6470. 0 < p.shadowAlphaTest &&
  6471. (p.textures.albedo.bind(u.samplers.tAlbedo),
  6472. h &&
  6473. (i.uniform2f(u.params.uUVOffset, p.uOffset, p.vOffset),
  6474. i.uniformMatrix4fv(
  6475. u.params.uMeshTransform,
  6476. !1,
  6477. m.mesh.displayMatrix
  6478. )),
  6479. m.drawAlphaShadow(u.attribs.vPosition, u.attribs.vTexCoord));
  6480. }
  6481. d && (t.bind(), i.enable(i.CULL_FACE), i.cullFace(i.BACK));
  6482. }),
  6483. (E.prototype.complete = function() {
  6484. return this.shaderSolid.complete() && this.shaderAlphaTest.complete();
  6485. }),
  6486. (B.prototype.draw = function(e) {
  6487. var t = e.view,
  6488. i = e.lights,
  6489. s = e.shadow,
  6490. n = this.gl,
  6491. r = this.shader.params,
  6492. a = this.shader.samplers;
  6493. this.shader.bind(),
  6494. (t = S.mul(S.empty(), t.projectionMatrix, t.viewMatrix)),
  6495. S.mul(t, t, this.desc.transform),
  6496. n.uniformMatrix4fv(r.uModelViewProjectionMatrix, !1, t),
  6497. (t = S.mul(S.empty(), i.matrix, this.desc.transform)),
  6498. n.uniformMatrix4fv(r.uModelSkyMatrix, !1, t),
  6499. 0 < i.count &&
  6500. (n.uniform4fv(r.uLightPositions, i.positionBuffer),
  6501. n.uniform3fv(r.uLightDirections, i.directionBuffer),
  6502. n.uniform3fv(r.uLightColors, i.colors),
  6503. n.uniform3fv(r.uLightParams, i.parameters),
  6504. n.uniform3fv(r.uLightSpot, i.spot),
  6505. (e = 0.392699 * e.postRender.currentSample()),
  6506. n.uniform2f(
  6507. r.uShadowKernelRotation,
  6508. 0.5 * Math.cos(e),
  6509. 0.5 * Math.sin(e)
  6510. ),
  6511. 0 < i.shadowCount &&
  6512. ((e = s.depthTextures[0].desc.width),
  6513. n.uniform2f(r.uShadowMapSize, e, 1 / e),
  6514. n.uniformMatrix4fv(r.uShadowMatrices, !1, i.finalTransformBuffer),
  6515. n.uniformMatrix4fv(
  6516. r.uInvShadowMatrices,
  6517. !1,
  6518. i.inverseTransformBuffer
  6519. ),
  6520. n.uniform4fv(
  6521. r.uShadowTexelPadProjections,
  6522. i.shadowTexelPadProjections
  6523. ),
  6524. s.bindDepthTexture(a.tDepth0, 0),
  6525. s.bindDepthTexture(a.tDepth1, 1),
  6526. s.bindDepthTexture(a.tDepth2, 2))),
  6527. n.uniform3f(
  6528. r.uShadowCatcherParams,
  6529. this.desc.simple ? 1 : 0,
  6530. this.desc.alpha,
  6531. this.desc.edgeFade
  6532. ),
  6533. n.depthMask(!1),
  6534. n.enable(n.BLEND),
  6535. n.blendFunc(n.ZERO, n.SRC_COLOR),
  6536. (i = this.shader.attribs.vPosition),
  6537. n.bindBuffer(n.ARRAY_BUFFER, this.quadGeom),
  6538. n.enableVertexAttribArray(i),
  6539. n.vertexAttribPointer(i, 3, n.FLOAT, !1, 0, 0),
  6540. n.drawArrays(n.TRIANGLES, 0, 6),
  6541. n.disableVertexAttribArray(i),
  6542. n.bindBuffer(n.ARRAY_BUFFER, null),
  6543. n.disable(n.BLEND),
  6544. n.depthMask(!0);
  6545. }),
  6546. (B.prototype.complete = function() {
  6547. return this.shader.complete();
  6548. }),
  6549. (L.prototype.solveAdditiveClusterTransform = function(e, t, i) {
  6550. t = S.identity();
  6551. var s = S.identity(),
  6552. n = S.identity();
  6553. S.mul(t, e, this.defaultClusterBaseTransform),
  6554. S.mul(s, this.defaultAssociateWorldTransformInvert, t),
  6555. S.mul(n, this.defaultAssociateWorldTransformInvert, s),
  6556. S.mul(i, this.defaultClusterWorldTransformInvert, n);
  6557. }),
  6558. (L.prototype.solveSimpleClusterTransform = function(e, t, i) {
  6559. var s = S.identity(),
  6560. n = S.identity();
  6561. S.invert(n, t),
  6562. S.mul(s, n, e),
  6563. S.mul(i, s, this.defaultClusterBaseTransform);
  6564. }),
  6565. (L.prototype.solveClusterTransformAtFrame = function(e, t, i, s) {
  6566. if (1 == this.linkMode) {
  6567. var n = S.identity();
  6568. (t = S.identity()),
  6569. e.evaluateModelPartTransformAtFrame(this.linkObjectIndex, i, n, !1),
  6570. e.evaluateModelPartTransformAtFrame(
  6571. this.associateObjectIndex,
  6572. i,
  6573. t,
  6574. !1
  6575. ),
  6576. this.solveAdditiveClusterTransform(n, t, s);
  6577. } else {
  6578. n = S.identity();
  6579. var r = S.identity();
  6580. e.evaluateModelPartTransformAtFrame(this.linkObjectIndex, i, n, !1),
  6581. e.evaluateModelPartTransformAtFrame(t, i, r, !1),
  6582. this.solveSimpleClusterTransform(n, r, s);
  6583. }
  6584. }),
  6585. (M.prototype.unpackUnitVectors = function(e, t, i, s) {
  6586. for (var n = 0; n < i; n++) {
  6587. var r = t[s * n],
  6588. a = 32768 <= (o = t[s * n + 1]);
  6589. a && (o -= 32768);
  6590. var o,
  6591. h =
  6592. 1 -
  6593. ((r = (r / 32767.4) * 2 - 1) * r +
  6594. (o = (o / 32767.4) * 2 - 1) * o);
  6595. (h = Math.sqrt(h)), (h = isNaN(h) ? 0 : h);
  6596. a && (h = -h), (e[3 * n] = r), (e[3 * n + 1] = o), (e[3 * n + 2] = h);
  6597. }
  6598. }),
  6599. (M.prototype.copyOriginalVertices = function(e) {
  6600. if (!this.unTransformedVertices)
  6601. if (
  6602. ((this.unTransformedVertices = new Float32Array(3 * e.vertexCount)),
  6603. (this.unTransformedNormals = new Float32Array(3 * e.vertexCount)),
  6604. (this.unTransformedTangents = new Float32Array(3 * e.vertexCount)),
  6605. (this.unTransformedBiTangents = new Float32Array(
  6606. 3 * e.vertexCount
  6607. )),
  6608. (this.skinVertexWeights = new Float32Array(e.vertexCount)),
  6609. (this.skinVertexTransform4x3 = new Float32Array(12)),
  6610. e.dynamicVertexData)
  6611. ) {
  6612. var t = new Float32Array(e.dynamicVertexData.buffer);
  6613. new Uint8Array(e.dynamicVertexData.buffer);
  6614. var i = (s = 0),
  6615. s = s + 12 + 8;
  6616. e.secondaryTexCoord && (s += 8);
  6617. var n = s,
  6618. r = (s += 4),
  6619. a = ((s = s + 4), e.stride / 2);
  6620. (s = new Uint8Array(e.dynamicVertexData.subarray(s))),
  6621. (s = new Uint16Array(s.buffer)),
  6622. (n = new Uint8Array(e.dynamicVertexData.subarray(n))),
  6623. (n = new Uint16Array(n.buffer)),
  6624. (r = new Uint8Array(e.dynamicVertexData.subarray(r))),
  6625. (r = new Uint16Array(r.buffer));
  6626. for (
  6627. this.unpackUnitVectors(
  6628. this.unTransformedNormals,
  6629. s,
  6630. e.vertexCount,
  6631. a
  6632. ),
  6633. this.unpackUnitVectors(
  6634. this.unTransformedTangents,
  6635. n,
  6636. e.vertexCount,
  6637. a
  6638. ),
  6639. this.unpackUnitVectors(
  6640. this.unTransformedBiTangents,
  6641. r,
  6642. e.vertexCount,
  6643. a
  6644. ),
  6645. a = 0;
  6646. a < e.vertexCount;
  6647. a++
  6648. )
  6649. (r = (e.stride * a + i) / 4),
  6650. (this.unTransformedVertices[3 * a] = t[r]),
  6651. (this.unTransformedVertices[3 * a + 1] = t[r + 1]),
  6652. (this.unTransformedVertices[3 * a + 2] = t[r + 2]);
  6653. } else
  6654. this.debugString +=
  6655. "<br>Can't init skinning rig - mesh buffer is not dynamic - rigid is " +
  6656. this.isRigidSkin;
  6657. }),
  6658. (M.prototype.useOriginalMeshVertices = function(e) {
  6659. this.isRigidSkin
  6660. ? (this.debugString += "<br>useOriginalMeshVertices for rigid skin?")
  6661. : this.copyOriginalVertices(e);
  6662. }),
  6663. (M.prototype.deformMeshVertices = function(e, t) {
  6664. if (0 != this.skinningClusters.length && this.unTransformedVertices) {
  6665. var i,
  6666. s = e.stride / 4,
  6667. n = new Float32Array(e.dynamicVertexData.buffer),
  6668. r = new Uint16Array(e.dynamicVertexData.buffer);
  6669. new Uint8Array(e.dynamicVertexData.buffer),
  6670. (i = 20),
  6671. e.secondaryTexCoord && (i += 8);
  6672. var a = i,
  6673. o = (i += 4);
  6674. i += 4;
  6675. for (
  6676. var h = this.unTransformedVertices.length / 3, l = 0, d = 0;
  6677. d < h;
  6678. ++d
  6679. ) {
  6680. var c = d,
  6681. u = (c * e.stride + a) / 2,
  6682. f = (c * e.stride + o) / 2,
  6683. m = (c * e.stride + i) / 2,
  6684. p = this.linkMapCount[c];
  6685. ((k = this.skinVertexTransform4x3)[
  6686. (this.skinVertexWeights[c] = 0)
  6687. ] = 0),
  6688. (k[1] = 0),
  6689. (k[2] = 0),
  6690. (k[3] = 0),
  6691. (k[4] = 0),
  6692. (k[5] = 0),
  6693. (k[6] = 0),
  6694. (k[7] = 0),
  6695. (k[8] = 0),
  6696. (k[9] = 0),
  6697. (k[10] = 0),
  6698. (k[11] = 0);
  6699. var g = this.linkMapWeights[l];
  6700. if (1 == p && 1 == g) {
  6701. var v = this.linkMapClusterIndices[l],
  6702. x = (v = this.skinningClusters[v]).matrix;
  6703. (k[0] = x[0]),
  6704. (k[1] = x[1]),
  6705. (k[2] = x[2]),
  6706. (k[3] = x[4]),
  6707. (k[4] = x[5]),
  6708. (k[5] = x[6]),
  6709. (k[6] = x[8]),
  6710. (k[7] = x[9]),
  6711. (k[8] = x[10]),
  6712. (k[9] = x[12]),
  6713. (k[10] = x[13]),
  6714. (k[11] = x[14]),
  6715. (this.skinVertexWeights[c] = 1);
  6716. } else
  6717. for (var y = (this.skinVertexWeights[c] = 0); y < p; y++)
  6718. (g = this.linkMapWeights[l + y]),
  6719. (v = this.linkMapClusterIndices[l + y]) <
  6720. this.skinningClusters.length &&
  6721. ((x = (v = this.skinningClusters[v]).matrix),
  6722. (k[0] += g * x[0]),
  6723. (k[1] += g * x[1]),
  6724. (k[2] += g * x[2]),
  6725. (k[3] += g * x[4]),
  6726. (k[4] += g * x[5]),
  6727. (k[5] += g * x[6]),
  6728. (k[6] += g * x[8]),
  6729. (k[7] += g * x[9]),
  6730. (k[8] += g * x[10]),
  6731. (k[9] += g * x[12]),
  6732. (k[10] += g * x[13]),
  6733. (k[11] += g * x[14]),
  6734. (this.skinVertexWeights[c] += g),
  6735. 1 == v.linkMode && (this.skinVertexWeights[c] = 1));
  6736. if (((l += this.linkMapCount[d]), 0 < this.skinVertexWeights[c])) {
  6737. var b = this.unTransformedVertices[3 * d + 0],
  6738. S = this.unTransformedVertices[3 * d + 1],
  6739. T = this.unTransformedVertices[3 * d + 2],
  6740. w = this.unTransformedNormals[3 * d + 0],
  6741. C = this.unTransformedNormals[3 * d + 1],
  6742. R = this.unTransformedNormals[3 * d + 2],
  6743. A =
  6744. ((v = this.unTransformedTangents[3 * d + 0]),
  6745. (x = this.unTransformedTangents[3 * d + 1]),
  6746. this.unTransformedTangents[3 * d + 2]),
  6747. k =
  6748. ((p = this.unTransformedBiTangents[3 * d + 0]),
  6749. this.unTransformedBiTangents[3 * d + 1]),
  6750. I =
  6751. ((g = this.unTransformedBiTangents[3 * d + 2]),
  6752. (y = this.skinVertexTransform4x3),
  6753. 1);
  6754. 0 < this.skinVertexWeights[c] &&
  6755. (I = 1 / this.skinVertexWeights[c]),
  6756. (n[s * d] = I * (b * y[0] + S * y[3] + T * y[6] + y[9]) * t),
  6757. (n[s * d + 1] =
  6758. I * (b * y[1] + S * y[4] + T * y[7] + y[10]) * t),
  6759. (n[s * d + 2] =
  6760. I * (b * y[2] + S * y[5] + T * y[8] + y[11]) * t),
  6761. (b = w * y[0] + C * y[3] + R * y[6]),
  6762. (c = w * y[1] + C * y[4] + R * y[7]),
  6763. (w = w * y[2] + C * y[5] + R * y[8]),
  6764. (C = v * y[0] + x * y[3] + A * y[6]),
  6765. (R = v * y[1] + x * y[4] + A * y[7]),
  6766. (v = v * y[2] + x * y[5] + A * y[8]),
  6767. (x = p * y[0] + k * y[3] + g * y[6]),
  6768. (A = p * y[1] + k * y[4] + g * y[7]),
  6769. (p = p * y[2] + k * y[5] + g * y[8]),
  6770. (c /= k = Math.sqrt(b * b + c * c + w * w)),
  6771. (w /= k),
  6772. (k = 32767.4 * ((b /= k) / 2 + 0.5)),
  6773. (g = 32767.4 * (c / 2 + 0.5)),
  6774. w < 0 && (g += 32768),
  6775. (r[m] = Math.floor(k)),
  6776. (r[1 + m] = Math.floor(g)),
  6777. (R /= k = Math.sqrt(C * C + R * R + v * v)),
  6778. (v /= k),
  6779. (k = 32767.4 * ((C /= k) / 2 + 0.5)),
  6780. (g = 32767.4 * (R / 2 + 0.5)),
  6781. v < 0 && (g += 32768),
  6782. (r[u] = Math.floor(k)),
  6783. (r[1 + u] = Math.floor(g)),
  6784. (A /= k = Math.sqrt(x * x + A * A + p * p)),
  6785. (p /= k),
  6786. (k = 32767.4 * ((x /= k) / 2 + 0.5)),
  6787. (g = 32767.4 * (A / 2 + 0.5)),
  6788. p < 0 && (g += 32768),
  6789. (r[f] = Math.floor(k)),
  6790. (r[1 + f] = Math.floor(g));
  6791. } else
  6792. (b = this.unTransformedVertices[3 * d + 0]),
  6793. (S = this.unTransformedVertices[3 * d + 1]),
  6794. (T = this.unTransformedVertices[3 * d + 2]),
  6795. (n[s * d] = b * t),
  6796. (n[s * d + 1] = S * t),
  6797. (n[s * d + 2] = T * t);
  6798. }
  6799. }
  6800. }),
  6801. (M.prototype.deformMesh = function(e, t) {
  6802. if (0 != this.skinningClusters.length && !this.isRigidSkin) {
  6803. this.deformMeshVertices(e, t);
  6804. var i = e.gl;
  6805. i.bindBuffer(i.ARRAY_BUFFER, e.vertexBuffer),
  6806. i.bufferData(i.ARRAY_BUFFER, e.dynamicVertexData, i.DYNAMIC_DRAW),
  6807. i.bindBuffer(i.ARRAY_BUFFER, null);
  6808. }
  6809. }),
  6810. (_.prototype.setClearColor = function() {
  6811. if (I.transparentBackground) this.gl.clearColor(0, 0, 0, 0);
  6812. else if (this.backgroundMode < 1) {
  6813. var e = this.backgroundColor;
  6814. this.gl.clearColor(e[0], e[1], e[2], 1);
  6815. } else this.gl.clearColor(0.0582, 0.06772, 0.07805, 1);
  6816. }),
  6817. (_.prototype.draw = function(e) {
  6818. if (this.backgroundMode < 1 || I.transparentBackground) return !1;
  6819. if (this.complete()) {
  6820. var t = this.gl,
  6821. i = this.backgroundShader,
  6822. s = e.view,
  6823. n = e.lights.invMatrix;
  6824. i.bind(),
  6825. t.uniformMatrix4fv(i.params.uInverseSkyMatrix, !1, n),
  6826. t.uniformMatrix4fv(
  6827. i.params.uViewProjection,
  6828. !1,
  6829. s.viewProjectionMatrix
  6830. ),
  6831. 3 == this.backgroundMode
  6832. ? t.uniform4fv(
  6833. i.params.uSkyCoefficients,
  6834. this.backgroundCoefficients
  6835. )
  6836. : this.backgroundTexture.bind(i.samplers.tSkyTexture),
  6837. (e = 0.07 + 0.94 * (1 - e.stripData.activeFade())),
  6838. t.uniform1f(i.params.uAlpha, e),
  6839. t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer),
  6840. t.enableVertexAttribArray(i.attribs.vPosition),
  6841. t.vertexAttribPointer(i.attribs.vPosition, 3, t.FLOAT, !1, 20, 0),
  6842. t.enableVertexAttribArray(i.attribs.vTexCoord),
  6843. t.vertexAttribPointer(i.attribs.vTexCoord, 2, t.FLOAT, !1, 20, 12),
  6844. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer),
  6845. e < 1 &&
  6846. (t.enable(t.BLEND),
  6847. t.blendFunc(t.SRC_ALPHA, t.ONE_MINUS_SRC_ALPHA)),
  6848. t.depthMask(!1),
  6849. t.disable(t.DEPTH_TEST),
  6850. t.drawElements(
  6851. t.TRIANGLES,
  6852. this.skyIndexCount,
  6853. t.UNSIGNED_SHORT,
  6854. 0
  6855. ),
  6856. t.enable(t.DEPTH_TEST),
  6857. t.depthMask(!0),
  6858. e < 1 && t.disable(t.BLEND),
  6859. t.disableVertexAttribArray(i.attribs.vPosition),
  6860. t.disableVertexAttribArray(i.attribs.vTexCoord);
  6861. }
  6862. }),
  6863. (_.prototype.complete = function() {
  6864. return (
  6865. !(this.backgroundShader && !this.backgroundShader.complete()) &&
  6866. this.specularTexture.complete()
  6867. );
  6868. }),
  6869. (D.expDecay = function(e, t) {
  6870. return Math.exp((-0.69314718 / e) * t);
  6871. }),
  6872. (D.prototype.update = function(e) {
  6873. var t = 0.001 * (Date.now() - this.timestamp);
  6874. this.timestamp = Date.now();
  6875. for (var i = !1, s = 0; s < this.stripCount; ++s) {
  6876. var n =
  6877. this.selectedStrip == this.STRIP_MENU
  6878. ? 0.3 * (s + 1) - 0.9
  6879. : this.selectedStrip < 0 || s < this.selectedStrip
  6880. ? -2
  6881. : 2;
  6882. if (e) this.strips[s] = n;
  6883. else {
  6884. var r = (r = n - this.strips[s]) * D.expDecay(0.05, t);
  6885. this.animationActive && (this.strips[s] = n - r),
  6886. (i = i || 0.001 < Math.abs(r));
  6887. }
  6888. }
  6889. this.animationActive = i;
  6890. }),
  6891. (D.prototype.active = function() {
  6892. return this.selectedStrip >= this.STRIP_MENU;
  6893. }),
  6894. (D.prototype.activeFade = function() {
  6895. var e;
  6896. return (e =
  6897. 1 <
  6898. (e =
  6899. (this.strips[this.stripCount - 1] - -2) /
  6900. (0.3 * this.stripCount - 0.9 - -2))
  6901. ? 1
  6902. : e) < 0
  6903. ? 0
  6904. : e;
  6905. }),
  6906. (D.prototype.activeWireframe = function() {
  6907. return (
  6908. this.active() && 0.01 < Math.abs(this.strips[4] - this.strips[3])
  6909. );
  6910. }),
  6911. (D.prototype.toggleMenu = function() {
  6912. this.selectedStrip =
  6913. this.selectedStrip == this.STRIP_MENU
  6914. ? this.STRIP_NONE
  6915. : this.STRIP_MENU;
  6916. }),
  6917. (D.prototype.selectStrip = function(e, t) {
  6918. if (this.selectedStrip == this.STRIP_MENU) {
  6919. var i = e + t * this.stripSlant;
  6920. this.selectedStrip = this.STRIP_NONE;
  6921. for (var s = 0; s < this.stripCount; ++s)
  6922. if (i < this.strips[s]) {
  6923. this.selectedStrip = s;
  6924. break;
  6925. }
  6926. } else this.selectedStrip = this.STRIP_MENU;
  6927. }),
  6928. (U.prototype.loadImage = function(e, t) {
  6929. var i = this.gl;
  6930. e &&
  6931. e.width &&
  6932. e.height &&
  6933. ((this.desc.width = e.width), (this.desc.height = e.height)),
  6934. (this.id = i.createTexture()),
  6935. i.bindTexture(this.type, this.id),
  6936. (this.format = t || i.RGBA),
  6937. (this.componentType = i.UNSIGNED_BYTE),
  6938. i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !0),
  6939. i.texImage2D(
  6940. this.type,
  6941. 0,
  6942. this.format,
  6943. this.format,
  6944. this.componentType,
  6945. e
  6946. ),
  6947. this.setParams(),
  6948. i.bindTexture(this.type, null);
  6949. }),
  6950. (U.prototype.loadArray = function(e, t, i) {
  6951. var s = this.gl;
  6952. (this.id = s.createTexture()),
  6953. s.bindTexture(this.type, this.id),
  6954. (this.format = t || s.RGBA),
  6955. (this.componentType = i || s.UNSIGNED_BYTE),
  6956. s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, !0),
  6957. s.texImage2D(
  6958. this.type,
  6959. 0,
  6960. this.format,
  6961. this.desc.width,
  6962. this.desc.height,
  6963. 0,
  6964. this.format,
  6965. this.componentType,
  6966. e || null
  6967. ),
  6968. this.setParams(),
  6969. s.bindTexture(this.type, null);
  6970. }),
  6971. (U.prototype.setParams = function() {
  6972. var e = this.gl,
  6973. t = function(e) {
  6974. return 0 < e && 0 == (e & (e - 1));
  6975. };
  6976. (t(this.desc.width) && t(this.desc.height)) ||
  6977. ((this.desc.clamp = !0), (this.desc.mipmap = !1)),
  6978. (t = !this.desc.nofilter),
  6979. this.desc.mipmap
  6980. ? (e.generateMipmap(this.type),
  6981. e.texParameteri(
  6982. this.type,
  6983. e.TEXTURE_MIN_FILTER,
  6984. t ? e.LINEAR_MIPMAP_LINEAR : e.NEAREST_MIPMAP_NEAREST
  6985. ))
  6986. : e.texParameteri(
  6987. this.type,
  6988. e.TEXTURE_MIN_FILTER,
  6989. t ? e.LINEAR : e.NEAREST
  6990. ),
  6991. e.texParameteri(
  6992. this.type,
  6993. e.TEXTURE_MAG_FILTER,
  6994. t ? e.LINEAR : e.NEAREST
  6995. ),
  6996. (this.desc.clamp || this.desc.mirror) &&
  6997. ((t = this.desc.clamp ? e.CLAMP_TO_EDGE : e.MIRRORED_REPEAT),
  6998. e.texParameteri(this.type, e.TEXTURE_WRAP_S, t),
  6999. e.texParameteri(this.type, e.TEXTURE_WRAP_T, t)),
  7000. this.desc.aniso &&
  7001. e.ext.textureAniso &&
  7002. e.texParameteri(
  7003. this.type,
  7004. e.ext.textureAniso.TEXTURE_MAX_ANISOTROPY_EXT,
  7005. this.desc.aniso
  7006. );
  7007. }),
  7008. (U.prototype.rebuildMips = function() {
  7009. this.desc.mipmap &&
  7010. (this.gl.bindTexture(this.type, this.id),
  7011. this.gl.generateMipmap(this.type));
  7012. }),
  7013. (U.prototype.copyColorBuffer = function() {
  7014. this.gl.bindTexture(this.type, this.id),
  7015. this.gl.copyTexSubImage2D(
  7016. this.type,
  7017. 0,
  7018. 0,
  7019. 0,
  7020. 0,
  7021. 0,
  7022. this.desc.width,
  7023. this.desc.height
  7024. );
  7025. }),
  7026. (U.prototype.bind = function(e) {
  7027. if (e) {
  7028. var t = this.gl;
  7029. t.uniform1i(e.location, e.unit),
  7030. t.activeTexture(t.TEXTURE0 + e.unit),
  7031. t.bindTexture(this.type, this.id);
  7032. }
  7033. }),
  7034. (U.prototype.destroy = function() {
  7035. this.gl.deleteTexture(this.id), (this.id = null);
  7036. }),
  7037. (U.prototype.complete = function() {
  7038. return !!this.id;
  7039. }),
  7040. (N.prototype.fromURL = function(e, t) {
  7041. var i = this.cache[e];
  7042. if (void 0 !== i) return i;
  7043. var s = new U(this.gl, t);
  7044. return (
  7045. C.fetchImage(e, function(e) {
  7046. s.loadImage(e);
  7047. }),
  7048. (this.cache[e] = s)
  7049. );
  7050. }),
  7051. (N.prototype.fromFile = function(e, t) {
  7052. if (!e) return null;
  7053. var i = this.cache[e.name];
  7054. if (void 0 !== i) return i;
  7055. var s = new U(this.gl, t);
  7056. return (
  7057. (this.cache[e.name] = s),
  7058. N.parseFile(e, function(e) {
  7059. s.loadImage(e), N.closeImage(e);
  7060. }),
  7061. s
  7062. );
  7063. }),
  7064. (N.prototype.fromFilesMergeAlpha = function(e, t, i) {
  7065. if (!t) return this.fromFile(e, i);
  7066. var s = e.name + "|" + t.name,
  7067. n = this.cache[s];
  7068. if (void 0 !== n) return n;
  7069. var r = this.gl;
  7070. this.blitShader ||
  7071. ((this.blitShader = new F(this.gl)),
  7072. this.blitShader.build(
  7073. "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; }",
  7074. "precision highp float; varying vec2 c; uniform sampler2D tTex; void main(){ gl_FragColor=texture2D(tTex,c).rgbr; }"
  7075. ),
  7076. (this.mergeVerts = r.createBuffer()),
  7077. r.bindBuffer(r.ARRAY_BUFFER, this.mergeVerts),
  7078. (n = new Float32Array([0, 0, 2, 0, 0, 2])),
  7079. r.bufferData(r.ARRAY_BUFFER, n, r.STATIC_DRAW),
  7080. r.bindBuffer(r.ARRAY_BUFFER, null));
  7081. var a = function(e) {
  7082. this.blitShader.bind(),
  7083. e.bind(this.blitShader.samplers.tTex),
  7084. r.bindBuffer(r.ARRAY_BUFFER, this.mergeVerts),
  7085. r.enableVertexAttribArray(this.blitShader.attribs.pos),
  7086. r.vertexAttribPointer(
  7087. this.blitShader.attribs.pos,
  7088. 2,
  7089. r.FLOAT,
  7090. !1,
  7091. 0,
  7092. 0
  7093. ),
  7094. r.drawArrays(r.TRIANGLES, 0, 3),
  7095. r.disableVertexAttribArray(this.blitShader.attribs.pos),
  7096. r.bindBuffer(r.ARRAY_BUFFER, null);
  7097. }.bind(this),
  7098. o = new U(this.gl, i);
  7099. this.cache[s] = o;
  7100. var h = 0,
  7101. l = 0,
  7102. d = function() {
  7103. if (h && l) {
  7104. var e, t;
  7105. if (
  7106. ((t =
  7107. l.width * l.height > h.width * h.height
  7108. ? ((e = l.width), l.height)
  7109. : ((e = h.width), h.height)),
  7110. (o.desc.width = e),
  7111. (o.desc.height = t),
  7112. e <= r.limits.viewportSizes[0] &&
  7113. t <= r.limits.viewportSizes[1])
  7114. ) {
  7115. var i = { clamp: !0 };
  7116. h.width == e && h.height == t
  7117. ? (o.loadImage(h, r.RGBA),
  7118. (e = new m(r, { color0: o, ignoreStatus: !0 })),
  7119. N.closeImage(h))
  7120. : ((t = new U(r, i)).loadImage(h, r.RGB),
  7121. N.closeImage(h),
  7122. o.loadArray(null),
  7123. (e = new m(r, { color0: o, ignoreStatus: !0 })).bind(),
  7124. a(t),
  7125. t.destroy()),
  7126. (t = new U(r, i)).loadImage(l, r.RGB),
  7127. N.closeImage(l),
  7128. e.bind(),
  7129. r.colorMask(!1, !1, !1, !0),
  7130. a(t),
  7131. r.colorMask(!0, !0, !0, !0),
  7132. t.destroy(),
  7133. m.bindNone(r),
  7134. o.rebuildMips();
  7135. } else {
  7136. ((i = document.createElement("canvas")).width = e),
  7137. (i.height = t);
  7138. var s = i.getContext("2d");
  7139. for (
  7140. s.drawImage(h, 0, 0),
  7141. N.closeImage(h),
  7142. i = s.getImageData(0, 0, e, t),
  7143. i = new Uint8Array(
  7144. i.data.buffer,
  7145. i.data.byteOffset,
  7146. i.data.length
  7147. ),
  7148. s.drawImage(l, 0, 0),
  7149. N.closeImage(l),
  7150. s = s.getImageData(0, 0, e, t).data,
  7151. e = e * t * 4,
  7152. t = 0;
  7153. t < e;
  7154. t += 4
  7155. )
  7156. i[t + 3] = s[t];
  7157. o.loadArray(i);
  7158. }
  7159. N.closeImage(l);
  7160. }
  7161. }.bind(this);
  7162. return (
  7163. N.parseFile(e, function(e) {
  7164. (h = e), d();
  7165. }),
  7166. N.parseFile(t, function(e) {
  7167. (l = e), d();
  7168. }),
  7169. o
  7170. );
  7171. }),
  7172. (N.parseFile = function(e, t, i) {
  7173. var s = i || new Image();
  7174. if ("undefined" != typeof URL && void 0 !== URL.createObjectURL) {
  7175. e = new Blob([e.data], { type: e.type });
  7176. var n = URL.createObjectURL(e);
  7177. (s.onload = function() {
  7178. URL.revokeObjectURL(n), t && t(s);
  7179. }),
  7180. (s.src = n);
  7181. } else {
  7182. e = new Blob([e.data], { type: e.type });
  7183. var r = new FileReader();
  7184. (r.onload = function(e) {
  7185. s.src = r.result;
  7186. }),
  7187. (s.onload = function() {
  7188. t && t(s);
  7189. }),
  7190. r.readAsDataURL(e);
  7191. }
  7192. }),
  7193. (N.closeImage = function(e) {
  7194. e &&
  7195. 256 < e.width * e.height &&
  7196. ((e.onload = null),
  7197. (e.onerror = null),
  7198. (e.src =
  7199. "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D"));
  7200. }),
  7201. (z.prototype.setBackground3x1 = function(e, t, i, s) {
  7202. var n = 8 / this.controlRect.getScreenHeight();
  7203. (this.backgroundControl = e.addTextButton("", 0, (1 - n) / 2, 1, n, 1)),
  7204. (this.backgroundControl.defaultAlpha = 1),
  7205. this.backgroundControl.setBackground3x1(e, 0, 0, t, i, s, 4),
  7206. (this.backgroundControl.controlRect.xPercent = this.controlRect.xPercent),
  7207. (this.backgroundControl.controlRect.widthPercent = this.controlRect.widthPercent),
  7208. (this.controlRect.linkedControl.style.zIndex = "3"),
  7209. this.setupCallbacks();
  7210. }),
  7211. (z.prototype.setSize = function(e, t) {
  7212. this.pixelsX = e;
  7213. var i = 24 / (this.pixelsY = t);
  7214. (this.knobWidthPercent = 24 / e),
  7215. (this.knobControlRect.xPercent = 0.5 - this.knobWidthPercent / 2),
  7216. (this.knobControlRect.yPercent = (1 - i) / 2 + -1 / t),
  7217. (this.knobControlRect.widthPercent = this.knobWidthPercent),
  7218. (this.knobControlRect.heightPercent = i),
  7219. this.controlRect.updateElement(),
  7220. (this.backgroundControl.controlRect.xPercent = this.controlRect.xPercent),
  7221. (this.backgroundControl.controlRect.widthPercent = this.controlRect.widthPercent),
  7222. this.backgroundControl.controlRect.updateElement();
  7223. }),
  7224. (z.prototype.setSliderPercent = function(e) {
  7225. e < 0 && (e = 0),
  7226. 1 < e && (e = 1),
  7227. (this.sliderPercent = e),
  7228. (this.knobControlRect.xPercent = e - this.knobWidthPercent / 2),
  7229. this.knobControlRect.updateElement();
  7230. }),
  7231. (z.prototype.setupCallbacks = function() {
  7232. var e = function(e) {
  7233. if (this.draggingSlider) {
  7234. var t = this.backgroundControl.controlRect.linkedControl.getBoundingClientRect();
  7235. this.setSliderPercent((e.clientX - t.left) / t.width),
  7236. this.guiScreen.ui.viewer.scene.sceneAnimator.setAnimationProgress(
  7237. this.sliderPercent,
  7238. !0
  7239. ),
  7240. this.guiScreen.ui.viewer.scene.sceneAnimator.paused &&
  7241. (this.guiScreen.ui.viewer.scene.postRender.discardAAHistory(),
  7242. this.guiScreen.ui.viewer.reDrawScene());
  7243. }
  7244. }.bind(this),
  7245. t = function(e) {
  7246. this.draggingSlider = !0;
  7247. var t = this.backgroundControl.controlRect.linkedControl.getBoundingClientRect();
  7248. this.setSliderPercent((e.clientX - t.left) / t.width),
  7249. this.guiScreen.ui.viewer.scene.sceneAnimator.setAnimationProgress(
  7250. this.sliderPercent,
  7251. !0
  7252. ),
  7253. (this.guiScreen.ui.viewer.scene.sceneAnimator.lockPlayback = !0),
  7254. this.guiScreen.ui.viewer.scene.sceneAnimator.paused &&
  7255. (this.guiScreen.ui.viewer.scene.postRender.discardAAHistory(),
  7256. this.guiScreen.ui.viewer.reDrawScene());
  7257. }.bind(this),
  7258. i = function(e) {
  7259. (this.draggingSlider = !1),
  7260. (this.guiScreen.ui.viewer.scene.sceneAnimator.lockPlayback = !1);
  7261. }.bind(this);
  7262. this.guiScreen.ui.viewer.input.element.addEventListener("mousemove", e),
  7263. this.guiScreen.ui.viewer.input.element.addEventListener("mouseup", i),
  7264. this.backgroundControl.controlRect.linkedControl.addEventListener(
  7265. "mousemove",
  7266. e
  7267. ),
  7268. this.backgroundControl.controlRect.linkedControl.addEventListener(
  7269. "mousedown",
  7270. t
  7271. ),
  7272. this.backgroundControl.controlRect.linkedControl.addEventListener(
  7273. "mouseup",
  7274. i
  7275. ),
  7276. this.controlRect.linkedControl.addEventListener("mouseup", i);
  7277. }),
  7278. (j.prototype.setSize = function(e, t) {
  7279. (this.container.width = 0 | e),
  7280. (this.container.height = 0 | t),
  7281. (this.container.style.width = e + "px"),
  7282. (this.container.style.height = t + "px"),
  7283. this.guiScreen.setSize(this.container.width, this.container.height);
  7284. }),
  7285. (j.prototype.clearView = function() {
  7286. for (; this.container.hasChildNodes(); )
  7287. this.container.removeChild(this.container.childNodes[0]);
  7288. delete this.progressBar,
  7289. delete this.thumbnail,
  7290. delete this.fadeThumbnail,
  7291. delete this.playButton,
  7292. delete this.helpOverlay;
  7293. }),
  7294. (j.prototype.bindInput = function(i) {
  7295. i.onSingleTap.push(
  7296. function(e, t) {
  7297. this.stripData.selectedStrip != this.stripData.STRIP_NONE &&
  7298. ((e = (2 / i.element.clientWidth) * e - 1),
  7299. (t = 1 - (2 / i.element.clientHeight) * t),
  7300. this.stripData.selectStrip(e, t),
  7301. this.stripData.selectedStrip == this.stripData.STRIP_MENU &&
  7302. this.helpOverlay.active &&
  7303. this.helpOverlay.toggle(),
  7304. this.refreshUI(),
  7305. this.viewer.wake());
  7306. }.bind(this)
  7307. );
  7308. }),
  7309. (j.sanitize = function(e) {
  7310. return e ? e.replace(/<|>|\(|\)|$|%|=/g, "") : e;
  7311. }),
  7312. (j.sanitizeURL = function(e) {
  7313. return e
  7314. ? 0 == e.indexOf("http://") ||
  7315. 0 == e.indexOf("https://") ||
  7316. 0 == e.indexOf("ftp://")
  7317. ? encodeURI(e)
  7318. : "http://" + encodeURI(e)
  7319. : e;
  7320. }),
  7321. (j.prototype.showFailure = function(e, t) {
  7322. this.container.innerHTML = "";
  7323. var i = document.createElement("canvas"),
  7324. s = this.container.width / this.container.height;
  7325. (i.width = 100),
  7326. (i.height = (i.height * s) | 0),
  7327. (i.style.position = "absolute"),
  7328. (i.style["z-index"] = "0"),
  7329. (i.style.width = i.style.height = "100%");
  7330. var n = i.getContext("2d"),
  7331. r = (n.fillStyle = n.createRadialGradient(
  7332. i.width / 2,
  7333. i.height / 2,
  7334. (i.width + i.height) / 2,
  7335. i.width / 2,
  7336. i.height / 2,
  7337. 0
  7338. ));
  7339. r.addColorStop(0, "rgb(0,0,0)"),
  7340. r.addColorStop(1, "rgb(35,60,80)"),
  7341. (n.fillStyle = r),
  7342. n.fillRect(0, 0, i.width, i.height),
  7343. this.container.appendChild(i);
  7344. var a = document.createElement("div");
  7345. dom.addClass(a, "error"),
  7346. (a.style["background-image"] = "url(images/errorBG.png)");
  7347. var o =
  7348. '<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">错误信息: ' +
  7349. (e || "文件无效(ERROR)请检查您所上传的文件以确定其稳定性") +
  7350. '</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>';
  7351. (a.innerHTML = o), this.container.appendChild(a);
  7352. }),
  7353. (j.prototype.showPreview = function(e) {
  7354. this.clearView(), (this.thumbnail = document.createElement("canvas"));
  7355. var t = this.container.width / this.container.height;
  7356. (this.thumbnail.height = this.viewer.mobile ? 200 : 300),
  7357. (this.thumbnail.width = (this.thumbnail.height * t) | 0),
  7358. (this.thumbnail.style.width = this.thumbnail.style.height = "100%");
  7359. var i = ((t = this.thumbnail.getContext(
  7360. "2d"
  7361. )).fillStyle = t.createRadialGradient(
  7362. this.thumbnail.width / 2,
  7363. this.thumbnail.height / 2,
  7364. (this.thumbnail.width + this.thumbnail.height) / 2,
  7365. this.thumbnail.width / 2,
  7366. 0,
  7367. 0
  7368. ));
  7369. i.addColorStop(0, "rgb(0,0,0)"),
  7370. i.addColorStop(1, "rgb(150,150,150)"),
  7371. (t.fillStyle = i),
  7372. t.fillRect(0, 0, this.thumbnail.width, this.thumbnail.height),
  7373. this.container.appendChild(this.thumbnail),
  7374. (this.playButton = document.createElement("input")),
  7375. (this.playButton.type = "image"),
  7376. (this.playButton.src = I.dataLocale + "play.png"),
  7377. (this.playButton.style.position = "absolute"),
  7378. (this.playButton.style.left = "50%"),
  7379. (this.playButton.style.top = "50%"),
  7380. (this.playButton.style[
  7381. "-webkit-transform"
  7382. ] = this.playButton.style.transform =
  7383. "translate(-50%,-50%) scale(0.4,0.4)"),
  7384. (this.playButton.style.opacity = 0.5),
  7385. (this.playButton.style.outline = "0px"),
  7386. (this.playButton.onclick = function() {
  7387. this.viewer.loadScene(this.viewer.sceneURL),
  7388. this.container.removeChild(this.playButton),
  7389. delete this.playButton;
  7390. }.bind(this)),
  7391. this.container.appendChild(this.playButton),
  7392. e ||
  7393. n(
  7394. this.viewer.sceneURL,
  7395. function(e) {
  7396. this.loadingImageURL || this.setThumbnail(e);
  7397. }.bind(this)
  7398. );
  7399. }),
  7400. (j.prototype.setThumbnailURL = function(e) {
  7401. (this.loadingImageURL = e) &&
  7402. C.fetchImage(this.loadingImageURL, this.setThumbnail.bind(this));
  7403. }),
  7404. (j.prototype.setThumbnail = function(e) {
  7405. if (this.thumbnail)
  7406. if (e.height >= this.container.height) {
  7407. var t = this.container.height / e.height;
  7408. (e.style.position = "absolute"),
  7409. (e.style.outline = "0px"),
  7410. (e.style.left = "50%"),
  7411. (e.style.top = "50%"),
  7412. (e.style["-webkit-transform"] = e.style.transform =
  7413. "translate(-50%,-50%) scale(" + t + "," + t + ")"),
  7414. this.container.replaceChild(e, this.thumbnail),
  7415. (this.thumbnail = e);
  7416. } else {
  7417. var i,
  7418. s = this.thumbnail.getContext("2d"),
  7419. n = this.thumbnail.width,
  7420. r = this.thumbnail.height;
  7421. t = r / e.height;
  7422. s.drawImage(e, (n - e.width * t) / 2, 0, e.width * t, r);
  7423. try {
  7424. i = s.getImageData(0, 0, n, r);
  7425. } catch (e) {
  7426. return;
  7427. }
  7428. e = s.createImageData(n, r);
  7429. for (var a = 0; a < 2; ++a) {
  7430. t = i.data;
  7431. for (var o = e.data, h = 0, l = 0; l < r; ++l)
  7432. for (var d = 0; d < n; ++d) {
  7433. for (var c = 0, u = 0, f = 0, m = -2; m <= 2; ++m)
  7434. for (
  7435. var p = (p = l + m) < 0 ? 0 : r <= p ? r - 1 : p, g = -2;
  7436. g <= 2;
  7437. ++g
  7438. ) {
  7439. var v;
  7440. (c =
  7441. c +
  7442. t[
  7443. (v =
  7444. 4 *
  7445. (p * n +
  7446. (v = (v = d + g) < 0 ? 0 : n <= v ? n - 1 : v)))
  7447. ]),
  7448. (u = u + t[v + 1]),
  7449. (f = f + t[v + 2]);
  7450. }
  7451. (o[h++] = c / 25),
  7452. (o[h++] = u / 25),
  7453. (o[h++] = f / 25),
  7454. (o[h++] = 255);
  7455. }
  7456. (t = i), (i = e), (e = t);
  7457. }
  7458. s.putImageData(i, 0, 0);
  7459. }
  7460. }),
  7461. (j.prototype.showActiveView = function() {
  7462. var e,
  7463. t,
  7464. i,
  7465. s,
  7466. n,
  7467. r = this.thumbnail;
  7468. this.clearView(),
  7469. r &&
  7470. ((this.fadeThumbnail = r),
  7471. (this.fadeThumbnail.style.opacity = 1),
  7472. this.container.appendChild(this.fadeThumbnail)),
  7473. void 0 === I.largeUI && (I.largeUI = this.viewer.mobile),
  7474. this.container.width < 450 && (I.largeUI = !1);
  7475. var a = g.support();
  7476. r = 1;
  7477. window.devicePixelRatio &&
  7478. (2 < window.devicePixelRatio
  7479. ? (r = 4)
  7480. : 1 < window.devicePixelRatio && (r = 2)),
  7481. I.largeUI && r < 4 && (r *= 2);
  7482. var o = I.largeUI ? 0.3 : 0.5;
  7483. (this.helpOverlay = document.createElement("div")),
  7484. (this.helpOverlay.style.pointerEvents = "none"),
  7485. this.container.appendChild(this.helpOverlay),
  7486. (this.hideSigOnHelp = e = this.container.width < 450),
  7487. (this.hideSigOnStrips = !0),
  7488. (t = [8, 8]),
  7489. (s = e
  7490. ? ((i = 198 + 2 * t[0]), 258 + 2 * t[1])
  7491. : ((i = 354 + 2 * t[0]), 218 + 2 * t[1])),
  7492. ((n = document.createElement("div")).style.position = "absolute"),
  7493. (n.style.width = n.style.height = "100%"),
  7494. (this.helpOverlay.contents = n),
  7495. ((n = document.createElement("div")).style.position = "absolute"),
  7496. (n.style.right = I.largeUI ? "85px" : "45px"),
  7497. (n.style.top = I.largeUI ? "20px" : "12px"),
  7498. (n.style["z-index"] = "20"),
  7499. (n.style.width = i + "px"),
  7500. (n.style.height = s + "px"),
  7501. this.helpOverlay.contents.appendChild(n),
  7502. ((s = document.createElement("div")).style.position = "absolute"),
  7503. (s.style.width = "100%"),
  7504. (s.style.height = "100%"),
  7505. (s.style.backgroundColor = "black"),
  7506. (s.style.opacity = "0.65"),
  7507. (s.style.borderRadius = "16px"),
  7508. n.appendChild(s),
  7509. (s = document.createElement("a")),
  7510. dom.addClass(s, "tipClose"),
  7511. (s.style.position = "absolute"),
  7512. (s.style.color = "#FFFFFF"),
  7513. (s.style.backgroundColor = "rgba(0,0,0,0.0)"),
  7514. (s.style.border = "0px"),
  7515. (s.style.outline = "0px"),
  7516. (s.style.fontSize = I.largeUI ? "16pt" : "10pt"),
  7517. (s.style.right = I.largeUI ? "-9px" : "4px"),
  7518. (s.style.top = I.largeUI ? "3px" : "7px"),
  7519. (s.style.width = s.style.height = I.largeUI ? "32px" : "16px"),
  7520. (s.style.pointerEvents = "auto"),
  7521. (s.style.cursor = "pointer"),
  7522. (s.onclick = function(e) {
  7523. this.helpOverlay.toggle(), this.refreshUI();
  7524. }.bind(this, s)),
  7525. n.appendChild(s),
  7526. ((s = document.createElement("center")).style.position = "absolute"),
  7527. (s.style.left = t[0] - 4 + "px"),
  7528. (s.style.right = t[0] + 4 + "px"),
  7529. (s.style.top = s.style.bottom = t[1] + "px"),
  7530. (s.style.paddingTop = "8px"),
  7531. e || (s.style.paddingRight = "8px"),
  7532. n.appendChild(s),
  7533. (n = s),
  7534. (t = (this.viewer.mobile ? "M" : "PC") + (2 < r ? 4 : 2) + "x.png"),
  7535. ((s = document.createElement("img")).style.width = "66px"),
  7536. (s.style.height = "90px"),
  7537. n.appendChild(s),
  7538. ((s = document.createElement("img")).style.width = "66px"),
  7539. (s.style.height = "90px"),
  7540. n.appendChild(s),
  7541. ((s = document.createElement("img")).style.width = "66px"),
  7542. (s.style.height = "90px"),
  7543. n.appendChild(s),
  7544. ((s = document.createElement("img")).style.width = "66px"),
  7545. (s.style.height = "90px"),
  7546. n.appendChild(s),
  7547. ((s = document.createElement("img")).style.position = "relative"),
  7548. e || (s.style.left = "8px"),
  7549. (s.style.width = "66px"),
  7550. (s.style.height = "90px"),
  7551. n.appendChild(s),
  7552. ((t = document.createElement("a")).href = "http://www.4dage.com/"),
  7553. (t.target = "_blank"),
  7554. (t.style.pointerEvents = "auto"),
  7555. (t.style.cursor = "pointer"),
  7556. n.appendChild(t),
  7557. ((s = document.createElement("img")).style.position = "absolute"),
  7558. (s.style.left = 0.5 * i - (e ? 65 : 116) + "px"),
  7559. (s.style.bottom = e ? "8px" : "12px"),
  7560. (s.style.width = e ? "116px" : "232px"),
  7561. t.appendChild(s),
  7562. ((i = document.createElement("div")).style.position = "absolute"),
  7563. (i.style.left = 0),
  7564. (i.style.right = e ? "30px" : "128px"),
  7565. (i.style.bottom = e ? "-4px" : "4px"),
  7566. (i.style.textAlign = "right"),
  7567. (i.style.fontFamilly = "Open Sans Arial"),
  7568. n.appendChild(i),
  7569. ((e = document.createElement("font")).style.fontSize = "9pt"),
  7570. (e.style.fontFamily = "Open Sans Arial"),
  7571. i.appendChild(e),
  7572. e.appendChild(t),
  7573. (this.helpOverlay.active = !1),
  7574. (this.helpOverlay.toggle = function(e) {
  7575. this.active
  7576. ? this.removeChild(this.contents)
  7577. : this.appendChild(this.contents),
  7578. (this.active = !this.active);
  7579. }.bind(this.helpOverlay, this.viewer)),
  7580. (this.menuCluster = document.createElement("div")),
  7581. (this.menuCluster.style.position = "absolute"),
  7582. (this.menuCluster.style.right = I.largeUI ? "4px" : "0px"),
  7583. (this.menuCluster.style.top = I.largeUI ? "20px" : "10px"),
  7584. I.largeUI
  7585. ? ((this.menuCluster.style.width = "72px"),
  7586. (this.menuCluster.style.height = "64px"))
  7587. : ((this.menuCluster.style.width = "36px"),
  7588. (this.menuCluster.style.height = "36px")),
  7589. ((n = document.createElement("div")).style.left = n.style.top =
  7590. "0px"),
  7591. (n.style.width = n.style.height = "100%"),
  7592. (this.menuCluster.contents = n),
  7593. this.menuCluster.appendChild(n),
  7594. (e = 0);
  7595. var h = (i = function(e, t, i, s, n, r) {
  7596. var a = document.createElement("div");
  7597. return (
  7598. dom.addClass(a, "controlBtn"),
  7599. dom.addClass(a, i),
  7600. (a.title = t),
  7601. I.largeUI && dom.addClass(a, "largeUI"),
  7602. e.appendChild(a),
  7603. a
  7604. );
  7605. })(this.menuCluster.contents, "4DAGE主页", "home", "", e++, o);
  7606. for (
  7607. h.onclick = function(e) {
  7608. window.open("http://www.4dage.com", "_blank");
  7609. }.bind(this, h),
  7610. a &&
  7611. ((a = i(
  7612. this.menuCluster.contents,
  7613. "全屏",
  7614. "fullscreen",
  7615. "fullscreen" + r + "x.png",
  7616. e++,
  7617. o
  7618. )).onclick = function(e) {
  7619. g.active()
  7620. ? g.end()
  7621. : g.begin(
  7622. this.viewer.domRoot,
  7623. this.viewer.fullscreenChange.bind(this.viewer)
  7624. ),
  7625. dom.hasClass(e, "full")
  7626. ? dom.removeClass(e, "full")
  7627. : dom.addClass(e, "full"),
  7628. this.refreshUI();
  7629. }.bind(this, a)),
  7630. (a = i(
  7631. this.menuCluster.contents,
  7632. "操作方式说明",
  7633. "tips",
  7634. "help" + r + "x.png",
  7635. e++,
  7636. o
  7637. )).onclick = function(e) {
  7638. this.helpOverlay.toggle(), this.refreshUI();
  7639. }.bind(this, a),
  7640. this.container.appendChild(this.menuCluster),
  7641. this.menuCluster.active = !0,
  7642. this.menuCluster.toggle = function() {
  7643. this.active
  7644. ? this.removeChild(this.contents)
  7645. : this.appendChild(this.contents),
  7646. (this.active = !this.active);
  7647. }.bind(this.menuCluster),
  7648. void 0 !== I.hostImage &&
  7649. (I.hostURL &&
  7650. (((t = document.createElement("a")).href = I.hostURL),
  7651. (t.target = "_blank")),
  7652. ((s = document.createElement("img")).src = I.hostImage),
  7653. (s.style.position = "absolute"),
  7654. (s.style.top = "4px"),
  7655. (s.style.left = "4px"),
  7656. (s.style.opacity = 0.65),
  7657. (s.style["-webkit-transform"] = s.style.transform =
  7658. "translate(-50%,-50%) scale(0.5,0.5) translate(50%,50%)"),
  7659. I.hostURL
  7660. ? ((s.onmouseover = function() {
  7661. this.style.opacity = 1;
  7662. }.bind(s)),
  7663. (s.onmouseout = function() {
  7664. this.style.opacity = 0.5;
  7665. }.bind(s)),
  7666. t.appendChild(s),
  7667. (this.hostLogo = t))
  7668. : (this.hostLogo = s),
  7669. (e = new XMLHttpRequest()).open("HEAD", s.src, !0),
  7670. (e.onload = function() {
  7671. this.container.appendChild(this.hostLogo);
  7672. }.bind(this)),
  7673. e.send()),
  7674. this.sceneStats = document.createElement("text"),
  7675. this.sceneStats.style.position = "absolute",
  7676. this.sceneStats.style.left = "9px",
  7677. this.sceneStats.style.bottom = "8px",
  7678. this.sceneStats.style.color = "gray",
  7679. this.sceneStats.style.fontFamily = "Open Sans Arial",
  7680. this.sceneStats.style.fontSize = "75%",
  7681. e = a = r = 0;
  7682. e < this.viewer.scene.meshes.length;
  7683. ++e
  7684. )
  7685. (r += (i = this.viewer.scene.meshes[e]).indexCount / 3),
  7686. (a += i.vertexCount);
  7687. (this.sceneStats.innerHTML =
  7688. "Triangles: " +
  7689. (0 | r).toLocaleString() +
  7690. "<br>Vertices: " +
  7691. (0 | a).toLocaleString()),
  7692. I.showFrameTime &&
  7693. ((this.frameTimer = document.createElement("text")),
  7694. (this.frameTimer.style.position = "absolute"),
  7695. (this.frameTimer.style.left = this.frameTimer.style.top = "5px"),
  7696. (this.frameTimer.style.color = "gray"),
  7697. (this.frameTimer.style.fontSize = "75%"),
  7698. this.container.appendChild(this.frameTimer),
  7699. (this.frameTimer.innerHTML = "--"),
  7700. (this.frameCount = 1e20));
  7701. }),
  7702. (j.prototype.refreshUI = function() {
  7703. if (this.sigCluster) {
  7704. var e = !1,
  7705. t = this.stripData.selectedStrip == this.stripData.STRIP_MENU;
  7706. this.hideSigOnStrips && (e = e || t),
  7707. this.hideSigOnHelp && (e = e || this.helpOverlay.active),
  7708. this.sigCluster.active == e && this.sigCluster.toggle();
  7709. }
  7710. }),
  7711. (j.prototype.signalLoadProgress = function(e, t) {
  7712. if (this.thumbnail) {
  7713. if (!this.progressBar) {
  7714. var i = document.createElement("div");
  7715. (i.style.backgroundColor = "rgb(240,240,240)"),
  7716. (i.style.opacity = 0.9),
  7717. (i.style.position = "absolute"),
  7718. (i.style.left = "20%"),
  7719. (i.style.width = "60%"),
  7720. (i.style.bottom = "30%"),
  7721. (i.style.height = "4px"),
  7722. (i.style["border-radius"] = "2px"),
  7723. (this.progressBar = document.createElement("div")),
  7724. (this.progressBar.style.backgroundColor = "#00ccff"),
  7725. (this.progressBar.style.position = "absolute"),
  7726. (this.progressBar.style.left = this.progressBar.style.bottom =
  7727. "0px"),
  7728. (this.progressBar.style.height = "100%"),
  7729. (this.progressBar.style.width = "0px"),
  7730. (this.progressBar.style["border-radius"] = "2px"),
  7731. i.appendChild(this.progressBar),
  7732. this.container.appendChild(i),
  7733. this.playButton &&
  7734. (this.container.removeChild(this.playButton),
  7735. delete this.playButton);
  7736. }
  7737. this.progressBar.style.width =
  7738. t <= 0
  7739. ? (((100 * e) / (2097152 + e)) | 0) + "%"
  7740. : (((100 * e) / t) | 0) + "%";
  7741. }
  7742. }),
  7743. (j.prototype.animating = function() {
  7744. return !!this.fadeThumbnail || !!this.frameTimer;
  7745. }),
  7746. (j.prototype.animate = function() {
  7747. if (
  7748. (this.fadeThumbnail &&
  7749. ((this.fadeThumbnailTimer = this.fadeThumbnailTimer || Date.now()),
  7750. (this.fadeThumbnail.style.opacity =
  7751. 1 - 0.0015 * (Date.now() - this.fadeThumbnailTimer)),
  7752. this.fadeThumbnail.style.opacity < 0.01 &&
  7753. (this.container.removeChild(this.fadeThumbnail),
  7754. delete this.fadeThumbnail,
  7755. delete this.fadeThumbnailTimer)),
  7756. this.frameTimer && (this.frameCount++, 60 <= this.frameCount))
  7757. ) {
  7758. var e = new Date().getTime();
  7759. if (void 0 !== this.frameTime) {
  7760. var t = (e - this.frameTime) / this.frameCount;
  7761. t = Math.floor(100 * t) / 100;
  7762. (this.frameTimer.innerHTML = t + " ms"),
  7763. (this.frameTimer.style.color = t < 32 ? "green" : "red");
  7764. }
  7765. (this.frameCount = 0), (this.frameTime = e);
  7766. }
  7767. if (
  7768. (this.guiScreen &&
  7769. this.guiScreen.playbackControls &&
  7770. ((e = this.guiScreen.playbackControls.timelineSlider).draggingSlider
  7771. ? this.viewer.scene.sceneAnimator.setAnimationProgress(
  7772. e.sliderPercent,
  7773. !0
  7774. )
  7775. : e.setSliderPercent(
  7776. this.viewer.scene.sceneAnimator.animationProgress
  7777. )),
  7778. this.sceneStats)
  7779. ) {
  7780. for (var i = (t = e = 0); i < this.viewer.scene.meshes.length; ++i) {
  7781. var s = this.viewer.scene.meshes[i];
  7782. (e = e + s.indexCount / 3), (t = t + s.vertexCount);
  7783. }
  7784. (this.sceneStats.innerHTML =
  7785. "Triangles: " +
  7786. (0 | e).toLocaleString() +
  7787. "<br>Vertices: " +
  7788. (0 | t).toLocaleString()),
  7789. this.viewer.scene.sceneAnimator &&
  7790. this.viewer.scene.sceneAnimator.showPlayControls &&
  7791. (this.sceneStats.innerHTML += "<br><br><br><br>"),
  7792. (e = !!this.sceneStats.parentElement),
  7793. (t = this.stripData.active() || !1),
  7794. e && !t
  7795. ? (this.container.removeChild(this.sceneStats),
  7796. this.hostLogo && this.container.appendChild(this.hostLogo))
  7797. : !e &&
  7798. t &&
  7799. (this.container.appendChild(this.sceneStats),
  7800. this.hostLogo && this.container.removeChild(this.hostLogo));
  7801. }
  7802. this.refreshUI(),
  7803. (this.stripData.animationActive || this.stripData.active()) &&
  7804. (this.animateStrips(),
  7805. this.stripData.animationActive && this.viewer.wake());
  7806. }),
  7807. (j.prototype.animateStrips = function() {
  7808. if (this.stripText)
  7809. for (
  7810. var e = Math.atan(
  7811. this.viewer.canvas.height /
  7812. this.viewer.canvas.width /
  7813. this.stripData.stripSlant
  7814. ),
  7815. t = 0;
  7816. t < this.stripData.labels.length;
  7817. ++t
  7818. ) {
  7819. var i =
  7820. 0.5 +
  7821. 0.5 *
  7822. (i =
  7823. (i = this.stripData.strips[t]) - this.stripData.stripSlant);
  7824. t == this.stripData.selectedStrip
  7825. ? ((this.stripText[t].style["-ms-transform"] = this.stripText[
  7826. t
  7827. ].style["-webkit-transform"] = this.stripText[
  7828. t
  7829. ].style.transform = "none"),
  7830. (this.stripText[t].style.top = "4px"),
  7831. (this.stripText[t].style.left = "0px"),
  7832. (this.stripText[t].style.width = "150px"),
  7833. (this.stripText[t].txt.style.textAlign = "center"),
  7834. (this.stripText[t].txt.style.background =
  7835. "rgba(0, 0, 0, 0.75)"),
  7836. (this.stripText[t].txt.style.background =
  7837. "-webkit-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))"),
  7838. (this.stripText[t].txt.style.background =
  7839. "-o-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))"),
  7840. (this.stripText[t].txt.style.background =
  7841. "-moz-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))"),
  7842. (this.stripText[t].txt.style.background =
  7843. "linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))"),
  7844. (this.stripText[t].txt.style.paddingLeft = "32px"),
  7845. (this.stripText[t].txt.style.paddingTop = "6px"),
  7846. (this.stripText[t].txt.style.paddingBottom = "4px"),
  7847. (this.stripText[t].txt.style.textShadow =
  7848. "1px 1px 2px rgba(0,0,0,0.7)"),
  7849. (this.stripText[t].line.style.opacity = 0.5),
  7850. (this.stripText[t].line.style.top = "100%"),
  7851. (this.stripText[t].line.style.width = "100%"),
  7852. (this.stripText[t].line.style.height = "1px"))
  7853. : ((this.stripText[t].style["-ms-transform"] = this.stripText[
  7854. t
  7855. ].style["-webkit-transform"] = this.stripText[
  7856. t
  7857. ].style.transform =
  7858. "translate(-50%, -50%) rotate(" +
  7859. e +
  7860. "rad) translate(50%, 50%)"),
  7861. (this.stripText[t].style.left = 100 * i + "%"),
  7862. (this.stripText[t].style.top = "0px"),
  7863. (this.stripText[t].style.width = "85px"),
  7864. (this.stripText[t].txt.style.textAlign = "left"),
  7865. (this.stripText[t].txt.style.background = "none"),
  7866. (this.stripText[t].txt.style.paddingLeft = "8px"),
  7867. (this.stripText[t].txt.style.paddingTop = "6px"),
  7868. (this.stripText[t].txt.style.paddingBottom = "4px"),
  7869. (this.stripText[t].txt.style.textShadow =
  7870. "2px 0px 3px rgba(0,0,0,0.7)"),
  7871. (this.stripText[t].line.style.opacity = 1),
  7872. (this.stripText[t].line.style.top = "-1px"),
  7873. (this.stripText[t].line.style.width = "10000px"),
  7874. (this.stripText[t].line.style.height = "2px"));
  7875. }
  7876. });
  7877. var V = {
  7878. type: Float32Array,
  7879. create: function(e, t, i, s) {
  7880. var n = new V.type(4);
  7881. return (n[0] = e), (n[1] = t), (n[2] = i), (n[3] = s), n;
  7882. },
  7883. empty: function() {
  7884. return new V.type(4);
  7885. },
  7886. set: function(e, t, i, s, n) {
  7887. (e[0] = t), (e[1] = i), (e[2] = s), (e[3] = n);
  7888. },
  7889. copy: function(e, t) {
  7890. (e[0] = t[0]), (e[1] = t[1]), (e[2] = t[2]), (e[3] = t[3]);
  7891. },
  7892. add: function(e, t, i) {
  7893. return (
  7894. (e[0] = t[0] + i[0]),
  7895. (e[1] = t[1] + i[1]),
  7896. (e[2] = t[2] + i[2]),
  7897. (e[3] = t[3] + i[3]),
  7898. e
  7899. );
  7900. },
  7901. sub: function(e, t, i) {
  7902. return (
  7903. (e[0] = t[0] - i[0]),
  7904. (e[1] = t[1] - i[1]),
  7905. (e[2] = t[2] - i[2]),
  7906. (e[3] = t[3] - i[3]),
  7907. e
  7908. );
  7909. },
  7910. scale: function(e, t, i) {
  7911. return (
  7912. (e[0] = i[0] * t),
  7913. (e[1] = i[1] * t),
  7914. (e[2] = i[2] * t),
  7915. (e[3] = i[3] * t),
  7916. e
  7917. );
  7918. },
  7919. mul: function(e, t, i) {
  7920. return (
  7921. (e[0] = t[0] * i[0]),
  7922. (e[1] = t[1] * i[1]),
  7923. (e[2] = t[2] * i[2]),
  7924. (e[3] = t[3] * i[3]),
  7925. e
  7926. );
  7927. },
  7928. mad: function(e, t, i, s) {
  7929. return (
  7930. (e[0] = t[0] * i[0] + s[0]),
  7931. (e[1] = t[1] * i[1] + s[1]),
  7932. (e[2] = t[2] * i[2] + s[2]),
  7933. (e[3] = t[3] * i[3] + s[3]),
  7934. e
  7935. );
  7936. },
  7937. smad: function(e, t, i, s) {
  7938. return (
  7939. (e[0] = t * i[0] + s[0]),
  7940. (e[1] = t * i[1] + s[1]),
  7941. (e[2] = t * i[2] + s[2]),
  7942. (e[3] = t * i[3] + s[3]),
  7943. e
  7944. );
  7945. },
  7946. negate: function(e, t) {
  7947. return (e[0] = -t[0]), (e[1] = -t[1]), (e[2] = -t[2]), e;
  7948. },
  7949. negate4: function(e, t) {
  7950. return (
  7951. (e[0] = -t[0]), (e[1] = -t[1]), (e[2] = -t[2]), (e[3] = -t[3]), e
  7952. );
  7953. },
  7954. length: function(e) {
  7955. var t = e[0],
  7956. i = e[1];
  7957. return (e = e[2]), Math.sqrt(t * t + i * i + e * e);
  7958. },
  7959. distance: function(e, t) {
  7960. var i = e[0] - t[0],
  7961. s = e[1] - t[1],
  7962. n = e[2] - t[2];
  7963. return Math.sqrt(i * i + s * s + n * n);
  7964. },
  7965. dot: function(e, t) {
  7966. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
  7967. },
  7968. dot4: function(e, t) {
  7969. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3] * t[3];
  7970. },
  7971. normalize: function(e, t) {
  7972. var i = t[0],
  7973. s = t[1],
  7974. n = t[2],
  7975. r = Math.sqrt(i * i + s * s + n * n);
  7976. return 0 == r
  7977. ? V.set(e, 0, 0, 0, 0)
  7978. : ((r = 1 / r), (e[0] = i * r), (e[1] = s * r), (e[2] = n * r), e);
  7979. },
  7980. cross: function(e, t, i) {
  7981. return (
  7982. (e[0] = t[1] * i[2]),
  7983. (e[0] += -t[2] * i[1]),
  7984. (e[1] = t[2] * i[0] - t[0] * i[2]),
  7985. (e[2] = t[0] * i[1] - t[1] * i[0]),
  7986. e
  7987. );
  7988. },
  7989. lerp: function(e, t, i, s) {
  7990. var n = 1 - s;
  7991. return (
  7992. (e[0] = t[0] * n + i[0] * s),
  7993. (e[1] = t[1] * n + i[1] * s),
  7994. (e[2] = t[2] * n + i[2] * s),
  7995. e
  7996. );
  7997. },
  7998. lerp4: function(e, t, i, s) {
  7999. var n = 1 - s;
  8000. return (
  8001. (e[0] = t[0] * n + i[0] * s),
  8002. (e[1] = t[1] * n + i[1] * s),
  8003. (e[2] = t[2] * n + i[2] * s),
  8004. (e[3] = t[3] * n + i[3] * s),
  8005. e
  8006. );
  8007. },
  8008. min: function(e, t, i) {
  8009. return (
  8010. (e[0] = Math.min(t[0], i[0])),
  8011. (e[1] = Math.min(t[1], i[1])),
  8012. (e[2] = Math.min(t[2], i[2])),
  8013. (e[3] = Math.min(t[3], i[3])),
  8014. e
  8015. );
  8016. },
  8017. max: function(e, t, i) {
  8018. return (
  8019. (e[0] = Math.max(t[0], i[0])),
  8020. (e[1] = Math.max(t[1], i[1])),
  8021. (e[2] = Math.max(t[2], i[2])),
  8022. (e[3] = Math.max(t[3], i[3])),
  8023. e
  8024. );
  8025. },
  8026. projectOnPlane: function(e, t, i, s) {
  8027. var n = V.empty();
  8028. return V.sub(n, t, i), (i = V.dot(n, s)), smad(e, -i, normal, t), e;
  8029. },
  8030. };
  8031. function H(e) {
  8032. (this.pivot = [0, 0, 0]),
  8033. (this.rotation = [0, 0]),
  8034. (this.radius = 1),
  8035. (this.nearPlane = 0.3),
  8036. (this.fov = 45),
  8037. (this.size = [1, 1]),
  8038. (this.transform = S.empty()),
  8039. (this.viewMatrix = S.empty()),
  8040. (this.projectionMatrix = S.empty()),
  8041. (this.viewProjectionMatrix = S.empty()),
  8042. e
  8043. ? this.loadView(e, !0)
  8044. : (this.saveResetView(), this.updateView(), this.updateProjection());
  8045. }
  8046. function W(e, t, i, s) {
  8047. var n;
  8048. if (
  8049. ((this.mobile = !!/Android|iPhone|iPod|iPad|Windows Phone|IEMobile|BlackBerry|webOS/.test(
  8050. navigator.userAgent
  8051. )),
  8052. (this.mobileFast = !!/iPhone|iPad/.test(navigator.userAgent)),
  8053. (n = !this.mobile))
  8054. )
  8055. e: {
  8056. if (
  8057. (((n = document.createElement("canvas")).width = n.height = 16),
  8058. (n =
  8059. n.getContext("webgl", {}) ||
  8060. n.getContext("experimental-webgl", {})))
  8061. ) {
  8062. var r = n.getExtension("WEBGL_debug_renderer_info");
  8063. if (r) {
  8064. (n = n.getParameter(r.UNMASKED_RENDERER_WEBGL)),
  8065. (n = !!/Intel|INTEL/.test(n));
  8066. break e;
  8067. }
  8068. }
  8069. n = !1;
  8070. }
  8071. (this.desktopSlow = n),
  8072. (this.domRoot = document.createElement("div")),
  8073. (this.domRoot.style.width = e + "px"),
  8074. (this.domRoot.style.height = t + "px"),
  8075. this.initCanvas(e, t),
  8076. (this.scene = this.input = null),
  8077. (this.sceneURL = i),
  8078. (this.sleepCounter = 8),
  8079. (this.onLoad = null),
  8080. (this.stripData = new D()),
  8081. (this.ui = new j(this)),
  8082. this.ui.setSize(e, t),
  8083. this.ui.showPreview(s);
  8084. }
  8085. (H.prototype.saveResetView = function() {
  8086. this.resetDesc = {
  8087. angles: [this.rotation[0], this.rotation[1]],
  8088. pivot: [this.pivot[0], this.pivot[1], this.pivot[2]],
  8089. limits: this.limits,
  8090. orbitRadius: this.radius,
  8091. fov: this.fov,
  8092. };
  8093. }),
  8094. (H.prototype.loadView = function(e, t) {
  8095. e &&
  8096. ((this.rotation[0] = e.angles[0]),
  8097. (this.rotation[1] = e.angles[1]),
  8098. rotInfo.pivot[0] || (rotInfo.pivot[0] = e.pivot[0]),
  8099. rotInfo.pivot[1] || (rotInfo.pivot[1] = e.pivot[1]),
  8100. rotInfo.pivot[2] || (rotInfo.pivot[2] = e.pivot[2]),
  8101. (this.pivot[0] = rotInfo.pivot[0]),
  8102. (this.pivot[1] = rotInfo.pivot[1]),
  8103. (this.pivot[2] = rotInfo.pivot[2]),
  8104. (this.radius = parseFloat(e.orbitRadius)),
  8105. (this.fov = e.fov),
  8106. (this.limits = e.limits),
  8107. t && this.saveResetView(),
  8108. this.updateView(),
  8109. this.updateProjection());
  8110. }),
  8111. (H.prototype.reset = function() {
  8112. this.loadView(this.resetDesc);
  8113. }),
  8114. (H.prototype.updateView = function() {
  8115. if (void 0 !== this.limits) {
  8116. if (this.limits.angles) {
  8117. var e = this.limits.angles.x,
  8118. t = this.limits.angles.y;
  8119. if (void 0 !== e) {
  8120. var i = this.rotation[0] - e.offset;
  8121. e = Math.min(Math.max(i, e.min), e.max);
  8122. this.rotation[0] += e - i;
  8123. }
  8124. void 0 !== t &&
  8125. ((i = this.rotation[1] - t.offset),
  8126. (e = Math.min(Math.max(i, t.min), t.max)),
  8127. (this.rotation[1] += e - i));
  8128. }
  8129. void 0 !== this.limits.orbitRadius &&
  8130. ((t = this.limits.orbitRadius.min),
  8131. (i = this.limits.orbitRadius.max),
  8132. void 0 !== t && (this.radius = Math.max(this.radius, t)),
  8133. void 0 !== i && (this.radius = Math.min(this.radius, i))),
  8134. void 0 !== this.limits.pan &&
  8135. ((t = this.limits.pan),
  8136. (i = this.resetDesc.pivot),
  8137. t.x && (this.pivot[0] = i[0]),
  8138. t.y && (this.pivot[1] = i[1]),
  8139. t.z && (this.pivot[2] = i[2]));
  8140. }
  8141. S.translation(this.transform, 0, 0, this.radius),
  8142. (t = S.rotation(S.empty(), this.rotation[0], 0)),
  8143. (i = S.rotation(S.empty(), this.rotation[1], 1)),
  8144. S.mul(t, i, t),
  8145. S.mul(this.transform, t, this.transform),
  8146. (this.transform[12] += this.pivot[0]),
  8147. (this.transform[13] += this.pivot[1]),
  8148. (this.transform[14] += this.pivot[2]),
  8149. S.invert(this.viewMatrix, this.transform),
  8150. S.mul(
  8151. this.viewProjectionMatrix,
  8152. this.viewMatrix,
  8153. this.projectionMatrix
  8154. );
  8155. }),
  8156. (H.prototype.updateProjection = function(e) {
  8157. S.perspectiveInfinite(
  8158. this.projectionMatrix,
  8159. this.fov,
  8160. this.size[0] / this.size[1],
  8161. this.nearPlane,
  8162. e
  8163. ),
  8164. S.mul(
  8165. this.viewProjectionMatrix,
  8166. this.projectionMatrix,
  8167. this.viewMatrix
  8168. );
  8169. }),
  8170. (W.prototype.initCanvas = function(e, t) {
  8171. if (
  8172. (this.canvas &&
  8173. this.canvas.parentNode &&
  8174. this.canvas.parentNode.removeChild(this.canvas),
  8175. (this.canvas = document.createElement("canvas")),
  8176. (this.pixelRatio = window.devicePixelRatio || 1),
  8177. this.mobile)
  8178. ) {
  8179. var i = this.mobileFast ? 1.5 : 1;
  8180. this.pixelRatio = this.pixelRatio > i ? i : this.pixelRatio;
  8181. } else this.desktopSlow && (this.pixelRatio = 1);
  8182. (this.canvas.width = e * this.pixelRatio),
  8183. (this.canvas.height = t * this.pixelRatio),
  8184. (this.canvas.style.width = e + "px"),
  8185. (this.canvas.style.height = t + "px"),
  8186. (this.canvas.style.position = "absolute"),
  8187. this.domRoot.appendChild(this.canvas);
  8188. }),
  8189. (W.prototype.initGL = function() {
  8190. var e = {
  8191. alpha: !!I.transparentBackground,
  8192. depth: !1,
  8193. stencil: !1,
  8194. antialias: !1,
  8195. premultipliedAlpha: !!I.transparentBackground,
  8196. preserveDrawingBuffer: !1,
  8197. };
  8198. e = this.gl =
  8199. this.canvas.getContext("webgl", e) ||
  8200. this.canvas.getContext("experimental-webgl", e);
  8201. return this.gl
  8202. ? (this.canvas.addEventListener(
  8203. "webglcontextlost",
  8204. function(e) {
  8205. e.preventDefault();
  8206. }.bind(this),
  8207. !1
  8208. ),
  8209. this.canvas.addEventListener(
  8210. "webglcontextrestored",
  8211. function(e) {
  8212. this.loadScene(this.sceneURL);
  8213. }.bind(this),
  8214. !1
  8215. ),
  8216. (e.ext = {
  8217. textureAniso:
  8218. e.getExtension("EXT_texture_filter_anisotropic") ||
  8219. e.getExtension("WEBKIT_EXT_texture_filter_anisotropic") ||
  8220. e.getExtension("MOZ_EXT_texture_filter_anisotropic"),
  8221. textureFloat: e.getExtension("OES_texture_float"),
  8222. textureFloatLinear: e.getExtension("OES_texture_float_linear"),
  8223. textureHalf: e.getExtension("OES_texture_half_float"),
  8224. textureHalfLinear: e.getExtension(
  8225. "OES_texture_half_float_linear"
  8226. ),
  8227. textureDepth: e.getExtension("WEBGL_depth_texture"),
  8228. colorBufferFloat: e.getExtension("WEBGL_color_buffer_float"),
  8229. colorBufferHalf: e.getExtension("EXT_color_buffer_half_float"),
  8230. index32bit: e.getExtension("OES_element_index_uint"),
  8231. loseContext: e.getExtension("WEBGL_lose_context"),
  8232. derivatives: e.getExtension("OES_standard_derivatives"),
  8233. renderInfo: e.getExtension("WEBGL_debug_renderer_info"),
  8234. }),
  8235. (e.limits = {
  8236. textureSize: e.getParameter(e.MAX_TEXTURE_SIZE),
  8237. textureCount: e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),
  8238. varyings: e.getParameter(e.MAX_VARYING_VECTORS),
  8239. vertexAttribs: e.getParameter(e.MAX_VERTEX_ATTRIBS),
  8240. vertexUniforms: e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),
  8241. fragmentUniforms: e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),
  8242. viewportSizes: e.getParameter(e.MAX_VIEWPORT_DIMS),
  8243. vendor: e.getParameter(e.VENDOR),
  8244. version: e.getParameter(e.VERSION),
  8245. }),
  8246. (e.hints = { mobile: this.mobile, pixelRatio: this.pixelRatio }),
  8247. e.enable(e.DEPTH_TEST),
  8248. (e.shaderCache = new O(e)),
  8249. (e.textureCache = new N(e)),
  8250. this.allocBacking(),
  8251. !0)
  8252. : (this.ui.showFailure(
  8253. 'webgl出错。</br>建议您将浏览器升级至最新版本,以获最好的体验。<br><span style="font-size:0.8em">获知更多webgl浏览器信息请<a href="webglInfo.html" style="color: #a6ccea;">点击此处</a></span>',
  8254. this
  8255. ),
  8256. !1);
  8257. }),
  8258. (W.prototype.allocBacking = function() {
  8259. var e = this.gl,
  8260. t = !1,
  8261. i = { width: this.canvas.width, height: this.canvas.height };
  8262. for (
  8263. this.mainColor = new U(e, i),
  8264. this.mainDepth = null,
  8265. e.ext.textureDepth &&
  8266. ((this.mainDepth = new U(e, {
  8267. width: this.canvas.width,
  8268. height: this.canvas.height,
  8269. nofilter: !0,
  8270. })),
  8271. this.mainDepth.loadArray(
  8272. null,
  8273. e.DEPTH_COMPONENT,
  8274. e.UNSIGNED_INT
  8275. )),
  8276. e.ext.textureHalf &&
  8277. e.ext.textureHalfLinear &&
  8278. (this.mainColor.loadArray(
  8279. null,
  8280. e.RGBA,
  8281. e.ext.textureHalf.HALF_FLOAT_OES
  8282. ),
  8283. (this.mainBuffer = new m(e, {
  8284. color0: this.mainColor,
  8285. depth: this.mainDepth,
  8286. createDepth: !this.mainDepth,
  8287. })),
  8288. (t = this.mainBuffer.valid)),
  8289. !t &&
  8290. e.ext.textureFloat &&
  8291. e.ext.textureFloatLinear &&
  8292. !e.hints.mobile &&
  8293. (this.mainColor.loadArray(null, e.RGBA, e.FLOAT),
  8294. (this.mainBuffer = new m(e, {
  8295. color0: this.mainColor,
  8296. depth: this.mainDepth,
  8297. createDepth: !this.mainDepth,
  8298. })),
  8299. (t = this.mainBuffer.valid));
  8300. !t;
  8301. )
  8302. (this.mainColor = new U(e, i)),
  8303. this.mainColor.loadArray(null, e.RGBA, e.UNSIGNED_BYTE),
  8304. (this.mainBuffer = new m(e, {
  8305. color0: this.mainColor,
  8306. depth: this.mainDepth,
  8307. createDepth: !this.mainDepth,
  8308. })),
  8309. (t = this.mainBuffer.valid),
  8310. (i.width /= 2),
  8311. (i.height /= 2),
  8312. this.mainDepth &&
  8313. (this.mainDepth.destroy(), (this.mainDepth = null));
  8314. this.mainBufferNoDepth = new m(e, { color0: this.mainColor });
  8315. }),
  8316. (W.prototype.loadScene = function(e) {
  8317. if (
  8318. ((this.sceneURL = e || this.sceneURL),
  8319. (this.scene = this.input = null),
  8320. this.initGL() && this.sceneURL)
  8321. ) {
  8322. var t = this.ui.signalLoadProgress.bind(this.ui);
  8323. e = function(e) {
  8324. t(1, 1),
  8325. (this.scene = new k(this.gl)),
  8326. (this.scene.stripData = this.stripData),
  8327. this.scene.load(new h(e))
  8328. ? this.scene.metaData.tbVersion <= 2070
  8329. ? this.ui.showFailure("模型文件版本过低", this)
  8330. : (this.bindInput(),
  8331. this.requestFrame(this.updateLoad.bind(this)),
  8332. this.onLoad && this.onLoad())
  8333. : this.ui.showFailure("模型文件无法读取或无效", this);
  8334. }.bind(this);
  8335. var i = function() {
  8336. this.ui.showFailure(
  8337. "模型文件 (" + this.sceneURL + ") 无法获取.",
  8338. this
  8339. );
  8340. }.bind(this);
  8341. C.fetchBinary(this.sceneURL, e, i, t);
  8342. }
  8343. }),
  8344. (W.prototype.unload = function() {
  8345. delete this.scene,
  8346. delete this.input,
  8347. delete this.ui,
  8348. delete this.mainColor,
  8349. delete this.mainBuffer,
  8350. delete this.gl;
  8351. var e = this.domRoot.clientWidth,
  8352. t = this.domRoot.clientHeight;
  8353. this.initCanvas(e, t),
  8354. (this.ui = new j(this)),
  8355. this.ui.setSize(e, t),
  8356. this.ui.showPreview(),
  8357. this.cancelFrame();
  8358. }),
  8359. (W.prototype.bindInput = function() {
  8360. (this.input = new e(this.ui.container)),
  8361. this.input.onDrag.push(
  8362. function(e, t, i, s) {
  8363. (e = 1 - 2.2 / (Math.sqrt(i * i + s * s) + 2.2)),
  8364. ((t = this.scene.view).rotation[1] -= 0.4 * i * e),
  8365. (t.rotation[0] -= 0.4 * s * e),
  8366. (t.rotation[0] = 90 < t.rotation[0] ? 90 : t.rotation[0]),
  8367. (t.rotation[0] = t.rotation[0] < -90 ? -90 : t.rotation[0]),
  8368. t.updateView(),
  8369. this.wake();
  8370. }.bind(this)
  8371. ),
  8372. this.input.onPan.push(
  8373. function(e, t) {
  8374. var i = this.scene.view,
  8375. s =
  8376. -e *
  8377. (n =
  8378. (i.fov / 45) *
  8379. 0.8 *
  8380. (i.radius / this.domRoot.clientHeight)),
  8381. n = t * n;
  8382. (i.pivot[0] += s * i.transform[0] + n * i.transform[4]),
  8383. (i.pivot[1] += s * i.transform[1] + n * i.transform[5]),
  8384. (i.pivot[2] += s * i.transform[2] + n * i.transform[6]),
  8385. i.updateView(),
  8386. this.wake();
  8387. }.bind(this)
  8388. ),
  8389. this.input.onPan2.push(
  8390. function(e, t) {
  8391. var i = 1 - 2.2 / (Math.sqrt(e * e + t * t) + 2.2);
  8392. (this.scene.lights.rotation -= 0.4 * e * i), this.wake();
  8393. }.bind(this)
  8394. ),
  8395. this.input.onZoom.push(
  8396. function(e) {
  8397. rotInfo.stopWhenZoom && webview.stopRotate();
  8398. var t = this.scene.view;
  8399. (t.radius *= 1 - 0.002 * e),
  8400. (t.radius = t.radius < 0.001 ? 0.001 : t.radius),
  8401. (t.radius = 1e3 < t.radius ? 1e3 : t.radius),
  8402. t.updateView(),
  8403. this.wake();
  8404. }.bind(this)
  8405. ),
  8406. this.input.onDoubleTap.push(
  8407. function(e, t) {
  8408. this.scene.view.reset(),
  8409. this.scene.sceneAnimator &&
  8410. this.scene.sceneAnimator.resetCustomView(),
  8411. this.wake();
  8412. }.bind(this)
  8413. ),
  8414. this.ui.bindInput(this.input);
  8415. }),
  8416. (W.prototype.rotateWhenIdle = function() {
  8417. rotInfo.radiusK &&
  8418. (webview.scene.view.radius =
  8419. rotInfo.radiusK /
  8420. (dom.id("fdageUI").clientWidth / dom.id("fdageUI").clientHeight)),
  8421. (webview.scene.view.pivot = rotInfo.pivot.slice()),
  8422. (webview.rotate = setInterval(function() {
  8423. (webview.scene.view.rotation[1] -= rotInfo.speed),
  8424. webview.updateView(!0, !0, 1);
  8425. }, 16));
  8426. }),
  8427. (W.prototype.stopRotate = function() {
  8428. webview.rotate
  8429. ? (clearInterval(webview.rotate),
  8430. console.log("clearInterval(webview.rotate)"),
  8431. (webview.rotate = null),
  8432. (webview.countIdelTime = setTimeout(
  8433. webview.rotateWhenIdle,
  8434. rotInfo.idleTime
  8435. )))
  8436. : webview.countIdelTime &&
  8437. (clearTimeout(webview.countIdelTime),
  8438. console.log("clearInterval(countIdelTime)"),
  8439. (webview.countIdelTime = setTimeout(
  8440. webview.rotateWhenIdle,
  8441. rotInfo.idleTime
  8442. )));
  8443. }),
  8444. (W.prototype.wake = function(e) {
  8445. (e = e || 16),
  8446. (this.sleepCounter = this.sleepCounter < e ? e : this.sleepCounter),
  8447. this.scene.postRender.discardAAHistory(),
  8448. this.requestFrame(this.update.bind(this));
  8449. }),
  8450. (W.prototype.requestFrame = function(e) {
  8451. var t =
  8452. window.requestAnimationFrame ||
  8453. window.mozRequestAnimationFrame ||
  8454. window.webkitRequestAnimationFrame ||
  8455. window.msRequestAnimationFrame;
  8456. if (!this.frameRequestPending) {
  8457. var i = function() {
  8458. (this.frameRequestPending = 0), e();
  8459. }.bind(this);
  8460. this.frameRequestPending = t(i, this.canvas);
  8461. }
  8462. }),
  8463. (W.prototype.cancelFrame = function() {
  8464. this.frameRequestPending &&
  8465. (
  8466. window.cancelAnimationFrame ||
  8467. window.mozCancelAnimationFrame ||
  8468. window.webkitCancelAnimationFrame ||
  8469. window.msCancelAnimationFrame
  8470. )(this.frameRequestPending);
  8471. }),
  8472. (W.prototype.fullscreenChange = function() {
  8473. g.active()
  8474. ? ((this.oldRootWidth = this.domRoot.style.width),
  8475. (this.oldRootHeight = this.domRoot.style.height),
  8476. (this.domRoot.style.width = "100%"),
  8477. (this.domRoot.style.height = "100%"))
  8478. : ((this.domRoot.style.width = this.oldRootWidth),
  8479. (this.domRoot.style.height = this.oldRootHeight)),
  8480. this.wake();
  8481. }),
  8482. (W.prototype.resize = function(e, t) {
  8483. e && t
  8484. ? ((this.domRoot.style.width = e + "px"),
  8485. (this.domRoot.style.height = t + "px"))
  8486. : ((e = this.domRoot.clientWidth), (t = this.domRoot.clientHeight)),
  8487. (this.canvas.width = e * this.pixelRatio),
  8488. (this.canvas.height = t * this.pixelRatio),
  8489. (this.canvas.style.width = e + "px"),
  8490. (this.canvas.style.height = t + "px"),
  8491. this.ui.setSize(e, t),
  8492. this.allocBacking(),
  8493. this.wake();
  8494. }),
  8495. (W.prototype.updateLoad = function() {
  8496. this.scene.complete()
  8497. ? this.start()
  8498. : this.requestFrame(this.updateLoad.bind(this)),
  8499. this.ui.animate();
  8500. }),
  8501. (W.prototype.start = function() {
  8502. this.scene.view.updateView(),
  8503. this.ui.showActiveView(),
  8504. this.requestFrame(this.update.bind(this)),
  8505. window.autoRotate && this.rotateWhenIdle(),
  8506. (document.documentElement.style.height = "100%"),
  8507. (document.documentElement.style.width = "100%"),
  8508. (document.documentElement.style.margin = "0"),
  8509. (document.documentElement.style.padding = "0"),
  8510. (document.body.style.height = "100%"),
  8511. (document.body.style.width = "100%"),
  8512. (document.body.style.margin = "0"),
  8513. (document.body.style.padding = "0");
  8514. }),
  8515. (W.prototype.update = function() {
  8516. var e = this.scene.sceneAnimator && !this.scene.sceneAnimator.paused;
  8517. (0 < this.sleepCounter ||
  8518. this.ui.animating() ||
  8519. e ||
  8520. this.stripData.animationActive) &&
  8521. (this.stripData.update(),
  8522. this.ui.animate(),
  8523. this.scene.update(),
  8524. this.drawScene(),
  8525. this.requestFrame(this.update.bind(this))),
  8526. e ? this.scene.postRender.discardAAHistory() : this.sleepCounter--;
  8527. }),
  8528. (W.prototype.reDrawScene = function() {
  8529. this.stripData.update(),
  8530. this.ui.animate(),
  8531. this.scene.update(),
  8532. this.drawScene(),
  8533. this.requestFrame(this.update.bind(this)),
  8534. this.scene.postRender.discardAAHistory();
  8535. }),
  8536. (W.prototype.drawScene = function() {
  8537. this.gl.isContextLost() ||
  8538. ((this.domRoot.clientWidth == this.canvas.clientWidth &&
  8539. this.domRoot.clientHeight == this.canvas.clientHeight) ||
  8540. this.resize(),
  8541. (this.scene.view.size = [
  8542. this.mainBuffer.width,
  8543. this.mainBuffer.height,
  8544. ]),
  8545. this.scene.view.updateProjection(),
  8546. this.scene.postRender.adjustProjectionForSupersampling(
  8547. this.scene.view
  8548. ),
  8549. this.scene.collectShadows(this.mainBuffer),
  8550. this.mainBuffer.bind(),
  8551. this.scene.draw(this.mainBuffer),
  8552. this.mainDepth &&
  8553. (this.mainBufferNoDepth.bind(),
  8554. this.scene.drawSecondary(this.mainDepth)),
  8555. this.scene.postRender.present(
  8556. this.mainColor,
  8557. this.canvas.width,
  8558. this.canvas.height,
  8559. this.stripData.active()
  8560. ));
  8561. }),
  8562. (W.prototype.updateView = function(e, t, i) {
  8563. t && webview.scene.view.updateView(),
  8564. webview.wake(i || 4),
  8565. e && webview.scene.postRender.discardAAHistory();
  8566. }),
  8567. ((I = void 0 === I ? {} : I).WebViewer = W),
  8568. (I.dataLocale = "images/");
  8569. var G = {
  8570. "alphaprepassfrag.glsl":
  8571. "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);}",
  8572. "alphaprepassvert.glsl":
  8573. "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;}",
  8574. "bloom.glsl":
  8575. "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;}",
  8576. "bloomshrink.glsl":
  8577. "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)));}",
  8578. "fogfrag.glsl":
  8579. "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}",
  8580. "fogvert.glsl":
  8581. "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);}",
  8582. "matdither.glsl":
  8583. "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);}",
  8584. "matfrag.glsl":
  8585. "\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}",
  8586. "matlighting.glsl":
  8587. "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;}",
  8588. "matmicrofiber.glsl":
  8589. "\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",
  8590. "matsampling.glsl":
  8591. "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);}",
  8592. "matshadows.glsl":
  8593. "\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",
  8594. "matskin.glsl":
  8595. "\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",
  8596. "matstrips.glsl":
  8597. "\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",
  8598. "matvert.glsl":
  8599. "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}",
  8600. "postaa.glsl":
  8601. "precision mediump float;uniform sampler2D tInput;varying vec2 j;void main(void){gl_FragColor=texture2D(tInput,j);}",
  8602. "postfrag.glsl":
  8603. "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;}",
  8604. "postvert.glsl":
  8605. "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);}",
  8606. "shadowfloorfrag.glsl":
  8607. "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;}",
  8608. "shadowfloorvert.glsl":
  8609. "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);}",
  8610. "shadowfrag.glsl":
  8611. "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;}",
  8612. "shadowvert.glsl":
  8613. "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}",
  8614. "sky.glsl":
  8615. "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;}",
  8616. "skySH.glsl":
  8617. "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;}",
  8618. "skyvert.glsl":
  8619. "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}",
  8620. "wirefrag.glsl":
  8621. "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);}",
  8622. "wirevert.glsl":
  8623. "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;}",
  8624. nil: "",
  8625. };
  8626. })(fdage);