4dage.js 306 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539
  1. var webview, dom = {}, rotInfo = {
  2. idleTime: 3e3,
  3. speed: .15,
  4. pivot: [],
  5. stopWhenZoom: !1
  6. };
  7. function getQueryVariable(e) {
  8. for (var t = window.location.search.substring(1).split("&"), i = 0; i < t.length; i++) {
  9. var s = t[i].split("=");
  10. if (s[0] == e)
  11. return s[1]
  12. }
  13. return !1
  14. }
  15. dom.addClass = function(e, t) {
  16. if (void 0 === e.className)
  17. e.className = t;
  18. else if (e.className !== t) {
  19. var i = e.className.split(/ +/);
  20. -1 == i.indexOf(t) && (i.push(t),
  21. e.className = i.join(" ").replace(/^\s+/, "").replace(/\s+$/, ""))
  22. }
  23. }
  24. ,
  25. dom.removeClass = function(e, t) {
  26. if (t)
  27. if (void 0 === e.className)
  28. ;
  29. else if (e.className === t)
  30. e.removeAttribute("class");
  31. else {
  32. var i = e.className.split(/ +/)
  33. , s = i.indexOf(t);
  34. -1 != s && (i.splice(s, 1),
  35. e.className = i.join(" "))
  36. }
  37. else
  38. e.className = void 0
  39. }
  40. ,
  41. dom.hasClass = function(e, t) {
  42. return new RegExp("(?:^|\\s+)" + t + "(?:\\s+|$)").test(e.className) || !1
  43. }
  44. ,
  45. dom.id = function(e, t) {
  46. return (t = t || document).getElementById && t.getElementById(e) || document.getElementById(e)
  47. }
  48. ,
  49. dom.Tag = function(e, t) {
  50. return (t = t || document).getElementsByTagName(e)
  51. }
  52. ,
  53. dom.cla = function(e, t) {
  54. return (t = t || document).getElementsByClassName(e)
  55. }
  56. ,
  57. dom.ifVoid = function(e, t) {
  58. return null == e ? t : e
  59. }
  60. ,
  61. dom.objToArray = function(e) {
  62. if (e instanceof Array)
  63. return e;
  64. var t = [];
  65. for (var i in e)
  66. t.push(e[i]);
  67. return t
  68. }
  69. ;
  70. var Clamp = function(e, t, i) {
  71. return void 0 === t && (t = 0),
  72. void 0 === i && (i = 1),
  73. Math.min(i, Math.max(t, e))
  74. }
  75. , codeToCh = function(e) {
  76. return unescape(e)
  77. };
  78. fdage = {},
  79. function(I) {
  80. function r(e, t, i) {
  81. if (this.name = t.partName,
  82. this.animatedProperties = [],
  83. this.sceneObjectType = t.sceneObjectType,
  84. this.skinningRigIndex = t.skinningRigIndex,
  85. this.id = i,
  86. this.mesh = this.skinningRig = 0,
  87. this.materialIndex = this.lightIndex = this.meshIndex = -1,
  88. this.emissiveProperty = this.offsetVProperty = this.offsetUProperty = this.material = 0,
  89. this.debugMe = t.debugMe,
  90. this.debugString = "",
  91. this.hasTransform = !1,
  92. this.modelPartIndex = t.modelPartIndex,
  93. this.modelPartFPS = t.modelPartFPS,
  94. this.modelPartScale = t.modelPartScale,
  95. this.parentIndex = t.parentIndex,
  96. this.totalFrames = t.totalFrames,
  97. this.animationLength = 1 / this.modelPartFPS * this.totalFrames,
  98. 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,
  99. t.animatedProperties) {
  100. i = t.animatedProperties.length;
  101. for (var s = 0; s < i; ++s) {
  102. var n = t.animatedProperties[s]
  103. , r = new a();
  104. r.name = n.name,
  105. this.animatedProperties.push(r),
  106. "Red" != r.name || this.redProperty || (this.redProperty = r),
  107. "Green" != r.name || this.greenProperty || (this.greenProperty = r),
  108. "Blue" != r.name || this.blueProperty || (this.blueProperty = r),
  109. "Brightness" != r.name || this.brightnessProperty || (this.brightnessProperty = r),
  110. "Distance" != r.name || this.distanceProperty || (this.distanceProperty = r),
  111. "Spot Angle" != r.name || this.spotAngleProperty || (this.spotAngleProperty = r),
  112. "Spot Sharpness" != r.name || this.spotSharpnessProperty || (this.spotSharpnessProperty = r),
  113. "Opacity" != r.name || this.opacityProperty || (this.opacityProperty = r),
  114. "Sky Illumination" != r.name || this.skyIllumProperty || (this.skyIllumProperty = r),
  115. "Light Illumination" != r.name || this.lightIllumProperty || (this.lightIllumProperty = r),
  116. "Dispersion" != r.name || this.dispersionProperty || (this.dispersionProperty = r),
  117. "Visible" != r.name || this.visibleProperty || (this.visibleProperty = r),
  118. "Spin Rate" == r.name && (this.spinProperty = r),
  119. "OffsetU" == r.name && (this.offsetUProperty = r),
  120. "OffsetV" == r.name && (this.offsetVProperty = r),
  121. "EmissiveIntensity" == r.name && (this.emissiveProperty = r)
  122. }
  123. }
  124. this.keyframesSharedBufferUShorts = this.keyframesSharedBufferFloats = this.keyFramesByteStream = 0,
  125. (e = e.get(t.file)) && (this.keyFramesByteStream = new u(e.data),
  126. this.unPackKeyFrames()),
  127. this.animatedLocalTransform = new o(this),
  128. this.hasTransform = this.animatedLocalTransform.hasTranslation || this.animatedLocalTransform.hasRotation || this.animatedLocalTransform.hasScale,
  129. this.cachedWorldTransform0 = S.identity(),
  130. this.cachedWorldTransform1 = S.identity(),
  131. this.cachedWorldTransform2 = S.identity(),
  132. this.cachedWorldTransform3 = S.identity(),
  133. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -10,
  134. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  135. this.useFixedLocalTransform = this.useFixedWorldTransform = !1
  136. }
  137. function a() {
  138. this.currentValue = 0,
  139. this.keyframeBufferStartIndexFloat = -1,
  140. this.lastValue = this.interpolationOffsetUShort = this.frameIndexOffsetUShort = this.weighOutOffsetFloat = this.weighInOffsetFloat = this.valueOffsetFloat = this.indexUShortSkip = this.indexFloatSkip = this.interpolationType = this.bytesPerKeyFrame = this.keyframePackingType = 0,
  141. this.lastFramePercent = -10,
  142. this.enable = !0,
  143. this.name = "NONE",
  144. this.splineKF0 = new i(0,0),
  145. this.splineKF1 = new i(0,0),
  146. this.splineKF2 = new i(0,0),
  147. this.splineKF3 = new i(0,0),
  148. this.debugMe = !0,
  149. this.debugString = "",
  150. this.lastSearchIndex = 1,
  151. this.savedSearchIndex = 0,
  152. this.splineKF0.frameIndex = 0,
  153. this.splineKF1.frameIndex = 1,
  154. this.splineKF2.frameIndex = 2,
  155. this.splineKF3.frameIndex = 3,
  156. this.numKeyframes = 0
  157. }
  158. function o(e) {
  159. var t = e.animatedProperties;
  160. for (this.TX = this.TY = this.TZ = this.RX = this.RY = this.RZ = this.SX = this.SY = this.SZ = 0,
  161. this.hostObject = e,
  162. this.matrix = S.identity(),
  163. this.cachedmatrix0 = S.identity(),
  164. this.cachedmatrix1 = S.identity(),
  165. this.cachedmatrix2 = S.identity(),
  166. this.cachedmatrix3 = S.identity(),
  167. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -1,
  168. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  169. this.debugString = "",
  170. e = 0; e < t.length; e++) {
  171. var i = t[e];
  172. "Translation X" == i.name ? this.TX = i : "Translation Y" == i.name ? this.TY = i : "Translation Z" == i.name ? this.TZ = i : "Rotation X" == i.name ? this.RX = i : "Rotation Y" == i.name ? this.RY = i : "Rotation Z" == i.name ? this.RZ = i : "Scale X" == i.name ? this.SX = i : "Scale Y" == i.name ? this.SY = i : "Scale Z" == i.name && (this.SZ = i)
  173. }
  174. this.hasTranslation = this.TX && this.TY && this.TZ,
  175. this.hasRotation = this.RX && this.RY && this.RZ,
  176. this.hasScale = this.SX && this.SY && this.SZ,
  177. this.lockTransform = !1
  178. }
  179. function c(e, t) {
  180. if (this.originalFPS = 1,
  181. this.name = t.name,
  182. this.totalSeconds = t.length,
  183. this.originalFPS = t.originalFPS,
  184. this.totalFrames = t.totalFrames,
  185. this.expectedNumAnimatedObjects = t.numAnimatedObjects,
  186. this.animatedObjects = [],
  187. this.sceneTransform = S.identity(),
  188. this.debugString = "",
  189. t.animatedObjects)
  190. for (var i = t.animatedObjects.length, s = 0; s < i; ++s) {
  191. var n = new r(e,t.animatedObjects[s],s);
  192. this.animatedObjects.push(n),
  193. this.debugString += n.debugString
  194. }
  195. this.meshObjects = [],
  196. this.lightObjects = [],
  197. this.materialObjects = [],
  198. this.turnTableObjects = [],
  199. this.cameraObjects = []
  200. }
  201. function h(e) {
  202. for (this.files = [],
  203. e = new u(e); !e.empty(); ) {
  204. var t = {};
  205. t.name = e.readCString(),
  206. t.type = e.readCString();
  207. var i = e.readUint32()
  208. , s = e.readUint32()
  209. , n = e.readUint32();
  210. if (t.data = e.readBytes(s),
  211. !(t.data.length < s)) {
  212. if (1 & i && (t.data = this.decompress(t.data, n),
  213. null === t.data))
  214. continue;
  215. this.files[t.name] = t
  216. }
  217. }
  218. }
  219. function l(e) {
  220. this.digits = new Uint16Array(e || 0)
  221. }
  222. function d(e) {
  223. for (var t = 0; t < e.length; ++t) {
  224. var i = e[t].bounds;
  225. if (void 0 === this.min)
  226. this.min = [i.min[0], i.min[1], i.min[2]],
  227. this.max = [i.max[0], i.max[1], i.max[2]];
  228. else
  229. for (var s = 0; s < 3; ++s)
  230. this.min[s] = Math.min(i.min[s], this.min[s]),
  231. this.max[s] = Math.max(i.max[s], this.max[s])
  232. }
  233. this.min = this.min ? this.min : [0, 0, 0],
  234. this.max = this.max ? this.max : [0, 0, 0],
  235. this.center = [.5 * (this.min[0] + this.max[0]), .5 * (this.min[1] + this.max[1]), .5 * (this.min[2] + this.max[2])],
  236. this.radius = [this.max[0] - this.center[0], this.max[1] - this.center[1], this.max[2] - this.center[2]],
  237. this.radiusDiagonal = Math.sqrt(this.radius[0] * this.radius[0] + this.radius[1] * this.radius[1] + this.radius[2] * this.radius[2])
  238. }
  239. function p(e) {
  240. this.name = "none",
  241. this.text = "default text",
  242. this.title = "none",
  243. this.debugString = this.imagePath = "",
  244. this.controlRect = new s(e),
  245. this.defaultAlpha = .5,
  246. this.focusAlpha = 1,
  247. this.updateAlphas = !0,
  248. 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
  249. }
  250. function u(e) {
  251. this.bytes = new Uint8Array(e)
  252. }
  253. function s(e) {
  254. this.name = "none",
  255. this.title = "frame",
  256. this.yPercent = this.xPercent = 0,
  257. this.heightPercent = this.widthPercent = 1,
  258. this.debugString = "",
  259. this.parentControlRect = 0,
  260. this.childControlRects = [],
  261. this.clicked = this.mouseDown = this.mouseOver = !1,
  262. this.localMouseYPercent = this.localMouseXPercent = 0,
  263. this.enabled = this.visible = !0,
  264. this.opacity = 1,
  265. this.guiScreen = e,
  266. this.id = this.callBack = this.linkedControl = 0
  267. }
  268. r.prototype.setFixedWorldTransform = function(e) {
  269. this.useFixedWorldTransform = !0,
  270. S.copy(this.cachedWorldTransform0, e)
  271. }
  272. ,
  273. r.prototype.setFixedLocalTransform = function(e) {
  274. this.useFixedLocalTransform = !0,
  275. this.animatedLocalTransform.lockTransform = !0,
  276. S.copy(this.animatedLocalTransform.cachedmatrix0, e)
  277. }
  278. ,
  279. r.prototype.getCachedWorldTransform = function(e) {
  280. return this.useFixedWorldTransform ? 0 : e == this.cachedFrame0 ? this.cachedmatrix0 : e == this.cachedFrame1 ? this.cachedmatrix1 : e == this.cachedFrame2 ? this.cachedmatrix2 : e == this.cachedFrame3 ? this.cachedmatrix3 : 0
  281. }
  282. ,
  283. r.prototype.getFreeCachedWorldTransform = function(e) {
  284. return this.useFixedWorldTransform ? 0 : (this.cachedFrameUse0--,
  285. this.cachedFrameUse1--,
  286. this.cachedFrameUse2--,
  287. this.cachedFrameUse3--,
  288. this.cachedFrameUse0 <= this.cachedFrameUse1 && this.cachedFrameUse0 <= this.cachedFrameUse2 && this.cachedFrameUse0 <= this.cachedFrameUse3 ? (this.cachedFrame0 = e,
  289. this.cachedFrameUse0 = 0,
  290. this.cachedWorldTransform0) : this.cachedFrameUse1 <= this.cachedFrameUse0 && this.cachedFrameUse1 <= this.cachedFrameUse2 && this.cachedFrameUse1 <= this.cachedFrameUse3 ? (this.cachedFrame1 = e,
  291. this.cachedFrameUse1 = 0,
  292. this.cachedWorldTransform1) : this.cachedFrameUse2 <= this.cachedFrameUse0 && this.cachedFrameUse2 <= this.cachedFrameUse1 && this.cachedFrameUse2 <= this.cachedFrameUse3 ? (this.cachedFrame2 = e,
  293. this.cachedFrameUse2 = 0,
  294. this.cachedWorldTransform2) : (this.cachedFrame3 = e,
  295. this.cachedFrameUse3 = 0,
  296. this.cachedWorldTransform3))
  297. }
  298. ,
  299. r.prototype.unPackKeyFrames = function() {
  300. if (this.keyFramesByteStream) {
  301. var e = new Float32Array(this.keyFramesByteStream.bytes.buffer)
  302. , t = new Uint32Array(this.keyFramesByteStream.bytes.buffer)
  303. , i = new Uint16Array(this.keyFramesByteStream.bytes.buffer)
  304. , s = new Uint8Array(this.keyFramesByteStream.bytes.buffer);
  305. this.keyframesSharedBufferFloats = e;
  306. e = 0,
  307. e = 1 + (t = (this.keyframesSharedBufferUShorts = t)[0]),
  308. t = this.animatedProperties.length;
  309. for (var n = 0; n < t; n++) {
  310. var r = this.animatedProperties[n]
  311. , a = 2 + 2 * n
  312. , o = 2 * a;
  313. r.keyframeBufferStartIndexFloat = e,
  314. r.numKeyframes = i[a],
  315. r.keyframePackingType = s[2 + o],
  316. r.interpolationType = s[3 + o],
  317. r.indexFloatSkip = 0,
  318. (r.indexUShortSkip = 0) < r.numKeyframes && (0 == r.keyframePackingType ? (r.bytesPerKeyFrame = 16,
  319. r.indexFloatSkip = 4,
  320. r.indexUShortSkip = 8,
  321. r.valueOffsetFloat = 0,
  322. r.weighInOffsetFloat = 1,
  323. r.weighOutOffsetFloat = 2,
  324. r.frameIndexOffsetUShort = 6,
  325. r.interpolationOffsetUShort = 7) : 1 == r.keyframePackingType ? (r.bytesPerKeyFrame = 8,
  326. r.indexFloatSkip = 2,
  327. r.indexUShortSkip = 4,
  328. r.valueOffsetFloat = 0,
  329. r.weighInOffsetFloat = 0,
  330. r.weighOutOffsetFloat = 0,
  331. r.frameIndexOffsetUShort = 2,
  332. r.interpolationOffsetUShort = 3) : 2 == r.keyframePackingType && (r.bytesPerKeyFrame = 4,
  333. r.indexFloatSkip = 1,
  334. r.indexUShortSkip = 2,
  335. r.valueOffsetFloat = 0,
  336. r.weighInOffsetFloat = 0,
  337. r.weighOutOffsetFloat = 0,
  338. r.frameIndexOffsetUShort = 0,
  339. r.interpolationOffsetUShort = 0)),
  340. e += r.numKeyframes * r.indexFloatSkip
  341. }
  342. }
  343. }
  344. ,
  345. r.prototype.setupSkinningRig = function(e, t, i, s) {
  346. var n = S.identity()
  347. , r = S.identity()
  348. , a = (a = i * (o = e.animatedObjects[t]).modelPartFPS) - Math.floor(a)
  349. , o = (i = Math.floor(e.getObjectAnimationFramePercent(o, i))) + 1
  350. , h = 1 - a
  351. , l = s.skinningClusters.length;
  352. if (0 < l)
  353. for (var d = 0; d < l; d++) {
  354. (c = s.skinningClusters[d]).solveClusterTransformAtFrame(e, t, i, n),
  355. c.solveClusterTransformAtFrame(e, t, o, r);
  356. for (var c = c.matrix, u = 0; u < 16; u++)
  357. c[u] = n[u] * h + r[u] * a
  358. }
  359. }
  360. ,
  361. r.prototype.evaluateLocalTransformAtFramePercent = function(e, t, i, s) {
  362. if (this.useFixedLocalTransform)
  363. S.copy(t, this.animatedLocalTransform.cachedmatrix0);
  364. else {
  365. var n = 0;
  366. s && (n = this.animatedLocalTransform.getCachedTransform(e)),
  367. n ? S.copy(t, n) : ((n = this.animatedLocalTransform.getFreeCachedTransform(e)) ? (this.animatedLocalTransform.evaluateMatrix(n, this.totalFrames, e, i),
  368. S.copy(t, n)) : this.animatedLocalTransform.evaluateMatrix(t, this.totalFrames, e, i),
  369. 0 != this.turnTableSpin && (e = S.rotation(S.empty(), this.turnTableSpin, 1),
  370. S.mul(t, t, e)))
  371. }
  372. }
  373. ,
  374. r.prototype.hasAnimatedTransform = function() {
  375. var e = this.animatedLocalTransform;
  376. return !!(e.TX && 1 < e.TX.numKeyframes || e.TY && 1 < e.TY.numKeyframes || e.TZ && 1 < e.TZ.numKeyframes || e.RX && 1 < e.RX.numKeyframes || e.RY && 1 < e.RY.numKeyframes || e.RZ && 1 < e.RZ.numKeyframes || e.SX && 1 < e.SX.numKeyframes || e.SY && 1 < e.SY.numKeyframes || e.SZ && 1 < e.SZ.numKeyframes)
  377. }
  378. ,
  379. a.prototype.evaluateCurve = function(e, t) {
  380. var i = this.splineKF1.frameIndex
  381. , s = this.splineKF2.frameIndex
  382. , n = this.splineKF1.value
  383. , r = this.splineKF2.value
  384. , a = i - (this.splineKF2.frameIndex - this.splineKF0.frameIndex)
  385. , o = s - (this.splineKF1.frameIndex - this.splineKF3.frameIndex)
  386. , h = n - (this.splineKF2.value - this.splineKF0.value) * this.splineKF1.weighOut
  387. , l = r - (this.splineKF1.value - this.splineKF3.value) * this.splineKF2.weighIn;
  388. return 3 == this.splineKF1.interpolation && (a = i - (this.splineKF2.frameIndex - this.splineKF1.frameIndex),
  389. h = n - this.splineKF1.weighOut),
  390. 3 == this.splineKF2.interpolation && (o = s - (this.splineKF1.frameIndex - this.splineKF2.frameIndex),
  391. l = r + this.splineKF2.weighIn),
  392. a = (e - a) / (i - a),
  393. i = (e - i) / (s - i),
  394. s = (e - s) / (o - s),
  395. ((h * (1 - a) + n * a) * (1 - i) + (o = n * (1 - i) + r * i) * i) * (1 - i) + ((r * (1 - s) + l * s) * i + o * (1 - i)) * i
  396. }
  397. ,
  398. a.prototype.evaluate = function(e, t, i) {
  399. if (!i)
  400. return t;
  401. if (0 == this.numKeyframes)
  402. return this.lastValue = t;
  403. if (1 == this.numKeyframes)
  404. return this.lastValue = 2 == this.keyframePackingType ? i.keyframesSharedBufferFloats[this.keyframeBufferStartIndexFloat] : i.keyframesSharedBufferFloats[this.keyframeBufferStartIndexFloat + this.valueOffsetFloat];
  405. if (this.lastFramePercent == e)
  406. return this.lastValue;
  407. var s = this.keyframeBufferStartIndexFloat
  408. , n = 2 * this.keyframeBufferStartIndexFloat;
  409. if (this.lastValue = t,
  410. this.lastFramePercent = e,
  411. 2 == this.keyframePackingType) {
  412. var r = e - (t = Math.floor(e));
  413. return e >= this.numKeyframes && (t -= Math.floor(e / this.numKeyframes) * this.numKeyframes),
  414. t >= this.numKeyframes ? this.lastValue = i.keyframesSharedBufferFloats[s + (this.numKeyframes - 1)] : t < 0 ? this.lastValue = i.keyframesSharedBufferFloats[s] : 0 == r ? this.lastValue = i.keyframesSharedBufferFloats[s + t] : (e = n = i.keyframesSharedBufferFloats[s + t],
  415. ++t >= this.numKeyframes && (t -= this.numKeyframes),
  416. 0 <= t && t < this.numKeyframes ? e = n * (1 - r) + i.keyframesSharedBufferFloats[s + t] * r : i.debugString += "<br>bad lerp frame " + t + " of " + this.numKeyframes,
  417. this.lastValue = e)
  418. }
  419. var a = this.numKeyframes;
  420. r = i.keyframesSharedBufferUShorts[n + this.frameIndexOffsetUShort];
  421. if (e >= i.keyframesSharedBufferUShorts[n + (a - 1) * this.indexUShortSkip + this.frameIndexOffsetUShort])
  422. return this.lastValue = i.keyframesSharedBufferFloats[s + (a - 1) * this.indexFloatSkip + this.valueOffsetFloat];
  423. if (e < r)
  424. return this.lastValue = i.keyframesSharedBufferFloats[s + this.valueOffsetFloat];
  425. this.lastSearchIndex < this.numKeyframes && e > i.keyframesSharedBufferUShorts[n + this.lastSearchIndex * this.indexUShortSkip + this.frameIndexOffsetUShort] && (this.lastSearchIndex = 1);
  426. for (var o = this.lastSearchIndex; o < a; o++) {
  427. r = s + o * this.indexFloatSkip;
  428. var h = s + (o - 1) * this.indexFloatSkip
  429. , l = n + o * this.indexUShortSkip
  430. , d = n + (o - 1) * this.indexUShortSkip;
  431. if (e >= i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort] && e <= i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort]) {
  432. this.lastSearchIndex = o;
  433. var c = i.keyframesSharedBufferUShorts[d + this.interpolationOffsetUShort];
  434. if (2 == c) {
  435. this.lastValue = e = e >= i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort] ? i.keyframesSharedBufferFloats[r + this.valueOffsetFloat] : i.keyframesSharedBufferFloats[h + this.valueOffsetFloat];
  436. break
  437. }
  438. if (0 == c) {
  439. s = i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort],
  440. t = i.keyframesSharedBufferFloats[h + this.valueOffsetFloat],
  441. n = i.keyframesSharedBufferFloats[r + this.valueOffsetFloat],
  442. r = (e - s) / (i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort] - s),
  443. this.lastValue = e = t * (1 - r) + n * r;
  444. break
  445. }
  446. if (1 == c || 3 == c) {
  447. var u = c = !1
  448. , f = 0
  449. , m = i.keyframesSharedBufferFloats[h + this.valueOffsetFloat]
  450. , p = i.keyframesSharedBufferFloats[r + this.valueOffsetFloat]
  451. , g = 0
  452. , v = 0
  453. , x = (d = i.keyframesSharedBufferUShorts[d + this.frameIndexOffsetUShort],
  454. l = i.keyframesSharedBufferUShorts[l + this.frameIndexOffsetUShort],
  455. 0)
  456. , y = 1
  457. , b = 1
  458. , S = 1
  459. , T = 1
  460. , w = 1
  461. , C = 1
  462. , R = 1
  463. , A = 1;
  464. 0 != this.weighInOffsetFloat && (b = i.keyframesSharedBufferFloats[h + this.weighInOffsetFloat],
  465. S = i.keyframesSharedBufferFloats[r + this.weighInOffsetFloat],
  466. C = i.keyframesSharedBufferFloats[h + this.weighOutOffsetFloat],
  467. R = i.keyframesSharedBufferFloats[r + this.weighOutOffsetFloat]),
  468. 1 < o && (c = !0,
  469. f = i.keyframesSharedBufferFloats[s + (o - 2) * this.indexFloatSkip + this.valueOffsetFloat],
  470. v = i.keyframesSharedBufferUShorts[n + (o - 2) * this.indexUShortSkip + this.frameIndexOffsetUShort],
  471. 0 != this.weighInOffsetFloat && (y = i.keyframesSharedBufferFloats[s + (o - 2) * this.indexFloatSkip + this.weighInOffsetFloat],
  472. w = i.keyframesSharedBufferFloats[s + (o - 2) * this.indexFloatSkip + this.weighOutOffsetFloat])),
  473. o < a - 1 && (u = !0,
  474. g = i.keyframesSharedBufferFloats[s + (o + 1) * this.indexFloatSkip + this.valueOffsetFloat],
  475. x = i.keyframesSharedBufferUShorts[n + (o + 1) * this.indexUShortSkip + this.frameIndexOffsetUShort],
  476. 0 != this.weighInOffsetFloat && (T = i.keyframesSharedBufferFloats[s + (o + 1) * this.indexFloatSkip + this.weighInOffsetFloat],
  477. A = i.keyframesSharedBufferFloats[s + (o + 1) * this.indexFloatSkip + this.weighOutOffsetFloat])),
  478. c && u ? (this.splineKF0.value = f,
  479. this.splineKF1.value = m,
  480. this.splineKF2.value = p,
  481. this.splineKF3.value = g,
  482. this.splineKF0.frameIndex = v,
  483. this.splineKF1.frameIndex = d,
  484. this.splineKF2.frameIndex = l,
  485. this.splineKF3.frameIndex = x,
  486. this.splineKF0.weighIn = y,
  487. this.splineKF0.weighOut = w,
  488. this.splineKF1.weighIn = b,
  489. this.splineKF1.weighOut = C,
  490. this.splineKF2.weighIn = S,
  491. this.splineKF2.weighOut = R,
  492. this.splineKF3.weighIn = T,
  493. this.splineKF3.weighOut = A) : (this.splineKF0.value = m,
  494. this.splineKF1.value = m,
  495. this.splineKF2.value = p,
  496. this.splineKF3.value = p,
  497. this.splineKF0.frameIndex = d,
  498. this.splineKF1.frameIndex = d,
  499. this.splineKF2.frameIndex = l,
  500. this.splineKF3.frameIndex = l,
  501. this.splineKF1.weighIn = b,
  502. this.splineKF2.weighIn = S,
  503. this.splineKF1.weighOut = C,
  504. this.splineKF2.weighOut = R,
  505. u ? (this.splineKF3.value = g,
  506. this.splineKF3.frameIndex = x,
  507. this.splineKF3.weighIn = T,
  508. this.splineKF3.weighOut = A) : (this.splineKF3.frameIndex++,
  509. this.splineKF3.value = this.splineKF1.value,
  510. this.splineKF3.weighIn = 1,
  511. this.splineKF3.weighOut = 1),
  512. c ? (this.splineKF0.value = f,
  513. this.splineKF0.frameIndex = v,
  514. this.splineKF0.weighIn = y,
  515. this.splineKF0.weighOut = w) : (this.splineKF0.value = this.splineKF2.value,
  516. this.splineKF0.weighIn = 1,
  517. this.splineKF0.weighOut = 1,
  518. 0 < this.splineKF0.frameIndex ? this.splineKF0.frameIndex-- : (this.splineKF1.frameIndex++,
  519. this.splineKF2.frameIndex++,
  520. this.splineKF3.frameIndex++,
  521. e++))),
  522. this.lastValue = e = this.evaluateCurve(e, t);
  523. break
  524. }
  525. }
  526. }
  527. return this.lastValue
  528. }
  529. ,
  530. o.prototype.getTRSValue = function(e, t, i) {
  531. return t ? (t.evaluate(e, i, this.hostObject),
  532. "" != t.debugString && (this.debugString += t.debugString),
  533. t.lastValue) : i
  534. }
  535. ,
  536. o.prototype.evaluateMatrix = function(e, t, i, s) {
  537. if (this.lockTransform)
  538. S.copy(e, this.cachedmatrix0);
  539. else {
  540. var n = 0
  541. , r = t = 0;
  542. n = r = t = 0,
  543. n = r = t = 1;
  544. this.hasRotation ? (n = this.getTRSValue(i, this.RX, 0),
  545. t = this.getTRSValue(i, this.RY, 0),
  546. r = this.getTRSValue(i, this.RZ, 0),
  547. s ? (this.matrix = S.rotation(S.empty(), r, 2),
  548. s = S.rotation(S.empty(), n, 0),
  549. S.mul(s, s, this.matrix),
  550. this.matrix = S.rotation(S.empty(), t, 1)) : (this.matrix = S.rotation(S.empty(), n, 0),
  551. s = S.rotation(S.empty(), t, 1),
  552. S.mul(s, s, this.matrix),
  553. this.matrix = S.rotation(S.empty(), r, 2)),
  554. S.mul(this.matrix, this.matrix, s)) : S.copy(this.matrix, S.identity()),
  555. this.hasTranslation && (t = this.getTRSValue(i, this.TX, 0),
  556. r = this.getTRSValue(i, this.TY, 0),
  557. n = this.getTRSValue(i, this.TZ, 0),
  558. this.matrix[12] = t,
  559. this.matrix[13] = r,
  560. this.matrix[14] = n),
  561. this.hasScale && (t = this.getTRSValue(i, this.SX, 1),
  562. r = this.getTRSValue(i, this.SY, 1),
  563. n = this.getTRSValue(i, this.SZ, 1),
  564. this.matrix[0] *= t,
  565. this.matrix[4] *= r,
  566. this.matrix[8] *= n,
  567. this.matrix[1] *= t,
  568. this.matrix[5] *= r,
  569. this.matrix[9] *= n,
  570. this.matrix[2] *= t,
  571. this.matrix[6] *= r,
  572. this.matrix[10] *= n,
  573. this.matrix[3] *= t,
  574. this.matrix[7] *= r,
  575. this.matrix[11] *= n),
  576. S.copy(e, this.matrix)
  577. }
  578. }
  579. ,
  580. o.prototype.clearCachedTransforms = function() {
  581. this.cachedFrame3 = this.cachedFrame2 = this.cachedFrame1 = this.cachedFrame0 = -1,
  582. this.cachedFrameUse3 = this.cachedFrameUse2 = this.cachedFrameUse1 = this.cachedFrameUse0 = 0,
  583. this.TX && (this.TX.lastFramePercent = -10),
  584. this.TY && (this.TY.lastFramePercent = -10),
  585. this.TZ && (this.TZ.lastFramePercent = -10),
  586. this.RX && (this.RX.lastFramePercent = -10),
  587. this.RY && (this.RY.lastFramePercent = -10),
  588. this.RZ && (this.RZ.lastFramePercent = -10),
  589. this.SX && (this.SX.lastFramePercent = -10),
  590. this.SY && (this.SY.lastFramePercent = -10),
  591. this.SZ && (this.SZ.lastFramePercent = -10),
  592. this.lockTransform = !1
  593. }
  594. ,
  595. o.prototype.getCachedTransform = function(e) {
  596. return this.lockTransform ? 0 : this.cachedFrame0 == e ? this.cachedmatrix0 : this.cachedFrame1 == e ? this.cachedmatrix1 : this.cachedFrame2 == e ? this.cachedmatrix2 : this.cachedFrame3 == e ? this.cachedmatrix3 : 0
  597. }
  598. ,
  599. o.prototype.getFreeCachedTransform = function(e) {
  600. return this.lockTransform ? 0 : (this.cachedFrameUse0--,
  601. this.cachedFrameUse1--,
  602. this.cachedFrameUse2--,
  603. this.cachedFrameUse3--,
  604. this.cachedFrameUse0 <= this.cachedFrameUse1 && this.cachedFrameUse0 <= this.cachedFrameUse2 && this.cachedFrameUse0 <= this.cachedFrameUse3 || this.cachedFrame0 == e ? (this.cachedFrame0 = e,
  605. this.cachedFrameUse0 = 0,
  606. this.cachedmatrix0) : this.cachedFrameUse1 <= this.cachedFrameUse0 && this.cachedFrameUse1 <= this.cachedFrameUse2 && this.cachedFrameUse1 <= this.cachedFrameUse3 || this.cachedFrame1 == e ? (this.cachedFrame1 = e,
  607. this.cachedFrameUse1 = 0,
  608. this.cachedmatrix1) : this.cachedFrameUse2 <= this.cachedFrameUse0 && this.cachedFrameUse2 <= this.cachedFrameUse1 && this.cachedFrameUse2 <= this.cachedFrameUse3 || this.cachedFrame2 == e ? (this.cachedFrame2 = e,
  609. this.cachedFrameUse2 = 0,
  610. this.cachedmatrix2) : (this.cachedFrame3 = e,
  611. this.cachedFrameUse3 = 0,
  612. this.cachedmatrix3))
  613. }
  614. ,
  615. c.prototype.evaluateModelPartTransformAtFrame = function(e, t, i, s) {
  616. S.copy(i, S.identity());
  617. for (var n = 0; n < 100; n++) {
  618. var r = this.animatedObjects[e];
  619. if (e == r.parentIndex)
  620. break;
  621. if (r.useFixedWorldTransform) {
  622. S.mul(i, r.cachedWorldTransform0, i);
  623. break
  624. }
  625. var a = 0;
  626. if (s && (a = r.getCachedWorldTransform(t)),
  627. a) {
  628. S.mul(i, a, i);
  629. break
  630. }
  631. a = S.identity(),
  632. r.evaluateLocalTransformAtFramePercent(t, a, !1, s),
  633. S.mul(i, a, i),
  634. e == r.parentIndex && (n = 100),
  635. e = r.parentIndex
  636. }
  637. }
  638. ,
  639. c.prototype.lerpModelPartTransform = function(e, t, i, s) {
  640. var n = this.animatedObjects[e];
  641. if (n.useFixedWorldTransform)
  642. S.copy(i, n.cachedWorldTransform0);
  643. else {
  644. var r = (r = t * n.modelPartFPS) - Math.floor(r)
  645. , a = Math.floor(this.getObjectAnimationFramePercent(n, t))
  646. , o = a + 1
  647. , h = t = 0;
  648. for (s && (t = n.getCachedWorldTransform(a),
  649. h = n.getCachedWorldTransform(o)),
  650. t || ((t = n.getFreeCachedWorldTransform(a)) || (t = S.identity()),
  651. this.evaluateModelPartTransformAtFrame(e, a, t, s)),
  652. h || ((h = n.getFreeCachedWorldTransform(o)) || (h = S.identity()),
  653. this.evaluateModelPartTransformAtFrame(e, o, h, s)),
  654. e = 1 - r,
  655. s = 0; s < 16; s++)
  656. i[s] = t[s] * e + h[s] * r
  657. }
  658. }
  659. ,
  660. c.prototype.getModelPartTransform = function(e, t, i, s) {
  661. this.lerpModelPartTransform(e, t, i, s)
  662. }
  663. ,
  664. c.prototype.getAnimatedLocalTransform = function(e, t, i, s) {
  665. e = this.animatedObjects[e];
  666. var n = this.animatedObjects[e.parentIndex]
  667. , r = n.modelPartIndex != n.id
  668. , a = S.identity();
  669. if (this.getModelPartTransform(e.modelPartIndex, t, a, s),
  670. r) {
  671. r = S.identity();
  672. var o = S.identity();
  673. this.getModelPartTransform(n.modelPartIndex, t, r, s),
  674. S.invert(o, r),
  675. S.mul(i, o, a),
  676. i[12] *= e.modelPartScale,
  677. i[13] *= e.modelPartScale,
  678. i[14] *= e.modelPartScale
  679. } else
  680. S.copy(i, a)
  681. }
  682. ,
  683. c.prototype.isVisibleAtFramePercent = function(e, t) {
  684. for (var i = e, s = 0, n = 0; n < 100; n++) {
  685. if ((s = this.animatedObjects[i]).visibleProperty) {
  686. if (s.visibleProperty.evaluate(t, 1, s),
  687. "" != s.debugString || "" != s.visibleProperty.debugString)
  688. return this.debugString += s.debugString,
  689. this.debugString += s.visibleProperty.debugString,
  690. !1;
  691. if (0 == s.visibleProperty.lastValue)
  692. return !1
  693. }
  694. i == s.parentIndex && (n = 100),
  695. i = s.parentIndex
  696. }
  697. return !0
  698. }
  699. ,
  700. c.prototype.getWorldTransform = function(e, t, i, s, n) {
  701. if ((e = this.animatedObjects[e]).useFixedWorldTransform)
  702. S.copy(i, e.cachedWorldTransform0);
  703. else {
  704. var r = this.getObjectAnimationFramePercent(e, t)
  705. , a = S.identity();
  706. if (e.evaluateLocalTransformAtFramePercent(r, a, !0, n),
  707. r = e.modelPartIndex != e.id) {
  708. r = S.identity();
  709. var o = S.identity();
  710. S.copy(o, a),
  711. this.getAnimatedLocalTransform(e.id, t, r),
  712. S.mul(a, r, o)
  713. }
  714. if (S.copy(i, a),
  715. e.parentIndex != e.id)
  716. for (var h = e.parentIndex, l = 0; l < 100; l++)
  717. e = this.animatedObjects[h],
  718. r = this.getObjectAnimationFramePercent(e, t),
  719. a = S.identity(),
  720. e.evaluateLocalTransformAtFramePercent(r, a, !0, n),
  721. (r = e.modelPartIndex != e.id) ? (r = S.identity(),
  722. this.getAnimatedLocalTransform(e.id, t, r),
  723. o = S.identity(),
  724. S.mul(o, a, i),
  725. S.mul(i, r, o)) : (o = S.identity(),
  726. S.copy(o, i),
  727. S.mul(i, a, o)),
  728. h == e.parentIndex && (l = 100),
  729. h = e.parentIndex;
  730. i[12] *= s,
  731. i[13] *= s,
  732. i[14] *= s
  733. }
  734. }
  735. ,
  736. c.prototype.hasParentInHierarchy = function(e, t) {
  737. for (var i = e.parentIndex, s = 0; s < 100; s++) {
  738. if ((e = this.animatedObjects[i]).id == t)
  739. return !0;
  740. i == e.parentIndex && (s = 100),
  741. i = e.parentIndex
  742. }
  743. return !1
  744. }
  745. ,
  746. c.prototype.hasParentTypeInHierarchy = function(e, t) {
  747. for (var i = e.parentIndex, s = 0; s < 100; s++) {
  748. if ((e = this.animatedObjects[i]).sceneObjectType == t)
  749. return !0;
  750. i == e.parentIndex && (s = 100),
  751. i = e.parentIndex
  752. }
  753. return !1
  754. }
  755. ,
  756. c.prototype.searchAnimationUpHierarchy = function(e) {
  757. for (var t = e.id, i = 0; i < 100; i++) {
  758. if ((e = this.animatedObjects[t]).animatedLocalTransform && (e.hasAnimatedTransform() || e.id != e.modelPartIndex && this.searchAnimationUpHierarchy(this.animatedObjects[e.modelPartIndex])))
  759. return !0;
  760. t == e.parentIndex && (i = 100),
  761. t = e.parentIndex
  762. }
  763. return !1
  764. }
  765. ,
  766. c.prototype.hasAnimationInHierarchy = function(e) {
  767. return !!(this.searchAnimationUpHierarchy(e) || e.id != e.modelPartIndex && this.searchAnimationUpHierarchy(this.animatedObjects[e.modelPartIndex]) || this.hasParentTypeInHierarchy(e, "TurnTableSO") || this.hasParentTypeInHierarchy(e, "CameraSO") || "CameraSO" == e.sceneObjectType)
  768. }
  769. ,
  770. c.prototype.getObjectAnimationFramePercent = function(e, t) {
  771. if (0 == this.totalFrames || 0 == e.animationLength)
  772. return 0;
  773. var i = t / e.animationLength;
  774. i = Math.floor(i);
  775. return (i = (t -= e.animationLength * i) * e.modelPartFPS) >= e.totalFrames + 1 && (i = e.totalFrames),
  776. i
  777. }
  778. ,
  779. h.prototype.get = function(e) {
  780. return this.files[e]
  781. }
  782. ,
  783. h.prototype.extract = function(e) {
  784. var t = this.files[e];
  785. return delete this.files[e],
  786. t
  787. }
  788. ,
  789. h.prototype.checkSignature = function(e) {
  790. if (!e)
  791. return !1;
  792. var t = this.get(e.name + ".sig");
  793. if (!t)
  794. return !1;
  795. if (!(t = JSON.parse(String.fromCharCode.apply(null, t.data))))
  796. return !1;
  797. for (var i = 5381, s = 0; s < e.data.length; ++s)
  798. i = 33 * i + e.data[s] & 4294967295;
  799. return (e = new l()).setBytes([0, 233, 33, 170, 116, 86, 29, 195, 228, 46, 189, 3, 185, 31, 245, 19, 159, 105, 73, 190, 158, 80, 175, 38, 210, 116, 221, 229, 171, 134, 104, 144, 140, 5, 99, 255, 208, 78, 248, 215, 172, 44, 79, 83, 5, 244, 152, 19, 92, 137, 112, 10, 101, 142, 209, 100, 244, 92, 190, 125, 28, 0, 185, 54, 143, 247, 49, 37, 15, 254, 142, 180, 185, 232, 50, 219, 11, 186, 106, 116, 78, 212, 10, 105, 53, 26, 14, 181, 80, 47, 87, 213, 182, 19, 126, 151, 86, 109, 182, 224, 37, 135, 80, 59, 22, 93, 125, 68, 214, 106, 209, 152, 235, 157, 249, 245, 48, 76, 203, 0, 0, 95, 200, 246, 243, 229, 85, 79, 169], !0),
  800. (s = new l()).setBytes(t[0]),
  801. s.powmod(65537, e).toInt32() == i
  802. }
  803. ,
  804. h.prototype.decompress = function(e, t) {
  805. var i = new Uint8Array(t)
  806. , s = 0
  807. , n = new Uint32Array(4096)
  808. , r = new Uint32Array(4096)
  809. , a = 256
  810. , o = e.length
  811. , h = 0
  812. , l = 1
  813. , d = 0
  814. , c = 1;
  815. i[s++] = e[0];
  816. for (var u = 1; !(o <= (c = u + (u >> 1)) + 1); u++) {
  817. d = e[c + 1],
  818. c = e[c];
  819. if ((f = 1 & u ? d << 4 | c >> 4 : (15 & d) << 8 | c) < a)
  820. if (f < 256)
  821. d = s,
  822. c = 1,
  823. i[s++] = f;
  824. else {
  825. d = s,
  826. c = r[f];
  827. for (var f, m = (f = n[f]) + c; f < m; )
  828. i[s++] = i[f++]
  829. }
  830. else {
  831. if (f != a)
  832. break;
  833. for (d = s,
  834. c = l + 1,
  835. m = (f = h) + l; f < m; )
  836. i[s++] = i[f++];
  837. i[s++] = i[h]
  838. }
  839. n[a] = h,
  840. r[a++] = l + 1,
  841. h = d,
  842. l = c,
  843. a = 4096 <= a ? 256 : a
  844. }
  845. return s == t ? i : null
  846. }
  847. ,
  848. l.prototype.setBytes = function(e, t) {
  849. var i = (e.length + 1) / 2 | 0;
  850. if (this.digits = new Uint16Array(i),
  851. t) {
  852. var s = 0;
  853. for (i = e.length - 1; 0 <= i; i -= 2)
  854. this.digits[s++] = e[i] + (0 < i ? 256 * e[i - 1] : 0)
  855. } else
  856. for (s = 0; s < i; ++s)
  857. this.digits[s] = e[2 * s] + 256 * e[2 * s + 1];
  858. this.trim()
  859. }
  860. ,
  861. l.prototype.toInt32 = function() {
  862. var e = 0;
  863. return 0 < this.digits.length && (e = this.digits[0],
  864. 1 < this.digits.length && (e |= this.digits[1] << 16)),
  865. e
  866. }
  867. ,
  868. l.prototype.lessThan = function(e) {
  869. if (this.digits.length == e.digits.length)
  870. for (var t = this.digits.length - 1; 0 <= t; --t) {
  871. var i = this.digits[t]
  872. , s = e.digits[t];
  873. if (i != s)
  874. return i < s
  875. }
  876. return this.digits.length < e.digits.length
  877. }
  878. ,
  879. l.prototype.shiftRight = function() {
  880. for (var e = 0, t = this.digits, i = t.length - 1; 0 <= i; --i) {
  881. var s = t[i];
  882. t[i] = s >> 1 | e << 15,
  883. e = s
  884. }
  885. this.trim()
  886. }
  887. ,
  888. l.prototype.shiftLeft = function(e) {
  889. if (0 < e) {
  890. for (var t = e / 16 | 0, i = 16 - (e %= 16), s = this.digits.length + t + 1, n = new l(s), r = 0; r < s; ++r)
  891. n.digits[r] = 65535 & ((r < t || r >= this.digits.length + t ? 0 : this.digits[r - t]) << e | (r < 1 + t ? 0 : this.digits[r - t - 1]) >>> i);
  892. return n.trim(),
  893. n
  894. }
  895. return new l(this)
  896. }
  897. ,
  898. l.prototype.bitCount = function() {
  899. var e = 0;
  900. if (0 < this.digits.length) {
  901. e = 16 * (this.digits.length - 1);
  902. for (var t = this.digits[this.digits.length - 1]; t; )
  903. t >>>= 1,
  904. ++e
  905. }
  906. return e
  907. }
  908. ,
  909. l.prototype.sub = function(e) {
  910. var t = this.digits
  911. , i = e.digits
  912. , s = this.digits.length;
  913. e = e.digits.length;
  914. for (var n = 0, r = 0; r < s; ++r) {
  915. var a, o = (o = t[r]) + ((n = o < (a = (a = r < e ? i[r] : 0) + n) ? 1 : 0) << 16);
  916. t[r] = o - a & 65535
  917. }
  918. this.trim()
  919. }
  920. ,
  921. l.prototype.mul = function(e) {
  922. for (var t = new l(this.digits.length + e.digits.length), i = t.digits, s = 0; s < this.digits.length; ++s)
  923. for (var n = this.digits[s], r = 0; r < e.digits.length; ++r)
  924. for (var a = n * e.digits[r], o = s + r; a; ) {
  925. var h = (65535 & a) + i[o];
  926. i[o] = 65535 & h,
  927. a >>>= 16,
  928. a += h >>> 16,
  929. ++o
  930. }
  931. return t.trim(),
  932. t
  933. }
  934. ,
  935. l.prototype.mod = function(e) {
  936. if (this.digits.length <= 0 || e.digits.length <= 0)
  937. return new l(0);
  938. var t = new l(this.digits);
  939. if (!this.lessThan(e)) {
  940. for (var i = (i = new l(e.digits)).shiftLeft(t.bitCount() - i.bitCount()); !t.lessThan(e); )
  941. i.lessThan(t) && t.sub(i),
  942. i.shiftRight();
  943. t.trim()
  944. }
  945. return t
  946. }
  947. ,
  948. l.prototype.powmod = function(e, t) {
  949. for (var i = new l([1]), s = this.mod(t); e; )
  950. 1 & e && (i = i.mul(s).mod(t)),
  951. e >>>= 1,
  952. s = s.mul(s).mod(t);
  953. return i
  954. }
  955. ,
  956. l.prototype.trim = function() {
  957. for (var e = this.digits.length; 0 < e && 0 == this.digits[e - 1]; )
  958. --e;
  959. e != this.digits.length && (this.digits = this.digits.subarray(0, e))
  960. }
  961. ,
  962. p.prototype.setBackground3x1 = function(e, t, i, s, n, r, a) {
  963. this.backgroundOffsetX = t,
  964. this.backgroundOffsetY = i,
  965. this.edgePixelsX = a,
  966. this.backgroundLeft = e.addImage(s),
  967. this.backgroundMiddle = e.addImage(n),
  968. this.backgroundRight = e.addImage(r),
  969. this.backgroundLeft.linkedControl.style.zIndex = "0",
  970. this.backgroundMiddle.linkedControl.style.zIndex = "0",
  971. this.backgroundRight.linkedControl.style.zIndex = "0",
  972. this.setOpacity(this.defaultAlpha)
  973. }
  974. ,
  975. p.prototype.setBackground3x3 = function(e, t, i, s, n, r, a, o, h, l, d, c, u, f) {
  976. this.backgroundOffsetX = t,
  977. this.backgroundOffsetY = i,
  978. this.edgePixelsX = u,
  979. this.edgePixelsY = f,
  980. this.backgroundTopLeft = e.addImage(s),
  981. this.backgroundMiddleLeft = e.addImage(a),
  982. this.backgroundBottomLeft = e.addImage(l),
  983. this.backgroundTopMiddle = e.addImage(n),
  984. this.backgroundMiddleMiddle = e.addImage(o),
  985. this.backgroundBottomMiddle = e.addImage(d),
  986. this.backgroundTopRight = e.addImage(r),
  987. this.backgroundMiddleRight = e.addImage(h),
  988. this.backgroundBottomRight = e.addImage(c),
  989. this.backgroundTopLeft.linkedControl.style.zIndex = "0",
  990. this.backgroundTopRight.linkedControl.style.zIndex = "0",
  991. this.backgroundTopMiddle.linkedControl.style.zIndex = "0",
  992. this.backgroundMiddleLeft.linkedControl.style.zIndex = "0",
  993. this.backgroundMiddleRight.linkedControl.style.zIndex = "0",
  994. this.backgroundMiddleMiddle.linkedControl.style.zIndex = "0",
  995. this.backgroundBottomLeft.linkedControl.style.zIndex = "0",
  996. this.backgroundBottomRight.linkedControl.style.zIndex = "0",
  997. this.backgroundBottomMiddle.linkedControl.style.zIndex = "0",
  998. this.setOpacity(this.defaultAlpha)
  999. }
  1000. ,
  1001. p.prototype.alignBackground = function() {
  1002. var e = (n = (s = this.controlRect).guiScreen).left * (1 - s.getScreenXPercent())
  1003. , t = n.bottom * (1 - s.getScreenYPercent())
  1004. , i = n.width * s.getScreenWidthPercent()
  1005. , s = n.height * s.getScreenHeightPercent();
  1006. t += this.backgroundOffsetY,
  1007. e += this.backgroundOffsetX;
  1008. if (this.backgroundTopLeft && this.backgroundTopRight && this.backgroundTopMiddle && this.backgroundMiddleLeft && this.backgroundMiddleRight && this.backgroundMiddleMiddle && this.backgroundBottomLeft && this.backgroundBottomRight && this.backgroundBottomMiddle) {
  1009. var n = i - 2 * this.edgePixelsX
  1010. , r = s - 2 * this.edgePixelsY;
  1011. this.backgroundTopLeft.linkedControl.style.height = this.edgePixelsY + "px",
  1012. this.backgroundTopMiddle.linkedControl.style.height = this.edgePixelsY + "px",
  1013. this.backgroundTopRight.linkedControl.style.height = this.edgePixelsY + "px",
  1014. this.backgroundBottomLeft.linkedControl.style.height = this.edgePixelsY + "px",
  1015. this.backgroundBottomMiddle.linkedControl.style.height = this.edgePixelsY + "px",
  1016. this.backgroundBottomRight.linkedControl.style.height = this.edgePixelsY + "px",
  1017. this.backgroundMiddleLeft.linkedControl.style.height = r + "px",
  1018. this.backgroundMiddleMiddle.linkedControl.style.height = r + "px",
  1019. this.backgroundMiddleRight.linkedControl.style.height = r + "px",
  1020. this.backgroundTopLeft.linkedControl.style.width = this.edgePixelsX + "px",
  1021. this.backgroundBottomLeft.linkedControl.style.width = this.edgePixelsX + "px",
  1022. this.backgroundMiddleLeft.linkedControl.style.width = this.edgePixelsX + "px",
  1023. this.backgroundTopRight.linkedControl.style.width = this.edgePixelsX + "px",
  1024. this.backgroundBottomRight.linkedControl.style.width = this.edgePixelsX + "px",
  1025. this.backgroundMiddleRight.linkedControl.style.width = this.edgePixelsX + "px",
  1026. this.backgroundTopMiddle.linkedControl.style.width = n + "px",
  1027. this.backgroundBottomMiddle.linkedControl.style.width = n + "px",
  1028. this.backgroundMiddleMiddle.linkedControl.style.width = n + "px",
  1029. this.backgroundTopLeft.linkedControl.style.left = e + "px",
  1030. this.backgroundBottomLeft.linkedControl.style.left = e + "px",
  1031. this.backgroundMiddleLeft.linkedControl.style.left = e + "px",
  1032. e += this.edgePixelsX,
  1033. this.backgroundTopMiddle.linkedControl.style.left = e + "px",
  1034. this.backgroundBottomMiddle.linkedControl.style.left = e + "px",
  1035. this.backgroundMiddleMiddle.linkedControl.style.left = e + "px",
  1036. e += n,
  1037. this.backgroundTopRight.linkedControl.style.left = e + "px",
  1038. this.backgroundBottomRight.linkedControl.style.left = e + "px",
  1039. this.backgroundMiddleRight.linkedControl.style.left = e + "px",
  1040. this.backgroundBottomLeft.linkedControl.style.bottom = t + "px",
  1041. this.backgroundBottomMiddle.linkedControl.style.bottom = t + "px",
  1042. this.backgroundBottomRight.linkedControl.style.bottom = t + "px",
  1043. t += this.edgePixelsY,
  1044. this.backgroundMiddleLeft.linkedControl.style.bottom = t + "px",
  1045. this.backgroundMiddleRight.linkedControl.style.bottom = t + "px",
  1046. this.backgroundMiddleMiddle.linkedControl.style.bottom = t + "px",
  1047. t += r,
  1048. this.backgroundTopLeft.linkedControl.style.bottom = t + "px",
  1049. this.backgroundTopMiddle.linkedControl.style.bottom = t + "px",
  1050. this.backgroundTopRight.linkedControl.style.bottom = t + "px"
  1051. }
  1052. this.backgroundLeft && this.backgroundRight && this.backgroundMiddle && (i -= 2 * this.edgePixelsX,
  1053. this.backgroundLeft.linkedControl.style.bottom = t + "px",
  1054. this.backgroundMiddle.linkedControl.style.bottom = t + "px",
  1055. this.backgroundRight.linkedControl.style.bottom = t + "px",
  1056. this.backgroundLeft.linkedControl.style.height = s + "px",
  1057. this.backgroundMiddle.linkedControl.style.height = s + "px",
  1058. this.backgroundRight.linkedControl.style.height = s + "px",
  1059. this.backgroundLeft.linkedControl.style.width = this.edgePixelsX + "px",
  1060. this.backgroundMiddle.linkedControl.style.width = i + "px",
  1061. this.backgroundRight.linkedControl.style.width = this.edgePixelsX + "px",
  1062. this.backgroundLeft.linkedControl.style.left = e + "px",
  1063. e += this.edgePixelsX,
  1064. this.backgroundMiddle.linkedControl.style.left = e + "px",
  1065. this.backgroundRight.linkedControl.style.left = e + i + "px")
  1066. }
  1067. ,
  1068. p.prototype.setOpacity = function(e) {
  1069. this.controlRect.linkedControl.style.opacity = e,
  1070. this.backgroundLeft && (this.backgroundLeft.linkedControl.style.opacity = e),
  1071. this.backgroundRight && (this.backgroundRight.linkedControl.style.opacity = e),
  1072. this.backgroundMiddle && (this.backgroundMiddle.linkedControl.style.opacity = e),
  1073. this.backgroundTopLeft && (this.backgroundTopLeft.linkedControl.style.opacity = e),
  1074. this.backgroundTopRight && (this.backgroundTopRight.linkedControl.style.opacity = e),
  1075. this.backgroundTopMiddle && (this.backgroundTopMiddle.linkedControl.style.opacity = e),
  1076. this.backgroundMiddleLeft && (this.backgroundMiddleLeft.linkedControl.style.opacity = e),
  1077. this.backgroundMiddleRight && (this.backgroundMiddleRight.linkedControl.style.opacity = e),
  1078. this.backgroundMiddleMiddle && (this.backgroundMiddleMiddle.linkedControl.style.opacity = e),
  1079. this.backgroundBottomLeft && (this.backgroundBottomLeft.linkedControl.style.opacity = e),
  1080. this.backgroundBottomRight && (this.backgroundBottomRight.linkedControl.style.opacity = e),
  1081. this.backgroundBottomMiddle && (this.backgroundBottomMiddle.linkedControl.style.opacity = e)
  1082. }
  1083. ,
  1084. p.prototype.setBackgroundVisible = function(e) {
  1085. this.backgroundLeft && this.backgroundLeft.showControl(e),
  1086. this.backgroundRight && this.backgroundRight.showControl(e),
  1087. this.backgroundMiddle && this.backgroundMiddle.showControl(e),
  1088. this.backgroundTopLeft && this.backgroundTopLeft.showControl(e),
  1089. this.backgroundTopRight && this.backgroundTopRight.showControl(e),
  1090. this.backgroundTopMiddle && this.backgroundTopMiddle.showControl(e),
  1091. this.backgroundMiddleLeft && this.backgroundMiddleLeft.showControl(e),
  1092. this.backgroundMiddleRight && this.backgroundMiddleRight.showControl(e),
  1093. this.backgroundMiddleMiddle && this.backgroundMiddleMiddle.showControl(e),
  1094. this.backgroundBottomLeft && this.backgroundBottomLeft.showControl(e),
  1095. this.backgroundBottomRight && this.backgroundBottomRight.showControl(e),
  1096. this.backgroundBottomMiddle && this.backgroundBottomMiddle.showControl(e)
  1097. }
  1098. ,
  1099. p.prototype.setVisible = function(e) {
  1100. this.controlRect.showControl(e),
  1101. this.setBackgroundVisible(e)
  1102. }
  1103. ,
  1104. p.prototype.linkControl = function(e) {
  1105. (this.controlRect.linkedControl = e).onmouseover = function() {
  1106. this.updateAlphas && (this.setOpacity(this.focusAlpha),
  1107. this.controlRect.mouseOver = !0,
  1108. this.linkedBackground && this.linkedBackground.setOpacity(this.focusAlpha))
  1109. }
  1110. .bind(this),
  1111. e.onmouseout = function() {
  1112. this.updateAlphas && (this.setOpacity(this.defaultAlpha),
  1113. this.controlRect.mouseOver = !1,
  1114. this.linkedBackground && this.linkedBackground.setOpacity(this.defaultAlpha))
  1115. }
  1116. .bind(this)
  1117. }
  1118. ,
  1119. u.prototype.empty = function() {
  1120. return this.bytes.length <= 0
  1121. }
  1122. ,
  1123. u.prototype.readCString = function() {
  1124. for (var e = this.bytes, t = e.length, i = 0; i < t; ++i)
  1125. if (0 == e[i])
  1126. return e = String.fromCharCode.apply(null, this.bytes.subarray(0, i)),
  1127. this.bytes = this.bytes.subarray(i + 1),
  1128. e;
  1129. return null
  1130. }
  1131. ,
  1132. u.prototype.asString = function() {
  1133. for (var e = "", t = 0; t < this.bytes.length; ++t)
  1134. e += String.fromCharCode(this.bytes[t]);
  1135. return e
  1136. }
  1137. ,
  1138. u.prototype.readBytes = function(e) {
  1139. var t = this.bytes.subarray(0, e);
  1140. return this.bytes = this.bytes.subarray(e),
  1141. t
  1142. }
  1143. ,
  1144. u.prototype.readUint32 = function() {
  1145. var e = this.bytes
  1146. , t = e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24;
  1147. return this.bytes = e.subarray(4),
  1148. t
  1149. }
  1150. ,
  1151. u.prototype.readUint8 = function() {
  1152. var e = this.bytes
  1153. , t = e[0];
  1154. return this.bytes = e.subarray(1),
  1155. t
  1156. }
  1157. ,
  1158. u.prototype.readUint16 = function() {
  1159. var e = this.bytes
  1160. , t = e[0] | e[1] << 8;
  1161. return this.bytes = e.subarray(2),
  1162. t
  1163. }
  1164. ,
  1165. u.prototype.readFloat32 = function() {
  1166. var e = new Uint8Array(this.bytes);
  1167. e = new Float32Array(e.buffer);
  1168. return this.bytes = this.bytes.subarray(4),
  1169. e[0]
  1170. }
  1171. ,
  1172. u.prototype.seekUint32 = function(e) {
  1173. return (e = this.bytes.subarray(4 * e))[0] | e[1] << 8 | e[2] << 16 | e[3] << 24
  1174. }
  1175. ,
  1176. u.prototype.seekFloat32 = function(e) {
  1177. return e = new Uint8Array(this.bytes.subarray(4 * e)),
  1178. new Float32Array(e.buffer)[0]
  1179. }
  1180. ,
  1181. u.prototype.getMatrix = function(e) {
  1182. return new Float32Array(this.bytes.buffer,64 * e,16)
  1183. }
  1184. ,
  1185. s.prototype.getScreenWidth = function() {
  1186. if (this.linkedControl)
  1187. return this.guiScreen.width * this.getScreenWidthPercent()
  1188. }
  1189. ,
  1190. s.prototype.getScreenHeight = function() {
  1191. if (this.linkedControl)
  1192. return this.guiScreen.height * this.getScreenHeightPercent()
  1193. }
  1194. ,
  1195. s.prototype.updateElement = function() {
  1196. var e = this.linkedControl;
  1197. if (e) {
  1198. var t = this.guiScreen.left * (1 - this.getScreenXPercent())
  1199. , i = this.guiScreen.bottom * (1 - this.getScreenYPercent())
  1200. , s = this.guiScreen.width * this.getScreenWidthPercent()
  1201. , n = this.guiScreen.height * this.getScreenHeightPercent();
  1202. e.style.left = t + "px",
  1203. e.style.bottom = i + "px",
  1204. e.style.width = s + "px",
  1205. e.style.height = n + "px"
  1206. }
  1207. }
  1208. ,
  1209. s.prototype.updateElement = function() {
  1210. var e = this.linkedControl;
  1211. if (e) {
  1212. var t = this.guiScreen.left * (1 - this.getScreenXPercent())
  1213. , i = this.guiScreen.bottom * (1 - this.getScreenYPercent())
  1214. , s = this.guiScreen.width * this.getScreenWidthPercent()
  1215. , n = this.guiScreen.height * this.getScreenHeightPercent();
  1216. e.style.left = t + "px",
  1217. e.style.bottom = i + "px",
  1218. e.style.width = s + "px",
  1219. e.style.height = n + "px"
  1220. }
  1221. }
  1222. ,
  1223. s.prototype.updateChildElements = function() {
  1224. this.updateElement();
  1225. for (var e = 0; e < this.childControlRects.length; e++)
  1226. this.childControlRects[e].updateChildElements()
  1227. }
  1228. ,
  1229. s.prototype.set = function(e, t, i, s) {
  1230. this.xPercent = e,
  1231. this.yPercent = t,
  1232. this.widthPercent = i,
  1233. this.heightPercent = s
  1234. }
  1235. ,
  1236. s.prototype.linkControl = function(e) {
  1237. (this.linkedControl = e).onmouseover = function() {
  1238. this.mouseOver = !0
  1239. }
  1240. .bind(this),
  1241. e.onmouseout = function() {
  1242. this.mouseOver = !1
  1243. }
  1244. .bind(this),
  1245. e.onmousedown = function() {
  1246. this.mouseDown = !0
  1247. }
  1248. .bind(this),
  1249. e.onmouseup = function() {
  1250. this.mouseDown = !1
  1251. }
  1252. .bind(this),
  1253. e.onclick = function() {
  1254. this.callBack && this.callBack(this),
  1255. this.clicked = !0
  1256. }
  1257. .bind(this)
  1258. }
  1259. ,
  1260. s.prototype.showControl = function(e) {
  1261. this.visible = e,
  1262. this.linkedControl && (this.linkedControl.style.display = e ? "block" : "none")
  1263. }
  1264. ,
  1265. s.prototype.setOpacity = function(e) {
  1266. this.opacity = e,
  1267. this.linkedControl && (this.linkedControl.style.opacity = e)
  1268. }
  1269. ,
  1270. s.prototype.hasChildControlRect = function(e) {
  1271. for (var t = 0; t < this.childControlRects.length; t++)
  1272. if (this.childControlRects[t] == e)
  1273. return !0;
  1274. return !1
  1275. }
  1276. ,
  1277. s.prototype.registerChildControlRect = function(e) {
  1278. this.hasChildControlRect(e) || (this.childControlRects.push(e),
  1279. e.parentControlRect = this)
  1280. }
  1281. ,
  1282. s.prototype.getScreenWidthPercent = function() {
  1283. var e = this.widthPercent;
  1284. return this.parentControlRect && (e *= this.parentControlRect.getScreenWidthPercent()),
  1285. e
  1286. }
  1287. ,
  1288. s.prototype.getScreenHeightPercent = function() {
  1289. var e = this.heightPercent;
  1290. return this.parentControlRect && (e *= this.parentControlRect.getScreenHeightPercent()),
  1291. e
  1292. }
  1293. ,
  1294. s.prototype.getScreenXPercent = function() {
  1295. var e = this.xPercent;
  1296. return this.parentControlRect && (e *= this.parentControlRect.getScreenWidthPercent(),
  1297. e += this.parentControlRect.getScreenXPercent()),
  1298. e
  1299. }
  1300. ,
  1301. s.prototype.getScreenYPercent = function() {
  1302. var e = this.yPercent;
  1303. return this.parentControlRect && (e *= this.parentControlRect.getScreenHeightPercent(),
  1304. e += this.parentControlRect.getScreenYPercent()),
  1305. e
  1306. }
  1307. ;
  1308. function n(e, t, i, s) {
  1309. var n = !1
  1310. , r = e + (-1 == e.indexOf("?") ? "?" : "&") + "thumb=1"
  1311. , a = function(e) {
  1312. return (e = new h(e).extract("thumbnail.jpg")) ? N.parseFile(e, t, s) : n ? i && i() : (n = !0,
  1313. C.fetchBinaryIncremental(r, a, i, 394240)),
  1314. 0
  1315. };
  1316. C.fetchBinaryIncremental(r, a, i, 65536)
  1317. }
  1318. function f(e, t) {
  1319. this.desc = t,
  1320. this.gl = e,
  1321. this.iblShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", ["#define FOG_IBL"]);
  1322. var i = ["#define FOG_DIR"];
  1323. this.dirShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1324. i.push("#define FOG_SHADOWS"),
  1325. this.dirShaderShadow = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1326. i = ["#define FOG_SPOT"],
  1327. this.spotShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1328. i.push("#define FOG_SHADOWS"),
  1329. this.spotShaderShadow = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1330. i = ["#define FOG_OMNI"],
  1331. this.omniShaderShadow = this.omniShader = e.shaderCache.fromURLs("fogvert.glsl", "fogfrag.glsl", i),
  1332. this.fullscreenTriangle = e.createBuffer(),
  1333. e.bindBuffer(e.ARRAY_BUFFER, this.fullscreenTriangle),
  1334. i = new Float32Array([0, 0, 2, 0, 0, 2]),
  1335. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  1336. e.bindBuffer(e.ARRAY_BUFFER, null)
  1337. }
  1338. function m(e, t) {
  1339. this.gl = e,
  1340. this.fbo = e.createFramebuffer(),
  1341. e.bindFramebuffer(e.FRAMEBUFFER, this.fbo),
  1342. t && (this.width = t.width,
  1343. this.height = t.height,
  1344. t.color0 && (this.color0 = t.color0,
  1345. e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, this.color0.id, 0),
  1346. this.width = t.color0.desc.width,
  1347. this.height = t.color0.desc.height),
  1348. t.depth ? (this.depth = t.depth,
  1349. e.framebufferTexture2D(e.FRAMEBUFFER, e.DEPTH_ATTACHMENT, e.TEXTURE_2D, this.depth.id, 0)) : (this.depthBuffer = t.depthBuffer,
  1350. t.createDepth && !this.depthBuffer && (this.depthBuffer = m.createDepthBuffer(e, this.width, this.height)),
  1351. this.depthBuffer && (e.bindRenderbuffer(e.RENDERBUFFER, this.depthBuffer),
  1352. e.framebufferRenderbuffer(e.FRAMEBUFFER, e.DEPTH_ATTACHMENT, e.RENDERBUFFER, this.depthBuffer),
  1353. e.bindRenderbuffer(e.RENDERBUFFER, null)))),
  1354. this.valid = t && t.ignoreStatus || e.checkFramebufferStatus(e.FRAMEBUFFER) == e.FRAMEBUFFER_COMPLETE,
  1355. e.bindFramebuffer(e.FRAMEBUFFER, null)
  1356. }
  1357. (I = void 0 === I ? {} : I).embed = function(e, t) {
  1358. var i, s = (t = function(e) {
  1359. if (e = e || {},
  1360. document.location.search)
  1361. for (var t = document.location.search.substring(1).split("&"), i = 0; i < t.length; ++i) {
  1362. var s = t[i].split("=");
  1363. e[s[0]] = s[1]
  1364. }
  1365. return t = function(e) {
  1366. if (0 | e)
  1367. return !0;
  1368. for (var t = "true True TRUE yes Yes YES".split(" "), i = 0; i < t.length; ++i)
  1369. if (e === t[i])
  1370. return !0;
  1371. return !1
  1372. }
  1373. ,
  1374. e.width = e.width || 800,
  1375. e.height = e.height || 600,
  1376. e.autoStart = t(e.autoStart),
  1377. e.pagePreset = t(e.pagePreset),
  1378. e.fullFrame = t(e.fullFrame) || t(e.bare),
  1379. e.fullFrame = !e.pagePreset && e.fullFrame,
  1380. e
  1381. }(t)).thumbnailURL;
  1382. if (t.pagePreset) {
  1383. i = new W(t.width,t.height,e,!!s),
  1384. document.body.style.backgroundColor = "#d7e4da";
  1385. var n = document.createElement("div");
  1386. n.style.position = "relative",
  1387. n.style.backgroundColor = "#e4e7e4",
  1388. n.style.width = t.width + 12 + "px",
  1389. n.style.height = t.height + 6 + 16 + "px",
  1390. n.style.margin = "auto",
  1391. n.style.boxShadow = "3px 5px 12px 0px grey",
  1392. document.body.appendChild(n);
  1393. var r = document.createElement("div");
  1394. if (r.style.position = "relative",
  1395. r.style.left = "6px",
  1396. r.style.top = "6px",
  1397. n.appendChild(r),
  1398. r.appendChild(i.domRoot),
  1399. !i.mobile) {
  1400. n.style.resize = "both",
  1401. n.style.overflow = "hidden";
  1402. var a = [n.style.width, n.style.height]
  1403. , o = function() {
  1404. g.active() ? n.style.resize = "none" : (n.style.resize = "both",
  1405. a[0] == n.style.width && a[1] == n.style.height || (a[0] = n.style.width,
  1406. a[1] = n.style.height,
  1407. i.resize(n.clientWidth - 12, n.clientHeight - 6 - 16))),
  1408. window.setTimeout(o, 100)
  1409. };
  1410. o()
  1411. }
  1412. } else
  1413. i = new W(t.fullFrame ? window.innerWidth : t.width,t.fullFrame ? window.innerHeight : t.height,e,!!s),
  1414. document.body.appendChild(i.domRoot),
  1415. t.fullFrame && (i.domRoot.style.position = "absolute",
  1416. i.domRoot.style.left = i.domRoot.style.top = 0,
  1417. window.addEventListener("resize", function() {
  1418. g.active() || i.resize(this.document.body.clientWidth, this.document.body.clientHeight)
  1419. }));
  1420. return (webview = i).ui.setThumbnailURL(s),
  1421. t.autoStart && i.loadScene(),
  1422. i
  1423. }
  1424. ,
  1425. I.fetchThumbnail = n,
  1426. f.prototype.draw = function(e, t) {
  1427. var i = this.gl
  1428. , s = e.view
  1429. , n = s.projectionMatrix
  1430. , r = S.empty();
  1431. S.mul(r, s.viewMatrix, s.projectionMatrix),
  1432. S.invert(r, s.viewProjectionMatrix),
  1433. r = [n[10] + n[11], -n[14], -2 * n[11]],
  1434. n = [-2 / n[0], -2 / n[5], (1 - n[8]) / n[0], (1 - n[9]) / n[5]],
  1435. i.enable(i.BLEND),
  1436. i.blendFunc(i.ONE, i.ONE_MINUS_SRC_ALPHA);
  1437. for (var a = 0; a < e.lights.count + 1; ++a) {
  1438. var o, h = a - 1, l = h < e.lights.shadowCount;
  1439. (o = 0 == a ? this.iblShader : 0 < e.lights.spot[3 * h] ? l ? this.spotShaderShadow : this.spotShader : 0 < e.lights.getLightPos(h)[3] ? this.omniShader : l ? this.dirShaderShadow : this.dirShader).bind();
  1440. var d = o.params;
  1441. if (i.uniform3fv(d.uDepthToZ, r),
  1442. i.uniform4fv(d.uUnproject, n),
  1443. i.uniformMatrix4fv(d.uInvViewMatrix, !1, s.transform),
  1444. i.uniform1f(d.uFogInvDistance, 1 / this.desc.distance),
  1445. i.uniform1f(d.uFogOpacity, this.desc.opacity * (1 - e.stripData.activeFade())),
  1446. i.uniform1f(d.uFogDispersion, 1 - this.desc.dispersion),
  1447. (u = [0, 0, 0])[this.desc.type] = 1,
  1448. i.uniform3fv(d.uFogType, u),
  1449. i.uniform3fv(d.uFogColor, this.desc.color),
  1450. i.uniform1f(d.uFogIllum, 0 == a ? this.desc.skyIllum : this.desc.lightIllum),
  1451. i.uniformMatrix4fv(d.uLightMatrix, !1, e.lights.invMatrix),
  1452. 0 == a) {
  1453. for (h = new Float32Array(e.sky.diffuseCoefficients),
  1454. l = 4; l < 16; ++l)
  1455. h[l] *= 1 - this.desc.dispersion;
  1456. for (l = 16; l < 36; ++l)
  1457. h[l] *= 1 - this.desc.dispersion * this.desc.dispersion;
  1458. i.uniform4fv(d.uFogLightSphere, h)
  1459. } else {
  1460. var c = e.lights.getLightPos(h)
  1461. , u = (c = S.mul4(V.empty(), e.lights.invMatrix, c[0], c[1], c[2], c[3]),
  1462. e.lights.getLightDir(h));
  1463. u = S.mulVec(V.empty(), e.lights.invMatrix, u[0], u[1], u[2]);
  1464. i.uniform4fv(d.uLightPosition, c),
  1465. i.uniform3fv(d.uLightColor, e.lights.getColor(h));
  1466. c = .01745329251 * e.lights.spot[3 * h];
  1467. var f = Math.cos(.5 * c);
  1468. i.uniform4fv(d.uSpotParams, [-u[0], -u[1], -u[2], 0 < c ? f * f : 0]),
  1469. i.uniform4fv(d.uLightAttenuation, [e.lights.parameters[3 * h + 0], e.lights.parameters[3 * h + 1], e.lights.parameters[3 * h + 2], f]),
  1470. l && (l = S.mul(S.empty(), e.lights.finalTransformBuffer.subarray(16 * h), e.lights.matrix),
  1471. i.uniformMatrix4fv(d.uShadowProj, !1, l),
  1472. e.shadow.depthTextures[h].bind(o.samplers.uShadowMap),
  1473. h = 0,
  1474. 1 < e.postRender.sampleCount && (h = e.postRender.currentSample() / e.postRender.sampleCount),
  1475. i.uniform1f(d.uDitherOffset, h),
  1476. i.uniform3fv(d.uAABBMin, e.bounds.min),
  1477. i.uniform3fv(d.uAABBMax, e.bounds.max),
  1478. h = V.lerp(V.empty(), e.bounds.min, e.bounds.max, .5),
  1479. l = V.distance(h, e.bounds.min),
  1480. i.uniform4f(d.uCylinder, h[0], h[1], h[2], l * l))
  1481. }
  1482. t.bind(o.samplers.tDepth),
  1483. o = o.attribs.vCoord,
  1484. i.bindBuffer(i.ARRAY_BUFFER, this.fullscreenTriangle),
  1485. i.enableVertexAttribArray(o),
  1486. i.vertexAttribPointer(o, 2, i.FLOAT, !1, 0, 0),
  1487. i.drawArrays(i.TRIANGLES, 0, 3),
  1488. i.disableVertexAttribArray(o),
  1489. i.bindBuffer(i.ARRAY_BUFFER, null)
  1490. }
  1491. i.disable(i.BLEND)
  1492. }
  1493. ,
  1494. f.prototype.complete = function() {
  1495. return this.iblShader.complete() && this.dirShader.complete() && this.dirShaderShadow.complete() && this.spotShader.complete() && this.spotShaderShadow.complete() && this.omniShader.complete() && this.omniShaderShadow.complete()
  1496. }
  1497. ,
  1498. m.createDepthBuffer = function(e, t, i) {
  1499. var s = e.createRenderbuffer();
  1500. return e.bindRenderbuffer(e.RENDERBUFFER, s),
  1501. e.renderbufferStorage(e.RENDERBUFFER, e.DEPTH_COMPONENT16, t, i),
  1502. e.bindRenderbuffer(e.RENDERBUFFER, null),
  1503. s
  1504. }
  1505. ,
  1506. m.prototype.bind = function() {
  1507. this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.fbo),
  1508. this.gl.viewport(0, 0, this.width, this.height)
  1509. }
  1510. ,
  1511. m.bindNone = function(e) {
  1512. e.bindFramebuffer(e.FRAMEBUFFER, null)
  1513. }
  1514. ;
  1515. var g = {
  1516. support: function() {
  1517. return !!(document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled)
  1518. },
  1519. begin: function(e, t) {
  1520. var i = e.requestFullscreen || e.webkitRequestFullScreen || e.mozRequestFullScreen || e.msRequestFullscreen;
  1521. if (i) {
  1522. var s = function() {
  1523. g.active() || (document.removeEventListener("fullscreenchange", s),
  1524. document.removeEventListener("webkitfullscreenchange", s),
  1525. document.removeEventListener("mozfullscreenchange", s),
  1526. document.removeEventListener("MSFullscreenChange", s)),
  1527. t && t()
  1528. };
  1529. document.addEventListener("fullscreenchange", s),
  1530. document.addEventListener("webkitfullscreenchange", s),
  1531. document.addEventListener("mozfullscreenchange", s),
  1532. document.addEventListener("MSFullscreenChange", s),
  1533. i.bind(e)()
  1534. }
  1535. },
  1536. end: function() {
  1537. var e = document.exitFullscreen || document.webkitExitFullscreen || document.mozCancelFullScreen || document.msExitFullscreen;
  1538. e && e.bind(document)()
  1539. },
  1540. active: function() {
  1541. return !!(document.fullscreenElement || document.webkitIsFullScreen || document.mozFullScreenElement || document.msFullscreenElement)
  1542. }
  1543. };
  1544. function v(e) {
  1545. this.debugString = "GUIRegion",
  1546. this.name = "Default",
  1547. this.controlRect = new s(e),
  1548. this.yPercent = this.xPercent = 0,
  1549. this.heightPercent = this.widthPercent = 1,
  1550. this.guiScreen = e
  1551. }
  1552. function t(e) {
  1553. this.init = !1,
  1554. this.ui = e,
  1555. this.bottom = this.left = this.height = this.width = 0,
  1556. this.clicked = this.mouseDown = !1,
  1557. this.playbackControls = 0,
  1558. e = 1,
  1559. window.devicePixelRatio && (2 < window.devicePixelRatio ? e = 4 : 1 < window.devicePixelRatio && (e = 2)),
  1560. this.imageSetNumber = e
  1561. }
  1562. function e(e) {
  1563. this.onTap = [],
  1564. this.onSingleTap = [],
  1565. this.onDoubleTap = [],
  1566. this.onDrag = [],
  1567. this.onZoom = [],
  1568. this.onPan = [],
  1569. this.onPan2 = [],
  1570. this.onAnything = [],
  1571. this.mouseDownCount = 0,
  1572. this.macHax = 0 <= navigator.platform.toUpperCase().indexOf("MAC"),
  1573. e && this.attach(e)
  1574. }
  1575. function i(e, t) {
  1576. e && t ? (this.frameIndex = t.frameIndex,
  1577. this.value = t.value,
  1578. this.interpolation = t.interpolation,
  1579. this.weighIn = t.weighIn,
  1580. this.weighOut = t.weighOut) : (this.interpolation = this.value = this.frameIndex = 0,
  1581. this.weighOut = this.weighIn = 1)
  1582. }
  1583. function x(e, t) {
  1584. for (var i in this.rotation = this.shadowCount = this.count = 0,
  1585. this.positions = [],
  1586. this.directions = [],
  1587. this.matrixWeights = [],
  1588. this.matrix = S.identity(),
  1589. this.invMatrix = S.identity(),
  1590. this.defaultmatrix = S.identity(),
  1591. this.defaultviewmatrix = S.identity(),
  1592. e)
  1593. this[i] = e[i];
  1594. this.count = this.positions.length / 4,
  1595. this.count = Math.min(6, this.count),
  1596. this.shadowCount = Math.min(3, this.shadowCount),
  1597. this.positions = new Float32Array(this.positions),
  1598. this.positionBuffer = new Float32Array(this.positions),
  1599. this.directions = new Float32Array(this.directions),
  1600. this.directionBuffer = new Float32Array(this.directions),
  1601. this.colors = new Float32Array(this.colors),
  1602. this.colorsBuffer = new Float32Array(this.colors),
  1603. this.modelViewBuffer = new Float32Array(16 * this.shadowCount),
  1604. this.projectionBuffer = new Float32Array(16 * this.shadowCount),
  1605. this.finalTransformBuffer = new Float32Array(16 * this.shadowCount),
  1606. this.inverseTransformBuffer = new Float32Array(16 * this.shadowCount),
  1607. this.shadowTexelPadProjections = new Float32Array(4 * this.shadowCount),
  1608. this.shadowsNeedUpdate = new Uint8Array(this.shadowCount);
  1609. for (var s = 0; s < this.shadowsNeedUpdate.length; ++s)
  1610. this.shadowsNeedUpdate[s] = 1;
  1611. for (S.rotation(this.matrix, this.rotation, 1),
  1612. S.transpose(this.invMatrix, this.matrix),
  1613. S.copy(this.defaultmatrix, this.matrix),
  1614. S.copy(this.defaultviewmatrix, t.viewMatrix),
  1615. s = 0; s < this.count; ++s) {
  1616. i = this.positions.subarray(4 * s, 4 * s + 4);
  1617. var n = this.directions.subarray(3 * s, 3 * s + 3);
  1618. 1 == this.matrixWeights[s] ? (S.mul4(i, this.matrix, i[0], i[1], i[2], i[3]),
  1619. S.mulVec(n, this.matrix, n[0], n[1], n[2])) : 2 == this.matrixWeights[s] && (S.mul4(i, t.viewMatrix, i[0], i[1], i[2], i[3]),
  1620. S.mulVec(n, t.viewMatrix, n[0], n[1], n[2]))
  1621. }
  1622. }
  1623. function y(e) {
  1624. this.name = "none",
  1625. this.text = "default text",
  1626. this.title = "none",
  1627. this.debugString = this.imagePath = "",
  1628. this.controlRect = new s(e),
  1629. this.textEntries = [],
  1630. this.textOffsetsX = [],
  1631. this.textOffsetsY = [],
  1632. this.buttons = [],
  1633. this.listBoxEntryHeight = 20,
  1634. this.selectedItemText = "",
  1635. this.selectedIndex = -1,
  1636. this.localPixelsY = 0,
  1637. this.localPixelsX = 100,
  1638. this.labelPixelDrop = 0,
  1639. this.labelPixelInset = 10,
  1640. this.labelTextHeight = 16,
  1641. this.closed = !1,
  1642. this.defaultButtonText = this.spacerMiddle = this.spacerRight = this.spacerLeft = this.spacerControl = 0,
  1643. this.listBoxButtons = [],
  1644. this.listBoxRegion = new v(e),
  1645. this.guiScreen = e,
  1646. this.lastMouseOverIndex = -1,
  1647. this.selectionChangedCallback = 0,
  1648. this.debugString = ""
  1649. }
  1650. function b(e, t, i) {
  1651. this.gl = e,
  1652. this.name = i.name;
  1653. var s = {
  1654. mipmap: !0,
  1655. aniso: e.hints.mobile ? 0 : 4,
  1656. clamp: !!i.textureWrapClamp,
  1657. mirror: !!i.textureWrapMirror
  1658. }
  1659. , n = {
  1660. mipmap: s.mipmap,
  1661. clamp: s.clamp,
  1662. mirror: s.mirror,
  1663. nofilter: i.textureFilterNearest || !1
  1664. };
  1665. if (n.nofilter || (n.aniso = e.hints.mobile ? 2 : 4),
  1666. this.textures = {
  1667. albedo: e.textureCache.fromFilesMergeAlpha(t.get(i.albedoTex), t.get(i.alphaTex), n),
  1668. reflectivity: e.textureCache.fromFilesMergeAlpha(t.get(i.reflectivityTex), t.get(i.glossTex), s),
  1669. normal: e.textureCache.fromFile(t.get(i.normalTex), s),
  1670. extras: e.textureCache.fromFilesMergeAlpha(t.get(i.extrasTex), t.get(i.extrasTexA), s)
  1671. },
  1672. this.extrasTexCoordRanges = {},
  1673. i.extrasTexCoordRanges)
  1674. for (var r in i.extrasTexCoordRanges)
  1675. this.extrasTexCoordRanges[r] = new Float32Array(i.extrasTexCoordRanges[r].scaleBias);
  1676. this.textures.extras || ((t = new U(e,{
  1677. width: 1,
  1678. height: 1
  1679. })).loadArray(new Uint8Array([255, 255, 255, 255])),
  1680. this.textures.extras = t);
  1681. var a = i.blendTint || [1, 1, 1];
  1682. t = {
  1683. none: function() {
  1684. e.disable(e.BLEND)
  1685. },
  1686. alpha: function() {
  1687. e.enable(e.BLEND),
  1688. e.blendFuncSeparate(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA, e.ONE_MINUS_DST_ALPHA, e.ONE)
  1689. },
  1690. add: function() {
  1691. e.enable(e.BLEND),
  1692. e.blendColor(a[0], a[1], a[2], 1),
  1693. e.blendFunc(e.ONE, e.CONSTANT_COLOR)
  1694. }
  1695. },
  1696. this.blend = t[i.blend] || t.none,
  1697. this.alphaTest = i.alphaTest || 0,
  1698. this.usesBlending = this.blend !== t.none,
  1699. this.usesRefraction = !!i.refraction,
  1700. this.shadowAlphaTest = this.alphaTest,
  1701. this.shadowAlphaTest <= 0 && this.blend === t.alpha && (this.shadowAlphaTest = .5),
  1702. this.castShadows = this.blend !== t.add,
  1703. this.horizonOcclude = i.horizonOcclude || 0,
  1704. this.fresnel = new Float32Array(i.fresnel ? i.fresnel : [1, 1, 1]),
  1705. this.emissiveIntensity = i.emissiveIntensity || 1,
  1706. n = !(s = []),
  1707. 0 < i.lightCount && s.push("#define LIGHT_COUNT " + i.lightCount),
  1708. 0 < i.shadowCount && (r = Math.min(i.lightCount, i.shadowCount),
  1709. this.usesRefraction && e.limits.textureCount <= 8 && (r = 2 < r ? 2 : r),
  1710. s.push("#define SHADOW_COUNT " + r)),
  1711. 0 < i.alphaTest && s.push("#define ALPHA_TEST"),
  1712. this.blend === t.alpha ? s.push("#define TRANSPARENCY_DITHER") : this.blend === t.none && s.push("#define NOBLEND"),
  1713. e.hints.mobile && s.push("#define MOBILE"),
  1714. e.ext.textureDepth && s.push("#define SHADOW_NATIVE_DEPTH"),
  1715. r = function(e) {
  1716. return 1 / (2 / 3 * 3.1415962 * (e * e + e + 1))
  1717. }
  1718. ,
  1719. i.useSkin && (s.push("#define SKIN"),
  1720. this.skinParams = i.skinParams || {
  1721. subdermisColor: [1, 1, 1],
  1722. transColor: [1, 0, 0, 1],
  1723. fresnelColor: [.2, .2, .2, .5],
  1724. fresnelOcc: 1,
  1725. fresnelGlossMask: 1,
  1726. transSky: .5,
  1727. shadowBlur: .5,
  1728. normalSmooth: .5,
  1729. transScatter: 0,
  1730. transDepth: 0,
  1731. millimeterScale: 1
  1732. },
  1733. this.extrasTexCoordRanges.subdermisTex || s.push("#define SKIN_NO_SUBDERMIS_TEX"),
  1734. this.extrasTexCoordRanges.translucencyTex || s.push("#define SKIN_NO_TRANSLUCENCY_TEX"),
  1735. this.extrasTexCoordRanges.fuzzTex || s.push("#define SKIN_NO_FUZZ_TEX"),
  1736. void 0 === this.skinParams.version && (this.skinParams.version = 1),
  1737. 2 == this.skinParams.version ? (s.push("#define SKIN_VERSION_2"),
  1738. this.skinParams.shadowBlur *= 4,
  1739. this.skinParams.shadowBlur = Math.min(this.skinParams.shadowBlur, 40),
  1740. this.skinParams.transIntegral = r(.5 * this.skinParams.transScatter),
  1741. this.skinParams.fresnelIntegral = 1 / 3.14159 * (1 - .5 * this.skinParams.fresnelColor[3]),
  1742. this.skinParams.transSky = 0) : (s.push("#define SKIN_VERSION_1"),
  1743. this.skinParams.shadowBlur = 8 * Math.min(this.skinParams.shadowBlur, 1),
  1744. this.skinParams.transDepth = 0,
  1745. this.skinParams.transScatter = this.skinParams.transColor[3],
  1746. this.skinParams.transIntegral = 1 / 3.14159 * (1 - .5 * this.skinParams.transScatter),
  1747. this.skinParams.fresnelIntegral = 1 / 3.14159 * (1 - .5 * this.skinParams.fresnelColor[3]),
  1748. this.skinParams.transSky *= 1.25,
  1749. this.skinParams.transIntegral *= 1.25)),
  1750. i.aniso && (s.push("#define ANISO"),
  1751. this.anisoParams = i.anisoParams || {
  1752. strength: 1,
  1753. tangent: [1, 0, 0],
  1754. integral: .5
  1755. },
  1756. this.extrasTexCoordRanges.anisoTex || s.push("#define ANISO_NO_DIR_TEX")),
  1757. i.microfiber && (s.push("#define MICROFIBER"),
  1758. this.microfiberParams = i.microfiberParams || {
  1759. fresnelColor: [.2, .2, .2, .5],
  1760. fresnelOcc: 1,
  1761. fresnelGlossMask: 1
  1762. },
  1763. this.microfiberParams.fresnelIntegral = 1 / 3.14159 * (1 - .5 * this.microfiberParams.fresnelColor[3]),
  1764. this.extrasTexCoordRanges.fuzzTex || s.push("#define MICROFIBER_NO_FUZZ_TEX")),
  1765. i.refraction && (s.push("#define REFRACTION"),
  1766. this.refractionParams = i.refractionParams || {
  1767. distantBackground: !1,
  1768. tint: [1, 1, 1],
  1769. useAlbedoTint: !1,
  1770. IOR: 1.5
  1771. },
  1772. this.extrasTexCoordRanges.refractionMaskTex || s.push("#define REFRACTION_NO_MASK_TEX")),
  1773. i.vertexColor && (s.push("#define VERTEX_COLOR"),
  1774. i.vertexColorsRGB && s.push("#define VERTEX_COLOR_SRGB"),
  1775. i.vertexColorAlpha && s.push("#define VERTEX_COLOR_ALPHA")),
  1776. this.horizonSmoothing = i.horizonSmoothing || 0,
  1777. 0 < this.horizonSmoothing && s.push("#define HORIZON_SMOOTHING"),
  1778. i.unlitDiffuse && s.push("#define DIFFUSE_UNLIT"),
  1779. this.extrasTexCoordRanges.emissiveTex && (s.push("#define EMISSIVE"),
  1780. i.emissiveSecondaryUV && (s.push("#define EMISSIVE_SECONDARY_UV"),
  1781. n = !0)),
  1782. this.extrasTexCoordRanges.aoTex && (s.push("#define AMBIENT_OCCLUSION"),
  1783. i.aoSecondaryUV && (s.push("#define AMBIENT_OCCLUSION_SECONDARY_UV"),
  1784. n = !0)),
  1785. i.tangentOrthogonalize && s.push("#define TSPACE_ORTHOGONALIZE"),
  1786. i.tangentNormalize && s.push("#define TSPACE_RENORMALIZE"),
  1787. i.tangentGenerateBitangent && s.push("#define TSPACE_COMPUTE_BITANGENT"),
  1788. n && s.push("#define TEXCOORD_SECONDARY"),
  1789. this.vOffset = this.uOffset = 0,
  1790. s.push("#define UV_OFFSET "),
  1791. this.shader = e.shaderCache.fromURLs("matvert.glsl", "matfrag.glsl", s),
  1792. s.push("#define STRIPVIEW"),
  1793. this.stripShader = e.shaderCache.fromURLs("matvert.glsl", "matfrag.glsl", s),
  1794. this.wireShader = e.shaderCache.fromURLs("wirevert.glsl", "wirefrag.glsl"),
  1795. this.blend === t.alpha && (this.prepassShader = e.shaderCache.fromURLs("alphaprepassvert.glsl", "alphaprepassfrag.glsl"))
  1796. }
  1797. v.prototype.addImageElement = function(e, t) {
  1798. var i = this.guiScreen.ui.menuCluster.contents
  1799. , s = document.createElement("input");
  1800. e.linkControl(s),
  1801. this.guiScreen.updateElement(e),
  1802. s.type = "image",
  1803. s.src = I.dataLocale + t,
  1804. s.style.position = "absolute",
  1805. s.style.border = "none",
  1806. s.style.outline = "0px",
  1807. s.style.zIndex = "1",
  1808. s.title = t,
  1809. s.style.opacity = e.opacity;
  1810. var n = new XMLHttpRequest();
  1811. return n.open("HEAD", s.src, !0),
  1812. n.onload = function(e) {
  1813. e.appendChild(this)
  1814. }
  1815. .bind(s, i),
  1816. n.send(),
  1817. s
  1818. }
  1819. ,
  1820. v.prototype.addImage = function(e) {
  1821. var t = new s(this.guiScreen);
  1822. return this.addImageElement(t, e),
  1823. t
  1824. }
  1825. ,
  1826. v.prototype.addTextButton = function(e, t, i, s, n, r) {
  1827. var a = new p(this.guiScreen);
  1828. return a.name = "none",
  1829. a.text = e,
  1830. a.controlRect.set(t, i, s, n),
  1831. a.controlRect.opacity = r,
  1832. this.controlRect.registerChildControlRect(a.controlRect),
  1833. t = this.guiScreen.ui.menuCluster.contents,
  1834. (i = document.createElement("text")).style.color = "white",
  1835. i.style.fontFamily = "Arial",
  1836. i.style.fontSize = I.largeUI ? "14px" : "12px",
  1837. i.style.textShadow = "2px 2px 3px #000000",
  1838. t.appendChild(i),
  1839. a.controlRect.linkControl(i),
  1840. this.guiScreen.updateElement(a.controlRect),
  1841. i.type = "text",
  1842. i.name = "text",
  1843. i.style.position = "absolute",
  1844. i.style.border = "none",
  1845. i.style.outline = "0px",
  1846. i.style.zIndex = "2",
  1847. i.innerHTML = e,
  1848. i.style.opacity = a.controlRect.opacity,
  1849. a.linkControl(i),
  1850. a
  1851. }
  1852. ,
  1853. t.prototype.setSize = function(e, t) {
  1854. this.width = e,
  1855. this.height = t,
  1856. this.left = -e,
  1857. this.bottom = -t,
  1858. this.playbackControls && this.playbackControls.resize(this)
  1859. }
  1860. ,
  1861. t.prototype.setupActiveView = function(e) {
  1862. this.init || (this.init = !0,
  1863. (this.ui = e).viewer.scene.sceneAnimator && (this.playbackControls = new R(this),
  1864. this.playbackControls.resize(this)))
  1865. }
  1866. ,
  1867. t.prototype.updateElement = function(e) {
  1868. var t = e.linkedControl;
  1869. if (t) {
  1870. var i = this.left * (1 - e.getScreenXPercent())
  1871. , s = this.bottom * (1 - e.getScreenYPercent())
  1872. , n = this.width * e.getScreenWidthPercent();
  1873. e = this.height * e.getScreenHeightPercent(),
  1874. t.style.left = i + "px",
  1875. t.style.bottom = s + "px",
  1876. t.style.width = n + "px",
  1877. t.style.height = e + "px"
  1878. }
  1879. }
  1880. ,
  1881. e.prototype.attach = function(e) {
  1882. this.element = e;
  1883. var m = function(e) {
  1884. for (var t = 0; t < this.onAnything.length; ++t)
  1885. this.onAnything[t]();
  1886. e.preventDefault()
  1887. }
  1888. .bind(this);
  1889. this.mouseStates = [{
  1890. pressed: !1,
  1891. position: [0, 0],
  1892. downPosition: [0, 0]
  1893. }, {
  1894. pressed: !1,
  1895. position: [0, 0],
  1896. downPosition: [0, 0]
  1897. }, {
  1898. pressed: !1,
  1899. position: [0, 0],
  1900. downPosition: [0, 0]
  1901. }],
  1902. this.lastTapPos = [0, 0],
  1903. e = function(e) {
  1904. if (e.target === this.element) {
  1905. this.mouseDownCount++;
  1906. var t = this.mouseStates[e.button];
  1907. if (t) {
  1908. t.pressed = !0;
  1909. var i = this.element.getBoundingClientRect();
  1910. t.position[0] = t.downPosition[0] = e.clientX - i.left,
  1911. t.position[1] = t.downPosition[1] = e.clientY - i.top,
  1912. m(e)
  1913. }
  1914. }
  1915. }
  1916. .bind(this),
  1917. this.element.addEventListener("mousedown", e),
  1918. e = function(e) {
  1919. var t = this.mouseStates[e.button];
  1920. if (t) {
  1921. var i = this.element.getBoundingClientRect()
  1922. , s = e.clientX - i.left;
  1923. i = e.clientY - i.top;
  1924. if (t.pressed = !1,
  1925. t.position[0] = s,
  1926. t.position[1] = i,
  1927. 0 == e.button && e.target == this.element && Math.abs(t.position[0] - t.downPosition[0]) + Math.abs(t.position[1] - t.downPosition[1]) < 10) {
  1928. for (var n = 0; n < this.onTap.length; ++n)
  1929. this.onTap[n](s, i);
  1930. if (this.needSingleClick = !0,
  1931. window.setTimeout(function(e, t) {
  1932. if (this.needSingleClick) {
  1933. for (var i = 0; i < this.onSingleTap.length; ++i)
  1934. this.onSingleTap[i](e, t);
  1935. this.needSingleClick = !1
  1936. }
  1937. }
  1938. .bind(this, s, i), 301),
  1939. t = !1,
  1940. void 0 !== this.doubleClickTimer && (n = Math.abs(s - this.lastTapPos[0]) + Math.abs(i - this.lastTapPos[1]) < 8,
  1941. Date.now() - this.doubleClickTimer < 300 && n))
  1942. for (t = !0,
  1943. this.needSingleClick = !1,
  1944. n = 0; n < this.onDoubleTap.length; ++n)
  1945. this.onDoubleTap[n](s, i);
  1946. this.doubleClickTimer = Date.now(),
  1947. t && (this.doubleClickTimer = -1e9),
  1948. this.lastTapPos[0] = s,
  1949. this.lastTapPos[1] = i
  1950. }
  1951. }
  1952. m(e)
  1953. }
  1954. .bind(this),
  1955. this.element.addEventListener("mouseup", e),
  1956. e = function(e) {
  1957. for (var t = !1, i = this.element.getBoundingClientRect(), s = 0; s < 3; ++s) {
  1958. var n = this.mouseStates[s];
  1959. if (n.pressed) {
  1960. webview.stopRotate();
  1961. t = e.clientX - i.left;
  1962. var r = e.clientY - i.top
  1963. , a = t - n.position[0]
  1964. , o = r - n.position[1];
  1965. if (n.position[0] = t,
  1966. n.position[1] = r,
  1967. 2 == s && e.altKey)
  1968. for (n = 0; n < this.onZoom.length; ++n)
  1969. this.onZoom[n](2 * o);
  1970. else if (1 <= s || e.ctrlKey)
  1971. for (n = 0; n < this.onPan.length; ++n)
  1972. this.onPan[n](a, o);
  1973. else if (0 == s)
  1974. if (e.shiftKey)
  1975. for (n = 0; n < this.onPan2.length; ++n)
  1976. this.onPan2[n](a, o);
  1977. else
  1978. for (n = 0; n < this.onDrag.length; ++n)
  1979. this.onDrag[n](t, r, a, o);
  1980. t = !0
  1981. }
  1982. }
  1983. t && m(e)
  1984. }
  1985. .bind(this),
  1986. this.element.addEventListener("mousemove", e),
  1987. e = function(e) {
  1988. var t = 0;
  1989. e.deltaY ? (t = -.4 * e.deltaY,
  1990. 1 == e.deltaMode ? t *= 16 : 2 == e.deltaMode && (t *= this.element.clientHeight)) : e.wheelDelta ? t = this.macHax && 120 == Math.abs(e.wheelDelta) ? .08 * e.wheelDelta : .4 * e.wheelDelta : e.detail && (t = -10 * e.detail);
  1991. for (var i = 0; i < this.onZoom.length; ++i)
  1992. this.onZoom[i](t);
  1993. m(e)
  1994. }
  1995. .bind(this),
  1996. this.element.addEventListener("mousewheel", e),
  1997. this.element.addEventListener("DOMMouseScroll", e),
  1998. this.element.addEventListener("wheel", e),
  1999. e = function(e) {
  2000. for (var t = 0; t < this.mouseStates.length; ++t)
  2001. this.mouseStates[t].pressed = !1;
  2002. e.preventDefault()
  2003. }
  2004. .bind(this),
  2005. this.element.addEventListener("mouseleave", e),
  2006. this.element.addEventListener("contextmenu", function(e) {
  2007. e.preventDefault()
  2008. }),
  2009. this.touches = {},
  2010. this.tapPossible = !1,
  2011. this.touchCountFloor = 0,
  2012. e = function(e) {
  2013. for (var t = this.element.getBoundingClientRect(), i = !1, s = 0; s < e.changedTouches.length; ++s)
  2014. if (e.target === this.element) {
  2015. var n = e.changedTouches[s];
  2016. (i = {
  2017. x: n.clientX - t.left,
  2018. y: n.clientY - t.top
  2019. }).startX = i.x,
  2020. i.startY = i.y,
  2021. this.touches[n.identifier] = i,
  2022. i = !0
  2023. }
  2024. for (this.tapPossible = 1 == e.touches.length,
  2025. n = t = 0; n < this.touches.length; ++n)
  2026. t++;
  2027. t > this.touchCountFloor && (this.touchCountFloor = t),
  2028. i && m(e)
  2029. }
  2030. .bind(this),
  2031. this.element.addEventListener("touchstart", e),
  2032. e = function(e) {
  2033. for (var t = !1, i = 0; i < e.changedTouches.length; ++i) {
  2034. var s = e.changedTouches[i]
  2035. , n = this.touches[s.identifier];
  2036. if (n) {
  2037. if (this.tapPossible) {
  2038. var r = this.element.getBoundingClientRect();
  2039. t = s.clientX - r.left,
  2040. r = s.clientY - r.top;
  2041. if (Math.max(Math.abs(t - n.startX), Math.abs(r - n.startY)) < 24) {
  2042. for (i = 0; i < this.onTap.length; ++i)
  2043. this.onTap[i](t, r);
  2044. if (this.needSingleTap = !0,
  2045. window.setTimeout(function(e, t) {
  2046. if (this.needSingleTap) {
  2047. for (var i = 0; i < this.onSingleTap.length; ++i)
  2048. this.onSingleTap[i](e, t);
  2049. this.needSingleTap = !1
  2050. }
  2051. }
  2052. .bind(this, t, r), 501),
  2053. n = !1,
  2054. void 0 !== this.doubleTapTimer) {
  2055. var a = Math.max(Math.abs(t - this.lastTapPos[0]), Math.abs(r - this.lastTapPos[1])) < 24
  2056. , o = Date.now() - this.doubleTapTimer < 500;
  2057. if (a && o)
  2058. for (n = !0,
  2059. i = 0; i < this.onDoubleTap.length; ++i)
  2060. this.onDoubleTap[i](t, r)
  2061. }
  2062. this.doubleTapTimer = Date.now(),
  2063. n && (this.doubleTapTimer = -1e9),
  2064. this.lastTapPos[0] = t,
  2065. this.lastTapPos[1] = r
  2066. }
  2067. this.tapPossible = !1
  2068. }
  2069. delete this.touches[s.identifier],
  2070. t = !0
  2071. }
  2072. }
  2073. for (s = i = 0; s < this.touches.length; ++s)
  2074. i++;
  2075. i <= 0 && (this.touchCountFloor = 0),
  2076. t && m(e)
  2077. }
  2078. .bind(this),
  2079. this.element.addEventListener("touchend", e),
  2080. this.element.addEventListener("touchcancel", e),
  2081. this.element.addEventListener("touchleave", e),
  2082. e = function(e) {
  2083. webview.stopRotate();
  2084. for (var t = [], i = 0; i < e.touches.length; ++i)
  2085. e.touches[i].target === this.element && t.push(e.touches[i]);
  2086. var s = this.element.getBoundingClientRect();
  2087. if (1 == t.length && this.touchCountFloor <= 1) {
  2088. var n = t[0]
  2089. , r = this.touches[n.identifier];
  2090. if (r) {
  2091. var a = n.clientX - s.left
  2092. , o = (n = n.clientY - s.top,
  2093. s = a - r.x,
  2094. n - r.y);
  2095. for (r.x = a,
  2096. r.y = n,
  2097. i = 0; i < this.onDrag.length; ++i)
  2098. this.onDrag[i](a, n, s, o, e.shiftKey)
  2099. }
  2100. } else if (2 == t.length && this.touchCountFloor <= 2) {
  2101. if (o = t[0],
  2102. i = this.touches[o.identifier],
  2103. n = t[1],
  2104. r = this.touches[n.identifier],
  2105. i && r) {
  2106. a = o.clientX - s.left,
  2107. o = o.clientY - s.top;
  2108. var h = n.clientX - s.left
  2109. , l = n.clientY - s.top
  2110. , d = Math.sqrt((a - h) * (a - h) + (o - l) * (o - l))
  2111. , c = Math.sqrt((i.x - r.x) * (i.x - r.x) + (i.y - r.y) * (i.y - r.y))
  2112. , u = Math.abs(d - c)
  2113. , f = (s = (a - i.x + h - r.x) / 2,
  2114. n = (o - i.y + l - r.y) / 2,
  2115. Math.sqrt(s * s + n * n));
  2116. if (i.x = a,
  2117. i.y = o,
  2118. r.x = h,
  2119. r.y = l,
  2120. 0 < u)
  2121. for (r = u / (u + f),
  2122. i = 0; i < this.onZoom.length; ++i)
  2123. this.onZoom[i](2 * (d - c) * r);
  2124. if (0 < f)
  2125. for (r = f / (u + f),
  2126. i = 0; i < this.onDrag.length; ++i)
  2127. this.onPan[i](s * r, n * r)
  2128. }
  2129. } else if (3 <= t.length) {
  2130. for (i = c = d = h = o = 0; i < t.length; ++i)
  2131. n = t[i],
  2132. r = this.touches[n.identifier],
  2133. d += a = n.clientX - s.left,
  2134. c += n = n.clientY - s.top,
  2135. r && (o += r.x,
  2136. h += r.y,
  2137. r.x = a,
  2138. r.y = n);
  2139. for (o /= t.length,
  2140. h /= t.length,
  2141. d /= t.length,
  2142. c /= t.length,
  2143. i = 0; i < this.onPan2.length; ++i)
  2144. this.onPan2[i](d - o, c - h)
  2145. }
  2146. 0 < t.length && m(e)
  2147. }
  2148. .bind(this),
  2149. this.element.addEventListener("touchmove", e)
  2150. }
  2151. ,
  2152. x.prototype.getLightPos = function(e) {
  2153. return this.positionBuffer.subarray(4 * e, 4 * e + 4)
  2154. }
  2155. ,
  2156. x.prototype.setLightDistance = function(e, t) {
  2157. t <= 0 && (t = 1e-5),
  2158. this.parameters[3 * e + 2] = 1 / t
  2159. }
  2160. ,
  2161. x.prototype.setLightSpotAngle = function(e, t) {
  2162. t <= 0 && (t = 1e-6),
  2163. this.spot[3 * e] = t;
  2164. var i = Math.sin(3.1415926 / 180 * t / 2);
  2165. this.spot[3 * e + 2] = 1 / (i * i) * this.spot[3 * e + 1]
  2166. }
  2167. ,
  2168. x.prototype.setLightSpotSharpness = function(e, t) {
  2169. this.spot[3 * e + 1] = t,
  2170. this.setLightSpotAngle(this.spot[3 * e])
  2171. }
  2172. ,
  2173. x.prototype.setLightPos = function(e, t) {
  2174. this.positions[4 * e + 0] = t[0],
  2175. this.positions[4 * e + 1] = t[1],
  2176. this.positions[4 * e + 2] = t[2];
  2177. var i = this.positions.subarray(4 * e, 4 * e + 4);
  2178. 1 == this.matrixWeights[e] ? S.mul4(i, this.defaultmatrix, t[0], t[1], t[2], i[3]) : 2 == this.matrixWeights[e] && S.mul4(i, this.defaultviewmatrix, t[0], t[1], t[2], i[3])
  2179. }
  2180. ,
  2181. x.prototype.setLightDir = function(e, t) {
  2182. this.directions[3 * e + 0] = t[0],
  2183. this.directions[3 * e + 1] = t[1],
  2184. this.directions[3 * e + 2] = t[2];
  2185. var i = this.directions.subarray(3 * e, 3 * e + 3);
  2186. 1 == this.matrixWeights[e] ? S.mulVec(i, this.defaultmatrix, t[0], t[1], t[2]) : 2 == this.matrixWeights[e] && S.mulVec(i, this.defaultviewmatrix, t[0], t[1], t[2])
  2187. }
  2188. ,
  2189. x.prototype.getLightColor = function(e) {
  2190. return this.colors.subarray(3 * e, 3 * e + 3)
  2191. }
  2192. ,
  2193. x.prototype.setLightColor = function(e, t) {
  2194. this.colors[3 * e + 0] = t[0],
  2195. this.colors[3 * e + 1] = t[1],
  2196. this.colors[3 * e + 2] = t[2]
  2197. }
  2198. ,
  2199. x.prototype.getLightDir = function(e) {
  2200. return this.directionBuffer.subarray(3 * e, 3 * e + 3)
  2201. }
  2202. ,
  2203. x.prototype.getColor = function(e) {
  2204. return e *= 3,
  2205. [this.colors[e], this.colors[e + 1], this.colors[e + 2]]
  2206. }
  2207. ,
  2208. x.prototype.update = function(e, t) {
  2209. var i = new S.type(this.matrix);
  2210. S.rotation(this.matrix, this.rotation, 1),
  2211. S.transpose(this.invMatrix, this.matrix);
  2212. for (var s = 0; s < this.count; ++s) {
  2213. var n = this.positions.subarray(4 * s, 4 * s + 4)
  2214. , r = this.directions.subarray(3 * s, 3 * s + 3)
  2215. , a = this.getLightPos(s)
  2216. , o = this.getLightDir(s);
  2217. 1 == this.matrixWeights[s] ? (a[0] = n[0],
  2218. a[1] = n[1],
  2219. a[2] = n[2],
  2220. a[3] = n[3],
  2221. o[0] = r[0],
  2222. o[1] = r[1],
  2223. o[2] = r[2]) : 2 == this.matrixWeights[s] ? (S.mul4(a, e.transform, n[0], n[1], n[2], n[3]),
  2224. S.mulVec(o, e.transform, r[0], r[1], r[2]),
  2225. S.mul4(a, this.matrix, a[0], a[1], a[2], a[3]),
  2226. S.mulVec(o, this.matrix, o[0], o[1], o[2])) : (S.mul4(a, this.matrix, n[0], n[1], n[2], n[3]),
  2227. S.mulVec(o, this.matrix, r[0], r[1], r[2])),
  2228. V.normalize(o, o)
  2229. }
  2230. r = new Float32Array(this.finalTransformBuffer),
  2231. a = S.empty(),
  2232. o = S.empty();
  2233. var h = S.empty()
  2234. , l = V.empty()
  2235. , d = V.empty()
  2236. , c = V.empty()
  2237. , u = V.empty()
  2238. , f = (n = V.empty(),
  2239. [])
  2240. , m = []
  2241. , p = S.create(.5, 0, 0, .5, 0, .5, 0, .5, 0, 0, .5, .5, 0, 0, 0, 1);
  2242. for (s = 0; s < this.count; ++s) {
  2243. for (l = this.getLightPos(s),
  2244. d = this.getLightDir(s),
  2245. .99 < Math.abs(d[1]) ? V.set(c, 1, 0, 0) : V.set(c, 0, 1, 0),
  2246. V.cross(u, c, d),
  2247. V.normalize(u, u),
  2248. V.cross(c, d, u),
  2249. V.normalize(c, c),
  2250. S.set(a, u[0], u[1], u[2], -V.dot(u, l), c[0], c[1], c[2], -V.dot(c, l), d[0], d[1], d[2], -V.dot(d, l), 0, 0, 0, 1),
  2251. l = 0; l < 8; ++l)
  2252. n[0] = 1 & l ? t.max[0] : t.min[0],
  2253. n[1] = 2 & l ? t.max[1] : t.min[1],
  2254. n[2] = 4 & l ? t.max[2] : t.min[2],
  2255. S.mulPoint(n, this.matrix, 1.005 * n[0], 1.005 * n[1], 1.005 * n[2]),
  2256. S.mulPoint(n, a, n[0], n[1], n[2]),
  2257. 0 == l ? (f[0] = m[0] = n[0],
  2258. f[1] = m[1] = n[1],
  2259. f[2] = m[2] = n[2]) : (f[0] = Math.min(f[0], n[0]),
  2260. f[1] = Math.min(f[1], n[1]),
  2261. f[2] = Math.min(f[2], n[2]),
  2262. m[0] = Math.max(m[0], n[0]),
  2263. m[1] = Math.max(m[1], n[1]),
  2264. m[2] = Math.max(m[2], n[2]));
  2265. l = -f[2],
  2266. d = -m[2];
  2267. var g = this.spot[3 * s];
  2268. 0 < g ? (l = Math.min(l, 1 / this.parameters[3 * s + 2]),
  2269. d = Math.max(.04 * l, d),
  2270. S.perspective(o, g, 1, d, l),
  2271. s < this.shadowCount && (l = 2 * -Math.tan(.00872664625 * g),
  2272. this.shadowTexelPadProjections[4 * s + 0] = this.modelViewBuffer[16 * s + 2] * l,
  2273. this.shadowTexelPadProjections[4 * s + 1] = this.modelViewBuffer[16 * s + 6] * l,
  2274. this.shadowTexelPadProjections[4 * s + 2] = this.modelViewBuffer[16 * s + 10] * l,
  2275. this.shadowTexelPadProjections[4 * s + 3] = this.modelViewBuffer[16 * s + 14] * l)) : (S.ortho(o, f[0], m[0], f[1], m[1], d, l),
  2276. s < this.shadowCount && (this.shadowTexelPadProjections[4 * s + 0] = this.shadowTexelPadProjections[4 * s + 1] = this.shadowTexelPadProjections[4 * s + 2] = 0,
  2277. this.shadowTexelPadProjections[4 * s + 3] = Math.max(m[0] - f[0], m[1] - f[1]))),
  2278. S.mul(h, o, a),
  2279. S.mul(h, p, h),
  2280. S.copyToBuffer(this.modelViewBuffer, 16 * s, a),
  2281. S.copyToBuffer(this.projectionBuffer, 16 * s, o),
  2282. S.copyToBuffer(this.finalTransformBuffer, 16 * s, h),
  2283. S.invert(h, h),
  2284. S.copyToBuffer(this.inverseTransformBuffer, 16 * s, h)
  2285. }
  2286. for (n = !1,
  2287. s = 0; s < i.length; ++s)
  2288. if (i[s] != this.matrix[s]) {
  2289. n = !0;
  2290. break
  2291. }
  2292. for (s = 0; s < this.shadowCount; s++)
  2293. if (n && 1 == this.matrixWeights[s])
  2294. this.shadowsNeedUpdate[s] = 1;
  2295. else
  2296. for (i = 16 * s; i < 16 * s + 16; ++i)
  2297. if (r[i] != this.finalTransformBuffer[i]) {
  2298. this.shadowsNeedUpdate[s] = 1;
  2299. break
  2300. }
  2301. }
  2302. ,
  2303. x.prototype.flagUpdateAnimatedLighting = function() {
  2304. for (var e = 0; e < this.shadowCount; e++)
  2305. this.shadowsNeedUpdate[e] = 1
  2306. }
  2307. ,
  2308. y.prototype.linkControl = function(e) {
  2309. this.controlRect.linkControl(e)
  2310. }
  2311. ,
  2312. y.prototype.spawnControl = function(e, t, i, s, n, r) {
  2313. var a = "backgroundTopLE" + (w = this.guiScreen.imageSetNumber) + "x.png"
  2314. , o = "backgroundTopM" + w + "x.png"
  2315. , h = "backgroundTopRE" + w + "x.png"
  2316. , l = "backgroundMiddleLE" + w + "x.png"
  2317. , d = "backgroundMiddleM" + w + "x.png"
  2318. , c = "backgroundMiddleRE" + w + "x.png"
  2319. , u = "backgroundBottomLE" + w + "x.png"
  2320. , f = "backgroundBottomM" + w + "x.png"
  2321. , m = "backgroundBottomRE" + w + "x.png"
  2322. , p = 3 * w
  2323. , g = "backgroundLE" + w + "x.png"
  2324. , v = "backgroundM" + w + "x.png"
  2325. , x = "backgroundRE" + w + "x.png"
  2326. , y = 2 * w
  2327. , b = "spacerLE" + w + "x.png"
  2328. , S = "spacerM" + w + "x.png"
  2329. , T = "spacerRE" + w + "x.png"
  2330. , w = 2 * w
  2331. , C = this.controlRect.guiScreen.width
  2332. , R = this.controlRect.guiScreen.height;
  2333. if (n) {
  2334. n = this.textEntries.length;
  2335. var A = i;
  2336. for (i = 0; i < n; i++) {
  2337. var k = 8 * (this.textEntries[i] ? this.textEntries[i].length : 0);
  2338. A < k && (A = k)
  2339. }
  2340. i = A + r
  2341. }
  2342. for (r = 1 / (n = this.textEntries.length + 1),
  2343. this.localPixelsX = i,
  2344. this.listBoxEntryHeight = s,
  2345. this.localPixelsY = (this.textEntries.length + 1) * this.listBoxEntryHeight,
  2346. i = 8 / this.localPixelsY,
  2347. s = 6 / this.localPixelsX,
  2348. A = 4 / this.localPixelsX,
  2349. k = r - i / 4,
  2350. this.labelTextHeight = I.largeUI ? 20 : 16,
  2351. this.labelPixelDrop = (this.listBoxEntryHeight - this.labelTextHeight) / 2,
  2352. this.listBoxRegion.controlRect.widthPercent = this.localPixelsX / C,
  2353. this.listBoxRegion.controlRect.heightPercent = this.localPixelsY / R,
  2354. this.listBoxRegion.controlRect.xPercent = e / C,
  2355. this.listBoxRegion.controlRect.yPercent = t / R,
  2356. this.openBackground = this.listBoxRegion.addTextButton("", 0, 0, 1, 1 + i, 1),
  2357. this.openBackground.setBackground3x3(this.listBoxRegion, 0, 0, a, o, h, l, d, c, u, f, m, p, p),
  2358. this.closedBackground = this.listBoxRegion.addTextButton("", 0, 0, 1, r, 1),
  2359. this.closedBackground.setBackground3x1(this.listBoxRegion, 0, 0, g, v, x, y),
  2360. e = this.labelPixelInset + this.textOffsetsX[0],
  2361. t = this.labelPixelDrop + this.textOffsetsY[0],
  2362. t /= this.localPixelsY,
  2363. e /= this.localPixelsX,
  2364. this.defaultButton = this.listBoxRegion.addTextButton("Selected", e, -t, 1, r, .5),
  2365. this.selectedIndex = 0,
  2366. this.defaultButton.controlRect.linkedControl.innerHTML = this.textEntries[this.selectedIndex],
  2367. this.defaultButton.linkedBackground = this.closedBackground,
  2368. this.spacerControl = this.listBoxRegion.addTextButton("", s, k, 1 - (s + A), i, 1),
  2369. this.spacerControl.defaultAlpha = 1,
  2370. this.spacerControl.setBackground3x1(this.listBoxRegion, 0, 0, b, S, T, w),
  2371. this.spacerControl.setVisible(!1),
  2372. this.spacerControl.linkedBackground = this.openBackground,
  2373. i = 1; i < n; i++)
  2374. e = this.labelPixelInset + this.textOffsetsX[i - 1],
  2375. t = this.labelPixelDrop + this.textOffsetsY[i - 1] - 4,
  2376. e /= this.localPixelsX,
  2377. t /= this.localPixelsY,
  2378. b = this.listBoxRegion.addTextButton(this.textEntries[i - 1], e, r * i - t, 1 - e, r, .5),
  2379. this.listBoxButtons.push(b),
  2380. b.linkedBackground = this.openBackground;
  2381. this.showList(!1),
  2382. this.setupCallbacks()
  2383. }
  2384. ,
  2385. y.prototype.setControl = function(e, t, i, s, n, r) {
  2386. var a = this.controlRect.guiScreen.width
  2387. , o = this.controlRect.guiScreen.height;
  2388. if (n) {
  2389. n = this.textEntries.length;
  2390. for (var h = 0; h < n; h++) {
  2391. var l = 8 * (this.textEntries[h] ? this.textEntries[h].length : 0);
  2392. i < l && (i = l)
  2393. }
  2394. i += r
  2395. }
  2396. this.localPixelsX = i,
  2397. this.listBoxEntryHeight = s,
  2398. this.localPixelsY = (this.textEntries.length + 1) * this.listBoxEntryHeight,
  2399. this.listBoxRegion.controlRect.widthPercent = this.localPixelsX / a,
  2400. this.listBoxRegion.controlRect.heightPercent = this.localPixelsY / o,
  2401. this.listBoxRegion.controlRect.xPercent = e / a,
  2402. this.listBoxRegion.controlRect.yPercent = t / o,
  2403. this.listBoxRegion.controlRect.updateChildElements(),
  2404. this.spacerControl.alignBackground(),
  2405. this.openBackground.alignBackground(),
  2406. this.closedBackground.alignBackground()
  2407. }
  2408. ,
  2409. y.prototype.addItem = function(e, t, i) {
  2410. this.textEntries.push(e),
  2411. this.textOffsetsX.push(t),
  2412. this.textOffsetsY.push(i)
  2413. }
  2414. ,
  2415. y.prototype.showList = function(e) {
  2416. for (var t = this.listBoxButtons.length, i = 0; i < t; i++)
  2417. this.listBoxButtons[i].setVisible(e);
  2418. this.closed = !e,
  2419. this.spacerControl && this.spacerControl.setVisible(e),
  2420. this.openBackground && this.openBackground.setVisible(e),
  2421. this.closedBackground && this.closedBackground.setVisible(!e),
  2422. e ? (this.defaultButton.linkedBackground = this.openBackground,
  2423. this.openBackground.setOpacity(1),
  2424. this.closedBackground.setOpacity(.5)) : this.defaultButton.linkedBackground = this.closedBackground
  2425. }
  2426. ,
  2427. y.prototype.selectItem = function(e) {
  2428. this.selectedItemText = this.textEntries[e],
  2429. this.selectedIndex = e,
  2430. this.defaultButton.controlRect.linkedControl.innerHTML = this.textEntries[this.selectedIndex],
  2431. e = (this.labelTextHeight - this.listBoxEntryHeight + 3) / this.localPixelsY,
  2432. this.defaultButton.controlRect.xPercent = (this.labelPixelInset + this.textOffsetsX[this.selectedIndex]) / this.localPixelsX,
  2433. this.defaultButton.controlRect.yPercent = e,
  2434. this.defaultButton.controlRect.updateElement()
  2435. }
  2436. ,
  2437. y.prototype.setupCallbacks = function() {
  2438. var e = function(e) {
  2439. if (this.closed) {
  2440. var t = (t = this.closedBackground.controlRect.linkedControl).getBoundingClientRect()
  2441. , i = e.clientX - t.left;
  2442. e = e.clientY - t.top,
  2443. i /= t.width,
  2444. t = e / t.height,
  2445. 0 <= i && i <= 1 && 0 <= t && t <= 1 ? this.closedBackground.setOpacity(1) : this.closedBackground.setOpacity(.5)
  2446. } else
  2447. t = (t = this.openBackground.controlRect.linkedControl).getBoundingClientRect(),
  2448. i = e.clientX - t.left,
  2449. e = e.clientY - t.top,
  2450. i /= t.width,
  2451. t = e / t.height,
  2452. 0 <= i && i <= 1 && 0 <= t && t <= 1 ? this.openBackground.setOpacity(1) : this.openBackground.setOpacity(.5)
  2453. }
  2454. .bind(this);
  2455. this.defaultButton.controlRect.linkedControl.onclick = function() {
  2456. this.closed ? this.showList(!0) : (this.showList(this.closed),
  2457. this.closedBackground.setOpacity(1),
  2458. this.defaultButton.setOpacity(1))
  2459. }
  2460. .bind(this);
  2461. for (var t = function(e) {
  2462. this.selectItem(e.id),
  2463. this.showList(!1),
  2464. this.defaultButton.setOpacity(.5),
  2465. this.selectionChangedCallback && this.selectionChangedCallback(this)
  2466. }
  2467. .bind(this), i = function(e) {
  2468. e = this.listBoxButtons.length;
  2469. for (var t = 0; t < e; t++)
  2470. this.listBoxButtons[t].controlRect.mouseOver && (this.selectItem(t),
  2471. t = e,
  2472. this.selectionChangedCallback && this.selectionChangedCallback(this));
  2473. this.showList(!1)
  2474. }
  2475. .bind(this), s = this.listBoxButtons.length, n = 0; n < s; n++)
  2476. this.listBoxButtons[n].controlRect.callBack = t,
  2477. this.listBoxButtons[n].controlRect.id = n,
  2478. this.listBoxButtons[n].controlRect.linkedControl.addEventListener("mousemove", e);
  2479. this.guiScreen.ui.viewer.input.element.addEventListener("mousemove", e),
  2480. this.openBackground.controlRect.linkedControl.addEventListener("mousemove", e),
  2481. this.closedBackground.controlRect.linkedControl.addEventListener("mousemove", e),
  2482. this.guiScreen.ui.viewer.input.element.addEventListener("mousedown", i)
  2483. }
  2484. ,
  2485. b.prototype.bind = function(e, t) {
  2486. if (!this.complete())
  2487. return !1;
  2488. var i, s = e.view, n = e.lights, r = e.sky, a = e.shadow, o = e.stripData.active() ? this.stripShader : this.shader, h = this.skinParams, l = this.anisoParams, d = this.microfiberParams, c = this.gl, u = o.params, f = this.textures, m = o.samplers;
  2489. o.bind(),
  2490. this.blend();
  2491. var p = t.mesh.displayMatrix
  2492. , g = S.mul(S.empty(), s.viewMatrix, p)
  2493. , v = S.mul(S.empty(), s.projectionMatrix, s.viewMatrix);
  2494. g = S.mul(S.empty(), s.projectionMatrix, g),
  2495. p = S.mul(S.empty(), n.matrix, p);
  2496. return c.uniformMatrix4fv(u.uModelViewProjectionMatrix, !1, g),
  2497. c.uniformMatrix4fv(u.uSkyMatrix, !1, p),
  2498. p = S.mulPoint(V.empty(), n.matrix, s.transform[12], s.transform[13], s.transform[14]),
  2499. c.uniform3f(u.uCameraPosition, p[0], p[1], p[2]),
  2500. c.uniform3fv(u.uFresnel, this.fresnel),
  2501. c.uniform1f(u.uAlphaTest, this.alphaTest),
  2502. c.uniform1f(u.uHorizonOcclude, this.horizonOcclude),
  2503. c.uniform1f(u.uHorizonSmoothing, this.horizonSmoothing),
  2504. c.uniform4fv(u.uDiffuseCoefficients, r.diffuseCoefficients),
  2505. 0 < n.count && (c.uniform4fv(u.uLightPositions, n.positionBuffer),
  2506. c.uniform3fv(u.uLightDirections, n.directionBuffer),
  2507. c.uniform3fv(u.uLightColors, n.colors),
  2508. c.uniform3fv(u.uLightParams, n.parameters),
  2509. c.uniform3fv(u.uLightSpot, n.spot),
  2510. p = .392699 * e.postRender.currentSample(),
  2511. c.uniform2f(u.uShadowKernelRotation, .5 * Math.cos(p), .5 * Math.sin(p)),
  2512. 0 < n.shadowCount && (p = a.depthTextures[0].desc.width,
  2513. c.uniform2f(u.uShadowMapSize, p, 1 / p),
  2514. c.uniformMatrix4fv(u.uShadowMatrices, !1, n.finalTransformBuffer),
  2515. c.uniformMatrix4fv(u.uInvShadowMatrices, !1, n.inverseTransformBuffer),
  2516. c.uniform4fv(u.uShadowTexelPadProjections, n.shadowTexelPadProjections),
  2517. a.bindDepthTexture(m.tDepth0, 0),
  2518. a.bindDepthTexture(m.tDepth1, 1),
  2519. a.bindDepthTexture(m.tDepth2, 2))),
  2520. h && (c.uniform3fv(u.uSubdermisColor, h.subdermisColor),
  2521. c.uniform4fv(u.uTransColor, h.transColor),
  2522. c.uniform1f(u.uTransScatter, h.transScatter),
  2523. c.uniform4fv(u.uFresnelColor, h.fresnelColor),
  2524. c.uniform1f(u.uFresnelOcc, h.fresnelOcc),
  2525. c.uniform1f(u.uFresnelGlossMask, h.fresnelGlossMask),
  2526. c.uniform1f(u.uFresnelIntegral, h.fresnelIntegral),
  2527. c.uniform1f(u.uTransIntegral, h.transIntegral),
  2528. c.uniform1f(u.uSkinTransDepth, h.transDepth),
  2529. c.uniform1f(u.uTransSky, h.transSky),
  2530. c.uniform1f(u.uSkinShadowBlur, h.shadowBlur),
  2531. c.uniform1f(u.uNormalSmooth, h.normalSmooth),
  2532. (i = this.extrasTexCoordRanges.subdermisTex) && c.uniform4fv(u.uTexRangeSubdermis, i),
  2533. (i = this.extrasTexCoordRanges.translucencyTex) && c.uniform4fv(u.uTexRangeTranslucency, i),
  2534. (i = this.extrasTexCoordRanges.fuzzTex) && c.uniform4fv(u.uTexRangeFuzz, i)),
  2535. d && (c.uniform4fv(u.uFresnelColor, d.fresnelColor),
  2536. c.uniform1f(u.uFresnelOcc, d.fresnelOcc),
  2537. c.uniform1f(u.uFresnelGlossMask, d.fresnelGlossMask),
  2538. c.uniform1f(u.uFresnelIntegral, d.fresnelIntegral),
  2539. (i = this.extrasTexCoordRanges.fuzzTex) && c.uniform4fv(u.uTexRangeFuzz, i)),
  2540. l && (c.uniform3fv(u.uAnisoTangent, l.tangent),
  2541. c.uniform1f(u.uAnisoStrength, l.strength),
  2542. c.uniform1f(u.uAnisoIntegral, l.integral),
  2543. (i = this.extrasTexCoordRanges.anisoTex) && c.uniform4fv(u.uTexRangeAniso, i)),
  2544. this.usesRefraction && (e.refractionSurface && e.refractionSurface.bind(m.tRefraction),
  2545. n = S.mul(S.empty(), v, n.invMatrix),
  2546. c.uniformMatrix4fv(u.uRefractionViewProjection, !1, n),
  2547. c.uniform1f(u.uRefractionRayDistance, this.refractionParams.distantBackground ? 1e10 : 4 * t.mesh.bounds.maxExtent),
  2548. c.uniform3fv(u.uRefractionTint, this.refractionParams.tint),
  2549. c.uniform1f(u.uRefractionAlbedoTint, this.refractionParams.useAlbedoTint ? 1 : 0),
  2550. c.uniform1f(u.uRefractionIOREntry, 1 / this.refractionParams.IOR),
  2551. (i = this.extrasTexCoordRanges.refractionMaskTex) && c.uniform4fv(u.uTexRangeRefraction, i)),
  2552. (i = this.extrasTexCoordRanges.emissiveTex) && (c.uniform4fv(u.uTexRangeEmissive, i),
  2553. c.uniform1f(u.uEmissiveScale, this.emissiveIntensity)),
  2554. (i = this.extrasTexCoordRanges.aoTex) && c.uniform4fv(u.uTexRangeAO, i),
  2555. f.albedo.bind(m.tAlbedo),
  2556. f.reflectivity.bind(m.tReflectivity),
  2557. f.normal.bind(m.tNormal),
  2558. f.extras.bind(m.tExtras),
  2559. r.specularTexture.bind(m.tSkySpecular),
  2560. o === this.stripShader && (c.uniform1fv(u.uStrips, e.stripData.strips),
  2561. c.uniform2f(u.uStripRes, 2 / s.size[0], 2 / s.size[1])),
  2562. c.uniform2f(u.uUVOffset, this.uOffset, this.vOffset),
  2563. !0
  2564. }
  2565. ,
  2566. b.prototype.bindAlphaPrepass = function(e, t) {
  2567. if (!this.complete() || !this.prepassShader)
  2568. return !1;
  2569. var i = this.gl
  2570. , s = this.prepassShader.params
  2571. , n = this.prepassShader.samplers;
  2572. this.prepassShader.bind();
  2573. var r = S.mul(S.empty(), e.view.viewMatrix, t.mesh.displayMatrix);
  2574. r = S.mul(S.empty(), e.view.projectionMatrix, r);
  2575. return i.uniformMatrix4fv(s.uModelViewProjectionMatrix, !1, r),
  2576. i.uniform2f(s.uUVOffset, this.uOffset, this.vOffset),
  2577. this.textures.albedo.bind(n.tAlbedo),
  2578. !0
  2579. }
  2580. ,
  2581. b.prototype.bindWire = function(e, t) {
  2582. if (!this.complete())
  2583. return !1;
  2584. var i = this.gl
  2585. , s = this.wireShader.params
  2586. , n = e.view;
  2587. i.enable(i.BLEND),
  2588. i.blendFunc(i.SRC_ALPHA, i.ONE_MINUS_SRC_ALPHA),
  2589. i.depthMask(!1),
  2590. this.wireShader.bind();
  2591. var r = S.mul(S.empty(), e.view.viewMatrix, t.mesh.displayMatrix);
  2592. r = S.mul(S.empty(), e.view.projectionMatrix, r);
  2593. return i.uniformMatrix4fv(s.uModelViewProjectionMatrix, !1, r),
  2594. i.uniform4f(s.uStripParams, 2 / n.size[0], 2 / n.size[1], e.stripData.strips[3], e.stripData.strips[4]),
  2595. !0
  2596. }
  2597. ,
  2598. b.prototype.complete = function() {
  2599. return this.wireShader.complete() && this.shader.complete() && this.stripShader.complete() && (!this.prepassShader || this.prepassShader.complete()) && (!this.refractionShader || this.refractionShader.complete()) && this.textures.albedo.complete() && this.textures.reflectivity.complete() && this.textures.normal.complete()
  2600. }
  2601. ;
  2602. var S = {
  2603. type: Float32Array,
  2604. create: function(e, t, i, s, n, r, a, o, h, l, d, c, u, f, m, p) {
  2605. var g = new S.type(16);
  2606. return g[0] = e,
  2607. g[4] = t,
  2608. g[8] = i,
  2609. g[12] = s,
  2610. g[1] = n,
  2611. g[5] = r,
  2612. g[9] = a,
  2613. g[13] = o,
  2614. g[2] = h,
  2615. g[6] = l,
  2616. g[10] = d,
  2617. g[14] = c,
  2618. g[3] = u,
  2619. g[7] = f,
  2620. g[11] = m,
  2621. g[15] = p,
  2622. g
  2623. },
  2624. empty: function() {
  2625. return new S.type(16)
  2626. },
  2627. identity: function() {
  2628. var e = new S.type(16);
  2629. return e[0] = 1,
  2630. e[4] = 0,
  2631. e[8] = 0,
  2632. e[12] = 0,
  2633. e[1] = 0,
  2634. e[5] = 1,
  2635. e[9] = 0,
  2636. e[13] = 0,
  2637. e[2] = 0,
  2638. e[6] = 0,
  2639. e[10] = 1,
  2640. e[14] = 0,
  2641. e[3] = 0,
  2642. e[7] = 0,
  2643. e[11] = 0,
  2644. e[15] = 1,
  2645. e
  2646. },
  2647. set: function(e, t, i, s, n, r, a, o, h, l, d, c, u, f, m, p, g) {
  2648. e[0] = t,
  2649. e[4] = i,
  2650. e[8] = s,
  2651. e[12] = n,
  2652. e[1] = r,
  2653. e[5] = a,
  2654. e[9] = o,
  2655. e[13] = h,
  2656. e[2] = l,
  2657. e[6] = d,
  2658. e[10] = c,
  2659. e[14] = u,
  2660. e[3] = f,
  2661. e[7] = m,
  2662. e[11] = p,
  2663. e[15] = g
  2664. },
  2665. translation: function(e, t, i, s) {
  2666. return S.set(e, 1, 0, 0, t, 0, 1, 0, i, 0, 0, 1, s, 0, 0, 0, 1),
  2667. e
  2668. },
  2669. rotation: function(e, t, i) {
  2670. e[0] = 1,
  2671. e[4] = 0,
  2672. e[8] = 0,
  2673. e[12] = 0,
  2674. e[1] = 0,
  2675. e[5] = 1,
  2676. e[9] = 0,
  2677. e[13] = 0,
  2678. e[2] = 0,
  2679. e[6] = 0,
  2680. e[10] = 1,
  2681. e[14] = 0,
  2682. e[3] = 0,
  2683. e[7] = 0,
  2684. e[11] = 0,
  2685. e[15] = 1;
  2686. var s = .0174532925 * t;
  2687. switch (t = Math.sin(s),
  2688. s = Math.cos(s),
  2689. i) {
  2690. case 0:
  2691. e[5] = s,
  2692. e[9] = -t,
  2693. e[6] = t,
  2694. e[10] = s;
  2695. break;
  2696. case 1:
  2697. e[0] = s,
  2698. e[8] = t,
  2699. e[2] = -t,
  2700. e[10] = s;
  2701. break;
  2702. case 2:
  2703. e[0] = s,
  2704. e[4] = -t,
  2705. e[1] = t,
  2706. e[5] = s
  2707. }
  2708. return e
  2709. },
  2710. mul: function(e, t, i) {
  2711. var s = t[0]
  2712. , n = t[1]
  2713. , r = t[2]
  2714. , a = t[3]
  2715. , o = t[4]
  2716. , h = t[5]
  2717. , l = t[6]
  2718. , d = t[7]
  2719. , c = t[8]
  2720. , u = t[9]
  2721. , f = t[10]
  2722. , m = t[11]
  2723. , p = t[12]
  2724. , g = t[13]
  2725. , v = t[14];
  2726. t = t[15];
  2727. var x = i[0]
  2728. , y = i[1]
  2729. , b = i[2]
  2730. , S = i[3];
  2731. return e[0] = x * s + y * o + b * c + S * p,
  2732. e[1] = x * n + y * h + b * u + S * g,
  2733. e[2] = x * r + y * l + b * f + S * v,
  2734. e[3] = x * a + y * d + b * m + S * t,
  2735. x = i[4],
  2736. y = i[5],
  2737. b = i[6],
  2738. S = i[7],
  2739. e[4] = x * s + y * o + b * c + S * p,
  2740. e[5] = x * n + y * h + b * u + S * g,
  2741. e[6] = x * r + y * l + b * f + S * v,
  2742. e[7] = x * a + y * d + b * m + S * t,
  2743. x = i[8],
  2744. y = i[9],
  2745. b = i[10],
  2746. S = i[11],
  2747. e[8] = x * s + y * o + b * c + S * p,
  2748. e[9] = x * n + y * h + b * u + S * g,
  2749. e[10] = x * r + y * l + b * f + S * v,
  2750. e[11] = x * a + y * d + b * m + S * t,
  2751. x = i[12],
  2752. y = i[13],
  2753. b = i[14],
  2754. S = i[15],
  2755. e[12] = x * s + y * o + b * c + S * p,
  2756. e[13] = x * n + y * h + b * u + S * g,
  2757. e[14] = x * r + y * l + b * f + S * v,
  2758. e[15] = x * a + y * d + b * m + S * t,
  2759. e
  2760. },
  2761. invert: function(e, t) {
  2762. var i = t[0]
  2763. , s = t[1]
  2764. , n = t[2]
  2765. , r = t[3]
  2766. , a = t[4]
  2767. , o = t[5]
  2768. , h = t[6]
  2769. , l = t[7]
  2770. , d = t[8]
  2771. , c = t[9]
  2772. , u = t[10]
  2773. , f = t[11]
  2774. , m = t[12]
  2775. , p = t[13]
  2776. , g = t[14]
  2777. , v = t[15]
  2778. , x = i * o - s * a
  2779. , y = i * h - n * a
  2780. , b = i * l - r * a
  2781. , S = s * h - n * o
  2782. , T = s * l - r * o
  2783. , w = n * l - r * h
  2784. , C = d * p - c * m
  2785. , R = d * g - u * m
  2786. , A = d * v - f * m
  2787. , k = c * g - u * p
  2788. , I = c * v - f * p
  2789. , P = u * v - f * g
  2790. , F = x * P - y * I + b * k + S * A - T * R + w * C;
  2791. return F ? (F = 1 / F,
  2792. e[0] = (o * P - h * I + l * k) * F,
  2793. e[1] = (n * I - s * P - r * k) * F,
  2794. e[2] = (p * w - g * T + v * S) * F,
  2795. e[3] = (u * T - c * w - f * S) * F,
  2796. e[4] = (h * A - a * P - l * R) * F,
  2797. e[5] = (i * P - n * A + r * R) * F,
  2798. e[6] = (g * b - m * w - v * y) * F,
  2799. e[7] = (d * w - u * b + f * y) * F,
  2800. e[8] = (a * I - o * A + l * C) * F,
  2801. e[9] = (s * A - i * I - r * C) * F,
  2802. e[10] = (m * T - p * b + v * x) * F,
  2803. e[11] = (c * b - d * T - f * x) * F,
  2804. e[12] = (o * R - a * k - h * C) * F,
  2805. e[13] = (i * k - s * R + n * C) * F,
  2806. e[14] = (p * y - m * S - g * x) * F,
  2807. e[15] = (d * S - c * y + u * x) * F,
  2808. e) : null
  2809. },
  2810. transpose: function(e, t) {
  2811. return e[0] = t[0],
  2812. e[4] = t[1],
  2813. e[8] = t[2],
  2814. e[12] = t[3],
  2815. e[1] = t[4],
  2816. e[5] = t[5],
  2817. e[9] = t[6],
  2818. e[13] = t[7],
  2819. e[2] = t[8],
  2820. e[6] = t[9],
  2821. e[10] = t[10],
  2822. e[14] = t[11],
  2823. e[3] = t[12],
  2824. e[7] = t[13],
  2825. e[11] = t[14],
  2826. e[15] = t[15],
  2827. e
  2828. },
  2829. mul4: function(e, t, i, s, n, r) {
  2830. return e[0] = t[0] * i + t[4] * s + t[8] * n + t[12] * r,
  2831. e[1] = t[1] * i + t[5] * s + t[9] * n + t[13] * r,
  2832. e[2] = t[2] * i + t[6] * s + t[10] * n + t[14] * r,
  2833. e[3] = t[3] * i + t[7] * s + t[11] * n + t[15] * r,
  2834. e
  2835. },
  2836. mulPoint: function(e, t, i, s, n) {
  2837. return e[0] = t[0] * i + t[4] * s + t[8] * n + t[12],
  2838. e[1] = t[1] * i + t[5] * s + t[9] * n + t[13],
  2839. e[2] = t[2] * i + t[6] * s + t[10] * n + t[14],
  2840. e
  2841. },
  2842. mulVec: function(e, t, i, s, n) {
  2843. return e[0] = t[0] * i + t[4] * s + t[8] * n,
  2844. e[1] = t[1] * i + t[5] * s + t[9] * n,
  2845. e[2] = t[2] * i + t[6] * s + t[10] * n,
  2846. e
  2847. },
  2848. perspective: function(e, t, i, s, n, r) {
  2849. return r = r || 0,
  2850. t = 1 / Math.tan(.00872664625 * t),
  2851. e[0] = t / i,
  2852. e[1] = e[2] = e[3] = 0,
  2853. e[5] = t,
  2854. e[4] = e[6] = e[7] = 0,
  2855. e[8] = e[9] = 0,
  2856. e[10] = (n + s) / (s - n) - 30518044e-12 * r,
  2857. e[11] = -1,
  2858. e[14] = 2 * n * s / (s - n),
  2859. e[12] = e[13] = e[15] = 0,
  2860. e
  2861. },
  2862. perspectiveInfinite: function(e, t, i, s, n) {
  2863. return n = n || 0,
  2864. t = 1 / Math.tan(.00872664625 * t),
  2865. e[0] = t / i,
  2866. e[1] = e[2] = e[3] = 0,
  2867. e[5] = t,
  2868. e[4] = e[6] = e[7] = 0,
  2869. e[8] = e[9] = 0,
  2870. e[10] = e[11] = -1 - 30518044e-12 * n,
  2871. e[14] = -2 * s,
  2872. e[12] = e[13] = e[15] = 0,
  2873. e
  2874. },
  2875. ortho: function(e, t, i, s, n, r, a, o) {
  2876. var h = 1 / (i - t)
  2877. , l = 1 / (n - s)
  2878. , d = 1 / (a - r);
  2879. return e[0] = h + h,
  2880. e[1] = e[2] = e[3] = 0,
  2881. e[5] = l + l,
  2882. e[4] = e[6] = e[7] = 0,
  2883. e[12] = -(i + t) * h,
  2884. e[13] = -(n + s) * l,
  2885. e[10] = -(d + d) - 30518044e-12 * (o || 0),
  2886. e[14] = -(a + r) * d,
  2887. e[8] = e[9] = e[11] = 0,
  2888. e[15] = 1,
  2889. e
  2890. },
  2891. lookAt: function(e, t, i, s) {
  2892. var n = e.subarray(0, 3)
  2893. , r = e.subarray(4, 7)
  2894. , a = e.subarray(8, 11);
  2895. V.sub(a, t, i),
  2896. V.cross(n, s, a),
  2897. V.normalize(a, a),
  2898. V.normalize(n, n),
  2899. V.cross(r, a, n),
  2900. S.set(e, n[0], n[1], n[2], -V.dot(n, t), r[0], r[1], r[2], -V.dot(r, t), a[0], a[1], a[2], -V.dot(a, t), 0, 0, 0, 1)
  2901. },
  2902. copy: function(e, t) {
  2903. for (var i = 0; i < 16; ++i)
  2904. e[i] = t[i]
  2905. },
  2906. copyToBuffer: function(e, t, i) {
  2907. for (var s = 0; s < 16; ++s)
  2908. e[t + s] = i[s]
  2909. }
  2910. };
  2911. function T(e, t, i) {
  2912. this.gl = e;
  2913. var s = (this.desc = t).isDynamicMesh;
  2914. this.numSubMeshes = this.dynamicVertexData = 0,
  2915. this.displayMatrix = S.identity(),
  2916. this.name = t.name,
  2917. this.modelMatrix = S.identity(),
  2918. this.origin = t.transform ? V.create(t.transform[12], t.transform[13], t.transform[14], 1) : V.create(0, 5, 0, 1),
  2919. this.stride = 32,
  2920. (this.vertexColor = t.vertexColor) && (this.stride += 4),
  2921. (this.secondaryTexCoord = t.secondaryTexCoord) && (this.stride += 8),
  2922. i = new u(i.data),
  2923. this.indexCount = t.indexCount,
  2924. this.indexTypeSize = t.indexTypeSize,
  2925. this.indexType = 4 == this.indexTypeSize ? e.UNSIGNED_INT : e.UNSIGNED_SHORT,
  2926. this.indexBuffer = e.createBuffer(),
  2927. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
  2928. var n = i.readBytes(this.indexCount * this.indexTypeSize);
  2929. e.bufferData(e.ELEMENT_ARRAY_BUFFER, n, e.STATIC_DRAW),
  2930. this.wireCount = t.wireCount,
  2931. this.wireBuffer = e.createBuffer(),
  2932. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.wireBuffer),
  2933. n = i.readBytes(this.wireCount * this.indexTypeSize),
  2934. e.bufferData(e.ELEMENT_ARRAY_BUFFER, n, e.STATIC_DRAW),
  2935. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null),
  2936. this.vertexCount = t.vertexCount,
  2937. this.vertexBuffer = e.createBuffer(),
  2938. e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer),
  2939. i = i.readBytes(this.vertexCount * this.stride),
  2940. s ? (this.dynamicVertexData = new Uint8Array(i),
  2941. e.bufferData(e.ARRAY_BUFFER, i, e.DYNAMIC_DRAW)) : e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  2942. e.bindBuffer(e.ARRAY_BUFFER, null),
  2943. this.bounds = void 0 === t.minBound || void 0 === t.maxBound ? {
  2944. min: V.create(-10, -10, -10, 1),
  2945. max: V.create(10, 10, -0, 1)
  2946. } : {
  2947. min: V.create(t.minBound[0], t.minBound[1], t.minBound[2], 1),
  2948. max: V.create(t.maxBound[0], t.maxBound[1], t.maxBound[2], 1)
  2949. },
  2950. this.bounds.maxExtent = Math.max(Math.max(t.maxBound[0] - t.minBound[0], t.maxBound[1] - t.minBound[1]), t.maxBound[2] - t.minBound[2]),
  2951. this.bounds.averageExtent = (t.maxBound[0] - t.minBound[0] + (t.maxBound[1] - t.minBound[1]) + (t.maxBound[2] - t.minBound[2])) / 3
  2952. }
  2953. function w(e, t, i) {
  2954. this.mesh = e,
  2955. this.gl = this.mesh.gl,
  2956. this.indexOffset = t.firstIndex * e.indexTypeSize,
  2957. this.indexCount = t.indexCount,
  2958. this.wireIndexOffset = t.firstWireIndex * e.indexTypeSize,
  2959. this.wireIndexCount = t.wireIndexCount,
  2960. this.material = i,
  2961. this.visible = !0
  2962. }
  2963. w.prototype.draw = function(e) {
  2964. var t = this.gl;
  2965. if (this.material.bind(e, this)) {
  2966. e = this.material.shader.attribs;
  2967. var i = this.mesh.stride;
  2968. this.mesh.desc.cullBackFaces ? (t.enable(t.CULL_FACE),
  2969. t.cullFace(t.BACK)) : t.disable(t.CULL_FACE),
  2970. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  2971. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  2972. t.enableVertexAttribArray(e.vPosition),
  2973. t.enableVertexAttribArray(e.vTexCoord),
  2974. t.enableVertexAttribArray(e.vTangent),
  2975. t.enableVertexAttribArray(e.vBitangent),
  2976. t.enableVertexAttribArray(e.vNormal);
  2977. var s = this.mesh.vertexColor && void 0 !== e.vColor;
  2978. s && t.enableVertexAttribArray(e.vColor);
  2979. var n = this.mesh.secondaryTexCoord && void 0 !== e.vTexCoord2;
  2980. n && t.enableVertexAttribArray(e.vTexCoord2);
  2981. var r = 0;
  2982. t.vertexAttribPointer(e.vPosition, 3, t.FLOAT, !1, i, r),
  2983. r += 12,
  2984. t.vertexAttribPointer(e.vTexCoord, 2, t.FLOAT, !1, i, r),
  2985. r += 8,
  2986. this.mesh.secondaryTexCoord && (n && t.vertexAttribPointer(e.vTexCoord2, 2, t.FLOAT, !1, i, r),
  2987. r += 8),
  2988. t.vertexAttribPointer(e.vTangent, 2, t.UNSIGNED_SHORT, !0, i, r),
  2989. r += 4,
  2990. t.vertexAttribPointer(e.vBitangent, 2, t.UNSIGNED_SHORT, !0, i, r),
  2991. r += 4,
  2992. t.vertexAttribPointer(e.vNormal, 2, t.UNSIGNED_SHORT, !0, i, r),
  2993. s && t.vertexAttribPointer(e.vColor, 4, t.UNSIGNED_BYTE, !0, i, r + 4),
  2994. t.drawElements(t.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  2995. t.disableVertexAttribArray(e.vPosition),
  2996. t.disableVertexAttribArray(e.vTexCoord),
  2997. t.disableVertexAttribArray(e.vTangent),
  2998. t.disableVertexAttribArray(e.vBitangent),
  2999. t.disableVertexAttribArray(e.vNormal),
  3000. s && t.disableVertexAttribArray(e.vColor),
  3001. n && t.disableVertexAttribArray(e.vTexCoord2)
  3002. }
  3003. }
  3004. ,
  3005. w.prototype.drawShadow = function(e) {
  3006. var t = this.gl;
  3007. this.mesh.desc.cullBackFaces ? (t.enable(t.CULL_FACE),
  3008. t.cullFace(t.BACK)) : t.disable(t.CULL_FACE),
  3009. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  3010. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  3011. t.enableVertexAttribArray(e),
  3012. t.vertexAttribPointer(e, 3, t.FLOAT, !1, this.mesh.stride, 0),
  3013. t.drawElements(t.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  3014. t.disableVertexAttribArray(e)
  3015. }
  3016. ,
  3017. w.prototype.drawAlphaShadow = function(e, t) {
  3018. var i = this.gl;
  3019. this.mesh.desc.cullBackFaces ? (i.enable(i.CULL_FACE),
  3020. i.cullFace(i.BACK)) : i.disable(i.CULL_FACE),
  3021. i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  3022. i.bindBuffer(i.ARRAY_BUFFER, this.mesh.vertexBuffer),
  3023. i.enableVertexAttribArray(e),
  3024. i.enableVertexAttribArray(t),
  3025. i.vertexAttribPointer(e, 3, i.FLOAT, !1, this.mesh.stride, 0),
  3026. i.vertexAttribPointer(t, 2, i.FLOAT, !1, this.mesh.stride, 12),
  3027. i.drawElements(i.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  3028. i.disableVertexAttribArray(e),
  3029. i.disableVertexAttribArray(t)
  3030. }
  3031. ,
  3032. w.prototype.drawAlphaPrepass = function(e) {
  3033. var t = this.gl;
  3034. if (this.material.bindAlphaPrepass(e, this)) {
  3035. e = this.material.prepassShader.attribs;
  3036. var i = this.mesh.stride;
  3037. this.mesh.desc.cullBackFaces ? (t.enable(t.CULL_FACE),
  3038. t.cullFace(t.BACK)) : t.disable(t.CULL_FACE),
  3039. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.mesh.indexBuffer),
  3040. t.bindBuffer(t.ARRAY_BUFFER, this.mesh.vertexBuffer),
  3041. t.enableVertexAttribArray(e.vPosition),
  3042. t.enableVertexAttribArray(e.vTexCoord),
  3043. t.vertexAttribPointer(e.vPosition, 3, t.FLOAT, !1, i, 0),
  3044. t.vertexAttribPointer(e.vTexCoord, 2, t.FLOAT, !1, i, 12),
  3045. t.drawElements(t.TRIANGLES, this.indexCount, this.mesh.indexType, this.indexOffset),
  3046. t.disableVertexAttribArray(e.vPosition),
  3047. t.disableVertexAttribArray(e.vTexCoord)
  3048. }
  3049. }
  3050. ,
  3051. w.prototype.drawWire = function(e) {
  3052. var t = this.material.wireShader.attribs
  3053. , i = this.gl;
  3054. this.material.bindWire(e, this) && (i.enableVertexAttribArray(t.vPosition),
  3055. i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.mesh.wireBuffer),
  3056. i.bindBuffer(i.ARRAY_BUFFER, this.mesh.vertexBuffer),
  3057. i.vertexAttribPointer(t.vPosition, 3, i.FLOAT, !1, this.mesh.stride, 0),
  3058. i.drawElements(i.LINES, this.wireIndexCount, this.mesh.indexType, this.wireIndexOffset),
  3059. i.disableVertexAttribArray(t.vPosition))
  3060. }
  3061. ,
  3062. w.prototype.complete = function() {
  3063. return this.material.complete()
  3064. }
  3065. ;
  3066. var C = {
  3067. fetchImage: function(e, t, i) {
  3068. var s = new Image();
  3069. s.crossOrigin = "Anonymous",
  3070. s.onload = function() {
  3071. 0 < s.width && 0 < s.height ? t(s) : i && i()
  3072. }
  3073. ,
  3074. i && (req.onerror = function() {
  3075. i()
  3076. }
  3077. ),
  3078. s.src = e
  3079. },
  3080. fetchText: function(e, t, i, s) {
  3081. var n = new XMLHttpRequest();
  3082. n.open("GET", e, !0),
  3083. n.onload = function() {
  3084. 200 == n.status ? t(n.responseText) : i && i()
  3085. }
  3086. ,
  3087. i && (n.onerror = function() {
  3088. i()
  3089. }
  3090. ),
  3091. s && (n.onprogress = function(e) {
  3092. s(e.loaded, e.total)
  3093. }
  3094. ),
  3095. n.send()
  3096. },
  3097. fetchBinary: function(e, t, i, s) {
  3098. var n = new XMLHttpRequest();
  3099. n.open("GET", e, !0),
  3100. n.responseType = "arraybuffer",
  3101. n.onload = function() {
  3102. 200 == n.status ? t(n.response) : i && i()
  3103. }
  3104. ,
  3105. i && (n.onerror = function() {
  3106. i()
  3107. }
  3108. ),
  3109. s && (n.onprogress = function(e) {
  3110. s(e.loaded, e.total)
  3111. }
  3112. ),
  3113. n.send()
  3114. },
  3115. fetchBinaryIncremental: function(r, a, t, o) {
  3116. var i = new XMLHttpRequest();
  3117. i.open("HEAD", r, !0),
  3118. i.onload = function() {
  3119. if (200 == i.status) {
  3120. var e = i.getResponseHeader("Accept-Ranges");
  3121. if (e && "none" != e) {
  3122. var s = 0 | i.getResponseHeader("Content-Length")
  3123. , n = function(e, t) {
  3124. var i = new XMLHttpRequest();
  3125. i.open("GET", r, !0),
  3126. i.setRequestHeader("Range", "bytes=" + e + "-" + t),
  3127. i.responseType = "arraybuffer",
  3128. i.onload = function() {
  3129. (206 == i.status || 200 == i.status) && a(i.response) && t < s && n(e += o, t = (t += o) < s - 1 ? t : s - 1)
  3130. }
  3131. ,
  3132. i.send()
  3133. };
  3134. n(0, o - 1)
  3135. } else
  3136. t && t()
  3137. } else
  3138. t && t()
  3139. }
  3140. ,
  3141. t && (i.onerror = function() {
  3142. t()
  3143. }
  3144. ),
  3145. i.send()
  3146. }
  3147. };
  3148. function R(e) {
  3149. this.debugString = "",
  3150. this.init = !1,
  3151. this.speedList = this.cameraList = this.animationList = this.playButton = this.timelineSlider = this.playbackRegion = this.previousFrameButton = this.nextFrameButton = this.pauseButton = this.playButton = 0,
  3152. this.visible = !1,
  3153. this.backgroundRegion = this.screenButton = 0,
  3154. this.guiScreen = e,
  3155. this.playbackRegion = new v(e),
  3156. this.idealSliderWidth = 650,
  3157. this.totalListBoxPixelsX = 0,
  3158. this.minWidth = 500,
  3159. this.compactMode = !1,
  3160. this.ui = e.ui;
  3161. var t = "animationpause" + e.imageSetNumber + "x.png"
  3162. , i = "animationplay" + e.imageSetNumber + "x.png"
  3163. , s = "timelineLE" + e.imageSetNumber + "x.png"
  3164. , n = "timelineM" + e.imageSetNumber + "x.png"
  3165. , r = "timelineRE" + e.imageSetNumber + "x.png"
  3166. , a = e.ui.viewer.scene.sceneAnimator.animations.length;
  3167. if (0 != a) {
  3168. var o = this.idealSliderWidth;
  3169. this.bottomOffset = 85,
  3170. this.centerOffset = 60;
  3171. var h, l = (h = e.width / 2 + this.centerOffset) - o / 2, d = l - 14 - 32, c = (h = h + o / 2) - d, u = 32 / e.height, f = this.bottomOffset / e.height, m = this.playbackRegion;
  3172. if (m.controlRect.widthPercent = c / e.width,
  3173. m.controlRect.heightPercent = u,
  3174. m.controlRect.xPercent = d / e.width,
  3175. m.controlRect.yPercent = f,
  3176. u = 32 / c,
  3177. this.pauseButton = new p(this.guiScreen),
  3178. this.pauseButton.controlRect.set(0, .125, u, .75),
  3179. this.pauseButton.controlRect.opacity = .5,
  3180. m.controlRect.registerChildControlRect(this.pauseButton.controlRect),
  3181. this.pauseButton.linkControl(m.addImageElement(this.pauseButton.controlRect, t)),
  3182. this.playButton = new p(this.guiScreen),
  3183. this.playButton.controlRect.set(0, .125, u, .75),
  3184. this.playButton.controlRect.opacity = .5,
  3185. m.controlRect.registerChildControlRect(this.playButton.controlRect),
  3186. this.playButton.linkControl(m.addImageElement(this.playButton.controlRect, i)),
  3187. t = o / c,
  3188. c = (l - d) / c,
  3189. this.timelineSlider = new z(this.guiScreen,m),
  3190. this.timelineSlider.controlRect.set(c, .03125, t, 1),
  3191. m.controlRect.registerChildControlRect(this.timelineSlider.controlRect),
  3192. this.timelineSlider.setBackground3x1(m, s, n, r),
  3193. this.pauseButton.controlRect.showControl(!e.ui.viewer.scene.sceneAnimator.paused),
  3194. this.playButton.controlRect.showControl(e.ui.viewer.scene.sceneAnimator.paused),
  3195. s = h + 14,
  3196. n = this.bottomOffset + 4,
  3197. r = e.ui.viewer.scene.sceneAnimator.animations[0].cameraObjects.length,
  3198. e.ui.viewer.scene.sceneAnimator.selectDefaultCamera(),
  3199. e.ui.viewer.scene.sceneAnimator.setViewFromSelectedCamera(),
  3200. this.maxListPixelsX = 0,
  3201. 1 < r) {
  3202. for (this.cameraList = new y(e),
  3203. c = 0; c < r; c++)
  3204. this.cameraList.addItem(e.ui.viewer.scene.sceneAnimator.animations[0].cameraObjects[c].name, 0, 0);
  3205. this.cameraList.spawnControl(s, n, 10, 24, !0, 8),
  3206. this.cameraList.selectItem(e.ui.viewer.scene.sceneAnimator.selectedCameraIndex),
  3207. this.maxListPixelsX = this.cameraList.localPixelsX,
  3208. this.totalListBoxPixelsX += this.cameraList.localPixelsX + 14
  3209. }
  3210. if (1 < a) {
  3211. for (this.animationList = new y(e),
  3212. c = 0; c < a; c++)
  3213. this.animationList.addItem(e.ui.viewer.scene.sceneAnimator.animations[c].name, 0, 0);
  3214. this.animationList.spawnControl(s, n, 10, 24, !0, 8),
  3215. this.maxListPixelsX < this.animationList.localPixelsX && (this.maxListPixelsX = this.animationList.localPixelsX),
  3216. this.totalListBoxPixelsX += this.animationList.localPixelsX + 14,
  3217. this.animationList.selectItem(e.ui.viewer.scene.sceneAnimator.selectedAnimationIndex)
  3218. }
  3219. c = h - (s = d - 44 - 14) + this.totalListBoxPixelsX,
  3220. this.speedList = new y(e),
  3221. this.speedList.addItem("4.0x", 4, 0),
  3222. this.speedList.addItem("2.0x", 4, 0),
  3223. this.speedList.addItem("1.0x", 4, 0),
  3224. this.speedList.addItem("0.5x", 4, 0),
  3225. this.speedList.addItem("0.25x", -2, 0),
  3226. this.speedList.spawnControl(s, n, 44, 24, !1, 0),
  3227. this.speedList.selectItem(2),
  3228. c > e.width && (this.idealSliderWidth = e.width - (118 + (this.totalListBoxPixelsX + 14)) - this.centerOffset,
  3229. e = 0,
  3230. this.cameraList && e++,
  3231. this.animationList && e++,
  3232. 1 == e && (this.idealSliderWidth += 56,
  3233. this.centerOffset -= 14),
  3234. 2 == e && (this.idealSliderWidth += 63,
  3235. this.centerOffset -= 63)),
  3236. this.setupCallbacks()
  3237. }
  3238. }
  3239. function A(e, t, i) {
  3240. if (this.gl = e,
  3241. this.desc = t,
  3242. t = [],
  3243. 0 != this.desc.sharpen && t.push("#define SHARPEN"),
  3244. (this.useBloom = 0 < this.desc.bloomColor[0] * this.desc.bloomColor[3] || 0 < this.desc.bloomColor[1] * this.desc.bloomColor[3] || 0 < this.desc.bloomColor[2] * this.desc.bloomColor[3]) && t.push("#define BLOOM"),
  3245. 0 != this.desc.vignette[3] && t.push("#define VIGNETTE"),
  3246. 1 == this.desc.saturation[0] * this.desc.saturation[3] && 1 == this.desc.saturation[1] * this.desc.saturation[3] && 1 == this.desc.saturation[2] * this.desc.saturation[3] || t.push("#define SATURATION"),
  3247. 1 == this.desc.contrast[0] * this.desc.contrast[3] && 1 == this.desc.contrast[1] * this.desc.contrast[3] && 1 == this.desc.contrast[2] * this.desc.contrast[3] && 1 == this.desc.brightness[0] * this.desc.brightness[3] && 1 == this.desc.brightness[1] * this.desc.brightness[3] && 1 == this.desc.brightness[2] * this.desc.brightness[3] || t.push("#define CONTRAST"),
  3248. 0 != this.desc.grain && t.push("#define GRAIN"),
  3249. 1 == this.desc.toneMap ? t.push("#define REINHARD") : 2 == this.desc.toneMap && t.push("#define HEJL"),
  3250. this.desc.colorLUT && t.push("#define COLOR_LUT"),
  3251. this.sampleIndex = 0,
  3252. this.sampleCount = 1,
  3253. i && (this.sampleCount = 4,
  3254. this.sampleOffsets = [[-.5, -.5], [.5, -.5], [-.5, .5], [.5, .5]]),
  3255. this.aaShader = e.shaderCache.fromURLs("postvert.glsl", "postaa.glsl"),
  3256. this.shader = e.shaderCache.fromURLs("postvert.glsl", "postfrag.glsl", t),
  3257. this.plainShader = e.shaderCache.fromURLs("postvert.glsl", "postfrag.glsl", []),
  3258. this.fullscreenTriangle = e.createBuffer(),
  3259. e.bindBuffer(e.ARRAY_BUFFER, this.fullscreenTriangle),
  3260. i = new Float32Array([0, 0, 2, 0, 0, 2]),
  3261. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3262. e.bindBuffer(e.ARRAY_BUFFER, null),
  3263. this.useBloom) {
  3264. for (this.bloomTextures = [],
  3265. this.bloomTargets = [],
  3266. i = 0; i < 2; ++i)
  3267. t = {
  3268. width: 256,
  3269. height: 256,
  3270. clamp: !0
  3271. },
  3272. this.bloomTextures[i] = new U(e,t),
  3273. this.bloomTextures[i].loadArray(null, e.RGBA, e.ext.textureHalf && e.ext.textureHalfLinear ? e.ext.textureHalf.HALF_FLOAT_OES : e.UNSIGNED_BYTE),
  3274. this.bloomTargets[i] = new m(e,{
  3275. width: t.width,
  3276. height: t.height,
  3277. color0: this.bloomTextures[i]
  3278. });
  3279. for (this.bloomSamples = 64; this.bloomSamples + 16 >= e.limits.fragmentUniforms; )
  3280. this.bloomSamples /= 2;
  3281. this.bloomShader = e.shaderCache.fromURLs("postvert.glsl", "bloom.glsl", ["#define BLOOM_SAMPLES " + this.bloomSamples]),
  3282. this.shrinkShader = e.shaderCache.fromURLs("postvert.glsl", "bloomshrink.glsl")
  3283. }
  3284. for (e = new Uint8Array(16384),
  3285. i = 0; i < 16384; i++) {
  3286. t = 255 * Math.random();
  3287. var s = 255 * Math.random();
  3288. e[i] = .5 * (t + s)
  3289. }
  3290. this.noiseTexture = new U(this.gl,{
  3291. width: 128,
  3292. height: 128
  3293. }),
  3294. this.noiseTexture.loadArray(e, this.gl.LUMINANCE),
  3295. this.desc.colorLUT && (e = this.desc.colorLUT,
  3296. this.colorLUT = new U(this.gl,{
  3297. width: e.length / 3 | 0,
  3298. height: 1,
  3299. clamp: !0
  3300. }),
  3301. this.colorLUT.loadArray(new Uint8Array(e), this.gl.RGB)),
  3302. this.blackTexture = new U(this.gl,{
  3303. width: 1,
  3304. height: 1
  3305. }),
  3306. this.blackTexture.loadArray(new Uint8Array([0, 0, 0, 0])),
  3307. this.bloomResult = this.blackTexture
  3308. }
  3309. function k(e) {
  3310. this.gl = e,
  3311. this.name = "untitled",
  3312. this.meshes = [],
  3313. this.meshRenderables = [],
  3314. this.materials = {},
  3315. this.sky = this.view = null,
  3316. this.selectedPartIndex = 0,
  3317. this.soloPart = !1,
  3318. this.miscnotes = "",
  3319. this.nextView = null,
  3320. this.viewFade = 0,
  3321. this.refractionSurface = this.shadow = this.stripData = this.lights = null,
  3322. this.sceneAnimator = this.frameCounter = 0,
  3323. this.sceneLoaded = !1,
  3324. this.debugString = ""
  3325. }
  3326. function P(e, t, i) {
  3327. if (this.scene = e,
  3328. this.animations = [],
  3329. this.skinningRigs = [],
  3330. this.meshIDs = [],
  3331. this.lightIDs = [],
  3332. this.materialIDs = [],
  3333. this.views = [],
  3334. this.viewYawOffsets = [],
  3335. this.viewPitchOffsets = [],
  3336. this.cameraObjectIndices = [],
  3337. this.cameraChildrenIndices = [],
  3338. this.subMeshObjectIndices = [],
  3339. this.subMeshLiveIndices = [],
  3340. this.scene = e,
  3341. this.selectedCameraIndex = -1,
  3342. this.selectedAnimationIndex = 0,
  3343. this.debugString = "",
  3344. this.scenePlaybackSpeed = this.playbackSpeed = 1,
  3345. this.animationProgress = this.totalSeconds = 0,
  3346. this.paused = this.autoAdvanceNextAnimation = !1,
  3347. this.animateVisibility = this.drawAnimated = this.linkSceneObjects = this.loadSkinningRigs = this.animateMaterials = this.animateTurntables = this.enableSkinning = this.animateMeshes = this.animateLights = this.playAnimations = this.loadAnimations = !0,
  3348. this.showDebugInfo = !1,
  3349. this.loopCount = 0,
  3350. this.loopTurntables = this.lockPlayback = !1,
  3351. this.fogObjectIndex = -1,
  3352. this.unitScaleSkinnedMeshes = !0,
  3353. this.sceneScale = i.sceneScale,
  3354. this.defaultCameraGlobalIndex = i.selectedCamera,
  3355. this.selectedAnimationIndex = i.selectedAnimation,
  3356. this.autoPlayAnims = i.autoPlayAnims,
  3357. this.showPlayControls = i.showPlayControls,
  3358. i.scenePlaybackSpeed && (this.scenePlaybackSpeed = i.scenePlaybackSpeed,
  3359. 0 == this.scenePlaybackSpeed && (this.scenePlaybackSpeed = 1)),
  3360. this.autoPlayAnims || (this.paused = !0),
  3361. this.loadAnimations) {
  3362. if (i.meshIDs)
  3363. for (var s = i.meshIDs.length, n = 0; n < s; ++n) {
  3364. var r = i.meshIDs[n].partIndex;
  3365. this.meshIDs.push(r)
  3366. }
  3367. if (i.lightIDs)
  3368. for (s = i.lightIDs.length,
  3369. n = 0; n < s; ++n)
  3370. r = (r = i.lightIDs[n]).partIndex,
  3371. this.lightIDs.push(r);
  3372. if (i.materialIDs)
  3373. for (s = i.materialIDs.length,
  3374. n = 0; n < s; ++n)
  3375. r = (r = i.materialIDs[n]).partIndex,
  3376. this.materialIDs.push(r);
  3377. if (this.numMatricesInTable = i.numMatrices,
  3378. r = new u((n = t.get("MatTable.bin")).data),
  3379. n || (this.numMatricesInTable = 0,
  3380. this.debugString += "<br>No mattable?"),
  3381. i.skinningRigs && this.loadSkinningRigs)
  3382. for (s = i.skinningRigs.length,
  3383. n = 0; n < s; ++n) {
  3384. "" == (a = new M(t,i.skinningRigs[n],r)).debugString ? this.skinningRigs.push(a) : (this.debugString += "<br>Error loading skinning rig " + n + " :" + a.debugString,
  3385. this.debugString += "<br>Skipping the rest",
  3386. n = s)
  3387. }
  3388. if (i.animations)
  3389. for (r = i.animations.length,
  3390. n = 0; n < r; ++n)
  3391. s = new c(t,i.animations[n]),
  3392. this.animations.push(s);
  3393. if (this.startMS = Date.now(),
  3394. r = this.animations.length,
  3395. this.linkSceneObjects && 0 != r) {
  3396. for (n = 0; n < r; n++)
  3397. for (s = (t = this.animations[n]).animatedObjects.length,
  3398. i = 0; i < s; i++)
  3399. "LightSO" == (a = t.animatedObjects[i]).sceneObjectType && (a.lightIndex = this.findLightIndexByPartIndex(i),
  3400. -1 != a.lightIndex ? t.lightObjects.push(a) : this.debugString += "<br> got light not in scene " + a.name),
  3401. "FogSO" == a.sceneObjectType && (this.fogObjectIndex = i),
  3402. "SubMeshSO" == a.sceneObjectType && 0 == n && (this.subMeshObjectIndices.push(i),
  3403. this.subMeshLiveIndices.push(-1)),
  3404. "Material" == a.sceneObjectType && (a.materialIndex = this.findMaterialIndexByPartIndex(i),
  3405. -1 == a.materialIndex ? this.debugString += "<br> can't find material index for object " + i : t.materialObjects.push(a)),
  3406. "TurnTableSO" == a.sceneObjectType && t.turnTableObjects.push(a),
  3407. "MeshSO" == a.sceneObjectType && (a.meshIndex = this.findMeshIndexByPartIndex(this.scene.meshes, i),
  3408. -1 == a.meshIndex ? (this.debugString += "<br> can't find mesh index for object " + i,
  3409. this.logObjectInfo(i, 0)) : (t.meshObjects.push(a),
  3410. a.mesh = this.scene.meshes[a.meshIndex],
  3411. -1 != a.skinningRigIndex && a.mesh && a.skinningRigIndex < this.skinningRigs.length && (a.skinningRig = this.skinningRigs[a.skinningRigIndex],
  3412. a.skinningRig.isRigidSkin || (a.mesh.dynamicVertexData ? a.skinningRig.useOriginalMeshVertices(a.mesh) : (this.debugString += "Skinning object - but mesh is not dynamic",
  3413. this.debugString += "<br>Rig index " + a.skinningRigIndex,
  3414. this.debugString += " not tagged as rigid"))))),
  3415. "CameraSO" == a.sceneObjectType && (a.modelPartIndex = a.id,
  3416. t.cameraObjects.push(a));
  3417. for (i = (t = this.animations[0]).cameraObjects.length,
  3418. n = 0; n < i; n++)
  3419. r = t.cameraObjects[n],
  3420. (s = this.scene.cameras[r.name]) ? (s = s.view) && (s = new H(s),
  3421. this.cameraObjectIndices.push(r.id),
  3422. this.views.push(s),
  3423. this.viewYawOffsets.push(0),
  3424. this.viewPitchOffsets.push(0)) : (this.debugString += "<br>no camDesc for " + r.name,
  3425. this.views.push(e.view));
  3426. for (e = this.scene.meshes.length,
  3427. r = this.subMeshObjectIndices.length,
  3428. n = s = 0; n < e; n++) {
  3429. var a = this.scene.meshes[n]
  3430. , o = !1;
  3431. for (i = 0; i < r; i++) {
  3432. var h = this.subMeshObjectIndices[i]
  3433. , l = t.animatedObjects[h]
  3434. , d = t.animatedObjects[l.parentIndex];
  3435. if (d.mesh || (this.debugString += "<br>submesh parent object has no mesh?",
  3436. this.debugString += "<br>obj.name " + l.name,
  3437. this.debugString += "<br>parent.name " + d.name,
  3438. this.debugString += "<br>submesh index " + i,
  3439. this.debugString += "<br>obj.index " + h),
  3440. d.mesh == a) {
  3441. for (o = 0; o < a.numSubMeshes; o++)
  3442. this.subMeshLiveIndices[i + (a.numSubMeshes - 1 - o)] = s,
  3443. s++;
  3444. i = r,
  3445. o = !0
  3446. }
  3447. }
  3448. o || (this.debugString += "<br>Missing submesh? - no matches for mesh " + n + " of " + e)
  3449. }
  3450. for (n = 0; n < r; n++)
  3451. -1 == this.subMeshLiveIndices[n] && (this.debugString += "<br>Missing mesh? Unused submesh " + n + " of " + r);
  3452. this.showDebugInfo = this.stopEverything = this.runDebugMode = !1,
  3453. this.selectDefaultCamera(),
  3454. this.findCameraChildren(),
  3455. this.findFixedTransforms(),
  3456. this.runDebugMode && (this.setAnimationProgress(0, !0),
  3457. "" != this.debugString ? this.stopEverything = !0 : this.checkDebug())
  3458. }
  3459. } else
  3460. this.debugString += "<br>Skip loading animation data"
  3461. }
  3462. function F(e) {
  3463. this.gl = e,
  3464. this.program = null,
  3465. this.params = {},
  3466. this.samplers = {},
  3467. this.attribs = {}
  3468. }
  3469. function O(e) {
  3470. this.gl = e,
  3471. this.cache = []
  3472. }
  3473. function E(e, t) {
  3474. if (this.gl = e,
  3475. this.shadowCount = t,
  3476. this.nativeDepth = !!e.ext.textureDepth,
  3477. this.desc = i,
  3478. i = this.nativeDepth ? ["#define SHADOW_NATIVE_DEPTH"] : [],
  3479. this.shaderSolid = e.shaderCache.fromURLs("shadowvert.glsl", "shadowfrag.glsl", i),
  3480. i.push("#define ALPHA_TEST 1"),
  3481. this.shaderAlphaTest = e.shaderCache.fromURLs("shadowvert.glsl", "shadowfrag.glsl", i),
  3482. this.depthTextures = [],
  3483. this.depthTargets = [],
  3484. 0 < this.shadowCount) {
  3485. var i = {
  3486. width: 2048,
  3487. height: 2048,
  3488. clamp: !0,
  3489. mipmap: !1,
  3490. nofilter: !0
  3491. };
  3492. e.hints.mobile && (i.width = i.height = 1536);
  3493. var s, n, r = {
  3494. width: i.width,
  3495. height: i.height
  3496. };
  3497. n = this.nativeDepth ? (s = e.DEPTH_COMPONENT,
  3498. e.UNSIGNED_SHORT) : (r.depthBuffer = m.createDepthBuffer(e, i.width, i.height),
  3499. s = e.RGB,
  3500. e.UNSIGNED_BYTE);
  3501. for (var a = 0; a < this.shadowCount; ++a)
  3502. this.depthTextures[a] = new U(e,i),
  3503. this.depthTextures[a].loadArray(null, s, n),
  3504. this.nativeDepth ? r.depth = this.depthTextures[a] : r.color0 = this.depthTextures[a],
  3505. this.depthTargets[a] = new m(e,r)
  3506. }
  3507. }
  3508. function B(e, t, i, s) {
  3509. this.gl = e,
  3510. this.desc = t,
  3511. this.lightCount = s.count,
  3512. this.shadowCount = i.shadowCount,
  3513. (t = this.nativeDepth ? ["#define SHADOW_NATIVE_DEPTH"] : []).push("#define LIGHT_COUNT " + this.lightCount),
  3514. t.push("#define SHADOW_COUNT " + this.shadowCount),
  3515. e.hints.mobile && t.push("#define MOBILE"),
  3516. this.shader = e.shaderCache.fromURLs("shadowfloorvert.glsl", "shadowfloorfrag.glsl", t),
  3517. t = new Float32Array([-1, 0, -1, -1, 0, 1, 1, 0, 1, -1, 0, -1, 1, 0, 1, 1, 0, -1]),
  3518. this.quadGeom = e.createBuffer(),
  3519. e.bindBuffer(e.ARRAY_BUFFER, this.quadGeom),
  3520. e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW),
  3521. e.bindBuffer(e.ARRAY_BUFFER, null)
  3522. }
  3523. function L() {
  3524. this.associateObjectIndex = this.linkObjectIndex = this.linkMode = 0,
  3525. this.vertexIndices = [],
  3526. this.vertexWeights = [],
  3527. this.matrix = S.identity(),
  3528. this.defaultAssociateWorldTransform = this.defaultClusterWorldTransform = this.defaultClusterBaseTransform = 0,
  3529. this.defaultClusterWorldTransformInvert = S.identity(),
  3530. this.defaultAssociateWorldTransformInvert = S.identity(),
  3531. this.debugString = ""
  3532. }
  3533. function M(e, t, i) {
  3534. if (this.debugString = "",
  3535. this.skinningClusters = [],
  3536. this.srcVFile = t.file,
  3537. e = e.get(this.srcVFile))
  3538. if (e.data) {
  3539. this.rigByteStream = new u(e.data),
  3540. e = new Uint32Array(this.rigByteStream.bytes.buffer,0,this.rigByteStream.bytes.length / 4),
  3541. this.expectedNumClusters = e[0],
  3542. this.expectedNumVertices = e[1],
  3543. this.numClusterLinks = e[2],
  3544. this.originalObjectIndex = e[3],
  3545. this.isRigidSkin = e[4],
  3546. this.tangentMethod = e[5],
  3547. t = 6 + 7 * this.expectedNumClusters;
  3548. for (var s = 0; s < this.expectedNumClusters; s++) {
  3549. var n = new L();
  3550. this.skinningClusters.push(n);
  3551. var r = 6 + 7 * s;
  3552. n.linkMode = e[1 + r],
  3553. n.linkObjectIndex = e[2 + r],
  3554. n.associateObjectIndex = e[3 + r];
  3555. var a = e[5 + r];
  3556. n.defaultClusterWorldTransform = i.getMatrix(e[4 + r]),
  3557. n.defaultClusterBaseTransform = i.getMatrix(a),
  3558. S.invert(n.defaultClusterWorldTransformInvert, n.defaultClusterWorldTransform),
  3559. 1 == n.linkMode && (n.defaultAssociateWorldTransform = i.getMatrix(e[6 + r]),
  3560. S.invert(n.defaultAssociateWorldTransformInvert, n.defaultAssociateWorldTransform))
  3561. }
  3562. e = (t = (i = 4 * t) + this.expectedNumVertices) + 2 * this.numClusterLinks,
  3563. t = new Uint8Array(this.rigByteStream.bytes.subarray(t)),
  3564. e = new Uint8Array(this.rigByteStream.bytes.subarray(e)),
  3565. this.linkMapCount = new Uint8Array(this.rigByteStream.bytes.buffer,i,this.expectedNumVertices),
  3566. this.linkMapClusterIndices = new Uint16Array(t.buffer),
  3567. this.linkMapWeights = new Float32Array(e.buffer)
  3568. } else
  3569. this.debugString += "<br>No data in " + this.srcVFile;
  3570. else
  3571. this.debugString += "<br>Error loading buffer for skinning rig " + this.srcVFile
  3572. }
  3573. function _(e, t, i) {
  3574. if (this.gl = e,
  3575. void 0 !== (s = t.extract("sky.dat") || t.extract("sky.png"))) {
  3576. this.specularTexture = new U(e,{
  3577. width: 256,
  3578. height: 2048,
  3579. clamp: !0
  3580. }),
  3581. t = s.data;
  3582. for (var s, n = (s = s.data.length) / 4, r = new Uint8Array(s), a = 0, o = 0; a < s; ++o)
  3583. r[a++] = t[o + 2 * n],
  3584. r[a++] = t[o + n],
  3585. r[a++] = t[o],
  3586. r[a++] = t[o + 3 * n];
  3587. this.specularTexture.loadArray(r)
  3588. }
  3589. if (this.diffuseCoefficients = new Float32Array(i.diffuseCoefficients),
  3590. this.backgroundMode = i.backgroundMode || 0,
  3591. this.backgroundBrightness = i.backgroundBrightness || 1,
  3592. this.backgroundColor = new Float32Array(i.backgroundColor),
  3593. 1 <= this.backgroundMode)
  3594. if (this.backgroundShader = e.shaderCache.fromURLs("skyvert.glsl", 3 == this.backgroundMode ? "skySH.glsl" : "sky.glsl", ["#define SKYMODE " + this.backgroundMode]),
  3595. this.vertexBuffer = e.createBuffer(),
  3596. e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer),
  3597. i = 1 / 256,
  3598. s = 2.8 * (t = .5 / 256),
  3599. n = .5 * t,
  3600. i = new Float32Array([0, 1, 0, .49609375 + i, .49609375 + i, 1, 0, 0, .9921875 + i, .49609375 + i, 0, 0, 1, .49609375 + i, .9921875 + i, -1, 0, 0, 0 + i, .49609375 + i, 0, 0, -1, .49609375 + i, 0 + i, 0, -1, 0, .9921875 + i, 0 + i, 0, -1, 0, .9921875 + i, .9921875 + i, 0, -1, 0, 0 + i, .9921875 + i, 0, -1, 0, 0 + i, 0 + i, s, 1 - s, -s, .5 + t, .5 - t, s, 1 - s, s, .5 + t, .5 + t, -s, 1 - s, s, .5 - t, .5 + t, -s, 1 - s, -s, .5 - t, .5 - t, -s, 0, -1 + s, .5 - t, 0 + i + t, s, 0, -1 + s, .5 + t, 0 + i + t, 1 - s, 0, -s, .9921875 + i - t, .5 - t, 1 - s, 0, s, .9921875 + i - t, .5 + t, s, 0, 1 - s, .5 + t, .9921875 + i - t, -s, 0, 1 - s, .5 - t, .9921875 + i - t, -1 + s, 0, s, 0 + i + t, .5 + t, -1 + s, 0, -s, 0 + i + t, .5 - t, 1, 0, 0, .9921875 + i - n, .49609375 + i, 0, 0, 1, .49609375 + i, .9921875 + i - n, -1, 0, 0, 0 + i + n, .49609375 + i, 0, 0, -1, .49609375 + i, 0 + i + n, 0, 1, 0, .49609375 + i - n, .49609375 + i, 0, 1, 0, .49609375 + i, .49609375 + i - n, 0, 1, 0, .49609375 + i + n, .49609375 + i, 0, 1, 0, .49609375 + i, .49609375 + i + n]),
  3601. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3602. e.bindBuffer(e.ARRAY_BUFFER, null),
  3603. this.indexBuffer = e.createBuffer(),
  3604. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, this.indexBuffer),
  3605. i = new Uint16Array([2, 1, 6, 3, 2, 7, 8, 4, 3, 4, 5, 1, 9, 14, 15, 17, 10, 16, 18, 19, 11, 20, 13, 12, 28, 12, 13, 13, 24, 28, 28, 24, 9, 9, 24, 14, 25, 9, 15, 25, 15, 21, 10, 25, 21, 10, 21, 16, 22, 26, 10, 22, 10, 17, 18, 11, 26, 22, 18, 26, 19, 23, 27, 19, 27, 11, 23, 20, 27, 27, 20, 12]),
  3606. this.skyIndexCount = i.length,
  3607. e.bufferData(e.ELEMENT_ARRAY_BUFFER, i, e.STATIC_DRAW),
  3608. e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null),
  3609. 3 == this.backgroundMode)
  3610. for (this.backgroundCoefficients = new Float32Array(this.diffuseCoefficients),
  3611. a = 0; a < this.backgroundCoefficients.length; ++a)
  3612. this.backgroundCoefficients[a] *= this.backgroundBrightness;
  3613. else {
  3614. var h;
  3615. this.backgroundTexture = new U(e,{
  3616. width: 256,
  3617. height: 256,
  3618. clamp: !0
  3619. }),
  3620. i = !1,
  3621. e.ext.textureHalf && e.ext.textureHalfLinear && (this.backgroundTexture.loadArray(null, e.RGB, e.ext.textureHalf.HALF_FLOAT_OES),
  3622. i = (h = new m(e,{
  3623. color0: this.backgroundTexture
  3624. })).valid),
  3625. !i && e.ext.textureFloat && e.ext.textureFloatLinear && !e.hints.mobile && (this.backgroundTexture.loadArray(null, e.RGB, e.FLOAT),
  3626. i = (h = new m(e,{
  3627. color0: this.backgroundTexture
  3628. })).valid),
  3629. i || (this.backgroundTexture.loadArray(),
  3630. h = new m(e,{
  3631. color0: this.backgroundTexture
  3632. })),
  3633. h.bind(),
  3634. (h = new F(e)).build("precision highp float; varying vec2 tc; attribute vec4 p; void main(){ gl_Position=p; tc=vec2(0.5,0.5/8.0)*p.xy+vec2(0.5,6.5/8.0); }", "precision highp float; varying vec2 tc; uniform sampler2D tex; uniform float b; void main(){vec4 s=texture2D(tex,tc); gl_FragColor.xyz=s.xyz*(b*s.w);}"),
  3635. h.bind(),
  3636. e.uniform1f(h.params.b, 7 * Math.sqrt(this.backgroundBrightness)),
  3637. this.specularTexture.bind(h.samplers.tex),
  3638. i = e.createBuffer(),
  3639. e.bindBuffer(e.ARRAY_BUFFER, i),
  3640. i = new Float32Array([-1, -1, .5, 1, 3, -1, .5, 1, -1, 3, .5, 1]),
  3641. e.bufferData(e.ARRAY_BUFFER, i, e.STATIC_DRAW),
  3642. e.enableVertexAttribArray(h.attribs.p),
  3643. e.vertexAttribPointer(h.attribs.p, 4, e.FLOAT, !1, 0, 0),
  3644. e.drawArrays(e.TRIANGLES, 0, 3),
  3645. e.disableVertexAttribArray(h.attribs.p)
  3646. }
  3647. }
  3648. function D() {
  3649. this.STRIP_NONE = -2,
  3650. this.STRIP_MENU = -1,
  3651. this.stripCount = 5,
  3652. this.strips = [0, 0, 0, 0, 0],
  3653. this.labels = ["Normals", "Albedo", "Reflectivity", "Gloss", "Topology"],
  3654. this.stripSlant = .25,
  3655. this.selectedStrip = this.STRIP_NONE,
  3656. this.animationActive = !1,
  3657. this.timestamp = Date.now(),
  3658. this.update(!0)
  3659. }
  3660. function U(e, t) {
  3661. this.gl = e,
  3662. this.id = null,
  3663. this.type = e.TEXTURE_2D,
  3664. this.format = e.RGBA,
  3665. this.componentType = e.UNSIGNED_BYTE,
  3666. t = t || {},
  3667. this.desc = {
  3668. width: t.width || 1,
  3669. height: t.height || 1,
  3670. mipmap: t.mipmap,
  3671. clamp: t.clamp,
  3672. mirror: t.mirror,
  3673. aniso: t.aniso,
  3674. nofilter: t.nofilter
  3675. }
  3676. }
  3677. function N(e) {
  3678. this.gl = e,
  3679. this.cache = []
  3680. }
  3681. function z(e, t) {
  3682. this.name = "none",
  3683. this.debugString = "",
  3684. this.knobControlRect = new s(e),
  3685. this.controlRect = new s(e);
  3686. var i = document.createElement("div");
  3687. i.id = "sliderUI",
  3688. i.style.position = "absolute",
  3689. i.style.overflow = "hidden",
  3690. i.style["-moz-user-select"] = "none",
  3691. i.style["-khtml-user-select"] = "none",
  3692. i.style["-webkit-user-select"] = "none",
  3693. i.style["-ms-user-select"] = "none",
  3694. this.controlRect.linkedControl = i,
  3695. this.backgroundControl = 0,
  3696. this.controlRect.registerChildControlRect(this.knobControlRect),
  3697. this.knobControlRect.setOpacity(.65),
  3698. this.sliderPercent = this.pixelsY = this.pixelsX = 0,
  3699. this.draggingSlider = !1,
  3700. this.guiScreen = e,
  3701. t.addImageElement(this.knobControlRect, "animationknob" + e.imageSetNumber + "x.png")
  3702. }
  3703. function j(e) {
  3704. this.viewer = e,
  3705. this.stripData = e.stripData,
  3706. (e = this.container = document.createElement("div")).id = "fdageUI",
  3707. e.style.position = "absolute",
  3708. e.style.overflow = "hidden",
  3709. e.style["-moz-user-select"] = "none",
  3710. e.style["-khtml-user-select"] = "none",
  3711. e.style["-webkit-user-select"] = "none",
  3712. e.style["-ms-user-select"] = "none",
  3713. this.viewer.domRoot.appendChild(e),
  3714. this.guiScreen = new t(this)
  3715. }
  3716. R.prototype.resize = function(e) {
  3717. e.ui.viewer.scene.sceneAnimator.showPlayControls || (e.width = 1,
  3718. e.height = 1),
  3719. this.compactMode = e.width < this.minWidth;
  3720. var t = this.bottomOffset
  3721. , i = this.bottomOffset + 4
  3722. , s = 0;
  3723. this.cameraList && this.animationList ? s += 42 + this.cameraList.localPixelsX + this.animationList.localPixelsX : this.cameraList ? s += 28 + this.cameraList.localPixelsX : this.animationList && (s += 28 + this.animationList.localPixelsX);
  3724. var n = e.width - s - 72;
  3725. 0 == s && (n -= 14);
  3726. var r = 116
  3727. , a = r + n + 14;
  3728. this.compactMode && (r = 58,
  3729. n += 44 + s,
  3730. 0 < s && (t += 32),
  3731. s || (i += 32));
  3732. var o = (s = 32 / n) + 14 / n
  3733. , h = 1 - o
  3734. , l = this.playbackRegion;
  3735. l.controlRect.widthPercent = n / e.width,
  3736. l.controlRect.heightPercent = 32 / e.height,
  3737. l.controlRect.xPercent = r / e.width,
  3738. l.controlRect.yPercent = t / e.height,
  3739. this.pauseButton.controlRect.set(0, .125, s, .75),
  3740. this.playButton.controlRect.set(0, .125, s, .75),
  3741. this.timelineSlider.controlRect.set(o, .03125, h, 1),
  3742. this.timelineSlider.setSize(n - 46, 32),
  3743. l.controlRect.updateElement(),
  3744. l.controlRect.updateChildElements(),
  3745. this.speedList.setControl(58, i, 44, 24, !1),
  3746. this.cameraList && (this.cameraList.setControl(a, i, 10, 24, !0, 8),
  3747. a += this.cameraList.localPixelsX + 14),
  3748. this.animationList && this.animationList.setControl(a, i, 10, 24, !0, 8),
  3749. this.timelineSlider.backgroundControl.alignBackground()
  3750. }
  3751. ,
  3752. R.prototype.setupCallbacks = function() {
  3753. var e = function(e) {
  3754. "0.01x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.01),
  3755. "0.05x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.05),
  3756. "0.25x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.25),
  3757. "0.5x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(.5),
  3758. "1.0x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(1),
  3759. "2.0x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(2),
  3760. "4.0x" == this.speedList.selectedItemText && this.ui.viewer.scene.sceneAnimator.setPlaybackSpeed(4)
  3761. }
  3762. .bind(this)
  3763. , t = function(e) {
  3764. this.ui.viewer.scene.sceneAnimator.selectCamera(this.cameraList.selectedIndex),
  3765. this.ui.viewer.wake()
  3766. }
  3767. .bind(this)
  3768. , i = function(e) {
  3769. this.ui.viewer.scene.sceneAnimator.selectAnimation(this.animationList.selectedIndex),
  3770. this.ui.viewer.wake()
  3771. }
  3772. .bind(this);
  3773. this.speedList && (this.speedList.selectionChangedCallback = e),
  3774. this.cameraList && (this.cameraList.selectionChangedCallback = t),
  3775. this.animationList && (this.animationList.selectionChangedCallback = i),
  3776. this.playButton.controlRect.linkedControl.onclick = function() {
  3777. this.ui.viewer.scene.sceneAnimator.pause(!1),
  3778. this.playButton.controlRect.showControl(!1),
  3779. this.pauseButton.controlRect.showControl(!0),
  3780. this.ui.viewer.wake()
  3781. }
  3782. .bind(this),
  3783. this.pauseButton.controlRect.linkedControl.onclick = function() {
  3784. this.ui.viewer.scene.sceneAnimator.pause(!0),
  3785. this.playButton.controlRect.showControl(!0),
  3786. this.pauseButton.controlRect.showControl(!1)
  3787. }
  3788. .bind(this)
  3789. }
  3790. ,
  3791. A.prototype.prepareBloom = function(e) {
  3792. if (this.useBloom && this.bloomShader.complete() && this.shrinkShader.complete()) {
  3793. this.shrinkShader.bind(),
  3794. this.bloomTargets[1].bind(),
  3795. e.bind(this.shrinkShader.samplers.tInput),
  3796. this.fillScreen(this.shrinkShader.attribs.vCoord),
  3797. this.bloomShader.bind();
  3798. var t = [];
  3799. this.bloomTargets[0].bind(),
  3800. this.bloomTextures[1].bind(this.bloomShader.samplers.tInput);
  3801. for (var i = 0, s = 0; s < this.bloomSamples; ++s) {
  3802. var n, r = 2 * s / (this.bloomSamples - 1) - 1;
  3803. n = 4 * r,
  3804. i += n = Math.exp(-.5 * n * n / 1) / 2.50662827463,
  3805. t[4 * s + 0] = r * this.desc.bloomSize,
  3806. t[4 * s + 1] = 0,
  3807. t[4 * s + 2] = n,
  3808. t[4 * s + 3] = 0
  3809. }
  3810. for (s = 0; s < this.bloomSamples; ++s)
  3811. t[4 * s + 2] /= i;
  3812. for (this.gl.uniform4fv(this.bloomShader.params.uKernel, t),
  3813. this.fillScreen(this.bloomShader.attribs.vCoord),
  3814. this.bloomTargets[1].bind(),
  3815. this.bloomTextures[0].bind(this.bloomShader.samplers.tInput),
  3816. s = 0; s < this.bloomSamples; ++s)
  3817. i = t[4 * s + 0],
  3818. i *= e.desc.width / e.desc.height,
  3819. t[4 * s + 0] = 0,
  3820. t[4 * s + 1] = i;
  3821. this.gl.uniform4fv(this.bloomShader.params.uKernel, t),
  3822. this.fillScreen(this.bloomShader.attribs.vCoord),
  3823. this.bloomResult = this.bloomTextures[1]
  3824. } else
  3825. this.bloomResult = this.blackTexture
  3826. }
  3827. ,
  3828. A.prototype.computeParams = function(e, t) {
  3829. var i = this.desc
  3830. , s = {};
  3831. s.scale = [i.contrast[0] * i.contrast[3], i.contrast[1] * i.contrast[3], i.contrast[2] * i.contrast[3]],
  3832. s.bias = [i.bias[0] * i.bias[3], i.bias[1] * i.bias[3], i.bias[2] * i.bias[3]],
  3833. s.bias = [-s.bias[0] * s.scale[0] + s.bias[0], -s.bias[1] * s.scale[1] + s.bias[1], -s.bias[2] * s.scale[2] + s.bias[2]];
  3834. var n = [i.brightness[0] * i.brightness[3], i.brightness[1] * i.brightness[3], i.brightness[2] * i.brightness[3]];
  3835. s.scale = [s.scale[0] * n[0], s.scale[1] * n[1], s.scale[2] * n[2]],
  3836. s.bias = [s.bias[0] * n[0], s.bias[1] * n[1], s.bias[2] * n[2]],
  3837. s.saturation = [i.saturation[0] * i.saturation[3], i.saturation[1] * i.saturation[3], i.saturation[2] * i.saturation[3]],
  3838. s.bloomColor = [i.bloomColor[0] * i.bloomColor[3], i.bloomColor[1] * i.bloomColor[3], i.bloomColor[2] * i.bloomColor[3]],
  3839. s.sharpen = [i.sharpen, .25 * i.sharpen, i.sharpenLimit],
  3840. s.sharpenKernel = [1 / e, 0, 0, 1 / t],
  3841. n = t < e ? e : t,
  3842. s.vignetteAspect = [e / n, t / n, .5 * e / n, .5 * t / n],
  3843. s.vignette = [2 * (1 - i.vignette[0]) * i.vignette[3], 2 * (1 - i.vignette[1]) * i.vignette[3], 2 * (1 - i.vignette[2]) * i.vignette[3], i.vignetteCurve];
  3844. n = 1 / this.noiseTexture.desc.width;
  3845. var r = 1 / this.noiseTexture.desc.height
  3846. , a = 1 - i.grainSharpness;
  3847. return s.grainCoord = [n * e, r * t, .5 * a * n, .5 * a * r],
  3848. s.grainScaleBias = [2 * i.grain, -i.grain],
  3849. s
  3850. }
  3851. ,
  3852. A.prototype.present = function(e, t, i, s) {
  3853. if (s || this.prepareBloom(e),
  3854. 1 < this.sampleCount && this.allocAABuffer(t, i),
  3855. (s = s ? this.plainShader : this.shader).bind()) {
  3856. var n = this.gl
  3857. , r = s.samplers
  3858. , a = s.params
  3859. , o = this.computeParams(t, i);
  3860. if (e.bind(r.tInput),
  3861. this.bloomResult.bind(r.tBloom),
  3862. this.noiseTexture.bind(r.tGrain),
  3863. this.colorLUT && this.colorLUT.bind(r.tLUT),
  3864. n.uniform3fv(a.uScale, o.scale),
  3865. n.uniform3fv(a.uBias, o.bias),
  3866. n.uniform3fv(a.uSaturation, o.saturation),
  3867. n.uniform4fv(a.uSharpenKernel, o.sharpenKernel),
  3868. n.uniform3fv(a.uSharpness, o.sharpen),
  3869. n.uniform3fv(a.uBloomColor, o.bloomColor),
  3870. n.uniform4fv(a.uVignetteAspect, o.vignetteAspect),
  3871. n.uniform4fv(a.uVignette, o.vignette),
  3872. n.uniform4fv(a.uGrainCoord, o.grainCoord),
  3873. n.uniform2fv(a.uGrainScaleBias, o.grainScaleBias),
  3874. e = 1 < this.sampleCount && 0 <= this.sampleIndex) {
  3875. var h = 1 / (1 + this.sampleIndex);
  3876. this.sampleIndex += 1,
  3877. h < 1 && (n.enable(n.BLEND),
  3878. n.blendColor(h, h, h, h),
  3879. n.blendFunc(n.CONSTANT_ALPHA, n.ONE_MINUS_CONSTANT_ALPHA)),
  3880. this.aaTarget.bind()
  3881. } else
  3882. m.bindNone(n),
  3883. 1 < this.sampleCount && (this.sampleIndex += 1);
  3884. n.viewport(0, 0, t, i),
  3885. this.fillScreen(s.attribs.vCoord),
  3886. e && (h < 1 && n.disable(n.BLEND),
  3887. m.bindNone(n),
  3888. this.aaShader.bind(),
  3889. this.aaBuffer.bind(this.aaShader.samplers.tInput),
  3890. this.fillScreen(this.aaShader.attribs.vCoord))
  3891. }
  3892. }
  3893. ,
  3894. A.prototype.allocAABuffer = function(e, t) {
  3895. this.aaBuffer && this.aaBuffer.desc.width == e && this.aaBuffer.desc.height == t || (this.aaBuffer && this.aaBuffer.destroy(),
  3896. this.aaBuffer = new U(this.gl,{
  3897. width: e,
  3898. height: t,
  3899. clamp: !0
  3900. }),
  3901. this.aaBuffer.loadArray(),
  3902. this.aaTarget = new m(this.gl,{
  3903. color0: this.aaBuffer,
  3904. ignoreStatus: !0
  3905. }))
  3906. }
  3907. ,
  3908. A.prototype.adjustProjectionForSupersampling = function(e) {
  3909. if (1 < this.sampleCount) {
  3910. var t = this.currentSample()
  3911. , i = this.sampleOffsets[t][0] / e.size[0];
  3912. t = this.sampleOffsets[t][1] / e.size[1],
  3913. i = S.translation(S.empty(), i, t, 0);
  3914. S.mul(e.projectionMatrix, i, e.projectionMatrix)
  3915. }
  3916. }
  3917. ,
  3918. A.prototype.discardAAHistory = function() {
  3919. this.sampleIndex = -1
  3920. }
  3921. ,
  3922. A.prototype.currentSample = function() {
  3923. return (this.sampleIndex < 0 ? 0 : this.sampleIndex) % this.sampleCount
  3924. }
  3925. ,
  3926. A.prototype.fillScreen = function(e) {
  3927. var t = this.gl;
  3928. t.bindBuffer(t.ARRAY_BUFFER, this.fullscreenTriangle),
  3929. t.enableVertexAttribArray(e),
  3930. t.vertexAttribPointer(e, 2, t.FLOAT, !1, 0, 0),
  3931. t.drawArrays(t.TRIANGLES, 0, 3),
  3932. t.disableVertexAttribArray(e),
  3933. t.bindBuffer(t.ARRAY_BUFFER, null)
  3934. }
  3935. ,
  3936. A.prototype.blitTexture = function(e) {
  3937. this.aaShader.bind(),
  3938. e.bind(this.aaShader.samplers.tInput),
  3939. this.fillScreen(this.aaShader.attribs.vCoord)
  3940. }
  3941. ,
  3942. k.prototype.load = function(e) {
  3943. var t, i = this.gl, s = e.extract("scene.json");
  3944. if (void 0 === s)
  3945. return !1;
  3946. if (!e.checkSignature(s))
  3947. return !1;
  3948. if (null == (s = new u(s.data).asString()) || s.length <= 0)
  3949. return !1;
  3950. try {
  3951. t = JSON.parse(s)
  3952. } catch (e) {
  3953. return console.error(e),
  3954. !1
  3955. }
  3956. for (var n in this.metaData = t.metaData,
  3957. this.view = new H(t.mainCamera.view),
  3958. this.sky = new _(this.gl,e,t.sky),
  3959. this.lights = new x(t.lights,this.view),
  3960. this.materialsList = [],
  3961. this.materials = {},
  3962. t.materials) {
  3963. var r = t.materials[n];
  3964. r.lightCount = this.lights.count,
  3965. r.shadowCount = this.lights.shadowCount,
  3966. s = new b(this.gl,e,r),
  3967. this.materials[r.name] = s,
  3968. this.materialsList.push(s)
  3969. }
  3970. if (t.meshes)
  3971. for (r = 0; r < t.meshes.length; ++r) {
  3972. n = t.meshes[r],
  3973. n = new T(this.gl,n,e.extract(n.file)),
  3974. this.meshes.push(n);
  3975. for (var a = 0; a < n.desc.subMeshes.length; ++a) {
  3976. var o = n.desc.subMeshes[a];
  3977. (s = this.materials[o.material]) && (n.numSubMeshes++,
  3978. this.meshRenderables.push(new w(n,o,s)))
  3979. }
  3980. }
  3981. return this.bounds = new d(this.meshes),
  3982. this.postRender = new A(this.gl,t.mainCamera.post,!0),
  3983. this.shadow = new E(i,this.lights.shadowCount),
  3984. this.cameras = t.Cameras,
  3985. t.AnimData && (this.sceneAnimator = new P(this,e,t.AnimData)),
  3986. t.fog && (this.fog = new f(i,t.fog)),
  3987. t.shadowFloor && (this.shadowFloor = new B(i,t.shadowFloor,this.shadow,this.lights)),
  3988. this.sceneLoaded = !0
  3989. }
  3990. ,
  3991. k.prototype.update = function() {
  3992. this.sceneAnimator && (this.frameCounter++,
  3993. this.lights.flagUpdateAnimatedLighting(),
  3994. this.sceneAnimator.drawAnimated && (1 == this.frameCounter ? this.sceneAnimator.resetPlayback() : this.sceneAnimator.updateAnimationPlayback())),
  3995. this.lights.update(this.view, this.bounds)
  3996. }
  3997. ,
  3998. k.prototype.collectShadows = function(e) {
  3999. this.shadow.collect(this, e)
  4000. }
  4001. ,
  4002. k.prototype.draw = function(e) {
  4003. var t = this.gl;
  4004. if (this.sceneLoaded) {
  4005. this.sky.setClearColor(),
  4006. t.clear(t.COLOR_BUFFER_BIT | t.DEPTH_BUFFER_BIT | t.STENCIL_BUFFER_BIT),
  4007. t.enable(t.DEPTH_TEST),
  4008. this.sky.draw(this),
  4009. this.shadowFloor && this.shadowFloor.draw(this);
  4010. for (var i = 0; i < this.meshRenderables.length; ++i)
  4011. this.meshRenderables[i].material.usesBlending || this.meshRenderables[i].material.usesRefraction || !this.meshRenderables[i].visible || this.meshRenderables[i].draw(this);
  4012. for (t.enable(t.POLYGON_OFFSET_FILL),
  4013. t.polygonOffset(1, 1),
  4014. t.colorMask(!1, !1, !1, !1),
  4015. i = 0; i < this.meshRenderables.length; ++i)
  4016. this.meshRenderables[i].drawAlphaPrepass(this);
  4017. for (t.colorMask(!0, !0, !0, !0),
  4018. t.disable(t.POLYGON_OFFSET_FILL),
  4019. t.depthFunc(t.LEQUAL),
  4020. t.depthMask(!1),
  4021. i = 0; i < this.meshRenderables.length; ++i)
  4022. this.meshRenderables[i].material.usesBlending && this.meshRenderables[i].visible && this.meshRenderables[i].draw(this);
  4023. t.disable(t.BLEND),
  4024. t.depthMask(!0),
  4025. t.depthFunc(t.LESS);
  4026. var s = !1;
  4027. for (i = 0; i < this.meshRenderables.length; ++i)
  4028. if (this.meshRenderables[i].material.usesRefraction) {
  4029. s = !0;
  4030. break
  4031. }
  4032. if (s)
  4033. for (this.refractionSurface && this.refractionSurface.desc.width == e.color0.desc.width && this.refractionSurface.desc.height == e.color0.desc.height || (this.refractionSurface = new U(t,e.color0.desc),
  4034. this.refractionSurface.loadArray(null, e.color0.format, e.color0.componentType),
  4035. this.refractionBuffer = new m(this.gl,{
  4036. color0: this.refractionSurface
  4037. })),
  4038. this.refractionBuffer.bind(),
  4039. this.postRender.blitTexture(e.color0),
  4040. e.bind(),
  4041. i = 0; i < this.meshRenderables.length; ++i)
  4042. this.meshRenderables[i].material.usesRefraction && this.meshRenderables[i].visible && this.meshRenderables[i].draw(this);
  4043. if (this.stripData.activeWireframe() && 0 < this.meshRenderables.length) {
  4044. for (i = 0; i < this.meshRenderables.length; ++i)
  4045. this.meshRenderables[i].visible && this.meshRenderables[i].drawWire(this);
  4046. t.depthMask(!0)
  4047. }
  4048. t.disable(t.BLEND)
  4049. }
  4050. }
  4051. ,
  4052. k.prototype.drawSecondary = function(e) {
  4053. this.fog && this.fog.draw(this, e)
  4054. }
  4055. ,
  4056. k.prototype.complete = function() {
  4057. if (!this.sky.complete() || !this.shadow.complete() || this.fog && !this.fog.complete() || this.shadowFloor && !this.shadowFloor.complete())
  4058. return !1;
  4059. for (var e = 0; e < this.meshRenderables.length; ++e)
  4060. if (!this.meshRenderables[e].complete())
  4061. return !1;
  4062. return !0
  4063. }
  4064. ,
  4065. P.prototype.flagAllForDebugging = function() {
  4066. for (var e = this.animations.length, t = 0; t < e; t++)
  4067. for (var i = this.animations[t], s = i.animatedObjects.length, n = 0; n < s; n++)
  4068. i.animatedObjects[n].debugMe = !0
  4069. }
  4070. ,
  4071. P.prototype.checkDebug = function() {
  4072. this.debugString = "<br>--------------------------------------Debug Info:",
  4073. this.debugString += "<br>this.selectedAnimationIndex :" + this.selectedAnimationIndex;
  4074. var e = this.animations[this.selectedAnimationIndex]
  4075. , t = e.animatedObjects.length;
  4076. this.debugString += "<br>numAnimatedObjects :" + t,
  4077. "" != e.debugString && (this.debugString += "<br>--------------------------------------------------Got animation bug info:",
  4078. this.debugString += e.debugString,
  4079. this.showDebugInfo = this.stopEverything = !0,
  4080. e.debugString = "");
  4081. for (var i = 0; i < t; i++) {
  4082. var s = e.animatedObjects[i];
  4083. "" == s.debugString && "" == s.animatedLocalTransform.debugString || (this.debugString += "<br>--------------------------------------------------Got object bug info:",
  4084. this.debugString += s.debugString,
  4085. this.debugString += s.animatedLocalTransform.debugString,
  4086. this.showDebugInfo = this.stopEverything = !0,
  4087. s.debugString = "",
  4088. s.animatedLocalTransform.debugString = ""),
  4089. s.skinningRig && "" != s.skinningRig.debugString && (this.debugString += "<br>--------------------------------------------------Got skin rig info:",
  4090. this.debugString += s.skinningRig.debugString,
  4091. s.skinningRig.debugString = "",
  4092. this.showDebugInfo = this.stopEverything = !0)
  4093. }
  4094. this.debugString += "<br>--------------------------------------Done Debug Info:"
  4095. }
  4096. ,
  4097. P.prototype.logObjectInfo = function(e, t) {
  4098. var i = t * (o = this.animations[this.selectedAnimationIndex]).originalFPS;
  4099. if (e >= o.animatedObjects.length)
  4100. this.debugString += "object index " + e + " exceeds " + o.animatedObjects.length;
  4101. else {
  4102. var s = o.animatedObjects[e]
  4103. , n = o.animatedObjects[s.modelPartIndex]
  4104. , r = o.getObjectAnimationFramePercent(s, t)
  4105. , a = o.getObjectAnimationFramePercent(n, t);
  4106. this.debugString = "",
  4107. this.debugString += "<br>Object Name: " + s.name,
  4108. this.debugString += "<br>Object Type: " + s.sceneObjectType,
  4109. this.debugString += "<br>Object Index: " + s.id,
  4110. this.debugString += "<br>Part Index: " + s.modelPartIndex,
  4111. this.debugString += "<br>Part Scale: " + s.modelPartScale,
  4112. this.debugString += "<br>Mesh Index: " + s.meshIndex,
  4113. this.debugString += "<br>Light Index: " + s.lightIndex,
  4114. this.debugString += "<br>Deformer Index: " + s.skinningRigIndex,
  4115. this.debugString += "<br>Parent Index: " + s.parentIndex,
  4116. this.debugString += "<br>Scene time " + t,
  4117. this.debugString += "<br>Scene framepercent " + i,
  4118. this.debugString += "<br>Object looped framepercent " + r,
  4119. this.debugString += "<br>Model looped framepercent " + a,
  4120. this.debugString += "<br>Object Anim length " + s.animationLength,
  4121. this.debugString += "<br>Object Total frames " + s.totalFrames,
  4122. this.debugString += "<br>Object FPS " + s.modelPartFPS,
  4123. this.debugString += "<br>Model Part Anim length " + n.animationLength,
  4124. this.debugString += "<br>Model total frames " + n.totalFrames,
  4125. this.debugString += "<br>Model Part FPS " + n.modelPartFPS,
  4126. i = S.identity(),
  4127. o.getWorldTransform(s.id, t, i, this.sceneScale, !0),
  4128. this.debugString += s.debugString;
  4129. var o = i[0]
  4130. , h = (s = i[1],
  4131. n = i[2],
  4132. r = i[4],
  4133. a = i[5],
  4134. i[6])
  4135. , l = i[8]
  4136. , d = i[9];
  4137. i = i[10];
  4138. Math.sqrt(o * o + s * s + n * n),
  4139. Math.sqrt(r * r + a * a + h * h),
  4140. Math.sqrt(l * l + d * d + i * i)
  4141. }
  4142. }
  4143. ,
  4144. P.prototype.resetPlayback = function() {
  4145. this.startMS = Date.now(),
  4146. this.animationProgress = this.totalSeconds = 0,
  4147. this.setAnimationProgress(0, !0)
  4148. }
  4149. ,
  4150. P.prototype.pause = function(e) {
  4151. this.paused = e,
  4152. this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed)
  4153. }
  4154. ,
  4155. P.prototype.setAnimationProgress = function(e, t) {
  4156. var i = this.animations[this.selectedAnimationIndex];
  4157. this.animationProgress = e,
  4158. this.totalSeconds = i.totalSeconds * this.animationProgress,
  4159. this.totalSeconds -= 1 / i.originalFPS,
  4160. this.totalSeconds < 0 && (this.totalSeconds = 0),
  4161. this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed),
  4162. t && this.updateScene()
  4163. }
  4164. ,
  4165. P.prototype.setPlaybackSpeed = function(e) {
  4166. this.playbackSpeed = e,
  4167. this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed)
  4168. }
  4169. ,
  4170. P.prototype.resetCustomView = function() {
  4171. 0 <= this.selectedCameraIndex && this.selectedCameraIndex < this.views.length && (this.viewYawOffsets[this.selectedCameraIndex] = 0,
  4172. this.viewPitchOffsets[this.selectedCameraIndex] = 0,
  4173. this.scene.view.rotation[1] = this.views[this.selectedCameraIndex].rotation[1],
  4174. this.scene.view.rotation[0] = this.views[this.selectedCameraIndex].rotation[0],
  4175. this.setViewFromSelectedCamera())
  4176. }
  4177. ,
  4178. P.prototype.updateUserCamera = function() {
  4179. if (this.clearCacheForCameraChildren(),
  4180. 0 <= this.selectedCameraIndex && this.selectedCameraIndex < this.views.length && this.selectedAnimationIndex < this.animations.length) {
  4181. var e = this.cameraObjectIndices[this.selectedCameraIndex]
  4182. , t = this.animations[this.selectedAnimationIndex];
  4183. if (e < t.animatedObjects.length) {
  4184. var i = this.views[this.selectedCameraIndex]
  4185. , s = this.scene.view.rotation[1]
  4186. , n = this.scene.view.rotation[0]
  4187. , r = n - i.rotation[0];
  4188. this.viewYawOffsets[this.selectedCameraIndex] = s - i.rotation[1],
  4189. this.viewPitchOffsets[this.selectedCameraIndex] = r,
  4190. i = t.animatedObjects[e],
  4191. t.getObjectAnimationFramePercent(i, this.totalSeconds);
  4192. r = S.identity();
  4193. var a = S.identity();
  4194. i.useFixedWorldTransform = !1,
  4195. i.useFixedLocalTransform = !1,
  4196. i.animatedLocalTransform.lockTransform = !1,
  4197. i.animatedLocalTransform.clearCachedTransforms(),
  4198. i.cachedFrame0 = -1,
  4199. i.cachedFrame1 = -1,
  4200. i.cachedFrame2 = -1,
  4201. i.cachedFrame3 = -1,
  4202. i.cachedFrameUse0 = 0,
  4203. i.cachedFrameUse1 = 0,
  4204. i.cachedFrameUse2 = 0,
  4205. i.cachedFrameUse3 = 0,
  4206. t.getWorldTransform(e, this.totalSeconds, a, this.sceneScale, !1);
  4207. e = a[0];
  4208. var o = a[1]
  4209. , h = a[2]
  4210. , l = a[4]
  4211. , d = a[5]
  4212. , c = a[6]
  4213. , u = a[8]
  4214. , f = a[9]
  4215. , m = a[10];
  4216. e = Math.sqrt(e * e + o * o + h * h),
  4217. l = Math.sqrt(l * l + d * d + c * c),
  4218. d = Math.sqrt(u * u + f * f + m * m);
  4219. (c = -(this.scene.view.pivot[0] - a[12])) * u + (o = -(this.scene.view.pivot[1] - a[13])) * f + (a = -(this.scene.view.pivot[2] - a[14])) * m <= 0 && (s += 180),
  4220. s = S.rotation(S.empty(), s, 1),
  4221. n = S.rotation(S.empty(), n, 0),
  4222. S.mul(r, s, n),
  4223. n = Math.sqrt(c * c + o * o + a * a),
  4224. s = this.scene.view.pivot[1] + r[9] * n,
  4225. a = this.scene.view.pivot[2] + r[10] * n,
  4226. r[12] = this.scene.view.pivot[0] + r[8] * n,
  4227. r[13] = s,
  4228. r[14] = a,
  4229. n = S.identity(),
  4230. t.getWorldTransform(i.parentIndex, this.totalSeconds, n, this.sceneScale, !1),
  4231. t = S.identity(),
  4232. S.invert(t, n),
  4233. n = S.identity(),
  4234. S.mul(n, t, r),
  4235. n[12] /= this.sceneScale,
  4236. n[13] /= this.sceneScale,
  4237. n[14] /= this.sceneScale,
  4238. r[0] *= e,
  4239. r[1] *= e,
  4240. r[2] *= e,
  4241. r[4] *= l,
  4242. r[5] *= l,
  4243. r[6] *= l,
  4244. r[8] *= d,
  4245. r[9] *= d,
  4246. r[10] *= d,
  4247. i.setFixedWorldTransform(r),
  4248. i.setFixedLocalTransform(n)
  4249. }
  4250. }
  4251. }
  4252. ,
  4253. P.prototype.setViewFromSelectedCamera = function() {
  4254. if (0 <= this.selectedCameraIndex && this.selectedCameraIndex < this.views.length) {
  4255. var e = this.views[this.selectedCameraIndex]
  4256. , t = this.scene.view
  4257. , i = this.viewYawOffsets[this.selectedCameraIndex]
  4258. , s = this.viewPitchOffsets[this.selectedCameraIndex];
  4259. t.pivot[0] = e.pivot[0],
  4260. t.pivot[1] = e.pivot[1],
  4261. t.pivot[2] = e.pivot[2],
  4262. t.rotation[0] = e.rotation[0] + s,
  4263. t.rotation[1] = e.rotation[1] + i,
  4264. t.radius = e.radius,
  4265. t.nearPlane = e.nearPlane,
  4266. t.fov = e.fov,
  4267. t.saveResetView(),
  4268. t.updateProjection(),
  4269. t.updateView()
  4270. }
  4271. }
  4272. ,
  4273. P.prototype.selectDefaultCamera = function() {
  4274. if (-1 != this.defaultCameraGlobalIndex && 0 < this.animations.length)
  4275. for (var e = this.animations[0], t = e.cameraObjects.length, i = 0; i < t; i++)
  4276. if (e.cameraObjects[i].id == this.defaultCameraGlobalIndex)
  4277. return void (this.selectedCameraIndex = i);
  4278. this.selectedCameraIndex = 0
  4279. }
  4280. ,
  4281. P.prototype.updateAnimationPlayback = function() {
  4282. if (!this.stopEverything || !this.runDebugMode) {
  4283. var e = this.animations[this.selectedAnimationIndex];
  4284. if (this.updateUserCamera(),
  4285. this.paused || !this.playAnimations)
  4286. this.startMS = 0 < this.playbackSpeed ? Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed) : Date.now() - 1e3 * this.totalSeconds,
  4287. this.refreshTransformsOnly(),
  4288. this.runDebugMode && this.checkDebug(),
  4289. (e = this.scene.view).saveResetView(),
  4290. e.updateProjection(),
  4291. e.updateView();
  4292. else {
  4293. this.lockPlayback && 0 < this.playbackSpeed && (this.startMS = Date.now() - 1e3 * this.totalSeconds / (this.playbackSpeed * this.scenePlaybackSpeed));
  4294. var t = (Date.now() - this.startMS) / 1e3 * this.playbackSpeed * this.scenePlaybackSpeed;
  4295. this.totalSeconds = (Date.now() - this.startMS) / 1e3 * this.playbackSpeed * this.scenePlaybackSpeed;
  4296. var i = (i = t / e.totalSeconds) - (t = Math.floor(i));
  4297. t != this.loopCount && (this.loopCount++,
  4298. this.loopTurntables && this.rolloverTurntables(),
  4299. this.autoAdvanceNextAnimation && (this.nextAnimation(),
  4300. this.resetPlayback())),
  4301. this.totalSeconds = e.totalSeconds * i,
  4302. this.animationProgress = this.totalSeconds / e.totalSeconds - Math.floor(this.totalSeconds / e.totalSeconds),
  4303. this.updateScene(),
  4304. this.runDebugMode && this.checkDebug()
  4305. }
  4306. }
  4307. }
  4308. ,
  4309. P.prototype.updateScene = function() {
  4310. this.lastSceneFramePercent = this.totalSeconds * this.animations[this.selectedAnimationIndex].originalFPS,
  4311. 0 != this.fogObjectIndex && this.updateFog(),
  4312. this.animateTurntables && this.updateTurntables(),
  4313. this.animateMeshes && this.poseMeshes(),
  4314. this.animateLights && this.updateLights(),
  4315. this.animateMaterials && this.updateMaterials(),
  4316. this.animateVisibility && this.updateVisibility()
  4317. }
  4318. ,
  4319. P.prototype.findCameraChildren = function() {
  4320. for (var e = this.animations[0], t = e.animatedObjects.length, i = 0; i < t; i++)
  4321. e.hasParentTypeInHierarchy(e.animatedObjects[i], "CameraSO") && this.cameraChildrenIndices.push(i)
  4322. }
  4323. ,
  4324. P.prototype.findFixedTransforms = function() {
  4325. for (var e = this.animations.length, t = 0; t < e; t++)
  4326. for (var i = this.animations[t], s = i.animatedObjects.length, n = 0; n < s; n++) {
  4327. var r = i.animatedObjects[n];
  4328. if (!r.useFixedWorldTransform && !i.hasAnimationInHierarchy(r))
  4329. if ("Material" == r.sceneObjectType)
  4330. r.setFixedWorldTransform(S.identity()),
  4331. r.setFixedLocalTransform(S.identity());
  4332. else {
  4333. var a = S.identity()
  4334. , o = S.identity();
  4335. i.hasParentTypeInHierarchy(r, "SceneRootSO") ? (i.getWorldTransform(r.id, 0, a, this.sceneScale, !1),
  4336. r.evaluateLocalTransformAtFramePercent(0, o, !0, !1)) : (i.evaluateModelPartTransformAtFrame(r.id, 0, a, !1),
  4337. r.evaluateLocalTransformAtFramePercent(0, o, !1, !1)),
  4338. r.setFixedWorldTransform(a),
  4339. r.setFixedLocalTransform(o)
  4340. }
  4341. }
  4342. }
  4343. ,
  4344. P.prototype.clearCacheForCameraChildren = function() {
  4345. for (var e = this.animations[this.selectedAnimationIndex], t = this.cameraChildrenIndices.length, i = 0; i < t; i++) {
  4346. var s = e.animatedObjects[this.cameraChildrenIndices[i]];
  4347. s.useFixedWorldTransform = !1,
  4348. s.useFixedLocalTransform = !1,
  4349. s.cachedFrame0 = -10,
  4350. s.cachedFrame1 = -10,
  4351. s.cachedFrame2 = -10,
  4352. s.cachedFrame3 = -10,
  4353. s.cachedFrameUse0 = 0,
  4354. s.cachedFrameUse1 = 0,
  4355. s.cachedFrameUse2 = 0,
  4356. s.cachedFrameUse3 = 0,
  4357. s.animatedLocalTransform.clearCachedTransforms(),
  4358. s.animatedLocalTransform.lockTransform = !1
  4359. }
  4360. }
  4361. ,
  4362. P.prototype.refreshTransformsOnly = function() {
  4363. for (var e = this.animations[this.selectedAnimationIndex], t = e.meshObjects.length, i = 0; i < t; i++) {
  4364. var s = e.meshObjects[i];
  4365. if (e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0),
  4366. this.enableSkinning && s.skinningRig && this.unitScaleSkinnedMeshes && !s.skinningRig.isRigidSkin) {
  4367. var n = (s = s.mesh.displayMatrix)[0]
  4368. , r = s[1]
  4369. , a = s[2]
  4370. , o = s[4]
  4371. , h = s[5]
  4372. , l = s[6]
  4373. , d = s[8]
  4374. , c = s[9]
  4375. , u = s[10];
  4376. d = ((n = Math.sqrt(n * n + r * r + a * a)) + (o = Math.sqrt(o * o + h * h + l * l)) + (d = Math.sqrt(d * d + c * c + u * u))) / 2;
  4377. s[0] /= d,
  4378. s[1] /= d,
  4379. s[2] /= d,
  4380. s[4] /= d,
  4381. s[5] /= d,
  4382. s[6] /= d,
  4383. s[8] /= d,
  4384. s[9] /= d,
  4385. s[10] /= d
  4386. }
  4387. }
  4388. if (this.animateLights)
  4389. for (t = e.lightObjects.length,
  4390. i = 0; i < t; i++)
  4391. (s = e.lightObjects[i]).useFixedWorldTransform || (d = this.scene.lights.getLightPos(s.lightIndex),
  4392. c = this.scene.lights.getLightDir(s.lightIndex),
  4393. u = S.identity(),
  4394. e.getWorldTransform(s.id, this.totalSeconds, u, this.sceneScale, !0),
  4395. c[0] = u[8],
  4396. c[1] = u[9],
  4397. c[2] = u[10],
  4398. 0 != d[3] && (d[0] = u[12],
  4399. d[1] = u[13],
  4400. d[2] = u[14],
  4401. this.scene.lights.setLightPos(s.lightIndex, d)),
  4402. this.scene.lights.setLightDir(s.lightIndex, c))
  4403. }
  4404. ,
  4405. P.prototype.findMeshIndexByPartIndex = function(e, t) {
  4406. for (var i = 0; i < this.meshIDs.length; ++i)
  4407. if (t == this.meshIDs[i])
  4408. return i;
  4409. return -1
  4410. }
  4411. ,
  4412. P.prototype.findLightIndexByPartIndex = function(e) {
  4413. for (var t = 0; t < this.lightIDs.length; t++)
  4414. if (e == this.lightIDs[t])
  4415. return t;
  4416. return -1
  4417. }
  4418. ,
  4419. P.prototype.findMaterialIndexByPartIndex = function(e) {
  4420. for (var t = 0; t < this.materialIDs.length; t++)
  4421. if (e == this.materialIDs[t])
  4422. return t;
  4423. return -1
  4424. }
  4425. ,
  4426. P.prototype.nextAnimation = function() {
  4427. this.selectedAnimationIndex++,
  4428. this.selectedAnimationIndex >= this.animations.length && (this.selectedAnimationIndex = 0)
  4429. }
  4430. ,
  4431. P.prototype.selectAnimation = function(e) {
  4432. 0 <= e && e < this.animations.length && (this.selectedAnimationIndex = e),
  4433. this.paused && this.setAnimationProgress(this.animationProgress, !0)
  4434. }
  4435. ,
  4436. P.prototype.selectCamera = function(e) {
  4437. -1 != e && this.selectedCameraIndex != e && (this.selectedCameraIndex = e,
  4438. this.setViewFromSelectedCamera())
  4439. }
  4440. ,
  4441. P.prototype.getAnimatedCamera = function() {
  4442. if (0 <= this.selectedCameraIndex && this.selectedAnimationIndex < this.animations.length) {
  4443. var e = this.animations[this.selectedAnimationIndex];
  4444. if (this.selectedCameraIndex < e.cameraObjects.length)
  4445. return e.cameraObjects[this.selectedCameraIndex]
  4446. }
  4447. }
  4448. ,
  4449. P.prototype.poseMeshes = function() {
  4450. for (var e = this.animations[this.selectedAnimationIndex], t = e.meshObjects.length, i = 0; i < t; i++) {
  4451. var s = e.meshObjects[i];
  4452. if (this.enableSkinning && s.skinningRig)
  4453. if (s.skinningRig.isRigidSkin)
  4454. e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0);
  4455. else {
  4456. s.setupSkinningRig(e, s.modelPartIndex, this.totalSeconds, s.skinningRig),
  4457. e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0);
  4458. var n = s.modelPartScale * this.sceneScale;
  4459. if (this.unitScaleSkinnedMeshes) {
  4460. var r = s.mesh.displayMatrix
  4461. , a = r[0]
  4462. , o = r[1]
  4463. , h = r[2]
  4464. , l = r[4]
  4465. , d = r[5]
  4466. , c = r[6]
  4467. , u = r[8]
  4468. , f = r[9]
  4469. , m = r[10];
  4470. u = ((a = Math.sqrt(a * a + o * o + h * h)) + (l = Math.sqrt(l * l + d * d + c * c)) + (u = Math.sqrt(u * u + f * f + m * m))) / 2;
  4471. r[0] /= u,
  4472. r[1] /= u,
  4473. r[2] /= u,
  4474. r[4] /= u,
  4475. r[5] /= u,
  4476. r[6] /= u,
  4477. r[8] /= u,
  4478. r[9] /= u,
  4479. r[10] /= u,
  4480. n *= u
  4481. }
  4482. s.skinningRig.deformMesh(s.mesh, n)
  4483. }
  4484. else
  4485. e.getWorldTransform(s.id, this.totalSeconds, s.mesh.displayMatrix, this.sceneScale, !0)
  4486. }
  4487. }
  4488. ,
  4489. P.prototype.updateLights = function() {
  4490. for (var e = this.animations[this.selectedAnimationIndex], t = this.totalSeconds * e.originalFPS, i = e.lightObjects.length, s = 0; s < i; s++) {
  4491. var n = e.lightObjects[s]
  4492. , r = this.scene.lights.getLightPos(n.lightIndex)
  4493. , a = this.scene.lights.getLightDir(n.lightIndex)
  4494. , o = this.scene.lights.getLightColor(n.lightIndex)
  4495. , h = S.identity()
  4496. , l = 1;
  4497. n.useFixedWorldTransform || e.getWorldTransform(n.id, this.totalSeconds, h, this.sceneScale, !0),
  4498. n.redProperty && (n.redProperty.evaluate(t, o[0], n),
  4499. o[0] = n.redProperty.lastValue),
  4500. n.greenProperty && (n.greenProperty.evaluate(t, o[1], n),
  4501. o[1] = n.greenProperty.lastValue),
  4502. n.blueProperty && (n.blueProperty.evaluate(t, o[2], n),
  4503. o[2] = n.blueProperty.lastValue),
  4504. n.brightnessProperty && (n.brightnessProperty.evaluate(t, l, n),
  4505. l = n.brightnessProperty.lastValue),
  4506. o[0] *= l,
  4507. o[1] *= l,
  4508. o[2] *= l,
  4509. 0 != r[3] && (n.useFixedWorldTransform || (r[0] = h[12],
  4510. r[1] = h[13],
  4511. r[2] = h[14],
  4512. this.scene.lights.setLightPos(n.lightIndex, r)),
  4513. n.spotAngleProperty && 0 < this.scene.lights.spot[3 * n.lightIndex] && (r = 0,
  4514. n.spotAngleProperty.evaluate(t, r, n),
  4515. r = n.spotAngleProperty.lastValue,
  4516. this.scene.lights.setLightSpotAngle(n.lightIndex, r)),
  4517. n.spotSharpnessProperty && (r = 0,
  4518. n.spotSharpnessProperty.evaluate(t, r, n),
  4519. r = n.spotSharpnessProperty.lastValue,
  4520. this.scene.lights.setLightSpotSharpness(n.lightIndex, r)),
  4521. n.distanceProperty && (r = 1,
  4522. n.distanceProperty.evaluate(t, r, n),
  4523. r = n.distanceProperty.lastValue * this.sceneScale,
  4524. this.scene.lights.setLightDistance(n.lightIndex, r))),
  4525. n.useFixedWorldTransform || (a[0] = h[8],
  4526. a[1] = h[9],
  4527. a[2] = h[10],
  4528. this.scene.lights.setLightDir(n.lightIndex, a)),
  4529. this.scene.lights.setLightColor(n.lightIndex, o)
  4530. }
  4531. }
  4532. ,
  4533. P.prototype.updateTurntables = function() {
  4534. for (var e = this.animations[this.selectedAnimationIndex], t = this.totalSeconds * e.originalFPS, i = e.turnTableObjects.length, s = 0; s < i; s++) {
  4535. var n = e.turnTableObjects[s];
  4536. n.spinProperty.evaluate(t, 0, n),
  4537. n.turnTableSpin = n.turnTableSpinOffset + n.spinProperty.lastValue * this.totalSeconds
  4538. }
  4539. }
  4540. ,
  4541. P.prototype.rolloverTurntables = function() {
  4542. for (var e = this.animations[this.selectedAnimationIndex], t = e.turnTableObjects.length, i = 0; i < t; i++) {
  4543. var s = e.turnTableObjects[i];
  4544. s.turnTableSpinOffset = s.turnTableSpin
  4545. }
  4546. }
  4547. ,
  4548. P.prototype.updateMaterials = function() {
  4549. for (var e = this.animations[this.selectedAnimationIndex], t = this.totalSeconds * e.originalFPS, i = e.materialObjects.length, s = 0; s < i; s++) {
  4550. var n = e.materialObjects[s];
  4551. n.offsetUProperty && (n.offsetUProperty.evaluate(t, 0, n),
  4552. this.scene.materialsList[n.materialIndex].uOffset = n.offsetUProperty.lastValue),
  4553. n.offsetVProperty && (n.offsetVProperty.evaluate(t, 0, n),
  4554. this.scene.materialsList[n.materialIndex].vOffset = n.offsetVProperty.lastValue),
  4555. n.emissiveProperty && 1 < n.emissiveProperty.numKeyframes && (n.emissiveProperty.evaluate(t, 0, n),
  4556. this.scene.materialsList[n.materialIndex].emissiveIntensity = n.emissiveProperty.lastValue)
  4557. }
  4558. }
  4559. ,
  4560. P.prototype.updateFog = function() {
  4561. var e = this.animations[this.selectedAnimationIndex]
  4562. , t = this.totalSeconds * e.originalFPS;
  4563. 0 <= this.fogObjectIndex && this.fogObjectIndex < e.animatedObjects.length && this.scene.fog && ((e = e.animatedObjects[this.fogObjectIndex]).redProperty && (this.scene.fog.desc.color[0] = e.redProperty.evaluate(t, this.scene.fog.desc.color[0], e)),
  4564. e.greenProperty && (this.scene.fog.desc.color[1] = e.greenProperty.evaluate(t, this.scene.fog.desc.color[1], e)),
  4565. e.blueProperty && (this.scene.fog.desc.color[2] = e.blueProperty.evaluate(t, this.scene.fog.desc.color[2], e)),
  4566. e.distanceProperty && (this.scene.fog.desc.distance = e.distanceProperty.evaluate(t, this.scene.fog.desc.distance, e)),
  4567. e.opacityProperty && (this.scene.fog.desc.opacity = e.opacityProperty.evaluate(t, this.scene.fog.desc.opacity, e)),
  4568. e.skyIllumProperty && (this.scene.fog.desc.skyIllum = e.skyIllumProperty.evaluate(t, this.scene.fog.desc.skyIllum, e)),
  4569. e.lightIllumProperty && (this.scene.fog.desc.lightIllum = e.lightIllumProperty.evaluate(t, this.scene.fog.desc.lightIllum, e)),
  4570. e.dispersionProperty && (this.scene.fog.desc.dispersion = e.dispersionProperty.evaluate(t, this.scene.fog.desc.dispersion, e)))
  4571. }
  4572. ,
  4573. P.prototype.updateVisibility = function() {
  4574. for (var e = this.animations[this.selectedAnimationIndex], t = this.subMeshObjectIndices.length, i = 0; i < t; i++) {
  4575. if (-1 != (n = this.subMeshLiveIndices[i])) {
  4576. var s = this.subMeshObjectIndices[i]
  4577. , n = this.scene.meshRenderables[n]
  4578. , r = e.getObjectAnimationFramePercent(e.animatedObjects[s], this.totalSeconds);
  4579. n.visible = e.isVisibleAtFramePercent(s, r)
  4580. }
  4581. }
  4582. }
  4583. ,
  4584. F.prototype.build = function(e, t) {
  4585. var i = this.gl;
  4586. this.program = i.createProgram(),
  4587. this.params = {},
  4588. this.samplers = {},
  4589. this.attribs = {};
  4590. var s = function(e) {
  4591. for (var t = "", i = e.indexOf("\n"), s = 0; -1 != i; )
  4592. t += ++s + ": ",
  4593. t += e.substring(0, i + 1),
  4594. i = (e = e.substring(i + 1, e.length)).indexOf("\n");
  4595. console.log(t)
  4596. }
  4597. , n = i.createShader(i.VERTEX_SHADER);
  4598. i.shaderSource(n, e),
  4599. i.compileShader(n),
  4600. i.getShaderParameter(n, i.COMPILE_STATUS) || (console.log(i.getShaderInfoLog(n)),
  4601. I.verboseErrors && s(e)),
  4602. i.attachShader(this.program, n),
  4603. n = i.createShader(i.FRAGMENT_SHADER),
  4604. i.shaderSource(n, t),
  4605. i.compileShader(n),
  4606. i.getShaderParameter(n, i.COMPILE_STATUS) || (console.log(i.getShaderInfoLog(n)),
  4607. I.verboseErrors && s(t)),
  4608. i.attachShader(this.program, n),
  4609. i.linkProgram(this.program),
  4610. i.getProgramParameter(this.program, i.LINK_STATUS) || console.log(i.getProgramInfoLog(this.program));
  4611. n = i.getProgramParameter(this.program, i.ACTIVE_UNIFORMS);
  4612. var r = 0;
  4613. for (s = 0; s < n; ++s) {
  4614. var a = i.getActiveUniform(this.program, s)
  4615. , o = a.name
  4616. , h = o.indexOf("[");
  4617. 0 <= h && (o = o.substring(0, h)),
  4618. h = i.getUniformLocation(this.program, a.name),
  4619. a.type == i.SAMPLER_2D || a.type == i.SAMPLER_CUBE ? this.samplers[o] = {
  4620. location: h,
  4621. unit: r++
  4622. } : this.params[o] = h
  4623. }
  4624. for (n = i.getProgramParameter(this.program, i.ACTIVE_ATTRIBUTES),
  4625. s = 0; s < n; ++s)
  4626. r = i.getActiveAttrib(this.program, s),
  4627. this.attribs[r.name] = i.getAttribLocation(this.program, r.name)
  4628. }
  4629. ,
  4630. F.prototype.bind = function() {
  4631. return !!this.program && (this.gl.useProgram(this.program),
  4632. !0)
  4633. }
  4634. ,
  4635. F.prototype.complete = function() {
  4636. return !!this.program
  4637. }
  4638. ,
  4639. O.prototype.fromURLs = function(e, t, i) {
  4640. var s = "";
  4641. if (i)
  4642. for (var n = 0; n < i.length; ++n)
  4643. s = i[n] + "\n" + s;
  4644. if (i = s + ":" + e + "|" + t,
  4645. void 0 !== (n = this.cache[i]))
  4646. return n;
  4647. function r() {
  4648. null != o && null != h && a.build(o, h)
  4649. }
  4650. var a = new F(this.gl)
  4651. , o = null
  4652. , h = null;
  4653. return this.fetch(e, function(e) {
  4654. o = s + e,
  4655. r()
  4656. }),
  4657. this.fetch(t, function(e) {
  4658. h = s + e,
  4659. r()
  4660. }),
  4661. this.cache[i] = a
  4662. }
  4663. ,
  4664. O.prototype.fetch = function(e, t) {
  4665. void 0 !== G ? void 0 !== G[e] ? this.resolveIncludes(new String(G[e]), t) : t("") : C.fetchText("src/shader/" + e, function(e) {
  4666. this.resolveIncludes(e, t)
  4667. }
  4668. .bind(this), function() {
  4669. t("")
  4670. })
  4671. }
  4672. ,
  4673. O.prototype.resolveIncludes = function(t, i) {
  4674. for (var r = [], a = !0, e = function(e, t, i, s, n) {
  4675. return a = !0,
  4676. r.push({
  4677. offset: n,
  4678. path: t.slice(1, t.length - 1)
  4679. }),
  4680. ""
  4681. }; a; )
  4682. a = !1,
  4683. t = t.replace(/#include\s((<[^>]+>)|("[^"]+"))/, e);
  4684. if (0 < r.length) {
  4685. var s = r.length;
  4686. for (e = 0; e < r.length; ++e)
  4687. this.fetch(r[e].path, function(e) {
  4688. if (this.src = e,
  4689. --s <= 0) {
  4690. for (e = r.length - 1; 0 <= e; --e)
  4691. t = t.substring(0, r[e].offset) + r[e].src + t.substring(r[e].offset);
  4692. i(t)
  4693. }
  4694. }
  4695. .bind(r[e]))
  4696. } else
  4697. i(t)
  4698. }
  4699. ,
  4700. E.prototype.bindDepthTexture = function(e, t) {
  4701. this.shadowCount > t && this.depthTextures[t].bind(e)
  4702. }
  4703. ,
  4704. E.prototype.collect = function(e, t) {
  4705. for (var i = this.gl, s = e.lights, n = s.shadowCount, r = s.modelViewBuffer, a = s.projectionBuffer, o = s.matrix, h = 0 != e.sceneAnimator, l = S.empty(), d = !1, c = 0; c < n; ++c)
  4706. if (s.shadowsNeedUpdate[c]) {
  4707. d = !(s.shadowsNeedUpdate[c] = 0),
  4708. S.mul(l, r.subarray(16 * c, 16 * (c + 1)), o),
  4709. S.mul(l, a.subarray(16 * c, 16 * (c + 1)), l),
  4710. this.depthTargets[c].bind(),
  4711. i.clearColor(1, 1, 1, 1),
  4712. i.clear(i.COLOR_BUFFER_BIT | i.DEPTH_BUFFER_BIT);
  4713. var u = this.shaderSolid;
  4714. u.bind(),
  4715. i.uniformMatrix4fv(u.params.uViewProjection, !1, l),
  4716. i.uniformMatrix4fv(u.params.uMeshTransform, !1, S.identity());
  4717. for (var f = 0; f < e.meshRenderables.length; ++f) {
  4718. var m = e.meshRenderables[f]
  4719. , p = m.material;
  4720. !m.mesh.desc.castShadows || !p.castShadows || 0 < p.shadowAlphaTest || (h && i.uniformMatrix4fv(u.params.uMeshTransform, !1, m.mesh.displayMatrix),
  4721. m.drawShadow(u.attribs.vPosition))
  4722. }
  4723. for ((u = this.shaderAlphaTest).bind(),
  4724. i.uniformMatrix4fv(u.params.uViewProjection, !1, l),
  4725. i.uniformMatrix4fv(u.params.uMeshTransform, !1, S.identity()),
  4726. f = 0; f < e.meshRenderables.length; ++f)
  4727. p = (m = e.meshRenderables[f]).material,
  4728. m.mesh.desc.castShadows && p.castShadows && 0 < p.shadowAlphaTest && (p.textures.albedo.bind(u.samplers.tAlbedo),
  4729. h && (i.uniform2f(u.params.uUVOffset, p.uOffset, p.vOffset),
  4730. i.uniformMatrix4fv(u.params.uMeshTransform, !1, m.mesh.displayMatrix)),
  4731. m.drawAlphaShadow(u.attribs.vPosition, u.attribs.vTexCoord))
  4732. }
  4733. d && (t.bind(),
  4734. i.enable(i.CULL_FACE),
  4735. i.cullFace(i.BACK))
  4736. }
  4737. ,
  4738. E.prototype.complete = function() {
  4739. return this.shaderSolid.complete() && this.shaderAlphaTest.complete()
  4740. }
  4741. ,
  4742. B.prototype.draw = function(e) {
  4743. var t = e.view
  4744. , i = e.lights
  4745. , s = e.shadow
  4746. , n = this.gl
  4747. , r = this.shader.params
  4748. , a = this.shader.samplers;
  4749. this.shader.bind(),
  4750. t = S.mul(S.empty(), t.projectionMatrix, t.viewMatrix),
  4751. S.mul(t, t, this.desc.transform),
  4752. n.uniformMatrix4fv(r.uModelViewProjectionMatrix, !1, t),
  4753. t = S.mul(S.empty(), i.matrix, this.desc.transform),
  4754. n.uniformMatrix4fv(r.uModelSkyMatrix, !1, t),
  4755. 0 < i.count && (n.uniform4fv(r.uLightPositions, i.positionBuffer),
  4756. n.uniform3fv(r.uLightDirections, i.directionBuffer),
  4757. n.uniform3fv(r.uLightColors, i.colors),
  4758. n.uniform3fv(r.uLightParams, i.parameters),
  4759. n.uniform3fv(r.uLightSpot, i.spot),
  4760. e = .392699 * e.postRender.currentSample(),
  4761. n.uniform2f(r.uShadowKernelRotation, .5 * Math.cos(e), .5 * Math.sin(e)),
  4762. 0 < i.shadowCount && (e = s.depthTextures[0].desc.width,
  4763. n.uniform2f(r.uShadowMapSize, e, 1 / e),
  4764. n.uniformMatrix4fv(r.uShadowMatrices, !1, i.finalTransformBuffer),
  4765. n.uniformMatrix4fv(r.uInvShadowMatrices, !1, i.inverseTransformBuffer),
  4766. n.uniform4fv(r.uShadowTexelPadProjections, i.shadowTexelPadProjections),
  4767. s.bindDepthTexture(a.tDepth0, 0),
  4768. s.bindDepthTexture(a.tDepth1, 1),
  4769. s.bindDepthTexture(a.tDepth2, 2))),
  4770. n.uniform3f(r.uShadowCatcherParams, this.desc.simple ? 1 : 0, this.desc.alpha, this.desc.edgeFade),
  4771. n.depthMask(!1),
  4772. n.enable(n.BLEND),
  4773. n.blendFunc(n.ZERO, n.SRC_COLOR),
  4774. i = this.shader.attribs.vPosition,
  4775. n.bindBuffer(n.ARRAY_BUFFER, this.quadGeom),
  4776. n.enableVertexAttribArray(i),
  4777. n.vertexAttribPointer(i, 3, n.FLOAT, !1, 0, 0),
  4778. n.drawArrays(n.TRIANGLES, 0, 6),
  4779. n.disableVertexAttribArray(i),
  4780. n.bindBuffer(n.ARRAY_BUFFER, null),
  4781. n.disable(n.BLEND),
  4782. n.depthMask(!0)
  4783. }
  4784. ,
  4785. B.prototype.complete = function() {
  4786. return this.shader.complete()
  4787. }
  4788. ,
  4789. L.prototype.solveAdditiveClusterTransform = function(e, t, i) {
  4790. t = S.identity();
  4791. var s = S.identity()
  4792. , n = S.identity();
  4793. S.mul(t, e, this.defaultClusterBaseTransform),
  4794. S.mul(s, this.defaultAssociateWorldTransformInvert, t),
  4795. S.mul(n, this.defaultAssociateWorldTransformInvert, s),
  4796. S.mul(i, this.defaultClusterWorldTransformInvert, n)
  4797. }
  4798. ,
  4799. L.prototype.solveSimpleClusterTransform = function(e, t, i) {
  4800. var s = S.identity()
  4801. , n = S.identity();
  4802. S.invert(n, t),
  4803. S.mul(s, n, e),
  4804. S.mul(i, s, this.defaultClusterBaseTransform)
  4805. }
  4806. ,
  4807. L.prototype.solveClusterTransformAtFrame = function(e, t, i, s) {
  4808. if (1 == this.linkMode) {
  4809. var n = S.identity();
  4810. t = S.identity(),
  4811. e.evaluateModelPartTransformAtFrame(this.linkObjectIndex, i, n, !1),
  4812. e.evaluateModelPartTransformAtFrame(this.associateObjectIndex, i, t, !1),
  4813. this.solveAdditiveClusterTransform(n, t, s)
  4814. } else {
  4815. n = S.identity();
  4816. var r = S.identity();
  4817. e.evaluateModelPartTransformAtFrame(this.linkObjectIndex, i, n, !1),
  4818. e.evaluateModelPartTransformAtFrame(t, i, r, !1),
  4819. this.solveSimpleClusterTransform(n, r, s)
  4820. }
  4821. }
  4822. ,
  4823. M.prototype.unpackUnitVectors = function(e, t, i, s) {
  4824. for (var n = 0; n < i; n++) {
  4825. var r = t[s * n]
  4826. , a = 32768 <= (o = t[s * n + 1]);
  4827. a && (o -= 32768);
  4828. var o, h = 1 - ((r = r / 32767.4 * 2 - 1) * r + (o = o / 32767.4 * 2 - 1) * o);
  4829. h = Math.sqrt(h),
  4830. h = isNaN(h) ? 0 : h;
  4831. a && (h = -h),
  4832. e[3 * n] = r,
  4833. e[3 * n + 1] = o,
  4834. e[3 * n + 2] = h
  4835. }
  4836. }
  4837. ,
  4838. M.prototype.copyOriginalVertices = function(e) {
  4839. if (!this.unTransformedVertices)
  4840. if (this.unTransformedVertices = new Float32Array(3 * e.vertexCount),
  4841. this.unTransformedNormals = new Float32Array(3 * e.vertexCount),
  4842. this.unTransformedTangents = new Float32Array(3 * e.vertexCount),
  4843. this.unTransformedBiTangents = new Float32Array(3 * e.vertexCount),
  4844. this.skinVertexWeights = new Float32Array(e.vertexCount),
  4845. this.skinVertexTransform4x3 = new Float32Array(12),
  4846. e.dynamicVertexData) {
  4847. var t = new Float32Array(e.dynamicVertexData.buffer);
  4848. new Uint8Array(e.dynamicVertexData.buffer);
  4849. var i = s = 0
  4850. , s = s + 12 + 8;
  4851. e.secondaryTexCoord && (s += 8);
  4852. var n = s
  4853. , r = s += 4
  4854. , a = (s = s + 4,
  4855. e.stride / 2);
  4856. s = new Uint8Array(e.dynamicVertexData.subarray(s)),
  4857. s = new Uint16Array(s.buffer),
  4858. n = new Uint8Array(e.dynamicVertexData.subarray(n)),
  4859. n = new Uint16Array(n.buffer),
  4860. r = new Uint8Array(e.dynamicVertexData.subarray(r)),
  4861. r = new Uint16Array(r.buffer);
  4862. for (this.unpackUnitVectors(this.unTransformedNormals, s, e.vertexCount, a),
  4863. this.unpackUnitVectors(this.unTransformedTangents, n, e.vertexCount, a),
  4864. this.unpackUnitVectors(this.unTransformedBiTangents, r, e.vertexCount, a),
  4865. a = 0; a < e.vertexCount; a++)
  4866. r = (e.stride * a + i) / 4,
  4867. this.unTransformedVertices[3 * a] = t[r],
  4868. this.unTransformedVertices[3 * a + 1] = t[r + 1],
  4869. this.unTransformedVertices[3 * a + 2] = t[r + 2]
  4870. } else
  4871. this.debugString += "<br>Can't init skinning rig - mesh buffer is not dynamic - rigid is " + this.isRigidSkin
  4872. }
  4873. ,
  4874. M.prototype.useOriginalMeshVertices = function(e) {
  4875. this.isRigidSkin ? this.debugString += "<br>useOriginalMeshVertices for rigid skin?" : this.copyOriginalVertices(e)
  4876. }
  4877. ,
  4878. M.prototype.deformMeshVertices = function(e, t) {
  4879. if (0 != this.skinningClusters.length && this.unTransformedVertices) {
  4880. var i, s = e.stride / 4, n = new Float32Array(e.dynamicVertexData.buffer), r = new Uint16Array(e.dynamicVertexData.buffer);
  4881. new Uint8Array(e.dynamicVertexData.buffer),
  4882. i = 20,
  4883. e.secondaryTexCoord && (i += 8);
  4884. var a = i
  4885. , o = i += 4;
  4886. i += 4;
  4887. for (var h = this.unTransformedVertices.length / 3, l = 0, d = 0; d < h; ++d) {
  4888. var c = d
  4889. , u = (c * e.stride + a) / 2
  4890. , f = (c * e.stride + o) / 2
  4891. , m = (c * e.stride + i) / 2
  4892. , p = this.linkMapCount[c];
  4893. (k = this.skinVertexTransform4x3)[this.skinVertexWeights[c] = 0] = 0,
  4894. k[1] = 0,
  4895. k[2] = 0,
  4896. k[3] = 0,
  4897. k[4] = 0,
  4898. k[5] = 0,
  4899. k[6] = 0,
  4900. k[7] = 0,
  4901. k[8] = 0,
  4902. k[9] = 0,
  4903. k[10] = 0,
  4904. k[11] = 0;
  4905. var g = this.linkMapWeights[l];
  4906. if (1 == p && 1 == g) {
  4907. var v = this.linkMapClusterIndices[l]
  4908. , x = (v = this.skinningClusters[v]).matrix;
  4909. k[0] = x[0],
  4910. k[1] = x[1],
  4911. k[2] = x[2],
  4912. k[3] = x[4],
  4913. k[4] = x[5],
  4914. k[5] = x[6],
  4915. k[6] = x[8],
  4916. k[7] = x[9],
  4917. k[8] = x[10],
  4918. k[9] = x[12],
  4919. k[10] = x[13],
  4920. k[11] = x[14],
  4921. this.skinVertexWeights[c] = 1
  4922. } else
  4923. for (var y = this.skinVertexWeights[c] = 0; y < p; y++)
  4924. g = this.linkMapWeights[l + y],
  4925. (v = this.linkMapClusterIndices[l + y]) < this.skinningClusters.length && (x = (v = this.skinningClusters[v]).matrix,
  4926. k[0] += g * x[0],
  4927. k[1] += g * x[1],
  4928. k[2] += g * x[2],
  4929. k[3] += g * x[4],
  4930. k[4] += g * x[5],
  4931. k[5] += g * x[6],
  4932. k[6] += g * x[8],
  4933. k[7] += g * x[9],
  4934. k[8] += g * x[10],
  4935. k[9] += g * x[12],
  4936. k[10] += g * x[13],
  4937. k[11] += g * x[14],
  4938. this.skinVertexWeights[c] += g,
  4939. 1 == v.linkMode && (this.skinVertexWeights[c] = 1));
  4940. if (l += this.linkMapCount[d],
  4941. 0 < this.skinVertexWeights[c]) {
  4942. var b = this.unTransformedVertices[3 * d + 0]
  4943. , S = this.unTransformedVertices[3 * d + 1]
  4944. , T = this.unTransformedVertices[3 * d + 2]
  4945. , w = this.unTransformedNormals[3 * d + 0]
  4946. , C = this.unTransformedNormals[3 * d + 1]
  4947. , R = this.unTransformedNormals[3 * d + 2]
  4948. , A = (v = this.unTransformedTangents[3 * d + 0],
  4949. x = this.unTransformedTangents[3 * d + 1],
  4950. this.unTransformedTangents[3 * d + 2])
  4951. , k = (p = this.unTransformedBiTangents[3 * d + 0],
  4952. this.unTransformedBiTangents[3 * d + 1])
  4953. , I = (g = this.unTransformedBiTangents[3 * d + 2],
  4954. y = this.skinVertexTransform4x3,
  4955. 1);
  4956. 0 < this.skinVertexWeights[c] && (I = 1 / this.skinVertexWeights[c]),
  4957. n[s * d] = I * (b * y[0] + S * y[3] + T * y[6] + y[9]) * t,
  4958. n[s * d + 1] = I * (b * y[1] + S * y[4] + T * y[7] + y[10]) * t,
  4959. n[s * d + 2] = I * (b * y[2] + S * y[5] + T * y[8] + y[11]) * t,
  4960. b = w * y[0] + C * y[3] + R * y[6],
  4961. c = w * y[1] + C * y[4] + R * y[7],
  4962. w = w * y[2] + C * y[5] + R * y[8],
  4963. C = v * y[0] + x * y[3] + A * y[6],
  4964. R = v * y[1] + x * y[4] + A * y[7],
  4965. v = v * y[2] + x * y[5] + A * y[8],
  4966. x = p * y[0] + k * y[3] + g * y[6],
  4967. A = p * y[1] + k * y[4] + g * y[7],
  4968. p = p * y[2] + k * y[5] + g * y[8],
  4969. c /= k = Math.sqrt(b * b + c * c + w * w),
  4970. w /= k,
  4971. k = 32767.4 * ((b /= k) / 2 + .5),
  4972. g = 32767.4 * (c / 2 + .5),
  4973. w < 0 && (g += 32768),
  4974. r[m] = Math.floor(k),
  4975. r[1 + m] = Math.floor(g),
  4976. R /= k = Math.sqrt(C * C + R * R + v * v),
  4977. v /= k,
  4978. k = 32767.4 * ((C /= k) / 2 + .5),
  4979. g = 32767.4 * (R / 2 + .5),
  4980. v < 0 && (g += 32768),
  4981. r[u] = Math.floor(k),
  4982. r[1 + u] = Math.floor(g),
  4983. A /= k = Math.sqrt(x * x + A * A + p * p),
  4984. p /= k,
  4985. k = 32767.4 * ((x /= k) / 2 + .5),
  4986. g = 32767.4 * (A / 2 + .5),
  4987. p < 0 && (g += 32768),
  4988. r[f] = Math.floor(k),
  4989. r[1 + f] = Math.floor(g)
  4990. } else
  4991. b = this.unTransformedVertices[3 * d + 0],
  4992. S = this.unTransformedVertices[3 * d + 1],
  4993. T = this.unTransformedVertices[3 * d + 2],
  4994. n[s * d] = b * t,
  4995. n[s * d + 1] = S * t,
  4996. n[s * d + 2] = T * t
  4997. }
  4998. }
  4999. }
  5000. ,
  5001. M.prototype.deformMesh = function(e, t) {
  5002. if (0 != this.skinningClusters.length && !this.isRigidSkin) {
  5003. this.deformMeshVertices(e, t);
  5004. var i = e.gl;
  5005. i.bindBuffer(i.ARRAY_BUFFER, e.vertexBuffer),
  5006. i.bufferData(i.ARRAY_BUFFER, e.dynamicVertexData, i.DYNAMIC_DRAW),
  5007. i.bindBuffer(i.ARRAY_BUFFER, null)
  5008. }
  5009. }
  5010. ,
  5011. _.prototype.setClearColor = function() {
  5012. if (I.transparentBackground)
  5013. this.gl.clearColor(0, 0, 0, 0);
  5014. else if (this.backgroundMode < 1) {
  5015. var e = this.backgroundColor;
  5016. this.gl.clearColor(e[0], e[1], e[2], 1)
  5017. } else
  5018. this.gl.clearColor(.0582, .06772, .07805, 1)
  5019. }
  5020. ,
  5021. _.prototype.draw = function(e) {
  5022. if (this.backgroundMode < 1 || I.transparentBackground)
  5023. return !1;
  5024. if (this.complete()) {
  5025. var t = this.gl
  5026. , i = this.backgroundShader
  5027. , s = e.view
  5028. , n = e.lights.invMatrix;
  5029. i.bind(),
  5030. t.uniformMatrix4fv(i.params.uInverseSkyMatrix, !1, n),
  5031. t.uniformMatrix4fv(i.params.uViewProjection, !1, s.viewProjectionMatrix),
  5032. 3 == this.backgroundMode ? t.uniform4fv(i.params.uSkyCoefficients, this.backgroundCoefficients) : this.backgroundTexture.bind(i.samplers.tSkyTexture),
  5033. e = .07 + .94 * (1 - e.stripData.activeFade()),
  5034. t.uniform1f(i.params.uAlpha, e),
  5035. t.bindBuffer(t.ARRAY_BUFFER, this.vertexBuffer),
  5036. t.enableVertexAttribArray(i.attribs.vPosition),
  5037. t.vertexAttribPointer(i.attribs.vPosition, 3, t.FLOAT, !1, 20, 0),
  5038. t.enableVertexAttribArray(i.attribs.vTexCoord),
  5039. t.vertexAttribPointer(i.attribs.vTexCoord, 2, t.FLOAT, !1, 20, 12),
  5040. t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer),
  5041. e < 1 && (t.enable(t.BLEND),
  5042. t.blendFunc(t.SRC_ALPHA, t.ONE_MINUS_SRC_ALPHA)),
  5043. t.depthMask(!1),
  5044. t.disable(t.DEPTH_TEST),
  5045. t.drawElements(t.TRIANGLES, this.skyIndexCount, t.UNSIGNED_SHORT, 0),
  5046. t.enable(t.DEPTH_TEST),
  5047. t.depthMask(!0),
  5048. e < 1 && t.disable(t.BLEND),
  5049. t.disableVertexAttribArray(i.attribs.vPosition),
  5050. t.disableVertexAttribArray(i.attribs.vTexCoord)
  5051. }
  5052. }
  5053. ,
  5054. _.prototype.complete = function() {
  5055. return !(this.backgroundShader && !this.backgroundShader.complete()) && this.specularTexture.complete()
  5056. }
  5057. ,
  5058. D.expDecay = function(e, t) {
  5059. return Math.exp(-.69314718 / e * t)
  5060. }
  5061. ,
  5062. D.prototype.update = function(e) {
  5063. var t = .001 * (Date.now() - this.timestamp);
  5064. this.timestamp = Date.now();
  5065. for (var i = !1, s = 0; s < this.stripCount; ++s) {
  5066. var n = this.selectedStrip == this.STRIP_MENU ? .3 * (s + 1) - .9 : this.selectedStrip < 0 || s < this.selectedStrip ? -2 : 2;
  5067. if (e)
  5068. this.strips[s] = n;
  5069. else {
  5070. var r = (r = n - this.strips[s]) * D.expDecay(.05, t);
  5071. this.animationActive && (this.strips[s] = n - r),
  5072. i = i || .001 < Math.abs(r)
  5073. }
  5074. }
  5075. this.animationActive = i
  5076. }
  5077. ,
  5078. D.prototype.active = function() {
  5079. return this.selectedStrip >= this.STRIP_MENU
  5080. }
  5081. ,
  5082. D.prototype.activeFade = function() {
  5083. var e;
  5084. return (e = 1 < (e = (this.strips[this.stripCount - 1] - -2) / (.3 * this.stripCount - .9 - -2)) ? 1 : e) < 0 ? 0 : e
  5085. }
  5086. ,
  5087. D.prototype.activeWireframe = function() {
  5088. return this.active() && .01 < Math.abs(this.strips[4] - this.strips[3])
  5089. }
  5090. ,
  5091. D.prototype.toggleMenu = function() {
  5092. this.selectedStrip = this.selectedStrip == this.STRIP_MENU ? this.STRIP_NONE : this.STRIP_MENU
  5093. }
  5094. ,
  5095. D.prototype.selectStrip = function(e, t) {
  5096. if (this.selectedStrip == this.STRIP_MENU) {
  5097. var i = e + t * this.stripSlant;
  5098. this.selectedStrip = this.STRIP_NONE;
  5099. for (var s = 0; s < this.stripCount; ++s)
  5100. if (i < this.strips[s]) {
  5101. this.selectedStrip = s;
  5102. break
  5103. }
  5104. } else
  5105. this.selectedStrip = this.STRIP_MENU
  5106. }
  5107. ,
  5108. U.prototype.loadImage = function(e, t) {
  5109. var i = this.gl;
  5110. e && e.width && e.height && (this.desc.width = e.width,
  5111. this.desc.height = e.height),
  5112. this.id = i.createTexture(),
  5113. i.bindTexture(this.type, this.id),
  5114. this.format = t || i.RGBA,
  5115. this.componentType = i.UNSIGNED_BYTE,
  5116. i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, !0),
  5117. i.texImage2D(this.type, 0, this.format, this.format, this.componentType, e),
  5118. this.setParams(),
  5119. i.bindTexture(this.type, null)
  5120. }
  5121. ,
  5122. U.prototype.loadArray = function(e, t, i) {
  5123. var s = this.gl;
  5124. this.id = s.createTexture(),
  5125. s.bindTexture(this.type, this.id),
  5126. this.format = t || s.RGBA,
  5127. this.componentType = i || s.UNSIGNED_BYTE,
  5128. s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, !0),
  5129. s.texImage2D(this.type, 0, this.format, this.desc.width, this.desc.height, 0, this.format, this.componentType, e || null),
  5130. this.setParams(),
  5131. s.bindTexture(this.type, null)
  5132. }
  5133. ,
  5134. U.prototype.setParams = function() {
  5135. var e = this.gl
  5136. , t = function(e) {
  5137. return 0 < e && 0 == (e & e - 1)
  5138. };
  5139. t(this.desc.width) && t(this.desc.height) || (this.desc.clamp = !0,
  5140. this.desc.mipmap = !1),
  5141. t = !this.desc.nofilter,
  5142. this.desc.mipmap ? (e.generateMipmap(this.type),
  5143. e.texParameteri(this.type, e.TEXTURE_MIN_FILTER, t ? e.LINEAR_MIPMAP_LINEAR : e.NEAREST_MIPMAP_NEAREST)) : e.texParameteri(this.type, e.TEXTURE_MIN_FILTER, t ? e.LINEAR : e.NEAREST),
  5144. e.texParameteri(this.type, e.TEXTURE_MAG_FILTER, t ? e.LINEAR : e.NEAREST),
  5145. (this.desc.clamp || this.desc.mirror) && (t = this.desc.clamp ? e.CLAMP_TO_EDGE : e.MIRRORED_REPEAT,
  5146. e.texParameteri(this.type, e.TEXTURE_WRAP_S, t),
  5147. e.texParameteri(this.type, e.TEXTURE_WRAP_T, t)),
  5148. this.desc.aniso && e.ext.textureAniso && e.texParameteri(this.type, e.ext.textureAniso.TEXTURE_MAX_ANISOTROPY_EXT, this.desc.aniso)
  5149. }
  5150. ,
  5151. U.prototype.rebuildMips = function() {
  5152. this.desc.mipmap && (this.gl.bindTexture(this.type, this.id),
  5153. this.gl.generateMipmap(this.type))
  5154. }
  5155. ,
  5156. U.prototype.copyColorBuffer = function() {
  5157. this.gl.bindTexture(this.type, this.id),
  5158. this.gl.copyTexSubImage2D(this.type, 0, 0, 0, 0, 0, this.desc.width, this.desc.height)
  5159. }
  5160. ,
  5161. U.prototype.bind = function(e) {
  5162. if (e) {
  5163. var t = this.gl;
  5164. t.uniform1i(e.location, e.unit),
  5165. t.activeTexture(t.TEXTURE0 + e.unit),
  5166. t.bindTexture(this.type, this.id)
  5167. }
  5168. }
  5169. ,
  5170. U.prototype.destroy = function() {
  5171. this.gl.deleteTexture(this.id),
  5172. this.id = null
  5173. }
  5174. ,
  5175. U.prototype.complete = function() {
  5176. return !!this.id
  5177. }
  5178. ,
  5179. N.prototype.fromURL = function(e, t) {
  5180. var i = this.cache[e];
  5181. if (void 0 !== i)
  5182. return i;
  5183. var s = new U(this.gl,t);
  5184. return C.fetchImage(e, function(e) {
  5185. s.loadImage(e)
  5186. }),
  5187. this.cache[e] = s
  5188. }
  5189. ,
  5190. N.prototype.fromFile = function(e, t) {
  5191. if (!e)
  5192. return null;
  5193. var i = this.cache[e.name];
  5194. if (void 0 !== i)
  5195. return i;
  5196. var s = new U(this.gl,t);
  5197. return this.cache[e.name] = s,
  5198. N.parseFile(e, function(e) {
  5199. s.loadImage(e),
  5200. N.closeImage(e)
  5201. }),
  5202. s
  5203. }
  5204. ,
  5205. N.prototype.fromFilesMergeAlpha = function(e, t, i) {
  5206. if (!t)
  5207. return this.fromFile(e, i);
  5208. var s = e.name + "|" + t.name
  5209. , n = this.cache[s];
  5210. if (void 0 !== n)
  5211. return n;
  5212. var r = this.gl;
  5213. this.blitShader || (this.blitShader = new F(this.gl),
  5214. this.blitShader.build("precision highp float; varying vec2 c; attribute vec2 pos; void main(){ gl_Position.xy = 2.0*pos-vec2(1.0); gl_Position.zw = vec2(0.5,1.0); c=pos; }", "precision highp float; varying vec2 c; uniform sampler2D tTex; void main(){ gl_FragColor=texture2D(tTex,c).rgbr; }"),
  5215. this.mergeVerts = r.createBuffer(),
  5216. r.bindBuffer(r.ARRAY_BUFFER, this.mergeVerts),
  5217. n = new Float32Array([0, 0, 2, 0, 0, 2]),
  5218. r.bufferData(r.ARRAY_BUFFER, n, r.STATIC_DRAW),
  5219. r.bindBuffer(r.ARRAY_BUFFER, null));
  5220. var a = function(e) {
  5221. this.blitShader.bind(),
  5222. e.bind(this.blitShader.samplers.tTex),
  5223. r.bindBuffer(r.ARRAY_BUFFER, this.mergeVerts),
  5224. r.enableVertexAttribArray(this.blitShader.attribs.pos),
  5225. r.vertexAttribPointer(this.blitShader.attribs.pos, 2, r.FLOAT, !1, 0, 0),
  5226. r.drawArrays(r.TRIANGLES, 0, 3),
  5227. r.disableVertexAttribArray(this.blitShader.attribs.pos),
  5228. r.bindBuffer(r.ARRAY_BUFFER, null)
  5229. }
  5230. .bind(this)
  5231. , o = new U(this.gl,i);
  5232. this.cache[s] = o;
  5233. var h = 0
  5234. , l = 0
  5235. , d = function() {
  5236. if (h && l) {
  5237. var e, t;
  5238. if (t = l.width * l.height > h.width * h.height ? (e = l.width,
  5239. l.height) : (e = h.width,
  5240. h.height),
  5241. o.desc.width = e,
  5242. o.desc.height = t,
  5243. e <= r.limits.viewportSizes[0] && t <= r.limits.viewportSizes[1]) {
  5244. var i = {
  5245. clamp: !0
  5246. };
  5247. h.width == e && h.height == t ? (o.loadImage(h, r.RGBA),
  5248. e = new m(r,{
  5249. color0: o,
  5250. ignoreStatus: !0
  5251. }),
  5252. N.closeImage(h)) : ((t = new U(r,i)).loadImage(h, r.RGB),
  5253. N.closeImage(h),
  5254. o.loadArray(null),
  5255. (e = new m(r,{
  5256. color0: o,
  5257. ignoreStatus: !0
  5258. })).bind(),
  5259. a(t),
  5260. t.destroy()),
  5261. (t = new U(r,i)).loadImage(l, r.RGB),
  5262. N.closeImage(l),
  5263. e.bind(),
  5264. r.colorMask(!1, !1, !1, !0),
  5265. a(t),
  5266. r.colorMask(!0, !0, !0, !0),
  5267. t.destroy(),
  5268. m.bindNone(r),
  5269. o.rebuildMips()
  5270. } else {
  5271. (i = document.createElement("canvas")).width = e,
  5272. i.height = t;
  5273. var s = i.getContext("2d");
  5274. for (s.drawImage(h, 0, 0),
  5275. N.closeImage(h),
  5276. i = s.getImageData(0, 0, e, t),
  5277. i = new Uint8Array(i.data.buffer,i.data.byteOffset,i.data.length),
  5278. s.drawImage(l, 0, 0),
  5279. N.closeImage(l),
  5280. s = s.getImageData(0, 0, e, t).data,
  5281. e = e * t * 4,
  5282. t = 0; t < e; t += 4)
  5283. i[t + 3] = s[t];
  5284. o.loadArray(i)
  5285. }
  5286. N.closeImage(l)
  5287. }
  5288. }
  5289. ;
  5290. return N.parseFile(e, function(e) {
  5291. h = e,
  5292. d()
  5293. }),
  5294. N.parseFile(t, function(e) {
  5295. l = e,
  5296. d()
  5297. }),
  5298. o
  5299. }
  5300. ,
  5301. N.parseFile = function(e, t, i) {
  5302. var s = i || new Image();
  5303. if ("undefined" != typeof URL && void 0 !== URL.createObjectURL) {
  5304. e = new Blob([e.data],{
  5305. type: e.type
  5306. });
  5307. var n = URL.createObjectURL(e);
  5308. s.onload = function() {
  5309. URL.revokeObjectURL(n),
  5310. t && t(s)
  5311. }
  5312. ,
  5313. s.src = n
  5314. } else {
  5315. e = new Blob([e.data],{
  5316. type: e.type
  5317. });
  5318. var r = new FileReader();
  5319. r.onload = function(e) {
  5320. s.src = r.result
  5321. }
  5322. ,
  5323. s.onload = function() {
  5324. t && t(s)
  5325. }
  5326. ,
  5327. r.readAsDataURL(e)
  5328. }
  5329. }
  5330. ,
  5331. N.closeImage = function(e) {
  5332. e && 256 < e.width * e.height && (e.onload = null,
  5333. e.onerror = null,
  5334. e.src = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D")
  5335. }
  5336. ,
  5337. z.prototype.setBackground3x1 = function(e, t, i, s) {
  5338. var n = 8 / this.controlRect.getScreenHeight();
  5339. this.backgroundControl = e.addTextButton("", 0, (1 - n) / 2, 1, n, 1),
  5340. this.backgroundControl.defaultAlpha = 1,
  5341. this.backgroundControl.setBackground3x1(e, 0, 0, t, i, s, 4),
  5342. this.backgroundControl.controlRect.xPercent = this.controlRect.xPercent,
  5343. this.backgroundControl.controlRect.widthPercent = this.controlRect.widthPercent,
  5344. this.controlRect.linkedControl.style.zIndex = "3",
  5345. this.setupCallbacks()
  5346. }
  5347. ,
  5348. z.prototype.setSize = function(e, t) {
  5349. this.pixelsX = e;
  5350. var i = 24 / (this.pixelsY = t);
  5351. this.knobWidthPercent = 24 / e,
  5352. this.knobControlRect.xPercent = .5 - this.knobWidthPercent / 2,
  5353. this.knobControlRect.yPercent = (1 - i) / 2 + -1 / t,
  5354. this.knobControlRect.widthPercent = this.knobWidthPercent,
  5355. this.knobControlRect.heightPercent = i,
  5356. this.controlRect.updateElement(),
  5357. this.backgroundControl.controlRect.xPercent = this.controlRect.xPercent,
  5358. this.backgroundControl.controlRect.widthPercent = this.controlRect.widthPercent,
  5359. this.backgroundControl.controlRect.updateElement()
  5360. }
  5361. ,
  5362. z.prototype.setSliderPercent = function(e) {
  5363. e < 0 && (e = 0),
  5364. 1 < e && (e = 1),
  5365. this.sliderPercent = e,
  5366. this.knobControlRect.xPercent = e - this.knobWidthPercent / 2,
  5367. this.knobControlRect.updateElement()
  5368. }
  5369. ,
  5370. z.prototype.setupCallbacks = function() {
  5371. var e = function(e) {
  5372. if (this.draggingSlider) {
  5373. var t = this.backgroundControl.controlRect.linkedControl.getBoundingClientRect();
  5374. this.setSliderPercent((e.clientX - t.left) / t.width),
  5375. this.guiScreen.ui.viewer.scene.sceneAnimator.setAnimationProgress(this.sliderPercent, !0),
  5376. this.guiScreen.ui.viewer.scene.sceneAnimator.paused && (this.guiScreen.ui.viewer.scene.postRender.discardAAHistory(),
  5377. this.guiScreen.ui.viewer.reDrawScene())
  5378. }
  5379. }
  5380. .bind(this)
  5381. , t = function(e) {
  5382. this.draggingSlider = !0;
  5383. var t = this.backgroundControl.controlRect.linkedControl.getBoundingClientRect();
  5384. this.setSliderPercent((e.clientX - t.left) / t.width),
  5385. this.guiScreen.ui.viewer.scene.sceneAnimator.setAnimationProgress(this.sliderPercent, !0),
  5386. this.guiScreen.ui.viewer.scene.sceneAnimator.lockPlayback = !0,
  5387. this.guiScreen.ui.viewer.scene.sceneAnimator.paused && (this.guiScreen.ui.viewer.scene.postRender.discardAAHistory(),
  5388. this.guiScreen.ui.viewer.reDrawScene())
  5389. }
  5390. .bind(this)
  5391. , i = function(e) {
  5392. this.draggingSlider = !1,
  5393. this.guiScreen.ui.viewer.scene.sceneAnimator.lockPlayback = !1
  5394. }
  5395. .bind(this);
  5396. this.guiScreen.ui.viewer.input.element.addEventListener("mousemove", e),
  5397. this.guiScreen.ui.viewer.input.element.addEventListener("mouseup", i),
  5398. this.backgroundControl.controlRect.linkedControl.addEventListener("mousemove", e),
  5399. this.backgroundControl.controlRect.linkedControl.addEventListener("mousedown", t),
  5400. this.backgroundControl.controlRect.linkedControl.addEventListener("mouseup", i),
  5401. this.controlRect.linkedControl.addEventListener("mouseup", i)
  5402. }
  5403. ,
  5404. j.prototype.setSize = function(e, t) {
  5405. this.container.width = 0 | e,
  5406. this.container.height = 0 | t,
  5407. this.container.style.width = e + "px",
  5408. this.container.style.height = t + "px",
  5409. this.guiScreen.setSize(this.container.width, this.container.height)
  5410. }
  5411. ,
  5412. j.prototype.clearView = function() {
  5413. for (; this.container.hasChildNodes(); )
  5414. this.container.removeChild(this.container.childNodes[0]);
  5415. delete this.progressBar,
  5416. delete this.thumbnail,
  5417. delete this.fadeThumbnail,
  5418. delete this.playButton,
  5419. delete this.helpOverlay
  5420. }
  5421. ,
  5422. j.prototype.bindInput = function(i) {
  5423. i.onSingleTap.push(function(e, t) {
  5424. this.stripData.selectedStrip != this.stripData.STRIP_NONE && (e = 2 / i.element.clientWidth * e - 1,
  5425. t = 1 - 2 / i.element.clientHeight * t,
  5426. this.stripData.selectStrip(e, t),
  5427. this.stripData.selectedStrip == this.stripData.STRIP_MENU && this.helpOverlay.active && this.helpOverlay.toggle(),
  5428. this.refreshUI(),
  5429. this.viewer.wake())
  5430. }
  5431. .bind(this))
  5432. }
  5433. ,
  5434. j.sanitize = function(e) {
  5435. return e ? e.replace(/<|>|\(|\)|$|%|=/g, "") : e
  5436. }
  5437. ,
  5438. j.sanitizeURL = function(e) {
  5439. return e ? 0 == e.indexOf("http://") || 0 == e.indexOf("https://") || 0 == e.indexOf("ftp://") ? encodeURI(e) : "http://" + encodeURI(e) : e
  5440. }
  5441. ,
  5442. j.prototype.showFailure = function(e, t) {
  5443. this.container.innerHTML = "";
  5444. var i = document.createElement("canvas")
  5445. , s = this.container.width / this.container.height;
  5446. i.width = 100,
  5447. i.height = i.height * s | 0,
  5448. i.style.position = "absolute",
  5449. i.style["z-index"] = "0",
  5450. i.style.width = i.style.height = "100%";
  5451. var n = i.getContext("2d")
  5452. , r = n.fillStyle = n.createRadialGradient(i.width / 2, i.height / 2, (i.width + i.height) / 2, i.width / 2, i.height / 2, 0);
  5453. r.addColorStop(0, "rgb(0,0,0)"),
  5454. r.addColorStop(1, "rgb(35,60,80)"),
  5455. n.fillStyle = r,
  5456. n.fillRect(0, 0, i.width, i.height),
  5457. this.container.appendChild(i);
  5458. var a = document.createElement("div");
  5459. dom.addClass(a, "error"),
  5460. a.style["background-image"] = "url(images/errorBG.png)";
  5461. var o = '<div class="errorInfo"><p style="font-size:1.5em; font-weight:lighter">转换模型时出错</p><p style="font-size:1.3em;letter-spacing:2px;font-weight:bold;line-height:1.5em;margin-top:30px">错误信息: ' + (e || "文件无效(ERROR)请检查您所上传的文件以确定其稳定性") + '</p><p style="font-size:0.8em;line-height:1.5em; margin-top:50px">您可以联系我们的客服、或点击<a href="http://www.4dage.com/tutorial.html" style="color: #a6ccea;">视频教程</a>获取更详细的上传解说<br>4Dweb将全程为您提供最优质的模型展示</p></div>';
  5462. a.innerHTML = o,
  5463. this.container.appendChild(a)
  5464. }
  5465. ,
  5466. j.prototype.showPreview = function(e) {
  5467. this.clearView(),
  5468. this.thumbnail = document.createElement("canvas");
  5469. var t = this.container.width / this.container.height;
  5470. this.thumbnail.height = this.viewer.mobile ? 200 : 300,
  5471. this.thumbnail.width = this.thumbnail.height * t | 0,
  5472. this.thumbnail.style.width = this.thumbnail.style.height = "100%";
  5473. var i = (t = this.thumbnail.getContext("2d")).fillStyle = t.createRadialGradient(this.thumbnail.width / 2, this.thumbnail.height / 2, (this.thumbnail.width + this.thumbnail.height) / 2, this.thumbnail.width / 2, 0, 0);
  5474. i.addColorStop(0, "rgb(0,0,0)"),
  5475. i.addColorStop(1, "rgb(7,62,92)"),
  5476. t.fillStyle = i,
  5477. t.fillRect(0, 0, this.thumbnail.width, this.thumbnail.height),
  5478. this.container.appendChild(this.thumbnail),
  5479. this.playButton = document.createElement("input"),
  5480. this.playButton.type = "image",
  5481. this.playButton.src = I.dataLocale + "play.png",
  5482. this.playButton.style.position = "absolute",
  5483. this.playButton.style.left = "50%",
  5484. this.playButton.style.top = "50%",
  5485. this.playButton.style["-webkit-transform"] = this.playButton.style.transform = "translate(-50%,-50%) scale(0.4,0.4)",
  5486. this.playButton.style.opacity = .5,
  5487. this.playButton.style.outline = "0px",
  5488. this.playButton.onclick = function() {
  5489. this.viewer.loadScene(this.viewer.sceneURL),
  5490. this.container.removeChild(this.playButton),
  5491. delete this.playButton
  5492. }
  5493. .bind(this),
  5494. this.container.appendChild(this.playButton),
  5495. e || n(this.viewer.sceneURL, function(e) {
  5496. this.loadingImageURL || this.setThumbnail(e)
  5497. }
  5498. .bind(this))
  5499. }
  5500. ,
  5501. j.prototype.setThumbnailURL = function(e) {
  5502. (this.loadingImageURL = e) && C.fetchImage(this.loadingImageURL, this.setThumbnail.bind(this))
  5503. }
  5504. ,
  5505. j.prototype.setThumbnail = function(e) {
  5506. if (this.thumbnail)
  5507. if (e.height >= this.container.height) {
  5508. var t = this.container.height / e.height;
  5509. e.style.position = "absolute",
  5510. e.style.outline = "0px",
  5511. e.style.left = "50%",
  5512. e.style.top = "50%",
  5513. e.style["-webkit-transform"] = e.style.transform = "translate(-50%,-50%) scale(" + t + "," + t + ")",
  5514. this.container.replaceChild(e, this.thumbnail),
  5515. this.thumbnail = e
  5516. } else {
  5517. var i, s = this.thumbnail.getContext("2d"), n = this.thumbnail.width, r = this.thumbnail.height;
  5518. t = r / e.height;
  5519. s.drawImage(e, (n - e.width * t) / 2, 0, e.width * t, r);
  5520. try {
  5521. i = s.getImageData(0, 0, n, r)
  5522. } catch (e) {
  5523. return
  5524. }
  5525. e = s.createImageData(n, r);
  5526. for (var a = 0; a < 2; ++a) {
  5527. t = i.data;
  5528. for (var o = e.data, h = 0, l = 0; l < r; ++l)
  5529. for (var d = 0; d < n; ++d) {
  5530. for (var c = 0, u = 0, f = 0, m = -2; m <= 2; ++m)
  5531. for (var p = (p = l + m) < 0 ? 0 : r <= p ? r - 1 : p, g = -2; g <= 2; ++g) {
  5532. var v;
  5533. c = c + t[v = 4 * (p * n + (v = (v = d + g) < 0 ? 0 : n <= v ? n - 1 : v))],
  5534. u = u + t[v + 1],
  5535. f = f + t[v + 2]
  5536. }
  5537. o[h++] = c / 25,
  5538. o[h++] = u / 25,
  5539. o[h++] = f / 25,
  5540. o[h++] = 255
  5541. }
  5542. t = i,
  5543. i = e,
  5544. e = t
  5545. }
  5546. s.putImageData(i, 0, 0)
  5547. }
  5548. }
  5549. ,
  5550. j.prototype.showActiveView = function() {
  5551. var e, t, i, s, n, r = this.thumbnail;
  5552. this.clearView(),
  5553. r && (this.fadeThumbnail = r,
  5554. this.fadeThumbnail.style.opacity = 1,
  5555. this.container.appendChild(this.fadeThumbnail)),
  5556. void 0 === I.largeUI && (I.largeUI = this.viewer.mobile),
  5557. this.container.width < 450 && (I.largeUI = !1);
  5558. var a = g.support();
  5559. r = 1;
  5560. window.devicePixelRatio && (2 < window.devicePixelRatio ? r = 4 : 1 < window.devicePixelRatio && (r = 2)),
  5561. I.largeUI && r < 4 && (r *= 2);
  5562. var o = I.largeUI ? .3 : .5;
  5563. this.helpOverlay = document.createElement("div"),
  5564. this.helpOverlay.style.pointerEvents = "none",
  5565. this.container.appendChild(this.helpOverlay),
  5566. this.hideSigOnHelp = e = this.container.width < 450,
  5567. this.hideSigOnStrips = !0,
  5568. t = [8, 8],
  5569. s = e ? (i = 198 + 2 * t[0],
  5570. 258 + 2 * t[1]) : (i = 354 + 2 * t[0],
  5571. 218 + 2 * t[1]),
  5572. (n = document.createElement("div")).style.position = "absolute",
  5573. n.style.width = n.style.height = "100%",
  5574. this.helpOverlay.contents = n,
  5575. (n = document.createElement("div")).style.position = "absolute",
  5576. n.style.right = I.largeUI ? "85px" : "45px",
  5577. n.style.top = I.largeUI ? "20px" : "12px",
  5578. n.style["z-index"] = "20",
  5579. n.style.width = i + "px",
  5580. n.style.height = s + "px",
  5581. this.helpOverlay.contents.appendChild(n),
  5582. (s = document.createElement("div")).style.position = "absolute",
  5583. s.style.width = "100%",
  5584. s.style.height = "100%",
  5585. s.style.backgroundColor = "black",
  5586. s.style.opacity = "0.65",
  5587. s.style.borderRadius = "16px",
  5588. n.appendChild(s),
  5589. s = document.createElement("a"),
  5590. dom.addClass(s, "tipClose"),
  5591. s.style.position = "absolute",
  5592. s.style.color = "#FFFFFF",
  5593. s.style.backgroundColor = "rgba(0,0,0,0.0)",
  5594. s.style.border = "0px",
  5595. s.style.outline = "0px",
  5596. s.style.fontSize = I.largeUI ? "16pt" : "10pt",
  5597. s.style.right = I.largeUI ? "-9px" : "4px",
  5598. s.style.top = I.largeUI ? "3px" : "7px",
  5599. s.style.width = s.style.height = I.largeUI ? "32px" : "16px",
  5600. s.style.pointerEvents = "auto",
  5601. s.style.cursor = "pointer",
  5602. s.onclick = function(e) {
  5603. this.helpOverlay.toggle(),
  5604. this.refreshUI()
  5605. }
  5606. .bind(this, s),
  5607. n.appendChild(s),
  5608. (s = document.createElement("center")).style.position = "absolute",
  5609. s.style.left = t[0] - 4 + "px",
  5610. s.style.right = t[0] + 4 + "px",
  5611. s.style.top = s.style.bottom = t[1] + "px",
  5612. s.style.paddingTop = "8px",
  5613. e || (s.style.paddingRight = "8px"),
  5614. n.appendChild(s),
  5615. n = s,
  5616. t = (this.viewer.mobile ? "M" : "PC") + (2 < r ? 4 : 2) + "x.png",
  5617. (s = document.createElement("img")).style.width = "66px",
  5618. s.style.height = "90px",
  5619. n.appendChild(s),
  5620. (s = document.createElement("img")).style.width = "66px",
  5621. s.style.height = "90px",
  5622. n.appendChild(s),
  5623. (s = document.createElement("img")).style.width = "66px",
  5624. s.style.height = "90px",
  5625. n.appendChild(s),
  5626. (s = document.createElement("img")).style.width = "66px",
  5627. s.style.height = "90px",
  5628. n.appendChild(s),
  5629. (s = document.createElement("img")).style.position = "relative",
  5630. e || (s.style.left = "8px"),
  5631. s.style.width = "66px",
  5632. s.style.height = "90px",
  5633. n.appendChild(s),
  5634. (t = document.createElement("a")).href = "http://www.4dage.com/",
  5635. t.target = "_blank",
  5636. t.style.pointerEvents = "auto",
  5637. t.style.cursor = "pointer",
  5638. n.appendChild(t),
  5639. (s = document.createElement("img")).style.position = "absolute",
  5640. s.style.left = .5 * i - (e ? 65 : 116) + "px",
  5641. s.style.bottom = e ? "8px" : "12px",
  5642. s.style.width = e ? "116px" : "232px",
  5643. t.appendChild(s),
  5644. (i = document.createElement("div")).style.position = "absolute",
  5645. i.style.left = 0,
  5646. i.style.right = e ? "30px" : "128px",
  5647. i.style.bottom = e ? "-4px" : "4px",
  5648. i.style.textAlign = "right",
  5649. i.style.fontFamilly = "Open Sans Arial",
  5650. n.appendChild(i),
  5651. (e = document.createElement("font")).style.fontSize = "9pt",
  5652. e.style.fontFamily = "Open Sans Arial",
  5653. i.appendChild(e),
  5654. e.appendChild(t),
  5655. this.helpOverlay.active = !1,
  5656. this.helpOverlay.toggle = function(e) {
  5657. this.active ? this.removeChild(this.contents) : this.appendChild(this.contents),
  5658. this.active = !this.active
  5659. }
  5660. .bind(this.helpOverlay, this.viewer),
  5661. this.menuCluster = document.createElement("div"),
  5662. this.menuCluster.style.position = "absolute",
  5663. this.menuCluster.style.right = I.largeUI ? "4px" : "0px",
  5664. this.menuCluster.style.top = I.largeUI ? "20px" : "10px",
  5665. I.largeUI ? (this.menuCluster.style.width = "72px",
  5666. this.menuCluster.style.height = "64px") : (this.menuCluster.style.width = "36px",
  5667. this.menuCluster.style.height = "36px"),
  5668. (n = document.createElement("div")).style.left = n.style.top = "0px",
  5669. n.style.width = n.style.height = "100%",
  5670. this.menuCluster.contents = n,
  5671. this.menuCluster.appendChild(n),
  5672. e = 0;
  5673. var h = (i = function(e, t, i, s, n, r) {
  5674. var a = document.createElement("div");
  5675. return dom.addClass(a, "controlBtn"),
  5676. dom.addClass(a, i),
  5677. a.title = t,
  5678. I.largeUI && dom.addClass(a, "largeUI"),
  5679. e.appendChild(a),
  5680. a
  5681. }
  5682. )(this.menuCluster.contents, "4DAGE主页", "home", "", e++, o);
  5683. for (h.onclick = function(e) {
  5684. window.open("http://www.4dage.com", "_blank")
  5685. }
  5686. .bind(this, h),
  5687. a && ((a = i(this.menuCluster.contents, "全屏", "fullscreen", "fullscreen" + r + "x.png", e++, o)).onclick = function(e) {
  5688. g.active() ? g.end() : g.begin(this.viewer.domRoot, this.viewer.fullscreenChange.bind(this.viewer)),
  5689. dom.hasClass(e, "full") ? dom.removeClass(e, "full") : dom.addClass(e, "full"),
  5690. this.refreshUI()
  5691. }
  5692. .bind(this, a)),
  5693. (a = i(this.menuCluster.contents, "操作方式说明", "tips", "help" + r + "x.png", e++, o)).onclick = function(e) {
  5694. this.helpOverlay.toggle(),
  5695. this.refreshUI()
  5696. }
  5697. .bind(this, a),
  5698. this.container.appendChild(this.menuCluster),
  5699. this.menuCluster.active = !0,
  5700. this.menuCluster.toggle = function() {
  5701. this.active ? this.removeChild(this.contents) : this.appendChild(this.contents),
  5702. this.active = !this.active
  5703. }
  5704. .bind(this.menuCluster),
  5705. void 0 !== I.hostImage && (I.hostURL && ((t = document.createElement("a")).href = I.hostURL,
  5706. t.target = "_blank"),
  5707. (s = document.createElement("img")).src = I.hostImage,
  5708. s.style.position = "absolute",
  5709. s.style.top = "4px",
  5710. s.style.left = "4px",
  5711. s.style.opacity = .65,
  5712. s.style["-webkit-transform"] = s.style.transform = "translate(-50%,-50%) scale(0.5,0.5) translate(50%,50%)",
  5713. I.hostURL ? (s.onmouseover = function() {
  5714. this.style.opacity = 1
  5715. }
  5716. .bind(s),
  5717. s.onmouseout = function() {
  5718. this.style.opacity = .5
  5719. }
  5720. .bind(s),
  5721. t.appendChild(s),
  5722. this.hostLogo = t) : this.hostLogo = s,
  5723. (e = new XMLHttpRequest()).open("HEAD", s.src, !0),
  5724. e.onload = function() {
  5725. this.container.appendChild(this.hostLogo)
  5726. }
  5727. .bind(this),
  5728. e.send()),
  5729. this.sceneStats = document.createElement("text"),
  5730. this.sceneStats.style.position = "absolute",
  5731. this.sceneStats.style.left = "9px",
  5732. this.sceneStats.style.bottom = "8px",
  5733. this.sceneStats.style.color = "gray",
  5734. this.sceneStats.style.fontFamily = "Open Sans Arial",
  5735. this.sceneStats.style.fontSize = "75%",
  5736. e = a = r = 0; e < this.viewer.scene.meshes.length; ++e)
  5737. r += (i = this.viewer.scene.meshes[e]).indexCount / 3,
  5738. a += i.vertexCount;
  5739. this.sceneStats.innerHTML = "Triangles: " + (0 | r).toLocaleString() + "<br>Vertices: " + (0 | a).toLocaleString(),
  5740. I.showFrameTime && (this.frameTimer = document.createElement("text"),
  5741. this.frameTimer.style.position = "absolute",
  5742. this.frameTimer.style.left = this.frameTimer.style.top = "5px",
  5743. this.frameTimer.style.color = "gray",
  5744. this.frameTimer.style.fontSize = "75%",
  5745. this.container.appendChild(this.frameTimer),
  5746. this.frameTimer.innerHTML = "--",
  5747. this.frameCount = 1e20)
  5748. }
  5749. ,
  5750. j.prototype.refreshUI = function() {
  5751. if (this.sigCluster) {
  5752. var e = !1
  5753. , t = this.stripData.selectedStrip == this.stripData.STRIP_MENU;
  5754. this.hideSigOnStrips && (e = e || t),
  5755. this.hideSigOnHelp && (e = e || this.helpOverlay.active),
  5756. this.sigCluster.active == e && this.sigCluster.toggle()
  5757. }
  5758. }
  5759. ,
  5760. j.prototype.signalLoadProgress = function(e, t) {
  5761. if (this.thumbnail) {
  5762. if (!this.progressBar) {
  5763. var i = document.createElement("div");
  5764. i.style.backgroundColor = "rgb(240,240,240)",
  5765. i.style.opacity = .9,
  5766. i.style.position = "absolute",
  5767. i.style.zIndex = 999
  5768. i.style.left = "20%",
  5769. i.style.width = "60%",
  5770. i.style.bottom = "30%",
  5771. i.style.height = "4px",
  5772. i.style["border-radius"] = "2px",
  5773. this.progressBar = document.createElement("div"),
  5774. this.progressBar.style.backgroundColor = "#00ccff",
  5775. this.progressBar.style.position = "absolute",
  5776. this.progressBar.style.left = this.progressBar.style.bottom = "0px",
  5777. this.progressBar.style.height = "100%",
  5778. this.progressBar.style.width = "0px",
  5779. this.progressBar.style["border-radius"] = "2px",
  5780. i.appendChild(this.progressBar),
  5781. this.container.appendChild(i),
  5782. this.playButton && (this.container.removeChild(this.playButton),
  5783. delete this.playButton)
  5784. }
  5785. this.progressBar.style.width = t <= 0 ? (100 * e / (2097152 + e) | 0) + "%" : (100 * e / t | 0) + "%"
  5786. }
  5787. }
  5788. ,
  5789. j.prototype.animating = function() {
  5790. return !!this.fadeThumbnail || !!this.frameTimer
  5791. }
  5792. ,
  5793. j.prototype.animate = function() {
  5794. if (this.fadeThumbnail && (this.fadeThumbnailTimer = this.fadeThumbnailTimer || Date.now(),
  5795. this.fadeThumbnail.style.opacity = 1 - .0015 * (Date.now() - this.fadeThumbnailTimer),
  5796. this.fadeThumbnail.style.opacity < .01 && (this.container.removeChild(this.fadeThumbnail),
  5797. delete this.fadeThumbnail,
  5798. delete this.fadeThumbnailTimer)),
  5799. this.frameTimer && (this.frameCount++,
  5800. 60 <= this.frameCount)) {
  5801. var e = (new Date()).getTime();
  5802. if (void 0 !== this.frameTime) {
  5803. var t = (e - this.frameTime) / this.frameCount;
  5804. t = Math.floor(100 * t) / 100;
  5805. this.frameTimer.innerHTML = t + " ms",
  5806. this.frameTimer.style.color = t < 32 ? "green" : "red"
  5807. }
  5808. this.frameCount = 0,
  5809. this.frameTime = e
  5810. }
  5811. if (this.guiScreen && this.guiScreen.playbackControls && ((e = this.guiScreen.playbackControls.timelineSlider).draggingSlider ? this.viewer.scene.sceneAnimator.setAnimationProgress(e.sliderPercent, !0) : e.setSliderPercent(this.viewer.scene.sceneAnimator.animationProgress)),
  5812. this.sceneStats) {
  5813. for (var i = t = e = 0; i < this.viewer.scene.meshes.length; ++i) {
  5814. var s = this.viewer.scene.meshes[i];
  5815. e = e + s.indexCount / 3,
  5816. t = t + s.vertexCount
  5817. }
  5818. this.sceneStats.innerHTML = "Triangles: " + (0 | e).toLocaleString() + "<br>Vertices: " + (0 | t).toLocaleString(),
  5819. this.viewer.scene.sceneAnimator && this.viewer.scene.sceneAnimator.showPlayControls && (this.sceneStats.innerHTML += "<br><br><br><br>"),
  5820. e = !!this.sceneStats.parentElement,
  5821. t = this.stripData.active() || !1,
  5822. e && !t ? (this.container.removeChild(this.sceneStats),
  5823. this.hostLogo && this.container.appendChild(this.hostLogo)) : !e && t && (this.container.appendChild(this.sceneStats),
  5824. this.hostLogo && this.container.removeChild(this.hostLogo))
  5825. }
  5826. this.refreshUI(),
  5827. (this.stripData.animationActive || this.stripData.active()) && (this.animateStrips(),
  5828. this.stripData.animationActive && this.viewer.wake())
  5829. }
  5830. ,
  5831. j.prototype.animateStrips = function() {
  5832. if (this.stripText)
  5833. for (var e = Math.atan(this.viewer.canvas.height / this.viewer.canvas.width / this.stripData.stripSlant), t = 0; t < this.stripData.labels.length; ++t) {
  5834. var i = .5 + .5 * (i = (i = this.stripData.strips[t]) - this.stripData.stripSlant);
  5835. t == this.stripData.selectedStrip ? (this.stripText[t].style["-ms-transform"] = this.stripText[t].style["-webkit-transform"] = this.stripText[t].style.transform = "none",
  5836. this.stripText[t].style.top = "4px",
  5837. this.stripText[t].style.left = "0px",
  5838. this.stripText[t].style.width = "150px",
  5839. this.stripText[t].txt.style.textAlign = "center",
  5840. this.stripText[t].txt.style.background = "rgba(0, 0, 0, 0.75)",
  5841. this.stripText[t].txt.style.background = "-webkit-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5842. this.stripText[t].txt.style.background = "-o-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5843. this.stripText[t].txt.style.background = "-moz-linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5844. this.stripText[t].txt.style.background = "linear-gradient(left, rgba(0,0,0,0.75), rgba(0,0,0,0))",
  5845. this.stripText[t].txt.style.paddingLeft = "32px",
  5846. this.stripText[t].txt.style.paddingTop = "6px",
  5847. this.stripText[t].txt.style.paddingBottom = "4px",
  5848. this.stripText[t].txt.style.textShadow = "1px 1px 2px rgba(0,0,0,0.7)",
  5849. this.stripText[t].line.style.opacity = .5,
  5850. this.stripText[t].line.style.top = "100%",
  5851. this.stripText[t].line.style.width = "100%",
  5852. this.stripText[t].line.style.height = "1px") : (this.stripText[t].style["-ms-transform"] = this.stripText[t].style["-webkit-transform"] = this.stripText[t].style.transform = "translate(-50%, -50%) rotate(" + e + "rad) translate(50%, 50%)",
  5853. this.stripText[t].style.left = 100 * i + "%",
  5854. this.stripText[t].style.top = "0px",
  5855. this.stripText[t].style.width = "85px",
  5856. this.stripText[t].txt.style.textAlign = "left",
  5857. this.stripText[t].txt.style.background = "none",
  5858. this.stripText[t].txt.style.paddingLeft = "8px",
  5859. this.stripText[t].txt.style.paddingTop = "6px",
  5860. this.stripText[t].txt.style.paddingBottom = "4px",
  5861. this.stripText[t].txt.style.textShadow = "2px 0px 3px rgba(0,0,0,0.7)",
  5862. this.stripText[t].line.style.opacity = 1,
  5863. this.stripText[t].line.style.top = "-1px",
  5864. this.stripText[t].line.style.width = "10000px",
  5865. this.stripText[t].line.style.height = "2px")
  5866. }
  5867. }
  5868. ;
  5869. var V = {
  5870. type: Float32Array,
  5871. create: function(e, t, i, s) {
  5872. var n = new V.type(4);
  5873. return n[0] = e,
  5874. n[1] = t,
  5875. n[2] = i,
  5876. n[3] = s,
  5877. n
  5878. },
  5879. empty: function() {
  5880. return new V.type(4)
  5881. },
  5882. set: function(e, t, i, s, n) {
  5883. e[0] = t,
  5884. e[1] = i,
  5885. e[2] = s,
  5886. e[3] = n
  5887. },
  5888. copy: function(e, t) {
  5889. e[0] = t[0],
  5890. e[1] = t[1],
  5891. e[2] = t[2],
  5892. e[3] = t[3]
  5893. },
  5894. add: function(e, t, i) {
  5895. return e[0] = t[0] + i[0],
  5896. e[1] = t[1] + i[1],
  5897. e[2] = t[2] + i[2],
  5898. e[3] = t[3] + i[3],
  5899. e
  5900. },
  5901. sub: function(e, t, i) {
  5902. return e[0] = t[0] - i[0],
  5903. e[1] = t[1] - i[1],
  5904. e[2] = t[2] - i[2],
  5905. e[3] = t[3] - i[3],
  5906. e
  5907. },
  5908. scale: function(e, t, i) {
  5909. return e[0] = i[0] * t,
  5910. e[1] = i[1] * t,
  5911. e[2] = i[2] * t,
  5912. e[3] = i[3] * t,
  5913. e
  5914. },
  5915. mul: function(e, t, i) {
  5916. return e[0] = t[0] * i[0],
  5917. e[1] = t[1] * i[1],
  5918. e[2] = t[2] * i[2],
  5919. e[3] = t[3] * i[3],
  5920. e
  5921. },
  5922. mad: function(e, t, i, s) {
  5923. return e[0] = t[0] * i[0] + s[0],
  5924. e[1] = t[1] * i[1] + s[1],
  5925. e[2] = t[2] * i[2] + s[2],
  5926. e[3] = t[3] * i[3] + s[3],
  5927. e
  5928. },
  5929. smad: function(e, t, i, s) {
  5930. return e[0] = t * i[0] + s[0],
  5931. e[1] = t * i[1] + s[1],
  5932. e[2] = t * i[2] + s[2],
  5933. e[3] = t * i[3] + s[3],
  5934. e
  5935. },
  5936. negate: function(e, t) {
  5937. return e[0] = -t[0],
  5938. e[1] = -t[1],
  5939. e[2] = -t[2],
  5940. e
  5941. },
  5942. negate4: function(e, t) {
  5943. return e[0] = -t[0],
  5944. e[1] = -t[1],
  5945. e[2] = -t[2],
  5946. e[3] = -t[3],
  5947. e
  5948. },
  5949. length: function(e) {
  5950. var t = e[0]
  5951. , i = e[1];
  5952. return e = e[2],
  5953. Math.sqrt(t * t + i * i + e * e)
  5954. },
  5955. distance: function(e, t) {
  5956. var i = e[0] - t[0]
  5957. , s = e[1] - t[1]
  5958. , n = e[2] - t[2];
  5959. return Math.sqrt(i * i + s * s + n * n)
  5960. },
  5961. dot: function(e, t) {
  5962. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2]
  5963. },
  5964. dot4: function(e, t) {
  5965. return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3] * t[3]
  5966. },
  5967. normalize: function(e, t) {
  5968. var i = t[0]
  5969. , s = t[1]
  5970. , n = t[2]
  5971. , r = Math.sqrt(i * i + s * s + n * n);
  5972. return 0 == r ? V.set(e, 0, 0, 0, 0) : (r = 1 / r,
  5973. e[0] = i * r,
  5974. e[1] = s * r,
  5975. e[2] = n * r,
  5976. e)
  5977. },
  5978. cross: function(e, t, i) {
  5979. return e[0] = t[1] * i[2],
  5980. e[0] += -t[2] * i[1],
  5981. e[1] = t[2] * i[0] - t[0] * i[2],
  5982. e[2] = t[0] * i[1] - t[1] * i[0],
  5983. e
  5984. },
  5985. lerp: function(e, t, i, s) {
  5986. var n = 1 - s;
  5987. return e[0] = t[0] * n + i[0] * s,
  5988. e[1] = t[1] * n + i[1] * s,
  5989. e[2] = t[2] * n + i[2] * s,
  5990. e
  5991. },
  5992. lerp4: function(e, t, i, s) {
  5993. var n = 1 - s;
  5994. return e[0] = t[0] * n + i[0] * s,
  5995. e[1] = t[1] * n + i[1] * s,
  5996. e[2] = t[2] * n + i[2] * s,
  5997. e[3] = t[3] * n + i[3] * s,
  5998. e
  5999. },
  6000. min: function(e, t, i) {
  6001. return e[0] = Math.min(t[0], i[0]),
  6002. e[1] = Math.min(t[1], i[1]),
  6003. e[2] = Math.min(t[2], i[2]),
  6004. e[3] = Math.min(t[3], i[3]),
  6005. e
  6006. },
  6007. max: function(e, t, i) {
  6008. return e[0] = Math.max(t[0], i[0]),
  6009. e[1] = Math.max(t[1], i[1]),
  6010. e[2] = Math.max(t[2], i[2]),
  6011. e[3] = Math.max(t[3], i[3]),
  6012. e
  6013. },
  6014. projectOnPlane: function(e, t, i, s) {
  6015. var n = V.empty();
  6016. return V.sub(n, t, i),
  6017. i = V.dot(n, s),
  6018. smad(e, -i, normal, t),
  6019. e
  6020. }
  6021. };
  6022. function H(e) {
  6023. this.pivot = [0, 0, 0],
  6024. this.rotation = [0, 0],
  6025. this.radius = 1,
  6026. this.nearPlane = .3,
  6027. this.fov = 45,
  6028. this.size = [1, 1],
  6029. this.transform = S.empty(),
  6030. this.viewMatrix = S.empty(),
  6031. this.projectionMatrix = S.empty(),
  6032. this.viewProjectionMatrix = S.empty(),
  6033. e ? this.loadView(e, !0) : (this.saveResetView(),
  6034. this.updateView(),
  6035. this.updateProjection())
  6036. }
  6037. function W(e, t, i, s) {
  6038. var n;
  6039. if (this.mobile = !!/Android|iPhone|iPod|iPad|Windows Phone|IEMobile|BlackBerry|webOS/.test(navigator.userAgent),
  6040. this.mobileFast = !!/iPhone|iPad/.test(navigator.userAgent),
  6041. n = !this.mobile)
  6042. e: {
  6043. if ((n = document.createElement("canvas")).width = n.height = 16,
  6044. n = n.getContext("webgl", {}) || n.getContext("experimental-webgl", {})) {
  6045. var r = n.getExtension("WEBGL_debug_renderer_info");
  6046. if (r) {
  6047. n = n.getParameter(r.UNMASKED_RENDERER_WEBGL),
  6048. n = !!/Intel|INTEL/.test(n);
  6049. break e
  6050. }
  6051. }
  6052. n = !1
  6053. }
  6054. this.desktopSlow = n,
  6055. this.domRoot = document.createElement("div"),
  6056. this.domRoot.style.width = e + "px",
  6057. this.domRoot.style.height = t + "px",
  6058. this.initCanvas(e, t),
  6059. this.scene = this.input = null,
  6060. this.sceneURL = i,
  6061. this.sleepCounter = 8,
  6062. this.onLoad = null,
  6063. this.stripData = new D(),
  6064. this.ui = new j(this),
  6065. this.ui.setSize(e, t),
  6066. this.ui.showPreview(s)
  6067. }
  6068. H.prototype.saveResetView = function() {
  6069. this.resetDesc = {
  6070. angles: [this.rotation[0], this.rotation[1]],
  6071. pivot: [this.pivot[0], this.pivot[1], this.pivot[2]],
  6072. limits: this.limits,
  6073. orbitRadius: this.radius,
  6074. fov: this.fov
  6075. }
  6076. }
  6077. ,
  6078. H.prototype.loadView = function(e, t) {
  6079. e && (this.rotation[0] = e.angles[0],
  6080. this.rotation[1] = e.angles[1],
  6081. rotInfo.pivot[0] || (rotInfo.pivot[0] = e.pivot[0]),
  6082. rotInfo.pivot[1] || (rotInfo.pivot[1] = e.pivot[1]),
  6083. rotInfo.pivot[2] || (rotInfo.pivot[2] = e.pivot[2]),
  6084. this.pivot[0] = rotInfo.pivot[0],
  6085. this.pivot[1] = rotInfo.pivot[1],
  6086. this.pivot[2] = rotInfo.pivot[2],
  6087. this.radius = parseFloat(getQueryVariable('currentdis')?Number(getQueryVariable('currentdis')):e.orbitRadius),
  6088. this.fov = e.fov,
  6089. // this.limits = {
  6090. // orbitRadius:{
  6091. // max: getQueryVariable('camdismax')?Number(getQueryVariable('camdismax')): e.limits.orbitRadius.max,
  6092. // min: getQueryVariable('camdismmin')?Number(getQueryVariable('camdismmin')): e.limits.orbitRadius.min,
  6093. // }
  6094. // },
  6095. t && this.saveResetView(),
  6096. this.updateView(),
  6097. this.updateProjection())
  6098. // console.log(e.limits,this.limits,'limits');
  6099. }
  6100. ,
  6101. H.prototype.reset = function() {
  6102. this.loadView(this.resetDesc)
  6103. }
  6104. ,
  6105. H.prototype.updateView = function() {
  6106. if (void 0 !== this.limits) {
  6107. if (this.limits.angles) {
  6108. var e = this.limits.angles.x
  6109. , t = this.limits.angles.y;
  6110. if (void 0 !== e) {
  6111. var i = this.rotation[0] - e.offset;
  6112. e = Math.min(Math.max(i, e.min), e.max);
  6113. this.rotation[0] += e - i
  6114. }
  6115. void 0 !== t && (i = this.rotation[1] - t.offset,
  6116. e = Math.min(Math.max(i, t.min), t.max),
  6117. this.rotation[1] += e - i)
  6118. }
  6119. void 0 !== this.limits.orbitRadius && (t = this.limits.orbitRadius.min,
  6120. i = this.limits.orbitRadius.max,
  6121. void 0 !== t && (this.radius = Math.max(this.radius, t)),
  6122. void 0 !== i && (this.radius = Math.min(this.radius, i))),
  6123. void 0 !== this.limits.pan && (t = this.limits.pan,
  6124. i = this.resetDesc.pivot,
  6125. t.x && (this.pivot[0] = i[0]),
  6126. t.y && (this.pivot[1] = i[1]),
  6127. t.z && (this.pivot[2] = i[2]))
  6128. }
  6129. S.translation(this.transform, 0, 0, this.radius),
  6130. t = S.rotation(S.empty(), this.rotation[0], 0),
  6131. i = S.rotation(S.empty(), this.rotation[1], 1),
  6132. S.mul(t, i, t),
  6133. S.mul(this.transform, t, this.transform),
  6134. this.transform[12] += this.pivot[0],
  6135. this.transform[13] += this.pivot[1],
  6136. this.transform[14] += this.pivot[2],
  6137. S.invert(this.viewMatrix, this.transform),
  6138. S.mul(this.viewProjectionMatrix, this.viewMatrix, this.projectionMatrix)
  6139. }
  6140. ,
  6141. H.prototype.updateProjection = function(e) {
  6142. S.perspectiveInfinite(this.projectionMatrix, this.fov, this.size[0] / this.size[1], this.nearPlane, e),
  6143. S.mul(this.viewProjectionMatrix, this.projectionMatrix, this.viewMatrix)
  6144. }
  6145. ,
  6146. W.prototype.initCanvas = function(e, t) {
  6147. if (this.canvas && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas),
  6148. this.canvas = document.createElement("canvas"),
  6149. this.pixelRatio = window.devicePixelRatio || 1,
  6150. this.mobile) {
  6151. var i = this.mobileFast ? 1.5 : 1;
  6152. this.pixelRatio = this.pixelRatio > i ? i : this.pixelRatio
  6153. } else
  6154. this.desktopSlow && (this.pixelRatio = 1);
  6155. this.canvas.width = e * this.pixelRatio,
  6156. this.canvas.height = t * this.pixelRatio,
  6157. this.canvas.style.width = e + "px",
  6158. this.canvas.style.height = t + "px",
  6159. this.canvas.style.position = "absolute",
  6160. this.domRoot.appendChild(this.canvas)
  6161. }
  6162. ,
  6163. W.prototype.initGL = function() {
  6164. var e = {
  6165. alpha: !!I.transparentBackground,
  6166. depth: !1,
  6167. stencil: !1,
  6168. antialias: !1,
  6169. premultipliedAlpha: !!I.transparentBackground,
  6170. preserveDrawingBuffer: !1
  6171. };
  6172. e = this.gl = this.canvas.getContext("webgl", e) || this.canvas.getContext("experimental-webgl", e);
  6173. return this.gl ? (this.canvas.addEventListener("webglcontextlost", function(e) {
  6174. e.preventDefault()
  6175. }
  6176. , !1),
  6177. this.canvas.addEventListener("webglcontextrestored", function(e) {
  6178. this.loadScene(this.sceneURL)
  6179. }
  6180. .bind(this), !1),
  6181. e.ext = {
  6182. textureAniso: e.getExtension("EXT_texture_filter_anisotropic") || e.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || e.getExtension("MOZ_EXT_texture_filter_anisotropic"),
  6183. textureFloat: e.getExtension("OES_texture_float"),
  6184. textureFloatLinear: e.getExtension("OES_texture_float_linear"),
  6185. textureHalf: e.getExtension("OES_texture_half_float"),
  6186. textureHalfLinear: e.getExtension("OES_texture_half_float_linear"),
  6187. textureDepth: e.getExtension("WEBGL_depth_texture"),
  6188. colorBufferFloat: e.getExtension("WEBGL_color_buffer_float"),
  6189. colorBufferHalf: e.getExtension("EXT_color_buffer_half_float"),
  6190. index32bit: e.getExtension("OES_element_index_uint"),
  6191. loseContext: e.getExtension("WEBGL_lose_context"),
  6192. derivatives: e.getExtension("OES_standard_derivatives"),
  6193. renderInfo: e.getExtension("WEBGL_debug_renderer_info")
  6194. },
  6195. e.limits = {
  6196. textureSize: e.getParameter(e.MAX_TEXTURE_SIZE),
  6197. textureCount: e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),
  6198. varyings: e.getParameter(e.MAX_VARYING_VECTORS),
  6199. vertexAttribs: e.getParameter(e.MAX_VERTEX_ATTRIBS),
  6200. vertexUniforms: e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),
  6201. fragmentUniforms: e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),
  6202. viewportSizes: e.getParameter(e.MAX_VIEWPORT_DIMS),
  6203. vendor: e.getParameter(e.VENDOR),
  6204. version: e.getParameter(e.VERSION)
  6205. },
  6206. e.hints = {
  6207. mobile: this.mobile,
  6208. pixelRatio: this.pixelRatio
  6209. },
  6210. e.enable(e.DEPTH_TEST),
  6211. e.shaderCache = new O(e),
  6212. e.textureCache = new N(e),
  6213. this.allocBacking(),
  6214. !0) : (this.ui.showFailure('webgl出错。</br>建议您将浏览器升级至最新版本,以获最好的体验。<br><span style="font-size:0.8em">获知更多webgl浏览器信息请<a href="webglInfo.html" style="color: #a6ccea;">点击此处</a></span>', this),
  6215. !1)
  6216. }
  6217. ,
  6218. W.prototype.allocBacking = function() {
  6219. var e = this.gl
  6220. , t = !1
  6221. , i = {
  6222. width: this.canvas.width,
  6223. height: this.canvas.height
  6224. };
  6225. for (this.mainColor = new U(e,i),
  6226. this.mainDepth = null,
  6227. e.ext.textureDepth && (this.mainDepth = new U(e,{
  6228. width: this.canvas.width,
  6229. height: this.canvas.height,
  6230. nofilter: !0
  6231. }),
  6232. this.mainDepth.loadArray(null, e.DEPTH_COMPONENT, e.UNSIGNED_INT)),
  6233. e.ext.textureHalf && e.ext.textureHalfLinear && (this.mainColor.loadArray(null, e.RGBA, e.ext.textureHalf.HALF_FLOAT_OES),
  6234. this.mainBuffer = new m(e,{
  6235. color0: this.mainColor,
  6236. depth: this.mainDepth,
  6237. createDepth: !this.mainDepth
  6238. }),
  6239. t = this.mainBuffer.valid),
  6240. !t && e.ext.textureFloat && e.ext.textureFloatLinear && !e.hints.mobile && (this.mainColor.loadArray(null, e.RGBA, e.FLOAT),
  6241. this.mainBuffer = new m(e,{
  6242. color0: this.mainColor,
  6243. depth: this.mainDepth,
  6244. createDepth: !this.mainDepth
  6245. }),
  6246. t = this.mainBuffer.valid); !t; )
  6247. this.mainColor = new U(e,i),
  6248. this.mainColor.loadArray(null, e.RGBA, e.UNSIGNED_BYTE),
  6249. this.mainBuffer = new m(e,{
  6250. color0: this.mainColor,
  6251. depth: this.mainDepth,
  6252. createDepth: !this.mainDepth
  6253. }),
  6254. t = this.mainBuffer.valid,
  6255. i.width /= 2,
  6256. i.height /= 2,
  6257. this.mainDepth && (this.mainDepth.destroy(),
  6258. this.mainDepth = null);
  6259. this.mainBufferNoDepth = new m(e,{
  6260. color0: this.mainColor
  6261. })
  6262. }
  6263. ,
  6264. W.prototype.loadScene = function(e) {
  6265. if (this.sceneURL = e || this.sceneURL,
  6266. this.scene = this.input = null,
  6267. this.initGL() && this.sceneURL) {
  6268. var t = this.ui.signalLoadProgress.bind(this.ui);
  6269. e = function(e) {
  6270. t(1, 1),
  6271. this.scene = new k(this.gl),
  6272. this.scene.stripData = this.stripData,
  6273. this.scene.load(new h(e)) ? this.scene.metaData.tbVersion <= 2070 ? this.ui.showFailure("模型文件版本过低", this) : (this.bindInput(),
  6274. this.requestFrame(this.updateLoad.bind(this)),
  6275. this.onLoad && this.onLoad()) : this.ui.showFailure("模型文件无法读取或无效", this)
  6276. }
  6277. .bind(this);
  6278. var i = function() {
  6279. this.ui.showFailure("模型文件 (" + this.sceneURL + ") 无法获取.", this)
  6280. }
  6281. .bind(this);
  6282. C.fetchBinary(this.sceneURL, e, i, t)
  6283. }
  6284. }
  6285. ,
  6286. W.prototype.unload = function() {
  6287. delete this.scene,
  6288. delete this.input,
  6289. delete this.ui,
  6290. delete this.mainColor,
  6291. delete this.mainBuffer,
  6292. delete this.gl;
  6293. var e = this.domRoot.clientWidth
  6294. , t = this.domRoot.clientHeight;
  6295. this.initCanvas(e, t),
  6296. this.ui = new j(this),
  6297. this.ui.setSize(e, t),
  6298. this.ui.showPreview(),
  6299. this.cancelFrame()
  6300. }
  6301. ,
  6302. W.prototype.bindInput = function() {
  6303. this.input = new e(this.ui.container),
  6304. this.input.onDrag.push(function(e, t, i, s) {
  6305. e = 1 - 2.2 / (Math.sqrt(i * i + s * s) + 2.2),
  6306. (t = this.scene.view).rotation[1] -= .4 * i * e,
  6307. t.rotation[0] -= .4 * s * e,
  6308. t.rotation[0] = 90 < t.rotation[0] ? 90 : t.rotation[0],
  6309. t.rotation[0] = t.rotation[0] < -90 ? -90 : t.rotation[0],
  6310. t.updateView(),
  6311. this.wake()
  6312. }
  6313. .bind(this)),
  6314. this.input.onPan.push(function(e, t) {
  6315. var i = this.scene.view
  6316. , s = -e * (n = i.fov / 45 * .8 * (i.radius / this.domRoot.clientHeight))
  6317. , n = t * n;
  6318. i.pivot[0] += s * i.transform[0] + n * i.transform[4],
  6319. i.pivot[1] += s * i.transform[1] + n * i.transform[5],
  6320. i.pivot[2] += s * i.transform[2] + n * i.transform[6],
  6321. i.updateView(),
  6322. this.wake()
  6323. }
  6324. .bind(this)),
  6325. this.input.onPan2.push(function(e, t) {
  6326. var i = 1 - 2.2 / (Math.sqrt(e * e + t * t) + 2.2);
  6327. this.scene.lights.rotation -= .4 * e * i,
  6328. this.wake()
  6329. }
  6330. .bind(this)),
  6331. this.input.onZoom.push(function(e) {
  6332. rotInfo.stopWhenZoom && webview.stopRotate();
  6333. var t = this.scene.view;
  6334. t.radius *= 1 - .002 * e,
  6335. t.radius = t.radius < .001 ? .001 : t.radius,
  6336. t.radius = 1e3 < t.radius ? 1e3 : t.radius,
  6337. t.updateView(),
  6338. this.wake()
  6339. }
  6340. .bind(this)),
  6341. this.input.onDoubleTap.push(function(e, t) {
  6342. this.scene.view.reset(),
  6343. this.scene.sceneAnimator && this.scene.sceneAnimator.resetCustomView(),
  6344. this.wake()
  6345. }
  6346. .bind(this)),
  6347. this.ui.bindInput(this.input)
  6348. }
  6349. ,
  6350. W.prototype.rotateWhenIdle = function() {
  6351. if(webview.rotate)return
  6352. rotInfo.radiusK && (webview.scene.view.radius = rotInfo.radiusK / (dom.id("fdageUI").clientWidth / dom.id("fdageUI").clientHeight)),
  6353. webview.scene.view.pivot = rotInfo.pivot.slice(),
  6354. webview.rotate = setInterval(function() {
  6355. webview.scene.view.rotation[1] -= rotInfo.speed,
  6356. webview.updateView(!0, !0, 1)
  6357. }, 16)
  6358. }
  6359. ,
  6360. W.prototype.stopRotate = function(ifFinish) { //ifFinish是否不再自动旋转
  6361. if(webview.rotate){
  6362. clearInterval(webview.rotate),
  6363. // console.log("clearInterval(webview.rotate)"),
  6364. webview.rotate = null,
  6365. ifFinish || (webview.countIdelTime = setTimeout(webview.rotateWhenIdle, rotInfo.idleTime))
  6366. }else{
  6367. if(webview.countIdelTime){
  6368. clearTimeout(webview.countIdelTime),
  6369. // console.log("clearInterval(countIdelTime)"),
  6370. ifFinish || (webview.countIdelTime = setTimeout(webview.rotateWhenIdle, rotInfo.idleTime))
  6371. }
  6372. }
  6373. }
  6374. ,
  6375. W.prototype.resetView = function(e) {//add
  6376. this.scene.view.reset()
  6377. this.wake()
  6378. }
  6379. ,
  6380. W.prototype.zoomIn = function() {//add 放大
  6381. this.input.onZoom[0](130);//放大会比缩小快一些,所以降低数值
  6382. }
  6383. W.prototype.zoomOut = function() {//add 缩小
  6384. this.input.onZoom[0](-150);
  6385. }
  6386. W.prototype.wake = function(e) {
  6387. e = e || 16,
  6388. this.sleepCounter = this.sleepCounter < e ? e : this.sleepCounter,
  6389. this.scene.postRender.discardAAHistory(),
  6390. this.requestFrame(this.update.bind(this))
  6391. }
  6392. ,
  6393. W.prototype.requestFrame = function(e) {
  6394. var t = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;
  6395. if (!this.frameRequestPending) {
  6396. var i = function() {
  6397. this.frameRequestPending = 0,
  6398. e()
  6399. }
  6400. .bind(this);
  6401. this.frameRequestPending = t(i, this.canvas)
  6402. }
  6403. }
  6404. ,
  6405. W.prototype.cancelFrame = function() {
  6406. this.frameRequestPending && (window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame)(this.frameRequestPending)
  6407. }
  6408. ,
  6409. W.prototype.fullscreenChange = function() {
  6410. g.active() ? (this.oldRootWidth = this.domRoot.style.width,
  6411. this.oldRootHeight = this.domRoot.style.height,
  6412. this.domRoot.style.width = "100%",
  6413. this.domRoot.style.height = "100%") : (this.domRoot.style.width = this.oldRootWidth,
  6414. this.domRoot.style.height = this.oldRootHeight),
  6415. this.wake()
  6416. }
  6417. ,
  6418. W.prototype.resize = function(e, t) {
  6419. e && t ? (this.domRoot.style.width = e + "px",
  6420. this.domRoot.style.height = t + "px") : (e = this.domRoot.clientWidth,
  6421. t = this.domRoot.clientHeight),
  6422. this.canvas.width = e * this.pixelRatio,
  6423. this.canvas.height = t * this.pixelRatio,
  6424. this.canvas.style.width = e + "px",
  6425. this.canvas.style.height = t + "px",
  6426. this.ui.setSize(e, t),
  6427. this.allocBacking(),
  6428. this.wake()
  6429. }
  6430. ,
  6431. W.prototype.updateLoad = function() {
  6432. this.scene.complete() ? this.start() : this.requestFrame(this.updateLoad.bind(this)),
  6433. this.ui.animate()
  6434. }
  6435. ,
  6436. W.prototype.start = function() {
  6437. // console.log('模型加载完成');
  6438. setTimeout(() => {
  6439. let dom =document.querySelector('.outerImg')
  6440. if(dom){
  6441. dom.style.opacity=0
  6442. dom.style.pointerEvents='none'
  6443. }
  6444. }, 500);
  6445. this.scene.view.updateView(),
  6446. this.ui.showActiveView(),
  6447. this.requestFrame(this.update.bind(this)),
  6448. window.autoRotate && this.rotateWhenIdle(),
  6449. document.documentElement.style.height = "100%",
  6450. document.documentElement.style.width = "100%",
  6451. document.documentElement.style.margin = "0",
  6452. document.documentElement.style.padding = "0",
  6453. document.body.style.height = "100%",
  6454. document.body.style.width = "100%",
  6455. document.body.style.margin = "0",
  6456. document.body.style.padding = "0"
  6457. }
  6458. ,
  6459. W.prototype.update = function() {
  6460. var e = this.scene.sceneAnimator && !this.scene.sceneAnimator.paused;
  6461. (0 < this.sleepCounter || this.ui.animating() || e || this.stripData.animationActive) && (this.stripData.update(),
  6462. this.ui.animate(),
  6463. this.scene.update(),
  6464. this.drawScene(),
  6465. this.requestFrame(this.update.bind(this))),
  6466. e ? this.scene.postRender.discardAAHistory() : this.sleepCounter--
  6467. }
  6468. ,
  6469. W.prototype.reDrawScene = function() {
  6470. this.stripData.update(),
  6471. this.ui.animate(),
  6472. this.scene.update(),
  6473. this.drawScene(),
  6474. this.requestFrame(this.update.bind(this)),
  6475. this.scene.postRender.discardAAHistory()
  6476. }
  6477. ,
  6478. W.prototype.drawScene = function() {
  6479. this.gl.isContextLost() || (this.domRoot.clientWidth == this.canvas.clientWidth && this.domRoot.clientHeight == this.canvas.clientHeight || this.resize(),
  6480. this.scene.view.size = [this.mainBuffer.width, this.mainBuffer.height],
  6481. this.scene.view.updateProjection(),
  6482. this.scene.postRender.adjustProjectionForSupersampling(this.scene.view),
  6483. this.scene.collectShadows(this.mainBuffer),
  6484. this.mainBuffer.bind(),
  6485. this.scene.draw(this.mainBuffer),
  6486. this.mainDepth && (this.mainBufferNoDepth.bind(),
  6487. this.scene.drawSecondary(this.mainDepth)),
  6488. this.scene.postRender.present(this.mainColor, this.canvas.width, this.canvas.height, this.stripData.active()))
  6489. }
  6490. ,
  6491. W.prototype.updateView = function(e, t, i) {
  6492. t && webview.scene.view.updateView(),
  6493. webview.wake(i || 4),
  6494. e && webview.scene.postRender.discardAAHistory()
  6495. }
  6496. ,
  6497. (I = void 0 === I ? {} : I).WebViewer = W,
  6498. I.dataLocale = "images/";
  6499. var G = {
  6500. "alphaprepassfrag.glsl": "precision mediump float;\n#include <matdither.glsl>\nuniform sampler2D tAlbedo;varying mediump vec2 d;void main(){float e=texture2D(tAlbedo,d).a;if(e<=f(d.x)){discard;}gl_FragColor=vec4(0.0);}",
  6501. "alphaprepassvert.glsl": "precision highp float;uniform mat4 uModelViewProjectionMatrix;uniform vec2 uUVOffset;attribute vec3 vPosition;attribute vec2 vTexCoord;varying mediump vec2 d;vec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}void main(void){gl_Position=h(uModelViewProjectionMatrix,vPosition.xyz);d=vTexCoord+uUVOffset;}",
  6502. "bloom.glsl": "precision mediump float;uniform sampler2D tInput;uniform vec4 uKernel[BLOOM_SAMPLES];varying highp vec2 j;void main(void){vec3 c=vec3(0.0,0.0,0.0);for(int k=0;k<BLOOM_SAMPLES;++k){vec3 l=uKernel[k].xyz;vec3 m=texture2D(tInput,j+l.xy).xyz;m=max(m,vec3(0.0,0.0,0.0));c+=m*l.z;}gl_FragColor.xyz=c;gl_FragColor.w=0.0;}",
  6503. "bloomshrink.glsl": "precision highp float;uniform sampler2D tInput;varying highp vec2 j;void main(void){float o=0.25/256.0;gl_FragColor=0.25*(texture2D(tInput,j+vec2(o,o))+texture2D(tInput,j+vec2(o,-o))+texture2D(tInput,j+vec2(-o,o))+texture2D(tInput,j+vec2(-o,-o)));}",
  6504. "fogfrag.glsl": "precision highp float;uniform sampler2D tDepth;uniform vec3 uDepthToZ;uniform vec4 uUnproject;uniform mat4 uInvViewMatrix;uniform float uFogInvDistance;uniform float uFogOpacity;uniform float uFogDispersion;uniform vec3 uFogType;uniform vec3 uFogColor;uniform float uFogIllum;uniform mat4 uLightMatrix;\n#ifdef FOG_IBL\nuniform vec4 uFogLightSphere[9];\n#else\nuniform vec4 uSpotParams;uniform vec4 uLightPosition;uniform vec3 uLightColor;uniform vec4 uLightAttenuation;\n#ifdef FOG_SHADOWS\nuniform mat4 uShadowProj;uniform sampler2D uShadowMap;uniform float uDitherOffset;uniform vec4 uCylinder;\n#endif\n#endif\nvec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}vec3 u(mat4 i,vec3 v){return i[0].xyz*v.x+i[1].xyz*v.y+i[2].xyz*v.z;}float A(float B){B*=uFogInvDistance;float C=uFogType.x*min(B,1.0)+(uFogType.y-uFogType.y/(1.0+16.0*B*B))+(uFogType.z-uFogType.z*exp(-3.0*B));return C*uFogOpacity;}\n#ifdef FOG_SHADOWS\nfloat D(vec3 E){vec4 p=h(uShadowProj,E);vec3 F=p.xyz/p.w;vec4 G=texture2D(uShadowMap,F.xy);float H=(G.x+G.y*(1.0/255.0))+G.z*(1.0/65025.0);return F.z<H || H>=1.0?1.0:0.0;}float f(vec2 I){return fract(sin(dot(I,vec2(12.9898,78.233)))*43758.5453+uDitherOffset);}void J(vec3 K,vec3 L,out float M,out float N){vec3 v=uSpotParams.xyz,p=uCylinder.xyz;vec3 O=L-dot(L,v)*v;vec3 P=(K-p)-dot(K-p,v)*v;float a=dot(O,O);float b=2.0*dot(O,P);float c=dot(P,P)-uCylinder.w;float Q=b*b-4.0*a*c;if(Q>=0.0){Q=sqrt(Q);M=(-b-Q)/(2.0*a);N=(-b+Q)/(2.0*a);}else {M=N=0.0;}}\n#endif\nvarying vec2 j;void main(void){vec3 R=uInvViewMatrix[3].xyz;float H=texture2D(tDepth,j).x;H=min(H,0.9999);vec3 S;S.z=uDepthToZ.y/(uDepthToZ.z*H+uDepthToZ.x);S.xy=S.z*(j*uUnproject.xy+uUnproject.zw);S=h(uInvViewMatrix,S).xyz;vec3 T;T.xy=(j*uUnproject.xy+uUnproject.zw);T.z=1.0;T=normalize(u(uInvViewMatrix,-T).xyz);vec3 U=uFogColor;\n#if defined(FOG_IBL)\nvec3 G=u(uLightMatrix,T);vec3 V=uFogLightSphere[0].xyz;V+=uFogLightSphere[1].xyz*G.y;V+=uFogLightSphere[2].xyz*G.z;V+=uFogLightSphere[3].xyz*G.x;vec3 swz=G.yyz*G.xzx;V+=uFogLightSphere[4].xyz*swz.x;V+=uFogLightSphere[5].xyz*swz.y;V+=uFogLightSphere[7].xyz*swz.z;vec3 sqr=G*G;V+=uFogLightSphere[6].xyz*(3.0*sqr.z-1.0);V+=uFogLightSphere[8].xyz*(sqr.x-sqr.y);U=mix(U,U*V,uFogIllum);float C=A(length(S-R));gl_FragColor.xyz=U*C;gl_FragColor.w=C;return;\n#else\n#if defined(FOG_SPOT) || defined(FOG_OMNI)\nfloat W=0.0,X=0.0;{float r=1.0/(uLightAttenuation.z);float a=1.0;float b=2.0*dot(T,R-uLightPosition.xyz);float c=dot(uLightPosition.xyz,uLightPosition.xyz)+dot(R,R)+-2.0*dot(uLightPosition.xyz,R)+-r*r;float Q=b*b-4.0*a*c;if(Q>=0.0){Q=sqrt(Q);W=(-b-Q)/(2.0*a);X=(-b+Q)/(2.0*a);}}\n#if defined(FOG_SPOT)\n{float Y=uSpotParams.w,Z=1.0-Y;vec3 v=T;vec3 dc=uSpotParams.xyz;vec3 dd=R-uLightPosition.xyz;vec3 de=v-dot(v,dc)*dc,df=dd-dot(dd,dc)*dc;float a=Y*dot(de,de)-Z*dot(v,dc)*dot(v,dc);float b=2.0*Y*dot(de,df)-2.0*Z*dot(v,dc)*dot(dd,dc);float c=Y*dot(df,df)-Z*dot(dd,dc)*dot(dd,dc);float Q=b*b-4.0*a*c;if(Q>=0.0){float dh=(-b-sqrt(Q))/(2.0*a);float di=(-b+sqrt(Q))/(2.0*a);if(di<dh){float de=dh;dh=di;di=de;}bool dj=dot(-uLightPosition.xyz+R+T*dh,uSpotParams.xyz)<=0.0;bool dk=dot(-uLightPosition.xyz+R+T*di,uSpotParams.xyz)<=0.0;if(!dj ||!dk){if(dj){dh=di;di=X;}else if(dk){di=dh;dh=W;}W=max(W,dh);X=min(X,di);}else {X=W=0.0;}}else {X=W=0.0;}}\n#endif\nfloat tx=dot(T,S-R);W=clamp(W,0.0,tx);X=clamp(X,0.0,tx);float dl=0.0;if(X>W){\n#ifdef FOG_SHADOWS\n#ifdef MOBILE\n#define SAMPLES 16\n#else\n#define SAMPLES 32\n#endif\nfloat dm=f(j)*(X-W)/float(SAMPLES-2);\n#else\n#define SAMPLES 8\nfloat dm=0.0;\n#endif\nfor(int k=0;k<SAMPLES;++k){float t=W+(X-W)*float(k)/float(SAMPLES-1);vec3 p=R+(t+dm)*T;float a=clamp(length(p-uLightPosition.xyz)*uLightAttenuation.z,0.0,1.0);a=1.0+uLightAttenuation.x*a+uLightAttenuation.y*a*a;\n#ifdef FOG_SHADOWS\na*=D(p);\n#endif\ndl+=a-a*A(t);}dl*=1.0/float(SAMPLES);dl*=(X-W)*uLightAttenuation.z;dl*=A(X-W);}U*=dl*uFogIllum;\n#elif defined(FOG_DIR)\nfloat C=A(dot(T,S-R));\n#ifdef FOG_SHADOWS\nfloat W,X;J(R,T,W,X);float tx=dot(T,S-R);W=clamp(W,0.0,tx);X=clamp(X,0.0,tx);if(X>W){\n#ifdef MOBILE\n#define SAMPLES 16\n#else\n#define SAMPLES 32\n#endif\nfloat dl=0.0;float dm=f(j)*(X-W)/float(SAMPLES-2);float dn=(X-W)*(1.0/float(SAMPLES));for(int k=0;k<SAMPLES;++k){float t=W+float(k)*dn+dm;vec3 p=R+t*T;float s=D(p);C-=(1.0-s)*(A(t+dn)-A(t));}}\n#endif\nfloat du=0.5+0.5*dot(T,-uSpotParams.xyz);du=1.0+uFogDispersion*(2.0*du*du-1.0);U*=(0.1*C)*(du*uFogIllum);\n#endif\ngl_FragColor.xyz=U*uLightColor;gl_FragColor.w=0.0;\n#endif\n}",
  6505. "fogvert.glsl": "precision highp float;attribute vec2 vCoord;varying vec2 j;void main(void){j=vCoord;gl_Position.xy=2.0*vCoord-vec2(1.0,1.0);gl_Position.zw=vec2(0.0,1.0);}",
  6506. "matdither.glsl": "float f(highp float I){highp float G=0.5*fract(gl_FragCoord.x*0.5)+0.5*fract(gl_FragCoord.y*0.5);return 0.4+0.6*fract(G+3.141592e6*I);}",
  6507. "matfrag.glsl": "\n#extension GL_OES_standard_derivatives : enable\nprecision mediump float;varying highp vec3 dv;varying mediump vec2 d;varying mediump vec3 dA;varying mediump vec3 dB;varying mediump vec3 dC;\n#ifdef VERTEX_COLOR\nvarying lowp vec4 dD;\n#endif\n#ifdef TEXCOORD_SECONDARY\nvarying mediump vec2 dE;\n#endif\nuniform sampler2D tAlbedo;uniform sampler2D tReflectivity;uniform sampler2D tNormal;uniform sampler2D tExtras;uniform sampler2D tSkySpecular;\n#ifdef REFRACTION\nuniform sampler2D tRefraction;\n#endif\nuniform vec4 uDiffuseCoefficients[9];uniform vec3 uCameraPosition;uniform float uAlphaTest;uniform vec3 uFresnel;uniform float uHorizonOcclude;uniform float uHorizonSmoothing;\n#ifdef EMISSIVE\nuniform float uEmissiveScale;uniform vec4 uTexRangeEmissive;\n#endif\n#ifdef AMBIENT_OCCLUSION\nuniform vec4 uTexRangeAO;\n#endif\n#ifdef REFRACTION\nuniform float uRefractionIOREntry;uniform float uRefractionRayDistance;uniform vec3 uRefractionTint;uniform float uRefractionAlbedoTint;uniform mat4 uRefractionViewProjection;uniform vec4 uTexRangeRefraction;\n#endif\n#ifdef LIGHT_COUNT\nuniform vec4 uLightPositions[LIGHT_COUNT];uniform vec3 uLightDirections[LIGHT_COUNT];uniform vec3 uLightColors[LIGHT_COUNT];uniform vec3 uLightParams[LIGHT_COUNT];uniform vec3 uLightSpot[LIGHT_COUNT];\n#endif\n#ifdef ANISO\nuniform float uAnisoStrength;uniform vec3 uAnisoTangent;uniform float uAnisoIntegral;uniform vec4 uTexRangeAniso;\n#endif\n#define saturate(x) clamp( x, 0.0, 1.0 )\n#include <matsampling.glsl>\n#include <matlighting.glsl>\n#include <matshadows.glsl>\n#include <matskin.glsl>\n#include <matmicrofiber.glsl>\n#include <matstrips.glsl>\n#ifdef TRANSPARENCY_DITHER\n#include <matdither.glsl>\n#endif\nvoid main(void){vec4 m=texture2D(tAlbedo,d);vec3 dF=dG(m.xyz);float e=m.w;\n#ifdef VERTEX_COLOR\n{vec3 dH=dD.xyz;\n#ifdef VERTEX_COLOR_SRGB\ndH=dH*(dH*(dH*0.305306011+vec3(0.682171111))+vec3(0.012522878));\n#endif\ndF*=dH;\n#ifdef VERTEX_COLOR_ALPHA\ne*=dD.w;\n#endif\n}\n#endif\n#ifdef ALPHA_TEST\nif(e<uAlphaTest){discard;}\n#endif\n#ifdef TRANSPARENCY_DITHER\ne=(e>f(d.x))?1.0:e;\n#endif\nvec3 dI=dJ(texture2D(tNormal,d).xyz);\n#ifdef ANISO\n#ifdef ANISO_NO_DIR_TEX\nvec3 dK=dL(uAnisoTangent);\n#else\nm=dM(d,uTexRangeAniso);vec3 dK=2.0*m.xyz-vec3(1.0);dK=dL(dK);\n#endif\ndK=dK-dI*dot(dK,dI);dK=normalize(dK);vec3 dN=dK*uAnisoStrength;\n#endif\nvec3 dO=normalize(uCameraPosition-dv);m=texture2D(tReflectivity,d);vec3 dP=dG(m.xyz);float dQ=m.w;float dR=dQ;\n#ifdef HORIZON_SMOOTHING\nfloat dS=dot(dO,dI);dS=uHorizonSmoothing-dS*uHorizonSmoothing;dQ=mix(dQ,1.0,dS*dS);\n#endif\n#ifdef STRIPVIEW\ndT dU;dV(dU,dQ,dP);\n#endif\nfloat dW=1.0;\n#ifdef AMBIENT_OCCLUSION\n#ifdef AMBIENT_OCCLUSION_SECONDARY_UV\ndW=dM(dE,uTexRangeAO).x;\n#else\ndW=dM(d,uTexRangeAO).x;\n#endif\ndW*=dW;\n#endif\n#if defined(SKIN)\ndX dY;dZ(dY);dY.ec*=dW;\n#elif defined(MICROFIBER)\ned ee;ef(ee,dI);ee.eh*=dW;\n#else\nvec3 ei=ej(dI);ei*=dW;\n#endif\nvec3 ek=reflect(-dO,dI);\n#ifdef ANISO\nvec3 rt=ek-(0.5*dN*dot(ek,dK));vec3 el=em(rt,mix(dQ,0.5*dQ,uAnisoStrength));\n#else\nvec3 el=em(ek,dQ);\n#endif\nel*=en(ek,dC);\n#ifdef LIGHT_COUNT\nhighp float eo=10.0/log2(dQ*0.968+0.03);eo*=eo;float eu=eo*(1.0/(8.0*3.1415926))+(4.0/(8.0*3.1415926));eu=min(eu,1.0e3);\n#ifdef SHADOW_COUNT\nev eA;\n#ifdef SKIN\n#ifdef SKIN_VERSION_1\neB(eA,SHADOW_KERNEL+SHADOW_KERNEL*dY.eC);\n#else\neD eE;float eF=SHADOW_KERNEL+SHADOW_KERNEL*dY.eC;eG(eE,eF);eB(eA,eF);\n#endif\n#else\neB(eA,SHADOW_KERNEL);\n#endif\n#endif\n#ifdef ANISO\neu*=uAnisoIntegral;\n#endif\nfor(int k=0;k<LIGHT_COUNT;++k){vec3 eH=uLightPositions[k].xyz-dv*uLightPositions[k].w;float eI=inversesqrt(dot(eH,eH));eH*=eI;float a=saturate(uLightParams[k].z/eI);a=1.0+a*(uLightParams[k].x+uLightParams[k].y*a);float s=saturate(dot(eH,uLightDirections[k]));s=saturate(uLightSpot[k].y-uLightSpot[k].z*(1.0-s*s));vec3 eJ=(a*s)*uLightColors[k].xyz;\n#if defined(SKIN)\n#ifdef SHADOW_COUNT\n#ifdef SKIN_VERSION_1\neK(dY,eA.eL[k],1.0,eH,dI,eJ);\n#else\neK(dY,eA.eL[k],eE.eE[k],eH,dI,eJ);\n#endif\n#else\neK(dY,1.0,0.0,eH,dI,eJ);\n#endif\n#elif defined(MICROFIBER)\n#ifdef SHADOW_COUNT\neM(ee,eA.eL[k],eH,dI,eJ);\n#else\neM(ee,1.0,eH,dI,eJ);\n#endif\n#else\nfloat eN=saturate((1.0/3.1415926)*dot(eH,dI));\n#ifdef SHADOW_COUNT\neN*=eA.eL[k];\n#endif\nei+=eN*eJ;\n#endif\nvec3 eO=eH+dO;\n#ifdef ANISO\neO=eO-(dN*dot(eO,dK));\n#endif\neO=normalize(eO);float eP=eu*pow(saturate(dot(eO,dI)),eo);\n#ifdef SHADOW_COUNT\neP*=eA.eL[k];\n#endif\nel+=eP*eJ;}\n#endif\n#if defined(SKIN)\nvec3 ei,diff_extra;eQ(ei,diff_extra,dY,dO,dI,dQ);\n#elif defined(MICROFIBER)\nvec3 ei,diff_extra;eR(ei,diff_extra,ee,dO,dI,dQ);\n#endif\nvec3 eS=eT(dO,dI,dP,dQ*dQ);el*=eS;\n#ifdef REFRACTION\nvec4 eU;{vec3 G=refract(-dO,dI,uRefractionIOREntry);G=dv+G*uRefractionRayDistance;vec4 eV=uRefractionViewProjection[0]*G.x+(uRefractionViewProjection[1]*G.y+(uRefractionViewProjection[2]*G.z+uRefractionViewProjection[3]));vec2 c=eV.xy/eV.w;c=0.5*c+vec2(0.5,0.5);vec2 i=mod(floor(c),2.0);c=fract(c);c.x=i.x>0.0?1.0-c.x:c.x;c.y=i.y>0.0?1.0-c.y:c.y;eU.rgb=texture2D(tRefraction,c).xyz;eU.rgb=mix(eU.rgb,eU.rgb*dF,uRefractionAlbedoTint);eU.rgb=eU.rgb-eU.rgb*eS;eU.rgb*=uRefractionTint;\n#ifdef REFRACTION_NO_MASK_TEX\neU.a=1.0;\n#else\neU.a=dM(d,uTexRangeRefraction).x;\n#endif\n}\n#endif\n#ifdef DIFFUSE_UNLIT\ngl_FragColor.xyz=dF;\n#else\ngl_FragColor.xyz=ei*dF;\n#endif\n#ifdef REFRACTION\ngl_FragColor.xyz=mix(gl_FragColor.xyz,eU.rgb,eU.a);\n#endif\ngl_FragColor.xyz+=el;\n#if defined(SKIN) || defined(MICROFIBER)\ngl_FragColor.xyz+=diff_extra;\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVE_SECONDARY_UV\nvec2 eW=dE;\n#else\nvec2 eW=d;\n#endif\ngl_FragColor.xyz+=uEmissiveScale*dG(dM(eW,uTexRangeEmissive).xyz);\n#endif\n#ifdef STRIPVIEW\ngl_FragColor.xyz=eX(dU,dI,dF,dP,dR,ei,el,gl_FragColor.xyz);\n#endif\n#ifdef NOBLEND\ngl_FragColor.w=1.0;\n#else\ngl_FragColor.w=e;\n#endif\n}",
  6508. "matlighting.glsl": "vec3 eY(vec3 eZ,float fc){return exp(-0.5*fc/(eZ*eZ))/(eZ*2.5066283);}vec3 fd(vec3 eZ){return vec3(1.0,1.0,1.0)/(eZ*2.5066283);}vec3 fe(vec3 ff){return vec3(-0.5,-0.5,-0.5)/(ff);}vec3 fh(vec3 fi,float fc){return exp(fi*fc);}\n#define SAMPLE_COUNT 21.0\n#define SAMPLE_HALF 10.0\n#define GAUSS_SPREAD 0.05\nvec3 fj(float fk,float fl,vec3 fm){vec3 fn=vec3(fl,fl,fl);fn=0.8*fn+vec3(0.2);vec3 fo=cos(fn*3.14159);vec3 fu=cos(fn*3.14159*0.5);fu*=fu;fu*=fu;fu*=fu;fn=fn+0.05*fo*fu*fm;fu*=fu;fu*=fu;fu*=fu;fn=fn+0.1*fo*fu*fm;fn=saturate(fn);fn*=fn*1.2;return fn;}vec3 fv(vec3 fm){return vec3(1.0,1.0,1.0)/3.1415926;}float fA(float fk,float fm){return saturate(-fk*fm+fk+fm);}vec3 fB(float fk,vec3 fm){return saturate(-fk*fm+vec3(fk)+fm);}float fC(float fm){return-0.31830988618379*fm+0.31830988618379;}vec3 fD(vec3 fm){return-0.31830988618379*fm+vec3(0.31830988618379);}vec3 eT(vec3 dO,vec3 dI,vec3 dP,float fE){float C=1.0-saturate(dot(dO,dI));float fF=C*C;C*=fF*fF;C*=fE;return(dP-C*dP)+C*uFresnel;}vec2 fG(vec2 fH,vec2 fm){fH=1.0-fH;vec2 fI=fH*fH;fI*=fI;fH=mix(fI,fH*0.4,fm);return fH;}vec3 ej(vec3 fJ){\n#define c(n) uDiffuseCoefficients[n].xyz\nvec3 G=(c(0)+fJ.y*((c(1)+c(4)*fJ.x)+c(5)*fJ.z))+fJ.x*(c(3)+c(7)*fJ.z)+c(2)*fJ.z;\n#undef c\nvec3 sqr=fJ*fJ;G+=uDiffuseCoefficients[6].xyz*(3.0*sqr.z-1.0);G+=uDiffuseCoefficients[8].xyz*(sqr.x-sqr.y);return G;}void fK(inout vec3 fL,inout vec3 fM,inout vec3 fN,vec3 fJ){fL=uDiffuseCoefficients[0].xyz;fM=uDiffuseCoefficients[1].xyz*fJ.y;fM+=uDiffuseCoefficients[2].xyz*fJ.z;fM+=uDiffuseCoefficients[3].xyz*fJ.x;vec3 swz=fJ.yyz*fJ.xzx;fN=uDiffuseCoefficients[4].xyz*swz.x;fN+=uDiffuseCoefficients[5].xyz*swz.y;fN+=uDiffuseCoefficients[7].xyz*swz.z;vec3 sqr=fJ*fJ;fN+=uDiffuseCoefficients[6].xyz*(3.0*sqr.z-1.0);fN+=uDiffuseCoefficients[8].xyz*(sqr.x-sqr.y);}vec3 fO(vec3 fL,vec3 fM,vec3 fN,vec3 fP,float fm){fP=mix(vec3(1.0),fP,fm);return(fL+fM*fP.x)+fN*fP.z;}vec3 fQ(vec3 fL,vec3 fM,vec3 fN,vec3 fP,vec3 fR){vec3 fS=mix(vec3(1.0),fP.yyy,fR);vec3 fT=mix(vec3(1.0),fP.zzz,fR);return(fL+fM*fS)+fN*fT;}vec3 em(vec3 fJ,float dQ){fJ/=dot(vec3(1.0),abs(fJ));vec2 fU=abs(fJ.zx)-vec2(1.0,1.0);vec2 fV=vec2(fJ.x<0.0?fU.x:-fU.x,fJ.z<0.0?fU.y:-fU.y);vec2 fW=(fJ.y<0.0)?fV:fJ.xz;fW=vec2(0.5*(254.0/256.0),0.125*0.5*(254.0/256.0))*fW+vec2(0.5,0.125*0.5);float fX=fract(7.0*dQ);fW.y+=0.125*(7.0*dQ-fX);vec2 fY=fW+vec2(0.0,0.125);vec4 fZ=mix(texture2D(tSkySpecular,fW),texture2D(tSkySpecular,fY),fX);vec3 r=fZ.xyz*(7.0*fZ.w);return r*r;}float en(vec3 fJ,vec3 hc){float hd=dot(fJ,hc);hd=saturate(1.0+uHorizonOcclude*hd);return hd*hd;}",
  6509. "matmicrofiber.glsl": "\n#ifdef MICROFIBER\nuniform vec4 uTexRangeFuzz;uniform vec4 uFresnelColor;uniform float uFresnelIntegral;uniform float uFresnelOcc;uniform float uFresnelGlossMask;struct ed{vec3 eh;vec3 eN;vec3 he;vec3 hf;vec3 hh;};void ef(out ed s,vec3 dI){s.eh=s.eN=ej(dI);s.he=vec3(0.0);s.hf=uFresnelColor.rgb;s.hh=uFresnelColor.aaa*vec3(1.0,0.5,0.25);\n#ifndef MICROFIBER_NO_FUZZ_TEX\nvec4 m=dM(d,uTexRangeFuzz);s.hf*=dG(m.rgb);\n#endif\n}void eM(inout ed s,float hi,vec3 eH,vec3 dI,vec3 eJ){float fk=dot(eH,dI);float eN=saturate((1.0/3.1415926)*fk);float hj=fA(fk,s.hh.z);\n#ifdef SHADOW_COUNT\neN*=hi;float hk=mix(1.0,hi,uFresnelOcc);float he=hj*hk;\n#else \nfloat he=hj;\n#endif\ns.he=he*eJ+s.he;s.eN=eN*eJ+s.eN;}void eR(out vec3 ei,out vec3 diff_extra,inout ed s,vec3 dO,vec3 dI,float dQ){s.he*=uFresnelIntegral;float fH=dot(dO,dI);vec2 hl=fG(vec2(fH,fH),s.hh.xy);s.he=s.eh*hl.x+(s.he*hl.y);s.he*=s.hf;float hm=saturate(1.0+-uFresnelGlossMask*dQ);s.he*=hm*hm;ei=s.eN;diff_extra=s.he;}\n#endif\n",
  6510. "matsampling.glsl": "vec3 dG(vec3 c){return c*c;}vec3 dJ(vec3 n){vec3 hn=dA;vec3 ho=dB;vec3 hu=gl_FrontFacing?dC:-dC;\n#ifdef TSPACE_RENORMALIZE\nhu=normalize(hu);\n#endif\n#ifdef TSPACE_ORTHOGONALIZE\nhn-=dot(hn,hu)*hu;\n#endif\n#ifdef TSPACE_RENORMALIZE\nhn=normalize(hn);\n#endif\n#ifdef TSPACE_ORTHOGONALIZE\nho=(ho-dot(ho,hu)*hu)-dot(ho,hn)*hn;\n#endif\n#ifdef TSPACE_RENORMALIZE\nho=normalize(ho);\n#endif\n#ifdef TSPACE_COMPUTE_BITANGENT\nvec3 hv=cross(hu,hn);ho=dot(hv,ho)<0.0?-hv:hv;\n#endif\nn=2.0*n-vec3(1.0);return normalize(hn*n.x+ho*n.y+hu*n.z);}vec3 dL(vec3 t){vec3 hu=gl_FrontFacing?dC:-dC;return normalize(dA*t.x+dB*t.y+hu*t.z);}vec4 dM(vec2 hA,vec4 hB){\n#if GL_OES_standard_derivatives\nvec2 hC=fract(hA);vec2 hD=fwidth(hC);float hE=(hD.x+hD.y)>0.5?-6.0:0.0;return texture2D(tExtras,hC*hB.xy+hB.zw,hE);\n#else\nreturn texture2D(tExtras,fract(hA)*hB.xy+hB.zw);\n#endif\n}vec3 hF(sampler2D hG,vec2 hH,float hI){vec3 n=texture2D(hG,hH,hI*2.5).xyz;return dJ(n);}",
  6511. "matshadows.glsl": "\n#ifdef SHADOW_COUNT\n#ifdef MOBILE\n#define SHADOW_KERNEL (4.0/1536.0)\n#else\n#define SHADOW_KERNEL (4.0/2048.0)\n#endif\nhighp vec4 h(highp mat4 i,highp vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}uniform sampler2D tDepth0;\n#if SHADOW_COUNT > 1\nuniform sampler2D tDepth1;\n#if SHADOW_COUNT > 2\nuniform sampler2D tDepth2;\n#endif\n#endif\nuniform highp vec2 uShadowKernelRotation;uniform highp vec2 uShadowMapSize;uniform highp mat4 uShadowMatrices[SHADOW_COUNT];uniform highp vec4 uShadowTexelPadProjections[SHADOW_COUNT];\n#ifndef MOBILE\nuniform highp mat4 uInvShadowMatrices[SHADOW_COUNT];\n#endif\nhighp float hJ(highp vec3 G){\n#ifdef SHADOW_NATIVE_DEPTH\nreturn G.x;\n#else\nreturn(G.x+G.y*(1.0/255.0))+G.z*(1.0/65025.0);\n#endif\n}\n#ifndef SHADOW_COMPARE\n#define SHADOW_COMPARE(a,b) ((a) < (b) ? 1.0 : 0.0)\n#endif\n#ifndef SHADOW_CLIP\n#define SHADOW_CLIP(c,v) v\n#endif\nfloat hK(sampler2D hL,highp vec2 hA,highp float H){\n#ifndef MOBILE\nhighp vec2 c=hA*uShadowMapSize.x;highp vec2 a=floor(c)*uShadowMapSize.y,b=ceil(c)*uShadowMapSize.y;highp vec4 eE;eE.x=hJ(texture2D(hL,a).xyz);eE.y=hJ(texture2D(hL,vec2(b.x,a.y)).xyz);eE.z=hJ(texture2D(hL,vec2(a.x,b.y)).xyz);eE.w=hJ(texture2D(hL,b).xyz);highp vec4 hM;hM.x=SHADOW_COMPARE(H,eE.x);hM.y=SHADOW_COMPARE(H,eE.y);hM.z=SHADOW_COMPARE(H,eE.z);hM.w=SHADOW_COMPARE(H,eE.w);highp vec2 w=c-a*uShadowMapSize.x;vec2 s=(w.y*hM.zw+hM.xy)-w.y*hM.xy;return(w.x*s.y+s.x)-w.x*s.x;\n#else\nhighp float G=hJ(texture2D(hL,hA.xy).xyz);return SHADOW_COMPARE(H,G);\n#endif\n}highp float hN(sampler2D hL,highp vec3 hA,float hO){highp vec2 l=uShadowKernelRotation*hO;float s;s=hK(hL,hA.xy+l,hA.z);s+=hK(hL,hA.xy-l,hA.z);s+=hK(hL,hA.xy+vec2(-l.y,l.x),hA.z);s+=hK(hL,hA.xy+vec2(l.y,-l.x),hA.z);s*=0.25;return s*s;}struct ev{float eL[LIGHT_COUNT];};void eB(out ev ss,float hO){highp vec3 hP[SHADOW_COUNT];vec3 hu=gl_FrontFacing?dC:-dC;for(int k=0;k<SHADOW_COUNT;++k){vec4 hQ=uShadowTexelPadProjections[k];float hR=hQ.x*dv.x+(hQ.y*dv.y+(hQ.z*dv.z+hQ.w));\n#ifdef MOBILE\nhR*=.001+hO;\n#else\nhR*=.0005+0.5*hO;\n#endif\nhighp vec4 hS=h(uShadowMatrices[k],dv+hR*hu);hP[k]=hS.xyz/hS.w;}float m;\n#if SHADOW_COUNT > 0\nm=hN(tDepth0,hP[0],hO);ss.eL[0]=SHADOW_CLIP(hP[0].xy,m);\n#endif\n#if SHADOW_COUNT > 1\nm=hN(tDepth1,hP[1],hO);ss.eL[1]=SHADOW_CLIP(hP[1].xy,m);\n#endif\n#if SHADOW_COUNT > 2\nm=hN(tDepth2,hP[2],hO);ss.eL[2]=SHADOW_CLIP(hP[2].xy,m);\n#endif\nfor(int k=SHADOW_COUNT;k<LIGHT_COUNT;++k){ss.eL[k]=1.0;}}struct eD{highp float eE[LIGHT_COUNT];};\n#ifdef MOBILE\nvoid eG(out eD ss,float hO){for(int k=0;k<LIGHT_COUNT;++k){ss.eE[k]=1.0;}}\n#else\nhighp vec4 hT(sampler2D hL,highp vec2 hA,highp mat4 hU){highp vec4 E;E.xy=hA;\n#ifndef MOBILE\nhighp vec2 c=hA*uShadowMapSize.x;highp vec2 a=floor(c)*uShadowMapSize.y,b=ceil(c)*uShadowMapSize.y;highp vec4 hM;hM.x=hJ(texture2D(hL,a).xyz);hM.y=hJ(texture2D(hL,vec2(b.x,a.y)).xyz);hM.z=hJ(texture2D(hL,vec2(a.x,b.y)).xyz);hM.w=hJ(texture2D(hL,b).xyz);highp vec2 w=c-a*uShadowMapSize.x;vec2 s=(w.y*hM.zw+hM.xy)-w.y*hM.xy;E.z=(w.x*s.y+s.x)-w.x*s.x;\n#else \nE.z=hJ(texture2D(hL,hA.xy).xyz);\n#endif\nE=h(hU,E.xyz);E.xyz/=E.w;return E;}void eG(out eD ss,float hO){highp vec3 hV[SHADOW_COUNT];vec3 hu=gl_FrontFacing?dC:-dC;hu*=0.6;for(int k=0;k<SHADOW_COUNT;++k){vec4 hQ=uShadowTexelPadProjections[k];float hR=hQ.x*dv.x+(hQ.y*dv.y+(hQ.z*dv.z+hQ.w));\n#ifdef MOBILE\nhR*=.001+hO;\n#else\nhR*=.0005+0.5*hO;\n#endif\nhighp vec4 hS=h(uShadowMatrices[k],dv-hR*hu);hV[k]=hS.xyz/hS.w;}highp vec4 hW;\n#if SHADOW_COUNT > 0\nhW=hT(tDepth0,hV[0].xy,uInvShadowMatrices[0]);ss.eE[0]=length(dv.xyz-hW.xyz);\n#endif\n#if SHADOW_COUNT > 1\nhW=hT(tDepth1,hV[1].xy,uInvShadowMatrices[1]);ss.eE[1]=length(dv.xyz-hW.xyz);\n#endif\n#if SHADOW_COUNT > 2\nhW=hT(tDepth2,hV[2].xy,uInvShadowMatrices[2]);ss.eE[2]=length(dv.xyz-hW.xyz);\n#endif\nfor(int k=SHADOW_COUNT;k<LIGHT_COUNT;++k){ss.eE[k]=1.0;}}\n#endif\n#endif\n",
  6512. "matskin.glsl": "\n#ifdef SKIN\n#ifndef SKIN_NO_SUBDERMIS_TEX\nuniform vec4 uTexRangeSubdermis;\n#endif\n#ifndef SKIN_NO_TRANSLUCENCY_TEX\nuniform vec4 uTexRangeTranslucency;\n#endif\n#ifndef SKIN_NO_FUZZ_TEX\nuniform vec4 uTexRangeFuzz;\n#endif\nuniform vec4 uTransColor;uniform vec4 uFresnelColor;uniform vec3 uSubdermisColor;uniform float uTransScatter;uniform float uFresnelOcc;uniform float uFresnelGlossMask;uniform float uTransSky;uniform float uFresnelIntegral;uniform float uTransIntegral;uniform float uSkinTransDepth;uniform float uSkinShadowBlur;uniform float uNormalSmooth;struct dX{vec3 hX;vec3 hY,hZ,ic,he;vec3 ec,eh,id;vec3 ie;vec3 ih;vec3 ii;vec3 ij;float ik;float il;float im;float eC;};void dZ(out dX s){vec4 m;\n#ifdef SKIN_NO_SUBDERMIS_TEX\ns.hX=uSubdermisColor;s.im=1.0;\n#else \nm=dM(d,uTexRangeSubdermis);s.hX=dG(m.xyz);s.im=m.w*m.w;\n#endif\ns.ij=uTransColor.rgb;s.ik=uTransScatter;\n#ifdef SKIN_VERSION_1\ns.eC=uSkinShadowBlur*s.im;\n#else \ns.il=max(max(s.ij.r,s.ij.g),s.ij.b)*uTransColor.a;float io=max(s.hX.r,max(s.hX.g,s.hX.b));io=1.0-io;io*=io;io*=io;io*=io;io=1.0-(io*io);s.im*=io;s.eC=uSkinShadowBlur*s.im*dot(s.hX.rgb,vec3(0.333,0.334,0.333));\n#endif\n#ifndef SKIN_NO_TRANSLUCENCY_TEX\nm=dM(d,uTexRangeTranslucency);s.ij*=dG(m.xyz);\n#endif\ns.ie=hF(tNormal,d,uNormalSmooth*s.im);vec3 iu,iv,iA;fK(iu,iv,iA,s.ie);s.eh=s.hY=iu+iv+iA;\n#ifdef SKIN_VERSION_1 \ns.ec=fQ(iu,iv,iA,vec3(1.0,0.6667,0.25),s.hX);\n#else\ns.ec=fQ(iu,iv,iA,vec3(1.0,0.6667,0.25),s.hX*0.2+vec3(0.1));\n#endif\n#ifdef SKIN_VERSION_1\nvec3 iB,iC,iD;fK(iB,iC,iD,-s.ie);s.id=fO(iB,iC,iD,vec3(1.0,0.4444,0.0625),s.ik);s.id*=uTransSky;\n#else \ns.id=vec3(0.0);\n#endif\ns.hZ=s.ic=s.he=vec3(0.0);s.hX*=0.5;s.ik*=0.5;s.ih=uFresnelColor.rgb;s.ii=uFresnelColor.aaa*vec3(1.0,0.5,0.25);\n#ifndef SKIN_NO_FUZZ_TEX\nm=dM(d,uTexRangeFuzz);s.ih*=dG(m.rgb);\n#endif\n}void eK(inout dX s,float iE,float iF,vec3 eH,vec3 dI,vec3 eJ){float fk=dot(eH,dI);float fl=dot(eH,s.ie);float eN=saturate((1.0/3.1415926)*fk);float hi=iE*iE;hi*=hi;hi=saturate(6.0*hi);\n#ifdef SKIN_VERSION_1 \nvec3 iG=fB(fl,s.hX);\n#else \nvec3 iG=fj(fk,fl,s.hX);\n#endif\nfloat iH=fA(-fl,s.ik);vec3 ic=vec3(iH*iH);\n#ifdef SKIN_VERSION_1\n#ifdef SHADOW_COUNT\nvec3 iI=vec3(iE);float iJ=saturate(hi-2.0*(iE*iE));iI+=iJ*s.hX;float iK=iE;\n#endif\n#else\n#ifdef SHADOW_COUNT\nvec3 iI;highp vec3 iL=(0.995*s.hX)+vec3(0.005,0.005,0.005);highp vec3 iM=vec3(1.0)-iL;iL=mix(iL,iM,iE);float iN=sqrt(iE);vec3 iO=2.0*vec3(1.0-iN);iN=1.0-iN;iN=(1.0-iN*iN);iI=saturate(pow(iL*iN,iO));highp float iP=0.35/(uSkinTransDepth+0.001);highp float iQ=saturate(iF*iP);iQ=saturate(1.0-iQ);iQ*=iQ;highp vec3 iR=vec3((-3.0*iQ)+3.15);highp vec3 iS=(0.9975*s.ij)+vec3(0.0025,0.0025,0.0025);highp float io=saturate(10.0*dot(iS,iS));vec3 iK=pow(iS*iQ,iR)*io;\n#else \nic=vec3(0.0);\n#endif\n#endif\nfloat hj=fA(fl,s.ii.z);\n#ifdef SHADOW_COUNT\nvec3 hk=mix(vec3(1.0),iI,uFresnelOcc);vec3 he=hj*hk;\n#else\nvec3 he=vec3(hj);\n#endif\n#ifdef SHADOW_COUNT\niG*=iI;eN*=hi;ic*=iK;\n#endif\ns.he=he*eJ+s.he;s.ic=ic*eJ+s.ic;s.hZ=iG*eJ+s.hZ;s.hY=eN*eJ+s.hY;}void eQ(out vec3 ei,out vec3 diff_extra,inout dX s,vec3 dO,vec3 dI,float dQ){s.he*=uFresnelIntegral;float fH=dot(dO,dI);vec2 hl=fG(vec2(fH,fH),s.ii.xy);s.he=s.eh*hl.x+(s.he*hl.y);s.he*=s.ih;float hm=saturate(1.0+-uFresnelGlossMask*dQ);s.he*=hm*hm;s.ic=s.ic*uTransIntegral;\n#ifdef SKIN_VERSION_1\ns.hZ=(s.hZ*fD(s.hX))+s.ec;\n#else\ns.hZ=(s.hZ*fv(s.hX))+s.ec;\n#endif\nei=mix(s.hY,s.hZ,s.im);\n#ifdef SKIN_VERSION_1\ns.ic=(s.ic+s.id)*s.ij;diff_extra=(s.he+s.ic)*s.im;\n#else\nei+=s.ic*s.il;diff_extra=s.he*s.im;\n#endif\n}\n#endif\n",
  6513. "matstrips.glsl": "\n#ifdef STRIPVIEW\nuniform float uStrips[5];uniform vec2 uStripRes;struct dT{float io[5];float bg;};void dV(out dT iT,inout float dQ,inout vec3 dP){highp vec2 hA=gl_FragCoord.xy*uStripRes-vec2(1.0,1.0);hA.x+=0.25*hA.y;iT.io[0]=step(hA.x,uStrips[0]);iT.io[1]=step(hA.x,uStrips[1]);iT.io[2]=step(hA.x,uStrips[2]);iT.io[3]=step(hA.x,uStrips[3]);iT.io[4]=step(hA.x,uStrips[4]);iT.bg=1.0-iT.io[4];iT.io[4]-=iT.io[3];iT.io[3]-=iT.io[2];iT.io[2]-=iT.io[1];iT.io[1]-=iT.io[0];bool iU=iT.io[4]>0.0;dQ=iU?0.5:dQ;dP=iU?vec3(0.1):dP;}vec3 eX(dT iT,vec3 dI,vec3 dF,vec3 dP,float dQ,vec3 ei,vec3 el,vec3 iV){return iT.io[0]*(dI*0.5+vec3(0.5))+iT.io[1]*dF+iT.io[2]*dP+vec3(iT.io[3]*dQ)+iT.io[4]*(vec3(0.12)+0.3*ei+el)+iT.bg*iV;}\n#endif\n",
  6514. "matvert.glsl": "precision highp float;uniform mat4 uModelViewProjectionMatrix;uniform mat4 uSkyMatrix;uniform vec2 uUVOffset;attribute vec3 vPosition;attribute vec2 vTexCoord;attribute vec2 vTangent;attribute vec2 vBitangent;attribute vec2 vNormal;\n#ifdef VERTEX_COLOR\nattribute vec4 vColor;\n#endif\n#ifdef TEXCOORD_SECONDARY\nattribute vec2 vTexCoord2;\n#endif\nvarying highp vec3 dv;varying mediump vec2 d;varying mediump vec3 dA;varying mediump vec3 dB;varying mediump vec3 dC;\n#ifdef VERTEX_COLOR\nvarying lowp vec4 dD;\n#endif\n#ifdef TEXCOORD_SECONDARY\nvarying mediump vec2 dE;\n#endif\nvec3 iW(vec2 v){bool iX=(v.y>(32767.1/65535.0));v.y=iX?(v.y-(32768.0/65535.0)):v.y;vec3 r;r.xy=(2.0*65535.0/32767.0)*v-vec2(1.0);r.z=sqrt(clamp(1.0-dot(r.xy,r.xy),0.0,1.0));r.z=iX?-r.z:r.z;return r;}vec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}vec3 u(mat4 i,vec3 v){return i[0].xyz*v.x+i[1].xyz*v.y+i[2].xyz*v.z;}void main(void){gl_Position=h(uModelViewProjectionMatrix,vPosition.xyz);d=vTexCoord+uUVOffset;dA=u(uSkyMatrix,iW(vTangent));dB=u(uSkyMatrix,iW(vBitangent));dC=u(uSkyMatrix,iW(vNormal));dv=h(uSkyMatrix,vPosition.xyz).xyz;\n#ifdef VERTEX_COLOR\ndD=vColor;\n#endif\n#ifdef TEXCOORD_SECONDARY\ndE=vTexCoord2;\n#endif\n}",
  6515. "postaa.glsl": "precision mediump float;uniform sampler2D tInput;varying vec2 j;void main(void){gl_FragColor=texture2D(tInput,j);}",
  6516. "postfrag.glsl": "precision mediump float;uniform sampler2D tInput;\n#ifdef BLOOM\nuniform sampler2D tBloom;\n#endif\n#ifdef GRAIN\nuniform sampler2D tGrain;\n#endif\n#ifdef COLOR_LUT\nuniform sampler2D tLUT;\n#endif\nuniform vec3 uScale;uniform vec3 uBias;uniform vec3 uSaturation;uniform vec4 uSharpenKernel;uniform vec3 uSharpness;uniform vec3 uBloomColor;uniform vec4 uVignetteAspect;uniform vec4 uVignette;uniform vec4 uGrainCoord;uniform vec2 uGrainScaleBias;varying vec2 j;vec3 iY(vec3 c){vec3 iZ=sqrt(c);return(iZ-iZ*c)+c*(0.4672*c+vec3(0.5328));}void main(void){vec4 jc=texture2D(tInput,j);vec3 c=jc.xyz;\n#ifdef SHARPEN\nvec3 hM=texture2D(tInput,j+uSharpenKernel.xy).xyz;hM+=texture2D(tInput,j-uSharpenKernel.xy).xyz;hM+=texture2D(tInput,j+uSharpenKernel.zw).xyz;hM+=texture2D(tInput,j-uSharpenKernel.zw).xyz;vec3 jd=uSharpness.x*c-uSharpness.y*hM;c+=clamp(jd,-uSharpness.z,uSharpness.z);\n#endif\n#ifdef BLOOM\nc+=uBloomColor*texture2D(tBloom,j).xyz;\n#endif\n#ifdef VIGNETTE\nvec2 je=j*uVignetteAspect.xy-uVignetteAspect.zw;vec3 v=clamp(vec3(1.0,1.0,1.0)-uVignette.xyz*dot(je,je),0.0,1.0);vec3 jf=v*v;jf*=v;c*=mix(v,jf,uVignette.w);\n#endif\n#ifdef SATURATION\nfloat gray=dot(c,vec3(0.3,0.59,0.11));c=mix(vec3(gray,gray,gray),c,uSaturation);\n#endif\n#ifdef CONTRAST\nc=c*uScale+uBias;\n#endif\n#ifdef GRAIN\nfloat jh=uGrainScaleBias.x*texture2D(tGrain,j*uGrainCoord.xy+uGrainCoord.zw).x+uGrainScaleBias.y;c+=c*jh;\n#endif\n#ifdef REINHARD\n{c*=1.8;float ji=dot(c,vec3(0.3333));c=clamp(c/(1.0+ji),0.0,1.0);}\n#elif defined(HEJL)\n{const highp float jj=0.22,jk=0.3,jl=.1,jm=0.2,jn=.01,jo=0.3;const highp float ju=1.25;highp vec3 eO=max(vec3(0.0),c-vec3(.004));c=(eO*((ju*jj)*eO+ju*vec3(jl*jk,jl*jk,jl*jk))+ju*vec3(jm*jn,jm*jn,jm*jn))/(eO*(jj*eO+vec3(jk,jk,jk))+vec3(jm*jo,jm*jo,jm*jo))-ju*vec3(jn/jo,jn/jo,jn/jo);}\n#endif\n#ifdef COLOR_LUT\nc=clamp(c,0.0,1.0);c=(255.0/256.0)*c+vec3(0.5/256.0);c.x=texture2D(tLUT,c.xx).x;c.y=texture2D(tLUT,c.yy).y;c.z=texture2D(tLUT,c.zz).z;c*=c;\n#endif\ngl_FragColor.xyz=iY(c);gl_FragColor.w=jc.w;}",
  6517. "postvert.glsl": "precision highp float;attribute vec2 vCoord;varying vec2 j;void main(void){j=vCoord;gl_Position.xy=2.0*vCoord-vec2(1.0,1.0);gl_Position.zw=vec2(0.0,1.0);}",
  6518. "shadowfloorfrag.glsl": "precision mediump float;varying highp vec3 dv;varying mediump vec2 jv;varying mediump vec3 dC;uniform vec3 uShadowCatcherParams;\n#ifdef LIGHT_COUNT\nuniform vec4 uLightPositions[LIGHT_COUNT];uniform vec3 uLightDirections[LIGHT_COUNT];uniform vec3 uLightColors[LIGHT_COUNT];uniform vec3 uLightParams[LIGHT_COUNT];uniform vec3 uLightSpot[LIGHT_COUNT];\n#endif\n#define saturate(x) clamp( x, 0.0, 1.0 )\n#define SHADOW_COMPARE(a,b) ((a) < (b) || (b) >= 1.0 ? 1.0 : 0.0)\n#define SHADOW_CLIP(c,v) ((c.x<0.0 || c.x>1.0 || c.y<0.0 || c.y>1.0) ? 1.0 : v)\n#include <matshadows.glsl>\nvoid main(void){ev eA;eB(eA,SHADOW_KERNEL);vec3 jA=vec3(0.0,0.0,0.0);vec3 jB=vec3(0.0,0.0,0.0);for(int k=0;k<SHADOW_COUNT;++k){vec3 eH=uLightPositions[k].xyz-dv*uLightPositions[k].w;float eI=inversesqrt(dot(eH,eH));eH*=eI;float a=saturate(uLightParams[k].z/eI);a=1.0+a*(uLightParams[k].x+uLightParams[k].y*a);float s=saturate(dot(eH,uLightDirections[k]));s=saturate(uLightSpot[k].y-uLightSpot[k].z*(1.0-s*s));vec3 jC=mix(uLightColors[k].xyz,vec3(1.0,1.0,1.0),uShadowCatcherParams.x);vec3 jD=(a*s)*jC;jD*=saturate(dot(eH,dC));jB+=jD;jA+=jD*eA.eL[k];}float jE=1.0e-4;vec3 r=(jA+jE)/(jB+jE);float jF=saturate(dot(jv,jv))*uShadowCatcherParams.z;r=mix(r,vec3(1.0,1.0,1.0),jF);r=mix(vec3(1.0,1.0,1.0),r,uShadowCatcherParams.y);gl_FragColor.xyz=r;gl_FragColor.w=1.0;}",
  6519. "shadowfloorvert.glsl": "precision highp float;uniform mat4 uModelViewProjectionMatrix;uniform mat4 uModelSkyMatrix;uniform float uScale;attribute vec3 vPosition;varying highp vec3 dv;varying mediump vec2 jv;varying mediump vec3 dC;vec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}void main(void){jv=vPosition.xz;dC=normalize(uModelSkyMatrix[1].xyz);dv=h(uModelSkyMatrix,vPosition).xyz;gl_Position=h(uModelViewProjectionMatrix,vPosition);}",
  6520. "shadowfrag.glsl": "precision highp float;varying vec2 jG;\n#ifdef ALPHA_TEST\nvarying mediump vec2 d;uniform sampler2D tAlbedo;\n#endif\nvec3 jH(float v){vec4 jI=vec4(1.0,255.0,65025.0,16581375.0)*v;jI=fract(jI);jI.xyz-=jI.yzw*(1.0/255.0);return jI.xyz;}void main(void){\n#ifdef ALPHA_TEST\nfloat e=texture2D(tAlbedo,d).a;if(e<0.5){discard;}\n#endif\n#ifdef SHADOW_NATIVE_DEPTH\ngl_FragColor.xyz=vec3(0.0,0.0,0.0);\n#else\ngl_FragColor.xyz=jH((jG.x/jG.y)*0.5+0.5);\n#endif\ngl_FragColor.w=0.0;}",
  6521. "shadowvert.glsl": "precision highp float;attribute vec3 vPosition;attribute vec2 vTexCoord;uniform mat4 uMeshTransform;uniform mat4 uViewProjection;varying vec2 jG;\n#ifdef ALPHA_TEST\nvarying mediump vec2 d;uniform vec2 uUVOffset;\n#endif\nvec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}void main(void){vec3 p=h(uMeshTransform,vPosition).xyz;gl_Position=h(uViewProjection,p);jG=gl_Position.zw;\n#ifdef ALPHA_TEST\nd=vTexCoord+uUVOffset;\n#endif\n}",
  6522. "sky.glsl": "precision highp float;uniform sampler2D tSkyTexture;uniform float uAlpha;varying vec2 d;void main(void){vec3 r=texture2D(tSkyTexture,d).xyz;gl_FragColor.xyz=r*r;gl_FragColor.w=uAlpha;}",
  6523. "skySH.glsl": "precision mediump float;uniform vec4 uSkyCoefficients[9];uniform float uAlpha;varying vec3 jJ;void main(void){vec3 G=normalize(jJ);vec3 r=uSkyCoefficients[0].xyz;r+=uSkyCoefficients[1].xyz*G.y;r+=uSkyCoefficients[2].xyz*G.z;r+=uSkyCoefficients[3].xyz*G.x;vec3 swz=G.yyz*G.xzx;r+=uSkyCoefficients[4].xyz*swz.x;r+=uSkyCoefficients[5].xyz*swz.y;r+=uSkyCoefficients[7].xyz*swz.z;vec3 sqr=G*G;r+=uSkyCoefficients[6].xyz*(3.0*sqr.z-1.0);r+=uSkyCoefficients[8].xyz*(sqr.x-sqr.y);gl_FragColor.xyz=r;gl_FragColor.w=uAlpha;}",
  6524. "skyvert.glsl": "precision highp float;uniform mat4 uInverseSkyMatrix;uniform mat4 uViewProjection;attribute vec3 vPosition;attribute vec2 vTexCoord;\n#if SKYMODE == 3\nvarying vec3 jJ;\n#else\nvarying vec2 d;\n#endif\nvec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}vec4 u(mat4 i,vec3 v){return i[0]*v.x+i[1]*v.y+i[2]*v.z;}void main(void){vec3 p=h(uInverseSkyMatrix,vPosition).xyz;gl_Position=u(uViewProjection,p);gl_Position.z-=(1.0/65535.0)*gl_Position.w;\n#if SKYMODE == 3\njJ=vPosition;jJ.xy+=1e-20*vTexCoord;\n#else\nd=vTexCoord;\n#endif\n}",
  6525. "wirefrag.glsl": "precision highp float;uniform vec4 uStripParams;void main(void){vec2 c=gl_FragCoord.xy*uStripParams.xy-vec2(1.0,1.0);c.x+=0.25*c.y;float a=c.x<uStripParams.z?0.0:0.9;a=c.x<uStripParams.w?a:0.0;gl_FragColor=vec4(0.0,0.0,0.0,a);}",
  6526. "wirevert.glsl": "precision highp float;uniform mat4 uModelViewProjectionMatrix;attribute vec3 vPosition;vec4 h(mat4 i,vec3 p){return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));}void main(void){gl_Position=h(uModelViewProjectionMatrix,vPosition);gl_Position.z+=-0.00005*gl_Position.w;}",
  6527. nil: ""
  6528. }
  6529. }(fdage);