4dage.js 351 KB

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